Skip to content

defang upgrade command #439

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

Merged
merged 9 commits into from
Aug 19, 2024
Merged

defang upgrade command #439

merged 9 commits into from
Aug 19, 2024

Conversation

lionello
Copy link
Member

@lionello lionello commented Jun 5, 2024

A bit hacky, but I think this would work well!! Fixes #41 and #238

This PR makes it easier to update the defang CLI by introducing a defang upgrade command. This is somewhat challenging because the defang CLI may be installed through many different mechanisms. We host our own direct installation scripts at https://s.defang.io/install and https://s.defang.io/defang_win_amd64.zip, but we also publish the CLI to homebrew, and nix. The defang upgrade command will try to determine which mechanism was used, and then prints appropriate instructions on how to upgrade. We originally considered running the update ourselves, but decided that we didn't feel comfortable shelling out to tools which are sort of out of our domain.

@lionello lionello added the wip Work in progress; don't merge label Jun 5, 2024
@lionello lionello marked this pull request as draft June 5, 2024 23:49
Copy link
Member

@jordanstephens jordanstephens left a comment

Choose a reason for hiding this comment

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

A few comments inline, but overall I think it's a practical solution. I would also add a log message on startup to run defang update if we detect the current version is outdated.

@jordanstephens jordanstephens self-requested a review August 13, 2024 23:49
we decided we didn't feel comfortable with proactively trying to run
other processes to update.

we may revisit this in the future, but for now this is a practical
compromise.
@jordanstephens jordanstephens marked this pull request as ready for review August 16, 2024 16:57
}

func homebrewPrefix(ctx context.Context) string {
output, err := exec.CommandContext(ctx, "brew", "config").Output()
Copy link
Member

Choose a reason for hiding this comment

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

@edwardrf how do we feel about this?

@jordanstephens jordanstephens self-requested a review August 16, 2024 17:09
@jordanstephens jordanstephens changed the title defang update command defang upgrade command Aug 16, 2024

// Check if we're running in PowerShell
if _, exists := os.LookupEnv("PSModulePath"); exists {
printInstructions(`pwsh -c "iwr https://s.defang.io/defang_win_amd64.zip -OutFile defang.zip"`)
Copy link
Member Author

Choose a reason for hiding this comment

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

We have since added winget support!

winget install defang
defang generate

Copy link
Member

Choose a reason for hiding this comment

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

@lionello does this change look right, then?

Suggested change
printInstructions(`pwsh -c "iwr https://s.defang.io/defang_win_amd64.zip -OutFile defang.zip"`)
printInstructions(`winget install defang`)

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 think that's good enough, but we might have to add logic to check whether it was installed with winget.

@lionello lionello merged commit 6a0d57d into main Aug 19, 2024
7 checks passed
@lionello lionello deleted the lio-update branch August 19, 2024 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wip Work in progress; don't merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI Update Command
3 participants