Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

cli: Project ops part 1 - CLI updates #2413

Merged
merged 24 commits into from Oct 12, 2021
Merged

cli: Project ops part 1 - CLI updates #2413

merged 24 commits into from Oct 12, 2021

Conversation

krantzinator
Copy link
Contributor

@krantzinator krantzinator commented Oct 4, 2021

(Most of the Files changed are updates to all the CLI docs page because of the new -project flag 馃槄 )

This is a cli-only PR adding a ProjectTargetRequired config item and corresponding WithMultipleApp option to set some commands to target all applications with the targeted project by default. Users can still specify -app=APPNAME to target a specific app.

This change also removes the -project flag from the context [...] commands and makes it a global flag. Various other documentation updates are included here as well to amend some of our language from being app-specific to project-specific.

This is a surface layer change, as it only supports functionality that we already had on the CLI side, and does not add any project-scoped awareness to our server or job system. It seemed like a good first pass to start with to get the CLI-messaging right.

With this functionality, all commands updated with the new config option will now run that command against each application in the project in sequence. A failure in one app is non-blocking; all applications will finish their jobs individually.

Notable: I moved the DoApp in internal/cli/deployment_destroy.go from the private func it was in (getDeployments) up to the parent Run function; this matches all the other CLI commands and sets us up better to move some of this project-scope to operations later.

Example output:
image

@krantzinator krantzinator added the pr/no-changelog No automatic changelog entry required for this pull request label Oct 4, 2021
@krantzinator krantzinator added this to the 0.6.0 milestone Oct 4, 2021
@krantzinator krantzinator requested a review from a team October 4, 2021 20:18
@krantzinator krantzinator removed the pr/no-changelog No automatic changelog entry required for this pull request label Oct 4, 2021
@krantzinator krantzinator self-assigned this Oct 4, 2021
@krantzinator
Copy link
Contributor Author

Pause: there is some weirdness with release that I'm seeing after further testing. Will mark as Draft.

@krantzinator krantzinator changed the title cli: Project ops part 1 - CLI updates Draft: cli: Project ops part 1 - CLI updates Oct 4, 2021
@krantzinator krantzinator removed the request for review from a team October 4, 2021 21:21
@krantzinator krantzinator marked this pull request as draft October 4, 2021 21:21
@krantzinator krantzinator changed the title Draft: cli: Project ops part 1 - CLI updates cli: Project ops part 1 - CLI updates Oct 4, 2021
@krantzinator krantzinator requested a review from a team October 7, 2021 20:51
@krantzinator krantzinator marked this pull request as ready for review October 7, 2021 20:52
Copy link
Contributor

@evanphx evanphx left a comment

Choose a reason for hiding this comment

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

Couple places where we should not corrupt the json output and a TODO.

internal/cli/artifact_list.go Outdated Show resolved Hide resolved
@@ -71,6 +71,7 @@ func (c *DeploymentListCommand) Run(args []string) int {
client := c.project.Client()

err := c.DoApp(c.Ctx, func(ctx context.Context, app *clientpkg.App) error {
app.UI.Output("%s", app.Ref().Application, terminal.WithHeaderStyle())
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 other about the output not being valid json in this case.

Copy link
Member

Choose a reason for hiding this comment

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

I'm also thinking for the json case, for all projects, instead of returning two separate json structures separated by newlines, we should probably collect and wrap them into a single array for each item listed? Maybe that's a future enhancement 馃

Copy link
Member

Choose a reason for hiding this comment

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

And if we did that, does it mean single apps are still an item in an array too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, we could do that by storing the json on the command, returning nothing in the DoApp if flag.json, and then returning the collected json outside of that loop?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, we could make a more generic mechanism for displaying json where you give the CLI a struct that it will json-ify (and thusly supports multiple structs)

internal/cli/option.go Outdated Show resolved Hide resolved
internal/cli/release_list.go Outdated Show resolved Hide resolved
Copy link
Member

@briancain briancain left a comment

Choose a reason for hiding this comment

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

馃帀 noice! Looking good. My main issue was getting project/app targeting for remote projects working again, I think it's just an issue with the new WithMultipleApp CLI option and it'll work for all commands that use that option.

internal/cli/artifact_list.go Outdated Show resolved Hide resolved
internal/cli/deployment_list.go Outdated Show resolved Hide resolved
website/content/docs/projects/index.mdx Outdated Show resolved Hide resolved
.changelog/2413.txt Outdated Show resolved Hide resolved
@@ -71,6 +71,7 @@ func (c *DeploymentListCommand) Run(args []string) int {
client := c.project.Client()

err := c.DoApp(c.Ctx, func(ctx context.Context, app *clientpkg.App) error {
app.UI.Output("%s", app.Ref().Application, terminal.WithHeaderStyle())
Copy link
Member

Choose a reason for hiding this comment

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

I'm also thinking for the json case, for all projects, instead of returning two separate json structures separated by newlines, we should probably collect and wrap them into a single array for each item listed? Maybe that's a future enhancement 馃

Copy link
Member

@briancain briancain left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for the updates, this looks legit to me. I found 1 issue I mentioned around raising an error for hostname register <hostname> if all apps in a project were targeted. Otherwise this looks great! 馃帀

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

Successfully merging this pull request may close these issues.

None yet

3 participants