Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve events #826

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/v1alpha1/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ func KeepResourceDeletePolicy(obj AnnotationHolder) bool {
}
return v == ResourceAnnEnumDeletePolicyKeep
}

const (
EventAnnKeyUserName = "cosmo-workspace.github.io/user"
EventAnnKeyInstanceName = LabelKeyInstanceName
)
2 changes: 2 additions & 0 deletions cmd/controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ MIT 2023 cosmo-workspace/cosmo
}
if err = (&controllers.TemplateReconciler{
Client: mgr.GetClient(),
Recorder: mgr.GetEventRecorderFor(tmplController),
Scheme: mgr.GetScheme(),
FieldManager: controllerFieldManager,
}).SetupWithManager(mgr); err != nil {
Expand All @@ -132,6 +133,7 @@ MIT 2023 cosmo-workspace/cosmo
}
if err = (&controllers.ClusterTemplateReconciler{
Client: mgr.GetClient(),
Recorder: mgr.GetEventRecorderFor(clusterTmplController),
Scheme: mgr.GetScheme(),
FieldManager: controllerFieldManager,
}).SetupWithManager(mgr); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/template/generate_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (o *generateWorkspaceOption) RunE(cmd *cobra.Command, args []string) error
}
o.Logr.Debug().Info(input)

