@@ -123,6 +123,15 @@ func SetCertificate(certificates []CertificateSpec, newCertificate CertificateSp
123
123
return certificates
124
124
}
125
125
126
+ // GetCertificateSecretName returns the name of secret for a certificate alias.
127
+ func GetCertificateSecretName (certificates []CertificateSpec , alias string ) (string , bool ) {
128
+ idx , cert := GetCertificate (certificates , alias )
129
+ if idx == - 1 {
130
+ return "" , false
131
+ }
132
+ return cert .SecretName , cert .SecretName != ""
133
+ }
134
+
126
135
// SetMissingSecretNameForCertificate sets the missing secret name for a certificate.
127
136
// If the certificate does not exist, it will add a new certificate with the desired secret name.
128
137
func SetMissingSecretNameForCertificate (certificates []CertificateSpec , alias , secretName string ) []CertificateSpec {
@@ -140,6 +149,22 @@ func SetMissingSecretNameForCertificate(certificates []CertificateSpec, alias, s
140
149
return certificates
141
150
}
142
151
152
+ // SetSecretNameForCertificate sets the secret name for a certificate.
153
+ // If the certificate does not exist, it will add a new certificate with the desired secret name.
154
+ // Otherwise, the secret name will be overwritten.
155
+ func SetSecretNameForCertificate (certificates []CertificateSpec , alias , secretName string ) []CertificateSpec {
156
+ idx , _ := GetCertificate (certificates , alias )
157
+ if idx != - 1 {
158
+ certificates [idx ].SecretName = secretName
159
+ } else {
160
+ certificates = append (certificates , CertificateSpec {
161
+ Alias : alias ,
162
+ SecretName : secretName ,
163
+ })
164
+ }
165
+ return certificates
166
+ }
167
+
143
168
// RemoveCertificate remove a certificate from the certificate list referred by "aliaS" parameter.
144
169
func RemoveCertificate (certificates []CertificateSpec , alias string ) []CertificateSpec {
145
170
idx , _ := GetCertificate (certificates , alias )
0 commit comments