rainbond: github.com/goodrain/rainbond/builder/sources Index | Files | Directories

package sources

import "github.com/goodrain/rainbond/builder/sources"

Index

Package Files

container.go container_config.go dockerfile.go file.go git.go home.go image.go jsonmessage.go registry.go repo.go sftp.go svn.go trust.go

Variables

var ErrorNoAuth = fmt.Errorf("pull image require docker login")

ErrorNoAuth error no auth

var ErrorNoImage = fmt.Errorf("image not exist")

ErrorNoImage error no image

func AllCmds Uses

func AllCmds() []string

AllCmds List all legal cmds in a dockerfile

func CheckFileExist Uses

func CheckFileExist(path string) bool

CheckFileExist CheckFileExist

func CheckTrustedRepositories Uses

func CheckTrustedRepositories(image, user, pass string) error

CheckTrustedRepositories check Repositories is exist ,if not create it.

func CopyFileWithProgress Uses

func CopyFileWithProgress(src, dst string, logger event.Logger) error

CopyFileWithProgress 复制文件,带进度

func CopyToFile Uses

func CopyToFile(outfile string, r io.Reader) error

CopyToFile writes the content of the reader to the specified file

func CopyWithProgress Uses

func CopyWithProgress(srcFile SrcFile, dstFile DstFile, allSize int64, logger event.Logger) (err error)

CopyWithProgress copy file

func EncodeAuthToBase64 Uses

func EncodeAuthToBase64(authConfig types.AuthConfig) (string, error)

EncodeAuthToBase64 serializes the auth configuration as JSON base64 payload

func EncodePrivateKey Uses

func EncodePrivateKey(private *rsa.PrivateKey) []byte

EncodePrivateKey EncodePrivateKey

func EncodeSSHKey Uses

func EncodeSSHKey(public *rsa.PublicKey) ([]byte, error)

EncodeSSHKey EncodeSSHKey

func GenSaveImageName Uses

func GenSaveImageName(name string) string

GenSaveImageName generates the final name of the image, which is the name of the image in the exported tar package.

func GenerateKey Uses

func GenerateKey(bits int) (*rsa.PrivateKey, *rsa.PublicKey, error)

GenerateKey GenerateKey

func GetCodeSourceDir Uses

func GetCodeSourceDir(RepositoryURL, branch, tenantID string, ServiceID string) string

GetCodeSourceDir get source storage directory it changes as gitrepostory address, branch, and service id change

func GetLastCommit Uses

func GetLastCommit(re *git.Repository) (*object.Commit, error)

GetLastCommit get last commit info get commit by head reference

func GetPrivateFile Uses

func GetPrivateFile(tenantID string) string

GetPrivateFile 获取私钥文件地址

func GetPublicKey Uses

func GetPublicKey(tenantID string) string

GetPublicKey 获取公钥

func GetTagFromNamedRef Uses

func GetTagFromNamedRef(ref reference.Named) string

GetTagFromNamedRef get image tag by name

func GitCheckout Uses

func GitCheckout(sourceDir, branch string) error

GitCheckout checkout the specified branch

func GitClone Uses

func GitClone(csi CodeSourceInfo, sourceDir string, logger event.Logger, timeout int) (*git.Repository, error)

GitClone git clone code

func GitCloneOrPull Uses

func GitCloneOrPull(csi CodeSourceInfo, sourceDir string, logger event.Logger, timeout int) (*git.Repository, error)

GitCloneOrPull if code exist in local,use git pull.

func GitPull Uses

func GitPull(csi CodeSourceInfo, sourceDir string, logger event.Logger, timeout int) (*git.Repository, error)

GitPull git pull code

func Go Uses

func Go(f func() error) chan error

Go is a basic promise implementation: it wraps calls a function in a goroutine, and returns a channel which will later return the function's return value.

func Home Uses

func Home() (string, error)

Home returns the home directory for the executing user.

This uses an OS-specific method for discovering the home directory. An error is returned if a home directory cannot be detected.

func ImageBuild Uses

