From df0d06118c8eed4e825dff7471fbae4ee14d3236 Mon Sep 17 00:00:00 2001 From: petar-cvit Date: Mon, 29 Jul 2024 21:23:32 +0200 Subject: [PATCH] update cyctl docs --- cyctl/cmd/update.go | 6 +-- cyctl/internal/update/modules.go | 23 +++++----- web/docs/cyctl/cyctl.md | 3 +- web/docs/cyctl/cyctl_create.md | 5 ++- web/docs/cyctl/cyctl_create_module.md | 42 +++++++++++++++++++ .../cyctl/cyctl_create_templateauthrules.md | 2 +- web/docs/cyctl/cyctl_create_templates.md | 2 +- web/docs/cyctl/cyctl_delete.md | 2 +- web/docs/cyctl/cyctl_delete_modules.md | 2 +- .../cyctl/cyctl_delete_templateauthrules.md | 2 +- web/docs/cyctl/cyctl_delete_templates.md | 2 +- web/docs/cyctl/cyctl_describe.md | 2 +- web/docs/cyctl/cyctl_describe_modules.md | 2 +- web/docs/cyctl/cyctl_describe_template.md | 2 +- .../cyctl/cyctl_describe_templateauthrules.md | 2 +- web/docs/cyctl/cyctl_get.md | 2 +- web/docs/cyctl/cyctl_get_modules.md | 2 +- web/docs/cyctl/cyctl_get_templateauthrules.md | 2 +- web/docs/cyctl/cyctl_get_templates.md | 2 +- web/docs/cyctl/cyctl_init.md | 7 ++-- web/docs/cyctl/cyctl_serve.md | 2 +- web/docs/cyctl/cyctl_update.md | 31 ++++++++++++++ web/docs/cyctl/cyctl_update_module.md | 35 ++++++++++++++++ web/docs/cyctl/cyctl_version.md | 2 +- 24 files changed, 147 insertions(+), 37 deletions(-) create mode 100644 web/docs/cyctl/cyctl_create_module.md create mode 100644 web/docs/cyctl/cyctl_update.md create mode 100644 web/docs/cyctl/cyctl_update_module.md diff --git a/cyctl/cmd/update.go b/cyctl/cmd/update.go index dc3574f3..14b5e2c7 100644 --- a/cyctl/cmd/update.go +++ b/cyctl/cmd/update.go @@ -17,16 +17,14 @@ var ( updateCMD = &cobra.Command{ Use: "update", - Short: "updates the given module", - Long: "updates the given module", + Short: "updates cyclops resources (currently supports only Modules)", + Long: "updates cyclops resources (currently supports only Modules)", Example: updateExample, Args: cobra.NoArgs, } ) func init() { - RootCmd.AddCommand(updateCMD) updateCMD.AddCommand(update.UpdateModuleCMD) - } diff --git a/cyctl/internal/update/modules.go b/cyctl/internal/update/modules.go index 6083921c..ca6e78b2 100644 --- a/cyctl/internal/update/modules.go +++ b/cyctl/internal/update/modules.go @@ -11,11 +11,10 @@ import ( apiextensionv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - ) var ( - updateModuleExample = `# updates the module,takes module-name as an argument with flags --key and --value + updateModuleExample = `# updates module values; takes module name as an argument with flags --key and --value # to update replicas for a module named test cyctl update module test --key="scaling.replicas" --value=3 ` @@ -23,7 +22,6 @@ cyctl update module test --key="scaling.replicas" --value=3 // updates the given module from cyclops API func updateModule(clientset *client.CyclopsV1Alpha1Client, moduleName, key string, value interface{}) { - if key == "" { fmt.Println("Error: key cannot be an empty string") return @@ -33,57 +31,60 @@ func updateModule(clientset *client.CyclopsV1Alpha1Client, moduleName, key strin if err != nil { fmt.Println("Failed to fetch module ", err) return - } + specValuesMap := make(map[string]interface{}) err = json.Unmarshal(module.Spec.Values.Raw, &specValuesMap) if err != nil { - fmt.Println("failed to decode json data:", err) return - } + err = unstructured.SetNestedField(specValuesMap, value, strings.Split(key, ".")...) if err != nil { - fmt.Println(err) return } + updatedSpecValues, err := json.Marshal(specValuesMap) if err != nil { fmt.Println("failed to encode to json: ", err) return } + module.Spec.Values = apiextensionv1.JSON{Raw: updatedSpecValues} module.TypeMeta = v1.TypeMeta{ APIVersion: "cyclops-ui.com/v1alpha1", Kind: "Module", } + _, err = clientset.Modules("cyclops").Update(module) if err != nil { fmt.Println("failed to update module: ", err) return } + fmt.Printf("successfully updated %v", moduleName) } var ( UpdateModuleCMD = &cobra.Command{ - Use: "module", - Short: "updates the module,takes module-name as an argument with flags --key and --value", - Long: "updates the module,takes module-name as an argument with flags --key and --value", + Short: "updates module values; takes module name as an argument with flags --key and --value", + Long: "updates module values; takes module name as an argument with flags --key and --value", Example: updateModuleExample, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - key, err := cmd.Flags().GetString("key") if err != nil { fmt.Println("failed to get value of flag --key: ", err) + return } + value, err := cmd.Flags().GetString("value") if err != nil { fmt.Println("failed to get value of flag --value ") + return } updateModule(kubeconfig.Moduleset, args[0], key, value) diff --git a/web/docs/cyctl/cyctl.md b/web/docs/cyctl/cyctl.md index d879b732..cfc6b3d4 100644 --- a/web/docs/cyctl/cyctl.md +++ b/web/docs/cyctl/cyctl.md @@ -20,6 +20,7 @@ Cyclops gives you a UI containing fields you define yourself to manage your K8s * [cyctl get](cyctl_get.md) - Retrieve custom resources like modules, templates, and templateauthrules * [cyctl init](cyctl_init.md) - initialize cyclops with all the resources (along with demo templates) * [cyctl serve](cyctl_serve.md) - Start the Cyclops UI +* [cyctl update](cyctl_update.md) - updates cyclops resources (currently supports only Modules) * [cyctl version](cyctl_version.md) - Prints the version of cyctl -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_create.md b/web/docs/cyctl/cyctl_create.md index c410281d..619eee70 100644 --- a/web/docs/cyctl/cyctl_create.md +++ b/web/docs/cyctl/cyctl_create.md @@ -10,7 +10,7 @@ Create custom resources like modules, templates, and templateauthrules ``` # Create one or more modules -cyctl create modules NAME +cyctl create module NAME -f values.yaml --repo='github.com/repo/a' --path='/path/to/charts' --version='main' # Create one or more templates cyctl create template NAME --repo='github.com/repo/a' --path='/path/to/charts' --version='main' @@ -28,7 +28,8 @@ cyctl create templateauthrule NAME --repo='https://github.com/cyclops-ui/templat ### SEE ALSO * [cyctl](cyctl.md) - 👁️ Customizable UI for Kubernetes Workloads +* [cyctl create module](cyctl_create_module.md) - Create Modules * [cyctl create templateauthrules](cyctl_create_templateauthrules.md) - Create templateauthrules * [cyctl create templates](cyctl_create_templates.md) - Create template -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_create_module.md b/web/docs/cyctl/cyctl_create_module.md new file mode 100644 index 00000000..34485c56 --- /dev/null +++ b/web/docs/cyctl/cyctl_create_module.md @@ -0,0 +1,42 @@ +# cyctl create module +## cyctl create module + +Create Modules + +### Synopsis + +The create module command allows you to create module from the Cyclops API. + +``` +cyctl create module NAME -f values.yaml --repo=repo --path=path --version=version [flags] +``` + +### Examples + +``` + + # Create module with values from a file + cyctl create module NAME -f values.yaml \ + --repo 'github.com/github/demo' \ + --path '/path/to/charts' \ + --version 'main' + +``` + +### Options + +``` + -f, --file string Path to the values.yaml file + -h, --help help for module + -n, --namespace string Namespace where the module will be created (default "cyclops") + -p, --path string Path to the module charts + -r, --repo string Repository URL for the module + -t, --template string Name of the template to use for the module creation + -v, --version string Version of the module +``` + +### SEE ALSO + +* [cyctl create](cyctl_create.md) - Create custom resources like modules, templates, and templateauthrules + +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_create_templateauthrules.md b/web/docs/cyctl/cyctl_create_templateauthrules.md index 05c71f3c..2c26c81f 100644 --- a/web/docs/cyctl/cyctl_create_templateauthrules.md +++ b/web/docs/cyctl/cyctl_create_templateauthrules.md @@ -34,4 +34,4 @@ cyctl create templateauthrule demo-templateauthrule --repo='https://github.com/c * [cyctl create](cyctl_create.md) - Create custom resources like modules, templates, and templateauthrules -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_create_templates.md b/web/docs/cyctl/cyctl_create_templates.md index a8f19a24..1faf38c8 100644 --- a/web/docs/cyctl/cyctl_create_templates.md +++ b/web/docs/cyctl/cyctl_create_templates.md @@ -34,4 +34,4 @@ cyctl create template NAME --repo='https://github.com/cyclops-ui/templates' --pa * [cyctl create](cyctl_create.md) - Create custom resources like modules, templates, and templateauthrules -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_delete.md b/web/docs/cyctl/cyctl_delete.md index b2844a24..485ca8ec 100644 --- a/web/docs/cyctl/cyctl_delete.md +++ b/web/docs/cyctl/cyctl_delete.md @@ -32,4 +32,4 @@ cyctl delete templateauthrules [templateauthrules_name] * [cyctl delete templateauthrules](cyctl_delete_templateauthrules.md) - Delete one or more templateauthrules * [cyctl delete templates](cyctl_delete_templates.md) - Delete one or more templates -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_delete_modules.md b/web/docs/cyctl/cyctl_delete_modules.md index 033102ab..12230381 100644 --- a/web/docs/cyctl/cyctl_delete_modules.md +++ b/web/docs/cyctl/cyctl_delete_modules.md @@ -30,4 +30,4 @@ cyctl delete modules module1 module2 module3 * [cyctl delete](cyctl_delete.md) - Delete custom resources like modules, templates, and templateauthrules -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_delete_templateauthrules.md b/web/docs/cyctl/cyctl_delete_templateauthrules.md index 40f35db7..25366b61 100644 --- a/web/docs/cyctl/cyctl_delete_templateauthrules.md +++ b/web/docs/cyctl/cyctl_delete_templateauthrules.md @@ -30,4 +30,4 @@ cyctl delete modules module1 module2 module3 * [cyctl delete](cyctl_delete.md) - Delete custom resources like modules, templates, and templateauthrules -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_delete_templates.md b/web/docs/cyctl/cyctl_delete_templates.md index 19c68b5f..ca885ecf 100644 --- a/web/docs/cyctl/cyctl_delete_templates.md +++ b/web/docs/cyctl/cyctl_delete_templates.md @@ -30,4 +30,4 @@ cyctl delete modules module1 module2 module3 * [cyctl delete](cyctl_delete.md) - Delete custom resources like modules, templates, and templateauthrules -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_describe.md b/web/docs/cyctl/cyctl_describe.md index 1b1dca92..4fd3c9b9 100644 --- a/web/docs/cyctl/cyctl_describe.md +++ b/web/docs/cyctl/cyctl_describe.md @@ -32,4 +32,4 @@ cyctl describe templateauthrules [templateauthrules_name] * [cyctl describe template](cyctl_describe_template.md) - Describe one or more templateauthrule * [cyctl describe templateauthrules](cyctl_describe_templateauthrules.md) - Describe one or more templateauthrule -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_describe_modules.md b/web/docs/cyctl/cyctl_describe_modules.md index 7b564ae3..8100012c 100644 --- a/web/docs/cyctl/cyctl_describe_modules.md +++ b/web/docs/cyctl/cyctl_describe_modules.md @@ -30,4 +30,4 @@ cyctl describe modules module1 module2 module3 * [cyctl describe](cyctl_describe.md) - Describe custom resources like modules, templates, and templateauthrules -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_describe_template.md b/web/docs/cyctl/cyctl_describe_template.md index 2d51c15e..33e61993 100644 --- a/web/docs/cyctl/cyctl_describe_template.md +++ b/web/docs/cyctl/cyctl_describe_template.md @@ -30,4 +30,4 @@ cyctl describe templates template1 template2 template3 * [cyctl describe](cyctl_describe.md) - Describe custom resources like modules, templates, and templateauthrules -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_describe_templateauthrules.md b/web/docs/cyctl/cyctl_describe_templateauthrules.md index c8c5ed02..68c879d5 100644 --- a/web/docs/cyctl/cyctl_describe_templateauthrules.md +++ b/web/docs/cyctl/cyctl_describe_templateauthrules.md @@ -30,4 +30,4 @@ cyctl describe templateauthrule templateauthrule1 templateauthrule2 templateauth * [cyctl describe](cyctl_describe.md) - Describe custom resources like modules, templates, and templateauthrules -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_get.md b/web/docs/cyctl/cyctl_get.md index 2285d78f..400e2d31 100644 --- a/web/docs/cyctl/cyctl_get.md +++ b/web/docs/cyctl/cyctl_get.md @@ -32,4 +32,4 @@ cyctl get templateauthrules * [cyctl get templateauthrules](cyctl_get_templateauthrules.md) - Retrieve list of templateauthrule in ps format * [cyctl get templates](cyctl_get_templates.md) - Retrieve list of templates in ps format -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_get_modules.md b/web/docs/cyctl/cyctl_get_modules.md index 99b1db52..e45083e0 100644 --- a/web/docs/cyctl/cyctl_get_modules.md +++ b/web/docs/cyctl/cyctl_get_modules.md @@ -30,4 +30,4 @@ cyctl get modules * [cyctl get](cyctl_get.md) - Retrieve custom resources like modules, templates, and templateauthrules -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_get_templateauthrules.md b/web/docs/cyctl/cyctl_get_templateauthrules.md index eb19a93a..e453325f 100644 --- a/web/docs/cyctl/cyctl_get_templateauthrules.md +++ b/web/docs/cyctl/cyctl_get_templateauthrules.md @@ -30,4 +30,4 @@ cyctl get templateauthrule * [cyctl get](cyctl_get.md) - Retrieve custom resources like modules, templates, and templateauthrules -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_get_templates.md b/web/docs/cyctl/cyctl_get_templates.md index 88c4b788..73d20a68 100644 --- a/web/docs/cyctl/cyctl_get_templates.md +++ b/web/docs/cyctl/cyctl_get_templates.md @@ -30,4 +30,4 @@ cyctl get templates * [cyctl get](cyctl_get.md) - Retrieve custom resources like modules, templates, and templateauthrules -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_init.md b/web/docs/cyctl/cyctl_init.md index a0caaaec..995d1d3d 100644 --- a/web/docs/cyctl/cyctl_init.md +++ b/web/docs/cyctl/cyctl_init.md @@ -9,12 +9,13 @@ cyctl init [flags] ### Options ``` - -h, --help help for init - -v, --version string specify cyclops version (default "main") + -t, --disable-telemetry disable emitting telemetry metrics from cyclops controller + -h, --help help for init + -v, --version string specify cyclops version (default "main") ``` ### SEE ALSO * [cyctl](cyctl.md) - 👁️ Customizable UI for Kubernetes Workloads -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_serve.md b/web/docs/cyctl/cyctl_serve.md index a22f1453..dfe23b48 100644 --- a/web/docs/cyctl/cyctl_serve.md +++ b/web/docs/cyctl/cyctl_serve.md @@ -21,4 +21,4 @@ cyctl serve -port [port] [flags] * [cyctl](cyctl.md) - 👁️ Customizable UI for Kubernetes Workloads -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_update.md b/web/docs/cyctl/cyctl_update.md new file mode 100644 index 00000000..5e3feca7 --- /dev/null +++ b/web/docs/cyctl/cyctl_update.md @@ -0,0 +1,31 @@ +# cyctl update +## cyctl update + +updates cyclops resources (currently supports only Modules) + +### Synopsis + +updates cyclops resources (currently supports only Modules) + +### Examples + +``` +# updates the given module +cyctl update module --key= --value= + +# to update replicas for a module named test,updates number of replicas to 3 +cyctl update module test --key="scaling.replicas" --value=3 +``` + +### Options + +``` + -h, --help help for update +``` + +### SEE ALSO + +* [cyctl](cyctl.md) - 👁️ Customizable UI for Kubernetes Workloads +* [cyctl update module](cyctl_update_module.md) - updates module values; takes module name as an argument with flags --key and --value + +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_update_module.md b/web/docs/cyctl/cyctl_update_module.md new file mode 100644 index 00000000..f4f96c1b --- /dev/null +++ b/web/docs/cyctl/cyctl_update_module.md @@ -0,0 +1,35 @@ +# cyctl update module +## cyctl update module + +updates module values; takes module name as an argument with flags --key and --value + +### Synopsis + +updates module values; takes module name as an argument with flags --key and --value + +``` +cyctl update module [flags] +``` + +### Examples + +``` +# updates module values; takes module name as an argument with flags --key and --value +# to update replicas for a module named test +cyctl update module test --key="scaling.replicas" --value=3 + +``` + +### Options + +``` + -h, --help help for module + -k, --key string the field to update + -v, --value string field value +``` + +### SEE ALSO + +* [cyctl update](cyctl_update.md) - updates cyclops resources (currently supports only Modules) + +###### Auto generated by spf13/cobra on 29-Jul-2024 diff --git a/web/docs/cyctl/cyctl_version.md b/web/docs/cyctl/cyctl_version.md index 165bdf85..e004f06c 100644 --- a/web/docs/cyctl/cyctl_version.md +++ b/web/docs/cyctl/cyctl_version.md @@ -22,4 +22,4 @@ cyctl version [flags] * [cyctl](cyctl.md) - 👁️ Customizable UI for Kubernetes Workloads -###### Auto generated by spf13/cobra on 24-Jun-2024 +###### Auto generated by spf13/cobra on 29-Jul-2024