And others

This commit is contained in:
Sandro Santilli 2016-11-07 17:53:22 +01:00
parent b3828e38a5
commit aadd7dcdc3
12 changed files with 34 additions and 34 deletions

View file

@ -170,7 +170,7 @@ func GetOrgByName(name string) (*User, error) {
}
u := &User{
LowerName: strings.ToLower(name),
Type: USER_TYPE_ORGANIZATION,
Type: UserTypeOrganization,
}
has, err := x.Get(u)
if err != nil {

View file

@ -29,7 +29,7 @@ import (
)
const (
_TPL_PUBLICK_KEY = `command="%s serv key-%d --config='%s'",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n"
tplPublicKey = `command="%s serv key-%d --config='%s'",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n"
)
var sshOpLocker sync.Mutex
@ -37,8 +37,8 @@ var sshOpLocker sync.Mutex
type KeyType int
const (
KEY_TYPE_USER = iota + 1
KEY_TYPE_DEPLOY
KeyTypeUser = iota + 1
KeyTypeDeploy
)
// PublicKey represents a user or deploy SSH public key.
@ -85,7 +85,7 @@ func (k *PublicKey) OmitEmail() string {
// AuthorizedString returns formatted public key string for authorized_keys file.
func (key *PublicKey) AuthorizedString() string {
return fmt.Sprintf(_TPL_PUBLICK_KEY, setting.AppPath, key.ID, setting.CustomConf, key.Content)
return fmt.Sprintf(tplPublicKey, setting.AppPath, key.ID, setting.CustomConf, key.Content)
}
func extractTypeFromBase64Key(key string) (string, error) {
@ -352,7 +352,7 @@ func appendAuthorizedKeysToFile(keys ...*PublicKey) error {
func checkKeyContent(content string) error {
has, err := x.Get(&PublicKey{
Content: content,
Type: KEY_TYPE_USER,
Type: KeyTypeUser,
})
if err != nil {
return err
@ -416,7 +416,7 @@ func AddPublicKey(ownerID int64, name, content string) (*PublicKey, error) {
Name: name,
Content: content,
Mode: AccessModeWrite,
Type: KEY_TYPE_USER,
Type: KeyTypeUser,
}
if err = addKey(sess, key); err != nil {
return nil, fmt.Errorf("addKey: %v", err)
@ -643,7 +643,7 @@ func AddDeployKey(repoID int64, name, content string) (*DeployKey, error) {
pkey := &PublicKey{
Content: content,
Mode: AccessModeRead,
Type: KEY_TYPE_DEPLOY,
Type: KeyTypeDeploy,
}
has, err := x.Get(pkey)
if err != nil {

View file

@ -37,8 +37,8 @@ import (
type UserType int
const (
USER_TYPE_INDIVIDUAL UserType = iota // Historic reason to make it starts at 0.
USER_TYPE_ORGANIZATION
UserTypeIndividual UserType = iota // Historic reason to make it starts at 0.
UserTypeOrganization
)
var (
@ -393,7 +393,7 @@ func (u *User) IsWriterOfRepo(repo *Repository) bool {
// IsOrganization returns true if user is actually a organization.
func (u *User) IsOrganization() bool {
return u.Type == USER_TYPE_ORGANIZATION
return u.Type == UserTypeOrganization
}
// IsUserOrgOwner returns true if user is in the owner team of given organization.

View file

@ -28,13 +28,13 @@ var HookQueue = sync.NewUniqueQueue(setting.Webhook.QueueLength)
type HookContentType int
const (
JSON HookContentType = iota + 1
FORM
ContentTypeJson HookContentType = iota + 1
ContentTypeForm
)
var hookContentTypes = map[string]HookContentType{
"json": JSON,
"form": FORM,
"json": ContentTypeJson,
"form": ContentTypeForm,
}
// ToHookContentType returns HookContentType by given name.
@ -44,9 +44,9 @@ func ToHookContentType(name string) HookContentType {
func (t HookContentType) Name() string {
switch t {
case JSON:
case ContentTypeJson:
return "json"
case FORM:
case ContentTypeForm:
return "form"
}
return ""
@ -511,9 +511,9 @@ func (t *HookTask) deliver() {
SetTLSClientConfig(&tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify})
switch t.ContentType {
case JSON:
case ContentTypeJson:
req = req.Header("Content-Type", "application/json").Body(t.PayloadContent)
case FORM:
case ContentTypeForm:
req.Param("payload", t.PayloadContent)
}