// Create a new project, either by creating a `project.openshift.io` resource if supported by the cluster
// (which will trigger the creation of a namespace),
// or by creating directly a `namespace` resource.
// With the `wait` flag, the function will wait for the `default` service account
// to be created in the namespace before to return.
Create a new project, either by creating a `project.openshift.io` resource if supported by the cluster
(which will trigger the creation of a namespace),
or by creating directly a `namespace` resource.
With the `wait` flag, the function will wait for the `default` service account
to be created in the namespace before to return.
// Create a new project either by creating a ` project . openshift . io ` resource if supported by the cluster // ( which will trigger the creation of a namespace ) // or by creating directly a ` namespace ` resource . // With the ` wait ` flag the function will wait for the ` default ` service account // to be created in the namespace before to return .
func Create(context *genericclioptions.Context, projectName string, wait bool) error {
	if projectName == "" {
		return errors.Errorf("no project name given")
	}
	projectSupport, err := context.Client.IsProjectSupported()
	if err != nil {
		return errors.Wrap(err, "unable to detect project support")
	}
	if projectSupport {
		err := context.Client.CreateNewProject(projectName, wait)
		if err != nil {
			return errors.Wrap(err, "unable to create new project")
		}
	} else {
		_, err := context.KClient.CreateNamespace(projectName)
		if err != nil {
			return errors.Wrap(err, "unable to create new project")
		}
	}
	if wait {
		err = context.KClient.WaitForServiceAccountInNamespace(projectName, "default")
		if err != nil {
			return errors.Wrap(err, "unable to wait for service account")
		}
	}
	return nil
}
func Create ( context * genericclioptions . Context , projectName string , wait bool ) error { if projectName == " " { return errors . Errorf ( " " ) } projectSupport , err := context . Client . IsProjectSupported ( ) if err != nil { return errors . Wrap ( err , " " ) } if projectSupport { err := context . Client . CreateNewProject ( projectName , wait ) if err != nil { return errors . Wrap ( err , " " ) } } else { _ , err := context . KClient . CreateNamespace ( projectName ) if err != nil { return errors . Wrap ( err , " " ) } } if wait { err = context . KClient . WaitForServiceAccountInNamespace ( projectName , " " ) if err != nil { return errors . Wrap ( err , " " ) } } return nil }
Create a new project, either by creating a `project.openshift.io` resource if supported by the cluster
(which will trigger the creation of a namespace),
or by creating directly a `namespace` resource.
Create a new project either by creating a ` project . openshift . io ` resource if supported by the cluster ( which will trigger the creation of a namespace ) or by creating directly a ` namespace ` resource .