Skip to content

Commit e0b71bc

Browse files
committed
started work on per-target auth secrets for #24
Adds an `A` configuration primitive that declares a set of options for getting Git credentials for targets.
1 parent 42d7c8d commit e0b71bc

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

config/config.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,17 @@ import (
2121

2222
// State represents a desired system state
2323
type State struct {
24-
Targets task.Targets `json:"targets"`
25-
Env map[string]string `json:"env"`
24+
Targets task.Targets `json:"targets"`
25+
AuthMethods []AuthMethod `json:"auths"`
26+
Env map[string]string `json:"env"`
27+
}
28+
29+
// AuthMethod represents a method of authentication for a target
30+
type AuthMethod struct {
31+
Name string `json:"name"` // name of the auth method
32+
Path string `json:"path"` // path within the secret store
33+
UserKey string `json:"user_key"` // key for username
34+
PassKey string `json:"pass_key"` // key for password
2635
}
2736

2837
// ConfigFromDirectory searches a directory for configuration files and
@@ -90,6 +99,15 @@ function T(t) {
9099
function E(k, v) {
91100
STATE.env[k] = v
92101
}
102+
103+
function A(a) {
104+
if(a.name === undefined) { throw "auth name undefined"; }
105+
if(a.path === undefined) { throw "auth path undefined"; }
106+
if(a.user_key === undefined) { throw "auth user_key undefined"; }
107+
if(a.pass_key === undefined) { throw "auth pass_key undefined"; }
108+
109+
STATE.auths.push(a);
110+
}
93111
`)
94112

95113
cb.vm.Set("HOSTNAME", hostname) //nolint:errcheck

task/target.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ type Target struct {
4848

4949
// Whether or not to run `Command` on first run, useful if the command is `docker-compose up`
5050
InitialRun bool `json:"initial_run"`
51+
52+
// Auth method to use from the auth store
53+
Auth string `json:"auth"`
5154
}
5255

5356
// Execute runs the target's command in the specified directory with the

0 commit comments

Comments
 (0)