models

package
v0.0.0-...-6fddae5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2017 License: Apache-2.0 Imports: 34 Imported by: 3

Documentation

Index

Constants

View Source
const (
	OFFICIAL_DOCKER_REPOSITORY_URL = "registry.hub.docker.com"
	OFFICIAL_DOCKER_AUTH_URL       = "auth.docker.io/token"
	OFFICIAL_DOCKER_AUTH_SERVICE   = "registry.docker.io"
	OFFICIAL_DOCKER_AUTH_SCOPE     = "repository:%v:pull"
)
View Source
const (
	APP_LOG_TMPL    = `` /* 942-byte string literal not displayed */
	DEPLOY_LOG_TMPL = `` /* 647-byte string literal not displayed */
)
View Source
const (
	CITE_BUILDBOT_GITHUB_CONTEXT = "buildbot/cite-build"
	CITE_K8S_ANNOTATION_KEY      = "cite.io/created-by"
)
View Source
const (
	SendGroupTalk    = "/send/group/kakaotalk"
	SendPersonalTalk = "/send/personal/kakaotalk"
	ListGroups       = "/user/%s/groups"
)
View Source
const (
	LOG_FORMAT = `%{color}%{level:.4s} %{shortfile}%{color:reset} | %{message}`
)

Variables

This section is empty.

Functions

func NewFluentLogger

func NewFluentLogger(tag string, args map[string]interface{}) *gologging.Logger

Types

type BuildBot

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

func NewBuildBot

func NewBuildBot() *BuildBot

func (*BuildBot) Build

func (b *BuildBot) Build(owner, repo, branch, sha string) error

func (*BuildBot) GetImageName

func (b *BuildBot) GetImageName(description string) (string, error)

func (*BuildBot) GetLogContent

func (this *BuildBot) GetLogContent(url string) (string, error)

func (*BuildBot) GetLogURL

func (b *BuildBot) GetLogURL(description string) (string, error)

func (*BuildBot) Proxy

func (b *BuildBot) Proxy(method string, header http.Header, body []byte) error

type BuildbotChangeHook

type BuildbotChangeHook struct {
	Project    string    `json:"project"`
	Revision   string    `json:"revision"`
	Branch     string    `json:"branch"`
	RevLink    string    `json:"revlink"`
	Repository string    `json:"repository"`
	CreatedAt  time.Time `json:"when_timestamp"`
	Author     string    `json:"author"`
	Comments   string    `json:"comments"`
}

type ByOrg

type ByOrg []github.Organization

func (ByOrg) Len

func (s ByOrg) Len() int

func (ByOrg) Less

func (s ByOrg) Less(i, j int) bool

func (ByOrg) Swap

func (s ByOrg) Swap(i, j int)

type ByRepos

type ByRepos []github.Repository

func (ByRepos) Len

func (s ByRepos) Len() int

func (ByRepos) Less

func (s ByRepos) Less(i, j int) bool

func (ByRepos) Swap

func (s ByRepos) Swap(i, j int)

type Config

type Config struct {
	Cite struct {
		Host                string
		ListenPort          string
		RCRetentionDuration string
		Version             string
	}
	Aggregator struct {
		Host string
	}
	Buildbot struct {
		Host    string
		WebHook string
	}
	ElasticSearch struct {
		Host       string
		KibanaHost string
	}
	LoadBalancer struct {
		Driver string
	}
	GitHub struct {
		AccessToken   string
		API           string
		ClientID      string
		ClientSecret  string
		Host          string
		OAuthAuthURL  string
		OAuthTokenURL string
		Scope         string
		Username      string
		WebhookURI    string
	}
	Grafana struct {
		Host string
	}
	Kubernetes struct {
		Master          string
		MaxPods         int
		MinInitialDelay int
		MaxInitialDelay int
		PollInterval    int
		PollTimeout     int
		DefaultCPU      string
		DefaultMemory   string
		MaxCPU          string
		MaxMemory       string
	}
	Notification struct {
		Watchcenter struct {
			API string
		}
		Slack struct {
			ClientID     string
			ClientSecret string
			RedirectURI  string
		}
		Default struct {
			Slack string
		}
	}
}
var (
	Conf Config
)

type Docker

type Docker struct{}

func NewDocker

func NewDocker() *Docker

func (*Docker) CheckImage

func (this *Docker) CheckImage(imageName string) bool

func (*Docker) DeleteImage

