diff --git a/cmd/config/internal/commands/internal/k8sgen/k8scopy.yaml b/cmd/config/internal/commands/internal/k8sgen/k8scopy.yaml index 474984b76..8b7ff35a6 100644 --- a/cmd/config/internal/commands/internal/k8sgen/k8scopy.yaml +++ b/cmd/config/internal/commands/internal/k8sgen/k8scopy.yaml @@ -4,7 +4,7 @@ # The files to vendor (copy). # See {repo}/cmd/k8scopy/main.go for more info. module: k8s.io/apimachinery -version: v0.18.10 +version: v0.19.8 packages: - name: pkg/api/resource files: diff --git a/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/amount.go b/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/amount.go index 23889377c..b71879442 100644 --- a/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/amount.go +++ b/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/amount.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.18.10; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.18.10/pkg/api/resource/amount.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/api/resource/amount.go /* Copyright 2014 The Kubernetes Authors. diff --git a/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/math.go b/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/math.go index a8cfa23a9..331591908 100644 --- a/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/math.go +++ b/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/math.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.18.10; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.18.10/pkg/api/resource/math.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/api/resource/math.go /* Copyright 2014 The Kubernetes Authors. diff --git a/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/quantity.go b/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/quantity.go index 3d2d19d33..fc635aafa 100644 --- a/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/quantity.go +++ b/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/quantity.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.18.10; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.18.10/pkg/api/resource/quantity.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/api/resource/quantity.go /* Copyright 2014 The Kubernetes Authors. diff --git a/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/scale_int.go b/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/scale_int.go index 66147cbb3..729294280 100644 --- a/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/scale_int.go +++ b/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/scale_int.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.18.10; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.18.10/pkg/api/resource/scale_int.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/api/resource/scale_int.go /* Copyright 2015 The Kubernetes Authors. diff --git a/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/suffix.go b/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/suffix.go index 0b04d3768..8a8c08bbb 100644 --- a/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/suffix.go +++ b/cmd/config/internal/commands/internal/k8sgen/pkg/api/resource/suffix.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.18.10; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.18.10/pkg/api/resource/suffix.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/api/resource/suffix.go /* Copyright 2014 The Kubernetes Authors. diff --git a/cmd/config/internal/generateddocs/api/docs.go b/cmd/config/internal/generateddocs/api/docs.go index d4ffb9672..5ef569132 100644 --- a/cmd/config/internal/generateddocs/api/docs.go +++ b/cmd/config/internal/generateddocs/api/docs.go @@ -1,7 +1,9 @@ + + // Code generated by "mdtogo"; DO NOT EDIT. package api -var ConfigIoLong = `# Configuration IO API Semantics +var ConfigIoLong=`# Configuration IO API Semantics Resource Configuration may be read / written from / to sources such as directories, stdin|out or network. Tools may be composed using pipes such that the tools writing @@ -61,8 +63,8 @@ Example: annotations: config.kubernetes.io/local-config: "true"` -var FunctionsImplShort = `Following is an example for implementing an nginx abstraction using a configuration` -var FunctionsImplLong = `# Running Configuration Functions using kustomize CLI +var FunctionsImplShort=`Following is an example for implementing an nginx abstraction using a configuration` +var FunctionsImplLong=`# Running Configuration Functions using kustomize CLI Configuration functions can be implemented using any toolchain and invoked using any container workflow orchestrator including Tekton, Cloud Build, or run directly using ` + "`" + `docker run` + "`" + `. @@ -231,8 +233,8 @@ The function is invoked using byrunning ` + "`" + `kustomize config run dir/` + app: nginx instance: my-instance` -var FunctionsSpecShort = `_Configuration functions_ enable shift-left practices (client-side) through:` -var FunctionsSpecLong = `# Configuration Functions Specification +var FunctionsSpecShort=`_Configuration functions_ enable shift-left practices (client-side) through:` +var FunctionsSpecLong=`# Configuration Functions Specification This document specifies a standard for client-side functions that operate on Kubernetes declarative configurations. This standard enables creating @@ -409,7 +411,7 @@ A non-zero exit code indicates a failure. [2]: https://tools.ietf.org/html/rfc2119 [3]: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds` -var Merge2Long = `# Merge (2-way) +var Merge2Long=`# Merge (2-way) 2-way merges fields from a source to a destination, overriding the destination fields where they differ. @@ -501,7 +503,7 @@ var Merge2Long = `# Merge (2-way) - name: sidecar2 image: sidecar2:v1` -var Merge3Long = `# Merge (3-way) +var Merge3Long=`# Merge (3-way) 3-way merge identifies changes between an original source + updated source and merges the result into a destination, overriding the destination fields where they have changed between diff --git a/cmd/config/internal/generateddocs/commands/docs.go b/cmd/config/internal/generateddocs/commands/docs.go index 2bde8042c..940f9c4da 100644 --- a/cmd/config/internal/generateddocs/commands/docs.go +++ b/cmd/config/internal/generateddocs/commands/docs.go @@ -1,28 +1,30 @@ + + // Code generated by "mdtogo"; DO NOT EDIT. package commands -var AnnotateShort = `[Alpha] Set an annotation on Resources.` -var AnnotateLong = ` +var AnnotateShort=`[Alpha] Set an annotation on Resources.` +var AnnotateLong=` [Alpha] Set an annotation on Resources. DIR: Path to local directory. ` -var AnnotateExamples = ` +var AnnotateExamples=` kustomize cfg annotate my-dir/ --kv foo=bar kustomize cfg annotate my-dir/ --kv foo=bar --kv a=b kustomize cfg annotate my-dir/ --kv foo=bar --kind Deployment --name foo` -var CatShort = `[Alpha] Print Resource Config from a local directory.` -var CatLong = ` +var CatShort=`[Alpha] Print Resource Config from a local directory.` +var CatLong=` [Alpha] Print Resource Config from a local directory. DIR: Path to local directory. ` -var CatExamples = ` +var CatExamples=` # print Resource config from a directory kustomize cfg cat my-dir/ @@ -32,11 +34,11 @@ var CatExamples = ` # unwrap Resource config from a directory in an ResourceList ... | kustomize cfg cat` -var CompletionShort = `Generate shell completion.` -var CompletionLong = ` +var CompletionShort=`Generate shell completion.` +var CompletionLong=` Generate shell completion for ` + "`" + `kustomize` + "`" + ` -- supports bash, zsh, fish and powershell. ` -var CompletionExamples = ` +var CompletionExamples=` # load completion for Bash source <(kustomize completion bash) @@ -53,19 +55,19 @@ var CompletionExamples = ` kustomize completion zsh > /usr/share/zsh/site-functions/_kustomize ` -var CountShort = `[Alpha] Count Resources Config from a local directory.` -var CountLong = ` +var CountShort=`[Alpha] Count Resources Config from a local directory.` +var CountLong=` [Alpha] Count Resources Config from a local directory. DIR: Path to local directory. ` -var CountExamples = ` +var CountExamples=` # print Resource counts from a directory kustomize cfg count my-dir/` -var CreateSetterShort = `[Alpha] Create a custom setter for a Resource field` -var CreateSetterLong = ` +var CreateSetterShort=`[Alpha] Create a custom setter for a Resource field` +var CreateSetterLong=` Create a custom setter for a Resource field by inlining OpenAPI as comments. DIR @@ -80,7 +82,7 @@ Create a custom setter for a Resource field by inlining OpenAPI as comments. The current value of the field, or a substring within the field. ` -var CreateSetterExamples = ` +var CreateSetterExamples=` # create a setter for port fields matching "8080" kustomize cfg create-setter DIR/ port 8080 --type "integer" --field port \ --description "default port used by the app" @@ -90,8 +92,8 @@ var CreateSetterExamples = ` kustomize cfg create-setter DIR/ image-tag v1.0.1 --type "string" \ --field image --description "current stable release"` -var DeleteSetterShort = `[Alpha] Delete a custom setter for a Resource field` -var DeleteSetterLong = ` +var DeleteSetterShort=`[Alpha] Delete a custom setter for a Resource field` +var DeleteSetterLong=` Delete a custom setter for a Resource field. DIR @@ -102,12 +104,12 @@ Delete a custom setter for a Resource field. The name of the setter to create. ` -var DeleteSetterExamples = ` +var DeleteSetterExamples=` # delete a setter for port kustomize cfg create-setter DIR/ port` -var FmtShort = `[Alpha] Format yaml configuration files.` -var FmtLong = ` +var FmtShort=`[Alpha] Format yaml configuration files.` +var FmtLong=` [Alpha] Format yaml configuration files. Fmt will format input by ordering fields and unordered list items in Kubernetes @@ -133,7 +135,7 @@ field paths. - .spec.template.spec.containers (by element name) - .webhooks.rules.operations (by element value) ` -var FmtExamples = ` +var FmtExamples=` # format file1.yaml and file2.yml kustomize cfg fmt file1.yaml file2.yml @@ -146,8 +148,8 @@ var FmtExamples = ` # format kustomize output kustomize build | kustomize cfg fmt` -var GrepShort = `[Alpha] Search for matching Resources in a directory or from stdin` -var GrepLong = ` +var GrepShort=`[Alpha] Search for matching Resources in a directory or from stdin` +var GrepLong=` [Alpha] Search for matching Resources in a directory or from stdin. QUERY: @@ -160,7 +162,7 @@ var GrepLong = ` DIR: Path to local directory. ` -var GrepExamples = ` +var GrepExamples=` # find Deployment Resources kustomize cfg grep "kind=Deployment" my-dir/ @@ -173,22 +175,22 @@ var GrepExamples = ` # look for Resources matching a specific container image kustomize cfg grep "spec.template.spec.containers[name=nginx].image=nginx:1\.7\.9" my-dir/ | kustomize cfg tree` -var InitShort = `[Alpha] Initialize a directory with a Krmfile.` -var InitLong = ` +var InitShort=`[Alpha] Initialize a directory with a Krmfile.` +var InitLong=` [Alpha] Initialize a directory with a Krmfile. DIR: Path to local directory. ` -var InitExamples = ` +var InitExamples=` # create a Krmfile in the local directory kustomize cfg init # create a Krmfile in my-dir/ kustomize cfg init my-dir/` -var ListSettersShort = `[Alpha] List setters for Resources.` -var ListSettersLong = ` +var ListSettersShort=`[Alpha] List setters for Resources.` +var ListSettersLong=` List setters for Resources. DIR @@ -199,15 +201,15 @@ List setters for Resources. Optional. The name of the setter to display. ` -var ListSettersExamples = ` +var ListSettersExamples=` Show setters: $ kustomize cfg list-setters DIR/ NAME DESCRIPTION VALUE TYPE COUNT SETBY name-prefix '' PREFIX string 2` -var MergeShort = `[Alpha] Merge Resource configuration files` -var MergeLong = ` +var MergeShort=`[Alpha] Merge Resource configuration files` +var MergeLong=` [Alpha] Merge Resource configuration files Merge reads Kubernetes Resource yaml configuration files from stdin or sources packages and write @@ -223,11 +225,11 @@ For information on merge rules, run: kustomize cfg docs merge ` -var MergeExamples = ` +var MergeExamples=` cat resources_and_patches.yaml | kustomize cfg merge > merged_resources.yaml` -var Merge3Short = `[Alpha] Merge diff of Resource configuration files into a destination (3-way)` -var Merge3Long = ` +var Merge3Short=`[Alpha] Merge diff of Resource configuration files into a destination (3-way)` +var Merge3Long=` [Alpha] Merge diff of Resource configuration files into a destination (3-way) Merge3 performs a 3-way merge by applying the diff between 2 sets of Resources to a 3rd set. @@ -242,11 +244,11 @@ For information on merge rules, run: kustomize cfg docs-merge3 ` -var Merge3Examples = ` +var Merge3Examples=` kustomize cfg merge3 --ancestor a/ --from b/ --to c/` -var RunFnsShort = `[Alpha] Reoncile config functions to Resources.` -var RunFnsLong = ` +var RunFnsShort=`[Alpha] Reoncile config functions to Resources.` +var RunFnsLong=` [Alpha] Reconcile config functions to Resources. run sequentially invokes all config functions in the directory, providing Resources @@ -291,11 +293,11 @@ order they appear in the file). See ` + "`" + `kustomize help cfg docs-fn` + "`" + ` for more details on writing functions. ` -var RunFnsExamples = ` +var RunFnsExamples=` kustomize fn run example/` -var SetShort = `[Alpha] Set values on Resources fields values.` -var SetLong = ` +var SetShort=`[Alpha] Set values on Resources fields values.` +var SetLong=` Set values on Resources fields. May set either the complete or partial field value. ` + "`" + `set` + "`" + ` identifies setters using field metadata published as OpenAPI extensions. @@ -333,7 +335,7 @@ The description and setBy fields are left unmodified unless specified with flags To create a custom setter for a field see: ` + "`" + `kustomize help cfg create-setter` + "`" + ` ` -var SetExamples = ` +var SetExamples=` Resource YAML: Name Prefix Setter # DIR/resources.yaml @@ -377,8 +379,8 @@ var SetExamples = ` name: test-app2 # {"description":"test environment","type":"string","x-kustomize":{"setBy":"dev","setter":[{"name":"name-prefix","value":"test"}]}} ...` -var SinkShort = `[Alpha] Implement a Sink by writing input to a local directory.` -var SinkLong = ` +var SinkShort=`[Alpha] Implement a Sink by writing input to a local directory.` +var SinkLong=` [Alpha] Implement a Sink by writing input to a local directory. kustomize fn sink [DIR] @@ -388,11 +390,11 @@ var SinkLong = ` ` + "`" + `sink` + "`" + ` writes its input to a directory ` -var SinkExamples = ` +var SinkExamples=` kustomize fn source DIR/ | your-function | kustomize fn sink DIR/` -var SourceShort = `[Alpha] Implement a Source by reading a local directory.` -var SourceLong = ` +var SourceShort=`[Alpha] Implement a Source by reading a local directory.` +var SourceLong=` [Alpha] Implement a Source by reading a local directory. kustomize fn source DIR... @@ -403,14 +405,14 @@ var SourceLong = ` ` + "`" + `source` + "`" + ` emits configuration to act as input to a function ` -var SourceExamples = ` +var SourceExamples=` # emity configuration directory as input source to a function kustomize fn source DIR/ kustomize fn source DIR/ | your-function | kustomize fn sink DIR/` -var TreeShort = `[Alpha] Display Resource structure from a directory or stdin.` -var TreeLong = ` +var TreeShort=`[Alpha] Display Resource structure from a directory or stdin.` +var TreeLong=` [Alpha] Display Resource structure from a directory or stdin. kustomize cfg tree may be used to print Resources in a directory or cluster, preserving structure @@ -431,7 +433,7 @@ By default, kustomize cfg tree uses Resource graph structure if any relationship are detected, as is typically the case when printing from a cluster. Otherwise, directory graph structure is used. The graph structure can also be selected explicitly using the '--graph-structure' flag. ` -var TreeExamples = ` +var TreeExamples=` # print Resources using directory structure kustomize cfg tree my-dir/ diff --git a/cmd/config/internal/generateddocs/tutorials/docs.go b/cmd/config/internal/generateddocs/tutorials/docs.go index 27f1f0fe6..b02cd1e21 100644 --- a/cmd/config/internal/generateddocs/tutorials/docs.go +++ b/cmd/config/internal/generateddocs/tutorials/docs.go @@ -1,8 +1,10 @@ + + // Code generated by "mdtogo"; DO NOT EDIT. package tutorials -var ConfigurationBasicsShort = `### Synopsis` -var ConfigurationBasicsLong = ` +var ConfigurationBasicsShort=`### Synopsis` +var ConfigurationBasicsLong=` ` + "`" + `kustomize cfg` + "`" + ` provides tools for working with local configuration directories. First fetch a bundle of configuration to your local file system from the @@ -274,8 +276,8 @@ var ConfigurationBasicsLong = ` │   └── image: ...` -var FunctionBasicsShort = `### Synopsis` -var FunctionBasicsLong = ` +var FunctionBasicsShort=`### Synopsis` +var FunctionBasicsLong=` ` + "`" + `kustomize config` + "`" + ` enables encapsulating function for manipulating Resource configuration inside containers, which are run using ` + "`" + `run` + "`" + `. diff --git a/kyaml/fn/framework/example2/pkged.go b/kyaml/fn/framework/example2/pkged.go index 4d222015e..cbf6d5975 100644 --- a/kyaml/fn/framework/example2/pkged.go +++ b/kyaml/fn/framework/example2/pkged.go @@ -9,4 +9,4 @@ import ( "github.com/markbates/pkger/pkging/mem" ) -var _ = pkger.Apply(mem.UnmarshalEmbed([]byte(`1f8b08000000000000ffec985d53dac01a80ff4ae6bd8e64f369c84c2f8c968816aca004e8749c4db284954d9649362a38fcf7330902adf5b4da0f7b3ccd15d937fbeef73e3c937ba0e984e7e0dc434ee3bc31b3f306e5caacc8054fe89228b3054e58f9fa8866e08032e50951ae3312e35489f91c8ba99267a1f2bd6419dac99c67e223165370bedb8f0c5d9c107060533ce22138f01187331c13a98a4a214f05a6692e311a6438a32497263c933282239ac6124e23e936a3a27c3e2d0292a544905cea919c175948caf4098d8b0c0bca5309e752d9680364b8c0594c04380032f438173f3ddd0e16e1149c4fd080cf32f40566041c9115e4a1d02338e72938907221d13417983112494121247c8329c30123124da5a0a02c92421c4e09c8e0f11665242fdb8d78d88879d9f87a657370d28231198ec87cfb7c4172b1cdd9851e6574785494c3bb87676d4f07d37433975f39111eeff0e8e7b2959837121e558d0c4896d36a29d5866ac26ab59261b29ef1770fb4a34c526592e184dcf26ca6903b9ccc19d194080bac3c9c2f92edcdcb8d5c37565e93f2372202535685d2f551fdb6ba0c395d12700cd4b464487844c0d15463dfb00dd5dcaf22578256c91ad2d43da4eea1fd0bd57074cb319b0ddb6e1aa8695bfb7bc876100219687e15958bbd5ef77c51757f446ec0b12c5d356568a71c1ccdd20dcb6c2219ba8ca63370b46a7b0938aa653775192e69048e8a1092c1db3d0eafaee63842e020197a51d92892a1ffc5045c36cbbf2af270968363cb702068520ea54fc2b21355b36da499860cddbc8c3475cd3235cb345732741e5545c86c22b5b9a9ba9df34a86c3e7571d5e5d15699193089c4f484632fa5c1d8129c96a64d5c87a1bc892615e4de31e3ecee2e71eb697f16b2543f966b380739c9154ec7adc355b0de7b7717317690892cc1916a4b1d18967f0f451d286aaaa666ca06ae8d62fd0748259fe639caa5b9caa1b9ceaba868c9fc06935f297d054552ddbda704fb755c3b65403bd359a2a137af798a8bb23b77eb986e6d344dbe1697d7c1fe8f4b07d5fe3e94be8ac6bd7b8796ddcfcd76bbfc510b417ee51a0bb6698b0141f9fc79deb83bbb3be7b89bdcbb8af0fe87878528c873d162e5c371af678a09f2c3fc4fcbaddea9ef75ab1b8f0d8f5d83797e3be7a32f60645e4b104fb83c51975ddd06b5d63ef5274a8717b18cf59908eac437a10636d609e51779f2c0e8abe3630dbc76ab38c47492b8ffc4bab7d2cf6db87a63ff2efd471df6d4ecedfbd833f06cb67a9e5ff86506ab550d642590be5bf4bf8d7d5c8cdbf48f5fb12717c2a612b8daafe9ad2a8ff46692c47fe0bd2681ab6850ce3ad11b396c67f01294f5ef2bfa289cbd01b5c9fc53c6e1f9fb0d0bb9b8fb4d672a38b97c9e036f0d8f568d8892743f407b570b3123f10c35db5bfab8646ad86b51ad66af8ef727c07a2d791c36d7f4a44e68c2f5ee2874f666cf8a919f66b0aa2f9fb04b11a792d88b520fe7f82e5e98bfe571c711a7acc1f0f4f96d86f1667d49d86c7eef2833eba3b4cc43c48ceadf6fb5ee98e37c45759909e9f06fe008dfcde34f2de579f2083a425c6173c1e27cd9b6d79d8bd1df95d76465d3a1ab64f43dd65a3253f6d1fba68ecabb781d742e38bb27c10b78fbbb763bf53b55595bdee4d90f6a6d83759987e113f44dff4b58e1fc4d857a7636dfbb9f324f05be9fa7327ffa1d7aeaf2da97da7f69db781a5d57f000000ffff010000ffff6b4abe49e0240000`))) +var _ = pkger.Apply(mem.UnmarshalEmbed([]byte(`1f8b08000000000000ffec985b739a4e1bc0bf0af35c13590e9e98e94530959854d368226aa7935960c5d585756089d18cdffd1d30689be66d931ed27f5bae641ff6d9f3fefc0df740a3294fc0bc8784064965d1482a942b8b34113ca41ba22cd63864d9eb131a8309ca8c874499c724c09112f025163325893de56bc93274c2258fc57b2c66607eb51f197a38246042513ce11e98f01e7b0b1c10298f4a1e8f04a6512231eac638a62491a63c9662827d1a05128e7c691553913d9fa72e8923224822f549c2d3d82359fa9406698c05e5918413296bb402325ce13820024c0019fa9c8bef9e6e170b6f06e607a8c0471906023302a68853f250e8139cf0084c88b890689408cc18f125371512bec5946197118946929b52e64b1ef6660464b0799b329264edfadcab043c6b7cb7b2099851ca980c2764b97fbe2289d8e71c428f32badc4fb3e1ddc3b3b6a78b6954cce5474e84cdbbdcffbe6c25e09590fb7923431227345f4ab5a25661bbddca30ddcdf8ab07da54a691328d7148563c5e28e40e874b4634c5c7022b0fe78bc447cb6c23778d65d724fbf589c094e5a1687754bfac2e434237044c03356b3284dc27606aaa51371a865aade7911b41f3640d69ea11d28e54ed4a354ca36e1aa8a222b551d71aa87a841a264220034d6efc6cb177eb9eacf3ee4fc82d98b59a8e1a3274220ea656d38dbaa6ab32f4188d16606af9f61230d55aa3a9cb704d7d305584900cf6e1717473b3c43e0213c9d0f7b346910c834f2660b145f259917b8b04cc860cc78286d95006c4cb3a518daa960d5d865e92459a486d20bd86d05686eea3aaba5a47a8868aaafb396f65683dbfeae8e6268dd284f8607e403292d1c7fc08cc485c22ab44d69f812c1996f934eee1fd2278ee617b19bfb632646f8a055ce29844e2d0e3a1d97c383f8d9b8748459070c9b0209542279ec1d34749055555cd28a06ae8b51fa0e914b3e4db3835f638550b9ceaba868cefc0693ef297d054475ad328b8a7a33ad29bf56afd4fa3a932a5778f897a3872bb973b683e4db4039e76c7f7814e0fdbf7399e3e85ceae76899bd7c6cdffbdf67b0c41676d9db8ba55f54216e1d3cba03b3fbebb1858d7d8be0e06fa904e4667e964d467dedab2fc519fbbfad9e65dc0e79d76efb2df0ec495cde613a7ba990cd4b3893d4c7d9b85d819ae2fa86579767b8eed6bd1a5c6aa152c991b8d6b2d7a1c606d58bda0569dac8fd38136ac764ed56616f7c376e23bd7b5cea9a8775a5567ecdca99381d59c5ebe7903bf0c96cf52cbff84501a5a2994a5509642f9ef12fe7535b2f817c97f5f228e4f25eca551d55f511a8dea4f94c66ce4a53496d2f83722e5c94bfe5b3471e3d9c3f945c083cee919f3ecbbe5586b6f0a5dbc0e872bd766f3f1a81b4c47e8176a61b112df10c343b5dfab86f5520d4b352cd5f0dfe5f80144af2387fbfe149f2c195fbfc40f9fcc28f8a9198d5714c4aafef304311f792988a520fe9d6079faa2ff16479c79367326a3b30d769ae905b566dea9b579a78fef5aa158bae165adf3b69fb9e32d7154e64697e7ae334463a73ff3edb7f92748376c8bc9150f2661f3765f1ef55663a7c72ea845c7a3ceb9a75b6cbce1e79d9685268eba72ed369a5c65e5e3a073da5b4d9c6ede565eb67bb76ed49f61a7cabce893780b7dd1d72e7e1c60479d4db4fde7ce33d76947bbcf9dfc9b5ebbbbb6a4f49dd277fe0c2c6dff070000ffff010000ffff2eef01c0e0240000`))) diff --git a/kyaml/go.mod b/kyaml/go.mod index bd3ef36a1..372756020 100644 --- a/kyaml/go.mod +++ b/kyaml/go.mod @@ -8,17 +8,16 @@ require ( github.com/go-openapi/spec v0.19.5 github.com/go-openapi/strfmt v0.19.5 github.com/go-openapi/validate v0.19.8 - github.com/google/go-cmp v0.3.0 + github.com/google/go-cmp v0.4.0 github.com/markbates/pkger v0.17.1 github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 - github.com/pkg/errors v0.8.0 + github.com/pkg/errors v0.9.1 github.com/sergi/go-diff v1.1.0 github.com/spf13/cobra v1.0.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.4.0 github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 - golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 // indirect gopkg.in/yaml.v2 v2.3.0 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c ) diff --git a/kyaml/go.sum b/kyaml/go.sum index 3e1a79eb0..329694a49 100644 --- a/kyaml/go.sum +++ b/kyaml/go.sum @@ -109,6 +109,8 @@ github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 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/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -152,6 +154,8 @@ github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtP github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/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/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -224,9 +228,8 @@ golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 h1:rjwSpXsdiK0dV8/Naq3kAw9ymfAeJIyd0upUIElB+lI= -golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -252,6 +255,8 @@ golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= diff --git a/kyaml/yaml/internal/k8sgen/k8scopy.yaml b/kyaml/yaml/internal/k8sgen/k8scopy.yaml index 09cb08cc3..4c6a0d438 100644 --- a/kyaml/yaml/internal/k8sgen/k8scopy.yaml +++ b/kyaml/yaml/internal/k8sgen/k8scopy.yaml @@ -4,7 +4,7 @@ # The files to vendor (copy). # See {repo}/cmd/k8scopy/main.go for more info. module: k8s.io/apimachinery -version: v0.17.0 +version: v0.19.8 packages: - name: pkg/labels files: diff --git a/kyaml/yaml/internal/k8sgen/pkg/labels/zz_generated.deepcopy.go b/kyaml/yaml/internal/k8sgen/pkg/labels/copied.deepcopy.go similarity index 88% rename from kyaml/yaml/internal/k8sgen/pkg/labels/zz_generated.deepcopy.go rename to kyaml/yaml/internal/k8sgen/pkg/labels/copied.deepcopy.go index 980093f69..e526152da 100644 --- a/kyaml/yaml/internal/k8sgen/pkg/labels/zz_generated.deepcopy.go +++ b/kyaml/yaml/internal/k8sgen/pkg/labels/copied.deepcopy.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.17.0; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.17.0/pkg/labels/zz_generated.deepcopy.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/labels/zz_generated.deepcopy.go // +build !ignore_autogenerated diff --git a/kyaml/yaml/internal/k8sgen/pkg/labels/labels.go b/kyaml/yaml/internal/k8sgen/pkg/labels/labels.go index 92ee10f60..300014eac 100644 --- a/kyaml/yaml/internal/k8sgen/pkg/labels/labels.go +++ b/kyaml/yaml/internal/k8sgen/pkg/labels/labels.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.17.0; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.17.0/pkg/labels/labels.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/labels/labels.go /* Copyright 2014 The Kubernetes Authors. @@ -60,14 +60,22 @@ func (ls Set) Get(label string) string { return ls[label] } -// AsSelector converts labels into a selectors. +// AsSelector converts labels into a selectors. It does not +// perform any validation, which means the server will reject +// the request if the Set contains invalid values. func (ls Set) AsSelector() Selector { return SelectorFromSet(ls) } +// AsValidatedSelector converts labels into a selectors. +// The Set is validated client-side, which allows to catch errors early. +func (ls Set) AsValidatedSelector() (Selector, error) { + return ValidatedSelectorFromSet(ls) +} + // AsSelectorPreValidated converts labels into a selector, but -// assumes that labels are already validated and thus don't -// preform any validation. +// assumes that labels are already validated and thus doesn't +// perform any validation. // According to our measurements this is significantly faster // in codepaths that matter at high scale. func (ls Set) AsSelectorPreValidated() Selector { diff --git a/kyaml/yaml/internal/k8sgen/pkg/labels/selector.go b/kyaml/yaml/internal/k8sgen/pkg/labels/selector.go index 826cc0cc3..73c5ae6a6 100644 --- a/kyaml/yaml/internal/k8sgen/pkg/labels/selector.go +++ b/kyaml/yaml/internal/k8sgen/pkg/labels/selector.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.17.0; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.17.0/pkg/labels/selector.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/labels/selector.go /* Copyright 2014 The Kubernetes Authors. @@ -225,7 +225,7 @@ func (r *Requirement) Matches(ls Labels) bool { return false } - // There should be only one strValue in r.strValues, and can be converted to a integer. + // There should be only one strValue in r.strValues, and can be converted to an integer. if len(r.strValues) != 1 { log.Printf("Invalid values count %+v of requirement %#v, for 'Gt', 'Lt' operators, exactly one value is required", len(r.strValues), r) return false @@ -873,23 +873,30 @@ func validateLabelValue(k, v string) error { // SelectorFromSet returns a Selector which will match exactly the given Set. A // nil and empty Sets are considered equivalent to Everything(). +// It does not perform any validation, which means the server will reject +// the request if the Set contains invalid values. func SelectorFromSet(ls Set) Selector { + return SelectorFromValidatedSet(ls) +} + +// ValidatedSelectorFromSet returns a Selector which will match exactly the given Set. A +// nil and empty Sets are considered equivalent to Everything(). +// The Set is validated client-side, which allows to catch errors early. +func ValidatedSelectorFromSet(ls Set) (Selector, error) { if ls == nil || len(ls) == 0 { - return internalSelector{} + return internalSelector{}, nil } requirements := make([]Requirement, 0, len(ls)) for label, value := range ls { r, err := NewRequirement(label, selection.Equals, []string{value}) - if err == nil { - requirements = append(requirements, *r) - } else { - //TODO: double check errors when input comes from serialization? - return internalSelector{} + if err != nil { + return nil, err } + requirements = append(requirements, *r) } // sort to have deterministic string representation sort.Sort(ByKey(requirements)) - return internalSelector(requirements) + return internalSelector(requirements), nil } // SelectorFromValidatedSet returns a Selector which will match exactly the given Set. diff --git a/kyaml/yaml/internal/k8sgen/pkg/selection/operator.go b/kyaml/yaml/internal/k8sgen/pkg/selection/operator.go index 0b5278988..29c443df4 100644 --- a/kyaml/yaml/internal/k8sgen/pkg/selection/operator.go +++ b/kyaml/yaml/internal/k8sgen/pkg/selection/operator.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.17.0; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.17.0/pkg/selection/operator.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/selection/operator.go /* Copyright 2016 The Kubernetes Authors. diff --git a/kyaml/yaml/internal/k8sgen/pkg/util/errors/errors.go b/kyaml/yaml/internal/k8sgen/pkg/util/errors/errors.go index 0b51357d3..24d040e06 100644 --- a/kyaml/yaml/internal/k8sgen/pkg/util/errors/errors.go +++ b/kyaml/yaml/internal/k8sgen/pkg/util/errors/errors.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.17.0; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.17.0/pkg/util/errors/errors.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/util/errors/errors.go /* Copyright 2015 The Kubernetes Authors. @@ -31,9 +31,14 @@ type MessageCountMap map[string]int // Aggregate represents an object that contains multiple errors, but does not // necessarily have singular semantic meaning. +// The aggregate can be used with `errors.Is()` to check for the occurrence of +// a specific error type. +// Errors.As() is not supported, because the caller presumably cares about a +// specific error of potentially multiple that match the given type. type Aggregate interface { error Errors() []error + Is(error) bool } // NewAggregate converts a slice of errors into an Aggregate interface, which @@ -74,16 +79,17 @@ func (agg aggregate) Error() string { } seenerrs := sets.NewString() result := "" - agg.visit(func(err error) { + agg.visit(func(err error) bool { msg := err.Error() if seenerrs.Has(msg) { - return + return false } seenerrs.Insert(msg) if len(seenerrs) > 1 { result += ", " } result += msg + return false }) if len(seenerrs) == 1 { return result @@ -91,19 +97,33 @@ func (agg aggregate) Error() string { return "[" + result + "]" } -func (agg aggregate) visit(f func(err error)) { +func (agg aggregate) Is(target error) bool { + return agg.visit(func(err error) bool { + return errors.Is(err, target) + }) +} + +func (agg aggregate) visit(f func(err error) bool) bool { for _, err := range agg { switch err := err.(type) { case aggregate: - err.visit(f) + if match := err.visit(f); match { + return match + } case Aggregate: for _, nestedErr := range err.Errors() { - f(nestedErr) + if match := f(nestedErr); match { + return match + } } default: - f(err) + if match := f(err); match { + return match + } } } + + return false } // Errors is part of the Aggregate interface. diff --git a/kyaml/yaml/internal/k8sgen/pkg/util/sets/empty.go b/kyaml/yaml/internal/k8sgen/pkg/util/sets/empty.go index d3b52b760..ef404add1 100644 --- a/kyaml/yaml/internal/k8sgen/pkg/util/sets/empty.go +++ b/kyaml/yaml/internal/k8sgen/pkg/util/sets/empty.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.17.0; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.17.0/pkg/util/sets/empty.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/util/sets/empty.go /* Copyright The Kubernetes Authors. diff --git a/kyaml/yaml/internal/k8sgen/pkg/util/sets/string.go b/kyaml/yaml/internal/k8sgen/pkg/util/sets/string.go index 3b52f6688..8af1bac2a 100644 --- a/kyaml/yaml/internal/k8sgen/pkg/util/sets/string.go +++ b/kyaml/yaml/internal/k8sgen/pkg/util/sets/string.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.17.0; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.17.0/pkg/util/sets/string.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/util/sets/string.go /* Copyright The Kubernetes Authors. diff --git a/kyaml/yaml/internal/k8sgen/pkg/util/validation/field/errors.go b/kyaml/yaml/internal/k8sgen/pkg/util/validation/field/errors.go index ff4367096..20229a5b6 100644 --- a/kyaml/yaml/internal/k8sgen/pkg/util/validation/field/errors.go +++ b/kyaml/yaml/internal/k8sgen/pkg/util/validation/field/errors.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.17.0; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.17.0/pkg/util/validation/field/errors.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/util/validation/field/errors.go /* Copyright 2014 The Kubernetes Authors. diff --git a/kyaml/yaml/internal/k8sgen/pkg/util/validation/field/path.go b/kyaml/yaml/internal/k8sgen/pkg/util/validation/field/path.go index daa777441..44cdf997a 100644 --- a/kyaml/yaml/internal/k8sgen/pkg/util/validation/field/path.go +++ b/kyaml/yaml/internal/k8sgen/pkg/util/validation/field/path.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.17.0; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.17.0/pkg/util/validation/field/path.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/util/validation/field/path.go /* Copyright 2015 The Kubernetes Authors. diff --git a/kyaml/yaml/internal/k8sgen/pkg/util/validation/validation.go b/kyaml/yaml/internal/k8sgen/pkg/util/validation/validation.go index 21131bda9..5e1ddbc46 100644 --- a/kyaml/yaml/internal/k8sgen/pkg/util/validation/validation.go +++ b/kyaml/yaml/internal/k8sgen/pkg/util/validation/validation.go @@ -1,5 +1,5 @@ -// Code generated by k8scopy from k8s.io/apimachinery@v0.17.0; DO NOT EDIT. -// Copied from k8s.io/apimachinery@v0.17.0/pkg/util/validation/validation.go +// Code generated by k8scopy from k8s.io/apimachinery@v0.19.8; DO NOT EDIT. +// File content copied from k8s.io/apimachinery@v0.19.8/pkg/util/validation/validation.go /* Copyright 2014 The Kubernetes Authors. @@ -109,9 +109,52 @@ func IsFullyQualifiedDomainName(fldPath *field.Path, name string) field.ErrorLis if len(strings.Split(name, ".")) < 2 { return append(allErrors, field.Invalid(fldPath, name, "should be a domain with at least two segments separated by dots")) } + for _, label := range strings.Split(name, ".") { + if errs := IsDNS1123Label(label); len(errs) > 0 { + return append(allErrors, field.Invalid(fldPath, label, strings.Join(errs, ","))) + } + } return allErrors } +// Allowed characters in an HTTP Path as defined by RFC 3986. A HTTP path may +// contain: +// * unreserved characters (alphanumeric, '-', '.', '_', '~') +// * percent-encoded octets +// * sub-delims ("!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=") +// * a colon character (":") +const httpPathFmt string = `[A-Za-z0-9/\-._~%!$&'()*+,;=:]+` + +var httpPathRegexp = regexp.MustCompile("^" + httpPathFmt + "$") + +// IsDomainPrefixedPath checks if the given string is a domain-prefixed path +// (e.g. acme.io/foo). All characters before the first "/" must be a valid +// subdomain as defined by RFC 1123. All characters trailing the first "/" must +// be valid HTTP Path characters as defined by RFC 3986. +func IsDomainPrefixedPath(fldPath *field.Path, dpPath string) field.ErrorList { + var allErrs field.ErrorList + if len(dpPath) == 0 { + return append(allErrs, field.Required(fldPath, "")) + } + + segments := strings.SplitN(dpPath, "/", 2) + if len(segments) != 2 || len(segments[0]) == 0 || len(segments[1]) == 0 { + return append(allErrs, field.Invalid(fldPath, dpPath, "must be a domain-prefixed path (such as \"acme.io/foo\")")) + } + + host := segments[0] + for _, err := range IsDNS1123Subdomain(host) { + allErrs = append(allErrs, field.Invalid(fldPath, host, err)) + } + + path := segments[1] + if !httpPathRegexp.MatchString(path) { + return append(allErrs, field.Invalid(fldPath, path, RegexError("Invalid path", httpPathFmt))) + } + + return allErrs +} + const labelValueFmt string = "(" + qualifiedNameFmt + ")?" const labelValueErrMsg string = "a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character"