diff --git a/.gitignore b/.gitignore index 83d7fcf53ce03d7dcb7af95d784535e225453b15..2dcac5e10f703e04f4b9194574241f179273f837 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ test/.terraform.local/ configs/gosdn.toml api/api_test.toml debug.test + +# Binary +gosdn diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 359c58968b128ab6a8e042c920da771253235b4e..391afe1b0cce65bd4d29734d34e8fae853075e2e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,14 +2,6 @@ variables: SECURE_ANALYZERS_PREFIX: registry.gitlab.com/gitlab-org/security-products/analyzers DOCKER_IMAGE_SHA: "${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA}" -workflow: - rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - - if: '$CI_PIPELINE_SOURCE == "schedule"' - - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH != "develop" && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH' - when: never - - if: '$CI_COMMIT_BRANCH' - stages: - .pre - build @@ -19,15 +11,22 @@ stages: - deploy - .post +workflow: + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + when: never + - when: always + default: before_script: - git config --global url."https://$GO_MODULES_USER:$GO_MODULES_ACCESS_TOKEN@code.fbi.h-da.de".insteadOf "https://code.fbi.h-da.de" include: - - local: '/build/ci/.code-quality-ci.yml' - - local: '/build/ci/.security-and-compliance-ci.yml' - - local: '/build/ci/.build-container.yml' - - local: '/build/ci/.test.yml' - - local: '/build/ci/.containerlab-ci.yml' - - local: '/build/ci/.uml-autogen-ci.yml' - - local: '/build/ci/.deploy-k8s.yml' + - local: '/.gitlab/ci/.build-container.yml' + - local: '/.gitlab/ci/.code-quality-ci.yml' + - local: '/.gitlab/ci/.security-and-compliance-ci.yml' + - local: '/.gitlab/ci/.test.yml' + - local: '/.gitlab/ci/.containerlab-ci.yml' + - local: '/.gitlab/ci/.integration-test.yml' + - local: '/.gitlab/ci/.uml-autogen-ci.yml' + - local: '/.gitlab/ci/.deploy-k8s.yml' diff --git a/build/ci/.build-container.yml b/.gitlab/ci/.build-container.yml similarity index 61% rename from build/ci/.build-container.yml rename to .gitlab/ci/.build-container.yml index 4631379e13ce426f68e53e45a0cbededb75f6d37..85c948fd1dbcc61b041e6320ab11864be283a4ff 100644 --- a/build/ci/.build-container.yml +++ b/.gitlab/ci/.build-container.yml @@ -7,32 +7,23 @@ build-docker: stage: build allow_failure: false needs: [] + variables: + TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH tags: - shell-builder rules: - - if: $CI_COMMIT_BRANCH == "develop" && $CI_NIGHTLY == null - variables: - TAG: $CI_REGISTRY_IMAGE:develop - BUILDARGS: -race - - if: $CI_NIGHTLY == "develop" - variables: - TAG: $CI_REGISTRY_IMAGE:nightly-develop - BUILDARGS: -race - - if: $CI_NIGHTLY == "mainline" - variables: - TAG: $CI_REGISTRY_IMAGE:nightly - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - variables: - TAG: $CI_REGISTRY_IMAGE:merge-request - BUILDARGS: -race - - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_NIGHTLY == null + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH variables: TAG: $CI_REGISTRY_IMAGE:latest - - if: '$CI_COMMIT_BRANCH' + - if: $CI_COMMIT_BRANCH == "develop" variables: - TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH - + TAG: $CI_REGISTRY_IMAGE:develop + BUILDARGS: -race + - when: always + - variables: + TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME + script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker build --build-arg GITLAB_USER=$GO_MODULES_USER --build-arg GITLAB_TOKEN=$GO_MODULES_ACCESS_TOKEN --build-arg BUILDARGS=$BUILDARGS -t $DOCKER_IMAGE_SHA . diff --git a/.gitlab/ci/.code-quality-ci.yml b/.gitlab/ci/.code-quality-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..3236cb127f9c0073307f045f41f6313297622e88 --- /dev/null +++ b/.gitlab/ci/.code-quality-ci.yml @@ -0,0 +1,11 @@ +code-quality: + image: golangci/golangci-lint:latest-alpine + stage: test + script: + # writes golangci-lint output to gl-code-quality-report.json + - golangci-lint run --config .gitlab/ci/.golangci-config/.golangci.yml --out-format code-climate | tee gl-code-quality-report.json + artifacts: + reports: + codequality: gl-code-quality-report.json + paths: + - gl-code-quality-report.json diff --git a/build/ci/.containerlab-ci.yml b/.gitlab/ci/.containerlab-ci.yml similarity index 63% rename from build/ci/.containerlab-ci.yml rename to .gitlab/ci/.containerlab-ci.yml index db038c76a60d1f4f5d396f551dd30df08c95aabf..0c2c18c7bee3cc486eabf75020c92293876ebe70 100644 --- a/build/ci/.containerlab-ci.yml +++ b/.gitlab/ci/.containerlab-ci.yml @@ -11,7 +11,7 @@ variables: - shell before_script: - cd ${CLAB_DIR} - - export PATH="${PATH}:${CI_PROJECT_DIR}/build/ci/scripts" + - export PATH="${PATH}:${CI_PROJECT_DIR}/.gitlab/ci/scripts" - echo "$CI_REGISTRY_PASSWORD" | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY - echo ${GOSDN_CONTAINER_IMAGE} - docker pull ${GOSDN_CONTAINER_IMAGE} @@ -21,7 +21,7 @@ variables: image: alpine:latest stage: build before_script: - - export PATH="${PATH}:${CI_PROJECT_DIR}/build/ci/scripts" + - export PATH="${PATH}:${CI_PROJECT_DIR}/.gitlab/ci/scripts" - firstOctet=$(generate_octet.sh $CI_COMMIT_SHA) - secondOctet=$(generate_octet.sh $CI_PIPELINE_ID) - export CLAB_MGMT_SUBNET="172.$firstOctet.$secondOctet.0/24" @@ -43,10 +43,6 @@ containerlab:template:integration: extends: .containerlab_template variables: CLAB_TEMPLATE: "${CI_PROJECT_DIR}/test/containerlab/int01.clab.tmpl.yml" - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'develop') - - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - - if: $CI_NIGHTLY containerlab:deploy:integration: @@ -64,16 +60,13 @@ containerlab:deploy:integration: artifacts: reports: dotenv: ${CI_PROJECT_DIR}/build.env - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'develop') - - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - - if: $CI_NIGHTLY containerlab:destroy: stage: .post tags: - shell + needs: ["containerlab:deploy:integration", "integration-test:nucleus", "integration-test:api", "containerlab:template:integration"] before_script: - cd ${CLAB_DIR} script: @@ -81,36 +74,30 @@ containerlab:destroy: - docker volume rm -f ${CLAB_NAME}-volume - docker image rm -f ${GOSDN_CONTAINER_IMAGE} allow_failure: true - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'develop') - when: always - - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - when: always - - if: $CI_NIGHTLY - when: always + when: always -containerlab:template:develop: - extends: .containerlab_template - variables: - CLAB_NAME: "dev" - CLAB_TEMPLATE: "${CI_PROJECT_DIR}/test/containerlab/dev.clab.tmpl.yml" - GOSDN_CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE:develop" - rules: - - if: $CI_COMMIT_BRANCH == 'develop' && $CI_NIGHTLY == null - - -containerlab:deploy:develop: - extends: - - .containerlab_deploy - needs: ["containerlab:template:develop", "build-docker"] - variables: - CLAB_NAME: "dev" - GOSDN_CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE:develop" - script: - - sudo containerlab deploy --topo ${CI_PROJECT_DIR}/${CLAB_NAME}.clab.yml --reconfigure - rules: - - if: $CI_COMMIT_BRANCH == 'develop' && $CI_NIGHTLY == null +#containerlab:template:develop: +# extends: .containerlab_template +# variables: +# CLAB_NAME: "dev" +# CLAB_TEMPLATE: "${CI_PROJECT_DIR}/test/containerlab/dev.clab.tmpl.yml" +# GOSDN_CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE:develop" +# rules: +# - if: $CI_COMMIT_BRANCH == 'develop' && $CI_NIGHTLY == null +# +# +#containerlab:deploy:develop: +# extends: +# - .containerlab_deploy +# needs: ["containerlab:template:develop", "build-docker"] +# variables: +# CLAB_NAME: "dev" +# GOSDN_CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE:develop" +# script: +# - sudo containerlab deploy --topo ${CI_PROJECT_DIR}/${CLAB_NAME}.clab.yml --reconfigure +# rules: +# - if: $CI_COMMIT_BRANCH == 'develop' && $CI_NIGHTLY == null containerlab:clean: diff --git a/build/ci/.deploy-k8s.yml b/.gitlab/ci/.deploy-k8s.yml similarity index 100% rename from build/ci/.deploy-k8s.yml rename to .gitlab/ci/.deploy-k8s.yml diff --git a/build/ci/.golangci-config/.golangci.yml b/.gitlab/ci/.golangci-config/.golangci.yml similarity index 100% rename from build/ci/.golangci-config/.golangci.yml rename to .gitlab/ci/.golangci-config/.golangci.yml diff --git a/build/ci/.golangci-config/.runlint.sh b/.gitlab/ci/.golangci-config/.runlint.sh similarity index 100% rename from build/ci/.golangci-config/.runlint.sh rename to .gitlab/ci/.golangci-config/.runlint.sh diff --git a/.gitlab/ci/.integration-test.yml b/.gitlab/ci/.integration-test.yml new file mode 100644 index 0000000000000000000000000000000000000000..49ce918e3f88db7fff8fccbdd156c9f8f828d817 --- /dev/null +++ b/.gitlab/ci/.integration-test.yml @@ -0,0 +1,31 @@ +.integration-test: &integration-test + image: ${CI_REGISTRY_IMAGE}:testing_${CI_PIPELINE_ID} + stage: integration-test + needs: + - job: "containerlab:deploy:integration" + variables: + GOSDN_LOG: "nolog" + GOSDN_TEST_API_ENDPOINT: "141.100.70.178:${GOSDN_GRPC_PORT}" + GOSDN_TEST_ENDPOINT: "141.100.70.178:${CEOS1_PORT}" + GOSDN_TEST_USER: "admin" + GOSDN_TEST_PASSWORD: "admin" + + +integration-test:nucleus: + <<: *integration-test + script: + - ${CI_PROJECT_DIR}/.gitlab/ci/scripts/wait-for-it.sh ${GOSDN_TEST_ENDPOINT} -s -t 180 -- echo "CEOS is up" + - sleep 30 + - cd ./test/integration + - go test -race -v -run TestGnmi_SetIntegration + - go test -race -v -run TestGnmi_GetIntegration + - go test -race -v -run TestGnmi_SubscribeIntegration + - go test -race -v -run TestGnmi_CapabilitiesIntegration + +integration-test:api: + <<: *integration-test + variables: + K8S_OP: "getenv" + script: + - cd ./api + - go test -race -v -run TestApiIntegration diff --git a/build/ci/.security-and-compliance-ci.yml b/.gitlab/ci/.security-and-compliance-ci.yml similarity index 100% rename from build/ci/.security-and-compliance-ci.yml rename to .gitlab/ci/.security-and-compliance-ci.yml diff --git a/.gitlab/ci/.test.yml b/.gitlab/ci/.test.yml new file mode 100644 index 0000000000000000000000000000000000000000..b8cbe03a7fd44af3bc9ba4513e1e99c7c37416ac --- /dev/null +++ b/.gitlab/ci/.test.yml @@ -0,0 +1,19 @@ +.test: &test + image: ${CI_REGISTRY_IMAGE}:testing_${CI_PIPELINE_ID} + stage: test + variables: + GOSDN_LOG: "nolog" + GOSDN_CHANGE_TIMEOUT: "100ms" + +unit-test: + script: + - go test -short -race $(go list ./... | grep -v /forks/ | grep -v /mocks ) -v -coverprofile=coverage.out + after_script: + - go tool cover -func=coverage.out + <<: *test + +controller-test: + image: golang:1.16 + script: + - go test -race -v -run TestRun + <<: *test diff --git a/build/ci/.uml-autogen-ci.yml b/.gitlab/ci/.uml-autogen-ci.yml similarity index 100% rename from build/ci/.uml-autogen-ci.yml rename to .gitlab/ci/.uml-autogen-ci.yml diff --git a/build/ci/scripts/docker_host_port b/.gitlab/ci/scripts/docker_host_port similarity index 100% rename from build/ci/scripts/docker_host_port rename to .gitlab/ci/scripts/docker_host_port diff --git a/build/ci/scripts/generate_octet.sh b/.gitlab/ci/scripts/generate_octet.sh similarity index 93% rename from build/ci/scripts/generate_octet.sh rename to .gitlab/ci/scripts/generate_octet.sh index 6cad5addc30badad963ee2e9d6dfe4f96fdc6aad..9d5dce7312a7ab516bd01d208ac961d5e23fe955 100755 --- a/build/ci/scripts/generate_octet.sh +++ b/.gitlab/ci/scripts/generate_octet.sh @@ -10,4 +10,4 @@ decimal_value=${decimal_value/-/} octet=$(((decimal_value % 255))) -echo -n $octet \ No newline at end of file +echo -n $octet diff --git a/build/ci/scripts/wait-for-it.sh b/.gitlab/ci/scripts/wait-for-it.sh similarity index 100% rename from build/ci/scripts/wait-for-it.sh rename to .gitlab/ci/scripts/wait-for-it.sh diff --git a/api/api_test.go b/api/api_test.go index a55113c1a25364a28e251e9fd200cecf408dafce..a3f722da0509f09585d713520a0274ec5a39c5ce 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -72,7 +72,6 @@ func Test_CommitConfirm(t *testing.T) { return } log.Info(resp) - } func Test_AddDevice(t *testing.T) { diff --git a/api/initialise_test.go b/api/initialise_test.go index 7a7429a96db3b2997f70b4ef3e4bddcfcb336ea9..c6a00cc2770e63cea87b577fe61c223e292a9c05 100644 --- a/api/initialise_test.go +++ b/api/initialise_test.go @@ -112,7 +112,6 @@ func bufDialer(context.Context, string) (net.Conn, error) { return lis.Dial() } -const unreachable = "203.0.113.10:6030" const testPath = "/system/config/hostname" var testAddress = "141.100.70.170:6030" diff --git a/build/ci/.code-quality-ci.yml b/build/ci/.code-quality-ci.yml deleted file mode 100644 index a608dd15e896e417aa25e19ee8657c037aa3e75e..0000000000000000000000000000000000000000 --- a/build/ci/.code-quality-ci.yml +++ /dev/null @@ -1,15 +0,0 @@ -code-quality: - image: golangci/golangci-lint:latest-alpine - stage: test - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" - - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - - if: $CI_COMMIT_BRANCH == "develop" - script: - # writes golangci-lint output to gl-code-quality-report.json - - golangci-lint run --config build/ci/.golangci-config/.golangci.yml --out-format code-climate | tee gl-code-quality-report.json - artifacts: - reports: - codequality: gl-code-quality-report.json - paths: - - gl-code-quality-report.json diff --git a/build/ci/.test.yml b/build/ci/.test.yml deleted file mode 100644 index 9531c7717b98bc8d4da7f7aa748247827ce54c53..0000000000000000000000000000000000000000 --- a/build/ci/.test.yml +++ /dev/null @@ -1,61 +0,0 @@ -.integration-test: &integration-test - image: ${CI_REGISTRY_IMAGE}:testing_${CI_PIPELINE_ID} - stage: integration-test - needs: - - job: "containerlab:deploy:integration" - variables: - GOSDN_LOG: "nolog" - GOSDN_TEST_API_ENDPOINT: "141.100.70.178:${GOSDN_GRPC_PORT}" - GOSDN_TEST_ENDPOINT: "141.100.70.178:${CEOS1_PORT}" - GOSDN_TEST_USER: "admin" - GOSDN_TEST_PASSWORD: "admin" - rules: - - if: $CI_NIGHTLY - - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH - - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH - allow_failure: true - -integration-test:nucleus: - <<: *integration-test - script: - - ${CI_PROJECT_DIR}/build/ci/scripts/wait-for-it.sh ${GOSDN_TEST_ENDPOINT} -s -t 180 -- echo "CEOS is up" - - cd ./test/integration - - go test -race -v -run TestGnmi_SetIntegration - - go test -race -v -run TestGnmi_GetIntegration - - go test -race -v -run TestGnmi_SubscribeIntegration - - go test -race -v -run TestGnmi_CapabilitiesIntegration - -integration-test:api: - <<: *integration-test - variables: - K8S_OP: "getenv" - script: - - cd ./api - - go test -race -v -run TestApiIntegration - -.test: &test - image: ${CI_REGISTRY_IMAGE}:testing_${CI_PIPELINE_ID} - stage: test - allow_failure: true - variables: - GOSDN_LOG: "nolog" - GOSDN_CHANGE_TIMEOUT: "100ms" - rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH - - if: $CI_NIGHTLY - - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH - allow_failure: true - -unit-test: - script: - - go test -short -race $(go list ./... | grep -v /forks/ | grep -v /mocks ) -v -coverprofile=coverage.out - after_script: - - go tool cover -func=coverage.out - <<: *test - -controller-test: - image: golang:1.16 - script: - - go test -race -v -run TestRun - <<: *test diff --git a/build/ci/scripts/generate_octet.bash b/build/ci/scripts/generate_octet.bash deleted file mode 100755 index 8becfc98b0c47025b445f7216ee935d37b2e4c88..0000000000000000000000000000000000000000 --- a/build/ci/scripts/generate_octet.bash +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -input=$1 -#trailing_backspace=$2 - -hashed_value=$(echo $input | sha256sum | awk '{print $1}' ) - -decimal_value=$((16#$hashed_value)) -decimal_value=${decimal_value/-/} - -octet=$(((decimal_value % 255))) - -echo -n $octet \ No newline at end of file diff --git a/controller.go b/controller.go index ed28c31be19a7864f52f63cd00188be24e98c819..d668c1753618fe44276c3b9d6885ccb623e29bdb 100644 --- a/controller.go +++ b/controller.go @@ -90,6 +90,9 @@ func startGrpc() error { orchestrator := viper.GetString("csbi-orchestrator") conn, err := grpc.Dial(orchestrator, grpc.WithInsecure()) + if err != nil { + log.Fatal(err) + } c.csbiClient = cpb.NewCsbiClient(conn) return nil } diff --git a/http_test.go b/http_test.go index 7b4926e16be0ee4548124b825d02e1cb8fcdcc99..94092e1ca63a862359cd9ca9ba4ad2fa753b4721 100644 --- a/http_test.go +++ b/http_test.go @@ -6,7 +6,6 @@ import ( ) func Test_httpApi(t *testing.T) { - tests := []struct { name string request string diff --git a/northbound/server/pnd.go b/northbound/server/pnd.go index 3e06a57809cf9f0306d8b54372fb665d1aae4db3..a25aefc09c97da1d7f0737467abea6412f114ad6 100644 --- a/northbound/server/pnd.go +++ b/northbound/server/pnd.go @@ -349,13 +349,6 @@ func handleSetOnd(pnd networkdomain.NetworkDomain, req []*ppb.SetOnd) (*ppb.SetR }, nil } -func handleSetSbi(pnd networkdomain.NetworkDomain, req []*ppb.SetSbi) (*ppb.SetResponse, error) { - return &ppb.SetResponse{ - Timestamp: time.Now().UnixNano(), - Status: ppb.SetResponse_ERROR, - }, nil -} - func handleSetChange(pnd networkdomain.NetworkDomain, req []*ppb.SetChange) (*ppb.SetResponse, error) { for _, r := range req { cuid, err := uuid.Parse(r.Cuid) diff --git a/nucleus/change.go b/nucleus/change.go index f64a99eaba5de7fa43ddcb52ff5adb6d14282a37..5340cfca151c77830830df0d336dd05f6d334681 100644 --- a/nucleus/change.go +++ b/nucleus/change.go @@ -132,7 +132,6 @@ func stateManager(ch *Change, timeout time.Duration) (chan<- ppb.Change_State, < errChan <- err } errChan <- fmt.Errorf("change %v timed out", ch.cuid) - break case s := <-stateIn: switch s { case ppb.Change_COMMITTED: diff --git a/nucleus/gnmi_transport.go b/nucleus/gnmi_transport.go index fb5b3016d64418e789dfb56125a40f8b77173725..e98faa28da5f0e676bbc2bd097226a4687b2d3e4 100644 --- a/nucleus/gnmi_transport.go +++ b/nucleus/gnmi_transport.go @@ -9,8 +9,6 @@ import ( "code.fbi.h-da.de/danet/gosdn/interfaces/southbound" - "google.golang.org/grpc" - ppb "code.fbi.h-da.de/danet/api/go/gosdn/pnd" "code.fbi.h-da.de/danet/forks/goarista/gnmi" @@ -71,10 +69,6 @@ func newGnmiTransport(opts *tpb.TransportOption, sbi southbound.SouthboundInterf }, nil } -func parseDialOptions(opts map[string]string) []grpc.DialOption { - return nil -} - // Get takes a slice of gnmi paths, splits them and calls get for each one of them. func (g *Gnmi) Get(ctx context.Context, params ...string) (interface{}, error) { if g.client == nil { diff --git a/nucleus/principalNetworkDomain.go b/nucleus/principalNetworkDomain.go index b0238a095dfb2766e9712b7974614229f560a314..f64e7c0dae2960521f59521ed103cfbe20767c07 100644 --- a/nucleus/principalNetworkDomain.go +++ b/nucleus/principalNetworkDomain.go @@ -320,6 +320,7 @@ func (pnd *pndImplementation) ChangeOND(duid uuid.UUID, operation ppb.ApiOperati return ch.cuid, nil } +// nolint will be implemented in the near future func handleRollbackError(id uuid.UUID, err error) { log.Error(err) // TODO: Notion of invalid state needed. diff --git a/nucleus/principalNetworkDomain_test.go b/nucleus/principalNetworkDomain_test.go index d14fd7f76b3a18f26e0d6134401ac47512768b6d..3a9c23f25cbda982f79ef90af8df3bbe76100b66 100644 --- a/nucleus/principalNetworkDomain_test.go +++ b/nucleus/principalNetworkDomain_test.go @@ -693,7 +693,6 @@ func Test_pndImplementation_GetDevice(t *testing.T) { t.Errorf("GetDevice() got = %v, want %v", foundDevice.(device.Device).Model(), tt.want) } } - }) } } @@ -744,7 +743,6 @@ func Test_pndImplementation_GetDeviceByName(t *testing.T) { t.Errorf("GetDeviceByName() got = %v, want %v", foundDevice.(device.Device).Model(), tt.want) } } - }) } } diff --git a/nucleus/southbound_test.go b/nucleus/southbound_test.go index 2f92d24a1d00d1663d0f86622a08c4773b366ebd..1994cf71d0335501025b28ba0d9eb2fc85458485 100644 --- a/nucleus/southbound_test.go +++ b/nucleus/southbound_test.go @@ -6,8 +6,6 @@ import ( spb "code.fbi.h-da.de/danet/api/go/gosdn/southbound" - "code.fbi.h-da.de/danet/gosdn/interfaces/transport" - "code.fbi.h-da.de/danet/gosdn/nucleus/util/path" "code.fbi.h-da.de/danet/gosdn/nucleus/util/proto" "code.fbi.h-da.de/danet/yang-models/generated/openconfig" @@ -19,9 +17,8 @@ import ( func TestOpenConfig_Id(t *testing.T) { type fields struct { - transport transport.Transport - schema *ytypes.Schema - id uuid.UUID + schema *ytypes.Schema + id uuid.UUID } tests := []struct { name string diff --git a/nucleus/transport.go b/nucleus/transport.go index abeeeca7476f63bdec1320877f0c2321ce010e24..49d74e1c2d3795a9b2a987625b756be7b4939ef6 100644 --- a/nucleus/transport.go +++ b/nucleus/transport.go @@ -29,7 +29,6 @@ func NewTransport(opts *tpb.TransportOption, sbi southbound.SouthboundInterface) return newGnmiTransport(opts, sbi) default: return nil, &errors.ErrInvalidTransportOptions{Opt: o} - } } diff --git a/nucleus/util/path/traverse.go b/nucleus/util/path/traverse.go index c246ebddff0d5fe9396faa22ff9cb6ca5b923e09..403ffc5e441f86013e3eb35a7b6ab331e50b0fb9 100644 --- a/nucleus/util/path/traverse.go +++ b/nucleus/util/path/traverse.go @@ -71,7 +71,6 @@ func processEntry(e *yang.Entry) *Element { // Strings constructs a slice containg all possible root to leaf paths. // Calls stringBuilder internally func Strings(paths map[string]*Element) []string { - p := make([]string, 0) ch := make(chan string) stop := make(chan bool) val := make(chan []string) @@ -81,7 +80,8 @@ func Strings(paths map[string]*Element) []string { stringBuilder(ch, &b, v) } stop <- true - p = <-val + p := <-val + return p } @@ -95,7 +95,6 @@ func appendix(c chan string, stop chan bool, pathChan chan []string) { log.Debug(path) case sig = <-stop: log.Debugf("Signal received: %v", sig) - } if sig { break