func (this *Docker) DeleteImage(imageName, tag string) error

func (*Docker) GetOfficialRegistryAuthToken

func (this *Docker) GetOfficialRegistryAuthToken(name string) (string, error)

func (*Docker) IsRepositoryV2

func (this *Docker) IsRepositoryV2(repo string) (bool, error)

func (*Docker) ListImageTags

func (this *Docker) ListImageTags(fullname string) ([]string, error)

func (*Docker) ListImageTagsV1

func (this *Docker) ListImageTagsV1(repo, name, token string) ([]string, error)

func (*Docker) ListImageTagsV2

func (this *Docker) ListImageTagsV2(repo, name, token string) ([]string, error)

type DockerRepositoryAuth

type DockerRepositoryAuth struct {
	Token string `json:"token"`
}

type Elastic

type Elastic struct {
	GMT           *time.Location
	AppLogTmpl    *template.Template
	DeployLogTmpl *template.Template
	// contains filtered or unexported fields
}

func NewElastic

func NewElastic() *Elastic

func (*Elastic) GetAppLogURL

func (this *Elastic) GetAppLogURL(nsName, svcName, branchName string) string

func (*Elastic) GetDeployLogURL

func (this *Elastic) GetDeployLogURL(deployID int, fromStr, toStr string) string

func (*Elastic) UpsertKibanaIndexPattern

func (this *Elastic) UpsertKibanaIndexPattern(namespace string) error

type GitHub

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

func NewCommonGitHub

func NewCommonGitHub() *GitHub

func NewGitHub

func NewGitHub(token string) *GitHub

func (*GitHub) AddCollaborator

func (this *GitHub) AddCollaborator(owner, repo, collaborator string) error

func (*GitHub) CheckDockerfile

func (this *GitHub) CheckDockerfile(owner string, repo string) (bool, error)

func (*GitHub) CreateCommitStatus

func (this *GitHub) CreateCommitStatus(owner, repo, ref, statusStr string)

func (*GitHub) CreateDeployment

func (this *GitHub) CreateDeployment(owner, repo, ref, description string) (int, error)

func (*GitHub) CreateDeploymentStatus

func (this *GitHub) CreateDeploymentStatus(owner, repo string, id int, state string)

func (*GitHub) GetBranch

func (this *GitHub) GetBranch(owner, repo, branchName string) (*github.Branch, error)

func (*GitHub) GetCommit

func (this *GitHub) GetCommit(owner, repo, sha string) (*github.RepositoryCommit, error)

func (*GitHub) GetDefaultBranchName

func (this *GitHub) GetDefaultBranchName(owner, repo string) (string, error)

func (*GitHub) GetLoginURL

func (this *GitHub) GetLoginURL() string

func (*GitHub) GetOAuth2Token

func (this *GitHub) GetOAuth2Token(state, code string) (string, error)

func (*GitHub) GetRepo

func (this *GitHub) GetRepo(owner, repo string) (*github.Repository, error)

func (*GitHub) GetSHA

func (this *GitHub) GetSHA(owner, repo, branch string) (string, error)

func (*GitHub) GetUser

func (this *GitHub) GetUser() (*github.User, error)

func (*GitHub) ListBranches

func (this *GitHub) ListBranches(owner, repo string, opt *github.ListOptions) ([]github.Branch, error)

func (*GitHub) ListCommits

func (this *GitHub) ListCommits(owner, repo string, opt *github.CommitsListOptions) ([]github.RepositoryCommit, error)

func (*GitHub) ListDeploymentStatuses

func (this *GitHub) ListDeploymentStatuses(owner, repo string, deployment int) ([]github.DeploymentStatus, error)

func (*GitHub) ListDeployments

func (this *GitHub) ListDeployments(owner, repo string, opt *github.DeploymentsListOptions) ([]github.Deployment, error)

func (*GitHub) ListHooks

func (this *GitHub) ListHooks(owner, repo string) ([]github.Hook, error)

func (*GitHub) ListOrgRepos

func (this *GitHub) ListOrgRepos(org string) ([]github.Repository, error)

func (*GitHub) ListOrgs

func (this *GitHub) ListOrgs() ([]github.Organization, error)

func (*GitHub) ListOwnerRepos

func (this *GitHub) ListOwnerRepos() ([]github.Repository, error)

func (*GitHub) ListStatuses

