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

cli: add --workspace flag to set base directory for Constellation workspace #2148

Merged
merged 5 commits into from
Aug 4, 2023

Conversation

daniel-weisse
Copy link
Member

@daniel-weisse daniel-weisse commented Aug 1, 2023

Context

The goal of this PR is to let users specify the Constellation workspace using flags.

For the longest time, our CLI allowed setting a path for the config and master secret files. Other files and folders however, were always assumed to be in the current working directory.
This PR aims to address this issue by adding the --workspace flag, which allows a user to set the workspace for a CLI command.
All actions on files will then be run from the given workspace instead from the directory the command is executed from.

Proposed change(s)

  • Remove --config flag
  • Remove --master-secret flag
  • Add --workspace flag
    • Replaces --config and --master-secret flags by allowing a user to specify the base directory context from where CLI commands are executed
    • All files are created and accessed relative to the path given by the flag
    • If omitted, uses the current working directory

Additional info

Not sure if we can properly test the flag using the e2e tests, so I request the reviewers to try out their workflows with the new flag and report any issues that may occur.

I already did some manual testing on GCP. Currently missing testing for IAM migration, general updates and manual tests on Azure/AWS.

e2e test Azure
e2e test AWS

Checklist

  • Update docs
  • Add labels (e.g., for changelog category)
  • Is PR title adequate for changelog?
  • Link to Milestone

@netlify
Copy link

netlify bot commented Aug 1, 2023

Deploy Preview for constellation-docs canceled.

Name Link
🔨 Latest commit 4fb92ed
🔍 Latest deploy log https://app.netlify.com/sites/constellation-docs/deploys/64cce188226ed800087ae88d

@daniel-weisse daniel-weisse force-pushed the feat/cli/workspace-flag branch 2 times, most recently from 0791d86 to fef45e0 Compare August 1, 2023 13:24
@daniel-weisse daniel-weisse marked this pull request as ready for review August 1, 2023 14:28
@daniel-weisse daniel-weisse force-pushed the feat/cli/workspace-flag branch 3 times, most recently from 545f5dc to f51cb28 Compare August 2, 2023 14:30
@elchead
Copy link
Contributor

elchead commented Aug 3, 2023

nit: change the title to "cli: add --workspace flag in favor of --config and --master-secret". seems to make it easier for the user what the change means in the changelog. you agree?

In the description I'd add:
The new flag makes the CLI consistent with the workspace concept (https://docs.edgeless.systems/constellation/architecture/orchestration#workspaces)

@elchead elchead self-requested a review August 3, 2023 07:37
@daniel-weisse daniel-weisse changed the title cli: allow setting workspace when running cli commands cli: add --workspace flag to set base directory for Constellation workspace Aug 3, 2023
cli/internal/cmd/cmd.go Outdated Show resolved Hide resolved
cli/cmd/root.go Outdated Show resolved Hide resolved
@malt3
Copy link
Contributor

malt3 commented Aug 3, 2023

If I understand this PR correctly, you update every use of file paths and prepend the workspace path to it.
While this works and is stable, I wonder why we do not follow the convention of other tools and perform os.Chdir(workspace) and keep all paths relative to the CWD?
I'm just trying to understand the tradeoffs and why this implementation was chosen.

EDIT: Example implementation

@elchead
Copy link
Contributor

elchead commented Aug 3, 2023

Had a rough look over the changes and lgtm. Maybe we can test the flag explicitly in our e2e_test (simply cd .. and then use the workspace flag?)

@elchead
Copy link
Contributor

elchead commented Aug 3, 2023

If I understand this PR correctly, you update every use of file paths and prepend the workspace path to it. While this works and is stable, I wonder why we do not follow the convention of other tools and perform os.Chdir(workspace) and keep all paths relative to the CWD? I'm just trying to understand the tradeoffs and why this implementation was chosen.

I think this would simplify the changes a lot and remove unneeded parameters. I think it's better to choose this if there is no other reason for the current way. Even thought it would be some additional work :/

@daniel-weisse
Copy link
Member Author

While this works and is stable, I wonder why we do not follow the convention of other tools and perform os.Chdir(workspace) and keep all paths relative to the CWD?

Tried this, and found a good solution that works.
Downside being that this won't correctly print filepaths relative to the execution directory. But it shouldn't be too much effort to fix that.

Copy link
Contributor

@malt3 malt3 left a comment

Choose a reason for hiding this comment

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

Thanks! Works great and LGTM.
Feel free to add or dismiss the short flag -C.

@3u13r 3u13r removed their request for review August 4, 2023 08:31
@3u13r
Copy link
Member

3u13r commented Aug 4, 2023

The one file under my ownership looks fine. Unassigned review.

@daniel-weisse daniel-weisse temporarily deployed to e2e August 4, 2023 09:01 — with GitHub Actions Inactive
Copy link
Member

@derpsteb derpsteb left a comment

Choose a reason for hiding this comment

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

Did some basic manual testing and looked at codeowned files.
👍

@daniel-weisse daniel-weisse force-pushed the feat/cli/workspace-flag branch 2 times, most recently from 66f95e6 to a7f81a6 Compare August 4, 2023 10:05
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
@daniel-weisse daniel-weisse added this to the v2.10.0 milestone Aug 4, 2023
@daniel-weisse daniel-weisse added the feature This introduces new functionality label Aug 4, 2023
@daniel-weisse daniel-weisse merged commit d1ace13 into main Aug 4, 2023
7 checks passed
@daniel-weisse daniel-weisse deleted the feat/cli/workspace-flag branch August 4, 2023 11:53
@elchead elchead added the breaking change Change breaks existing API or configuration. label Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Change breaks existing API or configuration. feature This introduces new functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants