cmd

package
v0.50.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// IVCAP_CLI_CLIENT_ID is the public OAuth2 client id registered for the CLI
	// in ivcap-id's Hydra (compiled in; discovery's non-standard
	// ivcap_cli_client_id field is intentionally ignored).
	IVCAP_CLI_CLIENT_ID = "ivcap-cli"
	// OIDC_DISCOVERY_PATH is proxied by the platform gateway to ivcap-id and
	// returns absolute token/device/jwks endpoints.
	OIDC_DISCOVERY_PATH = "/.well-known/openid-configuration"
)
View Source
const (
	ENV_PREFIX = "IVCAP"
	URN_PREFIX = "ivcap"
)
View Source
const ArtifactInCollectionSchema = "urn:common:schema:in_collection.1"
View Source
const CHECK_VERSION_INTERVAL = time.Duration(24 * time.Hour)
View Source
const CONFIG_DIR_ENV = "IVCAP_CONFIG_DIR"

CONFIG_DIR_ENV overrides the directory holding config.yaml and history. It is used as-is (no "ivcap-cli" suffix is appended). Unlike XDG_CONFIG_HOME it is honoured on every OS, so tests and CI can reliably isolate the config.

View Source
const CONFIG_FILE_DIR = "ivcap-cli"

Names for config dir and file - stored in the os.UserConfigDir() directory unless CONFIG_DIR_ENV is set

View Source
const CONFIG_FILE_NAME = "config.yaml"
View Source
const CREATE_FROM_ASPECT = sdk.CreateFromAspectTemplate
View Source
const CollectionItemSchema = "urn:ivcap:schema:collection-item.1"

CollectionItemSchema is the aspect schema used to record that an item (artifact or other entity URN) is a member of a collection.

View Source
const CollectionSchema = "urn:ivcap:schema:collection.1"

CollectionSchema is the aspect schema used to store a collection definition (name + optional description).

View Source
const DEFAULT_SERVICE_TIMEOUT_IN_SECONDS = 30
View Source
const DEF_CHUNK_SIZE = 10000000 // -1 ... no chunking
View Source
const DEF_LIMIT = 10
View Source
const DEF_MAX_COLLECTION_ITEMS = 10
View Source
const HISTORY_FILE_NAME = "history.yaml"
View Source
const JOB_SCHEMA = "urn:ivcap:schema:job.2"
View Source
const MAX_NAME_COL_LEN = 30

Max characters to limit name to

View Source
const PROJECT_HEADER = adpt.ProjectHeader

PROJECT_HEADER carries the caller's selected project to the server-side resolver under the opaque-token flow (the CLI never mints project-scoped JWTs).

View Source
const RELEASE_CHECK_URL = "https://github.com/ivcap-works/ivcap-cli/releases/latest"
View Source
const VERSION_CHECK_FILE_NAME = "vcheck.txt"

Variables

View Source
var ACCESS_TOKEN_ENV = ENV_PREFIX + "_ACCESS_TOKEN"
View Source
var URN_CHECK = regexp.MustCompile(`urn:[A-Za-z0-9][A-Za-z0-9-]{2,}:[A-Za-z0-9()+,\-.:=@;$_!*']+`)

Functions

func CreateAdapter

func CreateAdapter(requiresAuth bool, opts ...adpt.Option) (adapter *adpt.Adapter)

func CreateAdapterWithTimeout

func CreateAdapterWithTimeout(requiresAuth bool, timeoutSec int, opts ...adpt.Option) (adapter *adpt.Adapter)

Returns an HTTP adapter which will wait a max. of `timeoutSec` sec for a reply. It also pre-configures the adapter in the following way:

  • If `requiresAuth` is set, each outgoing request includes an `Authorization` header with a 'Bearer' token provided either via the `--access-token` flag, the IVCAP_ACCESS_TOKEN environment, or the AccessToken from the ActiveContext.
  • If the `path` parameter for any of the adapter calls is NOT a fully fledged URL, the URL defined in ActiveContext is automatically prefixed.
  • If the ActiveContext defines a `Host` parameter, it is also added as a `Host` HTTP header.

func CreateDoc added in v0.35.0

func CreateDoc()

func Execute

func Execute(version string)

func GetConfigDir

