Compare commits

..

No commits in common. "master" and "v1.0.3" have entirely different histories.

View File

@ -7,6 +7,7 @@ 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"
@ -69,9 +70,7 @@ func (c client) Do(namespace, kind, resourceName, actionMethod, repo string) (er
return fmt.Errorf("repo not empty")
}
repo = utils.ParseImage(repo)
resource.(*appv1.Deployment).Spec.Template.Spec.Containers[0].Image = repo
resource.(*appv1.Deployment).Spec.Template.Spec.Containers[0].Image = utils.ParseImage(repo)
_, err = kindType.(kindv1.DeploymentInterface).Update(context.Background(), resource.(*appv1.Deployment), metav1.UpdateOptions{})
@ -95,6 +94,10 @@ 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 {