hunk.code_window:   }
   }
   export async function getNamespaces(environmentId: EnvironmentId) {
     try {
       const { data: namespaces } = await axios.get<Namespaces>(
         buildUrl(environmentId)
       );
  
hunk.labels: keep keep add keep keep keep keep keep
hunk.after_edit: // getNamespaces is used to retrieve namespaces using the Portainer backend with caching
  
hunk.file_path: app/react/kubernetes/namespaces/service.ts
hunk.type: add
file: package stackbuilders
  
  import (
  	"errors"
  
  	httperror "github.com/portainer/libhttp/error"
  	"github.com/portainer/libhttp/request"
  	portainer "github.com/portainer/portainer/api"
  )
  
  type StackBuilderDirector struct {
  	builder interface{}
  }
  
  func NewStackBuilderDirector(b interface{}) *StackBuilderDirector {
  	return &StackBuilderDirector{
  		builder: b,
  	}
  }
  
  func (d *StackBuilderDirector) Build(payload *StackPayload, endpoint *portainer.Endpoint) (*portainer.Stack, *httperror.HandlerError) {
  
  	switch builder := d.builder.(type) {
  	case GitMethodStackBuildProcess:
  		return builder.SetGeneralInfo(payload, endpoint).
  			SetUniqueInfo(payload).
  			SetGitRepository(payload).
  			Deploy(payload, endpoint).
  			SetAutoUpdate(payload).
  			SaveStack()
  
  	case FileUploadMethodStackBuildProcess:
  		return builder.SetGeneralInfo(payload, endpoint).
  			SetUniqueInfo(payload).
  			SetUploadedFile(payload).
  			Deploy(payload, endpoint).
  			SaveStack()
  
  	case FileContentMethodStackBuildProcess:
  		return builder.SetGeneralInfo(payload, endpoint).
  			SetUniqueInfo(payload).
  			SetFileContent(payload).
  			Deploy(payload, endpoint).
  			SaveStack()
  
  	case UrlMethodStackBuildProcess:
  		return builder.SetGeneralInfo(payload, endpoint).
  			SetUniqueInfo(payload).
  			SetURL(payload).
  			Deploy(payload, endpoint).
  			SaveStack()
  	}
  
  	return nil, httperror.BadRequest("Invalid value for query parameter: method. Value must be one of: string or repository or url or file", errors.New(request.ErrInvalidQueryParameter))
  }
  