-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
60 lines (56 loc) · 1.67 KB
/
main.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"flag"
"log"
"os"
"strings"
)
func main() {
chartPath := flag.String("chartPath", ".", "path to the chart")
secretNamespace := flag.String("secretNamespace", "argocd", "namespace where the secret is located")
secretNames := flag.String("registries", os.Getenv("HELM_DEPS_SECRET_NAMES"), "comma separated list of registries to update")
addRegistries := flag.String("add-registries", os.Getenv("HELM_DEPS_SECRET_NAMES_REPO_ADD"), "comma separated list of registries using 'helm repo add'")
ecrLoginEnabled := flag.Bool("ecr", true, "enable ecr login")
flag.Parse()
if ecrLoginEnabled != nil && *ecrLoginEnabled && *secretNames != "" {
registryMap := make(map[string]*RegistryInfo)
for _, registry := range strings.Split(*secretNames, ",") {
registryMap[registry] = &RegistryInfo{}
}
registryHelper := &RegistryHelper{
Registries: registryMap,
Namespace: *secretNamespace,
}
err := registryHelper.UpdateRegistryInfo()
if err != nil {
log.Fatal(err)
}
err = registryHelper.RegistryLogin()
if err != nil {
log.Fatal(err)
}
defer registryHelper.RegistryLogout() // nolint: errcheck
}
if addRegistries != nil && *addRegistries != "" {
registryMap := make(map[string]*RegistryInfo)
for _, registry := range strings.Split(*addRegistries, ",") {
registryMap[registry] = &RegistryInfo{}
}
registryHelper := &RegistryHelper{
Registries: registryMap,
Namespace: *secretNamespace,
}
err := registryHelper.UpdateRegistryInfo()
if err != nil {
log.Fatal(err)
}
err = registryHelper.RegistryAdd()
if err != nil {
log.Fatal(err)
}
}
err := updateDependencies(*chartPath)
if err != nil {
log.Fatal(err)
}
}