op

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ItemIDNotesPlain    = "notesPlain"
	ItemFieldTypeString = "STRING"

	ItemPurposeNotes = "NOTES"

	ItemLabelNotesPlain = "notesPlain"
)
View Source
const (
	VaultItemCategoryAPICredential = "API Credential"
)

Variables

This section is empty.

Functions

func ValidateIdentifier added in v0.1.3

func ValidateIdentifier(kind, name string) error

ValidateIdentifier checks that name is a non-empty identifier that matches the allowlist. kind is included in the error so callers can tell which argument was rejected (e.g. "vault", "item").

Types

type Client

type Client interface {
	GetVault(ctx context.Context,
		vaultName string,
	) (Vault, error)
	GetVaultItem(ctx context.Context,
		vaultName string,
		itemName string,
	) (Item, error)
	ListVaultItems(ctx context.Context,
		vaultName string,
	) ([]Item, error)
}

type CommandBuilder

type CommandBuilder struct {
	Format string
	Item   *ItemCommandBuilder
	Vault  *VaultCommandBuilder
}

func NewCommandBuilder

func NewCommandBuilder() *CommandBuilder

func (*CommandBuilder) Build

func (c *CommandBuilder) Build() []string

func (*CommandBuilder) WithItem

func (c *CommandBuilder) WithItem(item *ItemCommandBuilder) *CommandBuilder

func (*CommandBuilder) WithJSONFormat

func (c *CommandBuilder) WithJSONFormat() *CommandBuilder

func (*CommandBuilder) WithVault

func (c *CommandBuilder) WithVault(vault *VaultCommandBuilder) *CommandBuilder

type CommandClient

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

func (*CommandClient) GetVault

func (c *CommandClient) GetVault(ctx context.Context, vaultName string) (Vault, error)

GetVault implements Client.

func (*CommandClient) GetVaultItem

func (c *CommandClient) GetVaultItem(ctx context.Context, vaultName string, itemName string) (Item, error)

GetVaultItem implements Client. 同一 vault/item への呼び出しは memoize され、op サブプロセスの起動は クライアントの生存期間中 1 回に抑えられる。エラーはキャッシュされず、 次の呼び出しで再試行される。

func (*CommandClient) ListVaultItems

func (c *CommandClient) ListVaultItems(ctx context.Context, vaultName string) ([]Item, error)

type FakeClient

type FakeClient struct {
	Vaults map[string][]Item
}

func NewFakeClient

func NewFakeClient() *FakeClient

func (*FakeClient) GetVault

func (f *FakeClient) GetVault(ctx context.Context, vaultName string) (Vault, error)

GetVault implements Client.

func (*FakeClient) GetVaultItem

func (f *FakeClient) GetVaultItem(ctx context.Context, vaultName string, itemName string) (Item, error)

GetVaultItem implements Client.

func (*FakeClient) ListVaultItems

func (f *FakeClient) ListVaultItems(ctx context.Context, vaultName string) ([]Item, error)

ListVaultItems implements Client.

type Item

type Item struct {
	ID           string        `json:"id,omitempty"`
	Title        string        `json:"title,omitempty"`
	Version      int           `json:"version,omitempty"`
	Vault        Vault         `json:"vault,omitempty"`
	Category     string        `json:"category,omitempty"`
	LastEditedBy string        `json:"last_edited_by,omitempty"`
	CreatedAt    string        `json:"created_at,omitempty"`
	UpdatedAt    string        `json:"updated_at,omitempty"`
	Sections     []ItemSection `json:"sections,omitempty"`
	Fields       []ItemField   `json:"fields,omitempty"`
}

type ItemCommandBuilder

type ItemCommandBuilder struct {
	Get    *ItemGetCommandBuilder
	Create *ItemCreateCommandBuilder
	// This method is not used in the provided code, but can be implemented if needed.
	List *ItemListCommandBuilder
}

func NewItemCommandBuilder

