Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new secret types to Applications.Core/secretstores #7816

Merged

Conversation

lakshmimsft
Copy link
Contributor

Description

Add new types to Applications.Core/secretstores (basicAuthentication, azureWorkloadIdentity, awsIRSA)
Update convertor, tests.
Update existing ValidateAndMutateRequest() in /pkg/corerp/frontend/controller/secretstores/kubernetes.go
to check if required secret keys exist for current secret type. Add to existing unit tests.

Type of change

Fixes: Part of #6917

@@ -106,6 +106,12 @@ func toSecretStoreDataTypeDataModel(src *SecretStoreDataType) datamodel.SecretTy
return datamodel.SecretTypeGeneric
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets add validations here during conversion if the required keys are present for the particular type. ex: "clientID" and "tenantID" keys should be present for type "azureWorkloadIdentity" type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed offline. Currently validations are included in

func ValidateAndMutateRequest(ctx context.Context, newResource *datamodel.SecretStore, oldResource *datamodel.SecretStore, options *controller.Options) (rest.Response, error) {
in line with other validations required for creating this resource. This function is accessed by controller here:
_ = ns.AddResource("secretStores", &builder.ResourceOption[*datamodel.SecretStore, datamodel.SecretStore]{

including @kachawla to confirm this is the right approach.

@lakshmimsft lakshmimsft marked this pull request as ready for review August 22, 2024 16:51
@lakshmimsft lakshmimsft requested review from a team as code owners August 22, 2024 16:51
Copy link

codecov bot commented Aug 22, 2024

Codecov Report

Attention: Patch coverage is 36.84211% with 12 lines in your changes missing coverage. Please review.

Project coverage is 61.03%. Comparing base (84cb120) to head (896cfc1).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...erp/api/v20231001preview/secretstore_conversion.go 0.00% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7816      +/-   ##
==========================================
- Coverage   61.08%   61.03%   -0.05%     
==========================================
  Files         523      523              
  Lines       27474    27493      +19     
==========================================
- Hits        16782    16781       -1     
- Misses       9210     9226      +16     
- Partials     1482     1486       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@radius-functional-tests
Copy link

radius-functional-tests bot commented Aug 22, 2024

Radius functional test overview

🔍 Go to test action run

Name Value
Repository lakshmimsft/radius-mainfork
Commit ref e577624
Unique ID func0cf485eb0f
Image tag pr-func0cf485eb0f
Click here to see the list of tools in the current test run
  • gotestsum 1.12.0
  • KinD: v0.20.0
  • Dapr: 1.12.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-func0cf485eb0f
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-func0cf485eb0f
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-func0cf485eb0f
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-func0cf485eb0f
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting corerp-cloud functional tests...
⌛ Starting datastoresrp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ datastoresrp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

@radius-functional-tests
Copy link

radius-functional-tests bot commented Aug 28, 2024

Radius functional test overview

🔍 Go to test action run

Name Value
Repository lakshmimsft/radius-mainfork
Commit ref d3e04e8
Unique ID func165aa50b04
Image tag pr-func165aa50b04
Click here to see the list of tools in the current test run
  • gotestsum 1.12.0
  • KinD: v0.20.0
  • Dapr: 1.12.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-func165aa50b04
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-func165aa50b04
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-func165aa50b04
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-func165aa50b04
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting corerp-cloud functional tests...
⌛ Starting datastoresrp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
✅ datastoresrp-cloud functional tests succeeded
✅ ucp-cloud functional tests succeeded
❌ corerp-cloud functional test failed. Please check the logs for more details

vishwahiremat
vishwahiremat previously approved these changes Aug 28, 2024
Copy link
Contributor

@vishwahiremat vishwahiremat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

newResource := testutil.MustGetTestData[datamodel.SecretStore](testFileCertValueFrom)
newResource.Properties.Resource = ""
resp, err := ValidateAndMutateRequest(context.TODO(), newResource, oldResource, nil)
tests := []struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@radius-functional-tests
Copy link

radius-functional-tests bot commented Aug 29, 2024

Radius functional test overview

🔍 Go to test action run

Name Value
Repository lakshmimsft/radius-mainfork
Commit ref babef6d
Unique ID func2ed15fc8d8
Image tag pr-func2ed15fc8d8
Click here to see the list of tools in the current test run
  • gotestsum 1.12.0
  • KinD: v0.20.0
  • Dapr: 1.12.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-func2ed15fc8d8
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-func2ed15fc8d8
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-func2ed15fc8d8
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-func2ed15fc8d8
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting ucp-cloud functional tests...
⌛ Starting datastoresrp-cloud functional tests...
⌛ Starting corerp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ datastoresrp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

Comment on lines 50 to 51
// SecretTypeAzureWorkloadIdentity is the azureFederatedIdentity secret type.
SecretTypeAzureWorkloadIdentity SecretType = "azureWorkloadIdentity"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// SecretTypeAzureWorkloadIdentity is the azureFederatedIdentity secret type.
SecretTypeAzureWorkloadIdentity SecretType = "azureWorkloadIdentity"
// SecretTypeAzureWorkloadIdentity is the azureWorkloadIdentity secret type.
SecretTypeAzureWorkloadIdentity SecretType = "azureWorkloadIdentity"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: pkg/corerp/frontend/controller/secretstores/testdata/secretstores_datamodel_awsirsa.json

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: pkg/corerp/frontend/controller/secretstores/testdata/secretstores_datamodel_azwi.json

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: pkg/corerp/frontend/controller/secretstores/testdata/secretstores_datamodel_basicauth.json

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: pkg/corerp/frontend/controller/secretstores/testdata/secretstores_datamodel_basicauth_invalid.json

@radius-functional-tests
Copy link

radius-functional-tests bot commented Aug 29, 2024

Radius functional test overview

🔍 Go to test action run

Name Value
Repository lakshmimsft/radius-mainfork
Commit ref b5527f7
Unique ID funcaad93367ab
Image tag pr-funcaad93367ab
Click here to see the list of tools in the current test run
  • gotestsum 1.12.0
  • KinD: v0.20.0
  • Dapr: 1.12.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-funcaad93367ab
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-funcaad93367ab
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-funcaad93367ab
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-funcaad93367ab
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting corerp-cloud functional tests...
⌛ Starting datastoresrp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
✅ datastoresrp-cloud functional tests succeeded
✅ ucp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

ytimocin
ytimocin previously approved these changes Aug 29, 2024
@radius-functional-tests
Copy link

radius-functional-tests bot commented Aug 29, 2024

Radius functional test overview

🔍 Go to test action run

Name Value
Repository lakshmimsft/radius-mainfork
Commit ref 896cfc1
Unique ID funcb7ea5236a7
Image tag pr-funcb7ea5236a7
Click here to see the list of tools in the current test run
  • gotestsum 1.12.0
  • KinD: v0.20.0
  • Dapr: 1.12.0
  • Azure KeyVault CSI driver: 1.4.2
  • Azure Workload identity webhook: 1.3.0
  • Bicep recipe location ghcr.io/radius-project/dev/test/testrecipes/test-bicep-recipes/<name>:pr-funcb7ea5236a7
  • Terraform recipe location http://tf-module-server.radius-test-tf-module-server.svc.cluster.local/<name>.zip (in cluster)
  • applications-rp test image location: ghcr.io/radius-project/dev/applications-rp:pr-funcb7ea5236a7
  • controller test image location: ghcr.io/radius-project/dev/controller:pr-funcb7ea5236a7
  • ucp test image location: ghcr.io/radius-project/dev/ucpd:pr-funcb7ea5236a7
  • deployment-engine test image location: ghcr.io/radius-project/deployment-engine:latest

Test Status

⌛ Building Radius and pushing container images for functional tests...
✅ Container images build succeeded
⌛ Publishing Bicep Recipes for functional tests...
✅ Recipe publishing succeeded
⌛ Starting corerp-cloud functional tests...
⌛ Starting ucp-cloud functional tests...
⌛ Starting datastoresrp-cloud functional tests...
✅ ucp-cloud functional tests succeeded
✅ datastoresrp-cloud functional tests succeeded
✅ corerp-cloud functional tests succeeded

@lakshmimsft lakshmimsft merged commit 50fef93 into radius-project:main Aug 29, 2024
29 checks passed
@@ -79,7 +79,7 @@ model RecipeConfigProperties {
@doc("Configuration for Terraform Recipes. Controls how Terraform plans and applies templates as part of Recipe deployment.")
terraform?: TerraformConfigProperties;

@doc("Environment variables injected during Terraform Recipe execution for the recipes in the environment.")
@doc("Environment variables injected during recipe execution for the recipes in the environment.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lakshmimsft what's causing this to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correcting the comment to indicate environment variables schema is part of RecipeConfigProperties and is not intended to be specific to Terraform execution.

Copy link
Contributor

@kachawla kachawla Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lakshmimsft it is specific to Terraform though at this point. Unless we are actually injecting these env vars for non-Terraform recipes, we shouldn't indicate it is. As a user, I'd then set it assuming it works for bicep as well, which it doesn't.

Copy link
Contributor Author

@lakshmimsft lakshmimsft Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a question asked in a design meeting: radius-project/design-notes#53 (comment)
Perhaps the comment should be more clear, eg: Environment variables injected during recipe execution for the recipes in the environment, currently supported for Terraform recipes.
Updated in in #7867

@doc("basicAuthentication type is used to represent username and password based authentication and the secretstore resource is expected to have the keys 'username' and 'password'.")
basicAuthentication,

@doc("azureWorkloadIdentity type is used to represent registry authentication using azure federated identity and the secretstore resource is expected to have the keys 'clientId' and 'tenantId'.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to call out "registry authentication" here? This resource is/can be referenced in multiple places with use cases being not limited to ACR. I'd also get PMs eyes on these user facing descriptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @vishwahiremat, @Reshrahim . referring to link

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with not specifying registry here as it can be referenced elsewhere as well.

Suggested change
@doc("azureWorkloadIdentity type is used to represent registry authentication using azure federated identity and the secretstore resource is expected to have the keys 'clientId' and 'tenantId'.")
@doc("azureWorkloadIdentity type is used to represent authentication using azure federated identity and the secretstore resource is expected to have the keys 'clientId' and 'tenantId'.")

Copy link
Contributor

@Reshrahim Reshrahim Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@doc("azureWorkloadIdentity type is used to represent registry authentication using azure federated identity and the secretstore resource is expected to have the keys 'clientId' and 'tenantId'.")
@doc("azureWorkloadIdentity type is used to represent authentication using azure workload identity and the secretstore resource is expected to have the keys 'clientId' and 'tenantId'.")

Copy link
Contributor

@Reshrahim Reshrahim Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is referenced as Azure workload identity and not federated identity in the docs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Reshrahim. What are your thoughts on explicitly mentioned "registry" authentication? Secret store resource is not limited to supporting management of secrets only for the use case of registries.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sorry din notice the comment above. I agree with your comment of calling it as authentication as the uses cases can be outside of registries

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming @Reshrahim.

@vishwahiremat @lakshmimsft - could one of you please update this as per Reshma's feedback?

@doc("azureWorkloadIdentity type is used to represent registry authentication using azure federated identity and the secretstore resource is expected to have the keys 'clientId' and 'tenantId'.")
azureWorkloadIdentity,

@doc("awsIRSA type is used to represent registry authentication using AWS IRSA(IAM Roles for Service accounts) and the secretstore resource is expected to have the keys 'roleARN'.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Couple of nits (can't add suggestions since the PR is merged):

  • Missing space between IRSA and (
  • key instead of keys

Comment on lines +24 to +28
RequiredUsername = "username"
RequiredPassword = "password"
RequiredClientId = "clientId"
RequiredTenantId = "tenantId"
RequiredRoleARN = "roleARN"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prefix Required is confusing, maybe I'm not following the thought process? They are the expected keys in the resource, so in general for such variables the convention is to add a key suffix, <key_name>Key, so it would be UsernameKey for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated in in #7867

@@ -19,4 +19,11 @@ package secretstores
const (
// ResourceTypeName is the resource type name for secret stores.
ResourceTypeName = "Applications.Core/secretStores"

// The following are possible required keys in a SecretStore depending on it's SecretType
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: let's not use different comment formats within the same file (example above for ResourceTypeName).

https://tip.golang.org/doc/comment#var

@@ -75,8 +78,15 @@ func getOrDefaultEncoding(t datamodel.SecretType, e datamodel.SecretValueEncodin
return e, err
}

// Define a map of required keys for each SecretType
var requiredKeys = map[datamodel.SecretType][]string{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be only referenced from ValidateAndMutateRequest function so I'd assume it should be scoped to that. Could you tell me more about the motivation to define it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved into function: #7867

Comment on lines +126 to +131
case datamodel.SecretTypeBasicAuthentication:
return to.Ptr(SecretStoreDataTypeBasicAuthentication)
case datamodel.SecretTypeAzureWorkloadIdentity:
return to.Ptr(SecretStoreDataTypeAzureWorkloadIdentity)
case datamodel.SecretTypeAWSIRSA:
return to.Ptr(SecretStoreDataTypeAwsIRSA)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should a unit test be added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added in #7867

lakshmimsft added a commit that referenced this pull request Aug 30, 2024
# Description
Updates per comments in
#7816

## Type of change
- This pull request adds or changes features of Radius and has an
approved issue (#6917 ).

Fixes: Part of #6917
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants