Skip to content

Commit c5a057c

Browse files
committed
additional-redacted-vars
Also remove unused AssertLogsDoNotContain
1 parent 4a6d1b1 commit c5a057c

File tree

6 files changed

+27
-33
lines changed

6 files changed

+27
-33
lines changed

charts/agent-stack-k8s/values.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
"title": "The UUID of the Buildkite cluster to pull Jobs from",
206206
"examples": [""]
207207
},
208-
"redacted-vars": {
208+
"additional-redacted-vars": {
209209
"type": "array",
210210
"default": [],
211211
"title": "Additional environment variables to redact values from logs",

internal/controller/config/config.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ const (
1515
)
1616

1717
type Config struct {
18-
Debug bool `mapstructure:"debug"`
19-
AgentTokenSecret string `mapstructure:"agent-token-secret" validate:"required"`
20-
BuildkiteToken string `mapstructure:"buildkite-token" validate:"required"`
21-
Image string `mapstructure:"image" validate:"required"`
22-
JobTTL time.Duration `mapstructure:"job-ttl"`
23-
MaxInFlight int `mapstructure:"max-in-flight" validate:"min=0"`
24-
Namespace string `mapstructure:"namespace" validate:"required"`
25-
Org string `mapstructure:"org" validate:"required"`
26-
Tags stringSlice `mapstructure:"tags" validate:"min=1"`
27-
ProfilerAddress string `mapstructure:"profiler-address" validate:"omitempty,hostname_port"`
28-
ClusterUUID string `mapstructure:"cluster-uuid" validate:"omitempty"`
29-
RedactedVars stringSlice `mapstructure:"redacted-vars" validate:"omitempty"`
18+
Debug bool `mapstructure:"debug"`
19+
AgentTokenSecret string `mapstructure:"agent-token-secret" validate:"required"`
20+
BuildkiteToken string `mapstructure:"buildkite-token" validate:"required"`
21+
Image string `mapstructure:"image" validate:"required"`
22+
JobTTL time.Duration `mapstructure:"job-ttl"`
23+
MaxInFlight int `mapstructure:"max-in-flight" validate:"min=0"`
24+
Namespace string `mapstructure:"namespace" validate:"required"`
25+
Org string `mapstructure:"org" validate:"required"`
26+
Tags stringSlice `mapstructure:"tags" validate:"min=1"`
27+
ProfilerAddress string `mapstructure:"profiler-address" validate:"omitempty,hostname_port"`
28+
ClusterUUID string `mapstructure:"cluster-uuid" validate:"omitempty"`
29+
AdditionalRedactedVars stringSlice `mapstructure:"additional-redacted-vars" validate:"omitempty"`
3030
}
3131

3232
type stringSlice []string
@@ -48,7 +48,7 @@ func (c Config) MarshalLogObject(enc zapcore.ObjectEncoder) error {
4848
enc.AddString("org", c.Org)
4949
enc.AddString("profiler-address", c.ProfilerAddress)
5050
enc.AddString("cluster-uuid", c.ClusterUUID)
51-
if err := enc.AddArray("redacted-vars", c.RedactedVars); err != nil {
51+
if err := enc.AddArray("additional-redacted-vars", c.AdditionalRedactedVars); err != nil {
5252
return err
5353
}
5454
return enc.AddArray("tags", c.Tags)

internal/controller/controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ func Run(
4949
}
5050

5151
sched := scheduler.New(logger.Named("scheduler"), k8sClient, scheduler.Config{
52-
Namespace: cfg.Namespace,
53-
Image: cfg.Image,
54-
AgentToken: cfg.AgentTokenSecret,
55-
JobTTL: cfg.JobTTL,
56-
RedactedVars: cfg.RedactedVars,
52+
Namespace: cfg.Namespace,
53+
Image: cfg.Image,
54+
AgentToken: cfg.AgentTokenSecret,
55+
JobTTL: cfg.JobTTL,
56+
AdditionalRedactedVars: cfg.AdditionalRedactedVars,
5757
})
5858
limiter := scheduler.NewLimiter(logger.Named("limiter"), sched, cfg.MaxInFlight)
5959

internal/controller/scheduler/scheduler.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ const (
3030
)
3131

3232
type Config struct {
33-
Namespace string
34-
Image string
35-
AgentToken string
36-
JobTTL time.Duration
37-
RedactedVars []string
33+
Namespace string
34+
Image string
35+
AgentToken string
36+
JobTTL time.Duration
37+
AdditionalRedactedVars []string
3838
}
3939

4040
func New(logger *zap.Logger, client kubernetes.Interface, cfg Config) *worker {
@@ -229,7 +229,7 @@ func (w *jobWrapper) Build(skipCheckout bool) (*batchv1.Job, error) {
229229
}
230230
}
231231

232-
redactedVars := append(w.cfg.RedactedVars, clicommand.RedactedVars.Value.Value()...)
232+
redactedVars := append(w.cfg.AdditionalRedactedVars, clicommand.RedactedVars.Value.Value()...)
233233

234234
volumeMounts := []corev1.VolumeMount{{Name: "workspace", MountPath: "/workspace"}}
235235
volumeMounts = append(volumeMounts, w.k8sPlugin.ExtraVolumeMounts...)

internal/integration/integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestControllerPicksUpJobsWithSubsetOfAgentTags(t *testing.T) {
5454
tc.AssertSuccess(ctx, build)
5555
}
5656

57-
func TestControllerSetsRedactedVars(t *testing.T) {
57+
func TestControllerSetsAdditionalRedactedVars(t *testing.T) {
5858
tc := testcase{
5959
T: t,
6060
Fixture: "redacted-vars.yaml",
@@ -67,7 +67,7 @@ func TestControllerSetsRedactedVars(t *testing.T) {
6767
t.Cleanup(cleanup)
6868

6969
cfg := cfg
70-
cfg.RedactedVars = []string{"ELEVEN_HERBS_AND_SPICES"}
70+
cfg.AdditionalRedactedVars = []string{"ELEVEN_HERBS_AND_SPICES"}
7171

7272
tc.StartController(ctx, cfg)
7373
build := tc.TriggerBuild(ctx, pipelineID)

internal/integration/testcase_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,6 @@ func (t testcase) AssertLogsContain(build api.Build, content string) {
196196
assert.Contains(t, t.FetchLogs(build), content)
197197
}
198198

199-
func (t testcase) AssertLogsDoNotContain(build api.Build, content string) {
200-
t.Helper()
201-
202-
assert.NotContains(t, t.FetchLogs, content)
203-
}
204-
205199
func (t testcase) AssertArtifactsContain(build api.Build, expected ...string) {
206200
t.Helper()
207201
config, err := buildkite.NewTokenConfig(cfg.BuildkiteToken, false)

0 commit comments

Comments
 (0)