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

     1  package github
     2  
     3  import (
     4  	secret2 "github.com/caos/orbos/pkg/secret"
     5  )
     6  
     7  type Connector struct {
     8  	//Internal id of the github provider
     9  	ID string `json:"id,omitempty" yaml:"id,omitempty"`
    10  	//Internal name of the github provider
    11  	Name string `json:"name,omitempty" yaml:"name,omitempty"`
    12  	//Configuration for the github 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.Orgs == nil &&
    32  		!c.LoadAllGroups &&
    33  		c.TeamNameField == "" &&
    34  		!c.UseLoginAsID {
    35  		return true
    36  	}
    37  	return false
    38  }
    39  
    40  type Config struct {
    41  	ClientID *secret2.Secret `json:"clientID,omitempty" yaml:"clientID,omitempty"`
    42  	//Existing secret with the clientID
    43  	ExistingClientIDSecret *secret2.Existing `json:"existingClientIDSecret,omitempty" yaml:"existingClientIDSecret,omitempty"`
    44  	ClientSecret           *secret2.Secret   `json:"clientSecret,omitempty" yaml:"clientSecret,omitempty"`
    45  	//Existing secret with the clientSecret
    46  	ExistingClientSecretSecret *secret2.Existing `json:"existingClientSecretSecret,omitempty" yaml:"existingClientSecretSecret,omitempty"`
    47  	//Required membership to organization in github
    48  	Orgs []*Org `json:"orgs,omitempty" yaml:"orgs,omitempty"`
    49  	//Flag which indicates that all user groups and teams should be loaded
    50  	LoadAllGroups bool `json:"loadAllGroups,omitempty" yaml:"loadAllGroups,omitempty"`
    51  	//Optional choice between 'name' (default), 'slug', or 'both'
    52  	TeamNameField string `json:"teamNameField,omitempty" yaml:"teamNameField,omitempty"`
    53  	//Flag which will switch from using the internal GitHub id to the users handle (@mention) as the user id
    54  	UseLoginAsID bool `json:"useLoginAsID,omitempty" yaml:"useLoginAsID,omitempty"`
    55  }
    56  
    57  type Org struct {
    58  	//Name of the organization
    59  	Name string `json:"name,omitempty" yaml:"name,omitempty"`
    60  	//Name of the required team in the organization
    61  	Teams []string `json:"teams,omitempty" yaml:"teams,omitempty"`
    62  }