Skip to content

Commit

Permalink
Merge pull request #41 from jstrachan/changes
Browse files Browse the repository at this point in the history
fix: add optional pipeline user/email
  • Loading branch information
jenkins-x-bot authored Jul 30, 2020
2 parents 48e3ee8 + e53b4b9 commit f41973c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/config/install_requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,14 @@ type RequirementsValues struct {
RequirementsConfig *RequirementsConfig `json:"jxRequirements,omitempty"`
}

// UserNameEmailConfig contains the user name and email of a user (e.g. pipeline user)
type UserNameEmailConfig struct {
// Username the username of the user
Username string `json:"username,omitempty"`
// Email the email address of the user
Email string `json:"email,omitempty"`
}

// RequirementsConfig contains the logical installation requirements in the `jx-requirements.yml` file when
// installing, configuring or upgrading Jenkins X via `jx boot`
type RequirementsConfig struct {
Expand All @@ -544,6 +552,8 @@ type RequirementsConfig struct {
Kaniko bool `json:"kaniko,omitempty"`
// Ingress contains ingress specific requirements
Ingress IngressConfig `json:"ingress"`
// PipelineUser the user name and email used for running pipelines
PipelineUser *UserNameEmailConfig `json:"pipelineUser,omitempty"`
// Repository specifies what kind of artifact repository you wish to use for storing artifacts (jars, tarballs, npm modules etc)
Repository RepositoryType `json:"repository,omitempty" envconfig:"JX_REQUIREMENT_REPOSITORY"`
// SecretStorage how should we store secrets for the cluster
Expand Down
13 changes: 13 additions & 0 deletions pkg/config/install_requirements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,19 @@ func TestRequirementsConfigMarshalExistingFile(t *testing.T) {
expectedClusterName := "my-cluster"
expectedSecretStorage := config.SecretStorageTypeVault
expectedDomain := "cheese.co.uk"
expectedPipelineUserName := "someone"
expectedPipelineUserEmail := "someone@acme.com"

file := filepath.Join(dir, config.RequirementsConfigFileName)
requirements := config.NewRequirementsConfig()
requirements.SecretStorage = expectedSecretStorage
requirements.Cluster.ClusterName = expectedClusterName
requirements.Ingress.Domain = expectedDomain
requirements.Kaniko = true
requirements.PipelineUser = &config.UserNameEmailConfig{
Username: expectedPipelineUserName,
Email: expectedPipelineUserEmail,
}

err = requirements.SaveConfig(file)
assert.NoError(t, err, "failed to save file %s", file)
Expand All @@ -61,10 +67,17 @@ func TestRequirementsConfigMarshalExistingFile(t *testing.T) {
assert.NoError(t, err, "failed to load requirements file in subDir: %s", subDir)
assert.FileExists(t, fileName)

t.Logf("generated requirements file %s\n", fileName)

assert.Equal(t, true, requirements.Kaniko, "requirements.Kaniko")
assert.Equal(t, expectedClusterName, requirements.Cluster.ClusterName, "requirements.ClusterName")
assert.Equal(t, expectedSecretStorage, requirements.SecretStorage, "requirements.SecretStorage")
assert.Equal(t, expectedDomain, requirements.Ingress.Domain, "requirements.Domain")

require.NotNil(t, requirements.PipelineUser, "requirements.PipelineUser")
assert.Equal(t, expectedPipelineUserName, requirements.PipelineUser.Username, "requirements.PipelineUser.Username")
assert.Equal(t, expectedPipelineUserEmail, requirements.PipelineUser.Email, "requirements.PipelineUser.Email")

}

func Test_OverrideRequirementsFromEnvironment_does_not_initialise_nil_structs(t *testing.T) {
Expand Down
21 changes: 21 additions & 0 deletions pkg/config/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f41973c

Please sign in to comment.