1
0
mirror of https://github.com/rancher/types.git synced 2025-06-28 22:46:49 +00:00

Add Import Yaml Action and types

Import action for project and cluster
New struct:
1. ImportClusterYamlInput
2. ImportProjectYamlInput
3. ImportYamlOutput
This commit is contained in:
Yuxing 2018-04-16 17:05:03 +08:00 committed by Darren Shepherd
parent 18af11c49a
commit 49e0df4b2f
8 changed files with 139 additions and 0 deletions

View File

@ -238,3 +238,16 @@ type ClusterRegistrationTokenStatus struct {
type GenerateKubeConfigOutput struct {
Config string `json:"config"`
}
type ImportClusterYamlInput struct {
Yaml string `json:"yaml,omitempty"`
}
type ImportProjectYamlInput struct {
Yaml string `json:"yaml,omitempty"`
Namespace string `json:"namespace,omitempty"`
}
type ImportYamlOutput struct {
OutputMessage string `json:"outputMessage,omitempty"`
}

View File

@ -139,6 +139,8 @@ func clusterTypes(schemas *types.Schemas) *types.Schemas {
MustImport(&Version, v3.ClusterEvent{}).
MustImport(&Version, v3.ClusterRegistrationToken{}).
MustImport(&Version, v3.GenerateKubeConfigOutput{}).
MustImport(&Version, v3.ImportClusterYamlInput{}).
MustImport(&Version, v3.ImportYamlOutput{}).
MustImportAndCustomize(&Version, v3.Cluster{}, func(schema *types.Schema) {
schema.MustCustomizeField("name", func(field types.Field) types.Field {
field.Type = "dnsLabel"
@ -149,6 +151,10 @@ func clusterTypes(schemas *types.Schemas) *types.Schemas {
schema.ResourceActions["generateKubeconfig"] = types.Action{
Output: "generateKubeConfigOutput",
}
schema.ResourceActions["importYaml"] = types.Action{
Input: "importClusterYamlInput",
Output: "importYamlOutput",
}
})
}
@ -166,12 +172,18 @@ func authzTypes(schemas *types.Schemas) *types.Schemas {
&mapper.NamespaceIDMapper{},
).
MustImport(&Version, v3.SetPodSecurityPolicyTemplateInput{}).
MustImport(&Version, v3.ImportProjectYamlInput{}).
MustImport(&Version, v3.ImportYamlOutput{}).
MustImportAndCustomize(&Version, v3.Project{}, func(schema *types.Schema) {
schema.ResourceActions = map[string]types.Action{
"setpodsecuritypolicytemplate": {
Input: "setPodSecurityPolicyTemplateInput",
Output: "project",
},
"importYaml": {
Input: "importProjectYamlInput",
Output: "importYamlOutput",
},
}
}).
MustImport(&Version, v3.GlobalRole{}).

View File

@ -368,6 +368,18 @@ func RegisterDeepCopies(scheme *runtime.Scheme) error {
in.(*HealthCheck).DeepCopyInto(out.(*HealthCheck))
return nil
}, InType: reflect.TypeOf(&HealthCheck{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*ImportClusterYamlInput).DeepCopyInto(out.(*ImportClusterYamlInput))
return nil
}, InType: reflect.TypeOf(&ImportClusterYamlInput{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*ImportProjectYamlInput).DeepCopyInto(out.(*ImportProjectYamlInput))
return nil
}, InType: reflect.TypeOf(&ImportProjectYamlInput{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*ImportYamlOutput).DeepCopyInto(out.(*ImportYamlOutput))
return nil
}, InType: reflect.TypeOf(&ImportYamlOutput{})},
conversion.GeneratedDeepCopyFunc{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*ImportedConfig).DeepCopyInto(out.(*ImportedConfig))
return nil
@ -3195,6 +3207,54 @@ func (in *HealthCheck) DeepCopy() *HealthCheck {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ImportClusterYamlInput) DeepCopyInto(out *ImportClusterYamlInput) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImportClusterYamlInput.
func (in *ImportClusterYamlInput) DeepCopy() *ImportClusterYamlInput {
if in == nil {
return nil
}
out := new(ImportClusterYamlInput)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ImportProjectYamlInput) DeepCopyInto(out *ImportProjectYamlInput) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImportProjectYamlInput.
func (in *ImportProjectYamlInput) DeepCopy() *ImportProjectYamlInput {
if in == nil {
return nil
}
out := new(ImportProjectYamlInput)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ImportYamlOutput) DeepCopyInto(out *ImportYamlOutput) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImportYamlOutput.
func (in *ImportYamlOutput) DeepCopy() *ImportYamlOutput {
if in == nil {
return nil
}
out := new(ImportYamlOutput)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ImportedConfig) DeepCopyInto(out *ImportedConfig) {
*out = *in

View File

@ -99,6 +99,8 @@ type ClusterOperations interface {
Delete(container *Cluster) error
ActionGenerateKubeconfig(*Cluster) (*GenerateKubeConfigOutput, error)
ActionImportYaml(*Cluster, *ImportClusterYamlInput) (*ImportYamlOutput, error)
}
func newClusterClient(apiClient *Client) *ClusterClient {
@ -154,3 +156,12 @@ func (c *ClusterClient) ActionGenerateKubeconfig(resource *Cluster) (*GenerateKu
return resp, err
}
func (c *ClusterClient) ActionImportYaml(resource *Cluster, input *ImportClusterYamlInput) (*ImportYamlOutput, error) {
resp := &ImportYamlOutput{}
err := c.apiClient.Ops.DoAction(ClusterType, "importYaml", &resource.Resource, input, resp)
return resp, err
}

View File

@ -0,0 +1,10 @@
package client
const (
ImportClusterYamlInputType = "importClusterYamlInput"
ImportClusterYamlInputFieldYaml = "yaml"
)
type ImportClusterYamlInput struct {
Yaml string `json:"yaml,omitempty" yaml:"yaml,omitempty"`
}

View File

@ -0,0 +1,12 @@
package client
const (
ImportProjectYamlInputType = "importProjectYamlInput"
ImportProjectYamlInputFieldNamespace = "namespace"
ImportProjectYamlInputFieldYaml = "yaml"
)
type ImportProjectYamlInput struct {
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
Yaml string `json:"yaml,omitempty" yaml:"yaml,omitempty"`
}

View File

@ -0,0 +1,10 @@
package client
const (
ImportYamlOutputType = "importYamlOutput"
ImportYamlOutputFieldOutputMessage = "outputMessage"
)
type ImportYamlOutput struct {
OutputMessage string `json:"outputMessage,omitempty" yaml:"outputMessage,omitempty"`
}

View File

@ -60,6 +60,8 @@ type ProjectOperations interface {
ByID(id string) (*Project, error)
Delete(container *Project) error
ActionImportYaml(*Project, *ImportProjectYamlInput) (*ImportYamlOutput, error)
ActionSetpodsecuritypolicytemplate(*Project, *SetPodSecurityPolicyTemplateInput) (*Project, error)
}
@ -108,6 +110,15 @@ func (c *ProjectClient) Delete(container *Project) error {
return c.apiClient.Ops.DoResourceDelete(ProjectType, &container.Resource)
}
func (c *ProjectClient) ActionImportYaml(resource *Project, input *ImportProjectYamlInput) (*ImportYamlOutput, error) {
resp := &ImportYamlOutput{}
err := c.apiClient.Ops.DoAction(ProjectType, "importYaml", &resource.Resource, input, resp)
return resp, err
}
func (c *ProjectClient) ActionSetpodsecuritypolicytemplate(resource *Project, input *SetPodSecurityPolicyTemplateInput) (*Project, error) {
resp := &Project{}