MCPcopy Create free account
hub / github.com/dagger/dagger / pushTargets

Method pushTargets

toolchains/engine-dev/main.go:541–571  ·  view source on GitHub ↗
(
	ctx context.Context,
	targetResults []targetResult,
	image string,
	registryUsername *string,
	registryPassword *dagger.Secret,
)

Source from the content-addressed store, hash-verified

539}
540
541func (dev *EngineDev) pushTargets(
542 ctx context.Context,
543 targetResults []targetResult,
544 image string,
545 registryUsername *string,
546 registryPassword *dagger.Secret,
547) error {
548 ctr := dag.Container()
549 if registryUsername != nil && registryPassword != nil {
550 registry, _, _ := strings.Cut(image, "/")
551 ctr = ctr.WithRegistryAuth(registry, *registryUsername, registryPassword)
552 }
553 jobs := parallel.New()
554 for i, target := range targets {
555 result := targetResults[i]
556 jobs = jobs.WithJob(fmt.Sprintf("push target %s", target.Name),
557 func(ctx context.Context) error {
558 for _, tag := range result.Tags {
559 if _, err := ctr.Publish(ctx, image+":"+tag, dagger.ContainerPublishOpts{
560 PlatformVariants: result.Platforms,
561 // use gzip to avoid incompatibility w/ older docker versions
562 ForcedCompression: dagger.ImageLayerCompressionGzip,
563 }); err != nil {
564 return err
565 }
566 }
567 return nil
568 })
569 }
570 return jobs.Run(ctx)
571}

Callers 1

PublishMethod · 0.95

Calls 6

NewFunction · 0.92
RunMethod · 0.65
ContainerMethod · 0.45
WithRegistryAuthMethod · 0.45
WithJobMethod · 0.45
PublishMethod · 0.45

Tested by

no test coverage detected