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

Standardize convention for requesting namespaced resources #3288

Merged
merged 6 commits into from
Sep 15, 2023

Conversation

sarataha
Copy link
Member

@sarataha sarataha commented Sep 5, 2023

Part of: #3220

What changed?
This PR standardizes the naming convention for requesting namespaced resources, in alignment with K8S practices. It specifically defines the structure for endpoints used to retrieve individual namespaced resources.
Example: GET "/v1/clusters/{cluster_name}/namespaces/{namespace}/external-secrets/{external_secret_name}".

Why was this change made?
This is part of the API clean up before publishing it for customer usage. It provides consistency in how namespaced resources are requested.

How was this change implemented?

How did you validate the change?

  • Explain how a reviewer can verify the change themselves

  • Integration tests -- what is covered, what cannot be covered;
    or, explain why there are no new tests

  • Unit tests -- what is covered, what cannot be covered; are
    there tests that fail without the change?

Release notes

Documentation Changes

Other follow ups

@sarataha sarataha added enhancement New feature or request team/pesto labels Sep 5, 2023
@sarataha sarataha force-pushed the namespaced-resource-convention branch 3 times, most recently from 32394ff to bdb9359 Compare September 6, 2023 02:14
@sarataha sarataha marked this pull request as ready for review September 6, 2023 02:26
@sarataha sarataha requested a review from foot September 6, 2023 02:26
@@ -293,7 +297,7 @@ service ClustersService {
rpc ListSopsKustomizations(ListSopsKustomizationsRequest)
returns (ListSopsKustomizationsResponse) {
option (google.api.http) = {
get : "/v1/sops-kustomizations"
get : "/v1/clusters/{cluster_name}/sops-kustomizations"
Copy link
Collaborator

Choose a reason for hiding this comment

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

sops-kustomizations are not namespaced?

Copy link
Member Author

Choose a reason for hiding this comment

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

In ListSopsKustomizationsRequest, only cluster_name is used 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

So, this is an inconsistency we should fix.

This endpoint should return all the sops-kustomizations even when a cluster is omitted. So lets put this back to /v1/sops-kustomizations, and we can open an issue to stop it requiring a cluster filter.

@@ -276,7 +280,7 @@ service ClustersService {
rpc GetPolicyConfig(GetPolicyConfigRequest)
returns (GetPolicyConfigResponse) {
option (google.api.http) = {
get : "/v1/policy-configs/{name}"
get : "/v1/clusters/{cluster_name}/policy-configs/{name}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some of policy stuff is not namespaced, policy-configs not?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess it's not namespaced based the test deployments 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

And we should change this to `/v1/namespaces/{clusterNamespace}/clusters/{cluster_name}/policy-configs/{name}

};
}

// List external secrets stores
rpc ListExternalSecretStores(ListExternalSecretStoresRequest)
returns (ListExternalSecretStoresResponse) {
option (google.api.http) = {
get : "/v1/external-secrets-stores"
get : "/v1clusters/{cluster_name}/external-secrets-stores"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would guess these are namespaced too?

Sorry, these are just questsion! Maybe we add a collection of links to the PR description for non-namespaced resources

Copy link
Collaborator

Choose a reason for hiding this comment

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

This should stay as /v1/external-secrets-stores and we should lift the clusterName constraint in the future.

@@ -243,15 +246,16 @@ service ClustersService {
rpc GetExternalSecret(GetExternalSecretRequest)
returns (GetExternalSecretResponse) {
option (google.api.http) = {
get : "/v1/external-secrets/{external_secret_name}"
get : "/v1/clusters/{cluster_name}/namespaces/{namespace}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

"/v1/namespaces/{clusterNamespace}/clusters/{cluster_name}/namespaces/{namespace}"

@sarataha sarataha force-pushed the namespaced-resource-convention branch from bdb9359 to 99c804d Compare September 11, 2023 16:13
Copy link
Collaborator

@foot foot left a comment

Choose a reason for hiding this comment

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

Nice one! ⭐

@foot foot merged commit a9faf36 into main Sep 15, 2023
@foot foot deleted the namespaced-resource-convention branch September 15, 2023 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request team/pesto
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants