updates he given template from cyclops API
(clientset *client.CyclopsV1Alpha1Client, templateName, path, version, repo, icon string)
| 26 | |
| 27 | // updates he given template from cyclops API |
| 28 | func updateTemplate(clientset *client.CyclopsV1Alpha1Client, templateName, path, version, repo, icon string) { |
| 29 | // Fetch the existing template store |
| 30 | template, err := clientset.TemplateStore("cyclops").Get(templateName) |
| 31 | if err != nil { |
| 32 | log.Fatal("Failed to fetch template store:", err.Error()) |
| 33 | return |
| 34 | } |
| 35 | |
| 36 | // Update the template store fields if provided |
| 37 | if repo != "" { |
| 38 | template.Spec.URL = repo |
| 39 | } |
| 40 | if path != "" { |
| 41 | template.Spec.Path = path |
| 42 | } |
| 43 | if version != "" { |
| 44 | template.Spec.Version = version |
| 45 | } |
| 46 | if icon != "" { |
| 47 | if template.ObjectMeta.Annotations == nil { |
| 48 | template.ObjectMeta.Annotations = make(map[string]string) |
| 49 | } |
| 50 | template.ObjectMeta.Annotations["cyclops-ui.com/icon"] = icon |
| 51 | } |
| 52 | template.TypeMeta = v1.TypeMeta{ |
| 53 | APIVersion: "cyclops-ui.com/v1alpha1", |
| 54 | Kind: "TemplateStore", |
| 55 | } |
| 56 | |
| 57 | // Update the template store in the cluster |
| 58 | _, err = clientset.TemplateStore("cyclops").Update(template) |
| 59 | if err != nil { |
| 60 | fmt.Println("Failed to update template store ", err) |
| 61 | return |
| 62 | } |
| 63 | |
| 64 | fmt.Printf("successfully updated %v \n", templateName) |
| 65 | |
| 66 | } |
| 67 | |
| 68 | var ( |
| 69 | UpdateTemplateStoreCMD = &cobra.Command{ |
no test coverage detected
searching dependent graphs…