Skip to content

Commit

Permalink
fix(api/types): merge cert-manager request w/ same issuer name[2]
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed Oct 22, 2021
1 parent a98bebb commit 9bc8dd6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/v1alpha1/rpaasinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (i *RpaasInstance) CertManagerRequests() (reqs []CertManager) {
if found {
r.DNSNames = append(r.DNSNames, req.DNSNames...)
r.IPAddresses = append(r.IPAddresses, req.IPAddresses...)
uniqueCerts[req.Issuer] = r
continue
}

Expand Down
40 changes: 40 additions & 0 deletions api/v1alpha1/rpaasinstance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,43 @@ func Test_BelongsToCluster(t *testing.T) {
belongs = instance.BelongsToCluster("cluster01")
assert.Equal(t, true, belongs)
}

func TestCertManagerRequests(t *testing.T) {
instance := &RpaasInstance{
Spec: RpaasInstanceSpec{
// this is a default certificate
DynamicCertificates: &DynamicCertificates{
CertManager: &CertManager{
Issuer: "my-issuer",
DNSNames: []string{
"default-domain.my-company.io",
},
IPAddresses: []string{
"10.1.1.1",
},
},
CertManagerRequests: []CertManager{
{
Issuer: "my-issuer",
DNSNames: []string{
"custom-domain.my-company.io",
},
IPAddresses: []string{
"10.1.1.2",
},
},
},
},
},
}

assert.Equal(t, []CertManager{
{
Issuer: "my-issuer",
DNSNames: []string{"default-domain.my-company.io", "custom-domain.my-company.io"},
IPAddresses: []string{"10.1.1.1", "10.1.1.2"},
DNSNamesDefault: false,
},
}, instance.CertManagerRequests())

}

0 comments on commit 9bc8dd6

Please sign in to comment.