mirror of
https://github.com/wahyd4/cert-manager.git
synced 2026-08-09 05:06:38 +10:00
add validation to the correct place
Signed-off-by: Tomáš Freund <tomas.freund@datamole.cz>
This commit is contained in:
@@ -500,11 +500,11 @@ type ACMEIssuerDNS01ProviderAzureDNS struct {
|
||||
// +optional
|
||||
Environment AzureDNSEnvironment `json:"environment,omitempty"`
|
||||
|
||||
// clientID of the MSI that should be used (only relevant when using MSI, can not be used at the same time with ManagedIdentityResourceID)
|
||||
// clientID of the MSI that should be used (only relevant when using MSI, can not be used at the same time as ManagedIdentityResourceID)
|
||||
// +optional
|
||||
ManagedIdentityClientID string `json:"managedIdentityClientID,omitempty"`
|
||||
|
||||
// resourceID of the MSI that should be used (only relevant when using MSI, can not be used at the same time with ManagedIdentityClientID)
|
||||
// resourceID of the MSI that should be used (only relevant when using MSI, can not be used at the same time as ManagedIdentityClientID)
|
||||
// +optional
|
||||
ManagedIdentityResourceID string `json:"managedIdentityResourceID,omitempty"`
|
||||
}
|
||||
|
||||
@@ -497,11 +497,11 @@ type ACMEIssuerDNS01ProviderAzureDNS struct {
|
||||
// +optional
|
||||
Environment AzureDNSEnvironment `json:"environment,omitempty"`
|
||||
|
||||
// clientID of the MSI that should be used (only relevant when using MSI, can not be used at the same time with ManagedIdentityResourceID)
|
||||
// clientID of the MSI that should be used (only relevant when using MSI, can not be used at the same time as ManagedIdentityResourceID)
|
||||
// +optional
|
||||
ManagedIdentityClientID string `json:"managedIdentityClientID,omitempty"`
|
||||
|
||||
// resourceID of the MSI that should be used (only relevant when using MSI, can not be used at the same time with ManagedIdentityClientID)
|
||||
// resourceID of the MSI that should be used (only relevant when using MSI, can not be used at the same time as ManagedIdentityClientID)
|
||||
// +optional
|
||||
ManagedIdentityResourceID string `json:"managedIdentityResourceID,omitempty"`
|
||||
}
|
||||
|
||||
@@ -497,11 +497,11 @@ type ACMEIssuerDNS01ProviderAzureDNS struct {
|
||||
// +optional
|
||||
Environment AzureDNSEnvironment `json:"environment,omitempty"`
|
||||
|
||||
// clientID of the MSI that should be used (only relevant when using MSI, can not be used at the same time with ManagedIdentityResourceID)
|
||||
// clientID of the MSI that should be used (only relevant when using MSI, can not be used at the same time as ManagedIdentityResourceID)
|
||||
// +optional
|
||||
ManagedIdentityClientID string `json:"managedIdentityClientID,omitempty"`
|
||||
|
||||
// resourceID of the MSI that should be used (only relevant when using MSI, can not be used at the same time with ManagedIdentityClientID)
|
||||
// resourceID of the MSI that should be used (only relevant when using MSI, can not be used at the same time as ManagedIdentityClientID)
|
||||
// +optional
|
||||
ManagedIdentityResourceID string `json:"managedIdentityResourceID,omitempty"`
|
||||
}
|
||||
|
||||
@@ -496,11 +496,11 @@ type ACMEIssuerDNS01ProviderAzureDNS struct {
|
||||
// +optional
|
||||
Environment AzureDNSEnvironment `json:"environment,omitempty"`
|
||||
|
||||
// clientID of the MSI that should be used (only relevant when using MSI, can not be used at the same time with ManagedIdentityResourceID)
|
||||
// clientID of the MSI that should be used (only relevant when using MSI, can not be used at the same time as ManagedIdentityResourceID)
|
||||
// +optional
|
||||
ManagedIdentityClientID string `json:"managedIdentityClientID,omitempty"`
|
||||
|
||||
// resourceID of the MSI that should be used (only relevant when using MSI, can not be used at the same time with ManagedIdentityClientID)
|
||||
// resourceID of the MSI that should be used (only relevant when using MSI, can not be used at the same time as ManagedIdentityClientID)
|
||||
// +optional
|
||||
ManagedIdentityResourceID string `json:"managedIdentityResourceID,omitempty"`
|
||||
}
|
||||
|
||||
@@ -427,6 +427,10 @@ type ACMEIssuerDNS01ProviderAzureDNS struct {
|
||||
HostedZoneName string
|
||||
|
||||
Environment AzureDNSEnvironment
|
||||
|
||||
ManagedIdentityClientID string
|
||||
|
||||
ManagedIdentityResourceID string
|
||||
}
|
||||
|
||||
type AzureDNSEnvironment string
|
||||
|
||||
@@ -335,6 +335,18 @@ func ValidateACMEChallengeSolverDNS01(p *cmacme.ACMEChallengeSolverDNS01, fldPat
|
||||
if len(p.AzureDNS.TenantID) == 0 {
|
||||
el = append(el, field.Required(fldPath.Child("azureDNS", "tenantID"), ""))
|
||||
}
|
||||
if len(p.AzureDNS.ManagedIdentityClientID) > 0 {
|
||||
el = append(el, field.Forbidden(fldPath.Child("azureDNS", "managedIdentityClientID"), "managed identity can not be used at the same time as clientID, tenantID or clientSecret"))
|
||||
}
|
||||
if len(p.AzureDNS.ManagedIdentityResourceID) > 0 {
|
||||
el = append(el, field.Forbidden(fldPath.Child("azureDNS", "managedIdentityResourceID"), "managed identity can not be used at the same time as clientID, tenantID or clientSecret"))
|
||||
}
|
||||
} else {
|
||||
// using managed identity
|
||||
if len(p.AzureDNS.ManagedIdentityClientID) > 0 && len(p.AzureDNS.ManagedIdentityResourceID) > 0 {
|
||||
el = append(el, field.Forbidden(fldPath.Child("azureDNS"), "managedIdentityClientID and managedIdentityResourceID connot both be specified"))
|
||||
}
|
||||
|
||||
}
|
||||
// SubscriptionID must always be defined
|
||||
if len(p.AzureDNS.SubscriptionID) == 0 {
|
||||
|
||||
@@ -49,10 +49,6 @@ func NewDNSProviderCredentials(environment, clientID, clientSecret, subscription
|
||||
}
|
||||
}
|
||||
|
||||
if managedIdentityClientID != "" && managedIdentityResourceID != "" {
|
||||
return nil, fmt.Errorf("managedIdentityClientID and managedIdentityResourceID can not be set at the same time")
|
||||
}
|
||||
|
||||
spt, err := getAuthorization(env, clientID, clientSecret, subscriptionID, tenantID, ambient, managedIdentityClientID, managedIdentityResourceID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user