Help us shape the future of Go! Take the 2026 Go Developer Survey

project

package
v0.48.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package project resolves and persists the currently selected Volcano project.

Index

Constants

View Source
const CloudEnvRelPath = "volcano/cloud.env"

CloudEnvRelPath is the env file cloud deploys read, as `volcano init` names it. `volcano connect` writes the project's API URL and anon key to it.

Variables

View Source
var ErrNotFound = errors.New("project not found")

ErrNotFound reports that no project matched an ID or name.

Functions

func CheckProjectOverride added in v0.48.0

func CheckProjectOverride(cfg *config.Config, selectedID string, link *config.Link) error

CheckProjectOverride refuses to relink a directory while VOLCANO_PROJECT_ID names a project other than selectedID. Commands would keep running against that project, and the cloud env file would deploy the selected project's anon key to it.

func CloudEnvPath added in v0.48.0

func CloudEnvPath(dir string) string

CloudEnvPath is the cloud env file in dir.

func DefaultAnonKey added in v0.48.0

func DefaultAnonKey(ctx context.Context, client *api.Client, projectID uuid.UUID) (string, error)

DefaultAnonKey returns the project's default anon key, the publishable key the SDK and frontends use. It creates one only when the project has none. The API lists the newest keys first, so the default, usually the oldest, can be on the last page.

func Find added in v0.31.0

func Find(ctx context.Context, client *api.Client, identifier string) (*apiclient.Project, error)

Find scans every project the credential can see for an exact ID or name match. Only an account token can list projects, so callers establish that before calling; a project access token earns a 403 here.

func Link(dir string, project *apiclient.Project) (*config.Link, error)

Link links dir to project, so commands run inside dir use it.

func WriteCloudEnv added in v0.48.0

func WriteCloudEnv(dir, apiURL, anonKey string) error

WriteCloudEnv sets the project's API URL and anon key in dir's cloud env file, keeping every other line. It creates the file when it is missing. The URL is written without userinfo, query or fragment: a Next.js build puts NEXT_PUBLIC_VOLCANO_API_URL in browser code.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service performs authenticated Volcano project workflows.

func NewService

func NewService(deps cliruntime.Deps) Service

NewService returns a project service.

func (Service) Create

func (s Service) Create(ctx context.Context, name, templateID string) (*apiclient.Project, error)

Create creates a project for the authenticated user.

func (Service) CreateAnonKey added in v0.34.0

func (s Service) CreateAnonKey(ctx context.Context, projectID, name string) (*apiclient.AnonKey, error)

CreateAnonKey creates a publishable key for the selected project.

func (Service) CreateServiceKey added in v0.34.0

func (s Service) CreateServiceKey(ctx context.Context, projectID, name string, permissions []string) (*apiclient.ServiceKey, error)

CreateServiceKey creates a service key in the selected project. An empty permissions slice is passed through as omitted so the server's full-access default remains authoritative.

func (Service) CurrentTarget added in v0.46.0

func (s Service) CurrentTarget(ctx context.Context) (Target, error)

CurrentTarget resolves the current project, and its name when the API or the saved selection has one. A missing name is not an error.

func (Service) Delete

func (s Service) Delete(ctx context.Context, projectID string) error

Delete starts asynchronous project deletion by ID.

func (Service) DeploymentsSince added in v0.46.0

func (s Service) DeploymentsSince(ctx context.Context, since time.Time) ([]apiclient.ProjectDeployment, error)

DeploymentsSince lists the current project's function and frontend deployments created at or after since.

func (Service) Get

func (s Service) Get(ctx context.Context, projectID string) (*apiclient.Project, error)

Get returns one authenticated project by ID.

func (Service) GetServiceKey added in v0.34.0

func (s Service) GetServiceKey(ctx context.Context, projectID, keyID string) (*apiclient.ServiceKey, error)

GetServiceKey returns one service key by ID for the selected project.

func (Service) List

func (s Service) List(ctx context.Context, page, limit int) (*config.Config, *apiclient.PaginatedProjects, error)

List returns the authenticated config and one visible project page.

func (Service) ListAnonKeys added in v0.5.0

func (s Service) ListAnonKeys(ctx context.Context, projectID string) ([]apiclient.AnonKey, error)

ListAnonKeys returns a project's anon keys (the publishable frontend/SDK keys). projectID may be empty to use the currently selected project.

func (Service) ListServiceKeys added in v0.34.0

func (s Service) ListServiceKeys(ctx context.Context, projectID string, page, limit int) (*apiclient.PaginatedServiceKeys, error)

ListServiceKeys returns one page of service keys for the selected project, or for projectID when it is explicitly provided.

func (Service) Rename added in v0.25.0

func (s Service) Rename(ctx context.Context, projectID, name string) (*apiclient.Project, error)

Rename changes a project's name and refreshes the saved active project.

func (Service) RequireAccountToken added in v0.31.0

func (s Service) RequireAccountToken() error

RequireAccountToken reports whether the configured credential can run the account-scoped project commands. Renaming and deleting a project are pk-only server-side, and a destructive command has to refuse before it asks the user to confirm something the CLI already knows cannot happen.

func (Service) SourceMode added in v0.46.0

SourceMode reports whether the current project deploys from Volcano (platform) or from its connected repository. A server without source export has no repository mode, so it reports platform.

func (Service) Usage added in v0.34.0

func (s Service) Usage(ctx context.Context, projectID string) (*apiclient.ProjectUsageResponse, error)

Usage returns aggregate usage for the selected project, or projectID when it is explicitly provided.

func (Service) Use

func (s Service) Use(ctx context.Context, identifier string) (UseResult, error)

Use sets the active project by exact ID or exact name. Inside a linked directory it updates the link, which would otherwise keep overriding the selection, and rewrites the anon key `volcano connect` wrote to the directory's cloud env file; elsewhere it saves the global selection.

type Target added in v0.46.0

type Target struct {
	ID uuid.UUID
	// Name is empty when the project could not be read by name.
	Name string
}

Target is the project a command acts on.

type UseResult added in v0.48.0

type UseResult struct {
	Project *apiclient.Project
	// SavedTo is where the selection was saved.
	SavedTo string
	// Previous is the project the link named before Use changed it. It is nil
	// outside a linked directory, and when the link already named the project.
	Previous *config.ProjectConfig
	// EnvFile is the linked directory's cloud env file when Use rewrote it for
	// the project, or tried to and failed with EnvErr. It is "" otherwise.
	EnvFile string
	// EnvErr is why EnvFile could not be rewritten. The selection is saved
	// either way.
	EnvErr error
}

UseResult is what Use changed.

func SelectInLink(ctx context.Context, client *api.Client, apiURL string, link *config.Link, selected *apiclient.Project) (UseResult, error)

SelectInLink links link's directory to selected and, when the project changes, rewrites the anon key `volcano connect` wrote to the directory's cloud env file, as Use does inside a linked directory. client and apiURL reach selected's API. Callers run CheckProjectOverride first.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL