feat: Add "coder projects create" command (#246)

* Refactor parameter parsing to return nil values if none computed

* Refactor parameter to allow for hiding redisplay

* Refactor parameters to enable schema matching

* Refactor provisionerd to dynamically update parameter schemas

* Refactor job update for provisionerd

* Handle multiple states correctly when provisioning a project

* Add project import job resource table

* Basic creation flow works!

* Create project fully works!!!

* Only show job status if completed

* Add create workspace support

* Replace Netflix/go-expect with ActiveState

* Fix linting errors

* Use forked chzyer/readline

* Add create workspace CLI

* Add CLI test

* Move jobs to their own APIs

* Remove go-expect

* Fix requested changes

* Skip workspacecreate test on windows
This commit is contained in:
Kyle Carberry
2022-02-12 13:34:04 -06:00
committed by GitHub
parent df13fef161
commit 154b9bce57
65 changed files with 3215 additions and 2241 deletions

View File

@ -19,18 +19,19 @@ func New() database.Store {
organizationMembers: make([]database.OrganizationMember, 0),
users: make([]database.User, 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),
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),
projectImportJobResource: make([]database.ProjectImportJobResource, 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 +46,19 @@ type fakeQuerier struct {
users []database.User
// New tables
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
files []database.File
parameterValue []database.ParameterValue
parameterSchema []database.ParameterSchema
project []database.Project
projectVersion []database.ProjectVersion
projectImportJobResource []database.ProjectImportJobResource
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.
@ -399,6 +401,23 @@ func (q *fakeQuerier) GetProjectByOrganizationAndName(_ context.Context, arg dat
return database.Project{}, sql.ErrNoRows
}
func (q *fakeQuerier) GetProjectImportJobResourcesByJobID(_ context.Context, jobID uuid.UUID) ([]database.ProjectImportJobResource, error) {
q.mutex.Lock()
defer q.mutex.Unlock()
resources := make([]database.ProjectImportJobResource, 0)
for _, resource := range q.projectImportJobResource {
if resource.JobID.String() != jobID.String() {
continue
}
resources = append(resources, resource)
}
if len(resources) == 0 {
return nil, sql.ErrNoRows
}
return resources, nil
}
func (q *fakeQuerier) GetProjectVersionsByProjectID(_ context.Context, projectID uuid.UUID) ([]database.ProjectVersion, error) {
q.mutex.Lock()
defer q.mutex.Unlock()
@ -643,7 +662,6 @@ func (q *fakeQuerier) InsertParameterValue(_ context.Context, arg database.Inser
SourceScheme: arg.SourceScheme,
SourceValue: arg.SourceValue,
DestinationScheme: arg.DestinationScheme,
DestinationValue: arg.DestinationValue,
}
q.parameterValue = append(q.parameterValue, parameterValue)
return parameterValue, nil
@ -667,6 +685,23 @@ func (q *fakeQuerier) InsertProject(_ context.Context, arg database.InsertProjec
return project, nil
}
func (q *fakeQuerier) InsertProjectImportJobResource(_ context.Context, arg database.InsertProjectImportJobResourceParams) (database.ProjectImportJobResource, error) {
q.mutex.Lock()
defer q.mutex.Unlock()
//nolint:gosimple
projectResource := database.ProjectImportJobResource{
ID: arg.ID,
CreatedAt: arg.CreatedAt,
JobID: arg.JobID,
Transition: arg.Transition,
Type: arg.Type,
Name: arg.Name,
}
q.projectImportJobResource = append(q.projectImportJobResource, projectResource)
return projectResource, nil
}
func (q *fakeQuerier) InsertProjectVersion(_ context.Context, arg database.InsertProjectVersionParams) (database.ProjectVersion, error) {
q.mutex.Lock()
defer q.mutex.Unlock()
@ -719,7 +754,6 @@ func (q *fakeQuerier) InsertParameterSchema(_ context.Context, arg database.Inse
DefaultSourceValue: arg.DefaultSourceValue,
AllowOverrideSource: arg.AllowOverrideSource,
DefaultDestinationScheme: arg.DefaultDestinationScheme,
DefaultDestinationValue: arg.DefaultDestinationValue,
AllowOverrideDestination: arg.AllowOverrideDestination,
DefaultRefresh: arg.DefaultRefresh,
RedisplayValue: arg.RedisplayValue,

24
database/dump.sql generated
View File

@ -28,6 +28,7 @@ CREATE TYPE parameter_destination_scheme AS ENUM (
CREATE TYPE parameter_scope AS ENUM (
'organization',
'project',
'import_job',
'user',
'workspace'
);
@ -87,7 +88,7 @@ CREATE TABLE api_keys (
);
CREATE TABLE file (
hash character varying(32) NOT NULL,
hash character varying(64) NOT NULL,
created_at timestamp with time zone NOT NULL,
created_by text NOT NULL,
mimetype character varying(64) NOT NULL,
@ -128,10 +129,9 @@ CREATE TABLE parameter_schema (
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,
default_source_value text NOT NULL,
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,
@ -150,8 +150,7 @@ CREATE TABLE parameter_value (
scope_id text NOT NULL,
source_scheme parameter_source_scheme NOT NULL,
source_value text NOT NULL,
destination_scheme parameter_destination_scheme NOT NULL,
destination_value text NOT NULL
destination_scheme parameter_destination_scheme NOT NULL
);
CREATE TABLE project (
@ -164,6 +163,15 @@ CREATE TABLE project (
active_version_id uuid NOT NULL
);
CREATE TABLE project_import_job_resource (
id uuid NOT NULL,
created_at timestamp with time zone NOT NULL,
job_id uuid NOT NULL,
transition workspace_transition NOT NULL,
type character varying(256) NOT NULL,
name character varying(64) NOT NULL
);
CREATE TABLE project_version (
id uuid NOT NULL,
project_id uuid NOT NULL,
@ -292,6 +300,9 @@ ALTER TABLE ONLY parameter_value
ALTER TABLE ONLY project
ADD CONSTRAINT project_id_key UNIQUE (id);
ALTER TABLE ONLY project_import_job_resource
ADD CONSTRAINT project_import_job_resource_id_key UNIQUE (id);
ALTER TABLE ONLY project
ADD CONSTRAINT project_organization_id_name_key UNIQUE (organization_id, name);
@ -340,6 +351,9 @@ ALTER TABLE ONLY workspace_resource
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_import_job_resource
ADD CONSTRAINT project_import_job_resource_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);

View File

@ -58,6 +58,7 @@ CREATE TABLE IF NOT EXISTS provisioner_job_log (
CREATE TYPE parameter_scope AS ENUM (
'organization',
'project',
'import_job',
'user',
'workspace'
);
@ -71,22 +72,6 @@ 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,
name varchar(64) NOT NULL,
created_at timestamptz NOT NULL,
updated_at timestamptz NOT NULL,
scope parameter_scope NOT NULL,
scope_id text NOT NULL,
source_scheme parameter_source_scheme NOT NULL,
source_value text NOT NULL,
destination_scheme parameter_destination_scheme NOT NULL,
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.
--
@ -103,12 +88,10 @@ CREATE TABLE parameter_schema (
name varchar(64) NOT NULL,
description varchar(8192) NOT NULL DEFAULT '',
default_source_scheme parameter_source_scheme,
default_source_value text,
default_source_value text NOT NULL,
-- 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,
@ -121,3 +104,28 @@ CREATE TABLE parameter_schema (
validation_value_type varchar(64) NOT NULL,
UNIQUE(job_id, name)
);
-- Parameters are provided to jobs for provisioning and to workspaces.
CREATE TABLE parameter_value (
id uuid NOT NULL UNIQUE,
name varchar(64) NOT NULL,
created_at timestamptz NOT NULL,
updated_at timestamptz NOT NULL,
scope parameter_scope NOT NULL,
scope_id text NOT NULL,
source_scheme parameter_source_scheme NOT NULL,
source_value text NOT NULL,
destination_scheme parameter_destination_scheme NOT NULL,
-- Prevents duplicates for parameters in the same scope.
UNIQUE(name, scope, scope_id)
);
-- Resources from multiple workspace states are stored here post project-import job.
CREATE TABLE project_import_job_resource (
id uuid NOT NULL UNIQUE,
created_at timestamptz NOT NULL,
job_id uuid NOT NULL REFERENCES provisioner_job(id) ON DELETE CASCADE,
transition workspace_transition NOT NULL,
type varchar(256) NOT NULL,
name varchar(64) NOT NULL
);

View File

@ -97,6 +97,7 @@ type ParameterScope string
const (
ParameterScopeOrganization ParameterScope = "organization"
ParameterScopeProject ParameterScope = "project"
ParameterScopeImportJob ParameterScope = "import_job"
ParameterScopeUser ParameterScope = "user"
ParameterScopeWorkspace ParameterScope = "workspace"
)
@ -307,10 +308,9 @@ type ParameterSchema struct {
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"`
DefaultSourceValue string `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"`
@ -330,7 +330,6 @@ type ParameterValue struct {
SourceScheme ParameterSourceScheme `db:"source_scheme" json:"source_scheme"`
SourceValue string `db:"source_value" json:"source_value"`
DestinationScheme ParameterDestinationScheme `db:"destination_scheme" json:"destination_scheme"`
DestinationValue string `db:"destination_value" json:"destination_value"`
}
type Project struct {
@ -343,6 +342,15 @@ type Project struct {
ActiveVersionID uuid.UUID `db:"active_version_id" json:"active_version_id"`
}
type ProjectImportJobResource 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"`
Transition WorkspaceTransition `db:"transition" json:"transition"`
Type string `db:"type" json:"type"`
Name string `db:"name" json:"name"`
}
type ProjectVersion struct {
ID uuid.UUID `db:"id" json:"id"`
ProjectID uuid.UUID `db:"project_id" json:"project_id"`

View File

@ -20,6 +20,7 @@ type querier interface {
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)
GetProjectImportJobResourcesByJobID(ctx context.Context, jobID uuid.UUID) ([]ProjectImportJobResource, error)
GetProjectVersionByID(ctx context.Context, id uuid.UUID) (ProjectVersion, error)
GetProjectVersionByProjectIDAndName(ctx context.Context, arg GetProjectVersionByProjectIDAndNameParams) (ProjectVersion, error)
GetProjectVersionsByProjectID(ctx context.Context, projectID uuid.UUID) ([]ProjectVersion, error)
@ -48,6 +49,7 @@ type querier interface {
InsertParameterSchema(ctx context.Context, arg InsertParameterSchemaParams) (ParameterSchema, error)
InsertParameterValue(ctx context.Context, arg InsertParameterValueParams) (ParameterValue, error)
InsertProject(ctx context.Context, arg InsertProjectParams) (Project, error)
InsertProjectImportJobResource(ctx context.Context, arg InsertProjectImportJobResourceParams) (ProjectImportJobResource, error)
InsertProjectVersion(ctx context.Context, arg InsertProjectVersionParams) (ProjectVersion, error)
InsertProvisionerDaemon(ctx context.Context, arg InsertProvisionerDaemonParams) (ProvisionerDaemon, error)
InsertProvisionerJob(ctx context.Context, arg InsertProvisionerJobParams) (ProvisionerJob, error)

View File

@ -173,6 +173,14 @@ FROM
WHERE
job_id = $1;
-- name: GetProjectImportJobResourcesByJobID :many
SELECT
*
FROM
project_import_job_resource
WHERE
job_id = $1;
-- name: GetProjectVersionsByProjectID :many
SELECT
*
@ -408,11 +416,10 @@ INSERT INTO
scope_id,
source_scheme,
source_value,
destination_scheme,
destination_value
destination_scheme
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING *;
($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING *;
-- name: InsertProject :one
INSERT INTO
@ -428,6 +435,12 @@ INSERT INTO
VALUES
($1, $2, $3, $4, $5, $6, $7) RETURNING *;
-- name: InsertProjectImportJobResource :one
INSERT INTO
project_import_job_resource (id, created_at, job_id, transition, type, name)
VALUES
($1, $2, $3, $4, $5, $6) RETURNING *;
-- name: InsertProjectVersion :one
INSERT INTO
project_version (
@ -454,7 +467,6 @@ INSERT INTO
default_source_value,
allow_override_source,
default_destination_scheme,
default_destination_value,
allow_override_destination,
default_refresh,
redisplay_value,
@ -480,8 +492,7 @@ VALUES
$13,
$14,
$15,
$16,
$17
$16
) RETURNING *;
-- name: InsertProvisionerDaemon :one

View File

@ -271,7 +271,7 @@ func (q *sqlQuerier) GetOrganizationsByUserID(ctx context.Context, userID string
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
id, created_at, job_id, name, description, default_source_scheme, default_source_value, allow_override_source, default_destination_scheme, allow_override_destination, default_refresh, redisplay_value, validation_error, validation_condition, validation_type_system, validation_value_type
FROM
parameter_schema
WHERE
@ -297,7 +297,6 @@ func (q *sqlQuerier) GetParameterSchemasByJobID(ctx context.Context, jobID uuid.
&i.DefaultSourceValue,
&i.AllowOverrideSource,
&i.DefaultDestinationScheme,
&i.DefaultDestinationValue,
&i.AllowOverrideDestination,
&i.DefaultRefresh,
&i.RedisplayValue,
@ -321,7 +320,7 @@ func (q *sqlQuerier) GetParameterSchemasByJobID(ctx context.Context, jobID uuid.
const getParameterValuesByScope = `-- name: GetParameterValuesByScope :many
SELECT
id, name, created_at, updated_at, scope, scope_id, source_scheme, source_value, destination_scheme, destination_value
id, name, created_at, updated_at, scope, scope_id, source_scheme, source_value, destination_scheme
FROM
parameter_value
WHERE
@ -353,7 +352,6 @@ func (q *sqlQuerier) GetParameterValuesByScope(ctx context.Context, arg GetParam
&i.SourceScheme,
&i.SourceValue,
&i.DestinationScheme,
&i.DestinationValue,
); err != nil {
return nil, err
}
@ -426,6 +424,45 @@ func (q *sqlQuerier) GetProjectByOrganizationAndName(ctx context.Context, arg Ge
return i, err
}
const getProjectImportJobResourcesByJobID = `-- name: GetProjectImportJobResourcesByJobID :many
SELECT
id, created_at, job_id, transition, type, name
FROM
project_import_job_resource
WHERE
job_id = $1
`
func (q *sqlQuerier) GetProjectImportJobResourcesByJobID(ctx context.Context, jobID uuid.UUID) ([]ProjectImportJobResource, error) {
rows, err := q.db.QueryContext(ctx, getProjectImportJobResourcesByJobID, jobID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ProjectImportJobResource
for rows.Next() {
var i ProjectImportJobResource
if err := rows.Scan(
&i.ID,
&i.CreatedAt,
&i.JobID,
&i.Transition,
&i.Type,
&i.Name,
); 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 getProjectVersionByID = `-- name: GetProjectVersionByID :one
SELECT
id, project_id, created_at, updated_at, name, description, import_job_id
@ -1378,7 +1415,6 @@ INSERT INTO
default_source_value,
allow_override_source,
default_destination_scheme,
default_destination_value,
allow_override_destination,
default_refresh,
redisplay_value,
@ -1404,9 +1440,8 @@ VALUES
$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
$16
) RETURNING id, created_at, job_id, name, description, default_source_scheme, default_source_value, allow_override_source, default_destination_scheme, allow_override_destination, default_refresh, redisplay_value, validation_error, validation_condition, validation_type_system, validation_value_type
`
type InsertParameterSchemaParams struct {
@ -1416,10 +1451,9 @@ type InsertParameterSchemaParams struct {
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"`
DefaultSourceValue string `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"`
@ -1440,7 +1474,6 @@ func (q *sqlQuerier) InsertParameterSchema(ctx context.Context, arg InsertParame
arg.DefaultSourceValue,
arg.AllowOverrideSource,
arg.DefaultDestinationScheme,
arg.DefaultDestinationValue,
arg.AllowOverrideDestination,
arg.DefaultRefresh,
arg.RedisplayValue,
@ -1460,7 +1493,6 @@ func (q *sqlQuerier) InsertParameterSchema(ctx context.Context, arg InsertParame
&i.DefaultSourceValue,
&i.AllowOverrideSource,
&i.DefaultDestinationScheme,
&i.DefaultDestinationValue,
&i.AllowOverrideDestination,
&i.DefaultRefresh,
&i.RedisplayValue,
@ -1483,11 +1515,10 @@ INSERT INTO
scope_id,
source_scheme,
source_value,
destination_scheme,
destination_value
destination_scheme
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING id, name, created_at, updated_at, scope, scope_id, source_scheme, source_value, destination_scheme, destination_value
($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id, name, created_at, updated_at, scope, scope_id, source_scheme, source_value, destination_scheme
`
type InsertParameterValueParams struct {
@ -1500,7 +1531,6 @@ type InsertParameterValueParams struct {
SourceScheme ParameterSourceScheme `db:"source_scheme" json:"source_scheme"`
SourceValue string `db:"source_value" json:"source_value"`
DestinationScheme ParameterDestinationScheme `db:"destination_scheme" json:"destination_scheme"`
DestinationValue string `db:"destination_value" json:"destination_value"`
}
func (q *sqlQuerier) InsertParameterValue(ctx context.Context, arg InsertParameterValueParams) (ParameterValue, error) {
@ -1514,7 +1544,6 @@ func (q *sqlQuerier) InsertParameterValue(ctx context.Context, arg InsertParamet
arg.SourceScheme,
arg.SourceValue,
arg.DestinationScheme,
arg.DestinationValue,
)
var i ParameterValue
err := row.Scan(
@ -1527,7 +1556,6 @@ func (q *sqlQuerier) InsertParameterValue(ctx context.Context, arg InsertParamet
&i.SourceScheme,
&i.SourceValue,
&i.DestinationScheme,
&i.DestinationValue,
)
return i, err
}
@ -1580,6 +1608,43 @@ func (q *sqlQuerier) InsertProject(ctx context.Context, arg InsertProjectParams)
return i, err
}
const insertProjectImportJobResource = `-- name: InsertProjectImportJobResource :one
INSERT INTO
project_import_job_resource (id, created_at, job_id, transition, type, name)
VALUES
($1, $2, $3, $4, $5, $6) RETURNING id, created_at, job_id, transition, type, name
`
type InsertProjectImportJobResourceParams 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"`
Transition WorkspaceTransition `db:"transition" json:"transition"`
Type string `db:"type" json:"type"`
Name string `db:"name" json:"name"`
}
func (q *sqlQuerier) InsertProjectImportJobResource(ctx context.Context, arg InsertProjectImportJobResourceParams) (ProjectImportJobResource, error) {
row := q.db.QueryRowContext(ctx, insertProjectImportJobResource,
arg.ID,
arg.CreatedAt,
arg.JobID,
arg.Transition,
arg.Type,
arg.Name,
)
var i ProjectImportJobResource
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.JobID,
&i.Transition,
&i.Type,
&i.Name,
)
return i, err
}
const insertProjectVersion = `-- name: InsertProjectVersion :one
INSERT INTO
project_version (