MCPcopy
hub / github.com/cyclops-ui/cyclops / updateTemplate

Function updateTemplate

cyctl/internal/update/template_store.go:28–66  ·  view source on GitHub ↗

updates he given template from cyclops API

(clientset *client.CyclopsV1Alpha1Client, templateName, path, version, repo, icon string)

Source from the content-addressed store, hash-verified

26
27// updates he given template from cyclops API
28func 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
68var (
69 UpdateTemplateStoreCMD = &cobra.Command{

Callers 1

template_store.goFile · 0.85

Calls 6

TemplateStoreMethod · 0.80
ErrorMethod · 0.80
PrintlnMethod · 0.80
PrintfMethod · 0.80
GetMethod · 0.65
UpdateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…