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
46 lines (41 loc) · 1.5 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
package gitlab
import (
"github.com/caos/orbos/internal/secret"
"reflect"
)
type Auth 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"`
//Groups of gitlab allowed to login
AllowedGroups []string `json:"allowedGroups,omitempty" yaml:"allowedGroups,omitempty"`
}
func ClearEmpty(g *Auth) *Auth {
if g == nil {
return nil
}
marshaled := Auth{
ClientID: secret.ClearEmpty(g.ClientID),
ExistingClientIDSecret: g.ExistingClientIDSecret,
ClientSecret: secret.ClearEmpty(g.ClientSecret),
ExistingClientSecretSecret: g.ExistingClientSecretSecret,
AllowedGroups: g.AllowedGroups,
}
if reflect.DeepEqual(marshaled, Auth{}) {
return nil
}
return &marshaled
}
func (g *Auth) MarshalYAML() (interface{}, error) {
type Alias Auth
return &Alias{
ClientID: secret.ClearEmpty(g.ClientID),
ExistingClientIDSecret: g.ExistingClientIDSecret,
ClientSecret: secret.ClearEmpty(g.ClientSecret),
ExistingClientSecretSecret: g.ExistingClientSecretSecret,
AllowedGroups: g.AllowedGroups,
}, nil
}