nsscache

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: MIT Imports: 8 Imported by: 1

README

nsscache-go

GoDoc Build Status Coverage Status

Implementation of nsscache in Go. The main goal of this library is too allow to write easily new program which can populate the nsscache files from not yet supported sources or to use your custom logic to generate those cache files.

Running the test

To run the test against libnss-cache, you need to have docker installer, and build the test image.

cd docker
docker build -t nsscache-go:latest .

See

Documentation

Overview

Package nsscache greatly simplifies the task of writing cache filling applications for libnss-cache by encapsulating the tasks of writing the caches, cache indexes, and doing so atomically into a reusable library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteAtomic

func WriteAtomic(filename string, wt io.WriterTo, perm os.FileMode) error

WriteAtomic allows atomic updates to files by first writing to a temporary file, setting all parameters on the temporary file and renaming it to the desired name. On most Linux systems this will be an atomic action.

Types

type CacheMap

type CacheMap map[string]*cache.Cache

CacheMap allows you to manage the caches as a group.

func NewCaches

func NewCaches(opts ...Option) CacheMap

NewCaches creates cache structs for passwd, group and shadow.

func (*CacheMap) FillCaches

func (cm *CacheMap) FillCaches(src source.Source) error

FillCaches uses the provided source to fill the caches of the CacheMap struct.

func (*CacheMap) WriteFiles

func (cm *CacheMap) WriteFiles(options *WriteOptions) error

WriteFiles write the content of the cache structs into files that libnss-cache can read.

type Option

type Option struct {
	CacheName string
	Option    cache.Option
}

Option is a wrapper type used to specify options on a specific cache.

type WriteOptions

type WriteOptions struct {
	Directory string
	Extension string
}

WriteOptions specifies optional values for writing the caches out. The directory will default to '/etc' and the Extension will default to 'cache'.

Directories

Path Synopsis
Package cache contains the types and convenience functions for manipulating caches in memory prior to writing to the disk.
Package cache contains the types and convenience functions for manipulating caches in memory prior to writing to the disk.
examples
nsscache-vault
example showing how to use vault with nsscache to write files readable by libnss-cache
example showing how to use vault with nsscache to write files readable by libnss-cache
Package source defines the interfaces that fill caches.
Package source defines the interfaces that fill caches.
s3
vault
Package vault is a source implementation that retrieves cache data from a path in a Hashicorp Vault key/value store.
Package vault is a source implementation that retrieves cache data from a path in a Hashicorp Vault key/value store.

Jump to

Keyboard shortcuts

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