fix: all enums same style (#262)

* fix: all enums same style

* fix: rename process to reduce

* add some missing enum renaming

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
Fabi
2020-06-23 14:47:47 +02:00
committed by GitHub
parent c376b92315
commit 3cd3a238c2
152 changed files with 1026 additions and 1024 deletions

View File

@@ -30,20 +30,20 @@ type ApplicationChange struct {
type AppState int32
const (
APPSTATE_ACTIVE AppState = iota
APPSTATE_INACTIVE
AppStateActive AppState = iota
AppStateInactive
)
type AppType int32
const (
APPTYPE_UNDEFINED AppType = iota
APPTYPE_OIDC
APPTYPE_SAML
AppTypeUnspecified AppType = iota
AppTypeOIDC
AppTypeSAML
)
func NewApplication(projectID, appID string) *Application {
return &Application{ObjectRoot: es_models.ObjectRoot{AggregateID: projectID}, AppID: appID, State: APPSTATE_ACTIVE}
return &Application{ObjectRoot: es_models.ObjectRoot{AggregateID: projectID}, AppID: appID, State: AppStateActive}
}
func (a *Application) IsValid(includeConfig bool) bool {
@@ -53,7 +53,7 @@ func (a *Application) IsValid(includeConfig bool) bool {
if !includeConfig {
return true
}
if a.Type == APPTYPE_OIDC && !a.OIDCConfig.IsValid() {
if a.Type == AppTypeOIDC && !a.OIDCConfig.IsValid() {
return false
}
return true

View File

@@ -21,10 +21,10 @@ func TestApplicationValid(t *testing.T) {
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
AppID: "AppID",
Name: "Name",
Type: APPTYPE_OIDC,
Type: AppTypeOIDC,
OIDCConfig: &OIDCConfig{
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_CODE},
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_AUTHORIZATION_CODE},
ResponseTypes: []OIDCResponseType{OIDCResponseTypeCode},
GrantTypes: []OIDCGrantType{OIDCGrantTypeAuthorizationCode},
},
},
},
@@ -37,10 +37,10 @@ func TestApplicationValid(t *testing.T) {
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
AppID: "AppID",
Name: "Name",
Type: APPTYPE_OIDC,
Type: AppTypeOIDC,
OIDCConfig: &OIDCConfig{
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_CODE},
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_IMPLICIT},
ResponseTypes: []OIDCResponseType{OIDCResponseTypeCode},
GrantTypes: []OIDCGrantType{OIDCGrantTypeImplicit},
},
},
},
@@ -53,10 +53,10 @@ func TestApplicationValid(t *testing.T) {
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
AppID: "AppID",
Name: "Name",
Type: APPTYPE_OIDC,
Type: AppTypeOIDC,
OIDCConfig: &OIDCConfig{
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_ID_TOKEN},
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_IMPLICIT},
ResponseTypes: []OIDCResponseType{OIDCResponseTypeIDToken},
GrantTypes: []OIDCGrantType{OIDCGrantTypeImplicit},
},
},
},
@@ -69,10 +69,10 @@ func TestApplicationValid(t *testing.T) {
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
AppID: "AppID",
Name: "Name",
Type: APPTYPE_OIDC,
Type: AppTypeOIDC,
OIDCConfig: &OIDCConfig{
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_ID_TOKEN},
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_AUTHORIZATION_CODE},
ResponseTypes: []OIDCResponseType{OIDCResponseTypeIDToken},
GrantTypes: []OIDCGrantType{OIDCGrantTypeAuthorizationCode},
},
},
},
@@ -85,10 +85,10 @@ func TestApplicationValid(t *testing.T) {
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
AppID: "AppID",
Name: "Name",
Type: APPTYPE_OIDC,
Type: AppTypeOIDC,
OIDCConfig: &OIDCConfig{
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_TOKEN},
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_IMPLICIT},
ResponseTypes: []OIDCResponseType{OIDCResponseTypeToken},
GrantTypes: []OIDCGrantType{OIDCGrantTypeImplicit},
},
},
},
@@ -101,10 +101,10 @@ func TestApplicationValid(t *testing.T) {
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
AppID: "AppID",
Name: "Name",
Type: APPTYPE_OIDC,
Type: AppTypeOIDC,
OIDCConfig: &OIDCConfig{
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_TOKEN},
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_AUTHORIZATION_CODE},
ResponseTypes: []OIDCResponseType{OIDCResponseTypeToken},
GrantTypes: []OIDCGrantType{OIDCGrantTypeAuthorizationCode},
},
},
},
@@ -117,10 +117,10 @@ func TestApplicationValid(t *testing.T) {
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
AppID: "AppID",
Name: "Name",
Type: APPTYPE_OIDC,
Type: AppTypeOIDC,
OIDCConfig: &OIDCConfig{
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_CODE, OIDCRESPONSETYPE_ID_TOKEN},
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_AUTHORIZATION_CODE, OIDCGRANTTYPE_IMPLICIT},
ResponseTypes: []OIDCResponseType{OIDCResponseTypeCode, OIDCResponseTypeIDToken},
GrantTypes: []OIDCGrantType{OIDCGrantTypeAuthorizationCode, OIDCGrantTypeImplicit},
},
},
},
@@ -133,10 +133,10 @@ func TestApplicationValid(t *testing.T) {
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
AppID: "AppID",
Name: "Name",
Type: APPTYPE_OIDC,
Type: AppTypeOIDC,
OIDCConfig: &OIDCConfig{
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_CODE, OIDCRESPONSETYPE_TOKEN},
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_AUTHORIZATION_CODE, OIDCGRANTTYPE_IMPLICIT},
ResponseTypes: []OIDCResponseType{OIDCResponseTypeCode, OIDCResponseTypeToken},
GrantTypes: []OIDCGrantType{OIDCGrantTypeAuthorizationCode, OIDCGrantTypeImplicit},
},
},
},
@@ -149,10 +149,10 @@ func TestApplicationValid(t *testing.T) {
ObjectRoot: models.ObjectRoot{AggregateID: "AggregateID"},
AppID: "AppID",
Name: "Name",
Type: APPTYPE_OIDC,
Type: AppTypeOIDC,
OIDCConfig: &OIDCConfig{
ResponseTypes: []OIDCResponseType{OIDCRESPONSETYPE_CODE, OIDCRESPONSETYPE_ID_TOKEN, OIDCRESPONSETYPE_TOKEN},
GrantTypes: []OIDCGrantType{OIDCGRANTTYPE_AUTHORIZATION_CODE, OIDCGRANTTYPE_IMPLICIT},
ResponseTypes: []OIDCResponseType{OIDCResponseTypeCode, OIDCResponseTypeIDToken, OIDCResponseTypeToken},
GrantTypes: []OIDCGrantType{OIDCGrantTypeAuthorizationCode, OIDCGrantTypeImplicit},
},
},
},

