From a38ffd7fae7f7a9f8fd88bf3fd90a7f3d672d144 Mon Sep 17 00:00:00 2001
From: Malte Bauch <malte.bauch@stud.h-da.de>
Date: Tue, 21 Mar 2023 16:18:53 +0100
Subject: [PATCH] clean up comments

---
 cli/cmd/networkElementCreate.go               |  4 ++-
 cli/cmd/prompt.go                             |  7 +++--
 controller/interfaces/transport/transport.go  |  1 -
 controller/mocks/NetworkElement.go            |  7 -----
 controller/mocks/Plugin.go                    | 26 +++++++++++++++++++
 .../server/configurationmanagement.go         | 12 ++-------
 controller/nucleus/plugin.go                  |  1 -
 7 files changed, 34 insertions(+), 24 deletions(-)

diff --git a/cli/cmd/networkElementCreate.go b/cli/cmd/networkElementCreate.go
index eeb8c1519..c16d2acac 100644
--- a/cli/cmd/networkElementCreate.go
+++ b/cli/cmd/networkElementCreate.go
@@ -96,12 +96,14 @@ var mneName string
 var opcode string
 var pluginID string
 
+var pluginIDFlagName = "plugin-id"
+
 func init() {
 	networkElementCmd.AddCommand(networkElementCreateCmd)
 
 	networkElementCreateCmd.Flags().StringVar(&mneName, "name", "", "add a network element name (optional)")
 	networkElementCreateCmd.Flags().StringVar(&opcode, "type", "", "generation target (csbi or plugin)")
-	networkElementCreateCmd.Flags().StringVar(&pluginID, "plugin-id", "", "the plugin ID of the plugin to be used")
+	networkElementCreateCmd.Flags().StringVar(&pluginID, pluginIDFlagName, "", "the plugin ID of the plugin to be used")
 	networkElementCreateCmd.Flags().StringVarP(&address, "address", "a", "", "address of a gnmi target, e.g. 192.168.1.1:6030")
 	networkElementCreateCmd.Flags().StringVarP(&username, "username", "u", "", "username for a gnmi resource")
 	networkElementCreateCmd.Flags().StringVarP(&password, "password", "p", "", "password for a gnmi resource")
diff --git a/cli/cmd/prompt.go b/cli/cmd/prompt.go
index 00309d410..945c6d78d 100644
--- a/cli/cmd/prompt.go
+++ b/cli/cmd/prompt.go
@@ -220,10 +220,9 @@ func completionBasedOnCmd(c *PromptCompleter, cmd *cobra.Command, inputSplit []s
 		}
 	case networkElementCreateCmd:
 		if len(inputFlags) != 0 {
-			// TODO: remove hardcoded `plugin-id`
-			if inputFlags[len(inputFlags)-1] == "--plugin-id" &&
-				((inputSplit[len(inputSplit)-1] == "--plugin-id" && d.GetWordBeforeCursor() == "") ||
-					(inputSplit[len(inputSplit)-2] == "--plugin-id" && d.GetWordBeforeCursor() != "")) {
+			if inputFlags[len(inputFlags)-1] == pluginIDFlagName &&
+				((inputSplit[len(inputSplit)-1] == pluginIDFlagName && d.GetWordBeforeCursor() == "") ||
+					(inputSplit[len(inputSplit)-2] == pluginIDFlagName && d.GetWordBeforeCursor() != "")) {
 				return c.updateSuggestionsThroughFunc(d, getAvailablePlugins)
 			} else {
 				return cobraCommandCompletion(cmd, d, inputFlags, []prompt.Suggest{})
diff --git a/controller/interfaces/transport/transport.go b/controller/interfaces/transport/transport.go
index b34823b74..c93927873 100644
--- a/controller/interfaces/transport/transport.go
+++ b/controller/interfaces/transport/transport.go
@@ -14,7 +14,6 @@ import (
 type Transport interface {
 	Get(ctx context.Context, params ...string) (any, error)
 	Set(ctx context.Context, payload change.Payload, path string, plugin plugin.Plugin) error
-	// TODO: add delete
 	CustomSet(ctx context.Context, req *gpb.SetRequest) (*gpb.SetResponse, error)
 	Subscribe(ctx context.Context, params ...string) error
 	ControlPlaneSubscribe(ctx context.Context, subscribeCallbackFunc HandleSubscribeResponse,
diff --git a/controller/mocks/NetworkElement.go b/controller/mocks/NetworkElement.go
index 078605421..193cea4e1 100644
--- a/controller/mocks/NetworkElement.go
+++ b/controller/mocks/NetworkElement.go
@@ -13,8 +13,6 @@ import (
 	transport "code.fbi.h-da.de/danet/gosdn/controller/interfaces/transport"
 
 	uuid "github.com/google/uuid"
-
-	ygot "github.com/openconfig/ygot/ygot"
 )
 
 // NetworkElement is an autogenerated mock type for the NetworkElement type
@@ -186,11 +184,6 @@ func (_m *NetworkElement) ProcessResponse(_a0 protoreflect.ProtoMessage) error {
 	return r0
 }
 
-// SetModel provides a mock function with given fields: _a0
-func (_m *NetworkElement) SetModel(_a0 ygot.GoStruct) {
-	_m.Called(_a0)
-}
-
 // Transport provides a mock function with given fields:
 func (_m *NetworkElement) Transport() transport.Transport {
 	ret := _m.Called()
diff --git a/controller/mocks/Plugin.go b/controller/mocks/Plugin.go
index 91229e732..fe8817b99 100644
--- a/controller/mocks/Plugin.go
+++ b/controller/mocks/Plugin.go
@@ -179,6 +179,32 @@ func (_m *Plugin) Ping() error {
 	return r0
 }
 
+// PruneConfigFalse provides a mock function with given fields: value
+func (_m *Plugin) PruneConfigFalse(value []byte) ([]byte, error) {
+	ret := _m.Called(value)
+
+	var r0 []byte
+	var r1 error
+	if rf, ok := ret.Get(0).(func([]byte) ([]byte, error)); ok {
+		return rf(value)
+	}
+	if rf, ok := ret.Get(0).(func([]byte) []byte); ok {
+		r0 = rf(value)
+	} else {
+		if ret.Get(0) != nil {
+			r0 = ret.Get(0).([]byte)
+		}
+	}
+
+	if rf, ok := ret.Get(1).(func([]byte) error); ok {
+		r1 = rf(value)
+	} else {
+		r1 = ret.Error(1)
+	}
+
+	return r0, r1
+}
+
 // Restart provides a mock function with given fields:
 func (_m *Plugin) Restart() error {
 	ret := _m.Called()
diff --git a/controller/northbound/server/configurationmanagement.go b/controller/northbound/server/configurationmanagement.go
index bf99180c7..f6a86f489 100644
--- a/controller/northbound/server/configurationmanagement.go
+++ b/controller/northbound/server/configurationmanagement.go
@@ -80,15 +80,6 @@ func (c ConfigurationManagementServer) ExportSDNConfig(ctx context.Context, requ
 
 	networkElements := pnd.NetworkElements()
 
-	// TODO: check if this is really necessary
-	//for _, networkElement := range networkElements {
-	//	model, err := networkElement.GetModelAsFilteredCopy()
-	//	if err != nil {
-	//		return nil, err
-	//	}
-	//	//networkElement.SetModel(model)
-	//}
-
 	sdnConfig.NetworkElements = networkElements
 
 	sdnConfig.Nodes, err = c.nodeService.GetAll()
@@ -323,7 +314,8 @@ func (c ConfigurationManagementServer) createNetworkElements(sdnConfig *loadedSD
 			TransportOption: &tpb.TransportOption_GnmiTransportOption{
 				GnmiTransportOption: &tpb.GnmiTransportOption{},
 			},
-			// TODO: change TransportOption - type is not needed
+			// TODO: change TransportOption - type is not needed; this should
+			// be removed as soon as we remove the csbi device type
 			Type: spb.Type_TYPE_OPENCONFIG,
 		}
 		_, err := pnd.AddNetworkElement(
diff --git a/controller/nucleus/plugin.go b/controller/nucleus/plugin.go
index faff75b29..27384db2a 100644
--- a/controller/nucleus/plugin.go
+++ b/controller/nucleus/plugin.go
@@ -164,7 +164,6 @@ func (p *Plugin) Ping() error {
 // UpdatePlugin updates a given Plugin. Therefore the version of the
 // `plugin.yml` manifest file is compared to the version in use. If a new
 // version is within the plugin folder, the new version of the plugin is built.
-// NOTE:This should only be used with caution.
 func UpdatePlugin(p plugin.Plugin) (updated bool, err error) {
 	return false, fmt.Errorf("not implemented yet")
 }
-- 
GitLab