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

     1  package gitlab
     2  
     3  import (
     4  	secret2 "github.com/caos/orbos/pkg/secret"
     5  )
     6  
     7  type Connector struct {
     8  	//Internal id of the gitlab provider
     9  	ID string `json:"id,omitempty" yaml:"id,omitempty"`
    10  	//Internal name of the gitlab provider
    11  	Name string `json:"name,omitempty" yaml:"name,omitempty"`
    12  	//Configuration for the gitlab provider
    13  	Config *Config `json:"config,omitempty" yaml:"config,omitempty"`
    14  }
    15  
    16  func (c *Connector) IsZero() bool {
    17  	if c.ID == "" &&
    18  		c.Name == "" &&
    19  		(c.Config == nil || c.Config.IsZero()) {
    20  		return true
    21  	}
    22  
    23  	return false
    24  }
    25  
    26  func (c *Config) IsZero() bool {
    27  	if (c.ClientID == nil || c.ClientID.IsZero()) &&
    28  		(c.ClientSecret == nil || c.ClientSecret.IsZero()) &&
    29  		c.ExistingClientIDSecret == nil &&
    30  		c.ExistingClientSecretSecret == nil &&
    31  		c.BaseURL == "" &&
    32  		c.Groups == nil &&
    33  		!c.UseLoginAsID {
    34  		return true
    35  	}
    36  	return false
    37  }
    38  
    39  type Config struct {
    40  	ClientID *secret2.Secret `json:"clientID,omitempty" yaml:"clientID,omitempty"`
    41  	//Existing secret with the clientID
    42  	ExistingClientIDSecret *secret2.Existing `json:"existingClientIDSecret,omitempty" yaml:"existingClientIDSecret,omitempty"`
    43  	ClientSecret           *secret2.Secret   `json:"clientSecret,omitempty" yaml:"clientSecret,omitempty"`
    44  	//Existing secret with the clientSecret
    45  	ExistingClientSecretSecret *secret2.Existing `json:"existingClientSecretSecret,omitempty" yaml:"existingClientSecretSecret,omitempty"`
    46  	//BaseURL of the gitlab instance
    47  	BaseURL string `json:"baseURL,omitempty" yaml:"baseURL,omitempty"`
    48  	//Optional groups whitelist, communicated through the "groups" scope
    49  	Groups []string `json:"groups,omitempty" yaml:"groups,omitempty"`
    50  	//Flag which will switch from using the internal GitLab id to the users handle (@mention) as the user id
    51  	UseLoginAsID bool `json:"useLoginAsID,omitempty" yaml:"useLoginAsID,omitempty"`
    52  }