mirror of https://github.com/docker/compose.git
allow usage of -f flag with oci Compose artifact
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
This commit is contained in:
parent
7c46beb8af
commit
26064d4b60
|
@ -36,7 +36,7 @@ func publishCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Servic
|
|||
ProjectOptions: p,
|
||||
}
|
||||
cmd := &cobra.Command{
|
||||
Use: "publish [OPTIONS] [REPOSITORY]",
|
||||
Use: "publish [OPTIONS] REPOSITORY[:TAG]",
|
||||
Short: "Publish compose application",
|
||||
RunE: Adapt(func(ctx context.Context, args []string) error {
|
||||
return runPublish(ctx, dockerCli, backend, opts, args[0])
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
command: docker compose alpha publish
|
||||
short: Publish compose application
|
||||
long: Publish compose application
|
||||
usage: docker compose alpha publish [OPTIONS] [REPOSITORY]
|
||||
usage: docker compose alpha publish [OPTIONS] REPOSITORY[:TAG]
|
||||
pname: docker compose alpha
|
||||
plink: docker_compose_alpha.yaml
|
||||
options:
|
||||
|
|
|
@ -178,6 +178,7 @@ func generateManifest(layers []v1.Descriptor, ociCompat api.OCIVersion) ([]Pusha
|
|||
case api.OCIVersion1_1:
|
||||
config = v1.DescriptorEmptyJSON
|
||||
artifactType = ComposeProjectArtifactType
|
||||
config.ArtifactType = artifactType
|
||||
// N.B. the descriptor has the data embedded in it
|
||||
toPush = append(toPush, Pushable{Descriptor: config, Data: make([]byte, len(config.Data))})
|
||||
default:
|
||||
|
|
|
@ -291,6 +291,7 @@ type ConfigOptions struct {
|
|||
type PushOptions struct {
|
||||
Quiet bool
|
||||
IgnoreFailures bool
|
||||
ImageMandatory bool
|
||||
}
|
||||
|
||||
// PullOptions group options of the Pull API
|
||||
|
|
|
@ -35,7 +35,7 @@ func (s *composeService) Publish(ctx context.Context, project *types.Project, re
|
|||
}
|
||||
|
||||
func (s *composeService) publish(ctx context.Context, project *types.Project, repository string, options api.PublishOptions) error {
|
||||
err := s.Push(ctx, project, api.PushOptions{})
|
||||
err := s.Push(ctx, project, api.PushOptions{IgnoreFailures: true, ImageMandatory: true})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -62,6 +62,9 @@ func (s *composeService) push(ctx context.Context, project *types.Project, optio
|
|||
w := progress.ContextWriter(ctx)
|
||||
for _, service := range project.Services {
|
||||
if service.Build == nil || service.Image == "" {
|
||||
if options.ImageMandatory && service.Image == "" {
|
||||
return fmt.Errorf("%q attribut is mandatory to push an image for service %q", "service.image", service.Name)
|
||||
}
|
||||
w.Event(progress.Event{
|
||||
ID: service.Name,
|
||||
Status: progress.Done,
|
||||
|
|
|
@ -30,6 +30,7 @@ import (
|
|||
"github.com/docker/buildx/store/storeutil"
|
||||
"github.com/docker/buildx/util/imagetools"
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/compose/v2/internal/ocipush"
|
||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
|
@ -113,6 +114,8 @@ func (g ociRemoteLoader) Load(ctx context.Context, path string) (string, error)
|
|||
|
||||
err2 := g.pullComposeFiles(ctx, local, composeFile, manifest, ref, resolver)
|
||||
if err2 != nil {
|
||||
// we need to clean up the directory to be sure we won't let empty files present
|
||||
_ = os.RemoveAll(local)
|
||||
return "", err2
|
||||
}
|
||||
}
|
||||
|
@ -137,8 +140,8 @@ func (g ociRemoteLoader) pullComposeFiles(ctx context.Context, local string, com
|
|||
return err
|
||||
}
|
||||
defer f.Close() //nolint:errcheck
|
||||
|
||||
if manifest.ArtifactType != "application/vnd.docker.compose.project" {
|
||||
if (manifest.ArtifactType != "" && manifest.ArtifactType != ocipush.ComposeProjectArtifactType) ||
|
||||
(manifest.ArtifactType == "" && manifest.Config.MediaType != ocipush.ComposeEmptyConfigMediaType) {
|
||||
return fmt.Errorf("%s is not a compose project OCI artifact, but %s", ref.String(), manifest.ArtifactType)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue