pod

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2016 License: Apache-2.0 Imports: 13 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"`
	Labels map[string]string `json:"labels,omitempty"`
}

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 PodLogConfig

type PodLogConfig struct {
	Type   string            `json:"type"`
	Config map[string]string `json:"config"`
}

type PortmappingWhiteList added in v0.6.2

type PortmappingWhiteList struct {
	InternalNetworks []string `json:"internalNetworks,omitempty"`
	ExternalNetworks []string `json:"externalNetworks,omitempty"`
}

type UserContainer

type UserContainer struct {
	Name          string                `json:"name"`
	Image         string                `json:"image"`
	User          UserUser              `json:"user,omitempty"`
	Command       []string              `json:"command"`
	Workdir       string                `json:"workdir"`
	Entrypoint    []string              `json:"entrypoint"`
	Tty           bool                  `json:"tty,omitempty"`
	Sysctl        map[string]string     `json:"sysctl,omitempty"`
	Labels        map[string]string     `json:"labels"`
	Ports         []UserContainerPort   `json:"ports"`
	Envs          []UserEnvironmentVar  `json:"envs"`
	Volumes       []UserVolumeReference `json:"volumes"`
	Files         []UserFileReference   `json:"files"`
	RestartPolicy string                `json:"restartPolicy"`
}

func ConvertOCF2UserContainer

func ConvertOCF2UserContainer(s *specs.Spec) *UserContainer

type UserContainerPort

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

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 UserInterface

type UserInterface struct {
	Bridge string `json:"bridge"`
	Ip     string `json:"ip"`
	Ifname string `json:"ifname,omitempty"`
	Mac    string `json:"mac,omitempty"`
	Gw     string `json:"gateway,omitempty"`
}

type UserPod

type UserPod struct {
	Name                  string                `json:"id"`
	Hostname              string                `json:"hostname"`
	Containers            []UserContainer       `json:"containers"`
	Resource              UserResource          `json:"resource"`
	Files                 []UserFile            `json:"files"`
	Volumes               []UserVolume          `json:"volumes"`
	Interfaces            []UserInterface       `json:"interfaces,omitempty"`
	Labels                map[string]string     `json:"labels"`
	Services              []UserService         `json:"services,omitempty"`
	LogConfig             PodLogConfig          `json:"log"`
	Dns                   []string              `json:"dns,omitempty"`
	PortmappingWhiteLists *PortmappingWhiteList `json:"portmappingWhiteLists,omitempty"`
	Tty                   bool                  `json:"tty"`
	Type                  string                `json:"type"`
	RestartPolicy         string
}

func ConvertOCF2PureUserPod

func ConvertOCF2PureUserPod(s *specs.Spec) *UserPod

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 + mount point is unique 2. file name is unique 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 UserService

type UserService struct {
	ServiceIP   string               `json:"serviceip"`
	ServicePort int                  `json:"serviceport"`
	Protocol    string               `json:"protocol"`
	Hosts       []UserServiceBackend `json:"hosts"`
}

type UserServiceBackend

type UserServiceBackend struct {
	HostIP   string `json:"hostip"`
	HostPort int    `json:"hostport"`
}

type UserUser

type UserUser struct {
	Name             string   `json:"name"`
	Group            string   `json:"group"`
	AdditionalGroups []string `json:"additionalGroups,omitempty"`
}

Pod Data Structure

type UserVolume

type UserVolume struct {
	Name   string           `json:"name"`
	Source string           `json:"source"`
	Driver string           `json:"driver"`
	Option UserVolumeOption `json:"option,omitempty"`
}

type UserVolumeOption

type UserVolumeOption struct {
	Monitors    []string `json:"monitors"`
	User        string   `json:"user"`
	Keyring     string   `json:"keyring"`
	BytesPerSec int      `json:"bytespersec"`
	Iops        int      `json:"iops"`
}

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