Documentation
¶
Index ¶
- Variables
- func EnvironmentName(key string) string
- func NormalizeProjectKey(value string) string
- func ValidEnvironment(value string) bool
- func ValidProjectKey(value string) bool
- func ValidUsername(value string) bool
- type BootstrapEnvironment
- type EnvironmentDefinition
- type Permission
- type PlatformPermission
- type Project
- type ProjectEnvironment
- type Service
- func (s *Service) Bootstrap(ctx context.Context, adminUsername, adminHash string, ...) error
- func (s *Service) DeleteEnvironment(ctx context.Context, project, environment string) error
- func (s *Service) DeletePermission(ctx context.Context, project, username string) error
- func (s *Service) DeleteProject(ctx context.Context, key string) error
- func (s *Service) DeleteUser(ctx context.Context, username string) error
- func (s *Service) Environment(ctx context.Context, project, environment string) (ProjectEnvironment, error)
- func (s *Service) GetProject(ctx context.Context, key string) (Project, error)
- func (s *Service) GetUser(ctx context.Context, username string) (User, error)
- func (s *Service) ListProjects(ctx context.Context, username string, isAdmin bool) ([]Project, error)
- func (s *Service) ListUsers(ctx context.Context) ([]User, error)
- func (s *Service) Permission(ctx context.Context, username string, isAdmin bool, project string) (Permission, error)
- func (s *Service) RequireConfigure(ctx context.Context, username string, isAdmin bool, project string) error
- func (s *Service) RequireDeploy(ctx context.Context, username string, isAdmin bool, project string) error
- func (s *Service) RequireView(ctx context.Context, username string, isAdmin bool, project string) (Permission, error)
- func (s *Service) RequireViewSecrets(ctx context.Context, username string, isAdmin bool, project string) error
- func (s *Service) SaveEnvironment(ctx context.Context, item ProjectEnvironment) error
- func (s *Service) SavePermission(ctx context.Context, permission Permission) error
- func (s *Service) SaveProject(ctx context.Context, project Project) error
- func (s *Service) SaveUser(ctx context.Context, user User) error
- type Store
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrForbidden = errors.New("project permission denied") ErrInvalidProject = errors.New("invalid project key") ErrInvalidProjectDisplayName = errors.New("project display name must contain 1 to 128 characters") ErrProjectDescriptionTooLong = errors.New("project description must not exceed 1000 characters") ErrInvalidEnvironment = errors.New("environment must be one of dev, test, uat, or prod") ErrInvalidUsername = errors.New("invalid username") ErrInvalidPermission = errors.New("invalid project permission") )
View Source
var EnvironmentDefinitions = []EnvironmentDefinition{
{Key: "dev", DisplayName: "开发环境", Order: 1},
{Key: "test", DisplayName: "测试环境", Order: 2},
{Key: "uat", DisplayName: "预发布环境", Order: 3},
{Key: "prod", DisplayName: "生产环境", Order: 4},
}
Functions ¶
func EnvironmentName ¶
func NormalizeProjectKey ¶
NormalizeProjectKey converts a user-facing project label into the restricted identifier required by Kubernetes, Terraform and AWS resource names. Chinese and other non-ASCII characters remain available in Project.DisplayName.
func ValidEnvironment ¶
func ValidProjectKey ¶
func ValidUsername ¶
Types ¶
type BootstrapEnvironment ¶
type EnvironmentDefinition ¶
type Permission ¶
type PlatformPermission ¶
type PlatformPermission struct {
CanManageProjects bool `json:"can_manage_projects"`
CanManageUsers bool `json:"can_manage_users"`
CanManageCredentials bool `json:"can_manage_credentials"`
CanManageComponents bool `json:"can_manage_components"`
CanViewAudit bool `json:"can_view_audit"`
}
func FullPlatformPermission ¶
func FullPlatformPermission() PlatformPermission
func (PlatformPermission) Any ¶
func (permission PlatformPermission) Any() bool
type Project ¶
type Project struct {
Key string `json:"key"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
SelectedAWSCredentialKey string `json:"selected_aws_credential_key"`
Environments []ProjectEnvironment `json:"environments"`
Permission Permission `json:"permission"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type ProjectEnvironment ¶
type ProjectEnvironment struct {
ProjectKey string `json:"project_key"`
Environment string `json:"environment"`
DisplayName string `json:"display_name"`
TargetName string `json:"target_name"`
Region string `json:"region"`
LifecycleStatus string `json:"lifecycle_status,omitempty"`
LifecycleDetail string `json:"lifecycle_detail,omitempty"`
LifecycleUpdatedAt *time.Time `json:"lifecycle_updated_at,omitempty"`
LatestJobID string `json:"latest_job_id,omitempty"`
LatestJobAction string `json:"latest_job_action,omitempty"`
LatestJobStatus string `json:"latest_job_status,omitempty"`
LatestJobProgress int `json:"latest_job_progress,omitempty"`
PhaseOneDeployed bool `json:"phase_one_deployed"`
PhaseTwoDeployed bool `json:"phase_two_deployed"`
CreatedAt time.Time `json:"created_at"`
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) DeleteEnvironment ¶
func (*Service) DeletePermission ¶
func (*Service) DeleteProject ¶
func (*Service) DeleteUser ¶
func (*Service) Environment ¶
func (*Service) GetProject ¶
func (*Service) ListProjects ¶
func (*Service) Permission ¶
func (*Service) RequireConfigure ¶
func (*Service) RequireDeploy ¶
func (*Service) RequireView ¶
func (*Service) RequireViewSecrets ¶
func (*Service) SaveEnvironment ¶
func (s *Service) SaveEnvironment(ctx context.Context, item ProjectEnvironment) error
func (*Service) SavePermission ¶
func (s *Service) SavePermission(ctx context.Context, permission Permission) error
func (*Service) SaveProject ¶
type Store ¶
type Store interface {
EnsureAdmin(context.Context, User) error
GetUser(context.Context, string) (User, error)
ListUsers(context.Context) ([]User, error)
SaveUser(context.Context, User) error
DeleteUser(context.Context, string) error
EnsureProject(context.Context, Project) error
ListProjects(context.Context, string, bool) ([]Project, error)
GetProject(context.Context, string) (Project, error)
SaveProject(context.Context, Project) error
DeleteProject(context.Context, string) error
ListProjectEnvironments(context.Context, string) ([]ProjectEnvironment, error)
GetProjectEnvironment(context.Context, string, string) (ProjectEnvironment, error)
SaveProjectEnvironment(context.Context, ProjectEnvironment) error
DeleteProjectEnvironment(context.Context, string, string) error
GetPermission(context.Context, string, string) (Permission, error)
SavePermission(context.Context, Permission) error
DeletePermission(context.Context, string, string) error
}
type User ¶
type User struct {
Username string `json:"username"`
DisplayName string `json:"display_name"`
PasswordHash string `json:"-"`
IsAdmin bool `json:"is_admin"`
Active bool `json:"active"`
PlatformPermissions PlatformPermission `json:"platform_permissions"`
Permissions []Permission `json:"permissions"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Click to show internal directories.
Click to hide internal directories.