1
0
mirror of synced 2026-03-20 01:26:57 +00:00

Add label arg to create commands

This commit is contained in:
stefanprodan
2020-09-08 17:42:32 +03:00
parent 9dbfca3d7a
commit 797cd9bea2
15 changed files with 107 additions and 43 deletions

View File

@@ -126,10 +126,7 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
return fmt.Errorf("chart name or path is required")
}
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
kubeClient, err := utils.kubeClient(kubeconfig)
sourceLabels, err := parseLabels()
if err != nil {
return err
}
@@ -142,6 +139,7 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Labels: sourceLabels,
},
Spec: helmv2.HelmReleaseSpec{
ReleaseName: hrName,
@@ -182,6 +180,14 @@ func createHelmReleaseCmdRun(cmd *cobra.Command, args []string) error {
return exportHelmRelease(helmRelease)
}
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
kubeClient, err := utils.kubeClient(kubeconfig)
if err != nil {
return err
}
logger.Actionf("applying release")
if err := upsertHelmRelease(ctx, kubeClient, helmRelease); err != nil {
return err
@@ -238,6 +244,7 @@ func upsertHelmRelease(ctx context.Context, kubeClient client.Client, helmReleas
return err
}
existing.Labels = helmRelease.Labels
existing.Spec = helmRelease.Spec
if err := kubeClient.Update(ctx, &existing); err != nil {
return err