2025-04-01 14:47:30 -07:00
|
|
|
-- name: GetTemplateVersionTerraformValues :one
|
|
|
|
|
SELECT
|
|
|
|
|
template_version_terraform_values.*
|
|
|
|
|
FROM
|
|
|
|
|
template_version_terraform_values
|
|
|
|
|
WHERE
|
|
|
|
|
template_version_terraform_values.template_version_id = @template_version_id;
|
|
|
|
|
|
2025-03-24 10:01:50 -06:00
|
|
|
-- name: InsertTemplateVersionTerraformValuesByJobID :exec
|
|
|
|
|
INSERT INTO
|
|
|
|
|
template_version_terraform_values (
|
|
|
|
|
template_version_id,
|
|
|
|
|
cached_plan,
|
2025-05-12 13:50:07 -06:00
|
|
|
cached_module_files,
|
2025-05-14 12:21:36 -05:00
|
|
|
updated_at,
|
|
|
|
|
provisionerd_version
|
2025-03-24 10:01:50 -06:00
|
|
|
)
|
|
|
|
|
VALUES
|
|
|
|
|
(
|
|
|
|
|
(select id from template_versions where job_id = @job_id),
|
|
|
|
|
@cached_plan,
|
2025-05-12 13:50:07 -06:00
|
|
|
@cached_module_files,
|
2025-05-14 12:21:36 -05:00
|
|
|
@updated_at,
|
|
|
|
|
@provisionerd_version
|
2025-03-24 10:01:50 -06:00
|
|
|
);
|
2026-06-24 12:09:22 -05:00
|
|
|
|
|
|
|
|
-- name: HasTemplateVersionsUsingCachedModuleFileInOrg :one
|
|
|
|
|
-- Reports whether the given file is referenced as cached module files by any
|
|
|
|
|
-- template version in the given organization. Used to authorize provisioner
|
|
|
|
|
-- module-file downloads so a daemon cannot read another organization's cached
|
|
|
|
|
-- Terraform module source.
|
|
|
|
|
SELECT EXISTS (
|
|
|
|
|
SELECT 1
|
|
|
|
|
FROM template_version_terraform_values tvtv
|
|
|
|
|
JOIN template_versions tv
|
|
|
|
|
ON tv.id = tvtv.template_version_id
|
|
|
|
|
WHERE tvtv.cached_module_files = @file_id::uuid
|
|
|
|
|
AND tv.organization_id = @organization_id::uuid
|
|
|
|
|
);
|