Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: depot/cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.83.3
Choose a base ref
...
head repository: depot/cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.84.0
Choose a head ref
  • 8 commits
  • 5 files changed
  • 2 contributors

Commits on Mar 6, 2025

  1. feat: add support for custom tags

    we first send the tags that we want to use in order to verify them with
    the API, then we send said tags to the buildkit instance to push when
    it's completed.
    billyb2 committed Mar 6, 2025

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    2689919 View commit details
  2. refactor: rename the --save-tags flag to --save-tag

    since we're not putting in a comma separated list of tags, this seems less
    confusing to me
    billyb2 committed Mar 6, 2025

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    d912f08 View commit details
  3. feat: prepend the target name to each tag in --save-tag

    billyb2 committed Mar 6, 2025

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    5848802 View commit details

Commits on Mar 7, 2025

  1. chore: better wording on --save-tag description

    Co-authored-by: Jacob Gillespie <jacobwgillespie@gmail.com>
    billyb2 and jacobwgillespie authored Mar 7, 2025

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    afb701a View commit details
  2. fix: don't prepend save tags in NewBakeRequest

    We add the targets to the tags the API sends back, so this is unnecessary
    
    Co-authored-by: Jacob Gillespie <jacobwgillespie@gmail.com>
    billyb2 and jacobwgillespie authored Mar 7, 2025

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    2a07fb2 View commit details
  3. ci things

    billyb2 committed Mar 7, 2025

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    b16d244 View commit details
  4. feat: print how to pull the image tags after building or baking with …

    …--save-tag
    billyb2 committed Mar 7, 2025

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    d5e9109 View commit details

Commits on Mar 10, 2025

  1. Merge pull request #323 from depot/billy/feat/custom-tags

    feat: add support for custom save tags
    jacobwgillespie authored Mar 10, 2025

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    b729abf View commit details
Showing with 493 additions and 440 deletions.
  1. +48 −6 pkg/buildx/commands/bake.go
  2. +8 −5 pkg/buildx/commands/build.go
  3. +10 −7 pkg/helpers/build.go
  4. +407 −395 pkg/proto/depot/cli/v1/build.pb.go
  5. +20 −27 proto/depot/cli/v1/build.proto
