aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSandro Santilli <strk@kbt.io>2016-11-07 17:53:22 +0100
committerSandro Santilli <strk@kbt.io>2016-11-07 17:53:22 +0100
commitaadd7dcdc317c5e1665318b537162749514ac212 (patch)
tree5e4772ba6ca97dd7dca62325024ec4359b0636c0
parentb3828e38a5fbb92a92bae11e1e126b87fbad09c8 (diff)
downloadgitea-aadd7dcdc317c5e1665318b537162749514ac212.tar.gz
gitea-aadd7dcdc317c5e1665318b537162749514ac212.zip
And others
-rw-r--r--cmd/serve.go2
-rw-r--r--models/org.go2
-rw-r--r--models/ssh_key.go14
-rw-r--r--models/user.go6
-rw-r--r--models/webhook.go16
-rw-r--r--routers/admin/orgs.go2
-rw-r--r--routers/admin/users.go2
-rw-r--r--routers/api/v1/admin/org.go2
-rw-r--r--routers/api/v1/user/user.go2
-rw-r--r--routers/home.go4
-rw-r--r--routers/org/org.go2
-rw-r--r--routers/repo/webhook.go14
12 files changed, 34 insertions, 34 deletions
diff --git a/cmd/serve.go b/cmd/serve.go
index 4e99ebe5ff..dee7ca16d8 100644
--- a/cmd/serve.go
+++ b/cmd/serve.go
@@ -213,7 +213,7 @@ func runServ(c *cli.Context) error {
keyID = key.ID
// Check deploy key or user key.
- if key.Type == models.KEY_TYPE_DEPLOY {
+ if key.Type == models.KeyTypeDeploy {
if key.Mode < requestedMode {
fail("Key permission denied", "Cannot push with deployment key: %d", key.ID)
}
diff --git a/models/org.go b/models/org.go
index 42470dce70..9583e20927 100644
--- a/models/org.go
+++ b/models/org.go
@@ -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 {
diff --git a/models/ssh_key.go b/models/ssh_key.go
index 08483b83d2..932361c00c 100644
--- a/models/ssh_key.go
+++ b/models/ssh_key.go
@@ -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 {
diff --git a/models/user.go b/models/user.go
index ba41a392cb..3870bdeb5a 100644
--- a/models/user.go
+++ b/models/user.go
@@ -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.
diff --git a/models/webhook.go b/models/webhook.go
index 4b5501715a..25c9326e7c 100644
--- a/models/webhook.go
+++ b/models/webhook.go
@@ -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)
}
diff --git a/routers/admin/orgs.go b/routers/admin/orgs.go
index efda1e5165..4d56797c73 100644
--- a/routers/admin/orgs.go
+++ b/routers/admin/orgs.go
@@ -22,7 +22,7 @@ func Organizations(ctx *context.Context) {
ctx.Data["PageIsAdminOrganizations"] = true
routers.RenderUserSearch(ctx, &routers.UserSearchOptions{
- Type: models.USER_TYPE_ORGANIZATION,
+ Type: models.UserTypeOrganization,
Counter: models.CountOrganizations,
Ranger: models.Organizations,
PageSize: setting.UI.Admin.OrgPagingNum,
diff --git a/routers/admin/users.go b/routers/admin/users.go
index 404d5ec3b1..445fb0021b 100644
--- a/routers/admin/users.go
+++ b/routers/admin/users.go
@@ -30,7 +30,7 @@ func Users(ctx *context.Context) {
ctx.Data["PageIsAdminUsers"] = true
routers.RenderUserSearch(ctx, &routers.UserSearchOptions{
- Type: models.USER_TYPE_INDIVIDUAL,
+ Type: models.UserTypeIndividual,
Counter: models.CountUsers,
Ranger: models.Users,
PageSize: setting.UI.Admin.UserPagingNum,
diff --git a/routers/api/v1/admin/org.go b/routers/api/v1/admin/org.go
index 1deaa34b43..b764f7a813 100644
--- a/routers/api/v1/admin/org.go
+++ b/routers/api/v1/admin/org.go
@@ -27,7 +27,7 @@ func CreateOrg(ctx *context.APIContext, form api.CreateOrgOption) {
Website: form.Website,
Location: form.Location,
IsActive: true,
- Type: models.USER_TYPE_ORGANIZATION,
+ Type: models.UserTypeOrganization,
}
if err := models.CreateOrganization(org, u); err != nil {
if models.IsErrUserAlreadyExist(err) ||
diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go
index e7322d725f..92ad7c81e5 100644
--- a/routers/api/v1/user/user.go
+++ b/routers/api/v1/user/user.go
@@ -16,7 +16,7 @@ import (
func Search(ctx *context.APIContext) {
opts := &models.SearchUserOptions{
Keyword: ctx.Query("q"),
- Type: models.USER_TYPE_INDIVIDUAL,
+ Type: models.UserTypeIndividual,
PageSize: com.StrTo(ctx.Query("limit")).MustInt(),
}
if opts.PageSize == 0 {
diff --git a/routers/home.go b/routers/home.go
index 10e75269b8..2dd223b748 100644
--- a/routers/home.go
+++ b/routers/home.go
@@ -172,7 +172,7 @@ func ExploreUsers(ctx *context.Context) {
ctx.Data["PageIsExploreUsers"] = true
RenderUserSearch(ctx, &UserSearchOptions{
- Type: models.USER_TYPE_INDIVIDUAL,
+ Type: models.UserTypeIndividual,
Counter: models.CountUsers,
Ranger: models.Users,
PageSize: setting.UI.ExplorePagingNum,
@@ -187,7 +187,7 @@ func ExploreOrganizations(ctx *context.Context) {
ctx.Data["PageIsExploreOrganizations"] = true
RenderUserSearch(ctx, &UserSearchOptions{
- Type: models.USER_TYPE_ORGANIZATION,
+ Type: models.UserTypeOrganization,
Counter: models.CountOrganizations,
Ranger: models.Organizations,
PageSize: setting.UI.ExplorePagingNum,
diff --git a/routers/org/org.go b/routers/org/org.go
index 156ccb3ee6..f937ac70d8 100644
--- a/routers/org/org.go
+++ b/routers/org/org.go
@@ -33,7 +33,7 @@ func CreatePost(ctx *context.Context, form auth.CreateOrgForm) {
org := &models.User{
Name: form.OrgName,
IsActive: true,
- Type: models.USER_TYPE_ORGANIZATION,
+ Type: models.UserTypeOrganization,
}
if err := models.CreateOrganization(org, ctx.User); err != nil {
diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go
index 918c34016f..d18008b52e 100644
--- a/routers/repo/webhook.go
+++ b/routers/repo/webhook.go
@@ -134,9 +134,9 @@ func WebHooksNewPost(ctx *context.Context, form auth.NewWebhookForm) {
return
}
- contentType := models.JSON
- if models.HookContentType(form.ContentType) == models.FORM {
- contentType = models.FORM
+ contentType := models.ContentTypeJson
+ if models.HookContentType(form.ContentType) == models.ContentTypeForm {
+ contentType = models.ContentTypeForm
}
w := &models.Webhook{
@@ -192,7 +192,7 @@ func SlackHooksNewPost(ctx *context.Context, form auth.NewSlackHookForm) {
w := &models.Webhook{
RepoID: orCtx.RepoID,
URL: form.PayloadURL,
- ContentType: models.JSON,
+ ContentType: models.ContentTypeJson,
HookEvent: ParseHookEvent(form.WebhookForm),
IsActive: form.Active,
HookTaskType: models.SLACK,
@@ -281,9 +281,9 @@ func WebHooksEditPost(ctx *context.Context, form auth.NewWebhookForm) {
return
}
- contentType := models.JSON
- if models.HookContentType(form.ContentType) == models.FORM {
- contentType = models.FORM
+ contentType := models.ContentTypeJson
+ if models.HookContentType(form.ContentType) == models.ContentTypeForm {
+ contentType = models.ContentTypeForm
}
w.URL = form.PayloadURL