unsts, err := template.NewRawYAMLBuilder(input, nil).Build()
unsts, err := template.NewRawYAMLBuilder(input).Build()
if err != nil {
return fmt.Errorf("failed to build template: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/template/generate_workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ spec:
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
u, err := template.NewRawYAMLBuilder(tt.args.tmpl, nil).Build()
u, err := template.NewRawYAMLBuilder(tt.args.tmpl).Build()
if err != nil {
t.Errorf("dummyTemplateBuild() error = %v", err)
}
Expand Down
7 changes: 4 additions & 3 deletions internal/controllers/cluster_instance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

cosmov1alpha1 "github.com/cosmo-workspace/cosmo/api/v1alpha1"
"github.com/cosmo-workspace/cosmo/pkg/clog"
"github.com/cosmo-workspace/cosmo/pkg/kosmo"
"github.com/cosmo-workspace/cosmo/pkg/template"
"github.com/cosmo-workspace/cosmo/pkg/transformer"
)
Expand Down Expand Up @@ -54,21 +55,21 @@ func (r *ClusterInstanceReconciler) Reconcile(ctx context.Context, req ctrl.Requ
// 1. Build Unstructured objects
objects, err := template.BuildObjects(tmpl.Spec, &inst)
if err != nil {
r.Recorder.Eventf(&inst, corev1.EventTypeWarning, "BuildFailed", "Failed to build manifests from Template: %v", err)
kosmo.InstanceEventf(r.Recorder, &inst, corev1.EventTypeWarning, "BuildFailed", "Failed to build manifests from Template: %v", err)
return ctrl.Result{}, err
}

// 2. Transform the objects
objects, err = transformer.ApplyTransformers(ctx, transformer.AllTransformers(&inst, r.Scheme, tmpl), objects)
if err != nil {
r.Recorder.Eventf(&inst, corev1.EventTypeWarning, "BuildFailed", "Failed to build resources: %v", err)
kosmo.InstanceEventf(r.Recorder, &inst, corev1.EventTypeWarning, "BuildFailed", "Failed to build resources: %v", err)
return ctrl.Result{}, err
}

// 3. Reconcile objects
if errs := r.impl.reconcileObjects(ctx, &inst, objects); len(errs) != 0 {
for _, err := range errs {
r.Recorder.Eventf(&inst, corev1.EventTypeWarning, "SyncFailed", "Failed to sync objects: %v", err)
kosmo.InstanceEventf(r.Recorder, &inst, corev1.EventTypeWarning, "SyncFailed", "Failed to sync objects: %v", err)
}
// requeue
return ctrl.Result{}, fmt.Errorf("apply child objects failed: %w", errs[0])
Expand Down
4 changes: 3 additions & 1 deletion internal/controllers/cluster_template_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/event"
Expand All @@ -17,6 +18,7 @@ import (
// ClusterTemplateReconciler reconciles a ClusterTemplate object
type ClusterTemplateReconciler struct {
client.Client
Recorder record.EventRecorder
Scheme *runtime.Scheme
FieldManager string
}
Expand Down Expand Up @@ -50,7 +52,7 @@ func (r *ClusterTemplateReconciler) reconcile(ctx context.Context, tmpl *cosmov1
return fmt.Errorf("failed to list clusterinstances for clustertemplate %s: %w", tmpl.Name, err)
}

if errs := notifyUpdateToInstances(ctx, r.Client, tmpl, insts.InstanceObjects()); len(errs) > 0 {
if errs := notifyUpdateToInstances(ctx, r.Client, r.Recorder, tmpl, insts.InstanceObjects()); len(errs) > 0 {
for _, e := range errs {
log.Error(e, "failed to notify the update of template")
}
Expand Down
15 changes: 8 additions & 7 deletions internal/controllers/instance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

cosmov1alpha1 "github.com/cosmo-workspace/cosmo/api/v1alpha1"
"github.com/cosmo-workspace/cosmo/pkg/clog"
"github.com/cosmo-workspace/cosmo/pkg/kosmo"
"github.com/cosmo-workspace/cosmo/pkg/kubeutil"
"github.com/cosmo-workspace/cosmo/pkg/template"
"github.com/cosmo-workspace/cosmo/pkg/transformer"
Expand Down Expand Up @@ -64,21 +65,21 @@ func (r *InstanceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
// 1. Build Unstructured objects
objects, err := template.BuildObjects(tmpl.Spec, &inst)
if err != nil {
r.Recorder.Eventf(&inst, corev1.EventTypeWarning, "BuildFailed", "Failed to build manifests from Template: %v", err)
kosmo.InstanceEventf(r.Recorder, &inst, corev1.EventTypeWarning, "BuildFailed", "Failed to build manifests from Template: %v", err)
return ctrl.Result{}, err
}

// 2. Transform the objects
objects, err = transformer.ApplyTransformers(ctx, transformer.AllTransformers(&inst, r.Scheme, tmpl), objects)
if err != nil {
r.Recorder.Eventf(&inst, corev1.EventTypeWarning, "BuildFailed", "Failed to build resources: %v", err)
kosmo.InstanceEventf(r.Recorder, &inst, corev1.EventTypeWarning, "BuildFailed", "Failed to build resources: %v", err)
return ctrl.Result{}, err
}

// 3. Reconcile objects
if errs := r.impl.reconcileObjects(ctx, &inst, objects); len(errs) != 0 {
for _, err := range errs {
r.Recorder.Eventf(&inst, corev1.EventTypeWarning, "SyncFailed", "Failed to sync objects: %v", err)
kosmo.InstanceEventf(r.Recorder, &inst, corev1.EventTypeWarning, "SyncFailed", "Failed to sync objects: %v", err)
}
// requeue
return ctrl.Result{}, fmt.Errorf("apply child objects failed: %w", errs[0])
Expand Down Expand Up @@ -162,7 +163,7 @@ func (r *instanceReconciler) reconcileObjects(ctx context.Context, inst cosmov1a
if err != nil {
errs = append(errs, fmt.Errorf("failed to create resource: kind = %s name = %s: %w", built.GetKind(), built.GetName(), err))
} else {
r.Recorder.Eventf(inst, corev1.EventTypeNormal, "Synced", "%s %s is created", built.GetKind(), built.GetName())
kosmo.InstanceEventf(r.Recorder, inst, corev1.EventTypeNormal, "Synced", "%s %s is created", built.GetKind(), built.GetName())
}
currAppliedMap[created.GetUID()] = unstToObjectRef(created)

Expand Down Expand Up @@ -190,7 +191,7 @@ func (r *instanceReconciler) reconcileObjects(ctx context.Context, inst cosmov1a
if _, err := r.apply(ctx, &built, r.FieldManager); err != nil {
errs = append(errs, fmt.Errorf("failed to apply resource %s %s: %w", built.GetKind(), built.GetName(), err))
} else {
r.Recorder.Eventf(inst, corev1.EventTypeNormal, "Synced", "%s %s is not desired state, synced", built.GetKind(), built.GetName())
kosmo.InstanceEventf(r.Recorder, inst, corev1.EventTypeNormal, "Synced", "%s %s is not desired state, synced", built.GetKind(), built.GetName())
}
}
}
Expand All @@ -203,10 +204,10 @@ func (r *instanceReconciler) reconcileObjects(ctx context.Context, inst cosmov1a
for _, d := range shouldDeletes {
if skip, err := prune(ctx, r.Client, d); err != nil {
log.Error(err, "failed to delete unused obj", "pruneAPIVersion", d.APIVersion, "pruneKind", d.Kind, "pruneName", d.Name, "pruneNamespace", d.Namespace)
r.Recorder.Eventf(inst, corev1.EventTypeWarning, "GCFailed", "Failed to delete unused obj: kind=%s name=%s namespace=%s", d.Kind, d.Name, d.Namespace)
kosmo.InstanceEventf(r.Recorder, inst, corev1.EventTypeWarning, "GCFailed", "Failed to delete unused obj: kind=%s name=%s namespace=%s", d.Kind, d.Name, d.Namespace)
} else if !skip {
log.Info("deleted unmanaged object", "apiVersion", d.APIVersion, "kind", d.Kind, "name", d.Name, "namespace", d.Namespace)
r.Recorder.Eventf(inst, corev1.EventTypeNormal, "GC", "Deleted unmanaged object: kind=%s name=%s namespace=%s", d.Kind, d.Name, d.Namespace)
kosmo.InstanceEventf(r.Recorder, inst, corev1.EventTypeNormal, "GC", "Deleted unmanaged object: kind=%s name=%s namespace=%s", d.Kind, d.Name, d.Namespace)
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions internal/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,16 @@ var _ = BeforeSuite(func() {
Expect(err).NotTo(HaveOccurred())

err = (&TemplateReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorderFor(tmplController),
}).SetupWithManager(mgr)
Expect(err).NotTo(HaveOccurred())

err = (&ClusterTemplateReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Recorder: mgr.GetEventRecorderFor(clusterTmplController),
}).SetupWithManager(mgr)
Expect(err).NotTo(HaveOccurred())

Expand Down
10 changes: 8 additions & 2 deletions internal/controllers/template_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ import (
"context"
"fmt"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/predicate"

cosmov1alpha1 "github.com/cosmo-workspace/cosmo/api/v1alpha1"
"github.com/cosmo-workspace/cosmo/pkg/clog"
"github.com/cosmo-workspace/cosmo/pkg/kosmo"
)

// TemplateReconciler reconciles a Template object
type TemplateReconciler struct {
client.Client
Recorder record.EventRecorder
Scheme *runtime.Scheme
FieldManager string
}
Expand Down Expand Up @@ -51,7 +55,7 @@ func (r *TemplateReconciler) reconcile(ctx context.Context, tmpl *cosmov1alpha1.
return fmt.Errorf("failed to list instances for template %s: %w", tmpl.Name, err)
}

if errs := notifyUpdateToInstances(ctx, r.Client, tmpl, insts.InstanceObjects()); len(errs) > 0 {
if errs := notifyUpdateToInstances(ctx, r.Client, r.Recorder, tmpl, insts.InstanceObjects()); len(errs) > 0 {
for _, e := range errs {
log.Error(e, "failed to notify the update of template")
}
Expand All @@ -70,7 +74,7 @@ func (r *TemplateReconciler) SetupWithManager(mgr ctrl.Manager) error {
Complete(r)
}

func notifyUpdateToInstances(ctx context.Context, c client.Client, tmpl cosmov1alpha1.TemplateObject, insts []cosmov1alpha1.InstanceObject) []error {
func notifyUpdateToInstances(ctx context.Context, c client.Client, rec record.EventRecorder, tmpl cosmov1alpha1.TemplateObject, insts []cosmov1alpha1.InstanceObject) []error {
log := clog.FromContext(ctx)
errs := make([]error, 0)
for _, inst := range insts {
Expand All @@ -90,6 +94,8 @@ func notifyUpdateToInstances(ctx context.Context, c client.Client, tmpl cosmov1a
if err := c.Status().Update(ctx, inst); err != nil {
errs = append(errs, fmt.Errorf("failed to update instance status: %s: %w", inst.GetName(), err))
}

kosmo.InstanceEventf(rec, inst, corev1.EventTypeNormal, "TemplateUpdated", "Detected Template %s is updated", tmpl.GetName())
}
return errs
}
17 changes: 9 additions & 8 deletions internal/controllers/user_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/cosmo-workspace/cosmo/pkg/auth/password"
"github.com/cosmo-workspace/cosmo/pkg/clog"
"github.com/cosmo-workspace/cosmo/pkg/instance"
"github.com/cosmo-workspace/cosmo/pkg/kosmo"
"github.com/cosmo-workspace/cosmo/pkg/useraddon"
)

Expand Down Expand Up @@ -51,12 +52,12 @@ func (r *UserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
return r.patchNamespaceToUserDesired(&ns, user)
})
if err != nil {
r.Recorder.Eventf(&user, corev1.EventTypeWarning, "SyncFailed", "Failed to sync namespace %s: %v", ns.Name, err)
kosmo.UserEventf(r.Recorder, &user, corev1.EventTypeWarning, "SyncFailed", "Failed to sync namespace %s: %v", ns.Name, err)
return ctrl.Result{}, fmt.Errorf("failed to sync namespace: %w", err)
}
if op != controllerutil.OperationResultNone {
log.Info("namespace synced", "namespace", ns.Name)
r.Recorder.Eventf(&user, corev1.EventTypeNormal, "Synced", "Successfully reconciled. Namespace %s is %s", ns.Name, op)
kosmo.UserEventf(r.Recorder, &user, corev1.EventTypeNormal, "Synced", "Successfully reconciled. Namespace %s is %s", ns.Name, op)
}

user.Status.Phase = ns.Status.Phase
Expand All @@ -80,12 +81,12 @@ func (r *UserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
// generate default password if password secret is not found
if _, err := password.GetDefaultPassword(ctx, r.Client, user.Name); err != nil && apierrs.IsNotFound(err) {
if err := password.ResetPassword(ctx, r.Client, user.Name); err != nil {
r.Recorder.Eventf(&user, corev1.EventTypeWarning, "PasswordInitFailed", "Failed to reset password: %v", err)
kosmo.UserEventf(r.Recorder, &user, corev1.EventTypeWarning, "PasswordInitFailed", "Failed to reset password: %v", err)
log.Error(err, "failed to reset password")
return ctrl.Result{}, err
}
log.Info("password secret initialized")
r.Recorder.Eventf(&user, corev1.EventTypeNormal, "PasswordInitialized", "Successfully reset password secret")
kosmo.UserEventf(r.Recorder, &user, corev1.EventTypeNormal, "PasswordInitialized", "Successfully reset password secret")
}
}

Expand Down Expand Up @@ -124,7 +125,7 @@ func (r *UserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.

if op != controllerutil.OperationResultNone {
log.Info("addon synced", "addon", addon)
r.Recorder.Eventf(&user, corev1.EventTypeNormal, "AddonSynced", "Addon %s is %s", addon.Template.Name, op)
kosmo.UserEventf(r.Recorder, &user, corev1.EventTypeNormal, "AddonSynced", "Addon %s is %s", addon.Template.Name, op)
} else {
log.Debug().Info("the result of update addon instance operation is None", "addon", addon)
}
Expand All @@ -150,7 +151,7 @@ func (r *UserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.

if len(addonErrs) > 0 {
for _, e := range addonErrs {
r.Recorder.Eventf(&user, corev1.EventTypeWarning, "AddonFailed", "Failed to sync addon: %v", e)
kosmo.UserEventf(r.Recorder, &user, corev1.EventTypeWarning, "AddonFailed", "Failed to sync addon: %v", e)
log.Error(e, "failed to sync user addon")
}
user.Status.Phase = "AddonFailed"
Expand All @@ -172,10 +173,10 @@ func (r *UserReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
for _, d := range shouldDeletes {
if skip, err := prune(ctx, r.Client, d); err != nil {
log.Error(err, "failed to delete unused addon", "pruneAPIVersion", d.APIVersion, "pruneKind", d.Kind, "pruneName", d.Name, "pruneNamespace", d.Namespace)
r.Recorder.Eventf(&user, corev1.EventTypeWarning, "GCFailed", "Failed to delete unused addon: kind=%s name=%s namespace=%s", d.Kind, d.Name, d.Namespace)
kosmo.UserEventf(r.Recorder, &user, corev1.EventTypeWarning, "GCFailed", "Failed to delete unused addon: kind=%s name=%s namespace=%s", d.Kind, d.Name, d.Namespace)
} else if !skip {
log.Info("deleted unmanaged addon", "apiVersion", d.APIVersion, "kind", d.Kind, "name", d.Name, "namespace", d.Namespace)
r.Recorder.Eventf(&user, corev1.EventTypeNormal, "GC", "Deleted unmanaged addon: kind=%s name=%s namespace=%s", d.Kind, d.Name, d.Namespace)
kosmo.UserEventf(r.Recorder, &user, corev1.EventTypeNormal, "GC", "Deleted unmanaged addon: kind=%s name=%s namespace=%s", d.Kind, d.Name, d.Namespace)
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions internal/controllers/workspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
cosmov1alpha1 "github.com/cosmo-workspace/cosmo/api/v1alpha1"
"github.com/cosmo-workspace/cosmo/pkg/clog"
"github.com/cosmo-workspace/cosmo/pkg/instance"
"github.com/cosmo-workspace/cosmo/pkg/kosmo"
"github.com/cosmo-workspace/cosmo/pkg/workspace"
)

Expand Down Expand Up @@ -78,12 +79,12 @@ func (r *WorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
return nil
})
if err != nil {
r.Recorder.Eventf(&ws, corev1.EventTypeWarning, "SyncFailed", "Failed to sync instance %s: %v", inst.Name, err)
kosmo.WorkspaceEventf(r.Recorder, &ws, corev1.EventTypeWarning, "SyncFailed", "Failed to sync instance %s: %v", inst.Name, err)
return ctrl.Result{}, fmt.Errorf("failed to sync instance: %w", err)
}
if op != controllerutil.OperationResultNone {
log.Info("instance synced", "instance", inst.Name)
r.Recorder.Eventf(&ws, corev1.EventTypeNormal, "Synced", "Successfully reconciled. Instance %s is %s", inst.Name, op)
kosmo.WorkspaceEventf(r.Recorder, &ws, corev1.EventTypeNormal, "Synced", "Successfully reconciled. Instance %s is %s", inst.Name, op)
} else {
log.Debug().Info("the result of update workspace instance operation is None", "instance", inst.Name)
}
Expand All @@ -108,12 +109,12 @@ func (r *WorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
return r.TraefikIngressRouteCfg.PatchTraefikIngressRouteAsDesired(&ir, ws, r.Scheme)
})
if err != nil {
r.Recorder.Eventf(&ws, corev1.EventTypeWarning, "SyncFailed", "Failed to sync traefik ingress route %s: %v", ir.Name, err)
kosmo.WorkspaceEventf(r.Recorder, &ws, corev1.EventTypeWarning, "SyncFailed", "Failed to sync traefik ingress route %s: %v", ir.Name, err)
return ctrl.Result{}, fmt.Errorf("failed to sync traefik ingress route: %w", err)
}
if op != controllerutil.OperationResultNone {
log.Info("traefik ingress route synced", "ingressroute", ir.Name)
r.Recorder.Eventf(&ws, corev1.EventTypeNormal, "Synced", "Successfully reconciled. Traefik ingress route %s is %s", ir.Name, op)
kosmo.WorkspaceEventf(r.Recorder, &ws, corev1.EventTypeNormal, "Synced", "Successfully reconciled. Traefik ingress route %s is %s", ir.Name, op)
}

// generate URL and set to status
Expand Down
2 changes: 1 addition & 1 deletion internal/dashboard/user_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (s *Server) GetUser(ctx context.Context, req *connect_go.Request[dashv1alph
}
events, err := s.Klient.ListEvents(ctx, cosmov1alpha1.UserNamespace(user.Name))
if err != nil {
log.Error(err, "failed to list events", "namespace", cosmov1alpha1.UserNamespace(user.Name))
log.Error(err, "failed to list events", "user", user.Name)
}

res := &dashv1alpha1.GetUserResponse{
Expand Down
10 changes: 3 additions & 7 deletions internal/webhooks/workspace_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (h *WorkspaceMutationWebhookHandler) mutateWorkspace(ctx context.Context, w
}

func (h *WorkspaceMutationWebhookHandler) migrateTmplServiceToNetworkRule(ctx context.Context, ws *cosmov1alpha1.Workspace, rawTmpl string, cfg cosmov1alpha1.Config) error {
unst, err := preTemplateBuild(*ws, rawTmpl)
unst, err := preTemplateBuild(rawTmpl)
if err != nil {
return err
}
Expand Down Expand Up @@ -134,12 +134,8 @@ func appendNetworkRuleIfNotExist(ws *cosmov1alpha1.Workspace, netRule cosmov1alp
ws.Spec.Network = append(ws.Spec.Network, netRule)
}

func preTemplateBuild(ws cosmov1alpha1.Workspace, rawTmpl string) ([]unstructured.Unstructured, error) {
var inst cosmov1alpha1.Instance
inst.SetName(ws.GetName())
inst.SetNamespace(ws.GetNamespace())

builder := template.NewRawYAMLBuilder(rawTmpl, &inst)
func preTemplateBuild(rawTmpl string) ([]unstructured.Unstructured, error) {
builder := template.NewRawYAMLBuilder(rawTmpl)
return builder.Build()
}

Expand Down
Loading
Loading