func (this *GitHub) ListStatuses(owner, repo, ref string) ([]github.RepoStatus, error)

func (*GitHub) UpsertHook

func (this *GitHub) UpsertHook(owner, repo string) error

type Kubernetes

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

func NewKubernetes

func NewKubernetes() *Kubernetes

func (*Kubernetes) DeleteNamespace

func (this *Kubernetes) DeleteNamespace(nsName string) error

func (*Kubernetes) DeletePod

func (this *Kubernetes) DeletePod(nsName, podName string) error

func (*Kubernetes) DeleteReplicationController

func (this *Kubernetes) DeleteReplicationController(nsName, rcName string) error

func (*Kubernetes) DeleteService

func (this *Kubernetes) DeleteService(nsName, svcName string) error

func (*Kubernetes) GetAllNamespaces

func (this *Kubernetes) GetAllNamespaces() ([]api.Namespace, error)

func (*Kubernetes) GetAllPods

func (this *Kubernetes) GetAllPods(nsName string) ([]api.Pod, error)

func (*Kubernetes) GetAllReplicationControllers

func (this *Kubernetes) GetAllReplicationControllers(nsName string) ([]api.ReplicationController, error)

func (*Kubernetes) GetAllServices

func (this *Kubernetes) GetAllServices(namespace string, requirements ...labels.Requirement) ([]api.Service, error)

func (*Kubernetes) GetEndpoints

func (this *Kubernetes) GetEndpoints(nsName string, labelMap map[string]string) ([]api.Endpoints, error)

func (*Kubernetes) GetLabels

func (this *Kubernetes) GetLabels(githubRepo, gitBranch string) map[string]string

func (*Kubernetes) GetNamespace

func (this *Kubernetes) GetNamespace(name string) (*api.Namespace, error)

func (*Kubernetes) GetNamespaces

func (this *Kubernetes) GetNamespaces(labelMap map[string]string) ([]api.Namespace, error)

func (*Kubernetes) GetPodLogs

func (this *Kubernetes) GetPodLogs(nsName, podID string, createdAt time.Time) (string, error)

func (*Kubernetes) GetPods

func (this *Kubernetes) GetPods(nsName string, labelMap map[string]string) ([]api.Pod, error)

func (*Kubernetes) GetReplicationController

func (this *Kubernetes) GetReplicationController(nsName, rcName string) (*api.ReplicationController, error)

func (*Kubernetes) GetReplicationControllers

func (this *Kubernetes) GetReplicationControllers(nsName string, labelMap map[string]string, requirements ...labels.Requirement) ([]api.ReplicationController, error)

func (*Kubernetes) GetService

func (this *Kubernetes) GetService(nsName, svcName string) (*api.Service, *Metadata, error)

func (*Kubernetes) GetServices

func (this *Kubernetes) GetServices(namespace string, labelMap map[string]string) ([]api.Service, error)

func (*Kubernetes) ScaleReplicationController

func (this *Kubernetes) ScaleReplicationController(nsName, rcName string, replicas int) (*api.ReplicationController, error)

func (*Kubernetes) UpdateReplicationController

func (this *Kubernetes) UpdateReplicationController(nsName string, rc *api.ReplicationController) (*api.ReplicationController, error)

func (*Kubernetes) UpdateService

func (this *Kubernetes) UpdateService(nsName string, svc *api.Service) (*api.Service, error)

func (*Kubernetes) UpsertNamespace

func (this *Kubernetes) UpsertNamespace(namespace string) error

func (*Kubernetes) UpsertReplicationController

func (this *Kubernetes) UpsertReplicationController(nsName, rcGenerateName, imageName string, rcLabels, rcSelector map[string]string, environment map[string]string, replicas int, ports []int, probePath string, deployID int, fluentLogger *gologging.Logger) error

func (*Kubernetes) UpsertService

func (this *Kubernetes) UpsertService(nsName, svcName string,
	svcLabels, svcSelector map[string]string,
	annotations string, ports []int) (*api.Service, error)

func (*Kubernetes) WaitForRC

func (this *Kubernetes) WaitForRC(rc *api.ReplicationController) error

type LogChunk

type LogChunk struct {
	Content   string `json:"content"`
	FirstLine int    `json:"firstline"`
	LogID     int    `json:"logid"`
}

type LogChunks

type LogChunks struct {
	Meta      interface{} `json:"meta"`
	LogChunks []LogChunk  `json:"logchunks"`
}

