/
multi_cluster_app.go
89 lines (74 loc) · 3.62 KB
/
multi_cluster_app.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
package v3
import (
"github.com/rancher/norman/condition"
"github.com/rancher/norman/types"
v3 "github.com/hd-Li/types/apis/project.cattle.io/v3"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
var (
MultiClusterAppConditionInstalled condition.Cond = "Installed"
MultiClusterAppConditionDeployed condition.Cond = "Deployed"
)
type MultiClusterApp struct {
types.Namespaced
metav1.TypeMeta `json:",inline"`
// Standard object’s metadata. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the the cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
Spec MultiClusterAppSpec `json:"spec"`
Status MultiClusterAppStatus `json:"status"`
}
type MultiClusterAppSpec struct {
TemplateVersionName string `json:"templateVersionName,omitempty" norman:"type=reference[templateVersion],required"`
Answers []Answer `json:"answers,omitempty"`
Targets []Target `json:"targets,omitempty" norman:"required,noupdate"`
Members []Member `json:"members,omitempty"`
Roles []string `json:"roles,omitempty" norman:"type=array[reference[roleTemplate]],required"`
RevisionHistoryLimit int `json:"revisionHistoryLimit,omitempty" norman:"default=10"`
UpgradeStrategy UpgradeStrategy `json:"upgradeStrategy,omitempty"`
}
type MultiClusterAppStatus struct {
Conditions []v3.AppCondition `json:"conditions,omitempty"`
RevisionName string `json:"revisionName,omitempty" norman:"type=reference[multiClusterAppRevision],required"`
}
type Target struct {
ProjectName string `json:"projectName,omitempty" norman:"type=reference[project],required"`
AppName string `json:"appName,omitempty" norman:"type=reference[v3/projects/schemas/app]"`
State string `json:"state,omitempty"`
Healthstate string `json:"healthState,omitempty"`
}
type Answer struct {
ProjectName string `json:"projectName,omitempty" norman:"type=reference[project]"`
ClusterName string `json:"clusterName,omitempty" norman:"type=reference[cluster]"`
Values map[string]string `json:"values,omitempty" norman:"required"`
}
type Member struct {
UserName string `json:"userName,omitempty" norman:"type=reference[user]"`
UserPrincipalName string `json:"userPrincipalName,omitempty" norman:"type=reference[principal]"`
DisplayName string `json:"displayName,omitempty"`
GroupPrincipalName string `json:"groupPrincipalName,omitempty" norman:"type=reference[principal]"`
AccessType string `json:"accessType,omitempty" norman:"type=enum,options=owner|member|read-only"`
}
type UpgradeStrategy struct {
RollingUpdate *RollingUpdate `json:"rollingUpdate,omitempty"`
}
type RollingUpdate struct {
BatchSize int `json:"batchSize,omitempty"`
Interval int `json:"interval,omitempty"`
}
type MultiClusterAppRevision struct {
types.Namespaced
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
TemplateVersionName string `json:"templateVersionName,omitempty" norman:"type=reference[templateVersion]"`
Answers []Answer `json:"answers,omitempty"`
}
type MultiClusterAppRollbackInput struct {
RevisionName string `json:"revisionName,omitempty" norman:"type=reference[multiClusterAppRevision]"`
}
type UpdateMultiClusterAppTargetsInput struct {
Projects []string `json:"projects" norman:"type=array[reference[project]],required"`
Answers []Answer `json:"answers"`
}