github.com/docker/compose-on-kubernetes@v0.5.0/api/compose/v1beta1/stack.go (about)

     1  package v1beta1
     2  
     3  import (
     4  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     5  	"k8s.io/apimachinery/pkg/runtime"
     6  )
     7  
     8  // StackList defines a list of stacks
     9  type StackList struct {
    10  	metav1.TypeMeta `json:",inline"`
    11  	metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
    12  
    13  	Items []Stack `json:"items" protobuf:"bytes,2,rep,name=items"`
    14  }
    15  
    16  // DeepCopyObject clones the stack list
    17  func (s *StackList) DeepCopyObject() runtime.Object {
    18  	if s == nil {
    19  		return nil
    20  	}
    21  	result := new(StackList)
    22  	result.TypeMeta = s.TypeMeta
    23  	result.ListMeta = s.ListMeta
    24  	if s.Items == nil {
    25  		return result
    26  	}
    27  	result.Items = make([]Stack, len(s.Items))
    28  	for ix, s := range s.Items {
    29  		result.Items[ix] = *s.clone()
    30  	}
    31  	return result
    32  }
    33  
    34  // Stack defines a stack object to be register in the kubernetes API
    35  type Stack struct {
    36  	metav1.TypeMeta   `json:",inline"`
    37  	metav1.ObjectMeta `json:"metadata,omitempty"`
    38  
    39  	Spec   StackSpec   `json:"spec,omitempty"`
    40  	Status StackStatus `json:"status,omitempty"`
    41  }
    42  
    43  // StackSpec defines the desired state of Stack
    44  type StackSpec struct {
    45  	ComposeFile string `json:"composeFile,omitempty"`
    46  }
    47  
    48  // StackPhase defines the status phase in which the stack is.
    49  type StackPhase string
    50  
    51  // These are valid conditions of a stack.
    52  const (
    53  	// StackAvailable means the stack is available.
    54  	StackAvailable StackPhase = "Available"
    55  	// StackProgressing means the deployment is progressing.
    56  	StackProgressing StackPhase = "Progressing"
    57  	// StackFailure is added in a stack when one of its members fails to be created
    58  	// or deleted.
    59  	StackFailure StackPhase = "Failure"
    60  )
    61  
    62  // StackStatus defines the observed state of Stack
    63  type StackStatus struct {
    64  	// Current condition of the stack.
    65  	Phase StackPhase `json:"phase,omitempty" protobuf:"bytes,1,opt,name=phase,casttype=StackPhase"`
    66  	// A human readable message indicating details about the stack.
    67  	Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"`
    68  }
    69  
    70  func (s *Stack) clone() *Stack {
    71  	if s == nil {
    72  		return nil
    73  	}
    74  	// in v1beta1, Stack has no pointer, slice or map. Plain old struct copy is ok
    75  	result := *s
    76  	return &result
    77  }
    78  
    79  // Clone implements the Cloner interface for kubernetes
    80  func (s *Stack) Clone() *Stack {
    81  	return s.clone()
    82  }
    83  
    84  // DeepCopyObject clones the stack
    85  func (s *Stack) DeepCopyObject() runtime.Object {
    86  	return s.clone()
    87  }