Skip to content

Commit

Permalink
more azure fettling
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsimonemms committed Oct 3, 2024
1 parent bb8ebc1 commit 24bda49
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,10 @@ const docTemplate = `{
"azure_auth": {
"$ref": "#/definitions/types.AzureAuth"
},
"azure_dns_zone_resource_group": {
"description": "Azure",
"type": "string"
},
"civo_auth": {
"$ref": "#/definitions/types.CivoAuth"
},
Expand Down
4 changes: 4 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,10 @@
"azure_auth": {
"$ref": "#/definitions/types.AzureAuth"
},
"azure_dns_zone_resource_group": {
"description": "Azure",
"type": "string"
},
"civo_auth": {
"$ref": "#/definitions/types.CivoAuth"
},
Expand Down
3 changes: 3 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ definitions:
type: string
azure_auth:
$ref: '#/definitions/types.AzureAuth'
azure_dns_zone_resource_group:
description: Azure
type: string
civo_auth:
$ref: '#/definitions/types.CivoAuth'
cloud_provider:
Expand Down
1 change: 0 additions & 1 deletion extensions/azure/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ func BootstrapAzureMgmtCluster(clientset kubernetes.Interface, cl *pkgtypes.Clus
DestinationGitopsRepoURL: destinationGitopsRepoURL,
GitProtocol: cl.GitProtocol,
CloudflareAPIToken: cl.CloudflareAuth.APIToken,
CloudAuth: cl.CivoAuth.Token,
DNSProvider: cl.DNSProvider,
CloudProvider: cl.CloudProvider,
HTTPSPassword: cl.GitAuth.Token,
Expand Down
1 change: 1 addition & 0 deletions internal/controller/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ func (clctrl *ClusterController) CreateTokens(kind string) interface{} {
case "azure":
gitopsTemplateTokens.AzureStorageResourceGroup = "kubefirst-state" // @todo(sje): take from resourceGroup var in internal/controller/state.go
gitopsTemplateTokens.AzureStorageContainerName = "terraform" // @todo(sje): take from containerName var in internal/controller/state.go
gitopsTemplateTokens.AzureDNSZoneResourceGroup = clctrl.AzureDNSZoneResourceGroup
case "k3s":
gitopsTemplateTokens.K3sServersPrivateIps = clctrl.K3sAuth.K3sServersPrivateIps
gitopsTemplateTokens.K3sServersPublicIps = clctrl.K3sAuth.K3sServersPublicIps
Expand Down
6 changes: 6 additions & 0 deletions pkg/providerConfigs/detokenize.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,14 @@ func detokenizeGitops(tokens *GitopsDirectoryValues, gitProtocol string, useClou
newContents = strings.ReplaceAll(newContents, "<AWS_NODE_CAPACITY_TYPE>", tokens.AwsNodeCapacityType)

// Azure
azureDnsZoneName := ""

Check failure on line 91 in pkg/providerConfigs/detokenize.go

View workflow job for this annotation

GitHub Actions / run-tests

var-naming: var azureDnsZoneName should be azureDNSZoneName (revive)
if tokens.ExternalDNSProviderName == "azure" {
azureDnsZoneName = fullDomainName
}
newContents = strings.ReplaceAll(newContents, "<KUBEFIRST_STATE_STORE_RESOURCE_GROUP>", tokens.AzureStorageResourceGroup)
newContents = strings.ReplaceAll(newContents, "<KUBEFIRST_STATE_STORE_CONTAINER_NAME>", tokens.AzureStorageContainerName)
newContents = strings.ReplaceAll(newContents, "<AZURE_DNS_ZONE_RESOURCE_GROUP>", tokens.AzureDNSZoneResourceGroup)
newContents = strings.ReplaceAll(newContents, "<AZURE_DNS_ZONE_NAME>", azureDnsZoneName) // This is only set if using Azure for DNS

// google
newContents = strings.ReplaceAll(newContents, "<GOOGLE_PROJECT>", tokens.GoogleProject)
Expand Down
1 change: 1 addition & 0 deletions pkg/providerConfigs/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type GitopsDirectoryValues struct {

AzureStorageResourceGroup string
AzureStorageContainerName string
AzureDNSZoneResourceGroup string

GoogleAuth string
GoogleProject string
Expand Down
3 changes: 3 additions & 0 deletions pkg/types/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ type Cluster struct {
AWSKMSKeyID string `bson:"aws_kms_key_id,omitempty" json:"aws_kms_key_id,omitempty"`
AWSKMSKeyDetokenizedCheck bool `bson:"aws_kms_key_detokenized_check" json:"aws_kms_key_detokenized_check"`

// Azure
AzureDNSZoneResourceGroup string `bson:"azure_dns_zone_resource_group,omitempty" json:"azure_dns_zone_resource_group,omitempty"`

// Telemetry
UseTelemetry bool `bson:"use_telemetry"`

Expand Down
1 change: 1 addition & 0 deletions pkg/utils/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ func CreateTokensFromDatabaseRecord(cl *pkgtypes.Cluster, registryPath string, s
// @todo(sje): is this not used?
gitopsTemplateTokens.AzureStorageResourceGroup = "kubefirst-state" // @todo(sje): take from resourceGroup var in internal/controller/state.go
gitopsTemplateTokens.AzureStorageContainerName = "terraform" // @todo(sje): take from containerName var in internal/controller/state.go
gitopsTemplateTokens.AzureDNSZoneResourceGroup = cl.AzureDNSZoneResourceGroup
}

return gitopsTemplateTokens
Expand Down

0 comments on commit 24bda49

Please sign in to comment.