forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_data.go
73 lines (60 loc) · 1.51 KB
/
config_data.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
61
62
63
64
65
66
67
68
69
70
71
72
73
package coreconfig
import (
"encoding/json"
"code.cloudfoundry.org/cli/cf/models"
)
type AuthPromptType string
const (
AuthPromptTypeText AuthPromptType = "TEXT"
AuthPromptTypePassword AuthPromptType = "PASSWORD"
)
type AuthPrompt struct {
Type AuthPromptType
DisplayName string
}
type Data struct {
AccessToken string
APIVersion string
AsyncTimeout uint
AuthorizationEndpoint string
ColorEnabled string
ConfigVersion int
DopplerEndPoint string
Locale string
MinCLIVersion string
MinRecommendedCLIVersion string
OrganizationFields models.OrganizationFields
PluginRepos []models.PluginRepo
RefreshToken string
RoutingAPIEndpoint string
SpaceFields models.SpaceFields
SSHOAuthClient string
SSLDisabled bool
Target string
Trace string
UaaEndpoint string
UAAGrantType string
UAAOAuthClient string
UAAOAuthClientSecret string
}
func NewData() *Data {
data := new(Data)
data.UAAOAuthClient = "cf"
data.UAAOAuthClientSecret = ""
return data
}
func (d *Data) JSONMarshalV3() ([]byte, error) {
d.ConfigVersion = 3
return json.MarshalIndent(d, "", " ")
}
func (d *Data) JSONUnmarshalV3(input []byte) error {
err := json.Unmarshal(input, d)
if err != nil {
return err
}
if d.ConfigVersion != 3 {
*d = Data{}
return nil
}
return nil
}