forked from juju/juju
/
caas.go
147 lines (120 loc) · 5.63 KB
/
caas.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// Copyright 2020 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package params
import (
"github.com/juju/names/v4"
"github.com/juju/version/v2"
"github.com/DavinZhang/juju/core/constraints"
)
// CAASUnitIntroductionArgs is used by sidecar units to introduce
// themselves via CAASApplication facade.
type CAASUnitIntroductionArgs struct {
PodName string `json:"pod-name"`
PodUUID string `json:"pod-uuid"`
}
// CAASUnitIntroduction contains the agent config for CAASApplication units.
type CAASUnitIntroduction struct {
UnitName string `json:"unit-name"`
AgentConf []byte `json:"agent-conf"`
}
// CAASUnitIntroductionResult is returned from CAASApplication facade.
type CAASUnitIntroductionResult struct {
Result *CAASUnitIntroduction `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
}
// CAASApplicationProvisioningInfoResults holds OperatorProvisioningInfo results.
type CAASApplicationProvisioningInfoResults struct {
Results []CAASApplicationProvisioningInfo `json:"results"`
}
// CAASUnitTerminationResult holds result to UnitTerminating call.
type CAASUnitTerminationResult struct {
// WillRestart is true if the termination of the unit is temporary.
WillRestart bool
Error *Error
}
// CAASApplicationProvisioningInfo holds info needed to provision a caas application.
type CAASApplicationProvisioningInfo struct {
ImagePath string `json:"image-path"`
Version version.Number `json:"version"`
APIAddresses []string `json:"api-addresses"`
CACert string `json:"ca-cert"`
Constraints constraints.Value `json:"constraints"`
Tags map[string]string `json:"tags,omitempty"`
Filesystems []KubernetesFilesystemParams `json:"filesystems,omitempty"`
Volumes []KubernetesVolumeParams `json:"volumes,omitempty"`
Devices []KubernetesDeviceParams `json:"devices,omitempty"`
Series string `json:"series,omitempty"`
ImageRepo DockerImageInfo `json:"image-repo,omitempty"`
CharmModifiedVersion int `json:"charm-modified-version,omitempty"`
CharmURL string `json:"charm-url,omitempty"`
Trust bool `json:"trust,omitempty"`
Scale int `json:"scale,omitempty"`
Error *Error `json:"error,omitempty"`
}
// CAASApplicationGarbageCollectArg holds info needed to cleanup units that have
// gone away permanently.
type CAASApplicationGarbageCollectArg struct {
Application Entity `json:"application"`
ObservedUnits Entities `json:"observed-units"`
DesiredReplicas int `json:"desired-replicas"`
ActivePodNames []string `json:"active-pod-names"`
Force bool `json:"force"`
}
// CAASApplicationGarbageCollectArgs holds info needed to cleanup units that have
// gone away permanently.
type CAASApplicationGarbageCollectArgs struct {
Args []CAASApplicationGarbageCollectArg `json:"args"`
}
// DockerImageInfo holds the details for a Docker resource type.
type DockerImageInfo struct {
// RegistryPath holds the path of the Docker image (including host and sha256) in a docker registry.
RegistryPath string `json:"image-name"`
// Username holds the username used to gain access to a non-public image.
Username string `json:"username,omitempty"`
// Password holds the password used to gain access to a non-public image.
Password string `json:"password,omitempty"`
// Auth is the base64 encoded "username:password" string.
Auth string `json:"auth,omitempty" yaml:"auth,omitempty"`
// IdentityToken is used to authenticate the user and get
// an access token for the registry.
IdentityToken string `json:"identitytoken,omitempty" yaml:"identitytoken,omitempty"`
// RegistryToken is a bearer token to be sent to a registry
RegistryToken string `json:"registrytoken,omitempty" yaml:"registrytoken,omitempty"`
Email string `json:"email,omitempty" yaml:"email,omitempty"`
// ServerAddress is the auth server address.
ServerAddress string `json:"serveraddress,omitempty" yaml:"serveraddress,omitempty"`
// Repository is the namespace of the image repo.
Repository string `json:"repository,omitempty" yaml:"repository,omitempty"`
}
// CAASApplicationOCIResourceResults holds all the image results for queried applications.
type CAASApplicationOCIResourceResults struct {
Results []CAASApplicationOCIResourceResult `json:"results"`
}
// CAASApplicationOCIResourceResult holds the image result or error for the queried application.
type CAASApplicationOCIResourceResult struct {
Result *CAASApplicationOCIResources `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
}
// CAASApplicationOCIResources holds a list of image OCI resources.
type CAASApplicationOCIResources struct {
Images map[string]DockerImageInfo `json:"images"`
}
// CAASUnitInfo holds CAAS unit information.
type CAASUnitInfo struct {
Tag string `json:"tag"`
UnitStatus *UnitStatus `json:"unit-status,omitempty"`
}
// CAASUnit holds CAAS unit information.
type CAASUnit struct {
Tag names.Tag
UnitStatus *UnitStatus
}
// CAASUnitsResult holds a slice of CAAS unit information or an error.
type CAASUnitsResult struct {
Units []CAASUnitInfo `json:"units,omitempty"`
Error *Error `json:"error,omitempty"`
}
// CAASUnitsResults contains multiple CAAS units result.
type CAASUnitsResults struct {
Results []CAASUnitsResult `json:"results"`
}