From 9b99e3c9c2bc4c48b5ed1a424543cc2fdc5673fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Cor=C3=A9?= Date: Fri, 17 Mar 2023 12:29:22 +0100 Subject: [PATCH 1/5] Add option to load related file into merged vars see GPTEINFRA-5776 and GPTEINFRA-5671 Add a new version of the 'related_files' entry in configuration file: 'related_file_v2'. The option provides a way to load the content of the file into a path. The path is JSON pointer format, like the other paths in the configuration (x-merge path in schema file.) Backward compatibility: Adding a new version of 'related_files' entry will ensure the previous one still works as expected across the different versions of the agV repos. Another solution would have been to support both list of strings and list of maps, but that would make the definition of the configuration less clear. We can also retire v1 later when it's been removed from all repos and not used anymore. --- cli/agnosticv.go | 20 ++++++++++++ cli/config.go | 9 ++++++ cli/fixtures/.agnosticv.yaml | 9 ++++++ .../service-ready-message-template.html.j2 | 1 + cli/merge.go | 29 +++++++++++++++++ cli/merge_test.go | 31 +++++++++++++++++++ readme.adoc | 31 ++++++++++++++++--- 7 files changed, 125 insertions(+), 5 deletions(-) create mode 100644 cli/fixtures/test/BABYLON_EMPTY_CONFIG/service-ready-message-template.html.j2 diff --git a/cli/agnosticv.go b/cli/agnosticv.go index cdc9805..cdb8abb 100644 --- a/cli/agnosticv.go +++ b/cli/agnosticv.go @@ -236,6 +236,11 @@ func isPathCatalogItem(root, p string) bool { return false } } + for _, el := range config.RelatedFilesV2 { + if path.Base(p) == el.File { + return false + } + } } // Catalog items are yaml files only. @@ -294,12 +299,27 @@ func extendMergeListWithRelated(pAbs string, mergeList []Include) []Include { Include{path: filepath.Join(filepath.Dir(pAbs), "description.html")}, ) + done := map[string]bool{} if config.initialized { for _, el := range config.RelatedFiles { + if _, ok := done[el]; ok { + continue + } result = append( result, Include{path: filepath.Join(filepath.Dir(pAbs), el)}, ) + done[el] = true + } + for _, el := range config.RelatedFilesV2 { + if _, ok := done[el.File]; ok { + continue + } + result = append( + result, + Include{path: filepath.Join(filepath.Dir(pAbs), el.File)}, + ) + done[el.File] = true } } diff --git a/cli/config.go b/cli/config.go index 74cb74b..bc1adf6 100644 --- a/cli/config.go +++ b/cli/config.go @@ -8,9 +8,17 @@ import ( yamljson "github.com/ghodss/yaml" ) +type RelatedFile struct { + File string `json:"file"` + LoadInto string `json:"load_into"` + ContentKey string `json:"content_key"` + Set map[string]interface{} `json:"set"` +} + type Config struct { // For any leaf file, consider those in same directory as related files: RelatedFiles []string `json:"related_files"` + RelatedFilesV2 []RelatedFile`json:"related_files_v2"` // Plumbing variable to know when config was loaded from disk. initialized bool @@ -34,6 +42,7 @@ func getConf(root string) Config { if err != nil { log.Fatalf("Unmarshal: %v", err) } + c.initialized = true return c diff --git a/cli/fixtures/.agnosticv.yaml b/cli/fixtures/.agnosticv.yaml index 905b2ac..895828f 100644 --- a/cli/fixtures/.agnosticv.yaml +++ b/cli/fixtures/.agnosticv.yaml @@ -1,3 +1,12 @@ --- related_files: - related_file.yaml + +# For any catalog item, consider those in same directory as related files: +related_files_v2: + - file: service-ready-message-template.html.j2 + load_into: /__meta__/service_ready + content_key: template + set: + format: jinja2 + output_format: html diff --git a/cli/fixtures/test/BABYLON_EMPTY_CONFIG/service-ready-message-template.html.j2 b/cli/fixtures/test/BABYLON_EMPTY_CONFIG/service-ready-message-template.html.j2 new file mode 100644 index 0000000..0c76bd1 --- /dev/null +++ b/cli/fixtures/test/BABYLON_EMPTY_CONFIG/service-ready-message-template.html.j2 @@ -0,0 +1 @@ +jinja2 content \ No newline at end of file diff --git a/cli/merge.go b/cli/merge.go index 4fa566c..84d11cc 100644 --- a/cli/merge.go +++ b/cli/merge.go @@ -402,6 +402,35 @@ func mergeVars(p string, mergeStrategies []MergeStrategy) (map[string]any, []Inc } } + // Add related file content + if config.initialized { + for _, related := range config.RelatedFilesV2 { + if related.LoadInto != "" { + if related.ContentKey == "" { + logErr.Fatalf("Related file %s has no content key", related.File) + } + dir := filepath.Dir(p) + relatedPath := filepath.Join(dir, related.File) + if !fileExists(relatedPath) { + continue + } + content := map[string]any{} + for k, v := range related.Set { + content[k] = v + } + relatedContent, err := os.ReadFile(relatedPath) + if err != nil { + logErr.Fatalf("Error reading related file %s: %v", relatedPath, err) + } + + content[related.ContentKey] = string(relatedContent) + if err := SetRelative(final, related.LoadInto, content); err != nil { + logErr.Fatalf("Error SetRelative: %v", err) + } + } + } + } + return final, mergeList, nil } diff --git a/cli/merge_test.go b/cli/merge_test.go index 417056c..e35a926 100644 --- a/cli/merge_test.go +++ b/cli/merge_test.go @@ -333,3 +333,34 @@ func TestMergeStrategicMergeList(t *testing.T) { t.Error("lists do not match", value, expected) } } + + +func TestRelativeFileLoadInto(t *testing.T) { + rootFlag = abs("fixtures") + initConf(rootFlag) + initSchemaList() + initMergeStrategies() + validateFlag = true + merged, _, err := mergeVars( + "fixtures/test/BABYLON_EMPTY_CONFIG/prod.yaml", + mergeStrategies, + ) + if err != nil { + t.Fatal(err) + } + + _, value, _, err := Get(merged, "/__meta__/service_ready") + if err != nil { + t.Error(err) + } + expected := map[string]any{ + "format":"jinja2", + "template":"jinja2 content", + "output_format": "html", + } + + if !reflect.DeepEqual(value, expected) { + t.Error("Values do not match", value, expected) + } + +} diff --git a/readme.adoc b/readme.adoc index 97b43d7..bca1253 100644 --- a/readme.adoc +++ b/readme.adoc @@ -288,10 +288,13 @@ another_var: value <1> * All included files of a catalog item are automatically considered related files. * All common files of a catalog item are automatically considered related files. * It is possible to add custom related files using the config file; see section below. +* It is possible to load related files into the merged vars using the config file; see section below. ==== Configuration ==== -You can add custom related files using the `related_files` configuration option in a `.agnosticv.yaml` configuration file. It contains a list of filenamesj that if present in the same directory of a catalog item, will be considered as related to that catalog item. +You can add custom related files using the `related_files` configuration option in a `.agnosticv.yaml` configuration file. It contains a list of filenames that if present in the same directory of a catalog item, will be considered as related to that catalog item. + +You can decide to load the content of the relative file into a path by specifying the path as a link:https://www.rfc-editor.org/rfc/rfc6901[JSON Pointer] format. The destination path will be a dictionary and the content will be loaded into the 'content_key'. Here is an example of configuration: @@ -300,10 +303,28 @@ Here is an example of configuration: [source,yaml] ---- # For any catalog item, consider those files in same directory as related files: -related_files: - - service-ready-message-template.html.j2 - - service-ready-message-template.html - - description.txt +related_files_v2: + - file: service-ready-message-template.html.j2 + load_into: /__meta__/catalog/message_templates/service_ready + content_key: template + set: + format: jinja2 + output_format: html + - file: description.txt +---- + +When merging, that will produce: + +[source,yaml] +---- +__meta__: + catalog: + message_templates: + service_ready: + template: | + <> + format: jinja2 + output_format: html ---- === Leaf files === From f4ca164c5bdbcc4ab2a8805a2a697e872cfe12b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Cor=C3=A9?= Date: Fri, 17 Mar 2023 14:08:14 +0100 Subject: [PATCH 2/5] Fix indentation --- readme.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.adoc b/readme.adoc index bca1253..16a6ebc 100644 --- a/readme.adoc +++ b/readme.adoc @@ -321,10 +321,10 @@ __meta__: catalog: message_templates: service_ready: + format: jinja2 + output_format: html template: | <> - format: jinja2 - output_format: html ---- === Leaf files === From d537b3844f810e53c665b7e7b7cfe497ce964097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Cor=C3=A9?= Date: Fri, 17 Mar 2023 22:42:33 +0100 Subject: [PATCH 3/5] Get rid of jsoninfo - following up on https://github.com/getkin/kin-openapi/pull/728 remove use of jsoninfo - Pin version of mergo to v0.3.12. v0.3.14 doesn't work the same or is buggy. - getSchemaList: Remove some unecessary step YAML->JSON, prefer JSON and data when possible --- cli/agnosticv_test.go | 10 ++++- cli/config.go | 12 +++--- cli/go.mod | 39 +++++++++-------- cli/go.sum | 97 ++++++++++++++++++++++++++++++++----------- cli/merge.go | 8 ---- cli/merge_test.go | 5 +-- cli/schema.go | 64 +++++++++++++++++++--------- 7 files changed, 154 insertions(+), 81 deletions(-) diff --git a/cli/agnosticv_test.go b/cli/agnosticv_test.go index 48431b8..a5de40c 100644 --- a/cli/agnosticv_test.go +++ b/cli/agnosticv_test.go @@ -436,8 +436,14 @@ func TestSchemaValidationPatternFailed(t *testing.T) { } errValidation := validateAgainstSchemas(path, merged) - if !strings.Contains(errValidation.Error(), "Error at \"/__meta__/lifespan/default\": string doesn't match the regular expression") { - t.Error("ErrorSchema not found", errValidation) + if errValidation == nil { + t.Error("Error expected") + } else { + if !strings.Contains( + errValidation.Error(), + "Error at \"/__meta__/lifespan/default\": string doesn't match the regular expression") { + t.Error("ErrorSchema not found", errValidation) + } } } diff --git a/cli/config.go b/cli/config.go index bc1adf6..c45ffd4 100644 --- a/cli/config.go +++ b/cli/config.go @@ -9,16 +9,16 @@ import ( ) type RelatedFile struct { - File string `json:"file"` - LoadInto string `json:"load_into"` - ContentKey string `json:"content_key"` - Set map[string]interface{} `json:"set"` + File string `json:"file"` + LoadInto string `json:"load_into"` + ContentKey string `json:"content_key"` + Set map[string]interface{} `json:"set"` } type Config struct { // For any leaf file, consider those in same directory as related files: - RelatedFiles []string `json:"related_files"` - RelatedFilesV2 []RelatedFile`json:"related_files_v2"` + RelatedFiles []string `json:"related_files"` + RelatedFilesV2 []RelatedFile `json:"related_files_v2"` // Plumbing variable to know when config was loaded from disk. initialized bool diff --git a/cli/go.mod b/cli/go.mod index 0bb2f5f..3cc4bcb 100644 --- a/cli/go.mod +++ b/cli/go.mod @@ -1,12 +1,12 @@ module github.com/redhat-cop/agnosticv/cli -go 1.18 +go 1.20 require ( - github.com/getkin/kin-openapi v0.94.0 + github.com/getkin/kin-openapi v0.115.0 github.com/ghodss/yaml v1.0.0 github.com/go-git/go-git/v5 v5.4.2 - github.com/go-openapi/jsonpointer v0.19.5 + github.com/go-openapi/jsonpointer v0.19.6 github.com/imdario/mergo v0.3.12 github.com/jmespath/go-jmespath v0.4.0 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 @@ -14,23 +14,28 @@ require ( ) require ( - github.com/Microsoft/go-winio v0.4.16 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect - github.com/acomagu/bufpipe v1.0.3 // indirect - github.com/emirpasic/gods v1.12.0 // indirect + github.com/Microsoft/go-winio v0.6.0 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230316153859-cb82d937a5d9 // indirect + github.com/acomagu/bufpipe v1.0.4 // indirect + github.com/cloudflare/circl v1.3.2 // indirect + github.com/emirpasic/gods v1.18.1 // indirect github.com/go-git/gcfg v1.5.0 // indirect - github.com/go-git/go-billy/v5 v5.3.1 // indirect - github.com/go-openapi/swag v0.19.15 // indirect + github.com/go-git/go-billy/v5 v5.4.1 // indirect + github.com/go-openapi/swag v0.22.3 // indirect + github.com/invopop/yaml v0.2.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect - github.com/mailru/easyjson v0.7.6 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect + github.com/mailru/easyjson v0.7.7 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/sergi/go-diff v1.1.0 // indirect - github.com/stretchr/testify v1.7.2 // indirect - github.com/xanzy/ssh-agent v0.3.0 // indirect - golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect - golang.org/x/net v0.0.0-20210326060303-6b1517762897 // indirect - golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79 // indirect + github.com/perimeterx/marshmallow v1.1.4 // indirect + github.com/sergi/go-diff v1.3.1 // indirect + github.com/xanzy/ssh-agent v0.3.3 // indirect + golang.org/x/crypto v0.7.0 // indirect + golang.org/x/mod v0.9.0 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/tools v0.7.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/cli/go.sum b/cli/go.sum index 92892d8..c75e7b7 100644 --- a/cli/go.sum +++ b/cli/go.sum @@ -1,23 +1,32 @@ github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk= github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= -github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 h1:YoJbenK9C67SkzkDfmQuVln04ygHj3vjZfd9FL+GmQQ= +github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= +github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg= +github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE= github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= -github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= +github.com/ProtonMail/go-crypto v0.0.0-20230316153859-cb82d937a5d9 h1:rndY7RCFW5vUcdVvhfIRsQhYm1MdvwI+dTFbyrWiGHY= +github.com/ProtonMail/go-crypto v0.0.0-20230316153859-cb82d937a5d9/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= +github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= +github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= +github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= +github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= +github.com/cloudflare/circl v1.3.2 h1:VWp8dY3yH69fdM7lM6A1+NhhVoDu9vqK0jOgmkQHFWk= +github.com/cloudflare/circl v1.3.2/go.mod h1:+CauBF6R70Jqcyl8N2hC8pAXYbWkGIezuSbuGLtRhnw= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= -github.com/getkin/kin-openapi v0.94.0 h1:bAxg2vxgnHHHoeefVdmGbR+oxtJlcv5HsJJa3qmAHuo= -github.com/getkin/kin-openapi v0.94.0/go.mod h1:LWZfzOd7PRy8GJ1dJ6mCU6tNdSfOwRac1BUPam4aw6Q= +github.com/getkin/kin-openapi v0.115.0 h1:c8WHRLVY3G8m9jQTy0/DnIuljgRwTCB5twZytQS4JyU= +github.com/getkin/kin-openapi v0.115.0/go.mod h1:l5e9PaFUo9fyLJCPGQeXI2ML8c3P8BHOEV2VaAVf/pc= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= @@ -25,22 +34,29 @@ github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aev github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34= github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= +github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= +github.com/go-git/go-billy/v5 v5.4.1/go.mod h1:vjbugF6Fz7JIflbVpl1hJsGjSHNltrSw45YK/ukIvQg= github.com/go-git/go-git-fixtures/v4 v4.2.1 h1:n9gGL1Ct/yIw+nfsfr8s4+sbhT+Ncu2SubfXjIWgci8= github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= -github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= -github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= +github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/invopop/yaml v0.1.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= +github.com/invopop/yaml v0.2.0 h1:7zky/qH+O0DwAyoobXUqvVBwgBFRxKoQ/3FjcVpjTMY= +github.com/invopop/yaml v0.2.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= @@ -50,8 +66,9 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGw github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= @@ -62,8 +79,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= -github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -71,47 +88,77 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/perimeterx/marshmallow v1.1.4 h1:pZLDH9RjlLGGorbXhcaQLhfuV0pFMNfPO55FuFkxqLw= +github.com/perimeterx/marshmallow v1.1.4/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= +github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= -github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo= +github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= +github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= +github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= +golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210326060303-6b1517762897 h1:KrsHThm5nFk34YtATK1LsThyGhGbGe1olrte/HInHvs= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79 h1:RX8C8PRZc2hTIod4ds8ij+/4RQX3AqhYj3uOHmyaz4E= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= +golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -127,6 +174,6 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/cli/merge.go b/cli/merge.go index 84d11cc..57ddaec 100644 --- a/cli/merge.go +++ b/cli/merge.go @@ -16,14 +16,6 @@ import ( "time" ) -// MergeStrategy type to define custom merge strategies. -// Strategy: the name of the strategy -// Path: the path in the structure of the vars to apply the strategy against. -type MergeStrategy struct { - Strategy string `json:"strategy,omitempty" yaml:"strategy,omitempty"` - Path string `json:"path,omitempty" yaml:"path,omitempty"` -} - // initMap initialize a map using a bunch of keys. func initMap(m map[string]any, keys []string) { logDebug.Printf("(initMap) %v", keys) diff --git a/cli/merge_test.go b/cli/merge_test.go index e35a926..9501dec 100644 --- a/cli/merge_test.go +++ b/cli/merge_test.go @@ -334,7 +334,6 @@ func TestMergeStrategicMergeList(t *testing.T) { } } - func TestRelativeFileLoadInto(t *testing.T) { rootFlag = abs("fixtures") initConf(rootFlag) @@ -354,8 +353,8 @@ func TestRelativeFileLoadInto(t *testing.T) { t.Error(err) } expected := map[string]any{ - "format":"jinja2", - "template":"jinja2 content", + "format": "jinja2", + "template": "jinja2 content", "output_format": "html", } diff --git a/cli/schema.go b/cli/schema.go index b2c0f03..401236a 100644 --- a/cli/schema.go +++ b/cli/schema.go @@ -1,13 +1,15 @@ package main import ( + "context" + "encoding/json" "fmt" - "github.com/getkin/kin-openapi/jsoninfo" - "github.com/getkin/kin-openapi/openapi3" - jsonyaml "github.com/ghodss/yaml" "os" "path/filepath" "strings" + + "github.com/getkin/kin-openapi/openapi3" + jsonyaml "github.com/ghodss/yaml" ) // Schema type @@ -17,21 +19,43 @@ type Schema struct { data []byte } +// MergeStrategy type to define custom merge strategies. +// Strategy: the name of the strategy +// Path: the path in the structure of the vars to apply the strategy against. +type MergeStrategy struct { + Strategy string `json:"strategy,omitempty" yaml:"strategy,omitempty"` + Path string `json:"path,omitempty" yaml:"path,omitempty"` +} + +type MergeStrategies struct { + XMerge []MergeStrategy `json:"x-merge,omitempty" yaml:"x-merge,omitempty"` +} + // AgnosticvSchema is openapi schema plus some extensions type AgnosticvSchema struct { + MergeStrategies openapi3.Schema +} - XMerge []MergeStrategy `json:"x-merge,omitempty" yaml:"x-merge,omitempty"` +func (m *MergeStrategies) UnmarshalJSON(data []byte) error { + type Alias MergeStrategies + var alias Alias + if err := json.Unmarshal(data, &alias); err != nil { + return err + } + m.XMerge = alias.XMerge + return nil } // UnmarshalJSON sets AnosticvSchema to a copy of data. func (schema *AgnosticvSchema) UnmarshalJSON(data []byte) error { - return jsoninfo.UnmarshalStrictStruct(data, schema) -} - -// MarshalJSON returns the JSON encoding of Schema. -func (schema *AgnosticvSchema) MarshalJSON() ([]byte, error) { - return jsoninfo.MarshalStrictStruct(schema) + if err := json.Unmarshal(data, &schema.Schema); err != nil { + return err + } + if err := json.Unmarshal(data, &schema.MergeStrategies); err != nil { + return err + } + return nil } var schemas []Schema @@ -76,19 +100,19 @@ func getSchemaList() ([]Schema, error) { schema := new(AgnosticvSchema) - if err := jsonyaml.Unmarshal(content, schema); err != nil { + data, err := jsonyaml.YAMLToJSON(content) + if err != nil { return err } - data, err := jsonyaml.YAMLToJSON(content) - if err != nil { + if err := json.Unmarshal(data, schema); err != nil { return err } // 3. merge Default schema if __meta__ is found schemaMap := make(map[string]any) - if err := jsonyaml.Unmarshal(content, &schemaMap); err != nil { + if err := json.Unmarshal(data, &schemaMap); err != nil { return err } @@ -114,21 +138,21 @@ func getSchemaList() ([]Schema, error) { // rewrite schema and data - if content, err = jsonyaml.Marshal(schemaMap); err != nil { + if data, err = json.Marshal(schemaMap); err != nil { return err } - if err := jsonyaml.Unmarshal(content, schema); err != nil { - return err - } - - if data, err = jsonyaml.YAMLToJSON(content); err != nil { + if err := json.Unmarshal(data, schema); err != nil { return err } } // Add schema + // validate schema + if err := schema.Validate(context.Background()); err != nil { + return err + } result = append(result, Schema{ path: pAbs, schema: schema, From e088b6c4fe155394d8c583713dfdbef17bebdc58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Cor=C3=A9?= Date: Fri, 17 Mar 2023 22:49:34 +0100 Subject: [PATCH 4/5] Add go build to the github workflow --- .github/workflows/static-checks.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml index 0f3f8fa..054da33 100644 --- a/.github/workflows/static-checks.yml +++ b/.github/workflows/static-checks.yml @@ -59,6 +59,10 @@ jobs: run: go vet ./... working-directory: cli + - name: Build + run: go build ./... + working-directory: cli + - uses: dominikh/staticcheck-action@v1.3.0 with: version: "2022.1.3" From 696b83a2be016a2b44019439a574f3f9f44701cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Cor=C3=A9?= Date: Fri, 17 Mar 2023 22:56:16 +0100 Subject: [PATCH 5/5] Fix workflow staticcheck error, avoid Go 1.20 --- .github/workflows/static-checks.yml | 4 ++-- cli/go.mod | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml index 054da33..c90c782 100644 --- a/.github/workflows/static-checks.yml +++ b/.github/workflows/static-checks.yml @@ -51,9 +51,9 @@ jobs: - uses: actions/checkout@v3 - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: '>=1.17.0' + go-version: 1.19 - name: Vet run: go vet ./... diff --git a/cli/go.mod b/cli/go.mod index 3cc4bcb..7f18f71 100644 --- a/cli/go.mod +++ b/cli/go.mod @@ -1,6 +1,6 @@ module github.com/redhat-cop/agnosticv/cli -go 1.20 +go 1.19 require ( github.com/getkin/kin-openapi v0.115.0