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

rpk cloud namespace: create, list, delete #16685

Merged
merged 3 commits into from
Feb 26, 2024

Conversation

r-vasquez
Copy link
Contributor

This PR introduces the new rpk cloud namespace command.

It also introduces the first use of the publicapi proto files in rpk and the grpc client.

Authentication:

Every command under rpk cloud namespace triggers an authentication flow (either SSO or client credentials) if the user executing the command is not authenticated.

The flags -X cloud.client_id and -X cloud.client_secret are available if you want a client credential flow and avoid browser authentication.

Examples:

rpk cloud namespace list

$ rpk cloud namespace list 
NAME      ID
test-1    <namespace-id>
foo       <namespace-id>
bar       <namespace-id>
$ rpk cloud namespace create rogger-test
NAME         ID                                    ERROR
rogger-test  <namespace-id>
rpk cloud namespace delete rogger-test
? Confirm deletion of namespace "rogger-test" with ID "<namespace-id> "? Yes
NAME         ID
rogger-test  <namespace-id> 

# --no-confirm available

Every command has the --format json/yaml available.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.3.x
  • v23.2.x
  • v23.1.x

Release Notes

Features

  • You can create namespaces in Redpanda cloud using rpk cloud namespace.

This includes a script to generate them
in the future.
This includes a new Dev Override:
RPK_PUBLIC_API_URL to override the
public api URL used by rpk.
This first commit introduces:
- Create
- List
- Delete
@r-vasquez r-vasquez requested a review from a team as a code owner February 23, 2024 01:15
@r-vasquez r-vasquez requested review from ivotron and removed request for a team February 23, 2024 01:15
@vbotbuildovich
Copy link
Collaborator

vbotbuildovich commented Feb 23, 2024

res = append(res, listResponse{n.Name, n.Id})
}
}
sort.Slice(res, func(i, j int) bool { return strings.ToLower(res[i].Name) < strings.ToLower(res[j].Name) })
Copy link
Contributor

Choose a reason for hiding this comment

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

why ToLower 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.

Without it, Go will sort the uppercase letter first.

data := []string{"A", "b", "D", "c"}
sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })

Will return:

[A,D,b,c]

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes but isn't that valid? I guess it's a matter of preference.
Also, are namespaces mixed case? I thought they were uuids formatted entirely lowercase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is valid. But here I'm sorting the names; they can use upper case and special characters. During the development, I had a case where it was sorted like:

NAME                         ID
Nicola's Playground          [redacted]
alena's                      [redacted]
andrew-integration           [redacted]
...

So I just did a case insensitive sort here because it looked weird to me.

@r-vasquez r-vasquez merged commit bba0658 into redpanda-data:dev Feb 26, 2024
32 checks passed
@r-vasquez
Copy link
Contributor Author

/backport v23.3.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants