Documentation
¶
Index ¶
- Constants
- func BuildPATRef(profile ProfileContext, appID string) string
- func NormalizeCredentialInput(input CredentialInput) (string, error)
- func NormalizeGitHTTPURL(raw string) (string, error)
- type AppStorage
- type CredentialFile
- type CredentialInput
- type CredentialRecord
- type GitConfig
- type GlobalGitConfig
- type InitResult
- type IssuedCredential
- type Issuer
- type ListRecord
- type ListResult
- type Manager
- func (m *Manager) Erase(r io.Reader) error
- func (m *Manager) Get(ctx context.Context, input CredentialInput, current ProfileContext, ...) error
- func (m *Manager) Init(ctx context.Context, profile ProfileContext, appID string) (*InitResult, error)
- func (m *Manager) List() (*ListResult, error)
- func (m *Manager) Remove(ctx context.Context, profile ProfileContext, appID string) (*RemoveResult, error)
- func (m *Manager) StoreCredential(r io.Reader) error
- type ProfileContext
- type RemoveResult
- type SecretStore
- type Store
- func (s *Store) Current() (*CredentialRecord, error)
- func (s *Store) DeleteByURL(gitHTTPURL string) (*CredentialRecord, error)
- func (s *Store) FindByAppID(appID string, profile ProfileContext) ([]CredentialRecord, error)
- func (s *Store) FindByURL(gitHTTPURL string) (*CredentialRecord, error)
- func (s *Store) Load() (*CredentialFile, error)
- func (s *Store) Path() string
- func (s *Store) Records() ([]CredentialRecord, error)
- func (s *Store) Save(file *CredentialFile) error
- func (s *Store) Upsert(record CredentialRecord) error
Constants ¶
View Source
const ( CurrentCredentialVersion = 1 MetadataFilename = "git.json" // KeychainService intentionally reuses the CLI-wide internal keychain // service, so Git PAT .enc files stay under Application Support/lark-cli. KeychainService = "lark-cli" StatusPending = "pending" StatusConfirmed = "confirmed" ListStatusValid = "valid" ListStatusExpired = "expired" ListStatusInvalidated = "invalidated" ListStatusMissingSecret = "missing_secret" ListStatusIncomplete = "incomplete" )
Variables ¶
This section is empty.
Functions ¶
func BuildPATRef ¶
func BuildPATRef(profile ProfileContext, appID string) string
func NormalizeCredentialInput ¶
func NormalizeCredentialInput(input CredentialInput) (string, error)
func NormalizeGitHTTPURL ¶
Types ¶
type AppStorage ¶
type CredentialFile ¶
type CredentialFile struct {
Version int `json:"version"`
CredentialRecord
}
CredentialFile is the app-scoped non-secret metadata persisted under the Miaoda app storage directory.
type CredentialInput ¶
func ParseCredentialInput ¶
func ParseCredentialInput(r io.Reader) (CredentialInput, error)
type CredentialRecord ¶
type CredentialRecord struct {
AppID string `json:"app_id"`
GitHTTPURL string `json:"git_http_url"`
Profile string `json:"profile"`
ProfileAppID string `json:"profile_app_id"`
UserOpenID string `json:"user_open_id"`
Username string `json:"username"`
PATRef string `json:"pat_ref"`
Status string `json:"status"`
ExpiresAt int64 `json:"expires_at"`
UpdatedAt int64 `json:"updated_at"`
LastEraseAt int64 `json:"last_erase_at,omitempty"`
InvalidatedAt int64 `json:"invalidated_at,omitempty"`
}
CredentialRecord points to the keychain-stored PAT without storing the PAT plaintext in metadata.
type GlobalGitConfig ¶
type GlobalGitConfig struct {
HelperCommand string
}
func (GlobalGitConfig) SetHelper ¶
func (g GlobalGitConfig) SetHelper(ctx context.Context, gitHTTPURL, appID string) error
func (GlobalGitConfig) UnsetHelper ¶
func (g GlobalGitConfig) UnsetHelper(ctx context.Context, gitHTTPURL string) error
type InitResult ¶
type IssuedCredential ¶
type Issuer ¶
type Issuer interface {
Issue(ctx context.Context, appID string, profile ProfileContext) (*IssuedCredential, error)
}
type ListRecord ¶
type ListResult ¶
type ListResult struct {
Records []ListRecord
}
type Manager ¶
type Manager struct {
Store *Store
Secrets *SecretStore
GitConfig GitConfig
Issuer Issuer
Now func() time.Time
}
func NewManager ¶
func NewManager(store *Store, secrets *SecretStore, gitConfig GitConfig, issuer Issuer) *Manager
func (*Manager) Get ¶
func (m *Manager) Get(ctx context.Context, input CredentialInput, current ProfileContext, out, errOut io.Writer) error
func (*Manager) Init ¶
func (m *Manager) Init(ctx context.Context, profile ProfileContext, appID string) (*InitResult, error)
func (*Manager) List ¶
func (m *Manager) List() (*ListResult, error)
func (*Manager) Remove ¶
func (m *Manager) Remove(ctx context.Context, profile ProfileContext, appID string) (*RemoveResult, error)
type ProfileContext ¶
type RemoveResult ¶
type RemoveResult struct {
AppID string
Removed bool
Records []CredentialRecord
ConfigWarning string
}
type SecretStore ¶
type SecretStore struct {
// contains filtered or unexported fields
}
func NewSecretStore ¶
func NewSecretStore(kc keychain.KeychainAccess) *SecretStore
func (*SecretStore) Remove ¶
func (s *SecretStore) Remove(ref string) error
func (*SecretStore) Set ¶
func (s *SecretStore) Set(ref, pat string) error
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func NewAppStore ¶
func NewAppStore(appID string, storage AppStorage) *Store
func NewStoreAt ¶
func (*Store) Current ¶
func (s *Store) Current() (*CredentialRecord, error)
func (*Store) DeleteByURL ¶
func (s *Store) DeleteByURL(gitHTTPURL string) (*CredentialRecord, error)
func (*Store) FindByAppID ¶
func (s *Store) FindByAppID(appID string, profile ProfileContext) ([]CredentialRecord, error)
func (*Store) Load ¶
func (s *Store) Load() (*CredentialFile, error)
func (*Store) Records ¶
func (s *Store) Records() ([]CredentialRecord, error)
func (*Store) Save ¶
func (s *Store) Save(file *CredentialFile) error
func (*Store) Upsert ¶
func (s *Store) Upsert(record CredentialRecord) error
Click to show internal directories.
Click to hide internal directories.