func ImageBuild(dockerCli *client.Client, contextDir string, options types.ImageBuildOptions, logger event.Logger, timeout int) error

ImageBuild ImageBuild

func ImageExist Uses

func ImageExist(imageName, user, password string) (bool, error)

ImageExist check image exist

func ImageImport Uses

func ImageImport(dockerCli *client.Client, image, source string, logger event.Logger) error

ImageImport save image to tar file source source file name eg. /tmp/xxx.tar

func ImageInspectWithRaw Uses

func ImageInspectWithRaw(dockerCli *client.Client, image string) (*types.ImageInspect, error)

ImageInspectWithRaw get image inspect

func ImageLoad Uses

func ImageLoad(dockerCli *client.Client, tarFile string, logger event.Logger) error

ImageLoad load image from tar file destination destination file name eg. /tmp/xxx.tar

func ImageNameHandle Uses

func ImageNameHandle(imageName string) *model.ImageName

ImageNameHandle 解析imagename

func ImageNameWithNamespaceHandle Uses

func ImageNameWithNamespaceHandle(imageName string) *model.ImageName

ImageNameWithNamespaceHandle if have namespace,will parse namespace

func ImagePull Uses

func ImagePull(dockerCli *client.Client, image string, username, password string, logger event.Logger, timeout int) (*types.ImageInspect, error)

ImagePull 拉取镜像 timeout 分钟为单位

func ImagePush Uses

func ImagePush(dockerCli *client.Client, image, user, pass string, logger event.Logger, timeout int) error

ImagePush 推送镜像 timeout 分钟为单位

func ImageRemove Uses

func ImageRemove(dockerCli *client.Client, image string) error

ImageRemove remove image

func ImageSave Uses

func ImageSave(dockerCli *client.Client, image, destination string, logger event.Logger) error

ImageSave save image to tar file destination destination file name eg. /tmp/xxx.tar

func ImageTag Uses

func ImageTag(dockerCli *client.Client, source, target string, logger event.Logger, timeout int) error

ImageTag 修改镜像tag

func MakeSSHKeyPair Uses

func MakeSSHKeyPair() (string, string, error)

MakeSSHKeyPair make ssh key

func RemoveDir Uses

func RemoveDir(path string) error

RemoveDir RemoveDir

func TrustedImagePush Uses

func TrustedImagePush(dockerCli *client.Client, image, user, pass string, logger event.Logger, timeout int) error

TrustedImagePush push image to trusted registry

type CodeSourceInfo Uses

type CodeSourceInfo struct {
    ServerType    string `json:"server_type"`
    RepositoryURL string `json:"repository_url"`
    Branch        string `json:"branch"`
    User          string `json:"user"`
    Password      string `json:"password"`
    //避免项目之间冲突,代码缓存目录提高到租户
    TenantID  string `json:"tenant_id"`
    ServiceID string `json:"service_id"`
}

CodeSourceInfo 代码源信息

func (CodeSourceInfo) GetCodeSourceDir Uses

func (c CodeSourceInfo) GetCodeSourceDir() string

GetCodeSourceDir get source storage directory

type Command Uses

type Command struct {
    Cmd       string   // lowercased command name (ex: `from`)
    SubCmd    string   // for ONBUILD only this holds the sub-command
    Json      bool     // whether the value is written in json form
    Original  string   // The original source line
    StartLine int      // The original source line number
    Flags     []string // Any flags such as `--from=...` for `COPY`.
    Value     []string // The contents of the command (ex: `ubuntu:xenial`)
}

Command Represents a single line (layer) in a Dockerfile. For example `FROM ubuntu:xenial`

func ParseFile Uses

func ParseFile(filename string) ([]Command, error)

ParseFile Parse a Dockerfile from a filename. An IOError or ParseError may occur.

func ParseReader Uses

func ParseReader(file io.Reader) ([]Command, error)

ParseReader Parse a Dockerfile from a reader. A ParseError may occur.

type Commit Uses

type Commit struct {
    Revision string `xml:"revision,attr"`
    Author   string `xml:"author"`
    Msg      string `xml:"msg"`
    Date     string `xml:"date"`
}

