-
Notifications
You must be signed in to change notification settings - Fork 90
/
helm.go
42 lines (35 loc) · 1000 Bytes
/
helm.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package operator
import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/pkg/errors"
)
func getChartsImagePullSecrets(deployedVersionArchive string) ([]string, error) {
archiveChartDir := filepath.Join(deployedVersionArchive, "overlays", "midstream", "charts")
chartDirs, err := ioutil.ReadDir(archiveChartDir)
if err != nil {
if os.IsNotExist(err) {
return nil, nil
}
return nil, errors.Wrap(err, "failed to read charts directory")
}
imagePullSecrets := []string{}
for _, chartDir := range chartDirs {
if !chartDir.IsDir() {
continue
}
secretFilename := filepath.Join(archiveChartDir, chartDir.Name(), "secret.yaml")
secretData, err := ioutil.ReadFile(secretFilename)
if err != nil {
if os.IsNotExist(err) {
continue
}
return nil, errors.Wrap(err, "failed to read helm tar.gz file")
}
secrets := strings.Split(string(secretData), "\n---\n")
imagePullSecrets = append(imagePullSecrets, secrets...)
}
return imagePullSecrets, nil
}