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 recipe engine #8180

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

rynowak
Copy link
Contributor

@rynowak rynowak commented Jan 2, 2025

Description

This change adds the recipe engine to the dynamic-rp. There's no usage of the recipe engine yet in this PR, it's a prerequisite for what's coming next.

The main problem being solved is improving the initialization code so that it can be used in our integration tests.

Type of change

  • This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Radius (issue link optional).

Part of: #6688

Contributor checklist

Please verify that the PR meets the following requirements, where applicable:

  • An overview of proposed schema changes is included in a linked GitHub issue.
  • A design document PR is created in the design-notes repository, if new APIs are being introduced.
  • If applicable, design document has been reviewed and approved by Radius maintainers/approvers.
  • A PR for the samples repository is created, if existing samples are affected by the changes in this PR.
  • A PR for the documentation repository is created, if the changes in this PR affect the documentation or any user facing updates are made.
  • A PR for the recipes repository is created, if existing recipes are affected by the changes in this PR.

@rynowak rynowak requested review from a team as code owners January 2, 2025 20:43
limitations under the License.
*/

package kubernetesclientprovider
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar to previous changes, moving the functionality to access a Kubernetes client into a "provider". By deferring and standardizing the initialization that makes it easier to override in tests.

@@ -35,6 +35,8 @@ data:
port: 6062
secretProvider:
provider: kubernetes
kubernetes:
kind: default
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only needed for dynamic-rp. UCP doesn't talk directly to Kubernetes, and applications-rp doesn't have the same expectations for testing.

Signed-off-by: Ryan Nowak <[email protected]>
@rynowak rynowak force-pushed the kubernetes-clients branch from a425853 to c8296ae Compare January 2, 2025 20:48
@@ -92,6 +97,9 @@ func Start(t *testing.T, opts ...TestHostOption) (*TestHost, *ucptesthost.TestHo
options, err := dynamicrp.NewOptions(context.Background(), config)
require.NoError(t, err)

// Prevent the default recipe drivers from being registered.
options.Recipes.Drivers = map[string]func(options *dynamicrp.Options) (driver.Driver, error){}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now we can load/use/mock the recipe engine in tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be used in the next PR, where we're actually going to test a resource that uses recipes.

}

// WithLegacy implements discovery.DiscoveryInterface.
func (d *DiscoveryClient) WithLegacy() discovery.DiscoveryInterface {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These functions were missing from our mock. The discovery package defines a ton of different interfaces. I changed from a really scenario-specific one to a more general one.

Copy link

codecov bot commented Jan 2, 2025

Codecov Report

Attention: Patch coverage is 24.75728% with 155 lines in your changes missing coverage. Please review.

Project coverage is 59.89%. Comparing base (710509a) to head (c8296ae).

Files with missing lines Patch % Lines
pkg/dynamicrp/options.go 22.36% 55 Missing and 4 partials ⚠️
...kubernetesclient/kubernetesclientprovider/types.go 24.67% 57 Missing and 1 partial ⚠️
pkg/recipes/terraform/execute.go 10.00% 18 Missing ⚠️
pkg/dynamicrp/backend/service.go 0.00% 7 Missing ⚠️
pkg/portableresources/processors/resourceclient.go 50.00% 5 Missing and 2 partials ⚠️
pkg/recipes/controllerconfig/config.go 0.00% 4 Missing ⚠️
pkg/recipes/driver/terraform.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8180      +/-   ##
==========================================
- Coverage   60.09%   59.89%   -0.20%     
==========================================
  Files         584      585       +1     
  Lines       38675    38850     +175     
==========================================
+ Hits        23240    23269      +29     
- Misses      13729    13863     +134     
- Partials     1706     1718      +12     

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


// FromConfig creates a new Kubernetes client provider from the given config.
func FromConfig(config *rest.Config) *KubernetesClientProvider {
return &KubernetesClientProvider{
Copy link
Contributor

@lakshmimsft lakshmimsft Jan 4, 2025

Choose a reason for hiding this comment

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

Do we want to return error here if config is nil? It will also distinguish it from FromEmpty()

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.

2 participants