type Metadata

type Metadata struct {
	Namespace      string         `json:"namespace" form:"namespace" form:"namespace"`
	Service        string         `json:"service" form:"service" schema:"service"`
	GithubOrg      string         `json:"github_org" form:"github_org" schema:"github_org"`
	GithubRepo     string         `json:"github_repo" form:"github_repo" schema:"github_repo"`
	GitBranch      string         `json:"git_branch" form:"git_branch" schema:"git_branch"`
	AutoDeploy     bool           `json:"auto_deploy" form:"auto_deploy" schema:"auto_deploy"`
	ContainerPort  int            `json:"container_port" form:"container_port" schema:"container_port"`
	ContainerPorts []int          `json:"container_ports"`
	HTTPPort       string         `json:"http_port" form:"http_port" schema:"http_port"`
	TCPPort        string         `json:"tcp_port" form:"tcp_port" schema:"tcp_port"`
	ProbePath      string         `json:"probe_path" form:"probe_path" schema:"probe_path"`
	Replicas       int            `json:"replicas" form:"replicas" schema:"replicas"`
	Watchcenter    int            `json:"watchcenter" form:"watchcenter" schema:"watchcenter"`
	Environment    string         `json:"environment" form:"environment" schema:"environment"`
	Notification   []Notification `json:"notification" schema:"noti"`
	// contains filtered or unexported fields
}

func UnmarshalMetadata

func UnmarshalMetadata(s string) (*Metadata, error)

func (*Metadata) EnvironmentMap

func (this *Metadata) EnvironmentMap() map[string]string

func (*Metadata) Iter

func (this *Metadata) Iter() map[string]string

not using reflection due to performance problem.

func (*Metadata) Marshal

func (this *Metadata) Marshal() string

type Notification

type Notification struct {
	Driver      string `json:"driver" schema:"driver"`
	Enable      bool   `json:"enable" schema:"enable"`
	Endpoint    string `json:"endpoint" schema:"endpoint"`
	Description string `json:"description" schema:"description"`
}

type Notifier

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

func NewNotifier

func NewNotifier() *Notifier

func (*Notifier) Send

func (n *Notifier) Send(nms []Notification, msg string) error

func (*Notifier) SendSystem

func (n *Notifier) SendSystem(msg string) error

func (*Notifier) SendWithFallback

func (n *Notifier) SendWithFallback(nms []Notification, wc int, msg string) error

type Util

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

func NewUtil

func NewUtil() *Util

func (*Util) Hash

func (this *Util) Hash(in interface{}) (string, error)

func (*Util) Normalize

func (this *Util) Normalize(delim string, args ...string) string

func (*Util) NormalizeByHyphen

func (this *Util) NormalizeByHyphen(delim string, args ...string) string

func (*Util) NormalizeGitBranch

func (this *Util) NormalizeGitBranch(delim string, args ...string) string

func (*Util) TCPPortsToList

func (this *Util) TCPPortsToList(in string) ([]int, error)

type WatchCenter

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

func NewWatchCenter

func NewWatchCenter() *WatchCenter

func (*WatchCenter) ListGroups

func (this *WatchCenter) ListGroups(username, email string) ([]WatchCenterGroup, error)

func (*WatchCenter) SendGroupTalk

func (this *WatchCenter) SendGroupTalk(to int, msg string)

func (*WatchCenter) SendPersonalTalk

func (this *WatchCenter) SendPersonalTalk(to, msg string)

type WatchCenterGroup

type WatchCenterGroup struct {
	Id       int `json:"id"`
	Category struct {
		Type                string `json:"type"`
		UnconditionalInvite bool   `json:"unconditionalInvite"`
	} `json:"category"`
	Name                string `json:"name"`
	Description         string `json:"description"`
	ServiceCode         string `json:"serviceCode"`
	LegacyId            string `json:"legacyId,omitempty"`
	UnconditionalInvite bool   `json:"unconditionalInvite"`
}

type WatchCenterGroupResponse

type WatchCenterGroupResponse struct {
	Code     string             `json:"code"`
	Message  string             `json:"message"`
	Response []WatchCenterGroup `json:response`
}

type WatchCenterResponse

type WatchCenterResponse struct {
	Code     string `json:"code"`
	Message  string `json:"message"`
	Success  bool   `json:"success,omitempty"`
	Response string `json:"response"`
}

Jump to

Keyboard shortcuts

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