-
Notifications
You must be signed in to change notification settings - Fork 930
feat: enable Terraform debug mode via deployment configuration #8260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
4f3591f
bf4aace
ec5b3ff
b6185b2
9bd246b
0d5850f
58e4f74
6485ba7
7a2b196
a7545ed
eb9f19c
53c83a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,11 +34,13 @@ import ( | |
// build, job, err := b.Build(...) | ||
type Builder struct { | ||
// settings that control the kind of build you get | ||
workspace database.Workspace | ||
trans database.WorkspaceTransition | ||
version versionTarget | ||
state stateTarget | ||
logLevel string | ||
workspace database.Workspace | ||
trans database.WorkspaceTransition | ||
version versionTarget | ||
state stateTarget | ||
logLevel string | ||
deploymentValues *codersdk.DeploymentValues | ||
|
||
richParameterValues []codersdk.WorkspaceBuildParameter | ||
initiator uuid.UUID | ||
reason database.BuildReason | ||
|
@@ -128,6 +130,12 @@ func (b Builder) LogLevel(l string) Builder { | |
return b | ||
} | ||
|
||
func (b Builder) DeploymentValues(dv *codersdk.DeploymentValues) Builder { | ||
// nolint: revive | ||
b.deploymentValues = dv | ||
return b | ||
} | ||
|
||
func (b Builder) Initiator(u uuid.UUID) Builder { | ||
// nolint: revive | ||
b.initiator = u | ||
|
@@ -638,11 +646,19 @@ func (b *Builder) authorize(authFunc func(action rbac.Action, object rbac.Object | |
} | ||
} | ||
|
||
if b.logLevel != "" && !authFunc(rbac.ActionUpdate, template) { | ||
if b.logLevel != "" && !authFunc(rbac.ActionRead, rbac.ResourceDeploymentValues) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the de-facto way to check for admin? It feels like it'd be one of those things that might change in the future (esp. a read permission). Probably fine for now though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's why I covered it on the workspace build level with tests for all crucial roles. |
||
return BuildError{ | ||
http.StatusBadRequest, | ||
"Workspace builds with a custom log level are restricted to administrators only.", | ||
xerrors.New("Workspace builds with a custom log level are restricted to administrators only."), | ||
} | ||
} | ||
|
||
if b.logLevel != "" && b.deploymentValues != nil && !b.deploymentValues.EnableTerraformDebugMode { | ||
return BuildError{ | ||
http.StatusBadRequest, | ||
"Workspace builds with a custom log level are restricted to template authors only.", | ||
xerrors.New("Workspace builds with a custom log level are restricted to template authors only."), | ||
"Terraform debug mode is disabled in the deployment configuration.", | ||
xerrors.New("Terraform debug mode is disabled in the deployment configuration."), | ||
} | ||
} | ||
return nil | ||
|
Uh oh!
There was an error while loading. Please reload this page.