-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update chart lock, switch to helm dependency build command
- Loading branch information
1 parent
ac0686c
commit 180007b
Showing
3 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/lorislab/samo/log" | ||
"github.com/lorislab/samo/tools" | ||
"github.com/spf13/cobra" | ||
"os" | ||
) | ||
|
||
type helmLockUpdateFlags struct { | ||
Helm helmFlags `mapstructure:",squash"` | ||
KeepCharts bool `mapstructure:"helm-keep-charts"` | ||
} | ||
|
||
func createHelmLockUpdateCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "lock-update", | ||
Short: "Update Chart.lock file", | ||
Long: `Update the Helm chart Chart.lock or create a new one if it doesn't exist`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
flags := helmLockUpdateFlags{} | ||
readOptions(&flags) | ||
project := loadProject(flags.Helm.Project) | ||
helmLockUpdate(project, flags) | ||
}, | ||
TraverseChildren: true, | ||
} | ||
|
||
addBoolFlag(cmd, "helm-clean-charts", "", false, "keep chart directory after Chart.lock update") | ||
return cmd | ||
} | ||
|
||
func helmLockUpdate(project *Project, flags helmLockUpdateFlags) { | ||
|
||
dir := helmDir(project, flags.Helm) | ||
|
||
// update helm Chart.lock | ||
tools.ExecCmd("helm", "dependency", "update", dir) | ||
|
||
// keep chart directory? | ||
if flags.KeepCharts { | ||
return | ||
} | ||
|
||
charts := dir + "/charts" | ||
if _, err := os.Stat(charts); !os.IsNotExist(err) { | ||
log.Debug("Clean helm dependencies directory", log.F("dir", charts)) | ||
err := os.RemoveAll(charts) | ||
if err != nil { | ||
log.Panic("error delete directory", log.F("output", charts).E(err)) | ||
} | ||
} | ||
|
||
} |