mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-28 05:47:08 +02:00
Adds repository name as parameter
This commit is contained in:
parent
040a18f928
commit
8fc471c909
@ -181,6 +181,7 @@ func runKubeCtlCommand(command gitopsUpdateDeploymentExecRunner, patchString str
|
||||
}
|
||||
|
||||
func runHelmCommand(runner gitopsUpdateDeploymentExecRunner, config *gitopsUpdateDeploymentOptions, workingDirectory string) ([]byte, error) {
|
||||
sourceDirectory := filepath.Join(workingDirectory, config.RepositoryName)
|
||||
var helmOutput = bytes.Buffer{}
|
||||
runner.Stdout(&helmOutput)
|
||||
|
||||
@ -195,8 +196,8 @@ func runHelmCommand(runner gitopsUpdateDeploymentExecRunner, config *gitopsUpdat
|
||||
helmParams := []string{
|
||||
"template",
|
||||
config.DeploymentName,
|
||||
filepath.Join(workingDirectory, config.ChartPath),
|
||||
"--values=" + filepath.Join(workingDirectory, config.HelmAdditionalValueFile),
|
||||
filepath.Join(sourceDirectory, config.ChartPath),
|
||||
"--values=" + filepath.Join(sourceDirectory, config.HelmAdditionalValueFile),
|
||||
"--set=" + config.HelmValueForRespositoryAndImageName + "=" + registryImage,
|
||||
"--set=" + config.HelmValueForImageVersion + "=" + imageTag,
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ type gitopsUpdateDeploymentOptions struct {
|
||||
HelmValueForRespositoryAndImageName string `json:"helmValueForRespositoryAndImageName,omitempty"`
|
||||
HelmValueForImageVersion string `json:"helmValueForImageVersion,omitempty"`
|
||||
DeploymentName string `json:"deploymentName,omitempty"`
|
||||
RepositoryName string `json:"repositoryName,omitempty"`
|
||||
DeployTool string `json:"deployTool,omitempty"`
|
||||
}
|
||||
|
||||
@ -108,6 +109,7 @@ func addGitopsUpdateDeploymentFlags(cmd *cobra.Command, stepConfig *gitopsUpdate
|
||||
cmd.Flags().StringVar(&stepConfig.HelmValueForRespositoryAndImageName, "helmValueForRespositoryAndImageName", os.Getenv("PIPER_helmValueForRespositoryAndImageName"), "value description used in the template to specify the repository and image name of the deployment")
|
||||
cmd.Flags().StringVar(&stepConfig.HelmValueForImageVersion, "helmValueForImageVersion", os.Getenv("PIPER_helmValueForImageVersion"), "value description used in the template to specify the version of the deployment")
|
||||
cmd.Flags().StringVar(&stepConfig.DeploymentName, "deploymentName", os.Getenv("PIPER_deploymentName"), "Defines the name of the deployment.")
|
||||
cmd.Flags().StringVar(&stepConfig.RepositoryName, "repositoryName", os.Getenv("PIPER_repositoryName"), "The name of the repository that is build by this pipeline")
|
||||
cmd.Flags().StringVar(&stepConfig.DeployTool, "deployTool", `kubectl`, "Defines the tool which should be used for deployment.")
|
||||
|
||||
cmd.MarkFlagRequired("commitMessage")
|
||||
@ -263,6 +265,14 @@ func gitopsUpdateDeploymentMetadata() config.StepData {
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{{Name: "helmDeploymentName"}},
|
||||
},
|
||||
{
|
||||
Name: "repositoryName",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
|
||||
Type: "string",
|
||||
Mandatory: false,
|
||||
Aliases: []config.Alias{},
|
||||
},
|
||||
{
|
||||
Name: "deployTool",
|
||||
ResourceRef: []config.ResourceReference{},
|
||||
|
@ -218,6 +218,7 @@ func TestRunGitopsUpdateDeploymentWithHelm(t *testing.T) {
|
||||
DeploymentName: "myFancyDeployment",
|
||||
HelmValueForRespositoryAndImageName: "image.repositoryName",
|
||||
HelmAdditionalValueFile: "./helm/additionalValues.yaml",
|
||||
RepositoryName: "sourceRepo",
|
||||
}
|
||||
|
||||
t.Parallel()
|
||||
@ -232,8 +233,8 @@ func TestRunGitopsUpdateDeploymentWithHelm(t *testing.T) {
|
||||
assert.Equal(t, "helm", runnerMock.executable)
|
||||
assert.Equal(t, "template", runnerMock.params[0])
|
||||
assert.Equal(t, "myFancyDeployment", runnerMock.params[1])
|
||||
assert.Equal(t, filepath.Join(".", "helm"), runnerMock.params[2])
|
||||
assert.Equal(t, "--values="+filepath.Join(".", "helm/additionalValues.yaml"), runnerMock.params[3])
|
||||
assert.Equal(t, filepath.Join(".", "sourceRepo", "helm"), runnerMock.params[2])
|
||||
assert.Equal(t, "--values="+filepath.Join(".", "sourceRepo", "helm/additionalValues.yaml"), runnerMock.params[3])
|
||||
assert.Equal(t, "--set=image.repositoryName=myregistry.com/registry/containers/myFancyContainer", runnerMock.params[4])
|
||||
assert.Equal(t, "--set=image.version=1337", runnerMock.params[5])
|
||||
})
|
||||
|
@ -153,6 +153,13 @@ spec:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- name: repositoryName
|
||||
type: string
|
||||
description: The name of the repository that is build by this pipeline
|
||||
scope:
|
||||
- PARAMETERS
|
||||
- STAGES
|
||||
- STEPS
|
||||
- name: deployTool
|
||||
type: string
|
||||
description: Defines the tool which should be used for deployment.
|
||||
|
Loading…
x
Reference in New Issue
Block a user