Skip to content

Commit

Permalink
Merge pull request #399 from yuwenma/patch-1
Browse files Browse the repository at this point in the history
feat: Enable server-side-apply on direct applier
  • Loading branch information
k8s-ci-robot authored Sep 9, 2024
2 parents 1a63d5a + cdfac96 commit 57a043f
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/patterns/declarative/pkg/applier/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ import (
)

type DirectApplier struct {
inner directApplierSite
// Whether to apply the KRM resources using server-side apply. https://kubernetes.io/docs/reference/using-api/server-side-apply/
// Note: The server-side apply is stable in Kubernetes v1.22, users should take the responsibility to make sure the cluster
// server can support this feature.
serverSideApplyPreferred bool
inner directApplierSite
}

func (d *DirectApplier) UseServerSideApply() {
d.serverSideApplyPreferred = true
}

var _ Applier = &DirectApplier{}

type directApplier struct {
}
type directApplier struct{}

type directApplierSite interface {
Run(a *apply.ApplyOptions) error
Expand Down Expand Up @@ -170,6 +177,7 @@ func (d *DirectApplier) Apply(ctx context.Context, opt ApplierOptions) error {
applyOpts.PruneResources = append(applyOpts.PruneResources, r...)
}

applyOpts.ServerSideApply = d.serverSideApplyPreferred
applyOpts.ForceConflicts = opt.Force
applyOpts.Namespace = opt.Namespace
applyOpts.SetObjects(infos)
Expand Down

0 comments on commit 57a043f

Please sign in to comment.