util

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEnvOfServiceParam

func AddEnvOfServiceParam(cmd *cobra.Command, id *string)

func AddEnvParam

func AddEnvParam(cmd *cobra.Command, id *string)

AddEnvParam todo: support name

func AddProjectParam

func AddProjectParam(cmd *cobra.Command, id, name *string)

func AddServiceParam

func AddServiceParam(cmd *cobra.Command, id, name *string)

func GetProjectByName

func GetProjectByName(client api.Client, ownerID, personalUsername, projectName string) (*model.Project, error)

GetProjectByName resolves a project by name within the active workspace.

  • Personal workspace (ownerID == ""): uses the cheap `project(owner: $personalUsername, name: $projectName)` query against the caller's account.
  • Team workspace (ownerID != ""): there is no `project(ownerID, name)` query, so walk the owner's project list and match by name locally.

Without the team branch a `--name`-based lookup in a team workspace would silently fall through to the caller's personal account — either failing to find the project, or worse, returning a same-named personal project instead of the intended team one. The personal path is unchanged, so existing personal-workspace callers see no behavior change.

func GetServiceByName

func GetServiceByName(client api.Client, ownerID, personalUsername, projectName, projectID, serviceName string) (*model.Service, error)

GetServiceByName resolves a service by name within the active workspace.

  • Personal workspace (ownerID == ""): uses the cheap `service(owner, projectName, name)` query.
  • Team workspace (ownerID != ""): the personal query keys on the caller's username and would silently look at the personal account. Use the project-scoped `ListAllServices(projectID)` and match by name locally — projectID is unique across owners and team-safe.

In a team workspace the caller must have a project context (projectID), because services have no top-level owner-scoped lookup and a service name is only unique within a project. Personal path is unchanged.

func PackZip

func PackZip() ([]byte, string, error)

func PackZipWithoutGitIgnoreFiles

func PackZipWithoutGitIgnoreFiles() ([]byte, error)

func ResolveEnvironmentID added in v0.5.8

func ResolveEnvironmentID(client api.Client, projectID string) (string, error)

ResolveEnvironmentID resolves the environment ID from the project ID by listing environments and returning the first one. Every project has exactly one environment since environments are deprecated.

func ResolveEnvironmentIDByServiceID added in v0.6.0

func ResolveEnvironmentIDByServiceID(client api.Client, serviceID string) (string, error)

ResolveEnvironmentIDByServiceID fetches the service, finds its project, and resolves the environment ID from that project.

Types

type CobraRunE

type CobraRunE func(cmd *cobra.Command, args []string) error

func DefaultIDNameByContext

func DefaultIDNameByContext(basicInfoFn func() zcontext.BasicInfo, id, name *string) CobraRunE

DefaultIDNameByContext returns a Cobra PreRunE that auto-fills `id` and `name` from the resource the supplied closure returns, provided both are empty. Useful for commands like `project get/delete` that should default to "whatever the user has pinned" when invoked with no flags.

The argument is a closure rather than the BasicInfo directly so the resolution happens at PreRunE time (after global flags are parsed), not at Cobra command construction time. This matters for PLA-1590: `--workspace` only takes effect after PersistentPreRunE runs, so a caller passing `f.EffectiveContext().GetProject()` directly would capture the persisted project, not the override-aware empty.

func RunEChain

func RunEChain(chains ...CobraRunE) CobraRunE

RunEChain runs a chain of CobraRunE functions

Jump to

Keyboard shortcuts

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