Skip to content

Commit

Permalink
uniform processCreateErr func to deal the resource create
Browse files Browse the repository at this point in the history
  • Loading branch information
JameKeal committed May 13, 2022
1 parent a6af9c9 commit ee15d8b
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions pkg/yurtctl/util/kubernetes/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,8 @@ func CreateDeployFromYaml(cliSet *kubernetes.Clientset, ns, dplyTmpl string, ctx
if !ok {
return errors.New("fail to assert Deployment")
}
if _, err = cliSet.AppsV1().Deployments(ns).Create(context.Background(), dply, metav1.CreateOptions{}); err != nil {
return err
}
klog.V(4).Infof("the deployment/%s is deployed", dply.Name)
return nil
_, err = cliSet.AppsV1().Deployments(ns).Create(context.Background(), dply, metav1.CreateOptions{})
return processCreateErr("deployment", dply.Name, err)
}

// CreateDaemonSetFromYaml creates the DaemonSet from the yaml template.
Expand All @@ -214,11 +211,7 @@ func CreateDaemonSetFromYaml(cliSet *kubernetes.Clientset, ns, dsTmpl string, ct
return fmt.Errorf("fail to assert daemonset: %v", err)
}
_, err = cliSet.AppsV1().DaemonSets(ns).Create(context.Background(), ds, metav1.CreateOptions{})
if err != nil {
return fmt.Errorf("fail to create the daemonset/%s: %v", ds.Name, err)
}
klog.V(4).Infof("daemonset/%s is created", ds.Name)
return nil
return processCreateErr("daemonset", ds.Name, err)
}

// CreateServiceFromYaml creates the Service from the yaml template.
Expand Down

0 comments on commit ee15d8b

Please sign in to comment.