Esempio n. 1
0
func NewUserPolicy(
	keyringPath string,
	deployPolicyPath string,
	preparerApp string,
	preparerUser string,
) (p Policy, err error) {
	keyringWatcher, err := util.NewFileWatcher(
		func(path string) (interface{}, error) {
			return LoadKeyring(path)
		},
		keyringPath,
	)
	if err != nil {
		return
	}
	defer func() {
		if err != nil {
			keyringWatcher.Close()
		}
	}()
	deployWatcher, err := util.NewFileWatcher(
		func(path string) (interface{}, error) {
			return LoadDeployPol(path)
		},
		deployPolicyPath,
	)
	if err != nil {
		return
	}
	p = UserPolicy{keyringWatcher, deployWatcher, preparerApp, preparerUser}
	return
}
Esempio n. 2
0
func NewFileKeyringPolicy(
	keyringPath string,
	authorizedDeployers map[string][]string,
) (Policy, error) {
	watcher, err := util.NewFileWatcher(
		func(path string) (interface{}, error) {
			return LoadKeyring(path)
		},
		keyringPath,
	)
	if err != nil {
		return nil, err
	}
	return FileKeyringPolicy{keyringPath, authorizedDeployers, watcher}, nil
}