func GetConfigDir(createIfNoExist bool) (configDir string)

func GetConfigFilePath

func GetConfigFilePath() (path string)

func GetHistory

func GetHistory(token string) (value string)

func GetIdentityAdapter added in v0.50.0

func GetIdentityAdapter(requiresAuth bool, opts ...adpt.Option) (adapter *adpt.Adapter)

GetIdentityAdapter builds an adapter targeting the identity server (id.<domain>) that never forwards the current project (PROJECT_HEADER). Use it for calls to ivcap-accounts: that service authorizes on the caller identity plus the resource id in the request path/body and never reads the token's project scope, so forwarding a stale current-project would only make the resolver request a project-scoped token whose membership check fails — a spurious 401 for an operation that would otherwise succeed.

func GetServiceNameForId

func GetServiceNameForId(serviceID *string) string

func IsAuthorised

func IsAuthorised() bool

func Logger

func Logger() *log.Logger

func MakeHistory

func MakeHistory(urn *string) string

func MakeMaybeHistory

func MakeMaybeHistory(sp *string) string

Check if argument is an IVCAP urn and if it is, turn it into a history.

func NewAdapter

func NewAdapter(
	url string,
	accessToken string,
	timeoutSec int,
	headers *map[string]string,
	opts ...adpt.Option,
) (*adpt.Adapter, error)

func NewTimeoutContext

func NewTimeoutContext() (ctxt context.Context, cancel context.CancelFunc)

func ParseIDToken

func ParseIDToken(tokenResponse *deviceTokenResponse, ctxt *Context, jwksURL string)

func SetContext

func SetContext(ctxt *Context, failIfNotExist bool)

func SetLogger

func SetLogger(l *log.Logger)

func WrapSoftSoft added in v0.41.8

func WrapSoftSoft(str string, wrapLen int) string

func WriteConfigFile

func WriteConfigFile(config *Config)

Types

type AgentContextDoc added in v0.47.2

type AgentContextDoc struct {
	// Path is a stable, repo-like path for tooling.
	Path string `json:"path" yaml:"path"`

	// SHA256 is the hex digest of the full file content.
	SHA256 string `json:"sha256" yaml:"sha256"`

	// Content is the embedded markdown.
	Content string `json:"content" yaml:"content"`
}

type AppError

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

func (*AppError) Error

func (e *AppError) Error() string

type ArtifactInCollection

type ArtifactInCollection struct {
	ArtifactID   string `json:"artifact"`
	CollectionID string `json:"collection"`
}

type ArtifactPostResponse

type ArtifactPostResponse struct {
	// Artifact ID
	ID string `form:"id" json:"id" xml:"id"`
	// Optional name
	Name string `form:"name,omitempty" json:"name,omitempty" xml:"name,omitempty"`
	// Artifact status
	Status string `form:"status" json:"status" xml:"status"`
	// Mime-type of data
	MimeType string `form:"mime-type,omitempty" json:"mime-type,omitempty" xml:"mime-type,omitempty"`
	// Size of data
	Size int64 `form:"size,omitempty" json:"size,omitempty" xml:"size,omitempty"`
}

type AuthInfo

type AuthInfo struct {
	Version      int              `yaml:"version"`
	ProviderList AuthProviderInfo `yaml:"auth"`
}

type AuthProvider

type AuthProvider struct {
	ID       string `yaml:"id,omitempty"`
	LoginURL string `yaml:"login-url"`
	TokenURL string `yaml:"token-url"`
	CodeURL  string `yaml:"code-url"`
	JwksURL  string `yaml:"jwks-url"`
	ClientID string `yaml:"client-id"`
	Audience string `yaml:"audience"`
	// contains filtered or unexported fields
}

type AuthProviderInfo

type AuthProviderInfo struct {
	DefaultProviderId string                  `yaml:"default-provider-id"`
	AuthProviders     map[string]AuthProvider `yaml:"providers"`
}

type CaddyFaultResponse

type CaddyFaultResponse struct {
	Name      string
	Id        string
	Message   string
	Temporary bool
	Timeout   bool
	Fault     bool
}

type CollectionDef added in v0.47.6

type CollectionDef struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

CollectionDef is the content body for the collection definition aspect.

type CollectionItem added in v0.47.6

