credential

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credential

type Credential struct {
	User     string                    `json:"user"`     // User name
	Password secretstring.SecretString `json:"password"` // Password (masked in JSON/logs)
}

Credential holds authentication information with password protection

func FromMap

func FromMap(data map[string]interface{}) (*Credential, error)

FromMap converts a map[string]interface{} from Vault storage to a Credential

func New

func New(user string, password string) *Credential

New creates a Credential with the given user and password.

func NewFromEnv

func NewFromEnv(userEnv string, passwordEnv string) Credential

NewFromEnv creates a Credential from environment variables as-is

func (*Credential) IsValid

func (cred *Credential) IsValid() bool

IsValid returns true if the credential has a non-empty username Note: Password validation is intentionally not included for flexibility

func (*Credential) Patch

func (cred *Credential) Patch(nc *Credential) bool

Patch updates the credential with non-empty values from the given credential. It returns true if any field was updated.

func (*Credential) Retrieve

func (cred *Credential) Retrieve() (*string, *string)

Retrieve returns pointers to user and password if credential is valid Returns nil pointers if credential is invalid

func (Credential) ToMap

func (c Credential) ToMap() map[string]interface{}

ToMap converts a Credential to a map[string]interface{} suitable for Vault storage

func (*Credential) Update

func (cred *Credential) Update(user *string, password *string)

Update modifies credential fields if the provided pointers are not nil

Jump to

Keyboard shortcuts

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