github.com/shashidharatd/test-infra@v0.0.0-20171006011030-71304e1ca560/prow/kube/types.go (about)

     1  /*
     2  Copyright 2016 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package kube
    18  
    19  import (
    20  	"time"
    21  )
    22  
    23  type ObjectMeta struct {
    24  	Name        string            `json:"name,omitempty"`
    25  	Namespace   string            `json:"namespace,omitempty"`
    26  	Labels      map[string]string `json:"labels,omitempty"`
    27  	Annotations map[string]string `json:"annotations,omitempty"`
    28  
    29  	ResourceVersion string `json:"resourceVersion,omitempty"`
    30  	UID             string `json:"uid,omitempty"`
    31  }
    32  
    33  type Secret struct {
    34  	Metadata ObjectMeta        `json:"metadata,omitempty"`
    35  	Data     map[string]string `json:"data,omitempty"`
    36  }
    37  
    38  type PodTemplateSpec struct {
    39  	Metadata ObjectMeta `json:"metadata,omitempty"`
    40  	Spec     PodSpec    `json:"spec,omitempty"`
    41  }
    42  
    43  type Pod struct {
    44  	Metadata ObjectMeta `json:"metadata,omitempty"`
    45  	Spec     PodSpec    `json:"spec,omitempty"`
    46  	Status   PodStatus  `json:"status,omitempty"`
    47  }
    48  
    49  type PodSpec struct {
    50  	Volumes       []Volume          `json:"volumes,omitempty"`
    51  	Containers    []Container       `json:"containers,omitempty"`
    52  	RestartPolicy string            `json:"restartPolicy,omitempty"`
    53  	NodeSelector  map[string]string `json:"nodeSelector,omitempty"`
    54  }
    55  
    56  type PodPhase string
    57  
    58  const (
    59  	PodPending   PodPhase = "Pending"
    60  	PodRunning   PodPhase = "Running"
    61  	PodSucceeded PodPhase = "Succeeded"
    62  	PodFailed    PodPhase = "Failed"
    63  	PodUnknown   PodPhase = "Unknown"
    64  )
    65  
    66  const (
    67  	Evicted = "Evicted"
    68  )
    69  
    70  type PodStatus struct {
    71  	Phase     PodPhase  `json:"phase,omitempty"`
    72  	Message   string    `json:"message,omitempty"`
    73  	Reason    string    `json:"reason,omitempty"`
    74  	StartTime time.Time `json:"startTime,omitempty"`
    75  }
    76  
    77  type Volume struct {
    78  	Name        string             `json:"name,omitempty"`
    79  	Secret      *SecretSource      `json:"secret,omitempty"`
    80  	DownwardAPI *DownwardAPISource `json:"downwardAPI,omitempty"`
    81  	HostPath    *HostPathSource    `json:"hostPath,omitempty"`
    82  	ConfigMap   *ConfigMapSource   `json:"configMap,omitempty"`
    83  }
    84  
    85  type ConfigMapSource struct {
    86  	Name string `json:"name,omitempty"`
    87  }
    88  
    89  type HostPathSource struct {
    90  	Path string `json:"path,omitempty"`
    91  }
    92  
    93  type SecretSource struct {
    94  	Name        string `json:"secretName,omitempty"`
    95  	DefaultMode int32  `json:"defaultMode,omitempty"`
    96  }
    97  
    98  type DownwardAPISource struct {
    99  	Items []DownwardAPIFile `json:"items,omitempty"`
   100  }
   101  
   102  type DownwardAPIFile struct {
   103  	Path  string              `json:"path"`
   104  	Field ObjectFieldSelector `json:"fieldRef,omitempty"`
   105  }
   106  
   107  type ObjectFieldSelector struct {
   108  	FieldPath string `json:"fieldPath"`
   109  }
   110  
   111  type Container struct {
   112  	Name    string   `json:"name,omitempty"`
   113  	Image   string   `json:"image,omitempty"`
   114  	Command []string `json:"command,omitempty"`
   115  	Args    []string `json:"args,omitempty"`
   116  	WorkDir string   `json:"workingDir,omitempty"`
   117  	Env     []EnvVar `json:"env,omitempty"`
   118  	Ports   []Port   `json:"ports,omitempty"`
   119  
   120  	Resources       Resources        `json:"resources,omitempty"`
   121  	SecurityContext *SecurityContext `json:"securityContext,omitempty"`
   122  	VolumeMounts    []VolumeMount    `json:"volumeMounts,omitempty"`
   123  }
   124  
   125  type Port struct {
   126  	ContainerPort int `json:"containerPort,omitempty"`
   127  	HostPort      int `json:"hostPort,omitempty"`
   128  }
   129  
   130  type EnvVar struct {
   131  	Name      string        `json:"name,omitempty"`
   132  	Value     string        `json:"value,omitempty"`
   133  	ValueFrom *EnvVarSource `json:"valueFrom,omitempty"`
   134  }
   135  
   136  type EnvVarSource struct {
   137  	ConfigMap ConfigMapKeySelector `json:"configMapKeyRef,omitempty"`
   138  }
   139  
   140  type ConfigMapKeySelector struct {
   141  	Name string `json:"name,omitempty"`
   142  	Key  string `json:"key,omitempty"`
   143  }
   144  
   145  type Resources struct {
   146  	Requests *ResourceRequest `json:"requests,omitempty"`
   147  	Limits   *ResourceRequest `json:"limits,omitempty"`
   148  }
   149  
   150  type ResourceRequest struct {
   151  	CPU    string `json:"cpu,omitempty"`
   152  	Memory string `json:"memory,omitempty"`
   153  }
   154  
   155  type SecurityContext struct {
   156  	Privileged bool `json:"privileged,omitempty"`
   157  }
   158  
   159  type VolumeMount struct {
   160  	Name      string `json:"name,omitempty"`
   161  	ReadOnly  bool   `json:"readOnly,omitempty"`
   162  	MountPath string `json:"mountPath,omitempty"`
   163  }
   164  
   165  type ConfigMap struct {
   166  	Metadata ObjectMeta        `json:"metadata,omitempty"`
   167  	Data     map[string]string `json:"data,omitempty"`
   168  }