View File

@@ -28,23 +28,23 @@ type ApplicationView struct {
type ApplicationSearchRequest struct {
Offset uint64
Limit uint64
SortingColumn ApplicationSearchKey
SortingColumn AppSearchKey
Asc bool
Queries []*ApplicationSearchQuery
}
type ApplicationSearchKey int32
type AppSearchKey int32
const (
APPLICATIONSEARCHKEY_UNSPECIFIED ApplicationSearchKey = iota
APPLICATIONSEARCHKEY_NAME
APPLICATIONSEARCHKEY_OIDC_CLIENT_ID
APPLICATIONSEARCHKEY_PROJECT_ID
APPLICATIONSEARCHKEY_APP_ID
AppSearchKeyUnspecified AppSearchKey = iota
AppSearchKeyName
AppSearchKeyOIDCClientID
AppSearchKeyProjectID
AppSearchKeyAppID
)
type ApplicationSearchQuery struct {
Key ApplicationSearchKey
Key AppSearchKey
Method model.SearchMethod
Value interface{}
}

View File

@@ -22,33 +22,33 @@ type OIDCConfig struct {
type OIDCResponseType int32
const (
OIDCRESPONSETYPE_CODE OIDCResponseType = iota
OIDCRESPONSETYPE_ID_TOKEN
OIDCRESPONSETYPE_TOKEN
OIDCResponseTypeCode OIDCResponseType = iota
OIDCResponseTypeIDToken
OIDCResponseTypeToken
)
type OIDCGrantType int32
const (
OIDCGRANTTYPE_AUTHORIZATION_CODE OIDCGrantType = iota
OIDCGRANTTYPE_IMPLICIT
OIDCGRANTTYPE_REFRESH_TOKEN
OIDCGrantTypeAuthorizationCode OIDCGrantType = iota
OIDCGrantTypeImplicit
OIDCGrantTypeRefreshToken
)
type OIDCApplicationType int32
const (
OIDCAPPLICATIONTYPE_WEB OIDCApplicationType = iota
OIDCAPPLICATIONTYPE_USER_AGENT
OIDCAPPLICATIONTYPE_NATIVE
OIDCApplicationTypeWeb OIDCApplicationType = iota
OIDCApplicationTypeUserAgent
OIDCApplicationTypeNative
)
type OIDCAuthMethodType int32
const (
OIDCAUTHMETHODTYPE_BASIC OIDCAuthMethodType = iota
OIDCAUTHMETHODTYPE_POST
OIDCAUTHMETHODTYPE_NONE
OIDCAuthMethodTypeBasic OIDCAuthMethodType = iota
OIDCAuthMethodTypePost
OIDCAuthMethodTypeNone
)
func (c *OIDCConfig) IsValid() bool {
@@ -67,11 +67,11 @@ func (c *OIDCConfig) getRequiredGrantTypes() []OIDCGrantType {
implicit := false
for _, r := range c.ResponseTypes {
switch r {
case OIDCRESPONSETYPE_CODE:
grantTypes = append(grantTypes, OIDCGRANTTYPE_AUTHORIZATION_CODE)
case OIDCRESPONSETYPE_ID_TOKEN, OIDCRESPONSETYPE_TOKEN:
case OIDCResponseTypeCode:
grantTypes = append(grantTypes, OIDCGrantTypeAuthorizationCode)
case OIDCResponseTypeIDToken, OIDCResponseTypeToken:
if !implicit {
grantTypes = append(grantTypes, OIDCGRANTTYPE_IMPLICIT)
grantTypes = append(grantTypes, OIDCGrantTypeImplicit)
}
}
}

View File

@@ -31,17 +31,17 @@ type ProjectChange struct {
type ProjectState int32
const (
PROJECTSTATE_ACTIVE ProjectState = iota
PROJECTSTATE_INACTIVE
PROJECTSTATE_REMOVED
ProjectStateActive ProjectState = iota
ProjectStateInactive
ProjectStateRemoved
)
func NewProject(id string) *Project {
return &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: id}, State: PROJECTSTATE_ACTIVE}
return &Project{ObjectRoot: es_models.ObjectRoot{AggregateID: id}, State: ProjectStateActive}
}
func (p *Project) IsActive() bool {
return p.State == PROJECTSTATE_ACTIVE
return p.State == ProjectStateActive
}
func (p *Project) IsValid() bool {

View File

@@ -22,16 +22,16 @@ type ProjectGrantIDs struct {
type ProjectGrantState int32
const (
PROJECTGRANTSTATE_ACTIVE ProjectGrantState = iota
PROJECTGRANTSTATE_INACTIVE
ProjectGrantStateActive ProjectGrantState = iota
ProjectGrantStateInactive
)
func NewProjectGrant(projectID, grantID string) *ProjectGrant {
return &ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: projectID}, GrantID: grantID, State: PROJECTGRANTSTATE_ACTIVE}
return &ProjectGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: projectID}, GrantID: grantID, State: ProjectGrantStateActive}
}
func (p *ProjectGrant) IsActive() bool {
return p.State == PROJECTGRANTSTATE_ACTIVE
return p.State == ProjectGrantStateActive
}
func (p *ProjectGrant) IsValid() bool {

View File

@@ -30,13 +30,13 @@ type ProjectGrantMemberSearchRequest struct {
type ProjectGrantMemberSearchKey int32
const (
PROJECTGRANTMEMBERSEARCHKEY_UNSPECIFIED ProjectGrantMemberSearchKey = iota
PROJECTGRANTMEMBERSEARCHKEY_USER_NAME
PROJECTGRANTMEMBERSEARCHKEY_EMAIL
PROJECTGRANTMEMBERSEARCHKEY_FIRST_NAME
PROJECTGRANTMEMBERSEARCHKEY_LAST_NAME
PROJECTGRANTMEMBERSEARCHKEY_GRANT_ID
PROJECTGRANTMEMBERSEARCHKEY_USER_ID
ProjectGrantMemberSearchKeyUnspecified ProjectGrantMemberSearchKey = iota
ProjectGrantMemberSearchKeyUserName
ProjectGrantMemberSearchKeyEmail
ProjectGrantMemberSearchKeyFirstName
ProjectGrantMemberSearchKeyLastName
ProjectGrantMemberSearchKeyGrantID
ProjectGrantMemberSearchKeyUserID
)
type ProjectGrantMemberSearchQuery struct {

View File

@@ -32,13 +32,13 @@ type ProjectGrantViewSearchRequest struct {
type ProjectGrantViewSearchKey int32
const (
GRANTEDPROJECTSEARCHKEY_UNSPECIFIED ProjectGrantViewSearchKey = iota
GRANTEDPROJECTSEARCHKEY_NAME
GRANTEDPROJECTSEARCHKEY_PROJECTID
GRANTEDPROJECTSEARCHKEY_GRANTID
GRANTEDPROJECTSEARCHKEY_ORGID
GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER
GRANTEDPROJECTSEARCHKEY_ROLE_KEYS
GrantedProjectSearchKeyUnspecified ProjectGrantViewSearchKey = iota
GrantedProjectSearchKeyName
GrantedProjectSearchKeyProjectID
GrantedProjectSearchKeyGrantID
GrantedProjectSearchKeyOrgID
GrantedProjectSearchKeyResourceOwner
GrantedProjectSearchKeyRoleKeys
)
type ProjectGrantViewSearchQuery struct {
@@ -55,15 +55,15 @@ type ProjectGrantViewSearchResponse struct {
}
func (r *ProjectGrantViewSearchRequest) AppendMyOrgQuery(orgID string) {
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_ORGID, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GrantedProjectSearchKeyOrgID, Method: model.SearchMethodEquals, Value: orgID})
}
func (r *ProjectGrantViewSearchRequest) AppendNotMyOrgQuery(orgID string) {
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_ORGID, Method: model.SEARCHMETHOD_NOT_EQUALS, Value: orgID})
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GrantedProjectSearchKeyOrgID, Method: model.SearchMethodNotEquals, Value: orgID})
}
func (r *ProjectGrantViewSearchRequest) AppendMyResourceOwnerQuery(orgID string) {
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GRANTEDPROJECTSEARCHKEY_RESOURCE_OWNER, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
r.Queries = append(r.Queries, &ProjectGrantViewSearchQuery{Key: GrantedProjectSearchKeyResourceOwner, Method: model.SearchMethodEquals, Value: orgID})
}
func (r *ProjectGrantViewSearchRequest) EnsureLimit(limit uint64) {

View File

@@ -29,13 +29,13 @@ type ProjectMemberSearchRequest struct {
type ProjectMemberSearchKey int32
const (
PROJECTMEMBERSEARCHKEY_UNSPECIFIED ProjectMemberSearchKey = iota
PROJECTMEMBERSEARCHKEY_USER_NAME
PROJECTMEMBERSEARCHKEY_EMAIL
PROJECTMEMBERSEARCHKEY_FIRST_NAME
PROJECTMEMBERSEARCHKEY_LAST_NAME
PROJECTMEMBERSEARCHKEY_PROJECT_ID
PROJECTMEMBERSEARCHKEY_USER_ID
ProjectMemberSearchKeyUnspecified ProjectMemberSearchKey = iota
ProjectMemberSearchKeyUserName
ProjectMemberSearchKeyEmail
ProjectMemberSearchKeyFirstName
ProjectMemberSearchKeyLastName
ProjectMemberSearchKeyProjectID
ProjectMemberSearchKeyUserID
)
type ProjectMemberSearchQuery struct {
@@ -57,5 +57,5 @@ func (r *ProjectMemberSearchRequest) EnsureLimit(limit uint64) {
}
}
func (r *ProjectMemberSearchRequest) AppendProjectQuery(projectID string) {
r.Queries = append(r.Queries, &ProjectMemberSearchQuery{Key: PROJECTMEMBERSEARCHKEY_PROJECT_ID, Method: model.SEARCHMETHOD_EQUALS, Value: projectID})
r.Queries = append(r.Queries, &ProjectMemberSearchQuery{Key: ProjectMemberSearchKeyProjectID, Method: model.SearchMethodEquals, Value: projectID})
}

View File

@@ -27,12 +27,12 @@ type ProjectRoleSearchRequest struct {
type ProjectRoleSearchKey int32
const (
PROJECTROLESEARCHKEY_UNSPECIFIED ProjectRoleSearchKey = iota
PROJECTROLESEARCHKEY_KEY
PROJECTROLESEARCHKEY_PROJECTID
PROJECTROLESEARCHKEY_ORGID
PROJECTROLESEARCHKEY_RESOURCEOWNER
PROJECTROLESEARCHKEY_DISPLAY_NAME
ProjectRoleSearchKeyUnspecified ProjectRoleSearchKey = iota
ProjectRoleSearchKeyKey
ProjectRoleSearchKeyProjectID
ProjectRoleSearchKeyOrgID
ProjectRoleSearchKeyResourceOwner
ProjectRoleSearchKeyDisplayName
)
type ProjectRoleSearchQuery struct {
@@ -49,10 +49,10 @@ type ProjectRoleSearchResponse struct {
}
func (r *ProjectRoleSearchRequest) AppendMyOrgQuery(orgID string) {
r.Queries = append(r.Queries, &ProjectRoleSearchQuery{Key: PROJECTROLESEARCHKEY_ORGID, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
r.Queries = append(r.Queries, &ProjectRoleSearchQuery{Key: ProjectRoleSearchKeyOrgID, Method: model.SearchMethodEquals, Value: orgID})
}
func (r *ProjectRoleSearchRequest) AppendProjectQuery(projectID string) {
r.Queries = append(r.Queries, &ProjectRoleSearchQuery{Key: PROJECTROLESEARCHKEY_PROJECTID, Method: model.SEARCHMETHOD_EQUALS, Value: projectID})
r.Queries = append(r.Queries, &ProjectRoleSearchQuery{Key: ProjectRoleSearchKeyProjectID, Method: model.SearchMethodEquals, Value: projectID})
}
func (r *ProjectRoleSearchRequest) EnsureLimit(limit uint64) {

View File

@@ -26,10 +26,10 @@ type ProjectViewSearchRequest struct {
type ProjectViewSearchKey int32
const (
PROJECTSEARCHKEY_UNSPECIFIED ProjectViewSearchKey = iota
PROJECTSEARCHKEY_NAME
PROJECTSEARCHKEY_PROJECTID
PROJECTSEARCHKEY_RESOURCE_OWNER
ProjectViewSearchKeyUnspecified ProjectViewSearchKey = iota
ProjectViewSearchKeyName
ProjectViewSearchKeyProjectID
ProjectViewSearchKeyResourceOwner
)
type ProjectViewSearchQuery struct {
@@ -46,7 +46,7 @@ type ProjectViewSearchResponse struct {
}
func (r *ProjectViewSearchRequest) AppendMyResourceOwnerQuery(orgID string) {
r.Queries = append(r.Queries, &ProjectViewSearchQuery{Key: PROJECTSEARCHKEY_RESOURCE_OWNER, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
r.Queries = append(r.Queries, &ProjectViewSearchQuery{Key: ProjectViewSearchKeyResourceOwner, Method: model.SearchMethodEquals, Value: orgID})
}
func (r *ProjectViewSearchRequest) EnsureLimit(limit uint64) {