LoadArchive loads from a reader containing a compressed tar archive.
(in io.Reader)
| 159 | |
| 160 | // LoadArchive loads from a reader containing a compressed tar archive. |
| 161 | func LoadArchive(in io.Reader) (chart.Charter, error) { |
| 162 | // Note: This function is for use by SDK users such as Flux. |
| 163 | |
| 164 | files, err := archive.LoadArchiveFiles(in) |
| 165 | if err != nil { |
| 166 | if errors.Is(err, gzip.ErrHeader) { |
| 167 | return nil, fmt.Errorf("stream does not appear to be a valid chart file (details: %w)", err) |
| 168 | } |
| 169 | return nil, fmt.Errorf("unable to load chart archive: %w", err) |
| 170 | } |
| 171 | |
| 172 | for _, f := range files { |
| 173 | if f.Name == "Chart.yaml" { |
| 174 | c := new(chartBase) |
| 175 | if err := yaml.Unmarshal(f.Data, c); err != nil { |
| 176 | return c, fmt.Errorf("cannot load Chart.yaml: %w", err) |
| 177 | } |
| 178 | switch c.APIVersion { |
| 179 | case c2.APIVersionV1, c2.APIVersionV2, "": |
| 180 | return c2load.LoadFiles(files) |
| 181 | case c3.APIVersionV3: |
| 182 | return c3load.LoadFiles(files) |
| 183 | default: |
| 184 | return nil, errors.New("unsupported chart version") |
| 185 | } |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | return nil, errors.New("unable to detect chart version, no Chart.yaml found") |
| 190 | } |
| 191 | |
| 192 | // chartBase is used to detect the API Version for the chart to run it through the |
| 193 | // loader for that type. |
searching dependent graphs…