Commit Commit

type ContainerConfig Uses

type ContainerConfig struct {
    // Metadata of the container. This information will uniquely identify the
    // container, and the runtime should leverage this to ensure correct
    // operation. The runtime may also use this information to improve UX, such
    // as by constructing a readable name.
    Metadata *ContainerMetadata `protobuf:"bytes,1,opt,name=metadata" json:"metadata,omitempty"`
    // Image to use.
    Image *ImageSpec `protobuf:"bytes,2,opt,name=image" json:"image,omitempty"`
    // Command to execute (i.e., entrypoint for docker)
    Command []string `protobuf:"bytes,3,rep,name=command" json:"command,omitempty"`
    // Args for the Command (i.e., command for docker)
    Args []string `protobuf:"bytes,4,rep,name=args" json:"args,omitempty"`
    // Current working directory of the command.
    WorkingDir string `protobuf:"bytes,5,opt,name=working_dir,json=workingDir,proto3" json:"working_dir,omitempty"`
    // List of environment variable to set in the container.
    Envs []*KeyValue `protobuf:"bytes,6,rep,name=envs" json:"envs,omitempty"`
    // Mounts for the container.
    Mounts []*Mount `protobuf:"bytes,7,rep,name=mounts" json:"mounts,omitempty"`
    // Devices for the container.
    Devices []*Device `protobuf:"bytes,8,rep,name=devices" json:"devices,omitempty"`
    // Key-value pairs that may be used to scope and select individual resources.
    // Label keys are of the form:
    //     label-key ::= prefixed-name | name
    //     prefixed-name ::= prefix '/' name
    //     prefix ::= DNS_SUBDOMAIN
    //     name ::= DNS_LABEL
    Labels map[string]string `protobuf:"bytes,9,rep,name=labels" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
    // Unstructured key-value map that may be used by the kubelet to store and
    // retrieve arbitrary metadata.
    //
    // Annotations MUST NOT be altered by the runtime; the annotations stored
    // here MUST be returned in the ContainerStatus associated with the container
    // this ContainerConfig creates.
    //
    // In general, in order to preserve a well-defined interface between the
    // kubelet and the container runtime, annotations SHOULD NOT influence
    // runtime behaviour.
    Annotations map[string]string `protobuf:"bytes,10,rep,name=annotations" json:"annotations,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
    // Path relative to PodSandboxConfig.LogDirectory for container to store
    // the log (STDOUT and STDERR) on the host.
    // E.g.,
    //     PodSandboxConfig.LogDirectory = `/var/log/pods/<podUID>/`
    //     ContainerConfig.LogPath = `containerName_Instance#.log`
    //
    // WARNING: Log management and how kubelet should interface with the
    // container logs are under active discussion in
    // https://issues.k8s.io/24677. There *may* be future change of direction
    // for logging as the discussion carries on.
    LogPath string `protobuf:"bytes,11,opt,name=log_path,json=logPath,proto3" json:"log_path,omitempty"`
    // Variables for interactive containers, these have very specialized
    // use-cases (e.g. debugging).
    // TODO: Determine if we need to continue supporting these fields that are
    // part of Kubernetes's Container Spec.
    Stdin     bool `protobuf:"varint,12,opt,name=stdin,proto3" json:"stdin,omitempty"`
    StdinOnce bool `protobuf:"varint,13,opt,name=stdin_once,json=stdinOnce,proto3" json:"stdin_once,omitempty"`
    Tty       bool `protobuf:"varint,14,opt,name=tty,proto3" json:"tty,omitempty"`
    // Configuration specific to Linux containers.
    //Linux *LinuxContainerConfig `protobuf:"bytes,15,opt,name=linux" json:"linux,omitempty"`
    AttachStdin   bool
    AttachStdout  bool
    AttachStderr  bool
    NetworkConfig *NetworkConfig
}

ContainerConfig holds all the required and optional fields for creating a container.

func (*ContainerConfig) GetAnnotations Uses

func (m *ContainerConfig) GetAnnotations() map[string]string

