(ctx context.Context, tag string, quietPush bool)
| 87 | } |
| 88 | |
| 89 | func (s *composeService) pushServiceImage(ctx context.Context, tag string, quietPush bool) error { |
| 90 | ref, err := reference.ParseNormalizedNamed(tag) |
| 91 | if err != nil { |
| 92 | return err |
| 93 | } |
| 94 | |
| 95 | authConfig, err := s.configFile().GetAuthConfig(registry.GetAuthConfigKey(reference.Domain(ref))) |
| 96 | if err != nil { |
| 97 | return err |
| 98 | } |
| 99 | |
| 100 | buf, err := json.Marshal(authConfig) |
| 101 | if err != nil { |
| 102 | return err |
| 103 | } |
| 104 | |
| 105 | stream, err := s.apiClient().ImagePush(ctx, tag, client.ImagePushOptions{ |
| 106 | RegistryAuth: base64.URLEncoding.EncodeToString(buf), |
| 107 | }) |
| 108 | if err != nil { |
| 109 | return err |
| 110 | } |
| 111 | dec := json.NewDecoder(stream) |
| 112 | for { |
| 113 | var jm jsonstream.Message |
| 114 | if err := dec.Decode(&jm); err != nil { |
| 115 | if errors.Is(err, io.EOF) { |
| 116 | break |
| 117 | } |
| 118 | return err |
| 119 | } |
| 120 | if jm.Error != nil { |
| 121 | return errors.New(jm.Error.Message) |
| 122 | } |
| 123 | |
| 124 | if !quietPush { |
| 125 | toPushProgressEvent(tag, jm, s.events) |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | return nil |
| 130 | } |
| 131 | |
| 132 | func toPushProgressEvent(prefix string, jm jsonstream.Message, events api.EventProcessor) { |
| 133 | if jm.ID == "" { |
no test coverage detected