This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
argocd.go
85 lines (77 loc) · 3.37 KB
/
argocd.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package argocd
import (
"github.com/caos/orbos/internal/operator/boom/api/v1beta1/argocd/auth"
"github.com/caos/orbos/internal/operator/boom/api/v1beta1/argocd/repository"
"github.com/caos/orbos/internal/operator/boom/api/v1beta1/network"
"github.com/caos/orbos/internal/secret"
)
type Argocd struct {
//Flag if tool should be deployed
//@default: false
Deploy bool `json:"deploy" yaml:"deploy"`
//Use of custom argocd-image which includes gopass
//@default: false
CustomImage *CustomImage `json:"customImage,omitempty" yaml:"customImage,omitempty"`
//Network configuration, used for SSO and external access
Network *network.Network `json:"network,omitempty" yaml:"network,omitempty"`
//Authorization and Authentication configuration for SSO
Auth *auth.Auth `json:"auth,omitempty" yaml:"auth,omitempty"`
//Configuration for RBAC in argocd
Rbac *Rbac `json:"rbacConfig,omitempty" yaml:"rbacConfig,omitempty"`
//Repositories used by argocd
Repositories []*repository.Repository `json:"repositories,omitempty" yaml:"repositories,omitempty"`
//Credentials used by argocd
Credentials []*repository.Repository `json:"credentials,omitempty" yaml:"credentials,omitempty"`
//List of known_hosts as strings for argocd
KnownHosts []string `json:"knownHosts,omitempty" yaml:"knownHosts,omitempty"`
//NodeSelector for deployment
NodeSelector map[string]string `json:"nodeSelector,omitempty" yaml:"nodeSelector,omitempty"`
}
func (r *Argocd) InitSecrets() {
if r.Auth == nil {
r.Auth = &auth.Auth{}
}
r.Auth.InitSecrets()
}
func (r *Argocd) IsZero() bool {
if !r.Deploy &&
r.CustomImage == nil &&
r.Network == nil &&
(r.Auth == nil || r.Auth.IsZero()) &&
r.Rbac == nil &&
r.Repositories == nil &&
r.Credentials == nil &&
r.KnownHosts == nil &&
r.NodeSelector == nil {
return true
}
return false
}
type Rbac struct {
//Attribute policy.csv which goes into configmap argocd-rbac-cm
Csv string `json:"policy.csv,omitempty" yaml:"policy.csv,omitempty"`
//Attribute policy.default which goes into configmap argocd-rbac-cm
Default string `json:"policy.default,omitempty" yaml:"policy.default,omitempty"`
//List of scopes which go into configmap argocd-rbac-cm
Scopes []string `json:"scopes,omitempty" yaml:"scopes,omitempty"`
}
type CustomImage struct {
//Flag if custom argocd-image should get used with gopass
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
//Name of used imagePullSecret to pull customImage
ImagePullSecret string `json:"imagePullSecret,omitempty" yaml:"imagePullSecret,omitempty"`
//List of gopass stores which should get cloned by argocd on startup
GopassStores []*GopassStore `json:"gopassStores,omitempty" yaml:"gopassStores,omitempty"`
}
type GopassStore struct {
SSHKey *secret.Secret `yaml:"sshKey,omitempty"`
//Existing secret with ssh-key to clone the repository for gopass
ExistingSSHKeySecret *secret.Existing `json:"existingSshKeySecret,omitempty" yaml:"existingSshKeySecret,omitempty"`
GPGKey *secret.Secret `yaml:"gpgKey,omitempty"`
//Existing secret with gpg-key to decode the repository for gopass
ExistingGPGKeySecret *secret.Existing `json:"existingGpgKeySecret,omitempty" yaml:"existingGpgKeySecret,omitempty"`
//URL to repository for gopass store
Directory string `json:"directory,omitempty" yaml:"directory,omitempty"`
//Name of the gopass store
StoreName string `json:"storeName,omitempty" yaml:"storeName,omitempty"`
}