Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated spire to handle entries via options (#258)
Turns out, spire-agent only polls spire-server every 5 seconds. This means that if we run spire-server, then spire-agent, then add entries... it can take up to six seconds to get our SVID. By moving to options, we can: 1. Start spire-server 2. Create entries 3. Start spire-agent And spire-agent *starts* with the entries and can thus issue ids. Signed-off-by: Ed Warnicke <hagbard@gmail.com>
- Loading branch information
1 parent
6d771f4
commit 392d4af
Showing
5 changed files
with
80 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ plugins { | |
} | ||
WorkloadAttestor "unix" { | ||
plugin_data { | ||
discover_workload_path = true | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package spire | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
type entry struct { | ||
spiffeID string | ||
selector string | ||
} | ||
|
||
type option struct { | ||
ctx context.Context | ||
agentID string | ||
entries []*entry | ||
} | ||
|
||
// Option for spire | ||
type Option func(*option) | ||
|
||
// WithContext - use ctx as context for starting spire | ||
func WithContext(ctx context.Context) Option { | ||
return func(o *option) { | ||
o.ctx = ctx | ||
} | ||
} | ||
|
||
// WithAgentID - agentID for starting spire | ||
func WithAgentID(agentID string) Option { | ||
return func(o *option) { | ||
o.agentID = agentID | ||
} | ||
} | ||
|
||
// WithEntry - Option to add Entry to spire-server. May be used multiple times. | ||
func WithEntry(spiffeID, selector string) Option { | ||
return func(o *option) { | ||
o.entries = append(o.entries, &entry{ | ||
spiffeID: spiffeID, | ||
selector: selector, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters