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

CLOUDP-289219: Create CLI commands for manipulating stream processors #3496

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

auddin431
Copy link
Collaborator

@auddin431 auddin431 commented Dec 19, 2024

Proposed changes

This work adds the noun processors to the top level noun streams so that stream processors can be interacted with through the CLI. The processors noun has the following verbs:

  • create
  • delete
  • list
  • describe
  • start
  • stop

Jira ticket: CLOUDP-289219

Checklist

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works
  • I have added any necessary documentation in document requirements section listed in CONTRIBUTING.md (if appropriate)
  • I have addressed the @mongodb/docs-cloud-team comments (if appropriate)
  • I have updated test/README.md (if an e2e test has been added)
  • I have run make fmt and formatted my code

Copy link
Collaborator

@tcannon91 tcannon91 left a comment

Choose a reason for hiding this comment

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

Next time, it might be a little easier to review if we break down the commits into each command or each command into their own PR :)

Dropping comments because I think I have gone through all of the create command. I haven't looked but I will try not to leave the same comments on the other commands if they have the same issues. I will continue looking at the other commands and try to only leave net new stuff

internal/store/streams.go Outdated Show resolved Hide resolved
internal/store/streams.go Show resolved Hide resolved
internal/cli/streams/processor/create.go Outdated Show resolved Hide resolved
internal/cli/streams/processor/create.go Outdated Show resolved Hide resolved
docs/command/atlas-streams-processors-create.txt Outdated Show resolved Hide resolved
internal/cli/streams/processor/create_test.go Outdated Show resolved Hide resolved
internal/cli/streams/processor/create_test.go Show resolved Hide resolved
internal/cli/streams/processor/create_test.go Outdated Show resolved Hide resolved
internal/cli/streams/processor/create_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@tcannon91 tcannon91 left a comment

Choose a reason for hiding this comment

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

E2E tests reviewed

test/e2e/atlas/data/create_streams_connection_atlas.json Outdated Show resolved Hide resolved
test/e2e/atlas/streams_with_clusters_test.go Show resolved Hide resolved
Copy link
Collaborator

@tcannon91 tcannon91 left a comment

Choose a reason for hiding this comment

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

Delete and Describe reviewed

internal/cli/streams/processor/delete.go Outdated Show resolved Hide resolved
internal/cli/streams/processor/delete.go Outdated Show resolved Hide resolved
internal/cli/streams/processor/delete_test.go Show resolved Hide resolved
internal/cli/streams/processor/describe.go Outdated Show resolved Hide resolved
internal/cli/streams/processor/describe.go Show resolved Hide resolved
internal/cli/streams/processor/describe.go Outdated Show resolved Hide resolved
internal/cli/streams/processor/describe.go Show resolved Hide resolved
internal/cli/streams/processor/describe_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@tcannon91 tcannon91 left a comment

Choose a reason for hiding this comment

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

Start and Stop reviewed

internal/cli/streams/processor/start.go Outdated Show resolved Hide resolved
internal/cli/streams/processor/start_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

This PR has gone 30 days without any activity and meets the project’s definition of "stale". This will be auto-closed if there is no new activity over the next 30 days. If the issue is still relevant and active, you can simply comment with a "bump" to keep it open, or add the label "not_stale". Thanks for keeping our repository healthy!

@github-actions github-actions bot added the stale A stale issue or PR label Jan 20, 2025
@gssbzn
Copy link
Collaborator

gssbzn commented Jan 21, 2025

@auddin431 this is currently mark as stale by our bots, are you still working on this?

@github-actions github-actions bot removed the stale A stale issue or PR label Jan 22, 2025
@auddin431
Copy link
Collaborator Author

@auddin431 this is currently mark as stale by our bots, are you still working on this?

@gssbzn yep im still working on this, was out for a while during holidays and got occupied with other tickets. Will push out requested changes in the next day or two

@auddin431
Copy link
Collaborator Author

evergreen keep-definitions

return nil, err
}

if processor.Name == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if processor.Name == nil {
if len(processor.Name) == 0 {

you may want to validate empty strings

}

// atlas streams processor create [--projectId projectId].
func CreateBuilder() *cobra.Command {
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this command need a --watch as in are the changes applied on create or does it take a while to be effective? see

for the use of watch on other commands

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm, I know cluster creation can be a very lengthy process so I see why it's necessary for the --watch, but this command takes about 5-10 seconds. Is there a general cutoff as to when --watch is necessary?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess the main rule would be created vs ready for use, customers that script with CLI or other tools want to know when is ready for use and for that reason we provide --watch

}

func (opts *DeleteOpts) Run() error {
return opts.Delete(opts.store.DeleteStreamProcessor, opts.ProjectID, opts.Instance)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return opts.Delete(opts.store.DeleteStreamProcessor, opts.ProjectID, opts.Instance)
return opts.Delete(opts.store.DeleteStreamProcessor, opts.ConfigProjectID(), opts.Instance)

here and everywhere else you do opts.ProjectID, project id is layered, it can come from config, env or flag, using th emethod ConfigProjectID() will make sure to use the correct one other wise you are looking only to the flag values

@auddin431 auddin431 requested a review from tcannon91 January 28, 2025 17:49
Copy link
Collaborator

@tcannon91 tcannon91 left a comment

Choose a reason for hiding this comment

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

Looks pretty good

Copy link
Collaborator

@tcannon91 tcannon91 left a comment

Choose a reason for hiding this comment

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

Looks good

Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

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

I'm finding a bit confusing that some commands don't follow the general output logic of the CLI

Comment on lines +162 to +164
if err := createOpts.Run(); err != nil {
t.Fatalf("Run() unexpected error: %v", err)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

since using testify to keep it consistent

Suggested change
if err := createOpts.Run(); err != nil {
t.Fatalf("Run() unexpected error: %v", err)
}
require.NoError(createOpts.Run())

Comment on lines +48 to +51
opts.Output = jsonOutput
if opts.includeStats {
return opts.Print(r)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

why overloading output options with your own option?

Comment on lines +47 to +50
opts.Output = jsonOutput
if opts.includeStats {
return opts.Print(*r.Results)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

same question? why is this a custom way to output instead of the standard --out|-o?

return opts.Print(*r.Results)
}

for _, res := range *r.Results {
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't use pointers, use getters https://github.com/mongodb/atlas-sdk-go/blob/main/docs/doc_5_best_practices.md#using-getters-instead-of-direct-field-access

Suggested change
for _, res := range *r.Results {
for _, res := range r.GetResults() {

return opts.Print(*r.Results)
}

for _, res := range *r.Results {
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are you iterating for the print? why don't you define a template that can handle the envelop object?

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.

3 participants