Documentation ¶
Index ¶
- Constants
- type Cache
- type Client
- type KeywhizFs
- func (kwfs KeywhizFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status)
- func (kwfs KeywhizFs) Open(name string, flags uint32, context *fuse.Context) (nodefs.File, fuse.Status)
- func (kwfs KeywhizFs) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, code fuse.Status)
- func (kwfs KeywhizFs) String() string
- func (kwfs KeywhizFs) Unlink(name string, context *fuse.Context) fuse.Status
- type Ownership
- type Secret
- type SecretBackend
- type SecretMap
- type SecretTime
- type Timeouts
Constants ¶
const ( VERSION = "2.0" EISDIR = fuse.Status(unix.EISDIR) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
Cache contains necessary state to return secrets, using previously cached content or retrieving from a server if necessary.
func NewCache ¶
func NewCache(backend SecretBackend, timeouts Timeouts, logConfig log.Config) *Cache
NewCache initializes a Cache.
func (*Cache) Add ¶
Add inserts a secret into the cache. If a secret is already in the cache with a matching identifier, it will be overridden This method is most useful for testing since lookups may add data to the cache.
func (*Cache) Len ¶
Len returns the number of values stored in the cache. This method is most useful for testing.
func (*Cache) Secret ¶
Secret retrieves a Secret by name from cache or a server.
Cache logic:
- If cache hit and very recent: return cache entry
- Ask backend w/ timeout
- If backend returns fast: update cache, return
- If timeout_backend_deadline AND cache hit: return cache entry, background update cache when backend returns
- If timeout_max_wait: log error and pretend file doesn't exist
func (*Cache) SecretList ¶
SecretList returns a listing of Secrets from cache or a server.
Cache logic:
- Ask backend w/ timeout
- If backend returns fast: update cache, return
- If timeout_backend_deadline: return cache entries, background update cache when backend returns
- If timeout_max_wait: log error and pretend no files
type Client ¶
Client basic struct.
func NewClient ¶
func NewClient(certFile, keyFile, caFile, serverURL string, timeout time.Duration, logConfig klog.Config, ping bool) (client Client)
NewClient produces a read-to-use client struct given PEM-encoded certificate file, key file, and ca file with the list of trusted certificate authorities.
func (Client) RawSecretList ¶
RawSecretList returns raw JSON from requesting a listing of secrets.
func (Client) SecretList ¶
SecretList returns a slice of unmarshalled Secret structs after requesting a listing of secrets.
type KeywhizFs ¶
type KeywhizFs struct { pathfs.FileSystem *log.Logger Client *Client Cache *Cache StartTime time.Time Ownership Ownership }
KeywhizFs is the central struct for dispatching filesystem operations.
func NewKeywhizFs ¶
func NewKeywhizFs(client *Client, ownership Ownership, timeouts Timeouts, logConfig log.Config) (kwfs *KeywhizFs, root nodefs.Node, err error)
NewKeywhizFs readies a KeywhizFs struct and its parent filesystem objects.
func (KeywhizFs) GetAttr ¶
GetAttr is a FUSE function which tells FUSE which files and directories exist.
name is empty when getting information on the base directory
func (KeywhizFs) Open ¶
func (kwfs KeywhizFs) Open(name string, flags uint32, context *fuse.Context) (nodefs.File, fuse.Status)
Open is a FUSE function where an in-memory open file struct is constructed.
type Ownership ¶
Ownership indicates the default ownership of filesystem entries.
func NewOwnership ¶
NewOwnership initializes default file ownership struct.
type Secret ¶
type Secret struct { Name string Content content `json:"secret"` Length uint64 `json:"secretLength"` CreatedAt time.Time `json:"creationDate"` IsVersioned bool Mode string Owner string Group string }
Secret represents data returned after processing a server request.
json tags after fields indicate to json decoder the key name in JSON
func ParseSecret ¶
ParseSecret deserializes raw JSON into a Secret struct.
func ParseSecretList ¶
ParseSecretList deserializes raw JSON into a list of Secret structs.
type SecretBackend ¶
type SecretBackend interface { Secret(string) (secret *Secret, ok bool) SecretList() (secretList []Secret, ok bool) }
SecretBackend represents an interface for storing secrets.
type SecretMap ¶
type SecretMap struct {
// contains filtered or unexported fields
}
SecretMap is a thread-safe map for storing key -> secret mapping.
func (*SecretMap) Get ¶
func (m *SecretMap) Get(key string) (s SecretTime, ok bool)
Get retrieves a values from the map and indicates if the lookup was ok.
func (*SecretMap) Put ¶
Put places a value in the map with a key, possibly overwriting an existing entry.
func (*SecretMap) PutIfAbsent ¶
PutIfAbsent places a value in the map with a key, if that key did not exist. Returns whether the value was placed.
func (*SecretMap) Values ¶
func (m *SecretMap) Values() []SecretTime
Values returns a slice of stored secrets in no particular order.
type SecretTime ¶
SecretTime contains a Secret record along with a timestamp when it was inserted.
type Timeouts ¶
type Timeouts struct { // FUSE may make many lookups in quick succession. If cached data is recent within the threshold, // a backend request is not attempted. Fresh time.Duration // BackendDeadline is distinct from the backend timeout. It is an optimistic timeout to wait // until resorting to cached data. BackendDeadline time.Duration MaxWait time.Duration }
Timeouts contains configuration for timeouts: timeout_backend_deadline: optimistic timeout to wait for cache timeout_max_wait: timeout for client to get data from server