github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/boom/api/latest/reconciling/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  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  	//Required membership to organization in github
    34  	Orgs []*Org `json:"orgs,omitempty" yaml:"orgs,omitempty"`
    35  	//Flag which indicates that all user groups and teams should be loaded
    36  	LoadAllGroups bool `json:"loadAllGroups,omitempty" yaml:"loadAllGroups,omitempty"`
    37  	//Optional choice between 'name' (default), 'slug', or 'both'
    38  	TeamNameField string `json:"teamNameField,omitempty" yaml:"teamNameField,omitempty"`
    39  	//Flag which will switch from using the internal GitHub id to the users handle (@mention) as the user id
    40  	UseLoginAsID bool `json:"useLoginAsID,omitempty" yaml:"useLoginAsID,omitempty"`
    41  }
    42  
    43  func (c *Config) IsZero() bool {
    44  	if (c.ClientID == nil || c.ClientID.IsZero()) &&
    45  		(c.ClientSecret == nil || c.ClientSecret.IsZero()) &&
    46  		c.ExistingClientIDSecret == nil &&
    47  		c.ExistingClientSecretSecret == nil &&
    48  		c.Orgs == nil &&
    49  		!c.LoadAllGroups &&
    50  		c.TeamNameField == "" &&
    51  		!c.UseLoginAsID {
    52  		return true
    53  	}
    54  	return false
    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  }