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