pod

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

README

INTRODUCE

This module include the key functions on processing the POD JSON data file

The sample input POD data file is:


{
	"id": "test_|-|_id",
	"containers" : [{
		"name": "web",
		"image": "nginx:latest"
	}],
	"resource": {
		"vcpu": 1,
		"memory": "128"
	},
	"files": [],
	"volumes": []
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InterfaceSlice

func InterfaceSlice(slice interface{}) ([]interface{}, error)

func RandStr

func RandStr(strSize int, randType string) string

Types

type KContainer

type KContainer struct {
	Name       string                 `json:"name"`
	Image      string                 `json:"image"`
	Command    []string               `json:"command"`
	Args       []string               `json:"args"`
	WorkingDir string                 `json:"workingDir"`
	Resources  map[string]interface{} `json:"resources"`
	CPU        int
	Memory     int64
	Volumes    []*KVolumeReference `json:"volumeMounts"`
	Ports      []*KPort            `json:"ports"`
	Env        []*KEnv             `json:"env"`
}

type KEmptyDir

type KEmptyDir struct{}

type KEnv

type KEnv struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type KGCEPersistentDisk

type KGCEPersistentDisk struct{}

type KHostDir

type KHostDir struct {
	Path string `json:"path"`
}

type KMeta

type KMeta struct {
	Name string `json:"name"`
}

type KPod

type KPod struct {
	Kind string `json:"kind"`
	Meta *KMeta `json:"metadata"`
	Spec *KSpec `json:"spec"`
}

func (*KPod) Convert

func (kp *KPod) Convert() (*UserPod, error)

type KPort

type KPort struct {
	Name          string `json:"name"`
	ContainerPort int    `json:"containerPort"`
	HostPort      int    `json:"hostPort"`
	Protocol      string `json:"protocol"`
}

type KSpec

type KSpec struct {
	Containers    []*KContainer `json:"containers"`
	Volumes       []*KVolume    `json:"volumes"`
	RestartPolicy string        `json:"restartPolicy"`
	DNSPolicy     []string
}

type KVolume

type KVolume struct {
	Name   string         `json:"name"`
	Source *KVolumeSource `json:"source"`
}

type KVolumeReference

type KVolumeReference struct {
	Name      string `json:"name"`
	MountPath string `json:"mountPath"`
	ReadOnly  bool   `json:"readOnly"`
}

type KVolumeSource

type KVolumeSource struct {
	EmptyDir          *KEmptyDir `json:"emptyDir"`
	HostDir           *KHostDir  `json:"hostDir"`
	GCEPersistentDisk *KGCEPersistentDisk
}

type UserContainer

type UserContainer struct {
	Name          string                `json:"name"`
	Image         string                `json:"image"`
	Command       []string              `json:"command"`
	Workdir       string                `json:"workdir"`
	Entrypoint    []string              `json:"entrypoint"`
	Ports         []UserContainerPort   `json:"ports"`
	Envs          []UserEnvironmentVar  `json:"envs"`
	Volumes       []UserVolumeReference `json:"volumes"`
	Files         []UserFileReference   `json:"files"`
	RestartPolicy string                `json:"restartPolicy"`
}

type UserContainerPort

type UserContainerPort struct {
	HostPort      int    `json:"hostPort"`
	ContainerPort int    `json:"containerPort"`
	ServicePort   int    `json:"servicePort"`
	Protocol      string `json:"protocol"`
}

Pod Data Structure

type UserEnvironmentVar

type UserEnvironmentVar struct {
	Env   string `json:"env"`
	Value string `json:"value"`
}

type UserFile

type UserFile struct {
	Name     string `json:"name"`
	Encoding string `json:"encoding"`
	Uri      string `json:"uri"`
	Contents string `json:"content"`
}

type UserFileReference

type UserFileReference struct {
	Path     string `json:"path"`
	Filename string `json:"filename"`
	Perm     string `json:"perm"`
	User     string `json:"user"`
	Group    string `json:"group"`
}

type UserPod

type UserPod struct {
	Name       string          `json:"id"`
	Containers []UserContainer `json:"containers"`
	Resource   UserResource    `json:"resource"`
	Files      []UserFile      `json:"files"`
	Volumes    []UserVolume    `json:"volumes"`
	Tty        bool            `json:"tty"`
	Type       string          `json:"type"`
}

func ProcessPodBytes

func ProcessPodBytes(body []byte) (*UserPod, error)

func ProcessPodFile

func ProcessPodFile(jsonFile string) (*UserPod, error)

func (*UserPod) Validate

func (pod *UserPod) Validate() error

validate 1. volume name, file name is unique 2. source mount to only one pos in one container 3. container should not use volume/file not in volume/file list 4. environment var should be uniq in one container

type UserResource

type UserResource struct {
	Vcpu   int `json:"vcpu"`
	Memory int `json:"memory"`
}

type UserVolume

type UserVolume struct {
	Name   string `json:"name"`
	Source string `json:"source"`
	Driver string `json:"driver"`
}

type UserVolumeReference

type UserVolumeReference struct {
	Path     string `json:"path"`
	Volume   string `json:"volume"`
	ReadOnly bool   `json:"readOnly"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL