Skip to content

Commit

Permalink
Support Azure cloud configuration for DNS Secrets (#2034)
Browse files Browse the repository at this point in the history
* Support azure cloud configuration for DNS Secrets

* PR Feedback

* Added check that azure secret contains valid GUIDs, see https://github.com/gardener/gardener-extension-provider-azure/blob/master/pkg/apis/azure/validation/secrets.go#L19

---------

Co-authored-by: Holger Koser <[email protected]>
  • Loading branch information
grolu and holgerkoser authored Sep 28, 2024
1 parent a2ed69c commit 2721499
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
25 changes: 23 additions & 2 deletions frontend/src/components/Secrets/GSecretDialogAzure.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ SPDX-License-Identifier: Apache-2.0
@blur="v$.subscriptionId.$touch()"
/>
</div>
<div v-if="isDNSSecret">
<v-select
v-model="azureCloud"
color="primary"
item-color="primary"
label="Azure Cloud"
:items="['AzurePublic', 'AzureChina', 'AzureGovernment']"
variant="underlined"
/>
</div>
</template>
<template #help-slot>
<div v-if="vendor==='azure'">
Expand All @@ -85,7 +95,7 @@ SPDX-License-Identifier: Apache-2.0
</g-external-link> on how to manage your credentials and subscriptions.
</p>
</div>
<div v-if="vendor==='azure-dns' || vendor==='azure-private-dns'">
<div v-if="isDNSSecret">
<p>
Follow the steps as described in the Azure documentation to
<g-external-link url="https://docs.microsoft.com/en-us/azure/dns/dns-sdk#create-a-service-principal-account">
Expand All @@ -105,7 +115,10 @@ import { required } from '@vuelidate/validators'
import GSecretDialog from '@/components/Secrets/GSecretDialog'
import GExternalLink from '@/components/GExternalLink'
import { withFieldName } from '@/utils/validators'
import {
withFieldName,
guid,
} from '@/utils/validators'
import { getErrorMessages } from '@/utils'
export default {
Expand Down Expand Up @@ -140,21 +153,25 @@ export default {
tenantId: undefined,
subscriptionId: undefined,
hideSecret: true,
azureCloud: 'AzurePublic',
}
},
validations () {
return {
clientId: withFieldName('Client ID', {
required,
guid,
}),
clientSecret: withFieldName('Client Secret', {
required,
}),
tenantId: withFieldName('Tenant ID', {
required,
guid,
}),
subscriptionId: withFieldName('Subscription ID', {
required,
guid,
}),
}
},
Expand All @@ -176,6 +193,7 @@ export default {
clientSecret: this.clientSecret,
subscriptionID: this.subscriptionId,
tenantID: this.tenantId,
AZURE_CLOUD: this.isDNSSecret ? this.azureCloud : undefined,
}
},
isCreateMode () {
Expand All @@ -193,6 +211,9 @@ export default {
}
return undefined
},
isDNSSecret () {
return this.vendor === 'azure-dns' || this.vendor === 'azure-private-dns'
},
},
methods: {
getErrorMessages,
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/utils/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const lowerCaseAlphaNumHyphenPattern = /^[-a-z0-9]*$/
const consecutiveHyphenPattern = /.?-{2,}.?/
const startEndHyphenPattern = /^-.*.|.*-$/
const numberOrPercentagePattern = /^[\d]+[%]?$/
const guidPattern = /^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$/
export const timezonePattern = /^([+-])(\d{2}):(\d{2})$/

const base64 = withMessage('Must be a valid base64 string', value => {
Expand All @@ -37,6 +38,7 @@ const noStartEndHyphen = withMessage('Must not start or end with a hyphen', valu
const numberOrPercentage = withMessage('Must be a number or percentage', value => {
return numberOrPercentagePattern.test(value)
})
const guid = withMessage('Must be a valid GUID', regex(guidPattern))

const isTimezone = withMessage('TimeZone must have format [+|-]HH:mm', value => {
return timezonePattern.test(value)
Expand Down Expand Up @@ -117,4 +119,5 @@ export {
includesIfAvailable,
numberOrPercentage,
isTimezone,
guid,
}

0 comments on commit 2721499

Please sign in to comment.