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
/
google.go
60 lines (54 loc) · 2.34 KB
/
google.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
53
54
55
56
57
58
59
60
package google
import (
"github.com/caos/orbos/internal/secret"
)
type Connector struct {
//Internal id of the google provider
ID string `json:"id,omitempty" yaml:"id,omitempty"`
//Internal name of the google provider
Name string `json:"name,omitempty" yaml:"name,omitempty"`
//Configuration for the google 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"`
//List of hosted domains which are permitted to login
HostedDomains []string `json:"hostedDomains,omitempty" yaml:"hostedDomains,omitempty"`
//List of groups in the hosted domains which are permitted to login
Groups []string `json:"groups,omitempty" yaml:"groups,omitempty"`
ServiceAccountJSON *secret.Secret `yaml:"serviceAccountJSON,omitempty"`
//Existing secret with the JSON of the service account
ExistingServiceAccountJSONSecret *secret.Existing `json:"existingServiceAccountJSONSecret,omitempty" yaml:"existingServiceAccountJSONSecret,omitempty"`
//File where the serviceAccountJSON will get persisted to impersonate G Suite admin
ServiceAccountFilePath string `json:"serviceAccountFilePath,omitempty" yaml:"serviceAccountFilePath,omitempty"`
//Email of a G Suite admin to impersonate
AdminEmail string `json:"adminEmail,omitempty" yaml:"adminEmail,omitempty"`
}
func (c *Config) IsZero() bool {
if (c.ClientID == nil || c.ClientID.IsZero()) &&
(c.ClientSecret == nil || c.ClientSecret.IsZero()) &&
(c.ServiceAccountJSON == nil || c.ServiceAccountJSON.IsZero()) &&
c.ExistingClientIDSecret == nil &&
c.ExistingClientSecretSecret == nil &&
c.ExistingServiceAccountJSONSecret == nil &&
c.HostedDomains == nil &&
c.Groups == nil &&
c.ServiceAccountFilePath == "" &&
c.AdminEmail == "" {
return true
}
return false
}