Skip to content

Commit

Permalink
#221 upsert deployment when dogu cr changed security context
Browse files Browse the repository at this point in the history
  • Loading branch information
nroeske committed Dec 16, 2024
1 parent 2cd64c4 commit 9a34e3e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion controllers/dogu_security_context_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package controllers

import (
"context"
"fmt"
k8sv2 "github.com/cloudogu/k8s-dogu-operator/v3/api/v2"
"github.com/cloudogu/k8s-dogu-operator/v3/controllers/resource"
"github.com/cloudogu/k8s-dogu-operator/v3/controllers/util"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
)

const (
Expand All @@ -18,6 +20,7 @@ const (

type doguSecurityContextManager struct {
doguResourceGenerator resource.DoguResourceGenerator
resourceDoguFetcher resourceDoguFetcher
resourceUpserter resource.ResourceUpserter
client client.Client
eventRecorder record.EventRecorder
Expand All @@ -33,6 +36,17 @@ func NewDoguSecurityContextManager(k8sClient client.Client, mgrSet *util.Manager
}

func (d doguSecurityContextManager) UpdateDeploymentWithSecurityContext(ctx context.Context, doguResource *k8sv2.Dogu) error {
//d.resourceUpserter.UpsertDoguDeployment()
logger := log.FromContext(ctx)
logger.Info("Fetching dogu...")
dogu, _, err := d.resourceDoguFetcher.FetchWithResource(ctx, doguResource)
if err != nil {
return err
}

logger.Info("Upserting deployment... ")
_, err = d.resourceUpserter.UpsertDoguDeployment(ctx, doguResource, dogu, nil)
if err != nil {
return fmt.Errorf("failed to upsert deployment with security context: %w", err)
}
return nil
}

0 comments on commit 9a34e3e

Please sign in to comment.