service

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const PresetScope = ""
View Source
const SystemScope = "*"

Variables

This section is empty.

Functions

func CreateOrUpdateSystemPolicyBinding added in v1.10.0

func CreateOrUpdateSystemPolicyBinding(ns string, rb *PolicyBinding, logger *zap.SugaredLogger) error

func CreateOrUpdateSystemRoleBinding added in v1.7.0

func CreateOrUpdateSystemRoleBinding(ns string, rb *RoleBinding, logger *zap.SugaredLogger) error

func CreatePolicies added in v1.10.0

func CreatePolicies(ns string, policies []*Policy, _ *zap.SugaredLogger) error

func CreatePolicy added in v1.10.0

func CreatePolicy(ns string, policy *Policy, _ *zap.SugaredLogger) error

func CreatePolicyBindings added in v1.10.0

func CreatePolicyBindings(ns string, rbs []*PolicyBinding, logger *zap.SugaredLogger) error

func CreateRole

func CreateRole(ns string, role *Role, _ *zap.SugaredLogger) error

func CreateRoleBindings added in v1.7.0

func CreateRoleBindings(ns string, rbs []*RoleBinding, logger *zap.SugaredLogger) error

func DeletePolicies added in v1.10.0

func DeletePolicies(names []string, projectName string, logger *zap.SugaredLogger) error

func DeletePolicy added in v1.10.0

func DeletePolicy(name string, projectName string, logger *zap.SugaredLogger) error

func DeletePolicyBinding added in v1.10.0

func DeletePolicyBinding(name string, projectName string, _ *zap.SugaredLogger) error

func DeletePolicyBindings added in v1.10.0

func DeletePolicyBindings(names []string, projectName string, userID string, _ *zap.SugaredLogger) error

func DeleteRole added in v1.7.0

func DeleteRole(name string, projectName string, logger *zap.SugaredLogger) error

func DeleteRoleBinding added in v1.7.0

func DeleteRoleBinding(name string, projectName string, _ *zap.SugaredLogger) error

func DeleteRoleBindings added in v1.7.0

func DeleteRoleBindings(names []string, projectName string, userID string, _ *zap.SugaredLogger) error

func DeleteRoles added in v1.7.0

func DeleteRoles(names []string, projectName string, logger *zap.SugaredLogger) error

func GetResourcesPermission added in v1.10.0

func GetResourcesPermission(uid string, projectName string, resourceType string, resources []string, logger *zap.SugaredLogger) (map[string][]string, error)

GetResourcesPermission get resources action list for frontend to show icon

func GetTestTask added in v1.17.0

func GetTestTask(testName string) (*aslanmodels.TestTaskStat, error)

func ListAllWorkflows added in v1.17.0

func ListAllWorkflows(testName string, log *zap.SugaredLogger) ([]*aslanmodels.Workflow, error)

func ListUserAllPoliciesByPolicyBindings added in v1.12.0

func ListUserAllPoliciesByPolicyBindings(policyBindings []*models.PolicyBinding) ([]*models.Policy, error)

func ListUserAllRoleBindings added in v1.10.0

func ListUserAllRoleBindings(projectName, uid string) ([]*models.RoleBinding, error)

func ListUserAllRolesByRoleBindings added in v1.10.0

func ListUserAllRolesByRoleBindings(roleBindings []*models.RoleBinding) ([]*models.Role, error)

func SearchSystemRoleBindings added in v1.12.0

func SearchSystemRoleBindings(uids []string, _ *zap.SugaredLogger) (map[string][]*RoleBinding, error)

func UpdateOrCreatePolicy added in v1.10.0

func UpdateOrCreatePolicy(ns string, policy *Policy, _ *zap.SugaredLogger) error

func UpdateOrCreatePolicyBinding added in v1.10.0

func UpdateOrCreatePolicyBinding(ns string, rb *PolicyBinding, logger *zap.SugaredLogger) error

func UpdateOrCreateRole added in v1.7.0

func UpdateOrCreateRole(ns string, role *Role, _ *zap.SugaredLogger) error

