github.com/docker/compose-on-kubernetes@v0.5.0/internal/internalversion/types.go (about) 1 package internalversion 2 3 import ( 4 "github.com/docker/compose-on-kubernetes/api/compose/impersonation" 5 "github.com/docker/compose-on-kubernetes/api/compose/latest" 6 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 7 "k8s.io/apimachinery/pkg/runtime" 8 ) 9 10 // Stack is the internal representation of a compose stack 11 type Stack struct { 12 metav1.TypeMeta 13 metav1.ObjectMeta 14 15 Spec StackSpec `json:"spec,omitempty"` 16 Status *StackStatus `json:"status,omitempty"` 17 } 18 19 // DeepCopyObject clones the stack 20 func (s *Stack) DeepCopyObject() runtime.Object { 21 return s.clone() 22 } 23 24 func (s *Stack) clone() *Stack { 25 if s == nil { 26 return nil 27 } 28 result := new(Stack) 29 result.TypeMeta = s.TypeMeta 30 result.ObjectMeta = s.ObjectMeta 31 result.Spec = *s.Spec.clone() 32 result.Status = s.Status.clone() 33 return result 34 } 35 36 // StackStatus is the current status of a stack 37 type StackStatus struct { 38 Phase StackPhase 39 Message string 40 } 41 42 func (s *StackStatus) clone() *StackStatus { 43 if s == nil { 44 return nil 45 } 46 result := *s 47 return &result 48 } 49 50 // StackSpec is the Spec field of a Stack 51 type StackSpec struct { 52 ComposeFile string `json:"composeFile,omitempty"` 53 Stack *latest.StackSpec `json:"stack,omitempty"` 54 Owner impersonation.Config `json:"owner,omitempty"` 55 } 56 57 func (s *StackSpec) clone() *StackSpec { 58 if s == nil { 59 return nil 60 } 61 result := new(StackSpec) 62 result.ComposeFile = s.ComposeFile 63 // consider that deserialized composefile is never modified after deserialization of the composefile 64 result.Stack = s.Stack.DeepCopy() 65 result.Owner = *s.Owner.Clone() 66 return result 67 } 68 69 // StackPhase is the current status phase. 70 type StackPhase string 71 72 // These are valid conditions of a stack. 73 const ( 74 // StackAvailable means the stack is available. 75 StackAvailable StackPhase = "Available" 76 // StackProgressing means the deployment is progressing. 77 StackProgressing StackPhase = "Progressing" 78 // StackFailure is added in a stack when one of its members fails to be created 79 // or deleted. 80 StackFailure StackPhase = "Failure" 81 // StackReconciliationPending means the stack has not yet been reconciled 82 StackReconciliationPending StackPhase = "ReconciliationPending" 83 ) 84 85 // StackList is a list of stacks 86 type StackList struct { 87 metav1.TypeMeta 88 metav1.ListMeta 89 Items []Stack 90 } 91 92 // DeepCopyObject clones the stack list 93 func (s *StackList) DeepCopyObject() runtime.Object { 94 if s == nil { 95 return nil 96 } 97 result := new(StackList) 98 result.TypeMeta = s.TypeMeta 99 result.ListMeta = s.ListMeta 100 if s.Items == nil { 101 return result 102 } 103 result.Items = make([]Stack, len(s.Items)) 104 for ix, s := range s.Items { 105 result.Items[ix] = *s.clone() 106 } 107 return result 108 } 109 110 // Owner is the user who created the stack 111 type Owner struct { 112 metav1.TypeMeta 113 metav1.ObjectMeta 114 Owner impersonation.Config 115 }