mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
93e3801945
* Implement helm step * Create kubernetes package * Refactoring helm.go * Add package, test commands * Add test for helm package * Add tests for helm.go * Add tests for helm.go * Add tests for utils.go * Add tests for helmExecute.go * small fix * Add helm lint * small fix * small fix * Fix according to comments * Fix test * small fix * Add helm add function * Changes according to new comments * Add helm push * Add unit tests * Add tests for helmExecute * Add small fix * small fix * small fix * Move DeployUtilsBundle from kubernetesDeploy to kubernetes package * small fix * small fix * Add unit-tests * Fix * Update resources/metadata/helmExecute.yaml * Update resources/metadata/helmExecute.yaml * Add helm chart server parameterization * small fix * small fix Co-authored-by: “Vitalii <“vitalii.sidorov@sap.com”> Co-authored-by: Oliver Nocon <33484802+OliverNocon@users.noreply.github.com>
79 lines
2.7 KiB
Go
79 lines
2.7 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/SAP/jenkins-library/pkg/kubernetes"
|
|
"github.com/SAP/jenkins-library/pkg/log"
|
|
"github.com/SAP/jenkins-library/pkg/telemetry"
|
|
)
|
|
|
|
func helmExecute(config helmExecuteOptions, telemetryData *telemetry.CustomData) {
|
|
utils := kubernetes.NewDeployUtilsBundle()
|
|
|
|
helmConfig := kubernetes.HelmExecuteOptions{
|
|
ChartPath: config.ChartPath,
|
|
DeploymentName: config.DeploymentName,
|
|
ContainerRegistryURL: config.ContainerRegistryURL,
|
|
Image: config.Image,
|
|
ContainerImageName: config.ContainerImageName,
|
|
ContainerImageTag: config.ContainerImageTag,
|
|
Namespace: config.Namespace,
|
|
KubeContext: config.KubeContext,
|
|
KubeConfig: config.KubeConfig,
|
|
HelmDeployWaitSeconds: config.HelmDeployWaitSeconds,
|
|
DryRun: config.DryRun,
|
|
PackageVersion: config.PackageVersion,
|
|
AppVersion: config.AppVersion,
|
|
DependencyUpdate: config.DependencyUpdate,
|
|
HelmValues: config.HelmValues,
|
|
FilterTest: config.FilterTest,
|
|
DumpLogs: config.DumpLogs,
|
|
ChartRepo: config.ChartRepo,
|
|
HelmRegistryUser: config.HelmRegistryUser,
|
|
HelmChartServer: config.HelmChartServer,
|
|
}
|
|
|
|
helmExecutor := kubernetes.NewHelmExecutor(helmConfig, utils, GeneralConfig.Verbose, log.Writer())
|
|
|
|
// error situations should stop execution through log.Entry().Fatal() call which leads to an os.Exit(1) in the end
|
|
if err := runHelmExecute(config.HelmCommand, helmExecutor); err != nil {
|
|
log.Entry().WithError(err).Fatalf("step execution failed: %v", err)
|
|
}
|
|
}
|
|
|
|
func runHelmExecute(helmCommand string, helmExecutor kubernetes.HelmExecutor) error {
|
|
switch helmCommand {
|
|
case "upgrade":
|
|
if err := helmExecutor.RunHelmUpgrade(); err != nil {
|
|
return fmt.Errorf("failed to execute upgrade: %v", err)
|
|
}
|
|
case "lint":
|
|
if err := helmExecutor.RunHelmLint(); err != nil {
|
|
return fmt.Errorf("failed to execute helm lint: %v", err)
|
|
}
|
|
case "install":
|
|
if err := helmExecutor.RunHelmInstall(); err != nil {
|
|
return fmt.Errorf("failed to execute helm install: %v", err)
|
|
}
|
|
case "test":
|
|
if err := helmExecutor.RunHelmTest(); err != nil {
|
|
return fmt.Errorf("failed to execute helm test: %v", err)
|
|
}
|
|
case "uninstall":
|
|
if err := helmExecutor.RunHelmUninstall(); err != nil {
|
|
return fmt.Errorf("failed to execute helm uninstall: %v", err)
|
|
}
|
|
case "package":
|
|
if err := helmExecutor.RunHelmPackage(); err != nil {
|
|
return fmt.Errorf("failed to execute helm package: %v", err)
|
|
}
|
|
case "push":
|
|
if err := helmExecutor.RunHelmPush(); err != nil {
|
|
return fmt.Errorf("failed to execute helm push: %v", err)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|