replaceDescriptor adds a descriptor to the index.json of the Path, replacing any one matching matcher, if found.
(appendable mutate.Appendable, matcher match.Matcher, options ...Option)
| 127 | // replaceDescriptor adds a descriptor to the index.json of the Path, replacing |
| 128 | // any one matching matcher, if found. |
| 129 | func (l Path) replaceDescriptor(appendable mutate.Appendable, matcher match.Matcher, options ...Option) error { |
| 130 | ii, err := l.ImageIndex() |
| 131 | if err != nil { |
| 132 | return err |
| 133 | } |
| 134 | |
| 135 | desc, err := partial.Descriptor(appendable) |
| 136 | if err != nil { |
| 137 | return err |
| 138 | } |
| 139 | |
| 140 | o := makeOptions(options...) |
| 141 | for _, opt := range o.descOpts { |
| 142 | opt(desc) |
| 143 | } |
| 144 | |
| 145 | add := mutate.IndexAddendum{ |
| 146 | Add: appendable, |
| 147 | Descriptor: *desc, |
| 148 | } |
| 149 | ii = mutate.AppendManifests(mutate.RemoveManifests(ii, matcher), add) |
| 150 | |
| 151 | index, err := ii.IndexManifest() |
| 152 | if err != nil { |
| 153 | return err |
| 154 | } |
| 155 | |
| 156 | rawIndex, err := json.MarshalIndent(index, "", " ") |
| 157 | if err != nil { |
| 158 | return err |
| 159 | } |
| 160 | |
| 161 | return l.WriteFile("index.json", rawIndex, os.ModePerm) |
| 162 | } |
| 163 | |
| 164 | // RemoveDescriptors removes any descriptors that match the match.Matcher from the index.json of the Path. |
| 165 | func (l Path) RemoveDescriptors(matcher match.Matcher) error { |
no test coverage detected