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

feat(apps): Let users deploy to their own docker hub (and other fixes) #277

Merged
merged 9 commits into from
Mar 17, 2022

Conversation

raulb
Copy link
Member

@raulb raulb commented Mar 16, 2022

Type of change

  • New feature
  • Bug fix
  • Refactor
  • Documentation

How was this tested?

  • Unit Tests
  • Tested in staging

Demo

See slack.

@raulb raulb self-assigned this Mar 16, 2022
Copy link
Contributor

@jayjayjpg jayjayjpg left a comment

Choose a reason for hiding this comment

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

This reads great! I left a few more clarifying questions to understand the feature better, but this is already looking good to go ✨

@@ -44,15 +49,17 @@ type createApplicationClient interface {

type Deploy struct {
flags struct {
Path string `long:"path" description:"path to the app directory"`
Path string `long:"path" description:"path to the app directory (default is local directory)"`
DockerHubUserName string `long:"docker-hub-username" description:"DockerHub username to use to build and deploy the application image"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This is neat! Do we want to expose to the user the concept of a function image in the descriptions for these flags, too?

Technically, we're only building a function image, instead of an application image, on Docker. What are your thoughts on the wording though and how much the user should be aware about the distinction between deploying an app and building a function image?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jayjayjpg I updated the wording last night (mostly due to linting), but now the message is a bit broader. Please take a look and tell me what you think.

}

func (d *Deploy) validateLocalDeploymentConfig() error {
// Check if users had an old configuration where DockerHub credentials were set as environment variables
Copy link
Contributor

Choose a reason for hiding this comment

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

The two step validation step for both environment variables and flags is really neat ✨

// Check if users had an old configuration where DockerHub credentials were set as environment variables
err := d.validateDockerHubEnvVars()
if err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we also log out the error here using logger.Error onto the console or is this already taken care of by returning the err variable?

Copy link
Member Author

@raulb raulb Mar 17, 2022

Choose a reason for hiding this comment

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

@jayjayjpg It's been taken care of. That function would return the error to then to the Execute function which Cobra (our CLI. builder, really) will print out as an error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it and thank you for the outline, that's super helpful!

default:
return fmt.Errorf("language %q not supported. %s", d.lang, LanguageNotSupportedError)
}

if err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

If the deploy should fail with an error, would we need to log the error explicitly here via logger.Error or is this already taken care of by returning the err object?

Copy link
Member Author

Choose a reason for hiding this comment

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

if the error is correctly returned by either deploy step, the CLI will ultimately print out the error returned on the execution.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, I wasn't fully aware yet, that an error essentially needs to be passed through to different commands and that sounds good!

}
})
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice test coverage!

@raulb raulb requested a review from jayjayjpg March 17, 2022 11:05
Copy link
Contributor

@jayjayjpg jayjayjpg left a comment

Choose a reason for hiding this comment

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

This reads great! Thank you for the super swift update and all of the details in the PR description, too! ✨

Path string `long:"path" description:"path to the app directory"`
Path string `long:"path" description:"path to the app directory (default is local directory)"`
DockerHubUserName string `long:"docker-hub-username" description:"DockerHub username to use to build and deploy the app"`
DockerHubAccessToken string `long:"docker-hub-access-token" description:"DockerHub access token to use to build and deploy the app"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this reads great and thank you for the swift update! ✨

// Check if users had an old configuration where DockerHub credentials were set as environment variables
err := d.validateDockerHubEnvVars()
if err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

Got it and thank you for the outline, that's super helpful!

default:
return fmt.Errorf("language %q not supported. %s", d.lang, LanguageNotSupportedError)
}

if err != nil {
return err
Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, I wasn't fully aware yet, that an error essentially needs to be passed through to different commands and that sounds good!

@raulb raulb merged commit 06d29a9 into master Mar 17, 2022
@raulb raulb deleted the raul/add-build branch March 17, 2022 11:16
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.

2 participants