Skip to content

Commit

Permalink
update cyctl docs
Browse files Browse the repository at this point in the history
  • Loading branch information
petar-cvit committed Jul 29, 2024
1 parent e095bce commit df0d061
Show file tree
Hide file tree
Showing 24 changed files with 147 additions and 37 deletions.
6 changes: 2 additions & 4 deletions cyctl/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}
23 changes: 12 additions & 11 deletions cyctl/internal/update/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@ 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
`
)

// 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
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion web/docs/cyctl/cyctl.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions web/docs/cyctl/cyctl_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
42 changes: 42 additions & 0 deletions web/docs/cyctl/cyctl_create_module.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_create_templateauthrules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_create_templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_delete_modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_delete_templateauthrules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_delete_templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_describe_modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_describe_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_describe_templateauthrules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_get_modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_get_templateauthrules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_get_templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions web/docs/cyctl/cyctl_init.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_serve.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
31 changes: 31 additions & 0 deletions web/docs/cyctl/cyctl_update.md
Original file line number Diff line number Diff line change
@@ -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 <module-name> --key=<key> --value=<value>
# to update replicas for a module named test,updates number of replicas to 3
cyctl update module <module-name> 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
35 changes: 35 additions & 0 deletions web/docs/cyctl/cyctl_update_module.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion web/docs/cyctl/cyctl_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit df0d061

Please sign in to comment.