Documentation
¶
Overview ¶
Package onecli provides a client for the OneCLI API and utilities for mapping workspace secrets to OneCLI secret definitions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
CreateSecret(ctx context.Context, input CreateSecretInput) (*Secret, error)
UpdateSecret(ctx context.Context, id string, input UpdateSecretInput) error
ListSecrets(ctx context.Context) ([]Secret, error)
DeleteSecret(ctx context.Context, id string) error
GetContainerConfig(ctx context.Context) (*ContainerConfig, error)
CreateRule(ctx context.Context, input CreateRuleInput) (*Rule, error)
ListRules(ctx context.Context) ([]Rule, error)
DeleteRule(ctx context.Context, id string) error
// ConnectApp connects an app provider using the given credential fields.
ConnectApp(ctx context.Context, provider string, fields map[string]string) error
}
Client defines the contract for interacting with the OneCLI API.
type ContainerConfig ¶
type ContainerConfig struct {
Env map[string]string `json:"env"`
CACertificate string `json:"caCertificate"`
CACertificateContainerPath string `json:"caCertificateContainerPath"`
}
ContainerConfig holds the environment variables and CA certificate returned by the OneCLI /api/container-config endpoint.
type CreateRuleInput ¶
type CreateRuleInput struct {
Name string `json:"name"`
HostPattern string `json:"hostPattern"`
PathPattern string `json:"pathPattern,omitempty"`
Action string `json:"action"`
Enabled bool `json:"enabled"`
AgentID string `json:"agentId,omitempty"`
RateLimit int `json:"rateLimit,omitempty"`
RateLimitWindow string `json:"rateLimitWindow,omitempty"`
}
CreateRuleInput is the request body for creating a networking rule.
type CreateSecretInput ¶
type CreateSecretInput struct {
Name string `json:"name"`
Type string `json:"type"`
Value string `json:"value"`
HostPattern string `json:"hostPattern"`
PathPattern string `json:"pathPattern,omitempty"`
InjectionConfig *InjectionConfig `json:"injectionConfig,omitempty"`
}
CreateSecretInput is the request body for creating a secret.
type CredentialProvider ¶
type CredentialProvider interface {
// APIKey returns the OneCLI API key.
APIKey(ctx context.Context) (string, error)
}
CredentialProvider retrieves the OneCLI API key.
func NewCredentialProvider ¶
func NewCredentialProvider(baseURL string) CredentialProvider
NewCredentialProvider creates a CredentialProvider that retrieves the API key from the OneCLI web service at the given base URL. In local mode, the first call bootstraps the local user and generates the key.
type InjectionConfig ¶
type InjectionConfig struct {
HeaderName string `json:"headerName"`
ValueFormat string `json:"valueFormat,omitempty"`
}
InjectionConfig describes how a secret is injected into HTTP requests.
type Rule ¶
type Rule struct {
ID string `json:"id"`
Name string `json:"name"`
HostPattern string `json:"hostPattern"`
Action string `json:"action"`
Enabled bool `json:"enabled"`
}
Rule represents a networking rule returned by the OneCLI API.
type Secret ¶
type Secret struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
HostPattern string `json:"hostPattern"`
PathPattern *string `json:"pathPattern"`
InjectionConfig *InjectionConfig `json:"injectionConfig"`
CreatedAt string `json:"createdAt"`
}
Secret represents a secret returned by the OneCLI API.
type SecretMapper ¶
type SecretMapper interface {
Map(item secret.ListItem, value string) ([]CreateSecretInput, error)
}
SecretMapper converts stored secrets to OneCLI CreateSecretInput values.
func NewSecretMapper ¶
func NewSecretMapper(registry secretservice.Registry) SecretMapper
NewSecretMapper creates a SecretMapper that uses the given registry to look up secret service metadata for known secret types.
type SecretProvisioner ¶
type SecretProvisioner interface {
ProvisionSecrets(ctx context.Context, secrets []CreateSecretInput) error
}
SecretProvisioner creates or updates OneCLI secrets from a list of pre-mapped CreateSecretInput values.
func NewSecretProvisioner ¶
func NewSecretProvisioner(client Client) SecretProvisioner
NewSecretProvisioner creates a SecretProvisioner that uses the given client to create secrets.
type UpdateSecretInput ¶
type UpdateSecretInput struct {
Value *string `json:"value,omitempty"`
HostPattern *string `json:"hostPattern,omitempty"`
PathPattern *string `json:"pathPattern,omitempty"`
InjectionConfig *InjectionConfig `json:"injectionConfig,omitempty"`
}
UpdateSecretInput is the request body for updating a secret.