github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/boom/api/v1beta1/argocd/argocd.go (about)

     1  package argocd
     2  
     3  import (
     4  	"github.com/caos/orbos/internal/operator/boom/api/v1beta1/argocd/auth"
     5  	"github.com/caos/orbos/internal/operator/boom/api/v1beta1/argocd/repository"
     6  	"github.com/caos/orbos/internal/operator/boom/api/v1beta1/network"
     7  	secret2 "github.com/caos/orbos/pkg/secret"
     8  )
     9  
    10  type Argocd struct {
    11  	//Flag if tool should be deployed
    12  	//@default: false
    13  	Deploy bool `json:"deploy" yaml:"deploy"`
    14  	//Use of custom argocd-image which includes gopass
    15  	//@default: false
    16  	CustomImage *CustomImage `json:"customImage,omitempty" yaml:"customImage,omitempty"`
    17  	//Network configuration, used for SSO and external access
    18  	Network *network.Network `json:"network,omitempty" yaml:"network,omitempty"`
    19  	//Authorization and Authentication configuration for SSO
    20  	Auth *auth.Auth `json:"auth,omitempty" yaml:"auth,omitempty"`
    21  	//Configuration for RBAC in argocd
    22  	Rbac *Rbac `json:"rbacConfig,omitempty" yaml:"rbacConfig,omitempty"`
    23  	//Repositories used by argocd
    24  	Repositories []*repository.Repository `json:"repositories,omitempty" yaml:"repositories,omitempty"`
    25  	//Credentials used by argocd
    26  	Credentials []*repository.Repository `json:"credentials,omitempty" yaml:"credentials,omitempty"`
    27  	//List of known_hosts as strings for argocd
    28  	KnownHosts []string `json:"knownHosts,omitempty" yaml:"knownHosts,omitempty"`
    29  	//NodeSelector for deployment
    30  	NodeSelector map[string]string `json:"nodeSelector,omitempty" yaml:"nodeSelector,omitempty"`
    31  }
    32  
    33  func (r *Argocd) InitSecrets() {
    34  	if r.Auth == nil {
    35  		r.Auth = &auth.Auth{}
    36  	}
    37  	r.Auth.InitSecrets()
    38  
    39  	for _, repo := range append(r.Repositories, r.Credentials...) {
    40  		repo.InitSecrets()
    41  	}
    42  }
    43  
    44  func (r *Argocd) IsZero() bool {
    45  	if !r.Deploy &&
    46  		r.CustomImage == nil &&
    47  		r.Network == nil &&
    48  		(r.Auth == nil || r.Auth.IsZero()) &&
    49  		r.Rbac == nil &&
    50  		r.Repositories == nil &&
    51  		r.Credentials == nil &&
    52  		r.KnownHosts == nil &&
    53  		r.NodeSelector == nil {
    54  		return true
    55  	}
    56  
    57  	return false
    58  }
    59  
    60  type Rbac struct {
    61  	//Attribute policy.csv which goes into configmap argocd-rbac-cm
    62  	Csv string `json:"policy.csv,omitempty" yaml:"policy.csv,omitempty"`
    63  	//Attribute policy.default which goes into configmap argocd-rbac-cm
    64  	Default string `json:"policy.default,omitempty" yaml:"policy.default,omitempty"`
    65  	//List of scopes which go into configmap argocd-rbac-cm
    66  	Scopes []string `json:"scopes,omitempty" yaml:"scopes,omitempty"`
    67  }
    68  
    69  type CustomImage struct {
    70  	//Flag if custom argocd-image should get used with gopass
    71  	Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
    72  	//List of gopass stores which should get cloned by argocd on startup
    73  	GopassStores []*GopassStore `json:"gopassStores,omitempty" yaml:"gopassStores,omitempty"`
    74  }
    75  
    76  type GopassStore struct {
    77  	SSHKey *secret2.Secret `json:"sshKey,omitempty" yaml:"sshKey,omitempty"`
    78  	//Existing secret with ssh-key to clone the repository for gopass
    79  	ExistingSSHKeySecret *secret2.Existing `json:"existingSshKeySecret,omitempty" yaml:"existingSshKeySecret,omitempty"`
    80  	GPGKey               *secret2.Secret   `json:"gpgKey,omitempty" yaml:"gpgKey,omitempty"`
    81  	//Existing secret with gpg-key to decode the repository for gopass
    82  	ExistingGPGKeySecret *secret2.Existing `json:"existingGpgKeySecret,omitempty" yaml:"existingGpgKeySecret,omitempty"`
    83  	//URL to repository for gopass store
    84  	Directory string `json:"directory,omitempty" yaml:"directory,omitempty"`
    85  	//Name of the gopass store
    86  	StoreName string `json:"storeName,omitempty" yaml:"storeName,omitempty"`
    87  }