type CollectionItem struct {
	Collection string `json:"collection"`
	Item       string `json:"item"`
}

CollectionItem is the content body for each collection-item aspect.

type Config

type Config struct {
	Version       string    `yaml:"version"`
	ActiveContext string    `yaml:"active-context"`
	Contexts      []Context `yaml:"contexts"`
}

func ReadConfigFile

func ReadConfigFile(createIfNoConfig bool) (config *Config, configFile string)

type Context

type Context struct {
	ApiVersion int    `yaml:"api-version"`
	Name       string `yaml:"name"`
	URL        string `yaml:"url"`
	// IdentityURL is the base URL of the identity server (https://id.<domain>).
	// Set at context creation; older contexts derive it from URL at runtime.
	IdentityURL string `yaml:"identity-url,omitempty"`
	// AccountID holds the account of the currently selected project (set by
	// `project use`); under the new auth flow it is no longer sourced from a token.
	AccountID string `yaml:"account-id"`
	Host      string `yaml:"host"` // set Host header if necessary

	// Auth mode / OIDC (opaque-token "Model B" flow)
	AuthMode  string `yaml:"auth-mode,omitempty"`  // "oidc" | "legacy"
	IssuerURL string `yaml:"issuer-url,omitempty"` // OIDC issuer recorded at login
	IDToken   string `yaml:"id-token,omitempty"`   // raw id_token JWT for local claim display

	// CurrentProject is forwarded to the server-side resolver via PROJECT_HEADER.
	CurrentProject string `yaml:"current-project,omitempty"`
	// Display names saved by `project use`, so `context current` can show them
	// without a network call. They can go stale if renamed elsewhere.
	CurrentProjectName string `yaml:"current-project-name,omitempty"`
	CurrentAccountName string `yaml:"current-account-name,omitempty"`

	// User Information
	AccountName     string `yaml:"account-name"`
	AccountNickName string `yaml:"account-nickname"`
	Email           string `yaml:"email"`

	// Cached Credentials
	AccessToken       string    `yaml:"access-token"`
	AccessTokenExpiry time.Time `yaml:"access-token-expiry"`
	RefreshToken      string    `yaml:"refresh-token"`
}

func GetActiveContext

func GetActiveContext() (ctxt *Context)

func GetContext

func GetContext(name string, defaultToActiveContext bool) (ctxt *Context)

func GetContextWithError

func GetContextWithError(name string, defaultToActiveContext bool) (ctxt *Context, err error)

type CustomIdClaims

type CustomIdClaims struct {
	Name          string   `json:"name,omitempty"`
	Nickname      string   `json:"nickname,omitempty"`
	Email         string   `json:"email,omitempty"`
	EmailVerified bool     `json:"email_verified,omitempty"`
	Avatar        string   `json:"picture,omitempty"`
	GroupIDs      []string `json:"ivcap/claims/groupIds,omitempty"`
	jwt.RegisteredClaims
}

type DeviceCode

type DeviceCode struct {
	DeviceCode              string `json:"device_code"`
	UserCode                string `json:"user_code"`
	VerificationURL         string `json:"verification_uri"`
	VerificationURLComplete string `json:"verification_uri_complete"`
	ExpiresIn               int64  `json:"expires_in"`
	Interval                int64  `json:"interval"`
}

type Flag added in v0.35.0

type Flag int64
const (
	Name Flag = iota
	Schema
	SchemaPrefix
	Entity
	InputFormat
	Policy
	Account
	AtTime
	File
)

type ManifestEntry added in v0.47.5

type ManifestEntry struct {
	Name     string
	Size     int64
	MimeType string
	Path     string
}

ManifestEntry represents a row from MANIFEST.csv

type OIDCDiscovery added in v0.50.0

type OIDCDiscovery struct {
	Issuer                      string `json:"issuer"`
	TokenEndpoint               string `json:"token_endpoint"`
	DeviceAuthorizationEndpoint string `json:"device_authorization_endpoint"`
	JwksURI                     string `json:"jwks_uri"`
}

OIDCDiscovery is the subset of the OIDC discovery document the CLI needs. The endpoints are absolute URLs (rewritten by ivcap-id to point at itself).

Jump to

Keyboard shortcuts

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