-
Notifications
You must be signed in to change notification settings - Fork 12
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
Conversation
There was a problem hiding this 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.
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.
src/pkg/cli/update.go
Outdated
} | ||
|
||
func homebrewPrefix(ctx context.Context) string { | ||
output, err := exec.CommandContext(ctx, "brew", "config").Output() |
There was a problem hiding this comment.
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?
|
||
// 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"`) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
printInstructions(`pwsh -c "iwr https://s.defang.io/defang_win_amd64.zip -OutFile defang.zip"`) | |
printInstructions(`winget install defang`) |
There was a problem hiding this comment.
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.
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 adefang upgrade
command. This is somewhat challenging because thedefang
CLI may be installed through many different mechanisms. We host our own direct installation scripts athttps://s.defang.io/install
andhttps://s.defang.io/defang_win_amd64.zip
, but we also publish the CLI to homebrew, and nix. Thedefang 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.