Skip to content

Commit 72f76b1

Browse files
committed
WIP
1 parent 3a510ea commit 72f76b1

File tree

8 files changed

+269
-244
lines changed

8 files changed

+269
-244
lines changed

coderd/provisionerdserver/provisionerdserver.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -409,13 +409,10 @@ func (server *Server) UpdateJob(ctx context.Context, request *proto.UpdateJobReq
409409
}
410410
}
411411

412-
if templateVariable.Required && value == "" {
413-
return nil, xerrors.Errorf("template variable %q is required but it is missing", templateVariable.Name)
414-
}
415-
416412
variableValues = append(variableValues, &sdkproto.VariableValue{
417-
Name: templateVariable.Name,
418-
Value: value,
413+
Name: templateVariable.Name,
414+
Value: value,
415+
Sensitive: templateVariable.Sensitive,
419416
})
420417

421418
_, err = server.Database.InsertTemplateVersionVariable(ctx, database.InsertTemplateVersionVariableParams{
@@ -1303,8 +1300,9 @@ func asVariableValues(templateVariables []database.TemplateVersionVariable) []*s
13031300

13041301
if value != "" || v.Required {
13051302
apiVariableValues = append(apiVariableValues, &sdkproto.VariableValue{
1306-
Name: v.Name,
1307-
Value: v.Value,
1303+
Name: v.Name,
1304+
Value: v.Value,
1305+
Sensitive: v.Sensitive,
13081306
})
13091307
}
13101308
}

coderd/rbac/builtin_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
// BenchmarkRBACValueAllocation benchmarks the cost of allocating a rego input
1212
// value. By default, `ast.InterfaceToValue` is used to convert the input,
13-
// which uses json marshalling under the hood.
13+
// which uses json marshaling under the hood.
1414
//
1515
// Currently ast.Object.insert() is the slowest part of the process and allocates
1616
// the most amount of bytes. This general approach copies all of our struct

coderd/templateversions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ func (api *API) postTemplateVersionDryRun(rw http.ResponseWriter, r *http.Reques
417417
WorkspaceName: req.WorkspaceName,
418418
ParameterValues: parameterValues,
419419
RichParameterValues: richParameterValues,
420+
// FIXME Variable values?
420421
})
421422
if err != nil {
422423
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{

provisionerd/proto/provisionerd.pb.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

provisionerd/proto/provisionerd.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ message UpdateJobResponse {
111111
// If parameter schemas are sent, the job will respond
112112
// with resolved parameter values.
113113
repeated provisioner.ParameterValue parameter_values = 2;
114-
repeated provisioner.VariableValue variable_values = 5;
114+
repeated provisioner.VariableValue variable_values = 3;
115115
}
116116

117117
message CommitQuotaRequest {

provisionerd/runner/runner.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func (r *Runner) do(ctx context.Context) (*proto.CompletedJob, *proto.FailedJob)
417417
switch jobType := r.job.Type.(type) {
418418
case *proto.AcquiredJob_TemplateImport_:
419419
r.logger.Debug(context.Background(), "acquired job is template import",
420-
slog.F("variable_values", jobType.TemplateImport.VariableValues), // FIXME to be redacted
420+
slog.F("variable_values", redactVariableValues(jobType.TemplateImport.VariableValues)),
421421
)
422422

423423
failedJob := r.runReadmeParse(ctx)
@@ -438,7 +438,7 @@ func (r *Runner) do(ctx context.Context) (*proto.CompletedJob, *proto.FailedJob)
438438
slog.F("state_length", len(jobType.WorkspaceBuild.State)),
439439
slog.F("parameters", jobType.WorkspaceBuild.ParameterValues),
440440
slog.F("rich_parameter_values", jobType.WorkspaceBuild.RichParameterValues),
441-
slog.F("variable_values", jobType.WorkspaceBuild.VariableValues), // FIXME to be redacted
441+
slog.F("variable_values", redactVariableValues(jobType.WorkspaceBuild.VariableValues)),
442442
)
443443
return r.runWorkspaceBuild(ctx)
444444
default:
@@ -1073,5 +1073,17 @@ func (r *Runner) flushQueuedLogs(ctx context.Context) {
10731073
}
10741074

10751075
func redactVariableValues(variableValues []*sdkproto.VariableValue) []*sdkproto.VariableValue {
1076-
1076+
var redacted []*sdkproto.VariableValue
1077+
for _, v := range variableValues {
1078+
if v.Sensitive {
1079+
redacted = append(redacted, &sdkproto.VariableValue{
1080+
Name: v.Name,
1081+
Value: "*redacted*",
1082+
Sensitive: true,
1083+
})
1084+
continue
1085+
}
1086+
redacted = append(redacted, v)
1087+
}
1088+
return redacted
10771089
}

0 commit comments

Comments
 (0)