Skip to content

Commit

Permalink
Support generating cert based TLS type secret
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardChen820 committed Jan 30, 2024
1 parent 237d661 commit f9f7474
Show file tree
Hide file tree
Showing 12 changed files with 528 additions and 230 deletions.
6 changes: 3 additions & 3 deletions api/v1/azureappconfigurationprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type AzureAppConfigurationProviderSpec struct {
Target ConfigurationGenerationParameters `json:"target"`
Auth *AzureAppConfigurationProviderAuth `json:"auth,omitempty"`
Configuration AzureAppConfigurationKeyValueOptions `json:"configuration,omitempty"`
Secret *AzureKeyVaultReference `json:"secret,omitempty"`
Secret *AzureSecretReference `json:"secret,omitempty"`
FeatureFlag *AzureAppConfigurationFeatureFlagOptions `json:"featureFlag,omitempty"`
}

Expand Down Expand Up @@ -141,8 +141,8 @@ type ManagedIdentityReferenceParameters struct {
Key string `json:"key"`
}

// AzureKeyVaultReference defines the authentication type used to Azure KeyVault resolve KeyVaultReference
type AzureKeyVaultReference struct {
// AzureSecretReference defines the authentication type used to Azure KeyVault resolve KeyVaultReference
type AzureSecretReference struct {
Target SecretGenerationParameters `json:"target"`
Auth *AzureKeyVaultAuth `json:"auth,omitempty"`
Refresh *RefreshSettings `json:"refresh,omitempty"`
Expand Down
10 changes: 5 additions & 5 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ spec:
type: array
type: object
secret:
description: AzureKeyVaultReference defines the authentication type
description: AzureSecretReference defines the authentication type
used to Azure KeyVault resolve KeyVaultReference
properties:
auth:
Expand Down
231 changes: 159 additions & 72 deletions internal/controller/appconfigurationprovider_controller.go

Large diffs are not rendered by default.

35 changes: 29 additions & 6 deletions internal/controller/appconfigurationprovider_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,27 @@ var _ = Describe("AppConfiguationProvider controller", func() {
mapResult["testSecretKey2"] = []byte("testValue2")
mapResult["testSecretKey3"] = []byte("testValue3")

secretName := "secret-to-be-created-3"
allSettings := &loader.TargetKeyValueSettings{
SecretSettings: mapResult,
SecretSettings: map[string]corev1.Secret{
secretName: {
Data: mapResult,
Type: corev1.SecretType("Opaque"),
},
},
SecretReferences: map[string]*loader.TargetSecretReference{
secretName: &loader.TargetSecretReference{
Type: corev1.SecretType("Opaque"),
UriSegments: make(map[string]loader.KeyVaultSecretUriSegment),
},
},
}

mockConfigurationSettings.EXPECT().CreateTargetSettings(gomock.Any(), gomock.Any()).Return(allSettings, nil)

ctx := context.Background()
providerName := "test-appconfigurationprovider-3"
configMapName := "configmap-to-be-created-3"
secretName := "secret-to-be-created-3"
configProvider := &acpv1.AzureAppConfigurationProvider{
TypeMeta: metav1.TypeMeta{
APIVersion: "appconfig.kubernetes.config/v1",
Expand All @@ -175,7 +186,7 @@ var _ = Describe("AppConfiguationProvider controller", func() {
Target: acpv1.ConfigurationGenerationParameters{
ConfigMapName: configMapName,
},
Secret: &acpv1.AzureKeyVaultReference{
Secret: &acpv1.AzureSecretReference{
Target: acpv1.SecretGenerationParameters{
SecretName: secretName,
},
Expand Down Expand Up @@ -213,17 +224,29 @@ var _ = Describe("AppConfiguationProvider controller", func() {
secretResult["testSecretKey2"] = []byte("testSecretValue2")
secretResult["testSecretKey3"] = []byte("testSecretValue3")

secretName := "secret-to-be-created-5"
allSettings := &loader.TargetKeyValueSettings{
SecretSettings: secretResult,
SecretSettings: map[string]corev1.Secret{
secretName: {
Data: secretResult,
Type: corev1.SecretType("Opaque"),
},
},
ConfigMapSettings: configMapResult,
SecretReferences: map[string]*loader.TargetSecretReference{
secretName: &loader.TargetSecretReference{
Type: corev1.SecretType("Opaque"),
UriSegments: make(map[string]loader.KeyVaultSecretUriSegment),
},
},
}

mockConfigurationSettings.EXPECT().CreateTargetSettings(gomock.Any(), gomock.Any()).Return(allSettings, nil)

ctx := context.Background()
providerName := "test-appconfigurationprovider-5"
configMapName := "configmap-to-be-created-5"
secretName := "secret-to-be-created-5"

configProvider := &acpv1.AzureAppConfigurationProvider{
TypeMeta: metav1.TypeMeta{
APIVersion: "appconfig.kubernetes.config/v1",
Expand All @@ -238,7 +261,7 @@ var _ = Describe("AppConfiguationProvider controller", func() {
Target: acpv1.ConfigurationGenerationParameters{
ConfigMapName: configMapName,
},
Secret: &acpv1.AzureKeyVaultReference{
Secret: &acpv1.AzureSecretReference{
Target: acpv1.SecretGenerationParameters{
SecretName: secretName,
},
Expand Down
Loading

0 comments on commit f9f7474

Please sign in to comment.