1
0
mirror of https://github.com/rancher/types.git synced 2025-08-14 02:35:19 +00:00

AuthConfig changes

This commit is contained in:
Craig Jellick 2018-01-30 08:28:55 -07:00 committed by Darren Shepherd
parent 9665da0fe7
commit 1e34f45776
2 changed files with 76 additions and 9 deletions

View File

@ -90,3 +90,43 @@ type ChangePasswordInput struct {
type SetPasswordInput struct {
NewPassword string `json:"newPassword" norman:"type=string,required"`
}
//AuthConfig structure contains the AuthConfig definition
type AuthConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Type string `json:"type"`
}
//GithubConfig structure contains the github config definition
type GithubConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
AuthConfig `json:",inline"`
Hostname string `json:"hostname,omitempty"`
Scheme string `json:"scheme,omitempty"`
ClientID string `json:"clientId,omitempty"`
ClientSecret string `json:"clientSecret,omitempty"`
Enabled bool `json:"enabled,omitempty"`
}
//LocalConfig structure contains the local config definition
type LocalConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
}
//GithubConfigTestInput structure defines all properties that can be sent by client to configure github
type GithubConfigTestInput struct {
GithubConfig GithubConfig `json:"githubConfig, omitempty"`
Enabled bool `json:"enabled,omitempty"`
}
//GithubConfigApplyInput structure defines all properties that can be sent by client to configure github
type GithubConfigApplyInput struct {
GithubConfig GithubConfig `json:"githubConfig, omitempty"`
GithubCredential GithubCredential `json:"githubCredential, omitempty"`
Enabled bool `json:"enabled,omitempty"`
}

View File

@ -26,11 +26,15 @@ var (
Init(clusterTypes).
Init(catalogTypes).
Init(authnTypes).
Init(tokens).
Init(schemaTypes).
Init(stackTypes).
Init(userTypes).
Init(logTypes).
Init(globalTypes)
TokenSchema = factory.Schemas(&Version).
Init(tokens)
)
func schemaTypes(schemas *types.Schemas) *types.Schemas {
@ -131,18 +135,11 @@ func machineTypes(schemas *types.Schemas) *types.Schemas {
}
func authnTypes(schemas *types.Schemas) *types.Schemas {
func tokens(schemas *types.Schemas) *types.Schemas {
return schemas.
AddMapperForType(&Version, v3.User{}, m.DisplayName{}).
AddMapperForType(&Version, v3.Group{}, m.DisplayName{}).
MustImport(&Version, v3.Group{}).
MustImport(&Version, v3.GroupMember{}).
MustImport(&Version, v3.Principal{}).
MustImport(&Version, v3.LoginInput{}).
MustImport(&Version, v3.LocalCredential{}).
MustImport(&Version, v3.GithubCredential{}).
MustImport(&Version, v3.ChangePasswordInput{}).
MustImport(&Version, v3.SetPasswordInput{}).
MustImportAndCustomize(&Version, v3.Token{}, func(schema *types.Schema) {
schema.CollectionActions = map[string]types.Action{
"login": {
@ -151,7 +148,18 @@ func authnTypes(schemas *types.Schemas) *types.Schemas {
},
"logout": {},
}
}).
})
}
func authnTypes(schemas *types.Schemas) *types.Schemas {
return schemas.
AddMapperForType(&Version, v3.User{}, m.DisplayName{}).
AddMapperForType(&Version, v3.Group{}, m.DisplayName{}).
MustImport(&Version, v3.Group{}).
MustImport(&Version, v3.GroupMember{}).
MustImport(&Version, v3.Principal{}).
MustImport(&Version, v3.ChangePasswordInput{}).
MustImport(&Version, v3.SetPasswordInput{}).
MustImportAndCustomize(&Version, v3.User{}, func(schema *types.Schema) {
schema.ResourceActions = map[string]types.Action{
"setpassword": {
@ -164,6 +172,25 @@ func authnTypes(schemas *types.Schemas) *types.Schemas {
Input: "changePasswordInput",
},
}
}).
MustImport(&Version, v3.AuthConfig{}).
MustImportAndCustomize(&Version, v3.GithubConfig{}, func(schema *types.Schema) {
schema.BaseType = "authConfig"
schema.ResourceActions = map[string]types.Action{
"configureTest": {
Input: "githubConfigTestInput",
Output: "githubConfig",
},
"testAndApply": {
Input: "githubConfigApplyInput",
Output: "githubConfig",
},
}
}).
MustImport(&Version, v3.GithubConfigTestInput{}).
MustImport(&Version, v3.GithubConfigApplyInput{}).
MustImportAndCustomize(&Version, v3.LocalConfig{}, func(schema *types.Schema) {
schema.BaseType = "authConfig"
})
}