func UpdateOrCreateRoleBinding added in v1.7.0

func UpdateOrCreateRoleBinding(ns string, rb *RoleBinding, logger *zap.SugaredLogger) error

func UpdatePolicy added in v1.10.0

func UpdatePolicy(ns string, policy *Policy, log *zap.SugaredLogger) error

func UpdateRole added in v1.7.0

func UpdateRole(ns string, role *Role, _ *zap.SugaredLogger) error

func UpdateRoleBindings added in v1.10.0

func UpdateRoleBindings(ns string, rbs []*RoleBinding, userID string, logger *zap.SugaredLogger) error

Types

type GetUserRulesByProjectResp added in v1.12.0

type GetUserRulesByProjectResp struct {
	IsSystemAdmin       bool                `json:"is_system_admin"`
	IsProjectAdmin      bool                `json:"is_project_admin"`
	ProjectVerbs        []string            `json:"project_verbs"`
	WorkflowVerbsMap    map[string][]string `json:"workflow_verbs_map"`
	EnvironmentVerbsMap map[string][]string `json:"environment_verbs_map"`
}

func GetUserPermissionByProject added in v1.18.0

func GetUserPermissionByProject(uid, projectName string, log *zap.SugaredLogger) (*GetUserRulesByProjectResp, error)

type GetUserRulesResp added in v1.12.0

type GetUserRulesResp struct {
	IsSystemAdmin    bool                `json:"is_system_admin"`
	ProjectAdminList []string            `json:"project_admin_list"`
	ProjectVerbMap   map[string][]string `json:"project_verb_map"`
	SystemVerbs      []string            `json:"system_verbs"`
}

func GetUserRules added in v1.12.0

func GetUserRules(uid string, log *zap.SugaredLogger) (*GetUserRulesResp, error)

type ListPolicyResp added in v1.10.0

type ListPolicyResp struct {
	Policies []Policy `json:"policies"`
}

type Policy added in v1.7.0

type Policy struct {
	Name        string  `json:"name"`
	Description string  `json:"description"`
	UpdateTime  int64   `json:"update_time"`
	Rules       []*Rule `json:"rules,omitempty"`
}

func GetPolicies added in v1.10.0

func GetPolicies(names string, log *zap.SugaredLogger) ([]*Policy, error)

func GetPolicy added in v1.10.0

func GetPolicy(ns, name string, log *zap.SugaredLogger) (*Policy, error)

func ListPolicies added in v1.10.0

func ListPolicies(projectName string, _ *zap.SugaredLogger) ([]*Policy, error)

type PolicyBinding added in v1.10.0

type PolicyBinding struct {
	Name   string               `json:"name"`
	UID    string               `json:"uid"`
	Policy string               `json:"policy"`
	Preset bool                 `json:"preset"`
	Type   setting.ResourceType `json:"type"`
}

func ListPolicyBindings added in v1.10.0

func ListPolicyBindings(ns, uid string, _ *zap.SugaredLogger) ([]*PolicyBinding, error)

func ListPolicyBindingsByPolicy added in v1.10.0

func ListPolicyBindingsByPolicy(ns, policyName string, publicPolicy bool, _ *zap.SugaredLogger) ([]*PolicyBinding, error)

type PolicyDefinition added in v1.7.0

type PolicyDefinition struct {
	Resource    string                  `json:"resource"`
	ResourceKey string                  `json:"resource_key"`
	Alias       string                  `json:"alias"`
	Description string                  `json:"description"`
	Rules       []*PolicyRuleDefinition `json:"rules"`
}

func GetPolicyRegistrationDefinitions added in v1.7.0

func GetPolicyRegistrationDefinitions(scope, envType string, logger *zap.SugaredLogger) ([]*PolicyDefinition, error)

type PolicyRuleDefinition added in v1.7.0

type PolicyRuleDefinition struct {
	Action      string `json:"action"`
	Alias       string `json:"alias"`
	Description string `json:"description"`
}

