Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lint #296

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/abac/pap/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ func (c *groupController) GetGroupSubjectCountBeforeExpiredAt(expiredAt int64) (
return c.service.GetGroupSubjectCountBeforeExpiredAt(expiredAt)
}

func (c *groupController) ListGroupSubjectBeforeExpiredAtBySubjects(subjects []Subject, expiredAt int64) ([]GroupSubject, error) {
func (c *groupController) ListGroupSubjectBeforeExpiredAtBySubjects(
subjects []Subject,
expiredAt int64,
) ([]GroupSubject, error) {
errorWrapf := errorx.NewLayerFunctionErrorWrapf(GroupCTL, "FilterGroupsHasMemberBeforeExpiredAt")

svcSubjects := convertToServiceSubjects(subjects)
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/debug/handler/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (
)

type queryPolicyCacheSerializer struct {
System string `form:"system" binding:"required"`
System string `form:"system" binding:"required"`
SubjectType string `form:"subject_type" binding:"required"`
SubjectID string `form:"subject_id" binding:"required"`
SubjectID string `form:"subject_id" binding:"required"`

Action string `form:"action"`
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/api/debug/handler/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func QueryActions(c *gin.Context) {
}

type querySubjectsSerializer struct {
Type string `form:"type" binding:"required"`
ID string `form:"id" binding:"required"`
Type string `form:"type" binding:"required"`
ID string `form:"id" binding:"required"`
System string `form:"system" binding:"required"`
}

Expand Down Expand Up @@ -154,10 +154,10 @@ func QuerySubjects(c *gin.Context) {
}

type queryPoliciesSerializer struct {
System string `form:"system" binding:"required"`
System string `form:"system" binding:"required"`
SubjectType string `form:"subject_type" binding:"required"`
SubjectID string `form:"subject_id" binding:"required"`
Action string `form:"action" binding:"required"`
SubjectID string `form:"subject_id" binding:"required"`
Action string `form:"action" binding:"required"`
}

// QueryPolicies ...
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/engine/handler/credentials_slz.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
package handler

type credentialsVerifySerializer struct {
Type string `json:"type" binding:"required"`
Data appCodeAppSecretSerializer `json:"data" binding:"required"`
Type string `json:"type" binding:"required"`
Data appCodeAppSecretSerializer `json:"data" binding:"required"`
}

type appCodeAppSecretSerializer struct {
AppCode string `json:"app_code" binding:"required"`
AppSecret string `json:"app_secret" binding:"required"`
AppCode string `json:"app_code" binding:"required"`
AppSecret string `json:"app_secret" binding:"required"`
}

type credentialsVerifyResponseSerializer struct {
Expand Down
22 changes: 11 additions & 11 deletions pkg/api/engine/handler/policy_slz.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (s *listPolicySerializer) initDefault() {

type policyResponseSubject struct {
Type string `json:"type" example:"user"`
ID string `json:"id" example:"admin"`
ID string `json:"id" example:"admin"`
Name string `json:"name" example:"Administer"`
}

Expand All @@ -99,15 +99,15 @@ type policyResponseAction struct {
}

type enginePolicyResponse struct {
Version string `json:"version" example:"1"`
ID int64 `json:"id" example:"100"`
System string `json:"system" example:"bk_cmdb"`
Version string `json:"version" example:"1"`
ID int64 `json:"id" example:"100"`
System string `json:"system" example:"bk_cmdb"`
Actions []policyResponseAction `json:"actions"`
Subject policyResponseSubject `json:"subject"`
Expression map[string]interface{} `json:"expression"`
TemplateID int64 `json:"template_id"`
ExpiredAt int64 `json:"expired_at" example:"4102444800"`
UpdatedAt int64 `json:"updated_at" example:"4102444800"`
ExpiredAt int64 `json:"expired_at" example:"4102444800"`
UpdatedAt int64 `json:"updated_at" example:"4102444800"`
}

type policyListResponse struct {
Expand All @@ -118,9 +118,9 @@ type policyListResponse struct {
// -- listPolicyPKs

type listPolicyIDsSerializer struct {
BeginUpdatedAt int64 `form:"begin_updated_at" json:"begin_updated_at" binding:"min=1" example:"1592899208"`
EndUpdatedAt int64 `form:"end_updated_at" json:"end_updated_at" binding:"min=1" example:"1592899208"`
Type string `form:"type" json:"type" binding:"omitempty,oneof=abac rbac" example:"abac"`
BeginUpdatedAt int64 `form:"begin_updated_at" json:"begin_updated_at" binding:"min=1"`
EndUpdatedAt int64 `form:"end_updated_at" json:"end_updated_at" binding:"min=1"`
Type string `form:"type" json:"type" binding:"omitempty,oneof=abac rbac"`
}

func (s *listPolicyIDsSerializer) validate() (bool, string) {
Expand Down Expand Up @@ -148,8 +148,8 @@ type listPolicyIDsResponse struct {
// --a getMaxPolicyPK

type getMaxPolicyIDSerializer struct {
UpdatedAt int64 `form:"updated_at" json:"updated_at" binding:"min=1" example:"1592899208"`
Type string `form:"type" json:"type" binding:"omitempty,oneof=abac rbac" example:"abac"`
UpdatedAt int64 `form:"updated_at" json:"updated_at" binding:"min=1" example:"1592899208"`
Type string `form:"type" json:"type" binding:"omitempty,oneof=abac rbac" example:"abac"`
}

func (s *getMaxPolicyIDSerializer) initDefault() {
Expand Down
40 changes: 20 additions & 20 deletions pkg/api/model/handler/action_slz.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
)

type relatedResourceType struct {
SystemID string `json:"system_id" binding:"required" example:"bk_cmdb"`
ID string `json:"id" binding:"required,max=32" example:"host"`
SystemID string `json:"system_id" binding:"required" example:"bk_cmdb"`
ID string `json:"id" binding:"required,max=32" example:"host"`

NameAlias string `json:"name_alias" example:""`
NameAlias string `json:"name_alias" example:""`
NameAliasEn string `json:"name_alias_en" example:""`

// 实例选择方式/范围: ["all", "instance", "attribute", "instance:paste"]
Expand All @@ -45,39 +45,39 @@ type relatedEnvironment struct {
}

type actionSerializer struct {
ID string `json:"id" binding:"required,max=32" example:"biz_create"`
Name string `json:"name" binding:"required" example:"biz_create"`
NameEn string `json:"name_en" binding:"required" example:"biz_create"`
ID string `json:"id" binding:"required,max=32" example:"biz_create"`
Name string `json:"name" binding:"required" example:"biz_create"`
NameEn string `json:"name_en" binding:"required" example:"biz_create"`

Description string `json:"description" binding:"omitempty" example:"biz_create is"`
DescriptionEn string `json:"description_en" binding:"omitempty" example:"biz_create is"`
Sensitivity int64 `json:"sensitivity" binding:"omitempty,gte=0,lte=9" example:"0"`
Description string `json:"description" binding:"omitempty" example:"biz_create is"`
DescriptionEn string `json:"description_en" binding:"omitempty" example:"biz_create is"`
Sensitivity int64 `json:"sensitivity" binding:"omitempty,gte=0,lte=9" example:"0"`

AuthType string `json:"auth_type" binding:"omitempty,oneof=rbac abac" example:"abac"`
Type string `json:"type" binding:"omitempty,oneof=create edit view delete list manage execute debug use"`
Hidden bool `json:"hidden" binding:"omitempty" example:"false"`
Type string `json:"type" binding:"omitempty,oneof=create edit view delete list manage execute debug use"`
Hidden bool `json:"hidden" binding:"omitempty" example:"false"`

RelatedResourceTypes []relatedResourceType `json:"related_resource_types"`
RelatedActions []string `json:"related_actions"`
RelatedEnvironments []relatedEnvironment `json:"related_environments" binding:"omitempty"`
RelatedEnvironments []relatedEnvironment `json:"related_environments" binding:"omitempty"`

Version int64 `json:"version" binding:"omitempty,gte=1" example:"1"`
}

type actionUpdateSerializer struct {
Name string `json:"name" example:"biz_create"`
NameEn string `json:"name_en" example:"biz_create"`
Description string `json:"description" binding:"omitempty" example:"biz_create is"`
DescriptionEn string `json:"description_en" binding:"omitempty" example:"biz_create is"`
Sensitivity int64 `json:"sensitivity" binding:"omitempty,gte=0,lte=9" example:"0"`
Name string `json:"name" example:"biz_create"`
NameEn string `json:"name_en" example:"biz_create"`
Description string `json:"description" example:"biz_create is" binding:"omitempty"`
DescriptionEn string `json:"description_en" example:"biz_create is" binding:"omitempty"`
Sensitivity int64 `json:"sensitivity" example:"0" binding:"omitempty,gte=0,lte=9"`

AuthType string `json:"auth_type" binding:"omitempty,oneof=rbac abac" example:"abac"`
Type string `json:"type" binding:"omitempty,oneof=create edit view delete list manage execute debug use"`
Hidden bool `json:"hidden" binding:"omitempty" example:"false"`
Type string `json:"type" binding:"omitempty,oneof=create edit view delete list manage execute debug use"`
Hidden bool `json:"hidden" binding:"omitempty" example:"false"`

RelatedResourceTypes []relatedResourceType `json:"related_resource_types"`
RelatedActions []string `json:"related_actions"`
RelatedEnvironments []relatedEnvironment `json:"related_environments" binding:"omitempty"`
RelatedEnvironments []relatedEnvironment `json:"related_environments" binding:"omitempty"`

Version int64 `json:"version" binding:"omitempty,gte=1" example:"1"`
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/api/model/handler/instance_selection_slz.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ import (
)

type instanceSelectionSerializer struct {
ID string `json:"id" binding:"required,max=32" example:"biz_set"`
Name string `json:"name" binding:"required" example:"biz_set"`
NameEn string `json:"name_en" binding:"required" example:"biz_set"`
IsDynamic bool `json:"is_dynamic" binding:"omitempty" example:"false"`
ID string `json:"id" binding:"required,max=32" example:"biz_set"`
Name string `json:"name" binding:"required" example:"biz_set"`
NameEn string `json:"name_en" binding:"required" example:"biz_set"`
IsDynamic bool `json:"is_dynamic" binding:"omitempty" example:"false"`

ResourceTypeChain []referenceResourceType `json:"resource_type_chain" structs:"resource_type_chain" binding:"required"`
}

type instanceSelectionUpdateSerializer struct {
// ID string `json:"id" binding:"required"`
Name string `json:"name" binding:"required" example:"biz_set"`
NameEn string `json:"name_en" binding:"required" example:"biz_set"`
Name string `json:"name" binding:"required" example:"biz_set"`
NameEn string `json:"name_en" binding:"required" example:"biz_set"`
IsDynamic bool `json:"is_dynamic" binding:"omitempty" example:"false"`

ResourceTypeChain []referenceResourceType `json:"resource_type_chain" structs:"resource_type_chain" binding:"required"`
Expand Down
22 changes: 11 additions & 11 deletions pkg/api/model/handler/resource_type_slz.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ type resourceProviderConfig struct {
}

type resourceTypeSerializer struct {
ID string `json:"id" binding:"required,max=32" example:"biz_set"`
Name string `json:"name" binding:"required" example:"biz_set"`
NameEn string `json:"name_en" binding:"required" example:"biz_set"`
ID string `json:"id" binding:"required,max=32" example:"biz_set"`
Name string `json:"name" binding:"required" example:"biz_set"`
NameEn string `json:"name_en" binding:"required" example:"biz_set"`

Description string `json:"description" binding:"omitempty" example:"biz_set is a"`
DescriptionEn string `json:"description_en" binding:"omitempty" example:"biz_set is a"`
Sensitivity int64 `json:"sensitivity" binding:"omitempty,gte=0,lte=9" example:"0"`
Description string `json:"description" binding:"omitempty" example:"biz_set is a"`
DescriptionEn string `json:"description_en" binding:"omitempty" example:"biz_set is a"`
Sensitivity int64 `json:"sensitivity" binding:"omitempty,gte=0,lte=9" example:"0"`

// can be empty
Parents []referenceResourceType `json:"parents"`
Expand All @@ -42,11 +42,11 @@ type resourceTypeSerializer struct {

type resourceTypeUpdateSerializer struct {
// ID string `json:"id" binding:"required"`
Name string `json:"name" binding:"omitempty" example:"biz_set"`
NameEn string `json:"name_en" binding:"omitempty" example:"biz_set"`
Description string `json:"description" binding:"omitempty" example:"biz_set is a"`
DescriptionEn string `json:"description_en" binding:"omitempty" example:"biz_set is a"`
Sensitivity int64 `json:"sensitivity" binding:"omitempty,gte=0,lte=9" example:"0"`
Name string `json:"name" binding:"omitempty" example:"biz_set"`
NameEn string `json:"name_en" binding:"omitempty" example:"biz_set"`
Description string `json:"description" binding:"omitempty" example:"biz_set is a"`
DescriptionEn string `json:"description_en" binding:"omitempty" example:"biz_set is a"`
Sensitivity int64 `json:"sensitivity" binding:"omitempty,gte=0,lte=9" example:"0"`

// can be empty
Parents []referenceResourceType `json:"parents"`
Expand Down
24 changes: 12 additions & 12 deletions pkg/api/model/handler/system_config_slz.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ type actionGroupActionSerializer struct {
}

type actionGroupSerializer struct {
Name string `json:"name" binding:"required" example:"admin"`
NameEn string `json:"name_en" binding:"required" example:"admin"`
Actions []actionGroupActionSerializer `json:"actions,omitempty" binding:"omitempty"`
Name string `json:"name" binding:"required" example:"admin"`
NameEn string `json:"name_en" binding:"required" example:"admin"`
Actions []actionGroupActionSerializer `json:"actions,omitempty" binding:"omitempty"`
SubGroups []actionGroupSerializer `json:"sub_groups,omitempty" binding:"omitempty"`
}

Expand Down Expand Up @@ -97,13 +97,13 @@ func validateActionGroup(actionGroups []actionGroupSerializer, name string) (boo
}

type resourceCreatorSingleActionSerializer struct {
ID string `json:"id" binding:"required" example:"edit"`
ID string `json:"id" binding:"required" example:"edit"`
Required bool `json:"required" binding:"required" example:"true"`
}

type resourceCreatorActionConfig struct {
ID string `json:"id" binding:"required" example:"host"`
Actions []resourceCreatorSingleActionSerializer `json:"actions" binding:"required,gt=0"`
ID string `json:"id" binding:"required"`
Actions []resourceCreatorSingleActionSerializer `json:"actions" binding:"required,gt=0"`
SubResourceTypes []resourceCreatorActionConfig `json:"sub_resource_types,omitempty" binding:"omitempty"`
}

Expand Down Expand Up @@ -144,7 +144,7 @@ func (r *resourceCreatorActionConfig) validate() error {
type resourceCreatorActionSerializer struct {
// 选择支持的方式:接入系统 和 用户,对于用户,则需要在授权接口上额外传入祖先creator信息
Mode string `json:"mode,omitempty" binding:"omitempty,oneof=system user" example:"system"`
Config []resourceCreatorActionConfig `json:"config" binding:"required"`
Config []resourceCreatorActionConfig `json:"config" binding:"required"`
}

func (r *resourceCreatorActionSerializer) getAllActionIDResourceTypeIDFromConfig() []ActionIDResourceTypeID {
Expand Down Expand Up @@ -187,8 +187,8 @@ type actionIDSerializer struct {
}

type commonActionSerializer struct {
Name string `json:"name" binding:"required" example:"admin"`
NameEn string `json:"name_en" binding:"required" example:"admin"`
Name string `json:"name" binding:"required" example:"admin"`
NameEn string `json:"name_en" binding:"required" example:"admin"`
Actions []actionIDSerializer `json:"actions" binding:"required,gte=1"`
}

Expand All @@ -205,9 +205,9 @@ func getAllFromCommonActions(commonActions []commonActionSerializer) []string {
}

type featureShieldRuleSerializer struct {
Effect string `json:"effect" binding:"required,oneof=deny allow" example:"deny"`
Feature string `json:"feature" binding:"required" example:"application.custom_permission"`
Action actionIDSerializer `json:"action" binding:"required"`
Effect string `json:"effect" binding:"required,oneof=deny allow" example:"deny"`
Feature string `json:"feature" binding:"required" example:"application.custom_permission"`
Action actionIDSerializer `json:"action" binding:"required"`
}

func (f *featureShieldRuleSerializer) validate() error {
Expand Down
Loading
Loading