(repoURL, path, commit string)
| 193 | } |
| 194 | |
| 195 | func (r Repo) LoadInitialTemplateValues(repoURL, path, commit string) (map[string]interface{}, error) { |
| 196 | creds, err := r.credResolver.RepoAuthCredentials(repoURL) |
| 197 | if err != nil { |
| 198 | return nil, err |
| 199 | } |
| 200 | |
| 201 | commitSHA, err := resolveRef(repoURL, commit, creds) |
| 202 | if err != nil { |
| 203 | return nil, err |
| 204 | } |
| 205 | |
| 206 | cached, ok := r.cache.GetTemplateInitialValues(repoURL, path, commitSHA, string(cyclopsv1alpha1.TemplateSourceTypeGit)) |
| 207 | if ok { |
| 208 | return cached, nil |
| 209 | } |
| 210 | |
| 211 | if gitproviders2.IsGitHubSource(repoURL) { |
| 212 | ghInitialValues, err := r.mapGitHubRepoInitialValues(repoURL, path, commitSHA, creds) |
| 213 | if err != nil { |
| 214 | return nil, err |
| 215 | } |
| 216 | |
| 217 | r.cache.SetTemplateInitialValues(repoURL, path, commitSHA, string(cyclopsv1alpha1.TemplateSourceTypeGit), ghInitialValues) |
| 218 | |
| 219 | return ghInitialValues, nil |
| 220 | } |
| 221 | |
| 222 | fs, err := clone(repoURL, commit, creds) |
| 223 | if err != nil { |
| 224 | return nil, err |
| 225 | } |
| 226 | |
| 227 | // load helm chart metadata |
| 228 | chartMetadata, err := fs.Open(path2.Join(path, "Chart.yaml")) |
| 229 | if err != nil { |
| 230 | return nil, errors.Wrap(err, "could not read 'Chart.yaml' file; it should be placed in the repo/path you provided; make sure you provided the correct path") |
| 231 | } |
| 232 | |
| 233 | var chartMetadataBuffer bytes.Buffer |
| 234 | _, err = io.Copy(bufio.NewWriter(&chartMetadataBuffer), chartMetadata) |
| 235 | if err != nil { |
| 236 | return nil, err |
| 237 | } |
| 238 | |
| 239 | var metadata *helm.Metadata |
| 240 | if err := yaml.Unmarshal(chartMetadataBuffer.Bytes(), &metadata); err != nil { |
| 241 | return nil, err |
| 242 | } |
| 243 | // endregion |
| 244 | |
| 245 | // region read values |
| 246 | data, err := readValuesFile(fs, path) |
| 247 | if err != nil { |
| 248 | return nil, err |
| 249 | } |
| 250 | |
| 251 | var initialValues map[string]interface{} |
| 252 | if err := yaml.Unmarshal(data, &initialValues); err != nil { |
no test coverage detected