GetAnnotations GetAnnotations

func (*ContainerConfig) GetDevices Uses

func (m *ContainerConfig) GetDevices() []*Device

GetDevices GetDevices

func (*ContainerConfig) GetEnvs Uses

func (m *ContainerConfig) GetEnvs() []*KeyValue

GetEnvs GetEnvs

func (*ContainerConfig) GetImage Uses

func (m *ContainerConfig) GetImage() *ImageSpec

GetImage GetImage

func (*ContainerConfig) GetLabels Uses

func (m *ContainerConfig) GetLabels() map[string]string

GetLabels GetLabels

func (*ContainerConfig) GetMetadata Uses

func (m *ContainerConfig) GetMetadata() *ContainerMetadata

GetMetadata GetMetadata

func (*ContainerConfig) GetMounts Uses

func (m *ContainerConfig) GetMounts() []*Mount

GetMounts GetMounts

type ContainerMetadata Uses

type ContainerMetadata struct {
    // Name of the container. Same as the container name in the PodSpec.
    Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
    // Attempt number of creating the container. Default: 0.
    Attempt uint32 `protobuf:"varint,2,opt,name=attempt,proto3" json:"attempt,omitempty"`
}

ContainerMetadata holds all necessary information for building the container name. The container runtime is encouraged to expose the metadata in its user interface for better user experience. E.g., runtime can construct a unique container name based on the metadata. Note that (name, attempt) is unique within a sandbox for the entire lifetime of the sandbox.

type Device Uses

type Device struct {
    // Path of the device within the container.
    ContainerPath string `protobuf:"bytes,1,opt,name=container_path,json=containerPath,proto3" json:"container_path,omitempty"`
    // Path of the device on the host.
    HostPath string `protobuf:"bytes,2,opt,name=host_path,json=hostPath,proto3" json:"host_path,omitempty"`
    // Cgroups permissions of the device, candidates are one or more of
    // * r - allows container to read from the specified device.
    // * w - allows container to write to the specified device.
    // * m - allows container to create device files that do not yet exist.
    Permissions string `protobuf:"bytes,3,opt,name=permissions,proto3" json:"permissions,omitempty"`
}

Device specifies a host device to mount into a container.

type DockerService Uses

type DockerService struct {
    // contains filtered or unexported fields
}

DockerService docker cli service

func CreateDockerService Uses

func CreateDockerService(ctx context.Context, client *client.Client) *DockerService

CreateDockerService create docker service

func (*DockerService) AttachContainer Uses

func (ds *DockerService) AttachContainer(containerID string, attacheStdin, attaStdout, attaStderr bool, inputStream io.ReadCloser, outputStream, errorStream io.Writer, errCh *chan error) (func(), error)

AttachContainer attach container

func (*DockerService) CreateContainer Uses

func (ds *DockerService) CreateContainer(config *ContainerConfig) (string, error)

CreateContainer creates a new container in the given PodSandbox Docker cannot store the log to an arbitrary location (yet), so we create an symlink at LogPath, linking to the actual path of the log. TODO: check if the default values returned by the runtime API are ok.

func (*DockerService) GetContainerLogPath Uses

func (ds *DockerService) GetContainerLogPath(containerID string) (string, error)

GetContainerLogPath returns the real path where docker stores the container log.

func (*DockerService) RemoveContainer Uses

func (ds *DockerService) RemoveContainer(containerID string) error

RemoveContainer removes the container. TODO: If a container is still running, should we forcibly remove it?

func (*DockerService) StartContainer Uses

func (ds *DockerService) StartContainer(containerID string) error

StartContainer starts the container.

func (*DockerService) StopContainer Uses

func (ds *DockerService) StopContainer(containerID string, timeout int64) error

StopContainer stops a running container with a grace period (i.e., timeout).

func (*DockerService) WaitExitOrRemoved Uses

func (ds *DockerService) WaitExitOrRemoved(containerID string, waitRemove bool) chan int

WaitExitOrRemoved wait container exist or remove

type DstFile Uses

type DstFile interface {
    Write([]byte) (int, error)
}

