-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.go
93 lines (89 loc) · 2.83 KB
/
config.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package resingo
import "encoding/json"
//ResinConfig resin configuration
type ResinConfig struct {
SocialProviders []string `json:"supportedSocialProviders"`
SignupCodeRequired bool `json:"signupCodeRequired"`
MixPanelToken string `json:"mixpanelToken"`
KeenProjectID string `json:"keenProjectId"`
KeenReadKey string `json:"keenReadKey"`
DeviceURLBase string `json:"deviceUrlsBase"`
GitServerURL string `json:"gitServerUrl"`
ImageMakerURL string `json:"imgMakerUrl"`
AdminURL string `json:"adminUrl"`
DebugEnabled bool `json:"debugEnabled"`
PubNub struct {
PubKey string `json:"publish_key"`
SubKey string `json:"subscribe_key"`
} `json:"pubnub"`
GoogleAnalytics struct {
ID string `kson:"id"`
Site string `json:"site"`
} `json:"ga"`
DeviceTypes []struct {
Slug string `json:"slug"`
Version int `json:"version"`
Aliases []string `json:"aliases"`
Name string `json:"name"`
Arch string `json:"arch"`
State string `json:"state"`
StateInstructions struct {
PostProvisioning []string `json:"postProvisioning"`
} `json:"stateInstructions"`
//Instructions []string `json:"instructions"`
SupportsBlink bool `json:"supportsBlink"`
Yocto struct {
Machine string `json:"machine"`
Image string `json:"image"`
FSType string `json:"fstype"`
Version string `json:"version"`
DeployArtfact string `json:"deployArtfact"`
Compressed bool `json:"compressed"`
} `json:"yocto"`
Options []struct {
IsGroup bool `json:"isGroup"`
Name string `json:"name"`
Message string `json:"message"`
Options []struct {
Name string `json:"name"`
Message string `json:"message"`
Type string `json:"type"`
CHoices []string `json:"choices"`
} `json:"options"`
} `json:"options"`
Configuration struct {
Config struct {
Partition struct {
Primary int `json:"primary"`
} `json:"partition"`
} `json:"config"`
} `json:"configuration"`
Initialization struct {
Options []struct {
Name string `json:"name"`
Message string `json:"message"`
Type string `json:"type"`
} `json:"options"`
Operations []struct {
Command string `json:"command"`
} `json:"operations"`
} `json:"initialization"`
BuildID string `json:"buildId"`
} `json:"deviceTypes"`
}
//ConfigGetAll return resin congiguration
func ConfigGetAll(ctx *Context) (*ResinConfig, error) {
h := authHeader(ctx.Config.AuthToken)
//uri := ctx.Config.APIEndpoint("config")
uri := apiEndpoint + "/config"
b, err := doJSON(ctx, "GET", uri, h, nil, nil)
if err != nil {
return nil, err
}
cfg := &ResinConfig{}
err = json.Unmarshal(b, cfg)
if err != nil {
return nil, err
}
return cfg, nil
}