From f0bd8013fae402f05d640481e24f55e173cc6f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E4=BD=9C=E6=AC=A2?= Date: Fri, 3 Nov 2023 16:36:52 +0800 Subject: [PATCH] :art: --- k8s/client.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/k8s/client.go b/k8s/client.go index 214d537..3012fcb 100644 --- a/k8s/client.go +++ b/k8s/client.go @@ -7,7 +7,6 @@ import ( "fmt" appv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/json" "k8s.io/client-go/kubernetes" kindv1 "k8s.io/client-go/kubernetes/typed/apps/v1" "time" @@ -70,7 +69,9 @@ func (c client) Do(namespace, kind, resourceName, actionMethod, repo string) (er return fmt.Errorf("repo not empty") } - resource.(*appv1.Deployment).Spec.Template.Spec.Containers[0].Image = utils.ParseImage(repo) + repo = utils.ParseImage(repo) + + resource.(*appv1.Deployment).Spec.Template.Spec.Containers[0].Image = repo _, err = kindType.(kindv1.DeploymentInterface).Update(context.Background(), resource.(*appv1.Deployment), metav1.UpdateOptions{}) @@ -94,10 +95,6 @@ func (c client) Do(namespace, kind, resourceName, actionMethod, repo string) (er return fmt.Errorf("get deployment error: %v", err.Error()) } - rJ, _ := json.Marshal(resource) - - fmt.Println(string(rJ)) - resource.(*appv1.Deployment).Spec.Template.ObjectMeta.Annotations["kubectl.kubernetes.io/restartedAt"] = time.Now().Local().String() _, err = kindType.(kindv1.DeploymentInterface).Update(context.Background(), resource.(*appv1.Deployment), metav1.UpdateOptions{}) if err != nil {