DstFile 目标文件

type IOError Uses

type IOError struct {
    Msg string
}

IOError A failure in opening a file for reading.

func (IOError) Error Uses

func (e IOError) Error() string

type ImageSpec Uses

type ImageSpec struct {
    Image string `protobuf:"bytes,1,opt,name=image,proto3" json:"image,omitempty"`
}

ImageSpec is an internal representation of an image. Currently, it wraps the value of a Container's Image field (e.g. imageID or imageDigest), but in the future it will include more detailed information about the different image types.

type Info Uses

type Info struct {
    XMLName       xml.Name `xml:"info"`
    URL           string   `xml:"entry>url"`
    RelativeURL   string   `xml:"entry>relative-url"`
    Root          string   `xml:"entry>repository>root"`
    UUID          string   `xml:"entry>repository>uuid"`
    WcrootAbspath string   `xml:"entry>wc-info>wcroot-abspath"`
    Schedule      string   `xml:"entry>wc-info>schedule"`
    Depth         string   `xml:"entry>wc-info>depth"`
    Logs          *Logs
    Branchs       []string
    Tags          []string
}

Info Info

type JSONError Uses

type JSONError struct {
    Code    int    `json:"code,omitempty"`
    Message string `json:"message,omitempty"`
}

JSONError wraps a concrete Code and Message, `Code` is is an integer error code, `Message` is the error message.

func (*JSONError) Error Uses

func (e *JSONError) Error() string

type JSONMessage Uses

type JSONMessage struct {
    Stream          string        `json:"stream,omitempty"`
    Status          string        `json:"status,omitempty"`
    Progress        *JSONProgress `json:"progressDetail,omitempty"`
    ProgressMessage string        `json:"progress,omitempty"` //deprecated
    ID              string        `json:"id,omitempty"`
    From            string        `json:"from,omitempty"`
    Time            int64         `json:"time,omitempty"`
    TimeNano        int64         `json:"timeNano,omitempty"`
    Error           *JSONError    `json:"errorDetail,omitempty"`
    ErrorMessage    string        `json:"error,omitempty"` //deprecated
    // Aux contains out-of-band data, such as digests for push signing.
    Aux *json.RawMessage `json:"aux,omitempty"`
}

JSONMessage JSONMessage

func (*JSONMessage) JSONString Uses

func (j *JSONMessage) JSONString() string

JSONString return json string

type JSONProgress Uses

type JSONProgress struct {
    Current int64 `json:"current,omitempty"`
    Total   int64 `json:"total,omitempty"`
    Start   int64 `json:"start,omitempty"`
    // If true, don't show xB/yB
    HideCounts bool `json:"hidecounts,omitempty"`
    // contains filtered or unexported fields
}

JSONProgress describes a Progress. terminalFd is the fd of the current terminal, Start is the initial value for the operation. Current is the current status and value of the progress made towards Total. Total is the end value describing when we made 100% progress for an operation.

type KeyValue Uses

type KeyValue struct {
    Key   string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
    Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
}

KeyValue KeyValue

type Logs Uses

type Logs struct {
    XMLName      xml.Name `xml:"log"`
    CommitEntrys []Commit `xml:"logentry"`
}

Logs commit logs

type Mount Uses

type Mount struct {
    // Path of the mount within the container.
    ContainerPath string `protobuf:"bytes,1,opt,name=container_path,json=containerPath,proto3" json:"container_path,omitempty"`
    // Path of the mount on the host.
    HostPath string `protobuf:"bytes,2,opt,name=host_path,json=hostPath,proto3" json:"host_path,omitempty"`
    // If set, the mount is read-only.
    Readonly bool `protobuf:"varint,3,opt,name=readonly,proto3" json:"readonly,omitempty"`
    // If set, the mount needs SELinux relabeling.
    SelinuxRelabel bool `protobuf:"varint,4,opt,name=selinux_relabel,json=selinuxRelabel,proto3" json:"selinux_relabel,omitempty"`
}

Mount specifies a host volume to mount into a container.

