refactor: Allow provisioner jobs to be disconnected from projects (#194)

* Nest jobs under an organization

* Rename project parameter to parameter schema

* Update references when computing project parameters

* Add files endpoint

* Allow one-off project import jobs

* Allow variables to be injected that are not defined by the schema

* Update API to use jobs first

* Fix CLI tests

* Fix linting

* Fix hex length for files table

* Reduce memory allocation for windows
This commit is contained in:
Kyle Carberry
2022-02-08 12:00:44 -06:00
committed by GitHub
parent 4c5e443b63
commit 7364933e65
37 changed files with 1380 additions and 995 deletions
+59 -55
View File
@@ -19,18 +19,18 @@ func New() database.Store {
organizationMembers: make([]database.OrganizationMember, 0),
users: make([]database.User, 0),
files: make([]database.File, 0),
parameterValue: make([]database.ParameterValue, 0),
project: make([]database.Project, 0),
projectVersion: make([]database.ProjectVersion, 0),
projectVersionParameter: make([]database.ProjectVersionParameter, 0),
provisionerDaemons: make([]database.ProvisionerDaemon, 0),
provisionerJobs: make([]database.ProvisionerJob, 0),
provisionerJobLog: make([]database.ProvisionerJobLog, 0),
workspace: make([]database.Workspace, 0),
workspaceResource: make([]database.WorkspaceResource, 0),
workspaceHistory: make([]database.WorkspaceHistory, 0),
workspaceAgent: make([]database.WorkspaceAgent, 0),
files: make([]database.File, 0),
parameterValue: make([]database.ParameterValue, 0),
parameterSchema: make([]database.ParameterSchema, 0),
project: make([]database.Project, 0),
projectVersion: make([]database.ProjectVersion, 0),
provisionerDaemons: make([]database.ProvisionerDaemon, 0),
provisionerJobs: make([]database.ProvisionerJob, 0),
provisionerJobLog: make([]database.ProvisionerJobLog, 0),
workspace: make([]database.Workspace, 0),
workspaceResource: make([]database.WorkspaceResource, 0),
workspaceHistory: make([]database.WorkspaceHistory, 0),
workspaceAgent: make([]database.WorkspaceAgent, 0),
}
}
@@ -45,18 +45,18 @@ type fakeQuerier struct {
users []database.User
// New tables
files []database.File
parameterValue []database.ParameterValue
project []database.Project
projectVersion []database.ProjectVersion
projectVersionParameter []database.ProjectVersionParameter
provisionerDaemons []database.ProvisionerDaemon
provisionerJobs []database.ProvisionerJob
provisionerJobLog []database.ProvisionerJobLog
workspace []database.Workspace
workspaceAgent []database.WorkspaceAgent
workspaceHistory []database.WorkspaceHistory
workspaceResource []database.WorkspaceResource
files []database.File
parameterValue []database.ParameterValue
parameterSchema []database.ParameterSchema
project []database.Project
projectVersion []database.ProjectVersion
provisionerDaemons []database.ProvisionerDaemon
provisionerJobs []database.ProvisionerJob
provisionerJobLog []database.ProvisionerJobLog
workspace []database.Workspace
workspaceAgent []database.WorkspaceAgent
workspaceHistory []database.WorkspaceHistory
workspaceResource []database.WorkspaceResource
}
// InTx doesn't rollback data properly for in-memory yet.
@@ -445,16 +445,16 @@ func (q *fakeQuerier) GetProjectVersionByID(_ context.Context, projectVersionID
return database.ProjectVersion{}, sql.ErrNoRows
}
func (q *fakeQuerier) GetProjectVersionParametersByVersionID(_ context.Context, projectVersionID uuid.UUID) ([]database.ProjectVersionParameter, error) {
func (q *fakeQuerier) GetParameterSchemasByJobID(_ context.Context, jobID uuid.UUID) ([]database.ParameterSchema, error) {
q.mutex.Lock()
defer q.mutex.Unlock()
parameters := make([]database.ProjectVersionParameter, 0)
for _, projectParameter := range q.projectVersionParameter {
if projectParameter.ProjectVersionID.String() != projectVersionID.String() {
parameters := make([]database.ParameterSchema, 0)
for _, parameterSchema := range q.parameterSchema {
if parameterSchema.JobID.String() != jobID.String() {
continue
}
parameters = append(parameters, projectParameter)
parameters = append(parameters, parameterSchema)
}
if len(parameters) == 0 {
return nil, sql.ErrNoRows
@@ -590,6 +590,7 @@ func (q *fakeQuerier) InsertFile(_ context.Context, arg database.InsertFileParam
file := database.File{
Hash: arg.Hash,
CreatedAt: arg.CreatedAt,
CreatedBy: arg.CreatedBy,
Mimetype: arg.Mimetype,
Data: arg.Data,
}
@@ -652,13 +653,15 @@ func (q *fakeQuerier) InsertProject(_ context.Context, arg database.InsertProjec
q.mutex.Lock()
defer q.mutex.Unlock()
//nolint:gosimple
project := database.Project{
ID: arg.ID,
CreatedAt: arg.CreatedAt,
UpdatedAt: arg.UpdatedAt,
OrganizationID: arg.OrganizationID,
Name: arg.Name,
Provisioner: arg.Provisioner,
ID: arg.ID,
CreatedAt: arg.CreatedAt,
UpdatedAt: arg.UpdatedAt,
OrganizationID: arg.OrganizationID,
Name: arg.Name,
Provisioner: arg.Provisioner,
ActiveVersionID: arg.ActiveVersionID,
}
q.project = append(q.project, project)
return project, nil
@@ -670,15 +673,13 @@ func (q *fakeQuerier) InsertProjectVersion(_ context.Context, arg database.Inser
//nolint:gosimple
version := database.ProjectVersion{
ID: arg.ID,
ProjectID: arg.ProjectID,
CreatedAt: arg.CreatedAt,
UpdatedAt: arg.UpdatedAt,
Name: arg.Name,
Description: arg.Description,
StorageMethod: arg.StorageMethod,
StorageSource: arg.StorageSource,
ImportJobID: arg.ImportJobID,
ID: arg.ID,
ProjectID: arg.ProjectID,
CreatedAt: arg.CreatedAt,
UpdatedAt: arg.UpdatedAt,
Name: arg.Name,
Description: arg.Description,
ImportJobID: arg.ImportJobID,
}
q.projectVersion = append(q.projectVersion, version)
return version, nil
@@ -703,15 +704,15 @@ func (q *fakeQuerier) InsertProvisionerJobLogs(_ context.Context, arg database.I
return logs, nil
}
func (q *fakeQuerier) InsertProjectVersionParameter(_ context.Context, arg database.InsertProjectVersionParameterParams) (database.ProjectVersionParameter, error) {
func (q *fakeQuerier) InsertParameterSchema(_ context.Context, arg database.InsertParameterSchemaParams) (database.ParameterSchema, error) {
q.mutex.Lock()
defer q.mutex.Unlock()
//nolint:gosimple
param := database.ProjectVersionParameter{
param := database.ParameterSchema{
ID: arg.ID,
CreatedAt: arg.CreatedAt,
ProjectVersionID: arg.ProjectVersionID,
JobID: arg.JobID,
Name: arg.Name,
Description: arg.Description,
DefaultSourceScheme: arg.DefaultSourceScheme,
@@ -727,7 +728,7 @@ func (q *fakeQuerier) InsertProjectVersionParameter(_ context.Context, arg datab
ValidationTypeSystem: arg.ValidationTypeSystem,
ValidationValueType: arg.ValidationValueType,
}
q.projectVersionParameter = append(q.projectVersionParameter, param)
q.parameterSchema = append(q.parameterSchema, param)
return param, nil
}
@@ -750,13 +751,16 @@ func (q *fakeQuerier) InsertProvisionerJob(_ context.Context, arg database.Inser
defer q.mutex.Unlock()
job := database.ProvisionerJob{
ID: arg.ID,
CreatedAt: arg.CreatedAt,
UpdatedAt: arg.UpdatedAt,
InitiatorID: arg.InitiatorID,
Provisioner: arg.Provisioner,
Type: arg.Type,
Input: arg.Input,
ID: arg.ID,
CreatedAt: arg.CreatedAt,
UpdatedAt: arg.UpdatedAt,
OrganizationID: arg.OrganizationID,
InitiatorID: arg.InitiatorID,
Provisioner: arg.Provisioner,
StorageMethod: arg.StorageMethod,
StorageSource: arg.StorageSource,
Type: arg.Type,
Input: arg.Input,
}
q.provisionerJobs = append(q.provisionerJobs, job)
return job, nil
+38 -36
View File
@@ -42,13 +42,13 @@ CREATE TYPE parameter_type_system AS ENUM (
'hcl'
);
CREATE TYPE project_storage_method AS ENUM (
'inline-archive'
CREATE TYPE provisioner_job_type AS ENUM (
'project_version_import',
'workspace_provision'
);
CREATE TYPE provisioner_job_type AS ENUM (
'project_import',
'workspace_provision'
CREATE TYPE provisioner_storage_method AS ENUM (
'file'
);
CREATE TYPE provisioner_type AS ENUM (
@@ -89,6 +89,7 @@ CREATE TABLE api_keys (
CREATE TABLE file (
hash character varying(32) NOT NULL,
created_at timestamp with time zone NOT NULL,
created_by text NOT NULL,
mimetype character varying(64) NOT NULL,
data bytea NOT NULL
);
@@ -120,6 +121,26 @@ CREATE TABLE organizations (
workspace_auto_off boolean DEFAULT false NOT NULL
);
CREATE TABLE parameter_schema (
id uuid NOT NULL,
created_at timestamp with time zone NOT NULL,
job_id uuid NOT NULL,
name character varying(64) NOT NULL,
description character varying(8192) DEFAULT ''::character varying NOT NULL,
default_source_scheme parameter_source_scheme,
default_source_value text,
allow_override_source boolean NOT NULL,
default_destination_scheme parameter_destination_scheme,
default_destination_value text,
allow_override_destination boolean NOT NULL,
default_refresh text NOT NULL,
redisplay_value boolean NOT NULL,
validation_error character varying(256) NOT NULL,
validation_condition character varying(512) NOT NULL,
validation_type_system parameter_type_system NOT NULL,
validation_value_type character varying(64) NOT NULL
);
CREATE TABLE parameter_value (
id uuid NOT NULL,
name character varying(64) NOT NULL,
@@ -140,7 +161,7 @@ CREATE TABLE project (
organization_id text NOT NULL,
name character varying(64) NOT NULL,
provisioner provisioner_type NOT NULL,
active_version_id uuid
active_version_id uuid NOT NULL
);
CREATE TABLE project_version (
@@ -150,31 +171,9 @@ CREATE TABLE project_version (
updated_at timestamp with time zone NOT NULL,
name character varying(64) NOT NULL,
description character varying(1048576) NOT NULL,
storage_method project_storage_method NOT NULL,
storage_source bytea NOT NULL,
import_job_id uuid NOT NULL
);
CREATE TABLE project_version_parameter (
id uuid NOT NULL,
created_at timestamp with time zone NOT NULL,
project_version_id uuid NOT NULL,
name character varying(64) NOT NULL,
description character varying(8192) DEFAULT ''::character varying NOT NULL,
default_source_scheme parameter_source_scheme,
default_source_value text,
allow_override_source boolean NOT NULL,
default_destination_scheme parameter_destination_scheme,
default_destination_value text,
allow_override_destination boolean NOT NULL,
default_refresh text NOT NULL,
redisplay_value boolean NOT NULL,
validation_error character varying(256) NOT NULL,
validation_condition character varying(512) NOT NULL,
validation_type_system parameter_type_system NOT NULL,
validation_value_type character varying(64) NOT NULL
);
CREATE TABLE provisioner_daemon (
id uuid NOT NULL,
created_at timestamp with time zone NOT NULL,
@@ -191,8 +190,11 @@ CREATE TABLE provisioner_job (
cancelled_at timestamp with time zone,
completed_at timestamp with time zone,
error text,
organization_id text NOT NULL,
initiator_id text NOT NULL,
provisioner provisioner_type NOT NULL,
storage_method provisioner_storage_method NOT NULL,
storage_source text NOT NULL,
type provisioner_job_type NOT NULL,
input jsonb NOT NULL,
worker_id uuid
@@ -275,6 +277,12 @@ CREATE TABLE workspace_resource (
ALTER TABLE ONLY file
ADD CONSTRAINT file_hash_key UNIQUE (hash);
ALTER TABLE ONLY parameter_schema
ADD CONSTRAINT parameter_schema_id_key UNIQUE (id);
ALTER TABLE ONLY parameter_schema
ADD CONSTRAINT parameter_schema_job_id_name_key UNIQUE (job_id, name);
ALTER TABLE ONLY parameter_value
ADD CONSTRAINT parameter_value_id_key UNIQUE (id);
@@ -290,12 +298,6 @@ ALTER TABLE ONLY project
ALTER TABLE ONLY project_version
ADD CONSTRAINT project_version_id_key UNIQUE (id);
ALTER TABLE ONLY project_version_parameter
ADD CONSTRAINT project_version_parameter_id_key UNIQUE (id);
ALTER TABLE ONLY project_version_parameter
ADD CONSTRAINT project_version_parameter_project_version_id_name_key UNIQUE (project_version_id, name);
ALTER TABLE ONLY project_version
ADD CONSTRAINT project_version_project_id_name_key UNIQUE (project_id, name);
@@ -335,8 +337,8 @@ ALTER TABLE ONLY workspace_resource
ALTER TABLE ONLY workspace_resource
ADD CONSTRAINT workspace_resource_workspace_history_id_type_name_key UNIQUE (workspace_history_id, type, name);
ALTER TABLE ONLY project_version_parameter
ADD CONSTRAINT project_version_parameter_project_version_id_fkey FOREIGN KEY (project_version_id) REFERENCES project_version(id) ON DELETE CASCADE;
ALTER TABLE ONLY parameter_schema
ADD CONSTRAINT parameter_schema_job_id_fkey FOREIGN KEY (job_id) REFERENCES provisioner_job(id) ON DELETE CASCADE;
ALTER TABLE ONLY project_version
ADD CONSTRAINT project_version_project_id_fkey FOREIGN KEY (project_id) REFERENCES project(id);
+3 -52
View File
@@ -1,7 +1,8 @@
-- Store arbitrary data like project source code or avatars.
CREATE TABLE file (
hash varchar(32) NOT NULL UNIQUE,
hash varchar(64) NOT NULL UNIQUE,
created_at timestamptz NOT NULL,
created_by text NOT NULL,
mimetype varchar(64) NOT NULL,
data bytea NOT NULL
);
@@ -20,14 +21,12 @@ CREATE TABLE project (
provisioner provisioner_type NOT NULL,
-- Target's a Project Version to use for Workspaces.
-- If a Workspace doesn't match this version, it will be prompted to rebuild.
active_version_id uuid,
active_version_id uuid NOT NULL,
-- Disallow projects to have the same name under
-- the same organization.
UNIQUE(organization_id, name)
);
CREATE TYPE project_storage_method AS ENUM ('inline-archive');
-- Project Versions store historical project data. When a Project Version is imported,
-- an "import" job is queued to parse parameters. A Project Version
-- can only be used if the import job succeeds.
@@ -43,8 +42,6 @@ CREATE TABLE project_version (
-- Extracted from a README.md on import.
-- Maximum of 1MB.
description varchar(1048576) NOT NULL,
storage_method project_storage_method NOT NULL,
storage_source bytea NOT NULL,
-- The import job for a Project Version. This is used
-- to detect if an import was successful.
import_job_id uuid NOT NULL,
@@ -52,49 +49,3 @@ CREATE TABLE project_version (
-- multiple times.
UNIQUE(project_id, name)
);
-- Types of parameters the automator supports.
CREATE TYPE parameter_type_system AS ENUM ('none', 'hcl');
-- Supported schemes for a parameter source.
CREATE TYPE parameter_source_scheme AS ENUM('none', 'data');
-- Supported schemes for a parameter destination.
CREATE TYPE parameter_destination_scheme AS ENUM('none', 'environment_variable', 'provisioner_variable');
-- Stores project version parameters parsed on import.
-- No secrets are stored here.
--
-- All parameter validation occurs server-side to process
-- complex validations.
--
-- Parameter types, description, and validation will produce
-- a UI for users to enter values.
-- Needs to be made consistent with the examples below.
CREATE TABLE project_version_parameter (
id uuid NOT NULL UNIQUE,
created_at timestamptz NOT NULL,
project_version_id uuid NOT NULL REFERENCES project_version(id) ON DELETE CASCADE,
name varchar(64) NOT NULL,
-- 8KB limit
description varchar(8192) NOT NULL DEFAULT '',
-- eg. data://inlinevalue
default_source_scheme parameter_source_scheme,
default_source_value text,
-- Allows the user to override the source.
allow_override_source boolean NOT null,
-- eg. env://SOME_VARIABLE, tfvars://example
default_destination_scheme parameter_destination_scheme,
default_destination_value text,
-- Allows the user to override the destination.
allow_override_destination boolean NOT null,
default_refresh text NOT NULL,
-- Whether the consumer can view the source and destinations.
redisplay_value boolean NOT null,
-- This error would appear in the UI if the condition is not met.
validation_error varchar(256) NOT NULL,
validation_condition varchar(512) NOT NULL,
validation_type_system parameter_type_system NOT NULL,
validation_value_type varchar(64) NOT NULL,
UNIQUE(project_version_id, name)
);
+51 -2
View File
@@ -9,10 +9,12 @@ CREATE TABLE IF NOT EXISTS provisioner_daemon (
);
CREATE TYPE provisioner_job_type AS ENUM (
'project_import',
'project_version_import',
'workspace_provision'
);
CREATE TYPE provisioner_storage_method AS ENUM ('file');
CREATE TABLE IF NOT EXISTS provisioner_job (
id uuid NOT NULL UNIQUE,
created_at timestamptz NOT NULL,
@@ -21,8 +23,11 @@ CREATE TABLE IF NOT EXISTS provisioner_job (
cancelled_at timestamptz,
completed_at timestamptz,
error text,
organization_id text NOT NULL,
initiator_id text NOT NULL,
provisioner provisioner_type NOT NULL,
storage_method provisioner_storage_method NOT NULL,
storage_source text NOT NULL,
type provisioner_job_type NOT NULL,
input jsonb NOT NULL,
worker_id uuid
@@ -57,6 +62,15 @@ CREATE TYPE parameter_scope AS ENUM (
'workspace'
);
-- Types of parameters the automator supports.
CREATE TYPE parameter_type_system AS ENUM ('none', 'hcl');
-- Supported schemes for a parameter source.
CREATE TYPE parameter_source_scheme AS ENUM('none', 'data');
-- Supported schemes for a parameter destination.
CREATE TYPE parameter_destination_scheme AS ENUM('none', 'environment_variable', 'provisioner_variable');
-- Parameters are provided to jobs for provisioning and to workspaces.
CREATE TABLE parameter_value (
id uuid NOT NULL UNIQUE,
@@ -71,4 +85,39 @@ CREATE TABLE parameter_value (
destination_value text NOT NULL,
-- Prevents duplicates for parameters in the same scope.
UNIQUE(name, scope, scope_id)
);
);
-- Stores project version parameters parsed on import.
-- No secrets are stored here.
--
-- All parameter validation occurs server-side to process
-- complex validations.
--
-- Parameter types, description, and validation will produce
-- a UI for users to enter values.
-- Needs to be made consistent with the examples below.
CREATE TABLE parameter_schema (
id uuid NOT NULL UNIQUE,
created_at timestamptz NOT NULL,
job_id uuid NOT NULL REFERENCES provisioner_job(id) ON DELETE CASCADE,
name varchar(64) NOT NULL,
description varchar(8192) NOT NULL DEFAULT '',
default_source_scheme parameter_source_scheme,
default_source_value text,
-- Allows the user to override the source.
allow_override_source boolean NOT null,
-- eg. env://SOME_VARIABLE, tfvars://example
default_destination_scheme parameter_destination_scheme,
default_destination_value text,
-- Allows the user to override the destination.
allow_override_destination boolean NOT null,
default_refresh text NOT NULL,
-- Whether the consumer can view the source and destinations.
redisplay_value boolean NOT null,
-- This error would appear in the UI if the condition is not met.
validation_error varchar(256) NOT NULL,
validation_condition varchar(512) NOT NULL,
validation_type_system parameter_type_system NOT NULL,
validation_value_type varchar(64) NOT NULL,
UNIQUE(job_id, name)
);
+64 -62
View File
@@ -151,29 +151,11 @@ func (e *ParameterTypeSystem) Scan(src interface{}) error {
return nil
}
type ProjectStorageMethod string
const (
ProjectStorageMethodInlineArchive ProjectStorageMethod = "inline-archive"
)
func (e *ProjectStorageMethod) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = ProjectStorageMethod(s)
case string:
*e = ProjectStorageMethod(s)
default:
return fmt.Errorf("unsupported scan type for ProjectStorageMethod: %T", src)
}
return nil
}
type ProvisionerJobType string
const (
ProvisionerJobTypeProjectImport ProvisionerJobType = "project_import"
ProvisionerJobTypeWorkspaceProvision ProvisionerJobType = "workspace_provision"
ProvisionerJobTypeProjectVersionImport ProvisionerJobType = "project_version_import"
ProvisionerJobTypeWorkspaceProvision ProvisionerJobType = "workspace_provision"
)
func (e *ProvisionerJobType) Scan(src interface{}) error {
@@ -188,6 +170,24 @@ func (e *ProvisionerJobType) Scan(src interface{}) error {
return nil
}
type ProvisionerStorageMethod string
const (
ProvisionerStorageMethodFile ProvisionerStorageMethod = "file"
)
func (e *ProvisionerStorageMethod) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = ProvisionerStorageMethod(s)
case string:
*e = ProvisionerStorageMethod(s)
default:
return fmt.Errorf("unsupported scan type for ProvisionerStorageMethod: %T", src)
}
return nil
}
type ProvisionerType string
const (
@@ -268,6 +268,7 @@ type APIKey struct {
type File struct {
Hash string `db:"hash" json:"hash"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
CreatedBy string `db:"created_by" json:"created_by"`
Mimetype string `db:"mimetype" json:"mimetype"`
Data []byte `db:"data" json:"data"`
}
@@ -299,6 +300,26 @@ type OrganizationMember struct {
Roles []string `db:"roles" json:"roles"`
}
type ParameterSchema struct {
ID uuid.UUID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
JobID uuid.UUID `db:"job_id" json:"job_id"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
DefaultSourceScheme ParameterSourceScheme `db:"default_source_scheme" json:"default_source_scheme"`
DefaultSourceValue sql.NullString `db:"default_source_value" json:"default_source_value"`
AllowOverrideSource bool `db:"allow_override_source" json:"allow_override_source"`
DefaultDestinationScheme ParameterDestinationScheme `db:"default_destination_scheme" json:"default_destination_scheme"`
DefaultDestinationValue sql.NullString `db:"default_destination_value" json:"default_destination_value"`
AllowOverrideDestination bool `db:"allow_override_destination" json:"allow_override_destination"`
DefaultRefresh string `db:"default_refresh" json:"default_refresh"`
RedisplayValue bool `db:"redisplay_value" json:"redisplay_value"`
ValidationError string `db:"validation_error" json:"validation_error"`
ValidationCondition string `db:"validation_condition" json:"validation_condition"`
ValidationTypeSystem ParameterTypeSystem `db:"validation_type_system" json:"validation_type_system"`
ValidationValueType string `db:"validation_value_type" json:"validation_value_type"`
}
type ParameterValue struct {
ID uuid.UUID `db:"id" json:"id"`
Name string `db:"name" json:"name"`
@@ -319,39 +340,17 @@ type Project struct {
OrganizationID string `db:"organization_id" json:"organization_id"`
Name string `db:"name" json:"name"`
Provisioner ProvisionerType `db:"provisioner" json:"provisioner"`
ActiveVersionID uuid.NullUUID `db:"active_version_id" json:"active_version_id"`
ActiveVersionID uuid.UUID `db:"active_version_id" json:"active_version_id"`
}
type ProjectVersion struct {
ID uuid.UUID `db:"id" json:"id"`
ProjectID uuid.UUID `db:"project_id" json:"project_id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
StorageMethod ProjectStorageMethod `db:"storage_method" json:"storage_method"`
StorageSource []byte `db:"storage_source" json:"storage_source"`
ImportJobID uuid.UUID `db:"import_job_id" json:"import_job_id"`
}
type ProjectVersionParameter struct {
ID uuid.UUID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
ProjectVersionID uuid.UUID `db:"project_version_id" json:"project_version_id"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
DefaultSourceScheme ParameterSourceScheme `db:"default_source_scheme" json:"default_source_scheme"`
DefaultSourceValue sql.NullString `db:"default_source_value" json:"default_source_value"`
AllowOverrideSource bool `db:"allow_override_source" json:"allow_override_source"`
DefaultDestinationScheme ParameterDestinationScheme `db:"default_destination_scheme" json:"default_destination_scheme"`
DefaultDestinationValue sql.NullString `db:"default_destination_value" json:"default_destination_value"`
AllowOverrideDestination bool `db:"allow_override_destination" json:"allow_override_destination"`
DefaultRefresh string `db:"default_refresh" json:"default_refresh"`
RedisplayValue bool `db:"redisplay_value" json:"redisplay_value"`
ValidationError string `db:"validation_error" json:"validation_error"`
ValidationCondition string `db:"validation_condition" json:"validation_condition"`
ValidationTypeSystem ParameterTypeSystem `db:"validation_type_system" json:"validation_type_system"`
ValidationValueType string `db:"validation_value_type" json:"validation_value_type"`
ID uuid.UUID `db:"id" json:"id"`
ProjectID uuid.UUID `db:"project_id" json:"project_id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
ImportJobID uuid.UUID `db:"import_job_id" json:"import_job_id"`
}
type ProvisionerDaemon struct {
@@ -363,18 +362,21 @@ type ProvisionerDaemon struct {
}
type ProvisionerJob struct {
ID uuid.UUID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
StartedAt sql.NullTime `db:"started_at" json:"started_at"`
CancelledAt sql.NullTime `db:"cancelled_at" json:"cancelled_at"`
CompletedAt sql.NullTime `db:"completed_at" json:"completed_at"`
Error sql.NullString `db:"error" json:"error"`
InitiatorID string `db:"initiator_id" json:"initiator_id"`
Provisioner ProvisionerType `db:"provisioner" json:"provisioner"`
Type ProvisionerJobType `db:"type" json:"type"`
Input json.RawMessage `db:"input" json:"input"`
WorkerID uuid.NullUUID `db:"worker_id" json:"worker_id"`
ID uuid.UUID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
StartedAt sql.NullTime `db:"started_at" json:"started_at"`
CancelledAt sql.NullTime `db:"cancelled_at" json:"cancelled_at"`
CompletedAt sql.NullTime `db:"completed_at" json:"completed_at"`
Error sql.NullString `db:"error" json:"error"`
OrganizationID string `db:"organization_id" json:"organization_id"`
InitiatorID string `db:"initiator_id" json:"initiator_id"`
Provisioner ProvisionerType `db:"provisioner" json:"provisioner"`
StorageMethod ProvisionerStorageMethod `db:"storage_method" json:"storage_method"`
StorageSource string `db:"storage_source" json:"storage_source"`
Type ProvisionerJobType `db:"type" json:"type"`
Input json.RawMessage `db:"input" json:"input"`
WorkerID uuid.NullUUID `db:"worker_id" json:"worker_id"`
}
type ProvisionerJobLog struct {
+2 -2
View File
@@ -16,12 +16,12 @@ type querier interface {
GetOrganizationByName(ctx context.Context, name string) (Organization, error)
GetOrganizationMemberByUserID(ctx context.Context, arg GetOrganizationMemberByUserIDParams) (OrganizationMember, error)
GetOrganizationsByUserID(ctx context.Context, userID string) ([]Organization, error)
GetParameterSchemasByJobID(ctx context.Context, jobID uuid.UUID) ([]ParameterSchema, error)
GetParameterValuesByScope(ctx context.Context, arg GetParameterValuesByScopeParams) ([]ParameterValue, error)
GetProjectByID(ctx context.Context, id uuid.UUID) (Project, error)
GetProjectByOrganizationAndName(ctx context.Context, arg GetProjectByOrganizationAndNameParams) (Project, error)
GetProjectVersionByID(ctx context.Context, id uuid.UUID) (ProjectVersion, error)
GetProjectVersionByProjectIDAndName(ctx context.Context, arg GetProjectVersionByProjectIDAndNameParams) (ProjectVersion, error)
GetProjectVersionParametersByVersionID(ctx context.Context, projectVersionID uuid.UUID) ([]ProjectVersionParameter, error)
GetProjectVersionsByProjectID(ctx context.Context, projectID uuid.UUID) ([]ProjectVersion, error)
GetProjectsByOrganizationIDs(ctx context.Context, ids []string) ([]Project, error)
GetProvisionerDaemonByID(ctx context.Context, id uuid.UUID) (ProvisionerDaemon, error)
@@ -45,10 +45,10 @@ type querier interface {
InsertFile(ctx context.Context, arg InsertFileParams) (File, error)
InsertOrganization(ctx context.Context, arg InsertOrganizationParams) (Organization, error)
InsertOrganizationMember(ctx context.Context, arg InsertOrganizationMemberParams) (OrganizationMember, error)
InsertParameterSchema(ctx context.Context, arg InsertParameterSchemaParams) (ParameterSchema, error)
InsertParameterValue(ctx context.Context, arg InsertParameterValueParams) (ParameterValue, error)
InsertProject(ctx context.Context, arg InsertProjectParams) (Project, error)
InsertProjectVersion(ctx context.Context, arg InsertProjectVersionParams) (ProjectVersion, error)
InsertProjectVersionParameter(ctx context.Context, arg InsertProjectVersionParameterParams) (ProjectVersionParameter, error)
InsertProvisionerDaemon(ctx context.Context, arg InsertProvisionerDaemonParams) (ProvisionerDaemon, error)
InsertProvisionerJob(ctx context.Context, arg InsertProvisionerJobParams) (ProvisionerJob, error)
InsertProvisionerJobLogs(ctx context.Context, arg InsertProvisionerJobLogsParams) ([]ProvisionerJobLog, error)
+16 -14
View File
@@ -165,13 +165,13 @@ FROM
WHERE
organization_id = ANY(@ids :: text [ ]);
-- name: GetProjectVersionParametersByVersionID :many
-- name: GetParameterSchemasByJobID :many
SELECT
*
FROM
project_version_parameter
parameter_schema
WHERE
project_version_id = $1;
job_id = $1;
-- name: GetProjectVersionsByProjectID :many
SELECT
@@ -364,9 +364,9 @@ VALUES
-- name: InsertFile :one
INSERT INTO
file (hash, created_at, mimetype, data)
file (hash, created_at, created_by, mimetype, data)
VALUES
($1, $2, $3, $4) RETURNING *;
($1, $2, $3, $4, $5) RETURNING *;
-- name: InsertProvisionerJobLogs :many
INSERT INTO
@@ -422,10 +422,11 @@ INSERT INTO
updated_at,
organization_id,
name,
provisioner
provisioner,
active_version_id
)
VALUES
($1, $2, $3, $4, $5, $6) RETURNING *;
($1, $2, $3, $4, $5, $6, $7) RETURNING *;
-- name: InsertProjectVersion :one
INSERT INTO
@@ -436,19 +437,17 @@ INSERT INTO
updated_at,
name,
description,
storage_method,
storage_source,
import_job_id
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING *;
($1, $2, $3, $4, $5, $6, $7) RETURNING *;
-- name: InsertProjectVersionParameter :one
-- name: InsertParameterSchema :one
INSERT INTO
project_version_parameter (
parameter_schema (
id,
created_at,
project_version_id,
job_id,
name,
description,
default_source_scheme,
@@ -497,13 +496,16 @@ INSERT INTO
id,
created_at,
updated_at,
organization_id,
initiator_id,
provisioner,
storage_method,
storage_source,
type,
input
)
VALUES
($1, $2, $3, $4, $5, $6, $7) RETURNING *;
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING *;
-- name: InsertUser :one
INSERT INTO
+213 -202
View File
@@ -37,7 +37,7 @@ WHERE
SKIP LOCKED
LIMIT
1
) RETURNING id, created_at, updated_at, started_at, cancelled_at, completed_at, error, initiator_id, provisioner, type, input, worker_id
) RETURNING id, created_at, updated_at, started_at, cancelled_at, completed_at, error, organization_id, initiator_id, provisioner, storage_method, storage_source, type, input, worker_id
`
type AcquireProvisionerJobParams struct {
@@ -63,8 +63,11 @@ func (q *sqlQuerier) AcquireProvisionerJob(ctx context.Context, arg AcquireProvi
&i.CancelledAt,
&i.CompletedAt,
&i.Error,
&i.OrganizationID,
&i.InitiatorID,
&i.Provisioner,
&i.StorageMethod,
&i.StorageSource,
&i.Type,
&i.Input,
&i.WorkerID,
@@ -108,7 +111,7 @@ func (q *sqlQuerier) GetAPIKeyByID(ctx context.Context, id string) (APIKey, erro
const getFileByHash = `-- name: GetFileByHash :one
SELECT
hash, created_at, mimetype, data
hash, created_at, created_by, mimetype, data
FROM
file
WHERE
@@ -123,6 +126,7 @@ func (q *sqlQuerier) GetFileByHash(ctx context.Context, hash string) (File, erro
err := row.Scan(
&i.Hash,
&i.CreatedAt,
&i.CreatedBy,
&i.Mimetype,
&i.Data,
)
@@ -265,6 +269,56 @@ func (q *sqlQuerier) GetOrganizationsByUserID(ctx context.Context, userID string
return items, nil
}
const getParameterSchemasByJobID = `-- name: GetParameterSchemasByJobID :many
SELECT
id, created_at, job_id, name, description, default_source_scheme, default_source_value, allow_override_source, default_destination_scheme, default_destination_value, allow_override_destination, default_refresh, redisplay_value, validation_error, validation_condition, validation_type_system, validation_value_type
FROM
parameter_schema
WHERE
job_id = $1
`
func (q *sqlQuerier) GetParameterSchemasByJobID(ctx context.Context, jobID uuid.UUID) ([]ParameterSchema, error) {
rows, err := q.db.QueryContext(ctx, getParameterSchemasByJobID, jobID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ParameterSchema
for rows.Next() {
var i ParameterSchema
if err := rows.Scan(
&i.ID,
&i.CreatedAt,
&i.JobID,
&i.Name,
&i.Description,
&i.DefaultSourceScheme,
&i.DefaultSourceValue,
&i.AllowOverrideSource,
&i.DefaultDestinationScheme,
&i.DefaultDestinationValue,
&i.AllowOverrideDestination,
&i.DefaultRefresh,
&i.RedisplayValue,
&i.ValidationError,
&i.ValidationCondition,
&i.ValidationTypeSystem,
&i.ValidationValueType,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getParameterValuesByScope = `-- name: GetParameterValuesByScope :many
SELECT
id, name, created_at, updated_at, scope, scope_id, source_scheme, source_value, destination_scheme, destination_value
@@ -374,7 +428,7 @@ func (q *sqlQuerier) GetProjectByOrganizationAndName(ctx context.Context, arg Ge
const getProjectVersionByID = `-- name: GetProjectVersionByID :one
SELECT
id, project_id, created_at, updated_at, name, description, storage_method, storage_source, import_job_id
id, project_id, created_at, updated_at, name, description, import_job_id
FROM
project_version
WHERE
@@ -391,8 +445,6 @@ func (q *sqlQuerier) GetProjectVersionByID(ctx context.Context, id uuid.UUID) (P
&i.UpdatedAt,
&i.Name,
&i.Description,
&i.StorageMethod,
&i.StorageSource,
&i.ImportJobID,
)
return i, err
@@ -400,7 +452,7 @@ func (q *sqlQuerier) GetProjectVersionByID(ctx context.Context, id uuid.UUID) (P
const getProjectVersionByProjectIDAndName = `-- name: GetProjectVersionByProjectIDAndName :one
SELECT
id, project_id, created_at, updated_at, name, description, storage_method, storage_source, import_job_id
id, project_id, created_at, updated_at, name, description, import_job_id
FROM
project_version
WHERE
@@ -423,66 +475,14 @@ func (q *sqlQuerier) GetProjectVersionByProjectIDAndName(ctx context.Context, ar
&i.UpdatedAt,
&i.Name,
&i.Description,
&i.StorageMethod,
&i.StorageSource,
&i.ImportJobID,
)
return i, err
}
const getProjectVersionParametersByVersionID = `-- name: GetProjectVersionParametersByVersionID :many
SELECT
id, created_at, project_version_id, name, description, default_source_scheme, default_source_value, allow_override_source, default_destination_scheme, default_destination_value, allow_override_destination, default_refresh, redisplay_value, validation_error, validation_condition, validation_type_system, validation_value_type
FROM
project_version_parameter
WHERE
project_version_id = $1
`
func (q *sqlQuerier) GetProjectVersionParametersByVersionID(ctx context.Context, projectVersionID uuid.UUID) ([]ProjectVersionParameter, error) {
rows, err := q.db.QueryContext(ctx, getProjectVersionParametersByVersionID, projectVersionID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ProjectVersionParameter
for rows.Next() {
var i ProjectVersionParameter
if err := rows.Scan(
&i.ID,
&i.CreatedAt,
&i.ProjectVersionID,
&i.Name,
&i.Description,
&i.DefaultSourceScheme,
&i.DefaultSourceValue,
&i.AllowOverrideSource,
&i.DefaultDestinationScheme,
&i.DefaultDestinationValue,
&i.AllowOverrideDestination,
&i.DefaultRefresh,
&i.RedisplayValue,
&i.ValidationError,
&i.ValidationCondition,
&i.ValidationTypeSystem,
&i.ValidationValueType,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Close(); err != nil {
return nil, err
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const getProjectVersionsByProjectID = `-- name: GetProjectVersionsByProjectID :many
SELECT
id, project_id, created_at, updated_at, name, description, storage_method, storage_source, import_job_id
id, project_id, created_at, updated_at, name, description, import_job_id
FROM
project_version
WHERE
@@ -505,8 +505,6 @@ func (q *sqlQuerier) GetProjectVersionsByProjectID(ctx context.Context, projectI
&i.UpdatedAt,
&i.Name,
&i.Description,
&i.StorageMethod,
&i.StorageSource,
&i.ImportJobID,
); err != nil {
return nil, err
@@ -622,7 +620,7 @@ func (q *sqlQuerier) GetProvisionerDaemons(ctx context.Context) ([]ProvisionerDa
const getProvisionerJobByID = `-- name: GetProvisionerJobByID :one
SELECT
id, created_at, updated_at, started_at, cancelled_at, completed_at, error, initiator_id, provisioner, type, input, worker_id
id, created_at, updated_at, started_at, cancelled_at, completed_at, error, organization_id, initiator_id, provisioner, storage_method, storage_source, type, input, worker_id
FROM
provisioner_job
WHERE
@@ -640,8 +638,11 @@ func (q *sqlQuerier) GetProvisionerJobByID(ctx context.Context, id uuid.UUID) (P
&i.CancelledAt,
&i.CompletedAt,
&i.Error,
&i.OrganizationID,
&i.InitiatorID,
&i.Provisioner,
&i.StorageMethod,
&i.StorageSource,
&i.Type,
&i.Input,
&i.WorkerID,
@@ -1254,14 +1255,15 @@ func (q *sqlQuerier) InsertAPIKey(ctx context.Context, arg InsertAPIKeyParams) (
const insertFile = `-- name: InsertFile :one
INSERT INTO
file (hash, created_at, mimetype, data)
file (hash, created_at, created_by, mimetype, data)
VALUES
($1, $2, $3, $4) RETURNING hash, created_at, mimetype, data
($1, $2, $3, $4, $5) RETURNING hash, created_at, created_by, mimetype, data
`
type InsertFileParams struct {
Hash string `db:"hash" json:"hash"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
CreatedBy string `db:"created_by" json:"created_by"`
Mimetype string `db:"mimetype" json:"mimetype"`
Data []byte `db:"data" json:"data"`
}
@@ -1270,6 +1272,7 @@ func (q *sqlQuerier) InsertFile(ctx context.Context, arg InsertFileParams) (File
row := q.db.QueryRowContext(ctx, insertFile,
arg.Hash,
arg.CreatedAt,
arg.CreatedBy,
arg.Mimetype,
arg.Data,
)
@@ -1277,6 +1280,7 @@ func (q *sqlQuerier) InsertFile(ctx context.Context, arg InsertFileParams) (File
err := row.Scan(
&i.Hash,
&i.CreatedAt,
&i.CreatedBy,
&i.Mimetype,
&i.Data,
)
@@ -1362,6 +1366,112 @@ func (q *sqlQuerier) InsertOrganizationMember(ctx context.Context, arg InsertOrg
return i, err
}
const insertParameterSchema = `-- name: InsertParameterSchema :one
INSERT INTO
parameter_schema (
id,
created_at,
job_id,
name,
description,
default_source_scheme,
default_source_value,
allow_override_source,
default_destination_scheme,
default_destination_value,
allow_override_destination,
default_refresh,
redisplay_value,
validation_error,
validation_condition,
validation_type_system,
validation_value_type
)
VALUES
(
$1,
$2,
$3,
$4,
$5,
$6,
$7,
$8,
$9,
$10,
$11,
$12,
$13,
$14,
$15,
$16,
$17
) RETURNING id, created_at, job_id, name, description, default_source_scheme, default_source_value, allow_override_source, default_destination_scheme, default_destination_value, allow_override_destination, default_refresh, redisplay_value, validation_error, validation_condition, validation_type_system, validation_value_type
`
type InsertParameterSchemaParams struct {
ID uuid.UUID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
JobID uuid.UUID `db:"job_id" json:"job_id"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
DefaultSourceScheme ParameterSourceScheme `db:"default_source_scheme" json:"default_source_scheme"`
DefaultSourceValue sql.NullString `db:"default_source_value" json:"default_source_value"`
AllowOverrideSource bool `db:"allow_override_source" json:"allow_override_source"`
DefaultDestinationScheme ParameterDestinationScheme `db:"default_destination_scheme" json:"default_destination_scheme"`
DefaultDestinationValue sql.NullString `db:"default_destination_value" json:"default_destination_value"`
AllowOverrideDestination bool `db:"allow_override_destination" json:"allow_override_destination"`
DefaultRefresh string `db:"default_refresh" json:"default_refresh"`
RedisplayValue bool `db:"redisplay_value" json:"redisplay_value"`
ValidationError string `db:"validation_error" json:"validation_error"`
ValidationCondition string `db:"validation_condition" json:"validation_condition"`
ValidationTypeSystem ParameterTypeSystem `db:"validation_type_system" json:"validation_type_system"`
ValidationValueType string `db:"validation_value_type" json:"validation_value_type"`
}
func (q *sqlQuerier) InsertParameterSchema(ctx context.Context, arg InsertParameterSchemaParams) (ParameterSchema, error) {
row := q.db.QueryRowContext(ctx, insertParameterSchema,
arg.ID,
arg.CreatedAt,
arg.JobID,
arg.Name,
arg.Description,
arg.DefaultSourceScheme,
arg.DefaultSourceValue,
arg.AllowOverrideSource,
arg.DefaultDestinationScheme,
arg.DefaultDestinationValue,
arg.AllowOverrideDestination,
arg.DefaultRefresh,
arg.RedisplayValue,
arg.ValidationError,
arg.ValidationCondition,
arg.ValidationTypeSystem,
arg.ValidationValueType,
)
var i ParameterSchema
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.JobID,
&i.Name,
&i.Description,
&i.DefaultSourceScheme,
&i.DefaultSourceValue,
&i.AllowOverrideSource,
&i.DefaultDestinationScheme,
&i.DefaultDestinationValue,
&i.AllowOverrideDestination,
&i.DefaultRefresh,
&i.RedisplayValue,
&i.ValidationError,
&i.ValidationCondition,
&i.ValidationTypeSystem,
&i.ValidationValueType,
)
return i, err
}
const insertParameterValue = `-- name: InsertParameterValue :one
INSERT INTO
parameter_value (
@@ -1430,19 +1540,21 @@ INSERT INTO
updated_at,
organization_id,
name,
provisioner
provisioner,
active_version_id
)
VALUES
($1, $2, $3, $4, $5, $6) RETURNING id, created_at, updated_at, organization_id, name, provisioner, active_version_id
($1, $2, $3, $4, $5, $6, $7) RETURNING id, created_at, updated_at, organization_id, name, provisioner, active_version_id
`
type InsertProjectParams struct {
ID uuid.UUID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
OrganizationID string `db:"organization_id" json:"organization_id"`
Name string `db:"name" json:"name"`
Provisioner ProvisionerType `db:"provisioner" json:"provisioner"`
ID uuid.UUID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
OrganizationID string `db:"organization_id" json:"organization_id"`
Name string `db:"name" json:"name"`
Provisioner ProvisionerType `db:"provisioner" json:"provisioner"`
ActiveVersionID uuid.UUID `db:"active_version_id" json:"active_version_id"`
}
func (q *sqlQuerier) InsertProject(ctx context.Context, arg InsertProjectParams) (Project, error) {
@@ -1453,6 +1565,7 @@ func (q *sqlQuerier) InsertProject(ctx context.Context, arg InsertProjectParams)
arg.OrganizationID,
arg.Name,
arg.Provisioner,
arg.ActiveVersionID,
)
var i Project
err := row.Scan(
@@ -1476,24 +1589,20 @@ INSERT INTO
updated_at,
name,
description,
storage_method,
storage_source,
import_job_id
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id, project_id, created_at, updated_at, name, description, storage_method, storage_source, import_job_id
($1, $2, $3, $4, $5, $6, $7) RETURNING id, project_id, created_at, updated_at, name, description, import_job_id
`
type InsertProjectVersionParams struct {
ID uuid.UUID `db:"id" json:"id"`
ProjectID uuid.UUID `db:"project_id" json:"project_id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
StorageMethod ProjectStorageMethod `db:"storage_method" json:"storage_method"`
StorageSource []byte `db:"storage_source" json:"storage_source"`
ImportJobID uuid.UUID `db:"import_job_id" json:"import_job_id"`
ID uuid.UUID `db:"id" json:"id"`
ProjectID uuid.UUID `db:"project_id" json:"project_id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
ImportJobID uuid.UUID `db:"import_job_id" json:"import_job_id"`
}
func (q *sqlQuerier) InsertProjectVersion(ctx context.Context, arg InsertProjectVersionParams) (ProjectVersion, error) {
@@ -1504,8 +1613,6 @@ func (q *sqlQuerier) InsertProjectVersion(ctx context.Context, arg InsertProject
arg.UpdatedAt,
arg.Name,
arg.Description,
arg.StorageMethod,
arg.StorageSource,
arg.ImportJobID,
)
var i ProjectVersion
@@ -1516,119 +1623,11 @@ func (q *sqlQuerier) InsertProjectVersion(ctx context.Context, arg InsertProject
&i.UpdatedAt,
&i.Name,
&i.Description,
&i.StorageMethod,
&i.StorageSource,
&i.ImportJobID,
)
return i, err
}
const insertProjectVersionParameter = `-- name: InsertProjectVersionParameter :one
INSERT INTO
project_version_parameter (
id,
created_at,
project_version_id,
name,
description,
default_source_scheme,
default_source_value,
allow_override_source,
default_destination_scheme,
default_destination_value,
allow_override_destination,
default_refresh,
redisplay_value,
validation_error,
validation_condition,
validation_type_system,
validation_value_type
)
VALUES
(
$1,
$2,
$3,
$4,
$5,
$6,
$7,
$8,
$9,
$10,
$11,
$12,
$13,
$14,
$15,
$16,
$17
) RETURNING id, created_at, project_version_id, name, description, default_source_scheme, default_source_value, allow_override_source, default_destination_scheme, default_destination_value, allow_override_destination, default_refresh, redisplay_value, validation_error, validation_condition, validation_type_system, validation_value_type
`
type InsertProjectVersionParameterParams struct {
ID uuid.UUID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
ProjectVersionID uuid.UUID `db:"project_version_id" json:"project_version_id"`
Name string `db:"name" json:"name"`
Description string `db:"description" json:"description"`
DefaultSourceScheme ParameterSourceScheme `db:"default_source_scheme" json:"default_source_scheme"`
DefaultSourceValue sql.NullString `db:"default_source_value" json:"default_source_value"`
AllowOverrideSource bool `db:"allow_override_source" json:"allow_override_source"`
DefaultDestinationScheme ParameterDestinationScheme `db:"default_destination_scheme" json:"default_destination_scheme"`
DefaultDestinationValue sql.NullString `db:"default_destination_value" json:"default_destination_value"`
AllowOverrideDestination bool `db:"allow_override_destination" json:"allow_override_destination"`
DefaultRefresh string `db:"default_refresh" json:"default_refresh"`
RedisplayValue bool `db:"redisplay_value" json:"redisplay_value"`
ValidationError string `db:"validation_error" json:"validation_error"`
ValidationCondition string `db:"validation_condition" json:"validation_condition"`
ValidationTypeSystem ParameterTypeSystem `db:"validation_type_system" json:"validation_type_system"`
ValidationValueType string `db:"validation_value_type" json:"validation_value_type"`
}
func (q *sqlQuerier) InsertProjectVersionParameter(ctx context.Context, arg InsertProjectVersionParameterParams) (ProjectVersionParameter, error) {
row := q.db.QueryRowContext(ctx, insertProjectVersionParameter,
arg.ID,
arg.CreatedAt,
arg.ProjectVersionID,
arg.Name,
arg.Description,
arg.DefaultSourceScheme,
arg.DefaultSourceValue,
arg.AllowOverrideSource,
arg.DefaultDestinationScheme,
arg.DefaultDestinationValue,
arg.AllowOverrideDestination,
arg.DefaultRefresh,
arg.RedisplayValue,
arg.ValidationError,
arg.ValidationCondition,
arg.ValidationTypeSystem,
arg.ValidationValueType,
)
var i ProjectVersionParameter
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.ProjectVersionID,
&i.Name,
&i.Description,
&i.DefaultSourceScheme,
&i.DefaultSourceValue,
&i.AllowOverrideSource,
&i.DefaultDestinationScheme,
&i.DefaultDestinationValue,
&i.AllowOverrideDestination,
&i.DefaultRefresh,
&i.RedisplayValue,
&i.ValidationError,
&i.ValidationCondition,
&i.ValidationTypeSystem,
&i.ValidationValueType,
)
return i, err
}
const insertProvisionerDaemon = `-- name: InsertProvisionerDaemon :one
INSERT INTO
provisioner_daemon (id, created_at, name, provisioners)
@@ -1667,23 +1666,29 @@ INSERT INTO
id,
created_at,
updated_at,
organization_id,
initiator_id,
provisioner,
storage_method,
storage_source,
type,
input
)
VALUES
($1, $2, $3, $4, $5, $6, $7) RETURNING id, created_at, updated_at, started_at, cancelled_at, completed_at, error, initiator_id, provisioner, type, input, worker_id
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING id, created_at, updated_at, started_at, cancelled_at, completed_at, error, organization_id, initiator_id, provisioner, storage_method, storage_source, type, input, worker_id
`
type InsertProvisionerJobParams struct {
ID uuid.UUID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
InitiatorID string `db:"initiator_id" json:"initiator_id"`
Provisioner ProvisionerType `db:"provisioner" json:"provisioner"`
Type ProvisionerJobType `db:"type" json:"type"`
Input json.RawMessage `db:"input" json:"input"`
ID uuid.UUID `db:"id" json:"id"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
OrganizationID string `db:"organization_id" json:"organization_id"`
InitiatorID string `db:"initiator_id" json:"initiator_id"`
Provisioner ProvisionerType `db:"provisioner" json:"provisioner"`
StorageMethod ProvisionerStorageMethod `db:"storage_method" json:"storage_method"`
StorageSource string `db:"storage_source" json:"storage_source"`
Type ProvisionerJobType `db:"type" json:"type"`
Input json.RawMessage `db:"input" json:"input"`
}
func (q *sqlQuerier) InsertProvisionerJob(ctx context.Context, arg InsertProvisionerJobParams) (ProvisionerJob, error) {
@@ -1691,8 +1696,11 @@ func (q *sqlQuerier) InsertProvisionerJob(ctx context.Context, arg InsertProvisi
arg.ID,
arg.CreatedAt,
arg.UpdatedAt,
arg.OrganizationID,
arg.InitiatorID,
arg.Provisioner,
arg.StorageMethod,
arg.StorageSource,
arg.Type,
arg.Input,
)
@@ -1705,8 +1713,11 @@ func (q *sqlQuerier) InsertProvisionerJob(ctx context.Context, arg InsertProvisi
&i.CancelledAt,
&i.CompletedAt,
&i.Error,
&i.OrganizationID,
&i.InitiatorID,
&i.Provisioner,
&i.StorageMethod,
&i.StorageSource,
&i.Type,
&i.Input,
&i.WorkerID,