mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-12 10:55:20 +02:00
Add renderSubchartNotes property to helmExecute and kubernetesDeploy (#4238)
Co-authored-by: Philipp Stehle <philipp.stehle@sap.com> Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com>
This commit is contained in:
parent
d12f01d90f
commit
35a55044b4
@ -41,6 +41,7 @@ func helmExecute(config helmExecuteOptions, telemetryData *telemetry.CustomData,
|
|||||||
CustomTLSCertificateLinks: config.CustomTLSCertificateLinks,
|
CustomTLSCertificateLinks: config.CustomTLSCertificateLinks,
|
||||||
Version: config.Version,
|
Version: config.Version,
|
||||||
PublishVersion: config.Version,
|
PublishVersion: config.Version,
|
||||||
|
RenderSubchartNotes: config.RenderSubchartNotes,
|
||||||
}
|
}
|
||||||
|
|
||||||
utils := kubernetes.NewDeployUtilsBundle(helmConfig.CustomTLSCertificateLinks)
|
utils := kubernetes.NewDeployUtilsBundle(helmConfig.CustomTLSCertificateLinks)
|
||||||
|
@ -45,6 +45,7 @@ type helmExecuteOptions struct {
|
|||||||
CustomTLSCertificateLinks []string `json:"customTlsCertificateLinks,omitempty"`
|
CustomTLSCertificateLinks []string `json:"customTlsCertificateLinks,omitempty"`
|
||||||
Publish bool `json:"publish,omitempty"`
|
Publish bool `json:"publish,omitempty"`
|
||||||
Version string `json:"version,omitempty"`
|
Version string `json:"version,omitempty"`
|
||||||
|
RenderSubchartNotes bool `json:"renderSubchartNotes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type helmExecuteCommonPipelineEnvironment struct {
|
type helmExecuteCommonPipelineEnvironment struct {
|
||||||
@ -224,6 +225,7 @@ func addHelmExecuteFlags(cmd *cobra.Command, stepConfig *helmExecuteOptions) {
|
|||||||
cmd.Flags().StringSliceVar(&stepConfig.CustomTLSCertificateLinks, "customTlsCertificateLinks", []string{}, "List of download links to custom TLS certificates. This is required to ensure trusted connections to instances with repositories (like nexus) when publish flag is set to true.")
|
cmd.Flags().StringSliceVar(&stepConfig.CustomTLSCertificateLinks, "customTlsCertificateLinks", []string{}, "List of download links to custom TLS certificates. This is required to ensure trusted connections to instances with repositories (like nexus) when publish flag is set to true.")
|
||||||
cmd.Flags().BoolVar(&stepConfig.Publish, "publish", false, "Configures helm to run the deploy command to publish artifacts to a repository.")
|
cmd.Flags().BoolVar(&stepConfig.Publish, "publish", false, "Configures helm to run the deploy command to publish artifacts to a repository.")
|
||||||
cmd.Flags().StringVar(&stepConfig.Version, "version", os.Getenv("PIPER_version"), "Defines the artifact version to use from helm package/publish commands.")
|
cmd.Flags().StringVar(&stepConfig.Version, "version", os.Getenv("PIPER_version"), "Defines the artifact version to use from helm package/publish commands.")
|
||||||
|
cmd.Flags().BoolVar(&stepConfig.RenderSubchartNotes, "renderSubchartNotes", true, "If set, render subchart notes along with the parent.")
|
||||||
|
|
||||||
cmd.MarkFlagRequired("image")
|
cmd.MarkFlagRequired("image")
|
||||||
}
|
}
|
||||||
@ -595,6 +597,15 @@ func helmExecuteMetadata() config.StepData {
|
|||||||
Aliases: []config.Alias{},
|
Aliases: []config.Alias{},
|
||||||
Default: os.Getenv("PIPER_version"),
|
Default: os.Getenv("PIPER_version"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "renderSubchartNotes",
|
||||||
|
ResourceRef: []config.ResourceReference{},
|
||||||
|
Scope: []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"},
|
||||||
|
Type: "bool",
|
||||||
|
Mandatory: false,
|
||||||
|
Aliases: []config.Alias{},
|
||||||
|
Default: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Containers: []config.Container{
|
Containers: []config.Container{
|
||||||
|
@ -200,6 +200,10 @@ func runHelmDeploy(config kubernetesDeployOptions, utils kubernetes.DeployUtils,
|
|||||||
upgradeParams = append(upgradeParams, "--kube-context", config.KubeContext)
|
upgradeParams = append(upgradeParams, "--kube-context", config.KubeContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.RenderSubchartNotes {
|
||||||
|
upgradeParams = append(upgradeParams, "--render-subchart-notes")
|
||||||
|
}
|
||||||
|
|
||||||
if len(config.AdditionalParameters) > 0 {
|
if len(config.AdditionalParameters) > 0 {
|
||||||
upgradeParams = append(upgradeParams, config.AdditionalParameters...)
|
upgradeParams = append(upgradeParams, config.AdditionalParameters...)
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ type kubernetesDeployOptions struct {
|
|||||||
HelmTestWaitSeconds int `json:"helmTestWaitSeconds,omitempty"`
|
HelmTestWaitSeconds int `json:"helmTestWaitSeconds,omitempty"`
|
||||||
HelmValues []string `json:"helmValues,omitempty"`
|
HelmValues []string `json:"helmValues,omitempty"`
|
||||||
ValuesMapping map[string]interface{} `json:"valuesMapping,omitempty"`
|
ValuesMapping map[string]interface{} `json:"valuesMapping,omitempty"`
|
||||||
|
RenderSubchartNotes bool `json:"renderSubchartNotes,omitempty"`
|
||||||
GithubToken string `json:"githubToken,omitempty"`
|
GithubToken string `json:"githubToken,omitempty"`
|
||||||
Image string `json:"image,omitempty"`
|
Image string `json:"image,omitempty"`
|
||||||
ImageNames []string `json:"imageNames,omitempty"`
|
ImageNames []string `json:"imageNames,omitempty"`
|
||||||
@ -189,6 +190,7 @@ func addKubernetesDeployFlags(cmd *cobra.Command, stepConfig *kubernetesDeployOp
|
|||||||
cmd.Flags().IntVar(&stepConfig.HelmTestWaitSeconds, "helmTestWaitSeconds", 300, "Number of seconds to wait for any individual Kubernetes operation (like Jobs for hooks). See https://helm.sh/docs/helm/helm_test/#options for further details")
|
cmd.Flags().IntVar(&stepConfig.HelmTestWaitSeconds, "helmTestWaitSeconds", 300, "Number of seconds to wait for any individual Kubernetes operation (like Jobs for hooks). See https://helm.sh/docs/helm/helm_test/#options for further details")
|
||||||
cmd.Flags().StringSliceVar(&stepConfig.HelmValues, "helmValues", []string{}, "List of helm values as YAML file reference or URL (as per helm parameter description for `-f` / `--values`)")
|
cmd.Flags().StringSliceVar(&stepConfig.HelmValues, "helmValues", []string{}, "List of helm values as YAML file reference or URL (as per helm parameter description for `-f` / `--values`)")
|
||||||
|
|
||||||
|
cmd.Flags().BoolVar(&stepConfig.RenderSubchartNotes, "renderSubchartNotes", true, "If set, render subchart notes along with the parent.")
|
||||||
cmd.Flags().StringVar(&stepConfig.GithubToken, "githubToken", os.Getenv("PIPER_githubToken"), "GitHub personal access token as per https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line")
|
cmd.Flags().StringVar(&stepConfig.GithubToken, "githubToken", os.Getenv("PIPER_githubToken"), "GitHub personal access token as per https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line")
|
||||||
cmd.Flags().StringVar(&stepConfig.Image, "image", os.Getenv("PIPER_image"), "Full name of the image to be deployed.")
|
cmd.Flags().StringVar(&stepConfig.Image, "image", os.Getenv("PIPER_image"), "Full name of the image to be deployed.")
|
||||||
cmd.Flags().StringSliceVar(&stepConfig.ImageNames, "imageNames", []string{}, "List of names of the images to be deployed.")
|
cmd.Flags().StringSliceVar(&stepConfig.ImageNames, "imageNames", []string{}, "List of names of the images to be deployed.")
|
||||||
@ -444,6 +446,15 @@ func kubernetesDeployMetadata() config.StepData {
|
|||||||
Mandatory: false,
|
Mandatory: false,
|
||||||
Aliases: []config.Alias{},
|
Aliases: []config.Alias{},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "renderSubchartNotes",
|
||||||
|
ResourceRef: []config.ResourceReference{},
|
||||||
|
Scope: []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"},
|
||||||
|
Type: "bool",
|
||||||
|
Mandatory: false,
|
||||||
|
Aliases: []config.Alias{},
|
||||||
|
Default: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "githubToken",
|
Name: "githubToken",
|
||||||
ResourceRef: []config.ResourceReference{
|
ResourceRef: []config.ResourceReference{
|
||||||
|
@ -43,6 +43,7 @@ func TestRunKubernetesDeploy(t *testing.T) {
|
|||||||
DeploymentName: "deploymentName",
|
DeploymentName: "deploymentName",
|
||||||
DeployTool: "helm",
|
DeployTool: "helm",
|
||||||
ForceUpdates: true,
|
ForceUpdates: true,
|
||||||
|
RenderSubchartNotes: true,
|
||||||
HelmDeployWaitSeconds: 400,
|
HelmDeployWaitSeconds: 400,
|
||||||
IngressHosts: []string{"ingress.host1", "ingress.host2"},
|
IngressHosts: []string{"ingress.host1", "ingress.host2"},
|
||||||
Image: "path/to/Image:latest",
|
Image: "path/to/Image:latest",
|
||||||
@ -90,6 +91,7 @@ func TestRunKubernetesDeploy(t *testing.T) {
|
|||||||
"--atomic",
|
"--atomic",
|
||||||
"--kube-context",
|
"--kube-context",
|
||||||
"testCluster",
|
"testCluster",
|
||||||
|
"--render-subchart-notes",
|
||||||
"--testParam",
|
"--testParam",
|
||||||
"testValue",
|
"testValue",
|
||||||
}, mockUtils.Calls[2].Params, "Wrong upgrade parameters")
|
}, mockUtils.Calls[2].Params, "Wrong upgrade parameters")
|
||||||
|
@ -61,6 +61,7 @@ type HelmExecuteOptions struct {
|
|||||||
SourceRepositoryPassword string `json:"sourceRepositoryPassword,omitempty"`
|
SourceRepositoryPassword string `json:"sourceRepositoryPassword,omitempty"`
|
||||||
HelmCommand string `json:"helmCommand,omitempty"`
|
HelmCommand string `json:"helmCommand,omitempty"`
|
||||||
CustomTLSCertificateLinks []string `json:"customTlsCertificateLinks,omitempty"`
|
CustomTLSCertificateLinks []string `json:"customTlsCertificateLinks,omitempty"`
|
||||||
|
RenderSubchartNotes bool `json:"renderSubchartNotes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHelmExecutor creates HelmExecute instance
|
// NewHelmExecutor creates HelmExecute instance
|
||||||
@ -168,6 +169,10 @@ func (h *HelmExecute) RunHelmUpgrade() error {
|
|||||||
helmParams = append(helmParams, "--atomic")
|
helmParams = append(helmParams, "--atomic")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if h.config.RenderSubchartNotes {
|
||||||
|
helmParams = append(helmParams, "--render-subchart-notes")
|
||||||
|
}
|
||||||
|
|
||||||
if len(h.config.AdditionalParameters) > 0 {
|
if len(h.config.AdditionalParameters) > 0 {
|
||||||
helmParams = append(helmParams, h.config.AdditionalParameters...)
|
helmParams = append(helmParams, h.config.AdditionalParameters...)
|
||||||
}
|
}
|
||||||
@ -230,16 +235,24 @@ func (h *HelmExecute) RunHelmInstall() error {
|
|||||||
}
|
}
|
||||||
helmParams = append(helmParams, "--namespace", h.config.Namespace)
|
helmParams = append(helmParams, "--namespace", h.config.Namespace)
|
||||||
helmParams = append(helmParams, "--create-namespace")
|
helmParams = append(helmParams, "--create-namespace")
|
||||||
|
|
||||||
if !h.config.KeepFailedDeployments {
|
if !h.config.KeepFailedDeployments {
|
||||||
helmParams = append(helmParams, "--atomic")
|
helmParams = append(helmParams, "--atomic")
|
||||||
}
|
}
|
||||||
|
|
||||||
helmParams = append(helmParams, "--wait", "--timeout", fmt.Sprintf("%vs", h.config.HelmDeployWaitSeconds))
|
helmParams = append(helmParams, "--wait", "--timeout", fmt.Sprintf("%vs", h.config.HelmDeployWaitSeconds))
|
||||||
for _, v := range h.config.HelmValues {
|
for _, v := range h.config.HelmValues {
|
||||||
helmParams = append(helmParams, "--values", v)
|
helmParams = append(helmParams, "--values", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if h.config.RenderSubchartNotes {
|
||||||
|
helmParams = append(helmParams, "--render-subchart-notes")
|
||||||
|
}
|
||||||
|
|
||||||
if len(h.config.AdditionalParameters) > 0 {
|
if len(h.config.AdditionalParameters) > 0 {
|
||||||
helmParams = append(helmParams, h.config.AdditionalParameters...)
|
helmParams = append(helmParams, h.config.AdditionalParameters...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if h.verbose {
|
if h.verbose {
|
||||||
helmParams = append(helmParams, "--debug")
|
helmParams = append(helmParams, "--debug")
|
||||||
}
|
}
|
||||||
|
@ -131,11 +131,12 @@ func TestRunHelmUpgrade(t *testing.T) {
|
|||||||
Image: "dtzar/helm-kubectl:3.4.1",
|
Image: "dtzar/helm-kubectl:3.4.1",
|
||||||
TargetRepositoryName: "test",
|
TargetRepositoryName: "test",
|
||||||
TargetRepositoryURL: "https://charts.helm.sh/stable",
|
TargetRepositoryURL: "https://charts.helm.sh/stable",
|
||||||
|
RenderSubchartNotes: true,
|
||||||
},
|
},
|
||||||
generalVerbose: true,
|
generalVerbose: true,
|
||||||
expectedExecCalls: []mock.ExecCall{
|
expectedExecCalls: []mock.ExecCall{
|
||||||
{Exec: "helm", Params: []string{"repo", "add", "test", "https://charts.helm.sh/stable", "--debug"}},
|
{Exec: "helm", Params: []string{"repo", "add", "test", "https://charts.helm.sh/stable", "--debug"}},
|
||||||
{Exec: "helm", Params: []string{"upgrade", "test_deployment", "test", "--debug", "--install", "--namespace", "test_namespace", "--force", "--wait", "--timeout", "3456s", "--atomic", "additional parameter"}},
|
{Exec: "helm", Params: []string{"upgrade", "test_deployment", "test", "--debug", "--install", "--namespace", "test_namespace", "--force", "--wait", "--timeout", "3456s", "--atomic", "--render-subchart-notes", "additional parameter"}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -231,11 +232,12 @@ func TestRunHelmInstall(t *testing.T) {
|
|||||||
HelmDeployWaitSeconds: 525,
|
HelmDeployWaitSeconds: 525,
|
||||||
TargetRepositoryURL: "https://charts.helm.sh/stable",
|
TargetRepositoryURL: "https://charts.helm.sh/stable",
|
||||||
TargetRepositoryName: "test",
|
TargetRepositoryName: "test",
|
||||||
|
RenderSubchartNotes: true,
|
||||||
},
|
},
|
||||||
generalVerbose: false,
|
generalVerbose: false,
|
||||||
expectedExecCalls: []mock.ExecCall{
|
expectedExecCalls: []mock.ExecCall{
|
||||||
{Exec: "helm", Params: []string{"repo", "add", "test", "https://charts.helm.sh/stable"}},
|
{Exec: "helm", Params: []string{"repo", "add", "test", "https://charts.helm.sh/stable"}},
|
||||||
{Exec: "helm", Params: []string{"install", "testPackage", "test", "--namespace", "test-namespace", "--create-namespace", "--atomic", "--wait", "--timeout", "525s"}},
|
{Exec: "helm", Params: []string{"install", "testPackage", "test", "--namespace", "test-namespace", "--create-namespace", "--atomic", "--wait", "--timeout", "525s", "--render-subchart-notes"}},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -336,6 +336,15 @@ spec:
|
|||||||
- PARAMETERS
|
- PARAMETERS
|
||||||
- STAGES
|
- STAGES
|
||||||
- STEPS
|
- STEPS
|
||||||
|
- name: renderSubchartNotes
|
||||||
|
type: bool
|
||||||
|
description: If set, render subchart notes along with the parent.
|
||||||
|
default: true
|
||||||
|
scope:
|
||||||
|
- GENERAL
|
||||||
|
- PARAMETERS
|
||||||
|
- STAGES
|
||||||
|
- STEPS
|
||||||
containers:
|
containers:
|
||||||
- image: dtzar/helm-kubectl:3
|
- image: dtzar/helm-kubectl:3
|
||||||
workingDir: /config
|
workingDir: /config
|
||||||
|
@ -310,6 +310,15 @@ spec:
|
|||||||
- PARAMETERS
|
- PARAMETERS
|
||||||
- STAGES
|
- STAGES
|
||||||
- STEPS
|
- STEPS
|
||||||
|
- name: renderSubchartNotes
|
||||||
|
type: bool
|
||||||
|
description: If set, render subchart notes along with the parent.
|
||||||
|
default: true
|
||||||
|
scope:
|
||||||
|
- GENERAL
|
||||||
|
- PARAMETERS
|
||||||
|
- STAGES
|
||||||
|
- STEPS
|
||||||
- name: githubToken
|
- name: githubToken
|
||||||
description: "GitHub personal access token as per
|
description: "GitHub personal access token as per
|
||||||
https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line"
|
https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line"
|
||||||
|
Loading…
Reference in New Issue
Block a user