func (o *PipelineCreateOption) GetDevOpsNamespaceList() (names []string, err error) {
	names, err = o.getUnstructuredNameList(true, []string{}, types.GetDevOpsProjectSchema())
	return
}
GetDevOpsNamespaceList returns a DevOps namespace list
package option
import (
	"bytes"
	"context"
	"fmt"
	"github.com/AlecAivazis/survey/v2"
	"github.com/Masterminds/sprig"
	"github.com/Pallinder/go-randomdata"
	"github.com/kubesphere-sigs/ks/kubectl-plugin/pipeline/tpl"
	"github.com/kubesphere-sigs/ks/kubectl-plugin/types"
	"github.com/spf13/cobra"
	"html/template"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/apimachinery/pkg/runtime/schema"
	"k8s.io/client-go/dynamic"
	"strings"
)
type PipelineCreateOption struct {
	Workspace   string
	Project     string
	Name        string
	Jenkinsfile string
	Template    string
	Type        string
	SCMType     string
	Batch       bool
	SkipCheck   bool
	Client       dynamic.Interface
	WorkspaceUID string
}
func (o *PipelineCreateOption) Wizard(_ *cobra.Command, _ []string) (err error) {
	if o.Batch {
		return
	}
	if o.Workspace == "" {
		var wsNames []string
		if wsNames, err = o.GetWorkspaceTemplateNameList(); err == nil {
			if o.Workspace, err = ChooseObjectFromArray("workspace name", wsNames); err != nil {
				return
			}
		} else {
			return
		}
	}
	if o.Project == "" {
		var projectNames []string
		if projectNames, err = o.getDevOpsProjectNameList(); err == nil {
			if o.Project, err = ChooseObjectFromArray("project name", projectNames); err != nil {
				return
			}
		} else {
			return
		}
	}
	if o.Template == "" {
		if o.Template, err = ChooseOneFromArray(tpl.GetAllTemplates()); err != nil {
			return
		}
	}
	if o.Name == "" {
		defaultVal := fmt.Sprintf("%s-%s", o.Template, strings.ToLower(randomdata.SillyName()))
		if o.Name, err = getInput("Please input the Pipeline name", defaultVal); err != nil {
			return
		}
	}
	return
}
func ChooseObjectFromArray(object string, options []string) (result string, err error) {
	prompt := &survey.Select{
		Message: fmt.Sprintf("Please select %s:", object),
		Options: options,
	}
	err = survey.AskOne(prompt, &result)
	return
}
func ChooseOneFromArray(options []string) (result string, err error) {
	result, err = ChooseObjectFromArray("", options)
	return
}
func getInput(title, defaultVal string) (result string, err error) {
	prompt := &survey.Input{
		Message: title,
		Default: defaultVal,
	}
	err = survey.AskOne(prompt, &result)
	return
}
func (o *PipelineCreateOption) ParseTemplate() (err error) {
	switch o.Template {
	case "":
	case "java":
		o.Jenkinsfile = tpl.GetBuildJava()
	case "go":
		o.Jenkinsfile = tpl.GetBuildGo()
	case "simple":
		o.Jenkinsfile = tpl.GetSimple()
	case "parameter":
		o.Jenkinsfile = tpl.GetParameter()
	case "longRun":
		o.Jenkinsfile = tpl.GetLongRunPipeline()
	case "parallel":
		o.Jenkinsfile = tpl.GetParallel()
	case "multi-branch-git":
		o.Type = "multi-branch-pipeline"
		o.SCMType = "git"
	case "multi-branch-gitlab":
		o.Type = "multi-branch-pipeline"
		o.SCMType = "gitlab"
	case "multi-branch-github":
		o.Type = "multi-branch-pipeline"
		o.SCMType = "github"
	default:
		err = fmt.Errorf("%s is not support", o.Template)
	}
	o.Jenkinsfile = strings.TrimSpace(o.Jenkinsfile)
	return
}
func (o *PipelineCreateOption) CreatePipeline() (err error) {
	ctx := context.TODO()
	var wdID string
	if !o.SkipCheck {
		var ws *unstructured.Unstructured
		if ws, err = o.CheckWorkspace(); err != nil {
			return
		}
		wdID = string(ws.GetUID())
	}
	var project *unstructured.Unstructured
	if project, err = o.CheckDevOpsProject(wdID); err != nil {
		return
	}
	o.Project = project.GetName()  
	var rawPip *unstructured.Unstructured
	if rawPip, err = o.createPipelineObj(); err == nil {
		if rawPip, err = o.Client.Resource(types.GetPipelineSchema()).Namespace(o.Project).Create(ctx, rawPip, metav1.CreateOptions{}); err != nil {
			err = fmt.Errorf("failed to create Pipeline, %v", err)
		}
	}
	return
}