Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AddRoleManagerRepo = migrations.Migration{ Version: 2, Message: "Add role repo manager", Handler: func(db storm.Node) error { roleManageRepo := v1Role.Role{ BaseModel: v1.BaseModel{ ApiVersion: "v1", Kind: "Role", BuiltIn: true, CreateAt: time.Now(), UpdateAt: time.Now(), }, Metadata: v1.Metadata{ Name: "Manage Image Registries", Description: "i18n_user_manage_repo", UUID: uuid.New().String(), }, Rules: []v1Role.PolicyRule{ { Resource: []string{"imagerepos"}, Verbs: []string{"*"}, }, }, } return db.Save(&roleManageRepo) }, }
View Source
var CreateAdministrator = migrations.Migration{ Version: 1, Message: "Create default user and cluster", Handler: func(db storm.Node) error { roleManageClusters := v1Role.Role{ BaseModel: v1.BaseModel{ ApiVersion: "v1", Kind: "Role", BuiltIn: true, CreateAt: time.Now(), UpdateAt: time.Now(), }, Metadata: v1.Metadata{ Name: "Manage Clusters", UUID: uuid.New().String(), Description: "i18n_user_manage_cluster", }, Rules: []v1Role.PolicyRule{ { Resource: []string{"clusters"}, Verbs: []string{"*"}, }, }, } roleManageRBAC := v1Role.Role{ BaseModel: v1.BaseModel{ ApiVersion: "v1", Kind: "Role", BuiltIn: true, CreateAt: time.Now(), UpdateAt: time.Now(), }, Metadata: v1.Metadata{ Name: "Manage RBAC", Description: "i18n_user_manage_rbac", UUID: uuid.New().String(), }, Rules: []v1Role.PolicyRule{ { Resource: []string{"users", "roles", "ldap"}, Verbs: []string{"*"}, }, }, } roleReadOnly := v1Role.Role{ BaseModel: v1.BaseModel{ ApiVersion: "v1", Kind: "Role", BuiltIn: true, CreateAt: time.Now(), UpdateAt: time.Now(), }, Metadata: v1.Metadata{ Name: "ReadOnly", Description: "i18n_user_manage_readonly", UUID: uuid.New().String(), }, Rules: []v1Role.PolicyRule{ { Resource: []string{"*"}, Verbs: []string{"get", "list"}, }, }, } roleCommonUser := v1Role.Role{ BaseModel: v1.BaseModel{ ApiVersion: "v1", Kind: "Role", BuiltIn: true, CreateAt: time.Now(), UpdateAt: time.Now(), }, Metadata: v1.Metadata{ Name: "Common User", Description: "i18n_user_common_user", UUID: uuid.New().String(), }, Rules: []v1Role.PolicyRule{ { Resource: []string{"clusters"}, Verbs: []string{"get", "list"}, }, }, } defaultUserPass := "kubepi" hash, _ := bcrypt.GenerateFromPassword([]byte(defaultUserPass), bcrypt.DefaultCost) userAdmin := v1User.User{ BaseModel: v1.BaseModel{ ApiVersion: "v1", Kind: "User", BuiltIn: true, CreateAt: time.Now(), UpdateAt: time.Now(), }, Metadata: v1.Metadata{ Name: "admin", UUID: uuid.New().String(), }, IsAdmin: true, NickName: "Administrator", Email: "support@fit2cloud.com", Language: "zh-CN", Authenticate: v1User.Authenticate{ Password: string(hash), }, } dbObjects := []interface{}{ &roleManageClusters, &roleCommonUser, &roleManageRBAC, &roleReadOnly, &userAdmin, } for i := range dbObjects { if err := db.Save(dbObjects[i]); err != nil { return err } } return nil }, }
View Source
var Migrations = []migrations.Migration{ CreateAdministrator, AddRoleManagerRepo, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.