From 7d7461207b3d29ca0885cbfd49f903c2723bb05a Mon Sep 17 00:00:00 2001 From: John Long Date: Thu, 30 Nov 2023 16:47:29 -0500 Subject: [PATCH] switched to patch instead of replace for updates --- Dockerfile | 2 +- go.mod | 2 ++ internal/kubernetes/client.go | 8 ++++++++ internal/repo/deploy.go | 2 +- internal/repo/release.go | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8640c16..ab6876e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Compress binary -FROM ghcr.io/xigxog/upx:4.2.0 AS upx +FROM ghcr.io/xigxog/upx:4.2.1 AS upx ARG COMPRESS=false diff --git a/go.mod b/go.mod index 2f0f7da..103ceef 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/xigxog/fox go 1.21 +replace github.com/xigxog/kubefox => ../kubefox + require ( github.com/cli/oauth v1.0.1 github.com/docker/docker v24.0.7+incompatible diff --git a/internal/kubernetes/client.go b/internal/kubernetes/client.go index ffdbefd..fd9b2d0 100644 --- a/internal/kubernetes/client.go +++ b/internal/kubernetes/client.go @@ -87,6 +87,14 @@ func (c *Client) Apply(ctx context.Context, obj client.Object) error { return c.Client.Apply(ctx, obj, opts...) } +func (c *Client) Merge(ctx context.Context, modified, original client.Object) error { + opts := []client.PatchOption{} + if c.cfg.Flags.DryRun { + opts = append(opts, client.DryRunAll) + } + return c.Client.Merge(ctx, modified, original, opts...) +} + func (r *Client) ListPlatforms(ctx context.Context) ([]v1alpha1.Platform, error) { pList := &v1alpha1.PlatformList{} if err := r.Client.List(ctx, pList); err != nil { diff --git a/internal/repo/deploy.go b/internal/repo/deploy.go index 6c4aa7b..dd638a7 100644 --- a/internal/repo/deploy.go +++ b/internal/repo/deploy.go @@ -40,7 +40,7 @@ func (r *repo) Deploy(name string, skipImageCheck bool) *v1alpha1.AppDeployment } log.VerboseMarshal(d, "AppDeployment:") - if err := r.k8s.Upsert(ctx, d); err != nil { + if err := r.k8s.Merge(ctx, d, nil); err != nil { log.Fatal("%v", err) } diff --git a/internal/repo/release.go b/internal/repo/release.go index efb7cfc..e839150 100644 --- a/internal/repo/release.go +++ b/internal/repo/release.go @@ -61,7 +61,7 @@ func (r *repo) Release(appDepId string) *v1alpha1.Release { }, } - if err := r.k8s.Upsert(ctx, rel); err != nil { + if err := r.k8s.Apply(ctx, rel); err != nil { log.Fatal("Error creating release: %v", err) }