diff --git a/doc/md/tutorial/_hello-holos/examples/01-holos-version.txt b/doc/md/tutorial/_hello-holos/examples/01-holos-version.txt index d692c78b..86c56794 100644 --- a/doc/md/tutorial/_hello-holos/examples/01-holos-version.txt +++ b/doc/md/tutorial/_hello-holos/examples/01-holos-version.txt @@ -4,4 +4,4 @@ cmp stdout $WORK/output.txt -- command.sh -- holos --version -- output.txt -- -0.104.3 +0.105.0 diff --git a/doc/md/tutorial/_helm-values/examples/01-holos-version.txt b/doc/md/tutorial/_helm-values/examples/01-holos-version.txt index d692c78b..86c56794 100644 --- a/doc/md/tutorial/_helm-values/examples/01-holos-version.txt +++ b/doc/md/tutorial/_helm-values/examples/01-holos-version.txt @@ -4,4 +4,4 @@ cmp stdout $WORK/output.txt -- command.sh -- holos --version -- output.txt -- -0.104.3 +0.105.0 diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-git-output.txt b/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-git-output.txt index 8139633e..f13913cc 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-git-output.txt +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-git-output.txt @@ -1,3 +1,3 @@ -[main 70107f8] add blackbox configuration +[main 11e8f96] add blackbox configuration 1 file changed, 15 insertions(+) create mode 100644 config/prometheus/blackbox.cue diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/common-config-git-output.txt b/doc/md/tutorial/_helm-values/script-02-helm-values/common-config-git-output.txt index 82322213..8929ee1c 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/common-config-git-output.txt +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/common-config-git-output.txt @@ -1,3 +1,3 @@ -[main dc787e2] integrate blackbox and prometheus together +[main 1ea1005] integrate blackbox and prometheus together 3 files changed, 1348 insertions(+), 2 deletions(-) create mode 100644 components/prometheus/values.cue.orig diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-git-output.txt b/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-git-output.txt index 9ae221c5..d3d7ba31 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-git-output.txt +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-git-output.txt @@ -1,4 +1,4 @@ -[main aaf64bb] import values +[main a2e337a] import values 2 files changed, 1815 insertions(+) create mode 100644 components/blackbox/values.cue create mode 100644 components/prometheus/values.cue diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-render-output.txt b/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-render-output.txt index f783ce24..b024688f 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-render-output.txt +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/import-values-render-output.txt @@ -1,3 +1,3 @@ -rendered blackbox in 111.222667ms -rendered prometheus in 139.292917ms -rendered platform in 139.350708ms +rendered blackbox in 143.36875ms +rendered prometheus in 170.982208ms +rendered platform in 171.067125ms diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-git-commit-output.txt b/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-git-commit-output.txt index 46f4da56..0deaff0f 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-git-commit-output.txt +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-git-commit-output.txt @@ -1,4 +1,4 @@ -[main 688da56] add blackbox and prometheus +[main 58e925d] add blackbox and prometheus 5 files changed, 1550 insertions(+) create mode 100644 components/blackbox/blackbox.cue create mode 100644 components/prometheus/prometheus.cue diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-output.txt b/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-output.txt index 527f4ccf..c21b5ddf 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-output.txt +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/register-components-output.txt @@ -1,3 +1,3 @@ -rendered blackbox in 778.713375ms -rendered prometheus in 839.024292ms -rendered platform in 839.07325ms +rendered blackbox in 5.63152525s +rendered prometheus in 9.53072125s +rendered platform in 9.530793625s diff --git a/doc/md/tutorial/_helm-values/script-02-helm-values/reviewing-changes-git-output.txt b/doc/md/tutorial/_helm-values/script-02-helm-values/reviewing-changes-git-output.txt index 8b7eb92a..6a18f58d 100644 --- a/doc/md/tutorial/_helm-values/script-02-helm-values/reviewing-changes-git-output.txt +++ b/doc/md/tutorial/_helm-values/script-02-helm-values/reviewing-changes-git-output.txt @@ -1,2 +1,2 @@ -[main 2d46297] render integrated blackbox and prometheus manifests +[main f4371e4] render integrated blackbox and prometheus manifests 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/md/tutorial/_kustomize/examples/01-holos-version.txt b/doc/md/tutorial/_kustomize/examples/01-holos-version.txt index d692c78b..86c56794 100644 --- a/doc/md/tutorial/_kustomize/examples/01-holos-version.txt +++ b/doc/md/tutorial/_kustomize/examples/01-holos-version.txt @@ -4,4 +4,4 @@ cmp stdout $WORK/output.txt -- command.sh -- holos --version -- output.txt -- -0.104.3 +0.105.0 diff --git a/doc/md/tutorial/_kustomize/script-02-kustomize/git-commit-component-output.txt b/doc/md/tutorial/_kustomize/script-02-kustomize/git-commit-component-output.txt index b77ff663..fdee4d74 100644 --- a/doc/md/tutorial/_kustomize/script-02-kustomize/git-commit-component-output.txt +++ b/doc/md/tutorial/_kustomize/script-02-kustomize/git-commit-component-output.txt @@ -1,4 +1,4 @@ -[main f621828] add httpbin +[main da03e4a] add httpbin 4 files changed, 113 insertions(+) create mode 100644 components/httpbin/httpbin.cue create mode 100644 components/httpbin/httpbin.yaml diff --git a/doc/md/tutorial/_kustomize/script-02-kustomize/git-commit-final-output.txt b/doc/md/tutorial/_kustomize/script-02-kustomize/git-commit-final-output.txt index 41b84e61..0c173dce 100644 --- a/doc/md/tutorial/_kustomize/script-02-kustomize/git-commit-final-output.txt +++ b/doc/md/tutorial/_kustomize/script-02-kustomize/git-commit-final-output.txt @@ -1,3 +1,3 @@ -[main 0cccd8c] annotate httpbin for prometheus probes +[main 2d3c3cb] annotate httpbin for prometheus probes 2 files changed, 18 insertions(+) create mode 100644 components/httpbin/patches.cue diff --git a/doc/md/tutorial/_kustomize/script-02-kustomize/kustomize-patch-render-output.txt b/doc/md/tutorial/_kustomize/script-02-kustomize/kustomize-patch-render-output.txt index 18a08c60..b6569870 100644 --- a/doc/md/tutorial/_kustomize/script-02-kustomize/kustomize-patch-render-output.txt +++ b/doc/md/tutorial/_kustomize/script-02-kustomize/kustomize-patch-render-output.txt @@ -1,2 +1,2 @@ -rendered httpbin in 77.754459ms -rendered platform in 77.832042ms +rendered httpbin in 99.597583ms +rendered platform in 99.678042ms diff --git a/doc/md/tutorial/_kustomize/script-02-kustomize/register-component-output.txt b/doc/md/tutorial/_kustomize/script-02-kustomize/register-component-output.txt index 6ea30910..34b6609b 100644 --- a/doc/md/tutorial/_kustomize/script-02-kustomize/register-component-output.txt +++ b/doc/md/tutorial/_kustomize/script-02-kustomize/register-component-output.txt @@ -1,2 +1,2 @@ -rendered httpbin in 77.095625ms -rendered platform in 77.190416ms +rendered httpbin in 2.595108833s +rendered platform in 2.595221s diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_hello-holos/examples/01-holos-version.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_hello-holos/examples/01-holos-version.txt index d692c78b..86c56794 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_hello-holos/examples/01-holos-version.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_hello-holos/examples/01-holos-version.txt @@ -4,4 +4,4 @@ cmp stdout $WORK/output.txt -- command.sh -- holos --version -- output.txt -- -0.104.3 +0.105.0 diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_hello-holos/script-02-hello-holos/register-components-output.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_hello-holos/script-02-hello-holos/register-components-output.txt index 82d0799d..5ac0a0ae 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_hello-holos/script-02-hello-holos/register-components-output.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_hello-holos/script-02-hello-holos/register-components-output.txt @@ -1,2 +1,2 @@ -rendered podinfo in 159.277916ms -rendered platform in 159.380625ms +rendered podinfo in 4.155374125s +rendered platform in 4.155477334s diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/examples/01-holos-version.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/examples/01-holos-version.txt index d692c78b..86c56794 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/examples/01-holos-version.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/examples/01-holos-version.txt @@ -4,4 +4,4 @@ cmp stdout $WORK/output.txt -- command.sh -- holos --version -- output.txt -- -0.104.3 +0.105.0 diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-git-output.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-git-output.txt index dd7d3954..7405bf25 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-git-output.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/blackbox-common-config-git-output.txt @@ -1,3 +1,3 @@ -[main 7761ac1] add blackbox configuration +[main d448299] add blackbox configuration 1 file changed, 15 insertions(+) create mode 100644 config/prometheus/blackbox.cue diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/common-config-git-output.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/common-config-git-output.txt index bd82f501..fb4dd68c 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/common-config-git-output.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/common-config-git-output.txt @@ -1,3 +1,3 @@ -[main 8c81fed] integrate blackbox and prometheus together +[main 2ce5a78] integrate blackbox and prometheus together 3 files changed, 1348 insertions(+), 2 deletions(-) create mode 100644 components/prometheus/values.cue.orig diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/import-values-git-output.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/import-values-git-output.txt index 81f1e2de..037940e3 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/import-values-git-output.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/import-values-git-output.txt @@ -1,4 +1,4 @@ -[main 18c7aad] import values +[main 2f0cd50] import values 2 files changed, 1815 insertions(+) create mode 100644 components/blackbox/values.cue create mode 100644 components/prometheus/values.cue diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/import-values-render-output.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/import-values-render-output.txt index 5a8d66ef..fc3f45d6 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/import-values-render-output.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/import-values-render-output.txt @@ -1,3 +1,3 @@ -rendered blackbox in 110.354458ms -rendered prometheus in 138.13225ms -rendered platform in 138.168958ms +rendered blackbox in 143.137333ms +rendered prometheus in 167.300583ms +rendered platform in 167.341209ms diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/register-components-git-commit-output.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/register-components-git-commit-output.txt index 112d8a0c..72dc9a01 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/register-components-git-commit-output.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/register-components-git-commit-output.txt @@ -1,4 +1,4 @@ -[main ff5bfaa] add blackbox and prometheus +[main b7e507c] add blackbox and prometheus 5 files changed, 1550 insertions(+) create mode 100644 components/blackbox/blackbox.cue create mode 100644 components/prometheus/prometheus.cue diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/register-components-output.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/register-components-output.txt index f36ab02b..0ffa8458 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/register-components-output.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/register-components-output.txt @@ -1,3 +1,3 @@ -rendered blackbox in 693.763959ms -rendered prometheus in 788.544209ms -rendered platform in 788.618792ms +rendered blackbox in 5.595935416s +rendered prometheus in 5.602449167s +rendered platform in 5.602527541s diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/reviewing-changes-git-output.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/reviewing-changes-git-output.txt index 898f4efa..4ea4a6a7 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/reviewing-changes-git-output.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_helm-values/script-02-helm-values/reviewing-changes-git-output.txt @@ -1,2 +1,2 @@ -[main 4033953] render integrated blackbox and prometheus manifests +[main 137f66a] render integrated blackbox and prometheus manifests 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/examples/01-holos-version.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/examples/01-holos-version.txt index d692c78b..86c56794 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/examples/01-holos-version.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/examples/01-holos-version.txt @@ -4,4 +4,4 @@ cmp stdout $WORK/output.txt -- command.sh -- holos --version -- output.txt -- -0.104.3 +0.105.0 diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/git-commit-component-output.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/git-commit-component-output.txt index e7dac03a..f4dc2a10 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/git-commit-component-output.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/git-commit-component-output.txt @@ -1,4 +1,4 @@ -[main 1b332f8] add httpbin +[main 2c843b8] add httpbin 4 files changed, 113 insertions(+) create mode 100644 components/httpbin/httpbin.cue create mode 100644 components/httpbin/httpbin.yaml diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/git-commit-final-output.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/git-commit-final-output.txt index cb5df2cb..467890a4 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/git-commit-final-output.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/git-commit-final-output.txt @@ -1,3 +1,3 @@ -[main e37f8ce] annotate httpbin for prometheus probes +[main a324ab5] annotate httpbin for prometheus probes 2 files changed, 18 insertions(+) create mode 100644 components/httpbin/patches.cue diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/kustomize-patch-render-output.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/kustomize-patch-render-output.txt index 1d5fba63..9f52dfa0 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/kustomize-patch-render-output.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/kustomize-patch-render-output.txt @@ -1,2 +1,2 @@ -rendered httpbin in 77.710709ms -rendered platform in 77.792958ms +rendered httpbin in 113.981791ms +rendered platform in 114.0585ms diff --git a/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/register-component-output.txt b/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/register-component-output.txt index b69a8861..0f2d7bc7 100644 --- a/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/register-component-output.txt +++ b/doc/website/versioned_docs/version-v1alpha5/tutorial/_kustomize/script-02-kustomize/register-component-output.txt @@ -1,2 +1,2 @@ -rendered httpbin in 76.942666ms -rendered platform in 77.014958ms +rendered httpbin in 2.546013s +rendered platform in 2.546090458s diff --git a/go.mod b/go.mod index de7bc95a..11eb4e51 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/holos-run/holos -go 1.23.0 - -toolchain go1.23.6 +go 1.24.0 require ( cuelang.org/go v0.14.1 @@ -110,6 +108,7 @@ require ( github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mb0/glob v0.0.0-20160210091149-1eb79d2de6c4 // indirect github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/miekg/dns v1.1.58 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect @@ -129,6 +128,7 @@ require ( github.com/onsi/ginkgo v1.16.4 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.1 // indirect + github.com/patrickdappollonio/kubectl-slice v1.4.2 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect @@ -153,7 +153,7 @@ require ( github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.7.0 // indirect - github.com/spf13/viper v1.18.2 // indirect + github.com/spf13/viper v1.19.0 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/tetratelabs/wazero v1.9.0 // indirect github.com/x-cray/logrus-prefixed-formatter v0.5.2 // indirect diff --git a/go.sum b/go.sum index 53399eb4..c104890b 100644 --- a/go.sum +++ b/go.sum @@ -308,6 +308,8 @@ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mb0/glob v0.0.0-20160210091149-1eb79d2de6c4 h1:NK3O7S5FRD/wj7ORQ5C3Mx1STpyEMuFe+/F0Lakd1Nk= +github.com/mb0/glob v0.0.0-20160210091149-1eb79d2de6c4/go.mod h1:FqD3ES5hx6zpzDainDaHgkTIqrPaI9uX4CVWqYZoQjY= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4= @@ -364,6 +366,8 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8 github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= +github.com/patrickdappollonio/kubectl-slice v1.4.2 h1:U1Jrma4BRK9D1Mbly8oP6uA06/gmOif6KjVQFrPUBzI= +github.com/patrickdappollonio/kubectl-slice v1.4.2/go.mod h1:gt3IidcTPeCcazqcMuXF51VWU5mGsQv6YlNpXxQvPsE= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= @@ -444,6 +448,8 @@ github.com/spf13/pflag v1.0.7 h1:vN6T9TfwStFPFM5XzjsvmzZkLuaLX+HS+0SeFLRgU6M= github.com/spf13/pflag v1.0.7/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= +github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= +github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= 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.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= diff --git a/internal/cli/root.go b/internal/cli/root.go index 32a98e5c..8ac604e8 100644 --- a/internal/cli/root.go +++ b/internal/cli/root.go @@ -17,6 +17,7 @@ import ( "github.com/holos-run/holos/internal/cli/command" "github.com/holos-run/holos/internal/cli/render" + "github.com/holos-run/holos/internal/cli/slice" "github.com/holos-run/holos/internal/cli/txtar" cueCmd "cuelang.org/go/cmd/cue/cmd" @@ -82,6 +83,9 @@ func New(cfg *holos.Config) *cobra.Command { // Compile rootCmd.AddCommand(NewCompileCmd()) + // Slice - https://github.com/patrickdappollonio/kubectl-slice + rootCmd.AddCommand(slice.NewKubectlSliceCmd()) + return rootCmd } diff --git a/internal/cli/slice/doc.go b/internal/cli/slice/doc.go new file mode 100644 index 00000000..fb3742dc --- /dev/null +++ b/internal/cli/slice/doc.go @@ -0,0 +1,22 @@ +// MIT License + +// Copyright (c) 2021 Patrick D'appollonio + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +package slice diff --git a/internal/cli/slice/slice.go b/internal/cli/slice/slice.go new file mode 100644 index 00000000..a9e656dc --- /dev/null +++ b/internal/cli/slice/slice.go @@ -0,0 +1,212 @@ +package slice + +import ( + "bytes" + "fmt" + "os" + "strings" + + "github.com/patrickdappollonio/kubectl-slice/slice" + "github.com/spf13/cobra" + "github.com/spf13/pflag" + "github.com/spf13/viper" +) + +var version = "development" + +const ( + helpShort = "kubectl-slice allows you to split a YAML into multiple subfiles using a pattern." + + helpLong = `kubectl-slice allows you to split a YAML into multiple subfiles using a pattern. +For documentation, available functions, and more, visit: https://github.com/patrickdappollonio/kubectl-slice.` +) + +var examples = []string{ + "kubectl-slice -f foo.yaml -o ./ --include-kind Pod,Namespace", + "kubectl-slice -f foo.yaml -o ./ --exclude-kind Pod", + "kubectl-slice -f foo.yaml -o ./ --exclude-name *-svc", + "kubectl-slice -f foo.yaml --exclude-name *-svc --stdout", + "kubectl-slice -f foo.yaml --include Pod/* --stdout", + "kubectl-slice -f foo.yaml --exclude deployment/kube* --stdout", + "kubectl-slice -d ./ --recurse -o ./ --include-kind Pod,Namespace", + "kubectl-slice -d ./ --recurse --stdout --include Pod/*", + "kubectl-slice --config config.yaml", +} + +func generateExamples([]string) string { + var s bytes.Buffer + for pos, v := range examples { + s.WriteString(fmt.Sprintf(" %s", v)) + + if pos != len(examples)-1 { + s.WriteString("\n") + } + } + + return s.String() +} + +func NewKubectlSliceCmd() *cobra.Command { + opts := slice.Options{} + var configFile string + + rootCommand := &cobra.Command{ + Use: "kubectl-slice", + Short: helpShort, + Long: helpLong, + Version: version, + SilenceUsage: true, + SilenceErrors: true, + Example: generateExamples(examples), + + PreRunE: func(cmd *cobra.Command, args []string) error { + return bindCobraAndViper(cmd, configFile) + }, + + RunE: func(cmd *cobra.Command, args []string) error { + // Bind to the appropriate stdout/stderr + opts.Stdout = cmd.OutOrStdout() + opts.Stderr = cmd.ErrOrStderr() + + // If no input file has been provided or it's "-", then + // point the app to stdin + if (opts.InputFile == "" || opts.InputFile == "-") && opts.InputFolder == "" { + opts.InputFile = os.Stdin.Name() + + // Check if we're receiving data from the terminal + // or from piped content. Users from piped content + // won't see this message. Users that might have forgotten + // setting the flags correctly will see this message. + if !opts.Quiet { + if fi, err := os.Stdin.Stat(); err == nil && fi.Mode()&os.ModeNamedPipe == 0 { + fmt.Fprintln(opts.Stderr, "Receiving data from the terminal. Press CTRL+D when you're done typing or CTRL+C") + fmt.Fprintln(opts.Stderr, "to exit without processing the content. If you're seeing this by mistake, make") + fmt.Fprintln(opts.Stderr, "sure the command line flags, environment variables or config file are correct.") + } + } + } + + // Create a new instance. This will also perform a basic validation. + instance, err := slice.New(opts) + if err != nil { + return fmt.Errorf("validation failed: %w", err) + } + + return instance.Execute() + }, + } + + rootCommand.Flags().StringVarP(&opts.InputFile, "input-file", "f", "", "the input file used to read the initial macro YAML file; if empty or \"-\", stdin is used (exclusive with --input-folder)") + rootCommand.Flags().StringVarP(&opts.InputFolder, "input-folder", "d", "", "the input folder used to read the initial macro YAML files (exclusive with --input-file)") + rootCommand.Flags().StringSliceVar(&opts.InputFolderExt, "extensions", []string{".yaml", ".yml"}, "the extensions to look for in the input folder") + rootCommand.Flags().BoolVarP(&opts.Recurse, "recurse", "r", false, "if true, the input folder will be read recursively (has no effect unless used with --input-folder)") + rootCommand.Flags().StringVarP(&opts.OutputDirectory, "output-dir", "o", "", "the output directory used to output the splitted files") + rootCommand.Flags().StringVarP(&opts.GoTemplate, "template", "t", slice.DefaultTemplateName, "go template used to generate the file name when creating the resource files in the output directory") + rootCommand.Flags().BoolVar(&opts.DryRun, "dry-run", false, "if true, no files are created, but the potentially generated files will be printed as the command output") + rootCommand.Flags().BoolVar(&opts.DebugMode, "debug", false, "enable debug mode") + rootCommand.Flags().BoolVarP(&opts.Quiet, "quiet", "q", false, "if true, no output is written to stdout/err") + rootCommand.Flags().StringSliceVar(&opts.IncludedKinds, "include-kind", nil, "resource kind to include in the output (singular, case insensitive, glob supported)") + rootCommand.Flags().StringSliceVar(&opts.ExcludedKinds, "exclude-kind", nil, "resource kind to exclude in the output (singular, case insensitive, glob supported)") + rootCommand.Flags().StringSliceVar(&opts.IncludedNames, "include-name", nil, "resource name to include in the output (singular, case insensitive, glob supported)") + rootCommand.Flags().StringSliceVar(&opts.ExcludedNames, "exclude-name", nil, "resource name to exclude in the output (singular, case insensitive, glob supported)") + rootCommand.Flags().StringSliceVar(&opts.Included, "include", nil, "resource name to include in the output (format /, case insensitive, glob supported)") + rootCommand.Flags().StringSliceVar(&opts.Excluded, "exclude", nil, "resource name to exclude in the output (format /, case insensitive, glob supported)") + rootCommand.Flags().BoolVarP(&opts.StrictKubernetes, "skip-non-k8s", "s", false, "if enabled, any YAMLs that don't contain at least an \"apiVersion\", \"kind\" and \"metadata.name\" will be excluded from the split") + rootCommand.Flags().BoolVar(&opts.SortByKind, "sort-by-kind", false, "if enabled, resources are sorted by Kind, a la Helm, before saving them to disk") + rootCommand.Flags().BoolVar(&opts.OutputToStdout, "stdout", false, "if enabled, no resource is written to disk and all resources are printed to stdout instead") + rootCommand.Flags().StringVarP(&configFile, "config", "c", "", "path to the config file") + rootCommand.Flags().BoolVar(&opts.AllowEmptyKinds, "allow-empty-kinds", false, "if enabled, resources with empty kinds don't produce an error when filtering") + rootCommand.Flags().BoolVar(&opts.AllowEmptyNames, "allow-empty-names", false, "if enabled, resources with empty names don't produce an error when filtering") + rootCommand.Flags().BoolVar(&opts.IncludeTripleDash, "include-triple-dash", false, "if enabled, the typical \"---\" YAML separator is included at the beginning of resources sliced") + rootCommand.Flags().BoolVar(&opts.PruneOutputDir, "prune", false, "if enabled, the output directory will be pruned before writing the files") + rootCommand.Flags().BoolVar(&opts.RemoveFileComments, "remove-comments", false, "if enabled, comments generated by the app are removed from the sliced files (but keep comments from the original file)") + rootCommand.Flags().StringSliceVar(&opts.IncludedGroups, "include-group", nil, "resource kind to include in the output (singular, case insensitive, glob supported)") + rootCommand.Flags().StringSliceVar(&opts.ExcludedGroups, "exclude-group", nil, "resource kind to exclude in the output (singular, case insensitive, glob supported)") + _ = rootCommand.Flags().MarkHidden("debug") + return rootCommand +} + +// envVarPrefix is the prefix used for environment variables. +// Using underscores to ensure compatibility with the shell. +const envVarPrefix = "KUBECTL_SLICE" + +// skippedFlags is a list of flags that are not bound through +// Viper. These include things like "help", "version", and of +// course, "config", since it doesn't make sense to say where +// the config file is located in the config file itself. +var skippedFlags = [...]string{ + "help", + "version", + "config", +} + +// bindCobraAndViper binds the settings loaded by Viper +// to the flags defined in Cobra. +func bindCobraAndViper(cmd *cobra.Command, configFileLocation string) error { + v := viper.New() + + // If a configuration file has been passed... + if cmd.Flags().Lookup("config").Changed { + // ... then set it as the configuration file + v.SetConfigFile(configFileLocation) + + // then read the configuration file + if err := v.ReadInConfig(); err != nil { + return fmt.Errorf("failed to read configuration file: %w", err) + } + } + + // Handler for potential error + var err error + + // Recurse through all the variables + cmd.Flags().VisitAll(func(flag *pflag.Flag) { + // Skip the flags that are not bound through Viper + for _, v := range skippedFlags { + if v == flag.Name { + return + } + } + + // Normalize key names with underscores instead of dashes + nameUnderscored := strings.ReplaceAll(flag.Name, "-", "_") + envVarName := strings.ToUpper(fmt.Sprintf("%s_%s", envVarPrefix, nameUnderscored)) + + // Bind the flag to the environment variable + if val, found := os.LookupEnv(envVarName); found { + v.Set(nameUnderscored, val) + } + + // If the CLI flag hasn't been changed, but the value is set in + // the configuration file, then set the CLI flag to the value + // from the configuration file + if !flag.Changed && v.IsSet(nameUnderscored) { + // Type check for all the supported types + switch val := v.Get(nameUnderscored).(type) { + + case string: + _ = cmd.Flags().Set(flag.Name, val) + + case []interface{}: + var stringified []string + for _, v := range val { + stringified = append(stringified, fmt.Sprintf("%v", v)) + } + _ = cmd.Flags().Set(flag.Name, strings.Join(stringified, ",")) + + case bool: + _ = cmd.Flags().Set(flag.Name, fmt.Sprintf("%t", val)) + + case int: + _ = cmd.Flags().Set(flag.Name, fmt.Sprintf("%d", val)) + + default: + err = fmt.Errorf("unsupported type %T for flag %q", val, nameUnderscored) + return + } + } + }) + + // If an error occurred, return it + return err +} diff --git a/version/embedded/minor b/version/embedded/minor index b16e5f75..f96ac067 100644 --- a/version/embedded/minor +++ b/version/embedded/minor @@ -1 +1 @@ -104 +105 diff --git a/version/embedded/patch b/version/embedded/patch index 00750edc..573541ac 100644 --- a/version/embedded/patch +++ b/version/embedded/patch @@ -1 +1 @@ -3 +0