common

package
v0.0.0-...-ebf2bd2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrAbort        // 中间件终止
	ErrNoPermission // 无操作权限
)
View Source
const (
	GROWERLAB_REPO_OWNER     = "GROWERLAB_REPO_OWNER"
	GROWERLAB_REPO_NAME      = "GROWERLAB_REPO_NAME"
	GROWERLAB_REPO_ACTION    = "GROWERLAB_REPO_ACTION"
	GROWERLAB_REPO_PROT_TYPE = "GROWERLAB_REPO_PROT_TYPE"
	GROWERLAB_REPO_OPERATOR  = "GROWERLAB_REPO_OPERATOR"
)

git运行时传入的环境变量

Variables

This section is empty.

Functions

func BuildRepoInfoByPath

func BuildRepoInfoByPath(path string) (repoOwner, repoName, repoPath string, err error)

func InitPermission

func InitPermission() error

Types

type Action

type Action string
const (
	ActionTypePull Action = "PULL"
	ActionTypePush Action = "PUSH"
)

func (Action) IsPull

func (a Action) IsPull() bool

type Context

type Context struct {
	// push、pull
	ActionType Action
	// 推送方式(http[s]、ssh、git)
	Type ProtType
	// ssh: 原始commands
	RawCommands []string
	// http: 原始url/commands
	RawURL string
	// http: 解析后的url
	RequestURL *url.URL
	// 仓库地址中的owner字段
	RepoOwner string
	// 仓库地址中的 仓库名
	RepoName string
	// 仓库的具体地址
	RepoDir string
	// 推送人 / 拉取人
	// 	当用户提交、拉取仓库时,应该要知道这个操作者是谁
	// 	如果仓库是公共的,那么可以忽略这个操作者字段
	// 	如果仓库是私有的,那么这个字段必须有值
	//
	Operator *Operator

	// http: 请求
	Resp http.ResponseWriter
	Req  *http.Request
}

相关操作的上下文

func BuildContextFromHTTP

func BuildContextFromHTTP(w http.ResponseWriter, r *http.Request) (*Context, error)

func BuildContextFromSSH

func BuildContextFromSSH(session ssh.Session) (*Context, error)

func (*Context) Desc

func (c *Context) Desc() string

func (*Context) Env

func (c *Context) Env() []string

func (*Context) IsReadAction

func (c *Context) IsReadAction() bool

type Operator

type Operator struct {
	// 当是http[s]协议时,这里可能有user、pwd(密码可能是token)
	HttpUser *url.Userinfo
	// 当是ssh协议时,可能有ssh的公钥字段
	SSHPublicKey ssh.PublicKey
}

操作者

func (*Operator) IsEmptyUser

func (o *Operator) IsEmptyUser() bool

func (*Operator) IsHttp

func (o *Operator) IsHttp() bool

type ProtType

type ProtType string

协议类型

const (
	ProtTypeHTTP ProtType = "http"
	ProtTypeSSH  ProtType = "ssh"
)

Jump to

Keyboard shortcuts

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