1
0
mirror of https://github.com/rancher/types.git synced 2025-08-31 21:00:16 +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

@@ -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{}