Skip to content

Commit

Permalink
⚡ edit template ref
Browse files Browse the repository at this point in the history
  • Loading branch information
petar-cvit committed May 4, 2024
1 parent a5e9a1d commit a648a84
Show file tree
Hide file tree
Showing 8 changed files with 324 additions and 119 deletions.
5 changes: 5 additions & 0 deletions cyclops-ctrl/api/v1alpha1/client/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package client

import (
"context"
"fmt"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -66,6 +67,8 @@ func (c *moduleClient) Create(project *cyclopsv1alpha1.Module) (*cyclopsv1alpha1

// Update takes the representation of a service and updates it. Returns the server's representation of the service, and an error, if there is any.
func (c *moduleClient) Update(module *cyclopsv1alpha1.Module) (project *cyclopsv1alpha1.Module, err error) {
fmt.Println("raw", module.Status)

result := &cyclopsv1alpha1.Module{}
err = c.restClient.Put().
Namespace(c.ns).
Expand All @@ -74,6 +77,8 @@ func (c *moduleClient) Update(module *cyclopsv1alpha1.Module) (project *cyclopsv
Body(module).
Do(context.TODO()).
Into(result)

fmt.Println("raw after", result.Status)
return
}

Expand Down
3 changes: 0 additions & 3 deletions cyclops-ctrl/api/v1alpha1/module_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ import (

// ModuleSpec defines the desired state of Module
type ModuleSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

TemplateRef TemplateRef `json:"template"`
Values apiextensionsv1.JSON `json:"values"`
}
Expand Down
15 changes: 15 additions & 0 deletions cyclops-ctrl/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cyclops-ctrl/internal/controller/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ func (m *Modules) UpdateModule(ctx *gin.Context) {
return
}

fmt.Println(module.Status)

history := curr.History
if curr.History == nil {
history = make([]v1alpha1.HistoryEntry, 0)
Expand Down
6 changes: 4 additions & 2 deletions cyclops-ctrl/internal/modulecontroller/module_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (r *ModuleReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
if err != nil {
r.logger.Error(err, "error fetching module template", "namespaced name", req.NamespacedName)

if err = r.setStatus(ctx, module, req.NamespacedName, cyclopsv1alpha1.Failed, template.ResolvedVersion, err.Error(), nil); err != nil {
if err = r.setStatus(ctx, module, req.NamespacedName, cyclopsv1alpha1.Failed, templateVersion, err.Error(), nil); err != nil {
return ctrl.Result{}, err
}

Expand Down Expand Up @@ -188,6 +188,9 @@ func (r *ModuleReconciler) generateResources(kClient *k8sclient.KubernetesClient
return nil, err
}

fmt.Println(module.Name)
fmt.Println(out)

installErrors := make([]string, 0)

for _, s := range strings.Split(out, "---") {
Expand Down Expand Up @@ -282,7 +285,6 @@ func (r *ModuleReconciler) setStatus(
Reason: reason,
Errors: installErrors,
},
TemplateResolvedVersion: trv,
}

if err := r.Status().Update(ctx, &module); err != nil {
Expand Down
Loading

0 comments on commit a648a84

Please sign in to comment.