-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
33 lines (28 loc) · 992 Bytes
/
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
package main
import (
"log"
"os"
"time"
"github.com/sikalabs/github-apps-pull-secret-sync/pkg/ghcr"
"github.com/sikalabs/github-apps-pull-secret-sync/pkg/kubernetes"
"github.com/sikalabs/github-apps-pull-secret-sync/version"
)
func main() {
if len(os.Args) < 5 {
log.Fatalf("Usage github-apps-pull-secret-sync "+version.Version+": %s <githubAppID> <githubInstallationID> <privateKeyPath> <username> [<namespace> ...]", os.Args[0])
}
log.Println("Starting github-apps-pull-secret-sync", version.Version)
for {
token := ghcr.GetGhcrToken(os.Args[1], os.Args[2], os.Args[3])
dockerConfigJson := ghcr.CreateDockerConfigJson(os.Args[4], token)
namespaces := os.Args[5:]
if len(namespaces) == 0 {
namespaces = kubernetes.GetNamespaces()
}
for _, namespace := range namespaces {
kubernetes.CreateOrUpdareSecretDockerConfigJson("github-apps-pull-secret", namespace, dockerConfigJson)
}
log.Println("Sleeping 50 minutes ...")
time.Sleep(50 * time.Minute)
}
}