This repository has been archived by the owner on Feb 14, 2022. It is now read-only.
/
types.go
115 lines (101 loc) · 2.73 KB
/
types.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
package internalversion
import (
"github.com/docker/compose-on-kubernetes/api/compose/impersonation"
"github.com/docker/compose-on-kubernetes/api/compose/latest"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
// Stack is the internal representation of a compose stack
type Stack struct {
metav1.TypeMeta
metav1.ObjectMeta
Spec StackSpec `json:"spec,omitempty"`
Status *StackStatus `json:"status,omitempty"`
}
// DeepCopyObject clones the stack
func (s *Stack) DeepCopyObject() runtime.Object {
return s.clone()
}
func (s *Stack) clone() *Stack {
if s == nil {
return nil
}
result := new(Stack)
result.TypeMeta = s.TypeMeta
result.ObjectMeta = s.ObjectMeta
result.Spec = *s.Spec.clone()
result.Status = s.Status.clone()
return result
}
// StackStatus is the current status of a stack
type StackStatus struct {
Phase StackPhase
Message string
}
func (s *StackStatus) clone() *StackStatus {
if s == nil {
return nil
}
result := *s
return &result
}
// StackSpec is the Spec field of a Stack
type StackSpec struct {
ComposeFile string `json:"composeFile,omitempty"`
Stack *latest.StackSpec `json:"stack,omitempty"`
Owner impersonation.Config `json:"owner,omitempty"`
}
func (s *StackSpec) clone() *StackSpec {
if s == nil {
return nil
}
result := new(StackSpec)
result.ComposeFile = s.ComposeFile
// consider that deserialized composefile is never modified after deserialization of the composefile
result.Stack = s.Stack.DeepCopy()
result.Owner = *s.Owner.Clone()
return result
}
// StackPhase is the current status phase.
type StackPhase string
// These are valid conditions of a stack.
const (
// StackAvailable means the stack is available.
StackAvailable StackPhase = "Available"
// StackProgressing means the deployment is progressing.
StackProgressing StackPhase = "Progressing"
// StackFailure is added in a stack when one of its members fails to be created
// or deleted.
StackFailure StackPhase = "Failure"
// StackReconciliationPending means the stack has not yet been reconciled
StackReconciliationPending StackPhase = "ReconciliationPending"
)
// StackList is a list of stacks
type StackList struct {
metav1.TypeMeta
metav1.ListMeta
Items []Stack
}
// DeepCopyObject clones the stack list
func (s *StackList) DeepCopyObject() runtime.Object {
if s == nil {
return nil
}
result := new(StackList)
result.TypeMeta = s.TypeMeta
result.ListMeta = s.ListMeta
if s.Items == nil {
return result
}
result.Items = make([]Stack, len(s.Items))
for ix, s := range s.Items {
result.Items[ix] = *s.clone()
}
return result
}
// Owner is the user who created the stack
type Owner struct {
metav1.TypeMeta
metav1.ObjectMeta
Owner impersonation.Config
}