func (c *CodebaseController) Create(ctx *app.CreateCodebaseContext) error {
	_, err := login.ContextIdentity(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrUnauthorized(err.Error()))
	}
	var cb *codebase.Codebase
	err = application.Transactional(c.db, func(appl application.Application) error {
		cb, err = appl.Codebases().Load(ctx, ctx.CodebaseID)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, goa.ErrNotFound(err.Error()))
		}
		return nil
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrInternal(err.Error()))
	}
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrInternal(err.Error()))
	}
	cheClient := che.NewStarterClient(c.config.GetCheStarterURL(), c.config.GetOpenshiftTenantMasterURL(), getNamespace(ctx))
	workspace := che.WorkspaceRequest{
		Branch:     "master",
		Name:       "test2",
		StackID:    "java-default",
		Repository: cb.URL,
	}
	workspaceResp, err := cheClient.CreateWorkspace(ctx, workspace)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"codebase_id": cb.ID,
			"err":         err,
		}, "unable to create workspaces")
		if werr, ok := err.(*che.WorkspaceError); ok {
			fmt.Println(werr.String())
		}
		return jsonapi.JSONErrorResponse(ctx, goa.ErrInternal(err.Error()))
	}

	resp := &app.WorkspaceOpen{
		Links: &app.WorkspaceOpenLinks{
			Open: &workspaceResp.WorkspaceIDEURL,
		},
	}
	return ctx.OK(resp)
}
// Create runs the create action.
Create runs the create action.
// Create runs the create action .
func (c *CodebaseController) Create(ctx *app.CreateCodebaseContext) error {
	_, err := login.ContextIdentity(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrUnauthorized(err.Error()))
	}
	var cb *codebase.Codebase
	err = application.Transactional(c.db, func(appl application.Application) error {
		cb, err = appl.Codebases().Load(ctx, ctx.CodebaseID)
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, goa.ErrNotFound(err.Error()))
		}
		return nil
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrInternal(err.Error()))
	}
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrInternal(err.Error()))
	}
	cheClient := che.NewStarterClient(c.config.GetCheStarterURL(), c.config.GetOpenshiftTenantMasterURL(), getNamespace(ctx))
	workspace := che.WorkspaceRequest{
		Branch:     "master",
		Name:       "test2",
		StackID:    "java-default",
		Repository: cb.URL,
	}
	workspaceResp, err := cheClient.CreateWorkspace(ctx, workspace)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"codebase_id": cb.ID,
			"err":         err,
		}, "unable to create workspaces")
		if werr, ok := err.(*che.WorkspaceError); ok {
			fmt.Println(werr.String())
		}
		return jsonapi.JSONErrorResponse(ctx, goa.ErrInternal(err.Error()))
	}
	resp := &app.WorkspaceOpen{
		Links: &app.WorkspaceOpenLinks{
			Open: &workspaceResp.WorkspaceIDEURL,
		},
	}
	return ctx.OK(resp)
}
func ( c * CodebaseController ) Create ( ctx * app . CreateCodebaseContext ) error { _ , err := login . ContextIdentity ( ctx ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , goa . ErrUnauthorized ( err . Error ( ) ) ) } var cb * codebase . Codebase err = application . Transactional ( c . db , func ( appl application . Application ) error { cb , err = appl . Codebases ( ) . Load ( ctx , ctx . CodebaseID ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , goa . ErrNotFound ( err . Error ( ) ) ) } return nil } ) if err != nil { return jsonapi . JSONErrorResponse ( ctx , goa . ErrInternal ( err . Error ( ) ) ) } if err != nil { return jsonapi . JSONErrorResponse ( ctx , goa . ErrInternal ( err . Error ( ) ) ) } cheClient := che . NewStarterClient ( c . config . GetCheStarterURL ( ) , c . config . GetOpenshiftTenantMasterURL ( ) , getNamespace ( ctx ) ) workspace := che . WorkspaceRequest { Branch : " " , Name : " " , StackID : " " , Repository : cb . URL , } workspaceResp , err := cheClient . CreateWorkspace ( ctx , workspace ) if err != nil { log . Error ( ctx , map [ string ] interface { } { " " : cb . ID , " " : err , } , " " ) if werr , ok := err . ( * che . WorkspaceError ) ; ok { fmt . Println ( werr . String ( ) ) } return jsonapi . JSONErrorResponse ( ctx , goa . ErrInternal ( err . Error ( ) ) ) } resp := & app . WorkspaceOpen { Links : & app . WorkspaceOpenLinks { Open : & workspaceResp . WorkspaceIDEURL , } , } return ctx . OK ( resp ) }
Create runs the create action.
Create runs the create action .