- Notifications
You must be signed in to change notification settings - Fork1k
chore: add db queries for dynamic parameters#17137
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1741,6 +1741,22 @@ func (q *querier) GetFileByID(ctx context.Context, id uuid.UUID) (database.File, | ||
return file, nil | ||
} | ||
func (q *querier) GetFileIDByTemplateVersionID(ctx context.Context, templateVersionID uuid.UUID) (uuid.UUID, error) { | ||
fileID, err := q.db.GetFileIDByTemplateVersionID(ctx, templateVersionID) | ||
if err != nil { | ||
return uuid.Nil, err | ||
} | ||
// This is a kind of weird check, because users will almost never have this | ||
// permission. Since this query is not currently used to provide data in a | ||
// user facing way, it's expected that this query is run as some system | ||
// subject in order to be authorized. | ||
err = q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceFile.WithID(fileID)) | ||
if err != nil { | ||
return uuid.Nil, err | ||
} | ||
aslilac marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
return fileID, nil | ||
} | ||
func (q *querier) GetFileTemplates(ctx context.Context, fileID uuid.UUID) ([]database.GetFileTemplatesRow, error) { | ||
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceSystem); err != nil { | ||
return nil, err | ||
@@ -2446,6 +2462,18 @@ func (q *querier) GetTemplateVersionParameters(ctx context.Context, templateVers | ||
return q.db.GetTemplateVersionParameters(ctx, templateVersionID) | ||
} | ||
func (q *querier) GetTemplateVersionTerraformValues(ctx context.Context, templateVersionID uuid.UUID) (database.TemplateVersionTerraformValue, error) { | ||
// The template_version_terraform_values table should follow the same access | ||
// control as the template_version table. Rather than reimplement the checks, | ||
// we just defer to existing implementation. (plus we'd need to use this query | ||
// to reimplement the proper checks anyway) | ||
_, err := q.GetTemplateVersionByID(ctx, templateVersionID) | ||
if err != nil { | ||
return database.TemplateVersionTerraformValue{}, err | ||
} | ||
return q.db.GetTemplateVersionTerraformValues(ctx, templateVersionID) | ||
} | ||
func (q *querier) GetTemplateVersionVariables(ctx context.Context, templateVersionID uuid.UUID) ([]database.TemplateVersionVariable, error) { | ||
tv, err := q.db.GetTemplateVersionByID(ctx, templateVersionID) | ||
if err != nil { | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.