diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d5460a..2a1829b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: if: matrix.full-tests run: | # TODO: use the GH action instead curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | - sh -s -- -b $HOME/go/bin v1.64.8 + sh -s -- -b $HOME/go/bin v2.1.6 $HOME/go/bin/golangci-lint run --timeout=30m \ --max-issues-per-linter 0 \ --max-same-issues 0 \ diff --git a/.golangci.yml b/.golangci.yml index e00ee31..732c0af 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,3 +1,6 @@ -run: - skip-dirs: - - pkg/mudyang # generated code \ No newline at end of file +version: "2" +linters: + exclusions: + paths: + - mudyang.go # generated code + - cmd/ # code to be removed soon \ No newline at end of file diff --git a/Makefile b/Makefile index 904c216..fac599c 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,10 @@ # all YANG modules. The generator name will be overridden in the # generated code using sed. generate: - ~/go/bin/go1.24.0 tool github.com/openconfig/ygot/generator -path=yang -output_file=pkg/mudyang/mudyang.go -generate_simple_unions -package_name=mudyang -generate_fakeroot -fakeroot_name=mudfile yang/ietf-packet-fields@2019-03-04.yang yang/ietf-ethertypes@2019-03-04.yang yang/ietf-acldns.yang yang/ietf-access-control-list@2019-03-04.yang yang/ietf-inet-types@2024-10-21.yang yang/iana-tls-profile@2025-04-18.yang yang/ietf-acl-tls@2025-04-18.yang yang/iana-hash-algs.yang yang/ietf-netconf-acm.yang yang/ietf-crypto-types@2021-09-14.yang yang/ietf-mud-transparency@2023-10-10.yang yang/ietf-ol@2024-04-26.yang yang/ietf-mud-tls@2025-04-18.yang yang/ietf-mud@2019-01-28.yang - sed '7s,.*,This package was generated by github.com\/openconfig\/ygot\/generator@v0.31.0,g' pkg/mudyang/mudyang.go > pkg/mudyang/mudyang.go.rewritten && mv pkg/mudyang/mudyang.go.rewritten pkg/mudyang/mudyang.go + @~/go/bin/go1.24.0 tool github.com/openconfig/ygot/generator -path=yang -output_file=mudyang.go -generate_simple_unions -package_name=mudyang -generate_fakeroot -fakeroot_name=mudfile yang/ietf-packet-fields@2019-03-04.yang yang/ietf-ethertypes@2019-03-04.yang yang/ietf-acldns.yang yang/ietf-access-control-list@2019-03-04.yang yang/ietf-inet-types@2024-10-21.yang yang/iana-tls-profile@2025-04-18.yang yang/ietf-acl-tls@2025-04-18.yang yang/iana-hash-algs.yang yang/ietf-netconf-acm.yang yang/ietf-crypto-types@2021-09-14.yang yang/ietf-mud-transparency@2023-10-10.yang yang/ietf-ol@2024-04-26.yang yang/ietf-mud-tls@2025-04-18.yang yang/ietf-mud@2019-01-28.yang + @sed '7s,.*,This package was generated by github.com\/openconfig\/ygot\/generator@v0.31.0,g' mudyang.go > mudyang.go.rewritten && mv mudyang.go.rewritten mudyang.go -.PHONY: generate \ No newline at end of file +lint: + @golangci-lint run --config .golangci.yml + +.PHONY: generate lint \ No newline at end of file diff --git a/cmd/read.go b/cmd/read.go index ea9d3cd..af28163 100644 --- a/cmd/read.go +++ b/cmd/read.go @@ -4,11 +4,10 @@ import ( "fmt" "os" - "github.com/spf13/cobra" - "github.com/openconfig/ygot/ygot" + "github.com/spf13/cobra" - "github.com/hslatman/mud.yang.go/pkg/mudyang" + "github.com/hslatman/go-mudyang" ) var readCmd = &cobra.Command{ diff --git a/cmd/validate.go b/cmd/validate.go index abaea16..683d290 100644 --- a/cmd/validate.go +++ b/cmd/validate.go @@ -4,9 +4,10 @@ import ( "fmt" "os" - "github.com/hslatman/mud.yang.go/pkg/mudyang" "github.com/openconfig/ygot/ytypes" "github.com/spf13/cobra" + + "github.com/hslatman/go-mudyang" ) var validateCmd = &cobra.Command{ diff --git a/go.mod b/go.mod index 9dd5afb..1cfc0f7 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/hslatman/mud.yang.go +module github.com/hslatman/go-mudyang go 1.24 diff --git a/main.go b/main.go deleted file mode 100644 index ffcc6e5..0000000 --- a/main.go +++ /dev/null @@ -1,9 +0,0 @@ -package main - -import ( - "github.com/hslatman/mud.yang.go/cmd" -) - -func main() { - cmd.Execute() -} diff --git a/pkg/mudyang/mudyang.go b/mudyang.go similarity index 100% rename from pkg/mudyang/mudyang.go rename to mudyang.go diff --git a/pkg/mudyang/mudyang_test.go b/mudyang_test.go similarity index 77% rename from pkg/mudyang/mudyang_test.go rename to mudyang_test.go index 2e38970..53f5202 100644 --- a/pkg/mudyang/mudyang_test.go +++ b/mudyang_test.go @@ -10,11 +10,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/hslatman/mud.yang.go/pkg/mudyang" + "github.com/hslatman/go-mudyang" ) -func TestMudfile_ΛValidate(t *testing.T) { +func TestMudfileValidate(t *testing.T) { t.Parallel() + leafRefOptions := &ytypes.LeafrefOptions{ IgnoreMissingData: false, Log: true, @@ -31,56 +32,56 @@ func TestMudfile_ΛValidate(t *testing.T) { }{ { name: "ok/amazon-echo", - filepath: "./../../examples/amazonEchoMud.json", + filepath: "./examples/amazonEchoMud.json", args: args{ opts: []ygot.ValidationOption{leafRefOptions}, }, }, { name: "ok/lightbulb-2000", - filepath: "./../../examples/lightbulb2000.json", + filepath: "./examples/lightbulb2000.json", args: args{ opts: []ygot.ValidationOption{leafRefOptions}, }, }, { name: "ok/wemo-switch", - filepath: "./../../examples/wemoswitchMud.json", + filepath: "./examples/wemoswitchMud.json", args: args{ opts: []ygot.ValidationOption{leafRefOptions}, }, }, { name: "ok/ol", - filepath: "./../../examples/ol/olExample.json", + filepath: "./examples/ol/olExample.json", args: args{ opts: []ygot.ValidationOption{leafRefOptions}, }, }, { name: "ok/transparency/mixed", - filepath: "./../../examples/transparency/mixedExample.json", + filepath: "./examples/transparency/mixedExample.json", args: args{ opts: []ygot.ValidationOption{leafRefOptions}, }, }, { name: "ok/transparency/complete", - filepath: "./../../examples/transparency/completeExample.json", + filepath: "./examples/transparency/completeExample.json", args: args{ opts: []ygot.ValidationOption{leafRefOptions}, }, }, { name: "ok/tls/example", - filepath: "./../../examples/tls/example.json", + filepath: "./examples/tls/example.json", args: args{ opts: []ygot.ValidationOption{leafRefOptions}, }, }, { name: "fail/amazon-echo", - filepath: "./../../examples/invalidAmazonEchoMud.json", + filepath: "./examples/invalidAmazonEchoMud.json", args: args{ opts: []ygot.ValidationOption{leafRefOptions}, }, @@ -108,7 +109,7 @@ func TestMudfile_ΛValidate(t *testing.T) { assert.NoError(t, err) - err = mud.ΛValidate(tc.args.opts...) + err = mud.Validate(tc.args.opts...) if tc.wantValidationErr { assert.Error(t, err) return