type ReleaseWorkflowResp added in v1.17.0

type ReleaseWorkflowResp struct {
	Name                 string                   `json:"name"`
	DisplayName          string                   `json:"display_name"`
	Category             setting.WorkflowCategory `json:"category"`
	Stages               []string                 `json:"stages"`
	Project              string                   `json:"project"`
	Description          string                   `json:"description"`
	CreatedBy            string                   `json:"createdBy"`
	CreateTime           int64                    `json:"createTime"`
	UpdatedBy            string                   `json:"updatedBy"`
	UpdateTime           int64                    `json:"updateTime"`
	RecentTask           *TaskInfo                `json:"recentTask"`
	RecentSuccessfulTask *TaskInfo                `json:"recentSuccessfulTask"`
	RecentFailedTask     *TaskInfo                `json:"recentFailedTask"`
	AverageExecutionTime float64                  `json:"averageExecutionTime"`
	SuccessRate          float64                  `json:"successRate"`
	NeverRun             bool                     `json:"never_run"`
	Verbs                []string                 `json:"verbs"`
}

func GetUserReleaseWorkflows added in v1.17.0

func GetUserReleaseWorkflows(uid string, log *zap.SugaredLogger) ([]*ReleaseWorkflowResp, error)

func WorkflowToWorkflowResp added in v1.17.0

func WorkflowToWorkflowResp(workflow *aslanmodels.WorkflowV4) *ReleaseWorkflowResp

type Role

type Role struct {
	Name  string  `json:"name"`
	Rules []*Rule `json:"rules,omitempty"`
	// if the role is created by user , set the type to "custom"
	// if the role is created by system , set the type  to "system"
	Type setting.ResourceType `json:"type,omitempty"`
	// frontend default select flag
	Select    bool   `json:"select,omitempty"`
	Namespace string `json:"namespace"`
	Desc      string `json:"desc,omitempty"`
}

func GetRole added in v1.7.0

func GetRole(ns, name string, _ *zap.SugaredLogger) (*Role, error)

func ListRoles added in v1.7.0

func ListRoles(projectName string, _ *zap.SugaredLogger) ([]*Role, error)

type RoleBinding

type RoleBinding struct {
	Name   string               `json:"name"`
	UID    string               `json:"uid"`
	Role   string               `json:"role"`
	Preset bool                 `json:"preset"`
	Type   setting.ResourceType `json:"type"`
}

func ListRoleBindings added in v1.7.0

func ListRoleBindings(ns, uid string, _ *zap.SugaredLogger) ([]*RoleBinding, error)

type Rule added in v1.7.0

type Rule struct {
	Verbs            []string                `json:"verbs"`
	Resources        []string                `json:"resources"`
	Kind             string                  `json:"kind"`
	MatchAttributes  []models.MatchAttribute `json:"match_attributes"`
	RelatedResources []string                `json:"related_resources"`
}

type TaskInfo added in v1.17.0

type TaskInfo struct {
	TaskID       int64  `json:"taskID"`
	PipelineName string `json:"pipelineName"`
	Status       string `json:"status"`
	TaskCreator  string `json:"task_creator"`
	CreateTime   int64  `json:"create_time"`
}

type TestingOpt added in v1.17.0

type TestingOpt struct {
	Name        string                  `json:"name"`
	ProductName string                  `json:"product_name"`
	Desc        string                  `json:"desc"`
	UpdateTime  int64                   `json:"update_time"`
	UpdateBy    string                  `json:"update_by"`
	TestCaseNum int                     `json:"test_case_num,omitempty"`
	ExecuteNum  int                     `json:"execute_num,omitempty"`
	PassRate    float64                 `json:"pass_rate,omitempty"`
	AvgDuration float64                 `json:"avg_duration,omitempty"`
	Workflows   []*aslanmodels.Workflow `json:"workflows,omitempty"`
	Verbs       []string                `json:"verbs"`
}

func ListTesting added in v1.17.0

func ListTesting(uid string, log *zap.SugaredLogger) ([]*TestingOpt, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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