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

     1  package reconciling
     2  
     3  import (
     4  	"github.com/caos/orbos/internal/operator/boom/api/latest/network"
     5  	"github.com/caos/orbos/internal/operator/boom/api/latest/reconciling/auth"
     6  	"github.com/caos/orbos/internal/operator/boom/api/latest/reconciling/repository"
     7  	"github.com/caos/orbos/pkg/kubernetes/k8s"
     8  	"github.com/caos/orbos/pkg/secret"
     9  )
    10  
    11  type Reconciling struct {
    12  	//Flag if tool should be deployed
    13  	//@default: false
    14  	Deploy bool `json:"deploy" yaml:"deploy"`
    15  	//Use of custom argocd-image which includes gopass
    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  	//Tolerations to run argocd on nodes
    32  	Tolerations k8s.Tolerations `json:"tolerations,omitempty" yaml:"tolerations,omitempty"`
    33  	//Dex options
    34  	Dex *CommonComponent `json:"dex,omitempty" yaml:"dex,omitempty"`
    35  	//RepoServer options
    36  	RepoServer *CommonComponent `json:"repoServer,omitempty" yaml:"repoServer,omitempty"`
    37  	//Redis options
    38  	Redis *CommonComponent `json:"redis,omitempty" yaml:"redis,omitempty"`
    39  	//Controller options
    40  	Controller *CommonComponent `json:"controller,omitempty" yaml:"controller,omitempty"`
    41  	//Server options
    42  	Server *CommonComponent `json:"server,omitempty" yaml:"server,omitempty"`
    43  	//Overwrite used image
    44  	OverwriteImage string `json:"overwriteImage,omitempty" yaml:"overwriteImage,omitempty"`
    45  	//Overwrite used image version
    46  	OverwriteVersion string `json:"overwriteVersion,omitempty" yaml:"overwriteVersion,omitempty"`
    47  	//Additional parameters to use in the deployments
    48  	AdditionalParameters *AdditionalParameters `json:"additionalParameters,omitempty" yaml:"additionalParameters,omitempty"`
    49  }
    50  
    51  type AdditionalParameters struct {
    52  	//Additional parameters for the Repo-Server
    53  	RepoServer []string `json:"repoServer,omitempty" yaml:"repoServer,omitempty"`
    54  	//Additional parameters for the Application-Controller
    55  	ApplicationController []string `json:"applicationController,omitempty" yaml:"applicationController,omitempty"`
    56  	//Additional parameters for the Server
    57  	Server []string `json:"server,omitempty" yaml:"server,omitempty"`
    58  }
    59  
    60  func (r *Reconciling) InitSecrets() {
    61  	if r.Auth == nil {
    62  		r.Auth = &auth.Auth{}
    63  	}
    64  	r.Auth.InitSecrets()
    65  }
    66  
    67  func (r *Reconciling) IsZero() bool {
    68  	if !r.Deploy &&
    69  		r.CustomImage == nil &&
    70  		r.Network == nil &&
    71  		(r.Auth == nil || r.Auth.IsZero()) &&
    72  		r.Rbac == nil &&
    73  		r.Repositories == nil &&
    74  		r.Credentials == nil &&
    75  		r.KnownHosts == nil &&
    76  		r.NodeSelector == nil &&
    77  		r.Tolerations == nil &&
    78  		r.Dex == nil &&
    79  		r.RepoServer == nil &&
    80  		r.Redis == nil &&
    81  		r.Controller == nil &&
    82  		r.Server == nil {
    83  		return true
    84  	}
    85  
    86  	return false
    87  }
    88  
    89  type CommonComponent struct {
    90  	//Resource requirements
    91  	Resources *k8s.Resources `json:"resources,omitempty" yaml:"resources,omitempty"`
    92  }
    93  
    94  /*
    95  	values.Dex.Tolerations = append(values.Dex.Tolerations, t)
    96  	values.RepoServer.Tolerations = append(values.RepoServer.Tolerations, t)
    97  	values.Redis.Tolerations = append(values.Redis.Tolerations, t)
    98  	values.Controller.Tolerations = append(values.Controller.Tolerations, t)
    99  	values.Server.Tolerations = append(values.Server.Tolerations, t)
   100  */
   101  
   102  type Rbac struct {
   103  	//Attribute policy.csv which goes into configmap argocd-rbac-cm
   104  	Csv string `json:"policy.csv,omitempty" yaml:"policy.csv,omitempty"`
   105  	//Attribute policy.default which goes into configmap argocd-rbac-cm
   106  	Default string `json:"policy.default,omitempty" yaml:"policy.default,omitempty"`
   107  	//List of scopes which go into configmap argocd-rbac-cm
   108  	Scopes []string `json:"scopes,omitempty" yaml:"scopes,omitempty"`
   109  }
   110  
   111  type CustomImage struct {
   112  	//Flag if custom argocd-image should get used with gopass
   113  	Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
   114  	//List of gopass stores which should get cloned by argocd on startup
   115  	GopassStores []*GopassStore `json:"gopassStores,omitempty" yaml:"gopassStores,omitempty"`
   116  }
   117  
   118  type GopassStore struct {
   119  	SSHKey *secret.Secret `json:"sshKey,omitempty" yaml:"sshKey,omitempty"`
   120  	//Existing secret with ssh-key to clone the repository for gopass
   121  	ExistingSSHKeySecret *secret.Existing `json:"existingSshKeySecret,omitempty" yaml:"existingSshKeySecret,omitempty"`
   122  	GPGKey               *secret.Secret   `json:"gpgKey,omitempty" yaml:"gpgKey,omitempty"`
   123  	//Existing secret with gpg-key to decode the repository for gopass
   124  	ExistingGPGKeySecret *secret.Existing `json:"existingGpgKeySecret,omitempty" yaml:"existingGpgKeySecret,omitempty"`
   125  	//URL to repository for gopass store
   126  	Directory string `json:"directory,omitempty" yaml:"directory,omitempty"`
   127  	//Name of the gopass store
   128  	StoreName string `json:"storeName,omitempty" yaml:"storeName,omitempty"`
   129  }