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

builder: move builder creation logic to builder package #2150

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

crazy-max
Copy link
Member

This moves the builder creation logic to the builder package as we plan to allow builder creation in the build UI of Docker Desktop so we avoid drifting with the same logic in command package.

if opts.Name == "default" {
return nil, errors.Errorf("default is a reserved name and cannot be used to identify builder instance")
} else if opts.Append && opts.Name == "" {
return nil, errors.Errorf("append requires a builder name")
Copy link
Member Author

@crazy-max crazy-max Dec 4, 2023

Choose a reason for hiding this comment

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

Now returns an error instead of a warning log:

logrus.Warnf("append used without name, creating a new instance instead")

I think being more strict about it is fine but let me know if we should typed this kind error and handle it it differently in command package when invoked through the CLI to still log a warning or just pass a logger to Create.

}
for _, c := range contexts {
if c.Name == name {
return nil, errors.Errorf("instance name %q already exists as context builder", name)
Copy link
Member Author

@crazy-max crazy-max Dec 4, 2023

Choose a reason for hiding this comment

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

Same as #2150 (comment)

switch {
case driverName == "kubernetes":
if opts.Endpoint != "" {
return nil, errors.Errorf("kubernetes driver does not support endpoint args %q", opts.Endpoint)
Copy link
Member Author

Choose a reason for hiding this comment

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

Same as #2150 (comment)

err2 = txn.Save(ngOriginal)
}
if err2 != nil {
return nil, errors.Errorf("could not rollback to previous state: %s", err2)
Copy link
Member Author

Choose a reason for hiding this comment

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

Same as #2150 (comment)

This moves the builder creation logic to the builder package as we
plan to allow builder creation in the build ui of Docker Desktop so we
avoid drifting with the same logic in command package.

Signed-off-by: CrazyMax <[email protected]>
@crazy-max crazy-max marked this pull request as ready for review December 5, 2023 13:30
var ep string
var setEp bool
switch {
case driverName == "kubernetes":
Copy link
Member

Choose a reason for hiding this comment

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

Ideally, these driver specifics can be removed from this package eventually, but not new code as this is how it was in commands as well.

@crazy-max crazy-max merged commit 0a0252d into docker:master Dec 11, 2023
61 checks passed
@crazy-max crazy-max deleted the builder-create branch December 11, 2023 09:34
@crazy-max crazy-max added this to the v0.13.0 milestone Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants