Skip to content

Commit

Permalink
Merge pull request #143 from spring-financial-group/master
Browse files Browse the repository at this point in the history
fix: make extraDomains cleaner and less confusing
  • Loading branch information
jenkins-x-bot-test authored May 15, 2021
2 parents 36e6295 + f0de4e5 commit 720e1ed
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pkg/apis/core/v4beta1/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ type IngressConfig struct {
CloudDNSSecretName string `json:"cloud_dns_secret_name,omitempty"`
// Domain to expose ingress endpoints
Domain string `json:"domain"`
// Extra domains to expose alternate endpoints with custom ingress
ExtraDomains []string `json:"extraDomains,omitempty"`
// Kind the kind of ingress used (ingress v1, ingress v2, istio etc)
Kind IngressType `json:"kind,omitempty"`
// IgnoreLoadBalancer if the nginx-controller LoadBalancer service should not be used to detect and update the
Expand Down Expand Up @@ -521,6 +519,8 @@ type RequirementsConfig struct {
Cluster ClusterConfig `json:"cluster"`
// Environments the requirements for the environments
Environments []EnvironmentConfig `json:"environments,omitempty"`
// ExtraDomains to expose alternate services with custom ingress for specific applications
ExtraDomains []IngressConfig `json:"extraDomains,omitempty"`
// Ingress contains ingress specific requirements
Ingress IngressConfig `json:"ingress"`
// Kuberhealthy indicates if we have already installed Kuberhealthy upfront in the kubernetes cluster
Expand Down
18 changes: 15 additions & 3 deletions pkg/apis/core/v4beta1/requirements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,29 @@ func TestRequirementsConfigMarshalExistingFile(t *testing.T) {
expectedClusterName := "my-cluster"
expectedSecretStorage := v4beta1.SecretStorageTypeVault
expectedDomain := "cheese.co.uk"
expectedExtraDomains := []string{"wine.com", "grapes.org.uk"}
expectedPipelineUserName := "someone"
expectedPipelineUserEmail := "someone@acme.com"
expectedExtraDomains := []v4beta1.IngressConfig{{
Domain: "wine.com",
TLS: &v4beta1.TLSConfig{
Enabled: true,
Production: true,
},
}, {
Domain: "grapes.org.uk",
TLS: &v4beta1.TLSConfig{
Enabled: true,
Production: false,
},
}}

file := filepath.Join(dir, v4beta1.RequirementsConfigFileName)
requirementResource := v4beta1.NewRequirementsConfig()
requirements := &requirementResource.Spec
requirements.SecretStorage = expectedSecretStorage
requirements.Cluster.ClusterName = expectedClusterName
requirements.Ingress.Domain = expectedDomain
requirements.Ingress.ExtraDomains = expectedExtraDomains
requirements.ExtraDomains = expectedExtraDomains
requirements.PipelineUser = &v4beta1.UserNameEmailConfig{
Username: expectedPipelineUserName,
Email: expectedPipelineUserEmail,
Expand All @@ -61,7 +73,7 @@ func TestRequirementsConfigMarshalExistingFile(t *testing.T) {
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")
assert.Equal(t, expectedExtraDomains, requirements.Ingress.ExtraDomains, "requirements.extraDomains")
assert.Equal(t, expectedExtraDomains, requirements.ExtraDomains, "requirements.extraDomains")
}

func Test_OverrideRequirementsFromEnvironment_does_not_initialise_nil_structs(t *testing.T) {
Expand Down
13 changes: 7 additions & 6 deletions schema/core.jenkins-x.io/v4beta1/requirements.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,6 @@
"domain": {
"type": "string"
},
"extraDomains": {
"items": {
"type": "string"
},
"type": "array"
},
"externalDNS": {
"type": "boolean"
},
Expand Down Expand Up @@ -269,6 +263,13 @@
},
"type": "array"
},
"extraDomains": {
"items": {
"$schema": "http://json-schema.org/draft-04/schema#",
"$ref": "#/definitions/IngressConfig"
},
"type": "array"
},
"ingress": {
"$ref": "#/definitions/IngressConfig"
},
Expand Down

0 comments on commit 720e1ed

Please sign in to comment.