github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/boom/api/latest/reconciling/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  type Config struct {
    27  	ClientID *secret2.Secret `json:"clientID,omitempty" yaml:"clientID,omitempty"`
    28  	//Existing secret with the clientID
    29  	ExistingClientIDSecret *secret2.Existing `json:"existingClientIDSecret,omitempty" yaml:"existingClientIDSecret,omitempty"`
    30  	ClientSecret           *secret2.Secret   `json:"clientSecret,omitempty" yaml:"clientSecret,omitempty"`
    31  	//Existing secret with the clientSecret
    32  	ExistingClientSecretSecret *secret2.Existing `json:"existingClientSecretSecret,omitempty" yaml:"existingClientSecretSecret,omitempty"`
    33  	//BaseURL of the gitlab instance
    34  	BaseURL string `json:"baseURL,omitempty" yaml:"baseURL,omitempty"`
    35  	//Optional groups whitelist, communicated through the "groups" scope
    36  	Groups []string `json:"groups,omitempty" yaml:"groups,omitempty"`
    37  	//Flag which will switch from using the internal GitLab id to the users handle (@mention) as the user id
    38  	UseLoginAsID bool `json:"useLoginAsID,omitempty" yaml:"useLoginAsID,omitempty"`
    39  }
    40  
    41  func (c *Config) IsZero() bool {
    42  	if (c.ClientID == nil || c.ClientID.IsZero()) &&
    43  		(c.ClientSecret == nil || c.ClientSecret.IsZero()) &&
    44  		c.ExistingClientIDSecret == nil &&
    45  		c.ExistingClientSecretSecret == nil &&
    46  		c.BaseURL == "" &&
    47  		c.Groups == nil &&
    48  		!c.UseLoginAsID {
    49  		return true
    50  	}
    51  	return false
    52  }