func NewItemCommandBuilder() *ItemCommandBuilder

func (*ItemCommandBuilder) Build

func (i *ItemCommandBuilder) Build() []string

func (*ItemCommandBuilder) WithCreate

func (*ItemCommandBuilder) WithGet

func (*ItemCommandBuilder) WithList

type ItemCreateCommandBuilder

type ItemCreateCommandBuilder struct {
	Title    string
	Vault    *string
	DryRun   bool
	Category *string
	Stdin    bool
}

func NewItemCreateCommandBuilder

func NewItemCreateCommandBuilder() *ItemCreateCommandBuilder

func (*ItemCreateCommandBuilder) Build

func (i *ItemCreateCommandBuilder) Build() []string

func (*ItemCreateCommandBuilder) WithCategory

func (i *ItemCreateCommandBuilder) WithCategory(category *string) *ItemCreateCommandBuilder

func (*ItemCreateCommandBuilder) WithDryRun

func (*ItemCreateCommandBuilder) WithStdin

func (*ItemCreateCommandBuilder) WithTitle

func (*ItemCreateCommandBuilder) WithVault

type ItemField

type ItemField struct {
	ID        string       `json:"id,omitempty"`
	Type      string       `json:"type,omitempty"`
	Purpose   string       `json:"purpose,omitempty"`
	Label     string       `json:"label,omitempty"`
	Value     string       `json:"value,omitempty"`
	Reference string       `json:"reference,omitempty"`
	Section   *ItemSection `json:"section,omitempty"`
}

type ItemGetCommandBuilder

type ItemGetCommandBuilder struct {
	Vault string
	Title string
}

func NewItemGetCommandBuilder

func NewItemGetCommandBuilder() *ItemGetCommandBuilder

func (*ItemGetCommandBuilder) Build

func (i *ItemGetCommandBuilder) Build() []string

func (*ItemGetCommandBuilder) WithTitle

func (i *ItemGetCommandBuilder) WithTitle(title string) *ItemGetCommandBuilder

func (*ItemGetCommandBuilder) WithVault

func (i *ItemGetCommandBuilder) WithVault(vault string) *ItemGetCommandBuilder

type ItemListCommandBuilder

type ItemListCommandBuilder struct {
	Vault *string
}

func NewItemListCommandBuilder

func NewItemListCommandBuilder() *ItemListCommandBuilder

func (*ItemListCommandBuilder) Build

func (i *ItemListCommandBuilder) Build() []string

func (*ItemListCommandBuilder) WithVault

type ItemSection

type ItemSection struct {
	ID    string `json:"id"`
	Label string `json:"label"`
}

type Vault

type Vault struct {
	ID             string `json:"id"`
	Name           string `json:"name"`
	ContentVersion int    `json:"content_version"`
}

type VaultCommandBuilder

type VaultCommandBuilder struct {
	Get  *VaultGetCommandBuilder
	List *VaultListCommandBuilder
}

func NewVaultCommandBuilder

func NewVaultCommandBuilder() *VaultCommandBuilder

func (*VaultCommandBuilder) Build

func (v *VaultCommandBuilder) Build() []string

func (*VaultCommandBuilder) WithGet

func (*VaultCommandBuilder) WithList

type VaultGetCommandBuilder

type VaultGetCommandBuilder struct {
	Vault string
}

func NewVaultGetCommandBuilder

func NewVaultGetCommandBuilder() *VaultGetCommandBuilder

func (*VaultGetCommandBuilder) Build

func (v *VaultGetCommandBuilder) Build() []string

func (*VaultGetCommandBuilder) WithVault

type VaultListCommandBuilder

type VaultListCommandBuilder struct{}

func NewVaultListCommandBuilder

func NewVaultListCommandBuilder() *VaultListCommandBuilder

func (*VaultListCommandBuilder) Build

func (v *VaultListCommandBuilder) Build() []string

Jump to

Keyboard shortcuts

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