54 changes: 48 additions & 6 deletions pkg/buildx/commands/bake.go
Original file line number Diff line number Diff line change
@@ -203,7 +203,7 @@ func RunBake(dockerCli command.Cli, in BakeOptions, validator BakeValidator, pri
_ = printer.Wait()

if in.save {
printSaveHelp(in.project, in.buildID, in.progress, requestedTargets)
printSaveHelp(in.project, in.buildID, in.progress, requestedTargets, in.additionalTags)
}
linter.Print(os.Stderr, in.progress)
return nil
@@ -295,10 +295,11 @@ func BakeCmd() *cobra.Command {
options.project,
bakeOpts,
helpers.UsingDepotFeatures{
Push: options.exportPush,
Load: options.exportLoad,
Save: options.save,
Lint: options.lint,
Push: options.exportPush,
Load: options.exportLoad,
Save: options.save,
SaveTags: options.saveTags,
Lint: options.lint,
},
)
build, err := helpers.BeginBuild(context.Background(), req, token)
@@ -557,7 +558,7 @@ func parseBakeTargets(targets []string) (bkt bakeTargets) {
}

// printSaveHelp prints instructions to pull or push the saved targets.
func printSaveHelp(project, buildID, progressMode string, requestedTargets []string) {
func printSaveHelp(project, buildID, progressMode string, requestedTargets, additionalTags []string) {
if progressMode != progress.PrinterModeQuiet {
fmt.Fprintln(os.Stderr)
saved := "target"
@@ -573,6 +574,47 @@ func printSaveHelp(project, buildID, progressMode string, requestedTargets []str
targets := strings.Join(requestedTargets, ",")
fmt.Fprintf(os.Stderr, "Saved %s: %s\n", saved, targets)
fmt.Fprintf(os.Stderr, "\tTo pull: depot pull --project %s %s\n", project, buildID)

if len(additionalTags) > 1 {
fmt.Fprintf(os.Stderr, "\tTo pull save-tags:\n")
fmt.Fprintf(os.Stderr, "\t\tdocker login registry.depot.dev -u x-token -p $(depot pull-token)\n")
fmt.Fprintln(os.Stderr)

// the api will send multiple of the same tag back for each target
if len(requestedTargets) > 0 {
seenTags := map[string]struct{}{}
for _, target := range requestedTargets {
if target == "default" {
continue
}

for _, tag := range additionalTags {
if strings.Contains(tag, buildID) {
continue
}

trueTag := tag + "-" + target
if _, ok := seenTags[trueTag]; ok {
continue
}
seenTags[trueTag] = struct{}{}

fmt.Fprintf(os.Stderr, "\t\tdocker pull %s\n", trueTag)
}
}
} else {
for _, tag := range additionalTags {
if strings.Contains(tag, buildID) {
continue
}

fmt.Fprintf(os.Stderr, "\t\tdocker pull %s\n", tag)
}
}

fmt.Fprintln(os.Stderr)
}

fmt.Fprintf(os.Stderr, "\tTo push: depot push %s--project %s --tag <REPOSITORY:TAG> %s\n", targetUsage, project, buildID)
}
}
13 changes: 8 additions & 5 deletions pkg/buildx/commands/build.go
Original file line number Diff line number Diff line change
@@ -120,6 +120,7 @@ type DepotOptions struct {
build *depotbuild.Build

save bool
saveTags []string
additionalTags []string
additionalCredentials []depotbuild.Credential

@@ -353,7 +354,7 @@ func buildTargets(ctx context.Context, dockerCli command.Cli, nodes []builder.No

printWarnings(os.Stderr, printer.Warnings(), progressMode)
if depotOpts.save {
printSaveHelp(depotOpts.project, depotOpts.buildID, progressMode, nil)
printSaveHelp(depotOpts.project, depotOpts.buildID, progressMode, nil, depotOpts.additionalTags)
}
linter.Print(os.Stderr, progressMode)

@@ -647,10 +648,11 @@ func BuildCmd() *cobra.Command {
options.project,
validatedOpts,
helpers.UsingDepotFeatures{
Push: options.exportPush,
Load: options.exportLoad,
Save: options.save,
Lint: options.lint,
Push: options.exportPush,
Load: options.exportLoad,
Save: options.save,
SaveTags: options.saveTags,
Lint: options.lint,
},
)

@@ -867,6 +869,7 @@ func depotAttestationFlags(_ *cobra.Command, options *DepotOptions, flags *pflag

func depotRegistryFlags(_ *cobra.Command, options *DepotOptions, flags *pflag.FlagSet) {
flags.BoolVar(&options.save, "save", false, `Saves the build to the depot registry`)
flags.StringArrayVar(&options.saveTags, "save-tag", []string{}, `Additional custom tag for the saved image, use with --save`)
}

func checkWarnedFlags(f *pflag.Flag) {
17 changes: 10 additions & 7 deletions pkg/helpers/build.go
Original file line number Diff line number Diff line change
@@ -39,10 +39,11 @@ func BeginBuild(ctx context.Context, req *cliv1.CreateBuildRequest, token string
}

type UsingDepotFeatures struct {
Push bool
Load bool
Save bool
Lint bool
Push bool
Load bool
Save bool
SaveTags []string
Lint bool
}

func NewBuildRequest(project string, opts map[string]buildx.Options, features UsingDepotFeatures) *cliv1.CreateBuildRequest {
@@ -67,6 +68,7 @@ func NewBuildRequest(project string, opts map[string]buildx.Options, features Us
{
Command: cliv1.Command_COMMAND_BUILD,
Tags: opts.Tags,
SaveTags: features.SaveTags,
Outputs: outputs,
Push: features.Push,
Load: features.Load,
@@ -84,8 +86,8 @@ func NewBuildRequest(project string, opts map[string]buildx.Options, features Us
func NewBakeRequest(project string, opts map[string]buildx.Options, features UsingDepotFeatures) *cliv1.CreateBuildRequest {
targets := make([]*cliv1.BuildOptions, 0, len(opts))

for name, opts := range opts {
name := name
for targetName, opts := range opts {
targetName := targetName
outputs := make([]*cliv1.BuildOutput, len(opts.Exports))
for i := range opts.Exports {
outputs[i] = &cliv1.BuildOutput{
@@ -102,7 +104,8 @@ func NewBakeRequest(project string, opts map[string]buildx.Options, features Usi
Load: features.Load,
Save: features.Save,
Lint: features.Lint,
TargetName: &name,
SaveTags: features.SaveTags,
TargetName: &targetName,
})
}

Loading