(out *tar.Writer, c *chart.Chart, prefix string)
| 155 | } |
| 156 | |
| 157 | func writeTarContents(out *tar.Writer, c *chart.Chart, prefix string) error { |
| 158 | err := validateName(c.Name()) |
| 159 | if err != nil { |
| 160 | return err |
| 161 | } |
| 162 | base := filepath.Join(prefix, c.Name()) |
| 163 | |
| 164 | // Pull out the dependencies of a v1 Chart, since there's no way |
| 165 | // to tell the serializer to skip a field for just this use case |
| 166 | savedDependencies := c.Metadata.Dependencies |
| 167 | if c.Metadata.APIVersion == chart.APIVersionV1 { |
| 168 | c.Metadata.Dependencies = nil |
| 169 | } |
| 170 | // Save Chart.yaml |
| 171 | cdata, err := yaml.Marshal(c.Metadata) |
| 172 | if c.Metadata.APIVersion == chart.APIVersionV1 { |
| 173 | c.Metadata.Dependencies = savedDependencies |
| 174 | } |
| 175 | if err != nil { |
| 176 | return err |
| 177 | } |
| 178 | if err := writeToTar(out, filepath.Join(base, ChartfileName), cdata, c.ModTime); err != nil { |
| 179 | return err |
| 180 | } |
| 181 | |
| 182 | // Save Chart.lock |
| 183 | // TODO: remove the APIVersion check when APIVersionV1 is not used anymore |
| 184 | if c.Metadata.APIVersion == chart.APIVersionV2 { |
| 185 | if c.Lock != nil { |
| 186 | ldata, err := yaml.Marshal(c.Lock) |
| 187 | if err != nil { |
| 188 | return err |
| 189 | } |
| 190 | if err := writeToTar(out, filepath.Join(base, "Chart.lock"), ldata, c.Lock.Generated); err != nil { |
| 191 | return err |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | // Save values.yaml |
| 197 | for _, f := range c.Raw { |
| 198 | if f.Name == ValuesfileName { |
| 199 | if err := writeToTar(out, filepath.Join(base, ValuesfileName), f.Data, f.ModTime); err != nil { |
| 200 | return err |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | // Save values.schema.json if it exists |
| 206 | if c.Schema != nil { |
| 207 | if !json.Valid(c.Schema) { |
| 208 | return errors.New("invalid JSON in " + SchemafileName) |
| 209 | } |
| 210 | if err := writeToTar(out, filepath.Join(base, SchemafileName), c.Schema, c.SchemaModTime); err != nil { |
| 211 | return err |
| 212 | } |
| 213 | } |
| 214 |
no test coverage detected
searching dependent graphs…