Browse Source

feat():add internal inserted (#490)

Co-authored-by: EMqmyd <mayuedong@emx.io>
EMQmyd 4 years atrás
parent
commit
ff215f0473
3 changed files with 35 additions and 0 deletions
  1. 13 0
      plugins/funcMeta.go
  2. 11 0
      plugins/sinkMeta.go
  3. 11 0
      plugins/sourceMeta.go

+ 13 - 0
plugins/funcMeta.go

@@ -29,6 +29,15 @@ type (
 	}
 )
 
+func isInternalFunc(fiName string) bool {
+	internal := []string{`accumulateWordCount.json`, `countPlusOne.json`, `echo.json`, `internal.json`}
+	for _, v := range internal {
+		if v == fiName {
+			return true
+		}
+	}
+	return false
+}
 func newUiFuncs(fi *fileFuncs) *uiFuncs {
 	if nil == fi {
 		return nil
@@ -72,6 +81,8 @@ func (m *Manager) readFuncMetaDir() error {
 		}
 		if nil == fis.About {
 			return fmt.Errorf("not found about of %s", filePath)
+		} else if isInternalFunc(fname) {
+			fis.About.Installed = true
 		} else {
 			_, fis.About.Installed = m.registry.Get(FUNCTION, strings.TrimSuffix(fname, `.json`))
 		}
@@ -90,6 +101,8 @@ func (m *Manager) readFuncMetaFile(filePath string) error {
 	}
 	if nil == fis.About {
 		return fmt.Errorf("not found about of %s", filePath)
+	} else if isInternalFunc(fiName) {
+		fis.About.Installed = true
 	} else {
 		_, fis.About.Installed = m.registry.Get(FUNCTION, strings.TrimSuffix(fiName, `.json`))
 	}

+ 11 - 0
plugins/sinkMeta.go

@@ -83,6 +83,15 @@ type (
 	}
 )
 
+func isInternalSink(fiName string) bool {
+	internal := []string{`edgex.json`, `log.json`, `mqtt.json`, `nop.json`, `rest.json`}
+	for _, v := range internal {
+		if v == fiName {
+			return true
+		}
+	}
+	return false
+}
 func newLanguage(fi *fileLanguage) *language {
 	if nil == fi {
 		return nil
@@ -184,6 +193,8 @@ func (m *Manager) readSinkMetaFile(filePath string) error {
 	if pluginName != baseProperty && pluginName != baseOption {
 		if nil == metadata.About {
 			return fmt.Errorf("not found about of %s", finame)
+		} else if isInternalSink(finame) {
+			metadata.About.Installed = true
 		} else {
 			_, metadata.About.Installed = m.registry.Get(SINK, pluginName)
 		}

+ 11 - 0
plugins/sourceMeta.go

@@ -27,6 +27,15 @@ type (
 	}
 )
 
+func isInternalSource(fiName string) bool {
+	internal := []string{`edgex.json`, `httppull.json`, `mqtt_source.json`}
+	for _, v := range internal {
+		if v == fiName {
+			return true
+		}
+	}
+	return false
+}
 func newUiSource(fi *fileSource) (*uiSource, error) {
 	if nil == fi {
 		return nil, nil
@@ -60,6 +69,8 @@ func (m *Manager) readSourceMetaFile(filePath string) error {
 	}
 	if nil == ptrMeta.About {
 		return fmt.Errorf("not found about of %s", filePath)
+	} else if isInternalSource(fileName) {
+		ptrMeta.About.Installed = true
 	} else {
 		_, ptrMeta.About.Installed = m.registry.Get(SOURCE, strings.TrimSuffix(fileName, `.json`))
 	}