mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: Convert all jobs to use a common resource and agent type (#369)
* ci: Update DataDog GitHub branch to fallback to GITHUB_REF This was detecting branches, but not our "main" branch before. Hopefully this fixes it! * Add basic Terraform Provider * Rename post files to upload * Add tests for resources * Skip instance identity test * Add tests for ensuring agent get's passed through properly * Fix linting errors * Add echo path * Fix agent authentication * fix: Convert all jobs to use a common resource and agent type This enables a consistent API for project import and provisioned resources.
This commit is contained in:
@@ -32,36 +32,3 @@ CREATE TABLE workspace_history (
|
||||
provision_job_id uuid NOT NULL,
|
||||
UNIQUE(workspace_id, name)
|
||||
);
|
||||
|
||||
-- Cloud resources produced by a provision job.
|
||||
CREATE TABLE workspace_resource (
|
||||
id uuid NOT NULL UNIQUE,
|
||||
created_at timestamptz NOT NULL,
|
||||
workspace_history_id uuid NOT NULL REFERENCES workspace_history (id) ON DELETE CASCADE,
|
||||
-- A unique identifier for the resource. This can be used
|
||||
-- to exchange for an agent token with various providers.
|
||||
instance_id varchar(64),
|
||||
-- Resource type produced by a provisioner.
|
||||
-- eg. "google_compute_instance"
|
||||
type varchar(256) NOT NULL,
|
||||
-- Name of the resource.
|
||||
-- eg. "kyle-dev-instance"
|
||||
name varchar(64) NOT NULL,
|
||||
-- Token for an agent to connect.
|
||||
workspace_agent_token varchar(128) NOT NULL UNIQUE,
|
||||
-- If an agent has been conencted for this resource,
|
||||
-- the agent table is not null.
|
||||
workspace_agent_id uuid,
|
||||
UNIQUE(workspace_history_id, type, name)
|
||||
);
|
||||
|
||||
CREATE TABLE workspace_agent (
|
||||
id uuid NOT NULL UNIQUE,
|
||||
workspace_resource_id uuid NOT NULL REFERENCES workspace_resource (id) ON DELETE CASCADE,
|
||||
created_at timestamptz NOT NULL,
|
||||
updated_at timestamptz NOT NULL,
|
||||
-- Identifies instance architecture, cloud, etc.
|
||||
instance_metadata jsonb NOT NULL,
|
||||
-- Identifies resources.
|
||||
resource_metadata jsonb NOT NULL
|
||||
);
|
||||
|
||||
@@ -55,6 +55,31 @@ CREATE TABLE IF NOT EXISTS provisioner_job_log (
|
||||
output varchar(1024) NOT NULL
|
||||
);
|
||||
|
||||
-- Resources from multiple workspace states are stored here post project-import job.
|
||||
CREATE TABLE provisioner_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,
|
||||
agent_id uuid
|
||||
);
|
||||
|
||||
-- Agents that associate with a specific resource.
|
||||
CREATE TABLE provisioner_job_agent (
|
||||
id uuid NOT NULL UNIQUE,
|
||||
created_at timestamptz NOT NULL,
|
||||
updated_at timestamptz,
|
||||
resource_id uuid NOT NULL REFERENCES provisioner_job_resource (id) ON DELETE CASCADE,
|
||||
auth_token uuid NOT NULL UNIQUE,
|
||||
auth_instance_id varchar(64),
|
||||
environment_variables jsonb,
|
||||
startup_script varchar(65534),
|
||||
instance_metadata jsonb,
|
||||
resource_metadata jsonb
|
||||
);
|
||||
|
||||
CREATE TYPE parameter_scope AS ENUM (
|
||||
'organization',
|
||||
'project',
|
||||
@@ -119,13 +144,3 @@ CREATE TABLE parameter_value (
|
||||
-- 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
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user