type NetworkConfig Uses

type NetworkConfig struct {
    NetworkMode string `json:"network_mode"`
}

NetworkConfig network config for container

type ParseError Uses

type ParseError struct {
    Msg string
}

ParseError A failure in parsing the file as a dockerfile.

func (ParseError) Error Uses

func (e ParseError) Error() string

type Repostory Uses

type Repostory struct {
    ID               int    `json:"id,omitempty"`
    Namespace        string `json:"namespace,omitempty"`
    NamespaceType    string `json:"namespaceType,omitempty"`
    Name             string `json:"name"`
    ShortDescription string `json:"shortDescription"`
    LongDescription  string `json:"longDescription"`
    Visibility       string `json:"visibility"`
    Status           string `json:"status,omitempty"`
}

Repostory repostory info

type RepostoryBuildInfo Uses

type RepostoryBuildInfo struct {
    RepostoryURL     string
    RepostoryURLType string
    BuildBranch      string
    BuildPath        string
    CodeHome         string
    // contains filtered or unexported fields
}

RepostoryBuildInfo 源码编译信息

func CreateRepostoryBuildInfo Uses

func CreateRepostoryBuildInfo(repoURL, repoType, branch, tenantID string, ServiceID string) (*RepostoryBuildInfo, error)

CreateRepostoryBuildInfo 创建源码编译信息 repoType git or svn

func (*RepostoryBuildInfo) GetCodeBuildAbsPath Uses

func (r *RepostoryBuildInfo) GetCodeBuildAbsPath() string

GetCodeBuildAbsPath 获取代码编译绝对目录

func (*RepostoryBuildInfo) GetCodeBuildPath Uses

func (r *RepostoryBuildInfo) GetCodeBuildPath() string

GetCodeBuildPath 获取代码编译相对目录

func (*RepostoryBuildInfo) GetCodeHome Uses

func (r *RepostoryBuildInfo) GetCodeHome() string

GetCodeHome 获取代码目录

func (*RepostoryBuildInfo) GetProtocol Uses

func (r *RepostoryBuildInfo) GetProtocol() string

GetProtocol 获取协议

type SFTPClient Uses

type SFTPClient struct {
    UserName string `json:"username"`
    PassWord string `json:"password"`
    Host     string `json:"host"`
    Port     int    `json:"int"`
    // contains filtered or unexported fields
}

SFTPClient sFTP客户端

func NewSFTPClient Uses

func NewSFTPClient(username, password, host, port string) (*SFTPClient, error)

NewSFTPClient NewSFTPClient

func (*SFTPClient) Close Uses

func (s *SFTPClient) Close()

Close 关闭啊

func (*SFTPClient) DownloadFile Uses

func (s *SFTPClient) DownloadFile(src, dst string, logger event.Logger) error

DownloadFile DownloadFile

func (*SFTPClient) FileExist Uses

func (s *SFTPClient) FileExist(filepath string) (bool, error)

FileExist 文件是否存在

func (*SFTPClient) MkdirAll Uses

func (s *SFTPClient) MkdirAll(dirpath string) error

MkdirAll 创建目录,递归

func (*SFTPClient) PushFile Uses

func (s *SFTPClient) PushFile(src, dst string, logger event.Logger) error

PushFile PushFile

type SVNClient Uses

type SVNClient interface {
    Checkout() (*Info, error)
    Update(childpath string) (*Info, error)
    UpdateOrCheckout(childpath string) (*Info, error)
}

SVNClient svn svnclient

func NewClient Uses

func NewClient(csi CodeSourceInfo, codeHome string, logger event.Logger) SVNClient

NewClient new svn svnclient

func NewClientWithEnv Uses

func NewClientWithEnv(username, password, url, sourceDir string, env []string) SVNClient

NewClientWithEnv ...

type SrcFile Uses

type SrcFile interface {
    Read([]byte) (int, error)
}

SrcFile 源文件

Directories

PathSynopsis
registry

Package sources imports 59 packages (graph) and is imported by 8 packages. Updated 2019-10-31. Refresh now. Tools for package owners.