nolint:gocyclo
(ctx context.Context, project *types.Project, repository string, options api.PublishOptions)
| 53 | |
| 54 | //nolint:gocyclo |
| 55 | func (s *composeService) publish(ctx context.Context, project *types.Project, repository string, options api.PublishOptions) error { |
| 56 | project, err := project.WithProfiles([]string{"*"}) |
| 57 | if err != nil { |
| 58 | return err |
| 59 | } |
| 60 | accept, err := s.preChecks(ctx, project, options) |
| 61 | if err != nil { |
| 62 | return err |
| 63 | } |
| 64 | if !accept { |
| 65 | return api.ErrCanceled |
| 66 | } |
| 67 | err = s.Push(ctx, project, api.PushOptions{IgnoreFailures: true, ImageMandatory: true}) |
| 68 | if err != nil { |
| 69 | return err |
| 70 | } |
| 71 | |
| 72 | layers, err := s.createLayers(ctx, project, options) |
| 73 | if err != nil { |
| 74 | return err |
| 75 | } |
| 76 | |
| 77 | s.events.On(api.Resource{ |
| 78 | ID: repository, |
| 79 | Text: "publishing", |
| 80 | Status: api.Working, |
| 81 | }) |
| 82 | if logrus.IsLevelEnabled(logrus.DebugLevel) { |
| 83 | logrus.Debug("publishing layers") |
| 84 | for _, layer := range layers { |
| 85 | indent, _ := json.MarshalIndent(layer, "", " ") |
| 86 | fmt.Println(string(indent)) |
| 87 | } |
| 88 | } |
| 89 | if !s.dryRun { |
| 90 | named, err := reference.ParseDockerRef(repository) |
| 91 | if err != nil { |
| 92 | return err |
| 93 | } |
| 94 | |
| 95 | var insecureRegistries []string |
| 96 | if options.InsecureRegistry { |
| 97 | insecureRegistries = append(insecureRegistries, reference.Domain(named)) |
| 98 | } |
| 99 | |
| 100 | resolver := oci.NewResolver(s.configFile(), desktop.ProxyTransportFor(ctx, s.apiClient()), insecureRegistries...) |
| 101 | |
| 102 | descriptor, err := oci.PushManifest(ctx, resolver, named, layers, options.OCIVersion) |
| 103 | if err != nil { |
| 104 | s.events.On(api.Resource{ |
| 105 | ID: repository, |
| 106 | Text: "publishing", |
| 107 | Status: api.Error, |
| 108 | }) |
| 109 | return err |
| 110 | } |
| 111 | |
| 112 | if options.Application { |