Skip to content

Commit b829672

Browse files
committed
help: --one-shot, --input-path, and --output-path are meant for testing purposes
1 parent 7be5342 commit b829672

File tree

1 file changed

+55
-34
lines changed

1 file changed

+55
-34
lines changed

pkg/agent/config.go

Lines changed: 55 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,34 @@ const (
2929

3030
// Config wraps the options for a run of the agent.
3131
type Config struct {
32+
// Deprecated: Schedule doesn't do anything. Use `period` instead.
3233
Schedule string `yaml:"schedule"`
3334
Period time.Duration `yaml:"period"`
34-
// Deprecated: Endpoint is being replaced with Server.
35+
36+
// Deprecated: Use `server` instead.
3537
Endpoint Endpoint `yaml:"endpoint"`
36-
// Server is the base url for the Preflight server.
37-
// It defaults to https://preflight.jetstack.io.
38+
39+
// Server is the base URL for the Preflight server. It defaults to
40+
// https://preflight.jetstack.io in Jetstack Secure OAuth and Jetstack
41+
// Secure API Token modes, and https://api.venafi.cloud in Venafi Cloud Key
42+
// Pair Service Account mode. It is ignored in Venafi Cloud VenafiConnection
43+
// mode.
3844
Server string `yaml:"server"`
39-
// OrganizationID within Preflight that will receive the data.
45+
46+
// OrganizationID is only used in Jetstack Secure OAuth and Jetstack Secure
47+
// API Token modes.
4048
OrganizationID string `yaml:"organization_id"`
41-
// ClusterID is the cluster that the agent is scanning.
42-
ClusterID string `yaml:"cluster_id"`
43-
ClusterDescription string `yaml:"cluster_description"`
44-
DataGatherers []DataGatherer `yaml:"data-gatherers"`
45-
// InputPath replaces DataGatherers with input data file
49+
50+
// ClusterID is the cluster that the agent is scanning. Used in all modes.
51+
ClusterID string `yaml:"cluster_id"`
52+
ClusterDescription string `yaml:"cluster_description"`
53+
DataGatherers []DataGatherer `yaml:"data-gatherers"`
54+
VenafiCloud *VenafiCloudConfig `yaml:"venafi-cloud,omitempty"`
55+
56+
// For testing purposes.
4657
InputPath string `yaml:"input-path"`
47-
// OutputPath replaces Server with output data file
48-
OutputPath string `yaml:"output-path"`
49-
VenafiCloud *VenafiCloudConfig `yaml:"venafi-cloud,omitempty"`
58+
// For testing purposes.
59+
OutputPath string `yaml:"output-path"`
5060
}
5161

5262
type Endpoint struct {
@@ -80,11 +90,9 @@ type AgentCmdFlags struct {
8090
// precedence over the config field `period`.
8191
Period time.Duration
8292

83-
// OneShot (--one-shot) flag causes agent to run once.
84-
OneShot bool
85-
86-
// VenafiCloudMode (--venafi-cloud) determines which format to load for
87-
// config and credential type.
93+
// VenafiCloudMode (--venafi-cloud) turns on the Venafi Cloud Key Pair
94+
// Service Account mode. Must be used in conjunction with
95+
// --credentials-file.
8896
VenafiCloudMode bool
8997

9098
// ClientID (--client-id) is the clientID in case of Venafi Cloud Key Pair
@@ -95,16 +103,27 @@ type AgentCmdFlags struct {
95103
// private key in case of Venafi Cloud Key Pair Service Account mode.
96104
PrivateKeyPath string
97105

98-
// CredentialsPath (--credentials-file, -k) is the path to the credentials )
99-
// is where the agent will try to loads the credentials (Experimental).
106+
// CredentialsPath (--credentials-file, -k) lets you specify the location of
107+
// the credentials file. This is used for the Jetstack Secure OAuth and
108+
// Venafi Cloud Key Pair Service Account modes. In Venafi Cloud Key Pair
109+
// Service Account mode, you also need to pass --venafi-cloud.
100110
CredentialsPath string
101111

102-
// OutputPath (--output-path) is where the agent will write data to instead
103-
// of uploading to server.
112+
// OneShot (--one-shot) is used for testing purposes. The agent will run
113+
// once and exit. It is often used in conjunction with --output-path and/or
114+
// --input-path.
115+
OneShot bool
116+
117+
// OutputPath (--output-path) is used for testing purposes. In conjunction
118+
// with --one-shot, it allows you to write the data readings to a file
119+
// instead uploading them to the Venafi Cloud API.
104120
OutputPath string
105121

106-
// InputPath (--input-path) is where the agent will read data from instead
107-
// of gathering data from clusters.
122+
// InputPath (--input-path) is used for testing purposes. In conjunction
123+
// with --one-shot, it allows you to push manually crafted data readings (in
124+
// JSON format) to the Venafi Cloud API without the need to connect to a
125+
// Kubernetes cluster. See the jscp-testing-cli's README for more info:
126+
// https://gitlab.com/venafi/vaas/applications/tls-protect-for-k8s/cloud-services/-/tree/master/jscp-testing-cli
108127
InputPath string
109128

110129
// BackoffMaxTime (--backoff-max-time) is the maximum time for which data
@@ -114,8 +133,8 @@ type AgentCmdFlags struct {
114133
// StrictMode (--strict) causes the agent to fail at the first attempt.
115134
StrictMode bool
116135

117-
// APIToken (--api-token) is meant for the old Jetstack Secure API and is an
118-
// alternative to OAuth.
136+
// APIToken (--api-token) allows you to use the Jetstack Secure API Token
137+
// mode. Defaults to the value of the env var API_TOKEN.
119138
APIToken string
120139

121140
// VenConnName (--venafi-connection) is the name of the VenafiConnection
@@ -171,7 +190,7 @@ func InitAgentCmdFlags(c *cobra.Command, cfg *AgentCmdFlags) {
171190
"venafi-cloud",
172191
"",
173192
false,
174-
fmt.Sprintf("Turn on the %s mode. The flag --credentials-file must also be passed.", JetstackSecureOAuth),
193+
fmt.Sprintf("Turns on the %s mode. The flag --credentials-file must also be passed.", JetstackSecureOAuth),
175194
)
176195
c.PersistentFlags().StringVarP(
177196
&cfg.ClientID,
@@ -194,21 +213,21 @@ func InitAgentCmdFlags(c *cobra.Command, cfg *AgentCmdFlags) {
194213
"one-shot",
195214
"",
196215
false,
197-
"Runs agent a single time if true, or continously if false",
216+
"For testing purposes. The agent will run once and exit. It is often used in conjunction with --output-path and/or --input-path.",
198217
)
199218
c.PersistentFlags().StringVarP(
200219
&cfg.OutputPath,
201220
"output-path",
202221
"",
203222
"",
204-
"Output file path, if used, it will write data to a local file instead of uploading to the preflight server",
223+
"For testing purposes. In conjunction with --one-shot, it allows you to write the data readings to a file instead of uploading to the server.",
205224
)
206225
c.PersistentFlags().StringVarP(
207226
&cfg.InputPath,
208227
"input-path",
209228
"",
210229
"",
211-
"Input file path, if used, it will read data from a local file instead of gathering data from clusters",
230+
"For testing purposes. In conjunction with --one-shot, it allows you to push manually crafted data readings (in JSON format) to the Venafi Cloud API without the need to connect to a Kubernetes cluster.",
212231
)
213232
c.PersistentFlags().DurationVarP(
214233
&cfg.BackoffMaxTime,
@@ -228,14 +247,14 @@ func InitAgentCmdFlags(c *cobra.Command, cfg *AgentCmdFlags) {
228247
&cfg.APIToken,
229248
"api-token",
230249
os.Getenv("API_TOKEN"),
231-
fmt.Sprintf("Turns on the %s mode. Defaults to the value of the env var API_TOKEN.", JetstackSecureAPIToken),
250+
"Turns on the "+string(JetstackSecureAPIToken)+" mode. Defaults to the value of the env var API_TOKEN.",
232251
)
233252
c.PersistentFlags().StringVar(
234253
&cfg.VenConnName,
235254
"venafi-connection",
236255
"",
237-
fmt.Sprintf("Turns on the %s mode. This flag configures the name of the "+
238-
"VenafiConnection to be used.", VenafiCloudVenafiConnection),
256+
"Turns on the "+string(VenafiCloudVenafiConnection)+" mode. "+
257+
"This flag configures the name of the VenafiConnection to be used.",
239258
)
240259
c.PersistentFlags().StringVar(
241260
&cfg.VenConnNS,
@@ -249,8 +268,9 @@ func InitAgentCmdFlags(c *cobra.Command, cfg *AgentCmdFlags) {
249268
&cfg.InstallNS,
250269
"install-namespace",
251270
"",
252-
fmt.Sprintf("Namespace in which the agent is running. Only needed with the %s mode"+
253-
"when running the agent outside of Kubernetes. Used for testing purposes.", VenafiCloudVenafiConnection),
271+
"For testing purposes. Namespace in which the agent is running. "+
272+
"Only needed with the "+string(VenafiCloudVenafiConnection)+" mode"+
273+
"when running the agent outside of Kubernetes.",
254274
)
255275
c.PersistentFlags().BoolVarP(
256276
&cfg.Profiling,
@@ -266,6 +286,7 @@ func InitAgentCmdFlags(c *cobra.Command, cfg *AgentCmdFlags) {
266286
false,
267287
"Enables Prometheus metrics server on the agent (port: 8081).",
268288
)
289+
269290
}
270291

271292
type AuthMode string

0 commit comments

Comments
 (0)