diff --git a/.gitattributes b/.gitattributes index d7fbd84988..5e22932239 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ # Generated files +database/dump.sql linguist-generated=true peerbroker/proto/*.go linguist-generated=true provisionerd/proto/*.go linguist-generated=true provisionersdk/proto/*.go linguist-generated=true diff --git a/database/databasefake/databasefake.go b/database/databasefake/databasefake.go index f0e9710132..4d94a39573 100644 --- a/database/databasefake/databasefake.go +++ b/database/databasefake/databasefake.go @@ -18,16 +18,18 @@ func New() database.Store { organizationMembers: make([]database.OrganizationMember, 0), users: make([]database.User, 0), - parameterValue: make([]database.ParameterValue, 0), - project: make([]database.Project, 0), - projectHistory: make([]database.ProjectHistory, 0), - projectParameter: make([]database.ProjectParameter, 0), - provisionerDaemons: make([]database.ProvisionerDaemon, 0), - provisionerJobs: make([]database.ProvisionerJob, 0), - workspace: make([]database.Workspace, 0), - workspaceResource: make([]database.WorkspaceResource, 0), - workspaceHistory: make([]database.WorkspaceHistory, 0), - workspaceAgent: make([]database.WorkspaceAgent, 0), + parameterValue: make([]database.ParameterValue, 0), + project: make([]database.Project, 0), + projectHistory: make([]database.ProjectHistory, 0), + projectHistoryLog: make([]database.ProjectHistoryLog, 0), + projectParameter: make([]database.ProjectParameter, 0), + provisionerDaemons: make([]database.ProvisionerDaemon, 0), + provisionerJobs: make([]database.ProvisionerJob, 0), + workspace: make([]database.Workspace, 0), + workspaceResource: make([]database.WorkspaceResource, 0), + workspaceHistory: make([]database.WorkspaceHistory, 0), + workspaceHistoryLog: make([]database.WorkspaceHistoryLog, 0), + workspaceAgent: make([]database.WorkspaceAgent, 0), } } @@ -40,16 +42,18 @@ type fakeQuerier struct { users []database.User // New tables - parameterValue []database.ParameterValue - project []database.Project - projectHistory []database.ProjectHistory - projectParameter []database.ProjectParameter - provisionerDaemons []database.ProvisionerDaemon - provisionerJobs []database.ProvisionerJob - workspace []database.Workspace - workspaceResource []database.WorkspaceResource - workspaceHistory []database.WorkspaceHistory - workspaceAgent []database.WorkspaceAgent + parameterValue []database.ParameterValue + project []database.Project + projectHistory []database.ProjectHistory + projectHistoryLog []database.ProjectHistoryLog + projectParameter []database.ProjectParameter + provisionerDaemons []database.ProvisionerDaemon + provisionerJobs []database.ProvisionerJob + workspace []database.Workspace + workspaceAgent []database.WorkspaceAgent + workspaceHistory []database.WorkspaceHistory + workspaceHistoryLog []database.WorkspaceHistoryLog + workspaceResource []database.WorkspaceResource } // InTx doesn't rollback data properly for in-memory yet. @@ -184,6 +188,23 @@ func (q *fakeQuerier) GetWorkspaceHistoryByWorkspaceIDWithoutAfter(_ context.Con return database.WorkspaceHistory{}, sql.ErrNoRows } +func (q *fakeQuerier) GetWorkspaceHistoryLogsByIDBefore(_ context.Context, arg database.GetWorkspaceHistoryLogsByIDBeforeParams) ([]database.WorkspaceHistoryLog, error) { + logs := make([]database.WorkspaceHistoryLog, 0) + for _, workspaceHistoryLog := range q.workspaceHistoryLog { + if workspaceHistoryLog.WorkspaceHistoryID.String() != arg.WorkspaceHistoryID.String() { + continue + } + if workspaceHistoryLog.CreatedAt.After(arg.CreatedAt) { + continue + } + logs = append(logs, workspaceHistoryLog) + } + if len(logs) == 0 { + return nil, sql.ErrNoRows + } + return logs, nil +} + func (q *fakeQuerier) GetWorkspaceHistoryByWorkspaceID(_ context.Context, workspaceID uuid.UUID) ([]database.WorkspaceHistory, error) { history := make([]database.WorkspaceHistory, 0) for _, workspaceHistory := range q.workspaceHistory { @@ -197,6 +218,19 @@ func (q *fakeQuerier) GetWorkspaceHistoryByWorkspaceID(_ context.Context, worksp return history, nil } +func (q *fakeQuerier) GetWorkspaceHistoryByWorkspaceIDAndName(_ context.Context, arg database.GetWorkspaceHistoryByWorkspaceIDAndNameParams) (database.WorkspaceHistory, error) { + for _, workspaceHistory := range q.workspaceHistory { + if workspaceHistory.WorkspaceID.String() != arg.WorkspaceID.String() { + continue + } + if !strings.EqualFold(workspaceHistory.Name, arg.Name) { + continue + } + return workspaceHistory, nil + } + return database.WorkspaceHistory{}, sql.ErrNoRows +} + func (q *fakeQuerier) GetWorkspacesByProjectAndUserID(_ context.Context, arg database.GetWorkspacesByProjectAndUserIDParams) ([]database.Workspace, error) { workspaces := make([]database.Workspace, 0) for _, workspace := range q.workspace { @@ -318,6 +352,36 @@ func (q *fakeQuerier) GetProjectHistoryByProjectID(_ context.Context, projectID return history, nil } +func (q *fakeQuerier) GetProjectHistoryByProjectIDAndName(_ context.Context, arg database.GetProjectHistoryByProjectIDAndNameParams) (database.ProjectHistory, error) { + for _, projectHistory := range q.projectHistory { + if projectHistory.ProjectID.String() != arg.ProjectID.String() { + continue + } + if !strings.EqualFold(projectHistory.Name, arg.Name) { + continue + } + return projectHistory, nil + } + return database.ProjectHistory{}, sql.ErrNoRows +} + +func (q *fakeQuerier) GetProjectHistoryLogsByIDBefore(_ context.Context, arg database.GetProjectHistoryLogsByIDBeforeParams) ([]database.ProjectHistoryLog, error) { + logs := make([]database.ProjectHistoryLog, 0) + for _, projectHistoryLog := range q.projectHistoryLog { + if projectHistoryLog.ProjectHistoryID.String() != arg.ProjectHistoryID.String() { + continue + } + if projectHistoryLog.CreatedAt.After(arg.CreatedAt) { + continue + } + logs = append(logs, projectHistoryLog) + } + if len(logs) == 0 { + return nil, sql.ErrNoRows + } + return logs, nil +} + func (q *fakeQuerier) GetProjectHistoryByID(_ context.Context, projectHistoryID uuid.UUID) (database.ProjectHistory, error) { for _, projectHistory := range q.projectHistory { if projectHistory.ID.String() != projectHistoryID.String() { @@ -371,6 +435,13 @@ func (q *fakeQuerier) GetOrganizationMemberByUserID(_ context.Context, arg datab return database.OrganizationMember{}, sql.ErrNoRows } +func (q *fakeQuerier) GetProvisionerDaemons(_ context.Context) ([]database.ProvisionerDaemon, error) { + if len(q.provisionerDaemons) == 0 { + return nil, sql.ErrNoRows + } + return q.provisionerDaemons, nil +} + func (q *fakeQuerier) GetProvisionerDaemonByID(_ context.Context, id uuid.UUID) (database.ProvisionerDaemon, error) { for _, provisionerDaemon := range q.provisionerDaemons { if provisionerDaemon.ID.String() != id.String() { @@ -486,6 +557,22 @@ func (q *fakeQuerier) InsertProjectHistory(_ context.Context, arg database.Inser return history, nil } +func (q *fakeQuerier) InsertProjectHistoryLogs(_ context.Context, arg database.InsertProjectHistoryLogsParams) ([]database.ProjectHistoryLog, error) { + logs := make([]database.ProjectHistoryLog, 0) + for index, output := range arg.Output { + logs = append(logs, database.ProjectHistoryLog{ + ProjectHistoryID: arg.ProjectHistoryID, + ID: arg.ID[index], + CreatedAt: arg.CreatedAt[index], + Source: arg.Source[index], + Level: arg.Level[index], + Output: output, + }) + } + q.projectHistoryLog = append(q.projectHistoryLog, logs...) + return logs, nil +} + func (q *fakeQuerier) InsertProjectParameter(_ context.Context, arg database.InsertProjectParameterParams) (database.ProjectParameter, error) { //nolint:gosimple param := database.ProjectParameter{ @@ -586,6 +673,7 @@ func (q *fakeQuerier) InsertWorkspaceHistory(_ context.Context, arg database.Ins CreatedAt: arg.CreatedAt, UpdatedAt: arg.UpdatedAt, WorkspaceID: arg.WorkspaceID, + Name: arg.Name, ProjectHistoryID: arg.ProjectHistoryID, BeforeID: arg.BeforeID, Transition: arg.Transition, @@ -596,6 +684,22 @@ func (q *fakeQuerier) InsertWorkspaceHistory(_ context.Context, arg database.Ins return workspaceHistory, nil } +func (q *fakeQuerier) InsertWorkspaceHistoryLogs(_ context.Context, arg database.InsertWorkspaceHistoryLogsParams) ([]database.WorkspaceHistoryLog, error) { + logs := make([]database.WorkspaceHistoryLog, 0) + for index, output := range arg.Output { + logs = append(logs, database.WorkspaceHistoryLog{ + WorkspaceHistoryID: arg.WorkspaceHistoryID, + ID: arg.ID[index], + CreatedAt: arg.CreatedAt[index], + Source: arg.Source[index], + Level: arg.Level[index], + Output: output, + }) + } + q.workspaceHistoryLog = append(q.workspaceHistoryLog, logs...) + return logs, nil +} + func (q *fakeQuerier) InsertWorkspaceResource(_ context.Context, arg database.InsertWorkspaceResourceParams) (database.WorkspaceResource, error) { workspaceResource := database.WorkspaceResource{ ID: arg.ID, @@ -659,7 +763,9 @@ func (q *fakeQuerier) UpdateWorkspaceHistoryByID(_ context.Context, arg database continue } workspaceHistory.UpdatedAt = arg.UpdatedAt + workspaceHistory.CompletedAt = arg.CompletedAt workspaceHistory.AfterID = arg.AfterID + workspaceHistory.ProvisionerState = arg.ProvisionerState q.workspaceHistory[index] = workspaceHistory return nil } diff --git a/database/dump.sql b/database/dump.sql index af4874e96d..0cea42a235 100644 --- a/database/dump.sql +++ b/database/dump.sql @@ -5,8 +5,12 @@ CREATE TYPE log_level AS ENUM ( 'debug', 'info', 'warn', - 'error', - 'fatal' + 'error' +); + +CREATE TYPE log_source AS ENUM ( + 'provisioner_daemon', + 'provisioner' ); CREATE TYPE login_type AS ENUM ( @@ -142,6 +146,15 @@ CREATE TABLE project_history ( import_job_id uuid NOT NULL ); +CREATE TABLE project_history_log ( + id uuid NOT NULL, + project_history_id uuid NOT NULL, + created_at timestamp with time zone NOT NULL, + source log_source NOT NULL, + level log_level NOT NULL, + output character varying(1024) NOT NULL +); + CREATE TABLE project_parameter ( id uuid NOT NULL, created_at timestamp with time zone NOT NULL, @@ -233,6 +246,7 @@ CREATE TABLE workspace_history ( completed_at timestamp with time zone, workspace_id uuid NOT NULL, project_history_id uuid NOT NULL, + name character varying(64) NOT NULL, before_id uuid, after_id uuid, transition workspace_transition NOT NULL, @@ -241,13 +255,13 @@ CREATE TABLE workspace_history ( provision_job_id uuid NOT NULL ); -CREATE TABLE workspace_log ( - workspace_id uuid NOT NULL, +CREATE TABLE workspace_history_log ( + id uuid NOT NULL, workspace_history_id uuid NOT NULL, - created timestamp with time zone NOT NULL, - logged_by character varying(255), + created_at timestamp with time zone NOT NULL, + source log_source NOT NULL, level log_level NOT NULL, - log jsonb NOT NULL + output character varying(1024) NOT NULL ); CREATE TABLE workspace_resource ( @@ -269,6 +283,9 @@ ALTER TABLE ONLY parameter_value ALTER TABLE ONLY project_history ADD CONSTRAINT project_history_id_key UNIQUE (id); +ALTER TABLE ONLY project_history_log + ADD CONSTRAINT project_history_log_id_key UNIQUE (id); + ALTER TABLE ONLY project_history ADD CONSTRAINT project_history_project_id_name_key UNIQUE (project_id, name); @@ -299,9 +316,18 @@ ALTER TABLE ONLY workspace_agent ALTER TABLE ONLY workspace_history ADD CONSTRAINT workspace_history_id_key UNIQUE (id); +ALTER TABLE ONLY workspace_history_log + ADD CONSTRAINT workspace_history_log_id_key UNIQUE (id); + +ALTER TABLE ONLY workspace_history + ADD CONSTRAINT workspace_history_workspace_id_name_key UNIQUE (workspace_id, name); + ALTER TABLE ONLY workspace ADD CONSTRAINT workspace_id_key UNIQUE (id); +ALTER TABLE ONLY workspace + ADD CONSTRAINT workspace_owner_id_name_key UNIQUE (owner_id, name); + ALTER TABLE ONLY workspace_resource ADD CONSTRAINT workspace_resource_id_key UNIQUE (id); @@ -311,7 +337,8 @@ ALTER TABLE ONLY workspace_resource ALTER TABLE ONLY workspace_resource ADD CONSTRAINT workspace_resource_workspace_history_id_name_key UNIQUE (workspace_history_id, name); -CREATE INDEX workspace_log_index ON workspace_log USING btree (workspace_id, workspace_history_id); +ALTER TABLE ONLY project_history_log + ADD CONSTRAINT project_history_log_project_history_id_fkey FOREIGN KEY (project_history_id) REFERENCES project_history(id) ON DELETE CASCADE; ALTER TABLE ONLY project_history ADD CONSTRAINT project_history_project_id_fkey FOREIGN KEY (project_id) REFERENCES project(id); @@ -325,18 +352,15 @@ ALTER TABLE ONLY provisioner_job ALTER TABLE ONLY workspace_agent ADD CONSTRAINT workspace_agent_workspace_resource_id_fkey FOREIGN KEY (workspace_resource_id) REFERENCES workspace_resource(id) ON DELETE CASCADE; +ALTER TABLE ONLY workspace_history_log + ADD CONSTRAINT workspace_history_log_workspace_history_id_fkey FOREIGN KEY (workspace_history_id) REFERENCES workspace_history(id) ON DELETE CASCADE; + ALTER TABLE ONLY workspace_history ADD CONSTRAINT workspace_history_project_history_id_fkey FOREIGN KEY (project_history_id) REFERENCES project_history(id) ON DELETE CASCADE; ALTER TABLE ONLY workspace_history ADD CONSTRAINT workspace_history_workspace_id_fkey FOREIGN KEY (workspace_id) REFERENCES workspace(id) ON DELETE CASCADE; -ALTER TABLE ONLY workspace_log - ADD CONSTRAINT workspace_log_workspace_history_id_fkey FOREIGN KEY (workspace_history_id) REFERENCES workspace_history(id) ON DELETE CASCADE; - -ALTER TABLE ONLY workspace_log - ADD CONSTRAINT workspace_log_workspace_id_fkey FOREIGN KEY (workspace_id) REFERENCES workspace(id) ON DELETE CASCADE; - ALTER TABLE ONLY workspace ADD CONSTRAINT workspace_project_id_fkey FOREIGN KEY (project_id) REFERENCES project(id); diff --git a/database/migrations/000002_projects.up.sql b/database/migrations/000002_projects.up.sql index 251b368ef3..6a021cc988 100644 --- a/database/migrations/000002_projects.up.sql +++ b/database/migrations/000002_projects.up.sql @@ -90,3 +90,25 @@ CREATE TABLE project_parameter ( validation_value_type varchar(64) NOT NULL, UNIQUE(project_history_id, name) ); + +CREATE TYPE log_level AS ENUM ( + 'trace', + 'debug', + 'info', + 'warn', + 'error' +); + +CREATE TYPE log_source AS ENUM ( + 'provisioner_daemon', + 'provisioner' +); + +CREATE TABLE project_history_log ( + id uuid NOT NULL UNIQUE, + project_history_id uuid NOT NULL REFERENCES project_history (id) ON DELETE CASCADE, + created_at timestamptz NOT NULL, + source log_source NOT NULL, + level log_level NOT NULL, + output varchar(1024) NOT NULL +); \ No newline at end of file diff --git a/database/migrations/000003_workspaces.up.sql b/database/migrations/000003_workspaces.up.sql index 55b6150815..60fc1c0d9d 100644 --- a/database/migrations/000003_workspaces.up.sql +++ b/database/migrations/000003_workspaces.up.sql @@ -4,7 +4,8 @@ CREATE TABLE workspace ( updated_at timestamptz NOT NULL, owner_id text NOT NULL, project_id uuid NOT NULL REFERENCES project (id), - name varchar(64) NOT NULL + name varchar(64) NOT NULL, + UNIQUE(owner_id, name) ); CREATE TYPE workspace_transition AS ENUM ( @@ -22,6 +23,7 @@ CREATE TABLE workspace_history ( completed_at timestamptz, workspace_id uuid NOT NULL REFERENCES workspace (id) ON DELETE CASCADE, project_history_id uuid NOT NULL REFERENCES project_history (id) ON DELETE CASCADE, + name varchar(64) NOT NULL, before_id uuid, after_id uuid, transition workspace_transition NOT NULL, @@ -29,7 +31,8 @@ CREATE TABLE workspace_history ( -- State stored by the provisioner provisioner_state bytea, -- Job ID of the action - provision_job_id uuid NOT NULL + provision_job_id uuid NOT NULL, + UNIQUE(workspace_id, name) ); -- Cloud resources produced by a provision job. @@ -63,28 +66,11 @@ CREATE TABLE workspace_agent ( resource_metadata jsonb NOT NULL ); -CREATE TYPE log_level AS ENUM ( - 'trace', - 'debug', - 'info', - 'warn', - 'error', - 'fatal' -); - -CREATE TABLE workspace_log ( - workspace_id uuid NOT NULL REFERENCES workspace (id) ON DELETE CASCADE, - -- workspace_history_id can be NULL because some events are not going to be part of a - -- deliberate transition, e.g. an infrastructure failure that kills the workspace +CREATE TABLE workspace_history_log ( + id uuid NOT NULL UNIQUE, workspace_history_id uuid NOT NULL REFERENCES workspace_history (id) ON DELETE CASCADE, - created timestamptz NOT NULL, --- not sure this is necessary, also not sure it's necessary separate from the log column - logged_by varchar(255), + created_at timestamptz NOT NULL, + source log_source NOT NULL, level log_level NOT NULL, - log jsonb NOT NULL -); - -CREATE INDEX workspace_log_index ON workspace_log ( - workspace_id, - workspace_history_id + output varchar(1024) NOT NULL ); \ No newline at end of file diff --git a/database/models.go b/database/models.go index 3b9fdfcd83..6fd1dad97d 100644 --- a/database/models.go +++ b/database/models.go @@ -19,7 +19,6 @@ const ( LogLevelInfo LogLevel = "info" LogLevelWarn LogLevel = "warn" LogLevelError LogLevel = "error" - LogLevelFatal LogLevel = "fatal" ) func (e *LogLevel) Scan(src interface{}) error { @@ -34,6 +33,25 @@ func (e *LogLevel) Scan(src interface{}) error { return nil } +type LogSource string + +const ( + LogSourceProvisionerDaemon LogSource = "provisioner_daemon" + LogSourceProvisioner LogSource = "provisioner" +) + +func (e *LogSource) Scan(src interface{}) error { + switch s := src.(type) { + case []byte: + *e = LogSource(s) + case string: + *e = LogSource(s) + default: + return fmt.Errorf("unsupported scan type for LogSource: %T", src) + } + return nil +} + type LoginType string const ( @@ -307,6 +325,15 @@ type ProjectHistory struct { ImportJobID uuid.UUID `db:"import_job_id" json:"import_job_id"` } +type ProjectHistoryLog struct { + ID uuid.UUID `db:"id" json:"id"` + ProjectHistoryID uuid.UUID `db:"project_history_id" json:"project_history_id"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + Source LogSource `db:"source" json:"source"` + Level LogLevel `db:"level" json:"level"` + Output string `db:"output" json:"output"` +} + type ProjectParameter struct { ID uuid.UUID `db:"id" json:"id"` CreatedAt time.Time `db:"created_at" json:"created_at"` @@ -398,6 +425,7 @@ type WorkspaceHistory struct { CompletedAt sql.NullTime `db:"completed_at" json:"completed_at"` WorkspaceID uuid.UUID `db:"workspace_id" json:"workspace_id"` ProjectHistoryID uuid.UUID `db:"project_history_id" json:"project_history_id"` + Name string `db:"name" json:"name"` BeforeID uuid.NullUUID `db:"before_id" json:"before_id"` AfterID uuid.NullUUID `db:"after_id" json:"after_id"` Transition WorkspaceTransition `db:"transition" json:"transition"` @@ -406,13 +434,13 @@ type WorkspaceHistory struct { ProvisionJobID uuid.UUID `db:"provision_job_id" json:"provision_job_id"` } -type WorkspaceLog struct { - WorkspaceID uuid.UUID `db:"workspace_id" json:"workspace_id"` - WorkspaceHistoryID uuid.UUID `db:"workspace_history_id" json:"workspace_history_id"` - Created time.Time `db:"created" json:"created"` - LoggedBy sql.NullString `db:"logged_by" json:"logged_by"` - Level LogLevel `db:"level" json:"level"` - Log json.RawMessage `db:"log" json:"log"` +type WorkspaceHistoryLog struct { + ID uuid.UUID `db:"id" json:"id"` + WorkspaceHistoryID uuid.UUID `db:"workspace_history_id" json:"workspace_history_id"` + CreatedAt time.Time `db:"created_at" json:"created_at"` + Source LogSource `db:"source" json:"source"` + Level LogLevel `db:"level" json:"level"` + Output string `db:"output" json:"output"` } type WorkspaceResource struct { diff --git a/database/querier.go b/database/querier.go index 1c908c186c..870d122f11 100644 --- a/database/querier.go +++ b/database/querier.go @@ -20,9 +20,12 @@ type querier interface { GetProjectByOrganizationAndName(ctx context.Context, arg GetProjectByOrganizationAndNameParams) (Project, error) GetProjectHistoryByID(ctx context.Context, id uuid.UUID) (ProjectHistory, error) GetProjectHistoryByProjectID(ctx context.Context, projectID uuid.UUID) ([]ProjectHistory, error) + GetProjectHistoryByProjectIDAndName(ctx context.Context, arg GetProjectHistoryByProjectIDAndNameParams) (ProjectHistory, error) + GetProjectHistoryLogsByIDBefore(ctx context.Context, arg GetProjectHistoryLogsByIDBeforeParams) ([]ProjectHistoryLog, error) GetProjectParametersByHistoryID(ctx context.Context, projectHistoryID uuid.UUID) ([]ProjectParameter, error) GetProjectsByOrganizationIDs(ctx context.Context, ids []string) ([]Project, error) GetProvisionerDaemonByID(ctx context.Context, id uuid.UUID) (ProvisionerDaemon, error) + GetProvisionerDaemons(ctx context.Context) ([]ProvisionerDaemon, error) GetProvisionerJobByID(ctx context.Context, id uuid.UUID) (ProvisionerJob, error) GetUserByEmailOrUsername(ctx context.Context, arg GetUserByEmailOrUsernameParams) (User, error) GetUserByID(ctx context.Context, id string) (User, error) @@ -32,7 +35,9 @@ type querier interface { GetWorkspaceByUserIDAndName(ctx context.Context, arg GetWorkspaceByUserIDAndNameParams) (Workspace, error) GetWorkspaceHistoryByID(ctx context.Context, id uuid.UUID) (WorkspaceHistory, error) GetWorkspaceHistoryByWorkspaceID(ctx context.Context, workspaceID uuid.UUID) ([]WorkspaceHistory, error) + GetWorkspaceHistoryByWorkspaceIDAndName(ctx context.Context, arg GetWorkspaceHistoryByWorkspaceIDAndNameParams) (WorkspaceHistory, error) GetWorkspaceHistoryByWorkspaceIDWithoutAfter(ctx context.Context, workspaceID uuid.UUID) (WorkspaceHistory, error) + GetWorkspaceHistoryLogsByIDBefore(ctx context.Context, arg GetWorkspaceHistoryLogsByIDBeforeParams) ([]WorkspaceHistoryLog, error) GetWorkspaceResourcesByHistoryID(ctx context.Context, workspaceHistoryID uuid.UUID) ([]WorkspaceResource, error) GetWorkspacesByProjectAndUserID(ctx context.Context, arg GetWorkspacesByProjectAndUserIDParams) ([]Workspace, error) GetWorkspacesByUserID(ctx context.Context, ownerID string) ([]Workspace, error) @@ -42,6 +47,7 @@ type querier interface { InsertParameterValue(ctx context.Context, arg InsertParameterValueParams) (ParameterValue, error) InsertProject(ctx context.Context, arg InsertProjectParams) (Project, error) InsertProjectHistory(ctx context.Context, arg InsertProjectHistoryParams) (ProjectHistory, error) + InsertProjectHistoryLogs(ctx context.Context, arg InsertProjectHistoryLogsParams) ([]ProjectHistoryLog, error) InsertProjectParameter(ctx context.Context, arg InsertProjectParameterParams) (ProjectParameter, error) InsertProvisionerDaemon(ctx context.Context, arg InsertProvisionerDaemonParams) (ProvisionerDaemon, error) InsertProvisionerJob(ctx context.Context, arg InsertProvisionerJobParams) (ProvisionerJob, error) @@ -49,6 +55,7 @@ type querier interface { InsertWorkspace(ctx context.Context, arg InsertWorkspaceParams) (Workspace, error) InsertWorkspaceAgent(ctx context.Context, arg InsertWorkspaceAgentParams) (WorkspaceAgent, error) InsertWorkspaceHistory(ctx context.Context, arg InsertWorkspaceHistoryParams) (WorkspaceHistory, error) + InsertWorkspaceHistoryLogs(ctx context.Context, arg InsertWorkspaceHistoryLogsParams) ([]WorkspaceHistoryLog, error) InsertWorkspaceResource(ctx context.Context, arg InsertWorkspaceResourceParams) (WorkspaceResource, error) UpdateAPIKeyByID(ctx context.Context, arg UpdateAPIKeyByIDParams) error UpdateProvisionerDaemonByID(ctx context.Context, arg UpdateProvisionerDaemonByIDParams) error diff --git a/database/query.sql b/database/query.sql index abf887cd17..4c18f5ed10 100644 --- a/database/query.sql +++ b/database/query.sql @@ -171,6 +171,15 @@ FROM WHERE project_id = $1; +-- name: GetProjectHistoryByProjectIDAndName :one +SELECT + * +FROM + project_history +WHERE + project_id = $1 + AND name = $2; + -- name: GetProjectHistoryByID :one SELECT * @@ -179,6 +188,23 @@ FROM WHERE id = $1; +-- name: GetProjectHistoryLogsByIDBefore :many +SELECT + * +FROM + project_history_log +WHERE + project_history_id = $1 + AND created_at <= $2 +ORDER BY + created_at; + +-- name: GetProvisionerDaemons :many +SELECT + * +FROM + provisioner_daemon; + -- name: GetProvisionerDaemonByID :one SELECT * @@ -241,6 +267,15 @@ WHERE LIMIT 1; +-- name: GetWorkspaceHistoryByWorkspaceIDAndName :one +SELECT + * +FROM + workspace_history +WHERE + workspace_id = $1 + AND name = $2; + -- name: GetWorkspaceHistoryByWorkspaceID :many SELECT * @@ -260,6 +295,17 @@ WHERE LIMIT 1; +-- name: GetWorkspaceHistoryLogsByIDBefore :many +SELECT + * +FROM + workspace_history_log +WHERE + workspace_history_id = $1 + AND created_at <= $2 +ORDER BY + created_at; + -- name: GetWorkspaceResourcesByHistoryID :many SELECT * @@ -378,6 +424,17 @@ INSERT INTO VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING *; +-- name: InsertProjectHistoryLogs :many +INSERT INTO + project_history_log +SELECT + @project_history_id :: uuid AS project_history_id, + unnset(@id :: uuid [ ]) AS id, + unnest(@created_at :: timestamptz [ ]) AS created_at, + unnset(@source :: log_source [ ]) as source, + unnset(@level :: log_level [ ]) as level, + unnset(@output :: varchar(1024) [ ]) as output RETURNING *; + -- name: InsertProjectParameter :one INSERT INTO project_parameter ( @@ -492,12 +549,24 @@ INSERT INTO workspace_id, project_history_id, before_id, + name, transition, initiator, provision_job_id ) VALUES - ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING *; + ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING *; + +-- name: InsertWorkspaceHistoryLogs :many +INSERT INTO + workspace_history_log +SELECT + @workspace_history_id :: uuid AS workspace_history_id, + unnset(@id :: uuid [ ]) AS id, + unnest(@created_at :: timestamptz [ ]) AS created_at, + unnset(@source :: log_source [ ]) as source, + unnset(@level :: log_level [ ]) as level, + unnset(@output :: varchar(1024) [ ]) as output RETURNING *; -- name: InsertWorkspaceResource :one INSERT INTO @@ -549,6 +618,8 @@ UPDATE workspace_history SET updated_at = $2, - after_id = $3 + completed_at = $3, + after_id = $4, + provisioner_state = $5 WHERE id = $1; diff --git a/database/query.sql.go b/database/query.sql.go index 83c2a8af00..45507b50c7 100644 --- a/database/query.sql.go +++ b/database/query.sql.go @@ -418,6 +418,85 @@ func (q *sqlQuerier) GetProjectHistoryByProjectID(ctx context.Context, projectID return items, nil } +const getProjectHistoryByProjectIDAndName = `-- name: GetProjectHistoryByProjectIDAndName :one +SELECT + id, project_id, created_at, updated_at, name, description, storage_method, storage_source, import_job_id +FROM + project_history +WHERE + project_id = $1 + AND name = $2 +` + +type GetProjectHistoryByProjectIDAndNameParams struct { + ProjectID uuid.UUID `db:"project_id" json:"project_id"` + Name string `db:"name" json:"name"` +} + +func (q *sqlQuerier) GetProjectHistoryByProjectIDAndName(ctx context.Context, arg GetProjectHistoryByProjectIDAndNameParams) (ProjectHistory, error) { + row := q.db.QueryRowContext(ctx, getProjectHistoryByProjectIDAndName, arg.ProjectID, arg.Name) + var i ProjectHistory + err := row.Scan( + &i.ID, + &i.ProjectID, + &i.CreatedAt, + &i.UpdatedAt, + &i.Name, + &i.Description, + &i.StorageMethod, + &i.StorageSource, + &i.ImportJobID, + ) + return i, err +} + +const getProjectHistoryLogsByIDBefore = `-- name: GetProjectHistoryLogsByIDBefore :many +SELECT + id, project_history_id, created_at, source, level, output +FROM + project_history_log +WHERE + project_history_id = $1 + AND created_at <= $2 +ORDER BY + created_at +` + +type GetProjectHistoryLogsByIDBeforeParams struct { + ProjectHistoryID uuid.UUID `db:"project_history_id" json:"project_history_id"` + CreatedAt time.Time `db:"created_at" json:"created_at"` +} + +func (q *sqlQuerier) GetProjectHistoryLogsByIDBefore(ctx context.Context, arg GetProjectHistoryLogsByIDBeforeParams) ([]ProjectHistoryLog, error) { + rows, err := q.db.QueryContext(ctx, getProjectHistoryLogsByIDBefore, arg.ProjectHistoryID, arg.CreatedAt) + if err != nil { + return nil, err + } + defer rows.Close() + var items []ProjectHistoryLog + for rows.Next() { + var i ProjectHistoryLog + if err := rows.Scan( + &i.ID, + &i.ProjectHistoryID, + &i.CreatedAt, + &i.Source, + &i.Level, + &i.Output, + ); 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 getProjectParametersByHistoryID = `-- name: GetProjectParametersByHistoryID :many SELECT id, created_at, project_history_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 @@ -530,6 +609,42 @@ func (q *sqlQuerier) GetProvisionerDaemonByID(ctx context.Context, id uuid.UUID) return i, err } +const getProvisionerDaemons = `-- name: GetProvisionerDaemons :many +SELECT + id, created_at, updated_at, name, provisioners +FROM + provisioner_daemon +` + +func (q *sqlQuerier) GetProvisionerDaemons(ctx context.Context) ([]ProvisionerDaemon, error) { + rows, err := q.db.QueryContext(ctx, getProvisionerDaemons) + if err != nil { + return nil, err + } + defer rows.Close() + var items []ProvisionerDaemon + for rows.Next() { + var i ProvisionerDaemon + if err := rows.Scan( + &i.ID, + &i.CreatedAt, + &i.UpdatedAt, + &i.Name, + pq.Array(&i.Provisioners), + ); 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 getProvisionerJobByID = `-- name: GetProvisionerJobByID :one SELECT id, created_at, updated_at, started_at, cancelled_at, completed_at, error, initiator_id, provisioner, type, project_id, input, worker_id @@ -751,7 +866,7 @@ func (q *sqlQuerier) GetWorkspaceByUserIDAndName(ctx context.Context, arg GetWor const getWorkspaceHistoryByID = `-- name: GetWorkspaceHistoryByID :one SELECT - id, created_at, updated_at, completed_at, workspace_id, project_history_id, before_id, after_id, transition, initiator, provisioner_state, provision_job_id + id, created_at, updated_at, completed_at, workspace_id, project_history_id, name, before_id, after_id, transition, initiator, provisioner_state, provision_job_id FROM workspace_history WHERE @@ -770,6 +885,7 @@ func (q *sqlQuerier) GetWorkspaceHistoryByID(ctx context.Context, id uuid.UUID) &i.CompletedAt, &i.WorkspaceID, &i.ProjectHistoryID, + &i.Name, &i.BeforeID, &i.AfterID, &i.Transition, @@ -782,7 +898,7 @@ func (q *sqlQuerier) GetWorkspaceHistoryByID(ctx context.Context, id uuid.UUID) const getWorkspaceHistoryByWorkspaceID = `-- name: GetWorkspaceHistoryByWorkspaceID :many SELECT - id, created_at, updated_at, completed_at, workspace_id, project_history_id, before_id, after_id, transition, initiator, provisioner_state, provision_job_id + id, created_at, updated_at, completed_at, workspace_id, project_history_id, name, before_id, after_id, transition, initiator, provisioner_state, provision_job_id FROM workspace_history WHERE @@ -805,6 +921,7 @@ func (q *sqlQuerier) GetWorkspaceHistoryByWorkspaceID(ctx context.Context, works &i.CompletedAt, &i.WorkspaceID, &i.ProjectHistoryID, + &i.Name, &i.BeforeID, &i.AfterID, &i.Transition, @@ -825,9 +942,45 @@ func (q *sqlQuerier) GetWorkspaceHistoryByWorkspaceID(ctx context.Context, works return items, nil } +const getWorkspaceHistoryByWorkspaceIDAndName = `-- name: GetWorkspaceHistoryByWorkspaceIDAndName :one +SELECT + id, created_at, updated_at, completed_at, workspace_id, project_history_id, name, before_id, after_id, transition, initiator, provisioner_state, provision_job_id +FROM + workspace_history +WHERE + workspace_id = $1 + AND name = $2 +` + +type GetWorkspaceHistoryByWorkspaceIDAndNameParams struct { + WorkspaceID uuid.UUID `db:"workspace_id" json:"workspace_id"` + Name string `db:"name" json:"name"` +} + +func (q *sqlQuerier) GetWorkspaceHistoryByWorkspaceIDAndName(ctx context.Context, arg GetWorkspaceHistoryByWorkspaceIDAndNameParams) (WorkspaceHistory, error) { + row := q.db.QueryRowContext(ctx, getWorkspaceHistoryByWorkspaceIDAndName, arg.WorkspaceID, arg.Name) + var i WorkspaceHistory + err := row.Scan( + &i.ID, + &i.CreatedAt, + &i.UpdatedAt, + &i.CompletedAt, + &i.WorkspaceID, + &i.ProjectHistoryID, + &i.Name, + &i.BeforeID, + &i.AfterID, + &i.Transition, + &i.Initiator, + &i.ProvisionerState, + &i.ProvisionJobID, + ) + return i, err +} + const getWorkspaceHistoryByWorkspaceIDWithoutAfter = `-- name: GetWorkspaceHistoryByWorkspaceIDWithoutAfter :one SELECT - id, created_at, updated_at, completed_at, workspace_id, project_history_id, before_id, after_id, transition, initiator, provisioner_state, provision_job_id + id, created_at, updated_at, completed_at, workspace_id, project_history_id, name, before_id, after_id, transition, initiator, provisioner_state, provision_job_id FROM workspace_history WHERE @@ -847,6 +1000,7 @@ func (q *sqlQuerier) GetWorkspaceHistoryByWorkspaceIDWithoutAfter(ctx context.Co &i.CompletedAt, &i.WorkspaceID, &i.ProjectHistoryID, + &i.Name, &i.BeforeID, &i.AfterID, &i.Transition, @@ -857,6 +1011,53 @@ func (q *sqlQuerier) GetWorkspaceHistoryByWorkspaceIDWithoutAfter(ctx context.Co return i, err } +const getWorkspaceHistoryLogsByIDBefore = `-- name: GetWorkspaceHistoryLogsByIDBefore :many +SELECT + id, workspace_history_id, created_at, source, level, output +FROM + workspace_history_log +WHERE + workspace_history_id = $1 + AND created_at <= $2 +ORDER BY + created_at +` + +type GetWorkspaceHistoryLogsByIDBeforeParams struct { + WorkspaceHistoryID uuid.UUID `db:"workspace_history_id" json:"workspace_history_id"` + CreatedAt time.Time `db:"created_at" json:"created_at"` +} + +func (q *sqlQuerier) GetWorkspaceHistoryLogsByIDBefore(ctx context.Context, arg GetWorkspaceHistoryLogsByIDBeforeParams) ([]WorkspaceHistoryLog, error) { + rows, err := q.db.QueryContext(ctx, getWorkspaceHistoryLogsByIDBefore, arg.WorkspaceHistoryID, arg.CreatedAt) + if err != nil { + return nil, err + } + defer rows.Close() + var items []WorkspaceHistoryLog + for rows.Next() { + var i WorkspaceHistoryLog + if err := rows.Scan( + &i.ID, + &i.WorkspaceHistoryID, + &i.CreatedAt, + &i.Source, + &i.Level, + &i.Output, + ); 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 getWorkspaceResourcesByHistoryID = `-- name: GetWorkspaceResourcesByHistoryID :many SELECT id, created_at, workspace_history_id, type, name, workspace_agent_token, workspace_agent_id @@ -1317,6 +1518,64 @@ func (q *sqlQuerier) InsertProjectHistory(ctx context.Context, arg InsertProject return i, err } +const insertProjectHistoryLogs = `-- name: InsertProjectHistoryLogs :many +INSERT INTO + project_history_log +SELECT + $1 :: uuid AS project_history_id, + unnset($2 :: uuid [ ]) AS id, + unnest($3 :: timestamptz [ ]) AS created_at, + unnset($4 :: log_source [ ]) as source, + unnset($5 :: log_level [ ]) as level, + unnset($6 :: varchar(1024) [ ]) as output RETURNING id, project_history_id, created_at, source, level, output +` + +type InsertProjectHistoryLogsParams struct { + ProjectHistoryID uuid.UUID `db:"project_history_id" json:"project_history_id"` + ID []uuid.UUID `db:"id" json:"id"` + CreatedAt []time.Time `db:"created_at" json:"created_at"` + Source []LogSource `db:"source" json:"source"` + Level []LogLevel `db:"level" json:"level"` + Output []string `db:"output" json:"output"` +} + +func (q *sqlQuerier) InsertProjectHistoryLogs(ctx context.Context, arg InsertProjectHistoryLogsParams) ([]ProjectHistoryLog, error) { + rows, err := q.db.QueryContext(ctx, insertProjectHistoryLogs, + arg.ProjectHistoryID, + pq.Array(arg.ID), + pq.Array(arg.CreatedAt), + pq.Array(arg.Source), + pq.Array(arg.Level), + pq.Array(arg.Output), + ) + if err != nil { + return nil, err + } + defer rows.Close() + var items []ProjectHistoryLog + for rows.Next() { + var i ProjectHistoryLog + if err := rows.Scan( + &i.ID, + &i.ProjectHistoryID, + &i.CreatedAt, + &i.Source, + &i.Level, + &i.Output, + ); 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 insertProjectParameter = `-- name: InsertProjectParameter :one INSERT INTO project_parameter ( @@ -1673,12 +1932,13 @@ INSERT INTO workspace_id, project_history_id, before_id, + name, transition, initiator, provision_job_id ) VALUES - ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING id, created_at, updated_at, completed_at, workspace_id, project_history_id, before_id, after_id, transition, initiator, provisioner_state, provision_job_id + ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING id, created_at, updated_at, completed_at, workspace_id, project_history_id, name, before_id, after_id, transition, initiator, provisioner_state, provision_job_id ` type InsertWorkspaceHistoryParams struct { @@ -1688,6 +1948,7 @@ type InsertWorkspaceHistoryParams struct { WorkspaceID uuid.UUID `db:"workspace_id" json:"workspace_id"` ProjectHistoryID uuid.UUID `db:"project_history_id" json:"project_history_id"` BeforeID uuid.NullUUID `db:"before_id" json:"before_id"` + Name string `db:"name" json:"name"` Transition WorkspaceTransition `db:"transition" json:"transition"` Initiator string `db:"initiator" json:"initiator"` ProvisionJobID uuid.UUID `db:"provision_job_id" json:"provision_job_id"` @@ -1701,6 +1962,7 @@ func (q *sqlQuerier) InsertWorkspaceHistory(ctx context.Context, arg InsertWorks arg.WorkspaceID, arg.ProjectHistoryID, arg.BeforeID, + arg.Name, arg.Transition, arg.Initiator, arg.ProvisionJobID, @@ -1713,6 +1975,7 @@ func (q *sqlQuerier) InsertWorkspaceHistory(ctx context.Context, arg InsertWorks &i.CompletedAt, &i.WorkspaceID, &i.ProjectHistoryID, + &i.Name, &i.BeforeID, &i.AfterID, &i.Transition, @@ -1723,6 +1986,64 @@ func (q *sqlQuerier) InsertWorkspaceHistory(ctx context.Context, arg InsertWorks return i, err } +const insertWorkspaceHistoryLogs = `-- name: InsertWorkspaceHistoryLogs :many +INSERT INTO + workspace_history_log +SELECT + $1 :: uuid AS workspace_history_id, + unnset($2 :: uuid [ ]) AS id, + unnest($3 :: timestamptz [ ]) AS created_at, + unnset($4 :: log_source [ ]) as source, + unnset($5 :: log_level [ ]) as level, + unnset($6 :: varchar(1024) [ ]) as output RETURNING id, workspace_history_id, created_at, source, level, output +` + +type InsertWorkspaceHistoryLogsParams struct { + WorkspaceHistoryID uuid.UUID `db:"workspace_history_id" json:"workspace_history_id"` + ID []uuid.UUID `db:"id" json:"id"` + CreatedAt []time.Time `db:"created_at" json:"created_at"` + Source []LogSource `db:"source" json:"source"` + Level []LogLevel `db:"level" json:"level"` + Output []string `db:"output" json:"output"` +} + +func (q *sqlQuerier) InsertWorkspaceHistoryLogs(ctx context.Context, arg InsertWorkspaceHistoryLogsParams) ([]WorkspaceHistoryLog, error) { + rows, err := q.db.QueryContext(ctx, insertWorkspaceHistoryLogs, + arg.WorkspaceHistoryID, + pq.Array(arg.ID), + pq.Array(arg.CreatedAt), + pq.Array(arg.Source), + pq.Array(arg.Level), + pq.Array(arg.Output), + ) + if err != nil { + return nil, err + } + defer rows.Close() + var items []WorkspaceHistoryLog + for rows.Next() { + var i WorkspaceHistoryLog + if err := rows.Scan( + &i.ID, + &i.WorkspaceHistoryID, + &i.CreatedAt, + &i.Source, + &i.Level, + &i.Output, + ); 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 insertWorkspaceResource = `-- name: InsertWorkspaceResource :one INSERT INTO workspace_resource ( @@ -1859,18 +2180,28 @@ UPDATE workspace_history SET updated_at = $2, - after_id = $3 + completed_at = $3, + after_id = $4, + provisioner_state = $5 WHERE id = $1 ` type UpdateWorkspaceHistoryByIDParams struct { - ID uuid.UUID `db:"id" json:"id"` - UpdatedAt time.Time `db:"updated_at" json:"updated_at"` - AfterID uuid.NullUUID `db:"after_id" json:"after_id"` + ID uuid.UUID `db:"id" json:"id"` + UpdatedAt time.Time `db:"updated_at" json:"updated_at"` + CompletedAt sql.NullTime `db:"completed_at" json:"completed_at"` + AfterID uuid.NullUUID `db:"after_id" json:"after_id"` + ProvisionerState []byte `db:"provisioner_state" json:"provisioner_state"` } func (q *sqlQuerier) UpdateWorkspaceHistoryByID(ctx context.Context, arg UpdateWorkspaceHistoryByIDParams) error { - _, err := q.db.ExecContext(ctx, updateWorkspaceHistoryByID, arg.ID, arg.UpdatedAt, arg.AfterID) + _, err := q.db.ExecContext(ctx, updateWorkspaceHistoryByID, + arg.ID, + arg.UpdatedAt, + arg.CompletedAt, + arg.AfterID, + arg.ProvisionerState, + ) return err } diff --git a/go.mod b/go.mod index f284827b2b..45cf8c8cfc 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,9 @@ module github.com/coder/coder go 1.17 +// Required until https://github.com/hashicorp/terraform-exec/pull/275 is merged. +replace github.com/hashicorp/terraform-exec => github.com/kylecarbs/terraform-exec v0.15.1-0.20220129210610-65894a884c09 + // Required until https://github.com/hashicorp/terraform-config-inspect/pull/74 is merged. replace github.com/hashicorp/terraform-config-inspect => github.com/kylecarbs/terraform-config-inspect v0.0.0-20211215004401-bbc517866b88 @@ -37,14 +40,12 @@ require ( require ( cloud.google.com/go/compute v0.1.0 // indirect - cloud.google.com/go/storage v1.19.0 // indirect github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/Microsoft/go-winio v0.5.1 // indirect github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/alecthomas/chroma v0.10.0 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect - github.com/aws/aws-sdk-go v1.42.42 // indirect github.com/cenkalti/backoff/v4 v4.1.2 // indirect github.com/containerd/continuity v0.2.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect @@ -105,7 +106,6 @@ require ( golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect - google.golang.org/api v0.65.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5 // indirect google.golang.org/grpc v1.44.0 // indirect diff --git a/go.sum b/go.sum index 13d1dc9311..cf80329fa8 100644 --- a/go.sum +++ b/go.sum @@ -32,7 +32,6 @@ cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= cloud.google.com/go v0.98.0/go.mod h1:ua6Ush4NALrHk5QXDWnjvZHN93OuF0HfuEPq9I1X0cM= cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= -cloud.google.com/go v0.100.1/go.mod h1:fs4QogzfH5n2pBXBP9vRiU+eCny7lD2vmFZy79Iuw1U= cloud.google.com/go v0.100.2 h1:t9Iw5QH5v4XtlEQaCtUY7x6sCABps8sW0acw7e2WQ6Y= cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= @@ -46,8 +45,6 @@ cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTB cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY= -cloud.google.com/go/iam v0.1.1 h1:4CapQyNFjiksks1/x7jsvsygFPhihslYk5GptIrlX68= -cloud.google.com/go/iam v0.1.1/go.mod h1:CKqrcnI/suGpybEHxZ7BMehL0oA4LpdyJdUlTl9jVMw= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -58,8 +55,6 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -cloud.google.com/go/storage v1.19.0 h1:XOQSnPJD8hRtZJ3VdCyK0mBZsGGImrzPAMbSWcHSe6Q= -cloud.google.com/go/storage v1.19.0/go.mod h1:6rgiTRjOqI/Zd9YKimub5TIB4d+p3LH33V3ZE1DMuUM= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= github.com/Azure/azure-pipeline-go v0.2.3/go.mod h1:x841ezTBIMG6O3lAcl8ATHnsOPVl2bqk7S3ta6S6u4k= @@ -85,9 +80,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ClickHouse/clickhouse-go v1.4.3/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= -github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= @@ -157,10 +149,7 @@ github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgI github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= -github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/aws/aws-sdk-go v1.17.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.42.42 h1:2K61yu5BApC9ExAwC5Vk6ljWzBGbiRGRQYLW7adhP5U= -github.com/aws/aws-sdk-go v1.42.42/go.mod h1:OGr6lGMAKGlG9CVrYnWYDKIyb829c6EVBRjxqjmPepc= github.com/aws/aws-sdk-go-v2 v1.8.0/go.mod h1:xEFuWz+3TYdlPRuo+CqATbeDWIWyaT5uAPwPaWtgse0= github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= github.com/aws/aws-sdk-go-v2/config v1.6.0/go.mod h1:TNtBVmka80lRPk5+S9ZqVfFszOQAGJJ9KbT3EM3CHNU= @@ -191,8 +180,6 @@ github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= -github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k= github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= @@ -219,7 +206,6 @@ github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/checkpoint-restore/go-criu/v4 v4.1.0/go.mod h1:xUQBLp4RLc5zJtWY++yjOoMoB5lihDt7fai+75m+rGw= github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M= github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= -github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -633,7 +619,6 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1 h1:dp3bWCh+PPO1zjRRiCSczJav13sBvG4UhNyVTa1KqdU= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -659,14 +644,11 @@ github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FK github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.5.3 h1:NF5+zOlQegim+w/EUhSLh6QhXHmZMEeHLQzllkQ3ROU= -github.com/hashicorp/go-getter v1.5.3/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXjMEgDD8+i7ZI= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -679,20 +661,18 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= -github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.4.0 h1:aAQzgqIrRKRa7w75CKpbBxYsmUoPjzVm1W59ca1L0J4= github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/hc-install v0.3.1 h1:VIjllE6KyAI1A244G8kTaHXy+TL5/XYzvrtFi8po/Yk= +github.com/hashicorp/hc-install v0.3.1/go.mod h1:3LCdWcCDS1gaHC9mhHCGbkYfoY6vdsKohGjugbZdZak= github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= @@ -706,12 +686,9 @@ github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOn github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= -github.com/hashicorp/terraform-exec v0.15.0 h1:cqjh4d8HYNQrDoEmlSGelHmg2DYDh5yayckvJ5bV18E= -github.com/hashicorp/terraform-exec v0.15.0/go.mod h1:H4IG8ZxanU+NW0ZpDRNsvh9f0ul7C0nHP+rUR/CHs7I= github.com/hashicorp/terraform-json v0.13.0 h1:Li9L+lKD1FO5RVFRM1mMMIBDoUHslOniyEi5CM+FWGY= github.com/hashicorp/terraform-json v0.13.0/go.mod h1:y5OdLBCT+rxbwnpxZs9kGL7R9ExU76+cpdY8zHwoazk= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -775,7 +752,6 @@ github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/ github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= @@ -809,12 +785,10 @@ github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQL github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= -github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.13.1/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -835,6 +809,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/ktrysmt/go-bitbucket v0.6.4/go.mod h1:9u0v3hsd2rqCHRIpbir1oP7F58uo5dq19sBYvuMoyQ4= github.com/kylecarbs/terraform-config-inspect v0.0.0-20211215004401-bbc517866b88 h1:tvG/qs5c4worwGyGnbbb4i/dYYLjpFwDMqcIT3awAf8= github.com/kylecarbs/terraform-config-inspect v0.0.0-20211215004401-bbc517866b88/go.mod h1:Z0Nnk4+3Cy89smEbrq+sl1bxc9198gIP4I7wcQF6Kqs= +github.com/kylecarbs/terraform-exec v0.15.1-0.20220129210610-65894a884c09 h1:o+8BFGukFfFmGgOJIWEeDXkXRDdFoZ9ndi/GjqnHTGg= +github.com/kylecarbs/terraform-exec v0.15.1-0.20220129210610-65894a884c09/go.mod h1:lRENyXw1BL5V0FCCE8lsW3XoVLRLnxM54jrlYSyXpvM= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= @@ -882,7 +858,6 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= @@ -894,13 +869,9 @@ github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJys github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible/go.mod h1:8AuVvqP/mXw1px98n46wfvcGfQ4ci2FwoAjKYxuo3Z4= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= -github.com/mitchellh/cli v1.1.2/go.mod h1:6iaV0fGdElS6dPBx0EApTxHrcWvmJphyh2n8YBLPPZ4= -github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= @@ -913,7 +884,6 @@ github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A= -github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/moby/locker v1.0.1/go.mod h1:S7SDdo5zpBK84bzzVlKr2V0hz+7x9hWbYC/kq7oQppc= github.com/moby/moby v20.10.12+incompatible h1:MJVrdG0tIQqVJQBTdtooPuZQFIgski5pYTXlcW8ToE0= @@ -1187,8 +1157,6 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1 github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= -github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ= -github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/unrolled/secure v1.0.9 h1:BWRuEb1vDrBFFDdbCnKkof3gZ35I/bnHGyt0LB0TNyQ= github.com/unrolled/secure v1.0.9/go.mod h1:fO+mEan+FLB0CdEnHf6Q4ZZVNqG+5fuLFnP8p0BXDPI= github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= @@ -1301,10 +1269,10 @@ golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -1721,9 +1689,6 @@ google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUb google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= google.golang.org/api v0.62.0/go.mod h1:dKmwPCydfsad4qCH08MSdgWjfHOyfpd4VtDGgRFdavw= google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= -google.golang.org/api v0.64.0/go.mod h1:931CdxA8Rm4t6zqTFGSsgwbAEZ2+GMYurbndwSimebM= -google.golang.org/api v0.65.0 h1:MTW9c+LIBAbwoS1Gb+YV7NjFBt2f7GtAS5hIzh2NjgQ= -google.golang.org/api v0.65.0/go.mod h1:ArYhxgGadlWmqO1IqVujw6Cs8IdD33bTmzKo2Sh+cbg= google.golang.org/appengine v1.0.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1807,8 +1772,6 @@ google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220111164026-67b88f271998/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5 h1:zzNejm+EgrbLfDZ6lu9Uud2IVvHySPl8vQzf04laR5Q= google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= @@ -1872,7 +1835,6 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= -gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= diff --git a/provisioner/terraform/parse.go b/provisioner/terraform/parse.go index cc92bc8f80..c0ab765c1b 100644 --- a/provisioner/terraform/parse.go +++ b/provisioner/terraform/parse.go @@ -1,7 +1,6 @@ package terraform import ( - "context" "encoding/json" "os" @@ -12,24 +11,32 @@ import ( ) // Parse extracts Terraform variables from source-code. -func (*terraform) Parse(_ context.Context, request *proto.Parse_Request) (*proto.Parse_Response, error) { +func (*terraform) Parse(request *proto.Parse_Request, stream proto.DRPCProvisioner_ParseStream) error { + defer func() { + _ = stream.CloseSend() + }() + module, diags := tfconfig.LoadModule(request.Directory) if diags.HasErrors() { - return nil, xerrors.Errorf("load module: %w", diags.Err()) + return xerrors.Errorf("load module: %w", diags.Err()) } parameters := make([]*proto.ParameterSchema, 0, len(module.Variables)) for _, v := range module.Variables { schema, err := convertVariableToParameter(v) if err != nil { - return nil, xerrors.Errorf("convert variable %q: %w", v.Name, err) + return xerrors.Errorf("convert variable %q: %w", v.Name, err) } parameters = append(parameters, schema) } - return &proto.Parse_Response{ - ParameterSchemas: parameters, - }, nil + return stream.Send(&proto.Parse_Response{ + Type: &proto.Parse_Response_Complete{ + Complete: &proto.Parse_Complete{ + ParameterSchemas: parameters, + }, + }, + }) } // Converts a Terraform variable to a provisioner parameter. diff --git a/provisioner/terraform/parse_test.go b/provisioner/terraform/parse_test.go index bbfe166827..e678d1d36c 100644 --- a/provisioner/terraform/parse_test.go +++ b/provisioner/terraform/parse_test.go @@ -49,10 +49,14 @@ func TestParse(t *testing.T) { }`, }, Response: &proto.Parse_Response{ - ParameterSchemas: []*proto.ParameterSchema{{ - Name: "A", - Description: "Testing!", - }}, + Type: &proto.Parse_Response_Complete{ + Complete: &proto.Parse_Complete{ + ParameterSchemas: []*proto.ParameterSchema{{ + Name: "A", + Description: "Testing!", + }}, + }, + }, }, }, { Name: "default-variable-value", @@ -62,17 +66,21 @@ func TestParse(t *testing.T) { }`, }, Response: &proto.Parse_Response{ - ParameterSchemas: []*proto.ParameterSchema{{ - Name: "A", - DefaultSource: &proto.ParameterSource{ - Scheme: proto.ParameterSource_DATA, - Value: "\"wow\"", + Type: &proto.Parse_Response_Complete{ + Complete: &proto.Parse_Complete{ + ParameterSchemas: []*proto.ParameterSchema{{ + Name: "A", + DefaultSource: &proto.ParameterSource{ + Scheme: proto.ParameterSource_DATA, + Value: "\"wow\"", + }, + DefaultDestination: &proto.ParameterDestination{ + Scheme: proto.ParameterDestination_PROVISIONER_VARIABLE, + Value: "A", + }, + }}, }, - DefaultDestination: &proto.ParameterDestination{ - Scheme: proto.ParameterDestination_PROVISIONER_VARIABLE, - Value: "A", - }, - }}, + }, }, }, { Name: "variable-validation", @@ -84,10 +92,15 @@ func TestParse(t *testing.T) { }`, }, Response: &proto.Parse_Response{ - ParameterSchemas: []*proto.ParameterSchema{{ - Name: "A", - ValidationCondition: `var.A == "value"`, - }}, + Type: &proto.Parse_Response_Complete{ + Complete: &proto.Parse_Complete{ + ParameterSchemas: []*proto.ParameterSchema{{ + Name: "A", + ValidationCondition: `var.A == "value"`, + }, + }, + }, + }, }, }} { testCase := testCase @@ -106,13 +119,23 @@ func TestParse(t *testing.T) { }) require.NoError(t, err) - // Ensure the want and got are equivalent! - want, err := json.Marshal(testCase.Response) - require.NoError(t, err) - got, err := json.Marshal(response) - require.NoError(t, err) + for { + msg, err := response.Recv() + require.NoError(t, err) - require.Equal(t, string(want), string(got)) + if msg.GetComplete() == nil { + continue + } + + // Ensure the want and got are equivalent! + want, err := json.Marshal(testCase.Response) + require.NoError(t, err) + got, err := json.Marshal(msg) + require.NoError(t, err) + + require.Equal(t, string(want), string(got)) + break + } }) } } diff --git a/provisioner/terraform/provision.go b/provisioner/terraform/provision.go index 4cf94ec0d9..fe0e9bec46 100644 --- a/provisioner/terraform/provision.go +++ b/provisioner/terraform/provision.go @@ -1,10 +1,13 @@ package terraform import ( - "context" + "bufio" + "encoding/json" "fmt" + "io" "os" "path/filepath" + "strings" "github.com/hashicorp/terraform-exec/tfexec" "golang.org/x/xerrors" @@ -13,32 +16,52 @@ import ( ) // Provision executes `terraform apply`. -func (t *terraform) Provision(ctx context.Context, request *proto.Provision_Request) (*proto.Provision_Response, error) { +func (t *terraform) Provision(request *proto.Provision_Request, stream proto.DRPCProvisioner_ProvisionStream) error { + ctx := stream.Context() statefilePath := filepath.Join(request.Directory, "terraform.tfstate") - err := os.WriteFile(statefilePath, request.State, 0600) - if err != nil { - return nil, xerrors.Errorf("write statefile %q: %w", statefilePath, err) + if len(request.State) > 0 { + err := os.WriteFile(statefilePath, request.State, 0600) + if err != nil { + return xerrors.Errorf("write statefile %q: %w", statefilePath, err) + } } terraform, err := tfexec.NewTerraform(request.Directory, t.binaryPath) if err != nil { - return nil, xerrors.Errorf("create new terraform executor: %w", err) + return xerrors.Errorf("create new terraform executor: %w", err) } version, _, err := terraform.Version(ctx, false) if err != nil { - return nil, xerrors.Errorf("get terraform version: %w", err) + return xerrors.Errorf("get terraform version: %w", err) } if !version.GreaterThanOrEqual(minimumTerraformVersion) { - return nil, xerrors.Errorf("terraform version %q is too old. required >= %q", version.String(), minimumTerraformVersion.String()) + return xerrors.Errorf("terraform version %q is too old. required >= %q", version.String(), minimumTerraformVersion.String()) } + reader, writer := io.Pipe() + defer reader.Close() + defer writer.Close() + go func() { + scanner := bufio.NewScanner(reader) + for scanner.Scan() { + _ = stream.Send(&proto.Provision_Response{ + Type: &proto.Provision_Response_Log{ + Log: &proto.Log{ + Level: proto.LogLevel_INFO, + Output: scanner.Text(), + }, + }, + }) + } + }() + terraform.SetStdout(writer) err = terraform.Init(ctx) if err != nil { - return nil, xerrors.Errorf("initialize terraform: %w", err) + return xerrors.Errorf("initialize terraform: %w", err) } env := map[string]string{} - options := make([]tfexec.ApplyOption, 0) + options := []tfexec.ApplyOption{tfexec.JSON(true)} for _, param := range request.ParameterValues { switch param.DestinationScheme { case proto.ParameterDestination_ENVIRONMENT_VARIABLE: @@ -46,26 +69,73 @@ func (t *terraform) Provision(ctx context.Context, request *proto.Provision_Requ case proto.ParameterDestination_PROVISIONER_VARIABLE: options = append(options, tfexec.Var(fmt.Sprintf("%s=%s", param.Name, param.Value))) default: - return nil, xerrors.Errorf("unsupported parameter type %q for %q", param.DestinationScheme, param.Name) + return xerrors.Errorf("unsupported parameter type %q for %q", param.DestinationScheme, param.Name) } } err = terraform.SetEnv(env) if err != nil { - return nil, xerrors.Errorf("apply environment variables: %w", err) + return xerrors.Errorf("apply environment variables: %w", err) } + reader, writer = io.Pipe() + defer reader.Close() + defer writer.Close() + go func() { + decoder := json.NewDecoder(reader) + for { + var log terraformProvisionLog + err := decoder.Decode(&log) + if err != nil { + return + } + + logLevel, err := convertTerraformLogLevel(log.Level) + if err != nil { + // Not a big deal, but we should handle this at some point! + continue + } + _ = stream.Send(&proto.Provision_Response{ + Type: &proto.Provision_Response_Log{ + Log: &proto.Log{ + Level: logLevel, + Output: log.Message, + }, + }, + }) + + if log.Diagnostic == nil { + continue + } + + // If the diagnostic is provided, let's provide a bit more info! + logLevel, err = convertTerraformLogLevel(log.Diagnostic.Severity) + if err != nil { + continue + } + _ = stream.Send(&proto.Provision_Response{ + Type: &proto.Provision_Response_Log{ + Log: &proto.Log{ + Level: logLevel, + Output: log.Diagnostic.Detail, + }, + }, + }) + } + }() + + terraform.SetStdout(writer) err = terraform.Apply(ctx, options...) if err != nil { - return nil, xerrors.Errorf("apply terraform: %w", err) + return xerrors.Errorf("apply terraform: %w", err) } statefileContent, err := os.ReadFile(statefilePath) if err != nil { - return nil, xerrors.Errorf("read file %q: %w", statefilePath, err) + return xerrors.Errorf("read file %q: %w", statefilePath, err) } state, err := terraform.ShowStateFile(ctx, statefilePath) if err != nil { - return nil, xerrors.Errorf("show state file %q: %w", statefilePath, err) + return xerrors.Errorf("show state file %q: %w", statefilePath, err) } resources := make([]*proto.Resource, 0) if state.Values != nil { @@ -77,8 +147,42 @@ func (t *terraform) Provision(ctx context.Context, request *proto.Provision_Requ } } - return &proto.Provision_Response{ - Resources: resources, - State: statefileContent, - }, nil + return stream.Send(&proto.Provision_Response{ + Type: &proto.Provision_Response_Complete{ + Complete: &proto.Provision_Complete{ + State: statefileContent, + Resources: resources, + }, + }, + }) +} + +type terraformProvisionLog struct { + Level string `json:"@level"` + Message string `json:"@message"` + + Diagnostic *terraformProvisionLogDiagnostic `json:"diagnostic"` +} + +type terraformProvisionLogDiagnostic struct { + Severity string `json:"severity"` + Summary string `json:"summary"` + Detail string `json:"detail"` +} + +func convertTerraformLogLevel(logLevel string) (proto.LogLevel, error) { + switch strings.ToLower(logLevel) { + case "trace": + return proto.LogLevel_TRACE, nil + case "debug": + return proto.LogLevel_DEBUG, nil + case "info": + return proto.LogLevel_INFO, nil + case "warn": + return proto.LogLevel_WARN, nil + case "error": + return proto.LogLevel_ERROR, nil + default: + return proto.LogLevel(0), xerrors.Errorf("invalid log level %q", logLevel) + } } diff --git a/provisioner/terraform/provision_test.go b/provisioner/terraform/provision_test.go index 71b7864bbe..07ac1bde9d 100644 --- a/provisioner/terraform/provision_test.go +++ b/provisioner/terraform/provision_test.go @@ -56,7 +56,11 @@ func TestProvision(t *testing.T) { Value: "example", }}, }, - Response: &proto.Provision_Response{}, + Response: &proto.Provision_Response{ + Type: &proto.Provision_Response_Complete{ + Complete: &proto.Provision_Complete{}, + }, + }, }, { Name: "missing-variable", Files: map[string]string{ @@ -70,10 +74,14 @@ func TestProvision(t *testing.T) { "main.tf": `resource "null_resource" "A" {}`, }, Response: &proto.Provision_Response{ - Resources: []*proto.Resource{{ - Name: "A", - Type: "null_resource", - }}, + Type: &proto.Provision_Response_Complete{ + Complete: &proto.Provision_Complete{ + Resources: []*proto.Resource{{ + Name: "A", + Type: "null_resource", + }}, + }, + }, }, }, { Name: "invalid-sourcecode", @@ -100,20 +108,34 @@ func TestProvision(t *testing.T) { request.State = testCase.Request.State } response, err := api.Provision(ctx, request) - if testCase.Error { - require.Error(t, err) - return + require.NoError(t, err) + for { + msg, err := response.Recv() + if msg != nil && msg.GetLog() != nil { + continue + } + if testCase.Error { + require.Error(t, err) + return + } + require.NoError(t, err) + + if msg.GetComplete() == nil { + continue + } + + require.NoError(t, err) + require.Greater(t, len(msg.GetComplete().State), 0) + + resourcesGot, err := json.Marshal(msg.GetComplete().Resources) + require.NoError(t, err) + + resourcesWant, err := json.Marshal(testCase.Response.GetComplete().Resources) + require.NoError(t, err) + + require.Equal(t, string(resourcesWant), string(resourcesGot)) + break } - require.NoError(t, err) - require.Greater(t, len(response.State), 0) - - resourcesGot, err := json.Marshal(response.Resources) - require.NoError(t, err) - - resourcesWant, err := json.Marshal(testCase.Response.Resources) - require.NoError(t, err) - - require.Equal(t, string(resourcesWant), string(resourcesGot)) }) } } diff --git a/provisionerd/proto/provisionerd.pb.go b/provisionerd/proto/provisionerd.pb.go index 11dfadb372..0f1723b09b 100644 --- a/provisionerd/proto/provisionerd.pb.go +++ b/provisionerd/proto/provisionerd.pb.go @@ -25,19 +25,19 @@ const ( type LogSource int32 const ( - LogSource_PROVISIONER LogSource = 0 - LogSource_DAEMON LogSource = 1 + LogSource_PROVISIONER_DAEMON LogSource = 0 + LogSource_PROVISIONER LogSource = 1 ) // Enum value maps for LogSource. var ( LogSource_name = map[int32]string{ - 0: "PROVISIONER", - 1: "DAEMON", + 0: "PROVISIONER_DAEMON", + 1: "PROVISIONER", } LogSource_value = map[string]int32{ - "PROVISIONER": 0, - "DAEMON": 1, + "PROVISIONER_DAEMON": 0, + "PROVISIONER": 1, } ) @@ -68,65 +68,6 @@ func (LogSource) EnumDescriptor() ([]byte, []int) { return file_provisionerd_proto_provisionerd_proto_rawDescGZIP(), []int{0} } -// LogLevel represents severity of the log. -type LogLevel int32 - -const ( - LogLevel_TRACE LogLevel = 0 - LogLevel_DEBUG LogLevel = 1 - LogLevel_INFO LogLevel = 2 - LogLevel_WARN LogLevel = 3 - LogLevel_ERROR LogLevel = 4 - LogLevel_FATAL LogLevel = 5 -) - -// Enum value maps for LogLevel. -var ( - LogLevel_name = map[int32]string{ - 0: "TRACE", - 1: "DEBUG", - 2: "INFO", - 3: "WARN", - 4: "ERROR", - 5: "FATAL", - } - LogLevel_value = map[string]int32{ - "TRACE": 0, - "DEBUG": 1, - "INFO": 2, - "WARN": 3, - "ERROR": 4, - "FATAL": 5, - } -) - -func (x LogLevel) Enum() *LogLevel { - p := new(LogLevel) - *p = x - return p -} - -func (x LogLevel) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (LogLevel) Descriptor() protoreflect.EnumDescriptor { - return file_provisionerd_proto_provisionerd_proto_enumTypes[1].Descriptor() -} - -func (LogLevel) Type() protoreflect.EnumType { - return &file_provisionerd_proto_provisionerd_proto_enumTypes[1] -} - -func (x LogLevel) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use LogLevel.Descriptor instead. -func (LogLevel) EnumDescriptor() ([]byte, []int) { - return file_provisionerd_proto_provisionerd_proto_rawDescGZIP(), []int{1} -} - // Empty indicates a successful request/response. type Empty struct { state protoimpl.MessageState @@ -453,13 +394,10 @@ type Log struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Source LogSource `protobuf:"varint,1,opt,name=source,proto3,enum=provisionerd.LogSource" json:"source,omitempty"` - Level LogLevel `protobuf:"varint,2,opt,name=level,proto3,enum=provisionerd.LogLevel" json:"level,omitempty"` - CreatedAt int64 `protobuf:"varint,3,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` - // Types that are assignable to Type: - // *Log_WorkspaceProvision_ - // *Log_ProjectImport_ - Type isLog_Type `protobuf_oneof:"type"` + Source LogSource `protobuf:"varint,1,opt,name=source,proto3,enum=provisionerd.LogSource" json:"source,omitempty"` + Level proto.LogLevel `protobuf:"varint,2,opt,name=level,proto3,enum=provisioner.LogLevel" json:"level,omitempty"` + CreatedAt int64 `protobuf:"varint,3,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` + Output string `protobuf:"bytes,4,opt,name=output,proto3" json:"output,omitempty"` } func (x *Log) Reset() { @@ -498,14 +436,14 @@ func (x *Log) GetSource() LogSource { if x != nil { return x.Source } - return LogSource_PROVISIONER + return LogSource_PROVISIONER_DAEMON } -func (x *Log) GetLevel() LogLevel { +func (x *Log) GetLevel() proto.LogLevel { if x != nil { return x.Level } - return LogLevel_TRACE + return proto.LogLevel_TRACE } func (x *Log) GetCreatedAt() int64 { @@ -515,43 +453,13 @@ func (x *Log) GetCreatedAt() int64 { return 0 } -func (m *Log) GetType() isLog_Type { - if m != nil { - return m.Type +func (x *Log) GetOutput() string { + if x != nil { + return x.Output } - return nil + return "" } -func (x *Log) GetWorkspaceProvision() *Log_WorkspaceProvision { - if x, ok := x.GetType().(*Log_WorkspaceProvision_); ok { - return x.WorkspaceProvision - } - return nil -} - -func (x *Log) GetProjectImport() *Log_ProjectImport { - if x, ok := x.GetType().(*Log_ProjectImport_); ok { - return x.ProjectImport - } - return nil -} - -type isLog_Type interface { - isLog_Type() -} - -type Log_WorkspaceProvision_ struct { - WorkspaceProvision *Log_WorkspaceProvision `protobuf:"bytes,4,opt,name=workspace_provision,json=workspaceProvision,proto3,oneof"` -} - -type Log_ProjectImport_ struct { - ProjectImport *Log_ProjectImport `protobuf:"bytes,5,opt,name=project_import,json=projectImport,proto3,oneof"` -} - -func (*Log_WorkspaceProvision_) isLog_Type() {} - -func (*Log_ProjectImport_) isLog_Type() {} - // JobUpdate represents an update to a job. // There may be no log output, but this message // should still be sent periodically as a heartbeat. @@ -560,8 +468,9 @@ type JobUpdate struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - JobId string `protobuf:"bytes,1,opt,name=job_id,json=jobId,proto3" json:"job_id,omitempty"` - Logs []*Log `protobuf:"bytes,2,rep,name=logs,proto3" json:"logs,omitempty"` + JobId string `protobuf:"bytes,1,opt,name=job_id,json=jobId,proto3" json:"job_id,omitempty"` + WorkspaceProvisionLogs []*Log `protobuf:"bytes,2,rep,name=workspace_provision_logs,json=workspaceProvisionLogs,proto3" json:"workspace_provision_logs,omitempty"` + ProjectImportLogs []*Log `protobuf:"bytes,3,rep,name=project_import_logs,json=projectImportLogs,proto3" json:"project_import_logs,omitempty"` } func (x *JobUpdate) Reset() { @@ -603,9 +512,16 @@ func (x *JobUpdate) GetJobId() string { return "" } -func (x *JobUpdate) GetLogs() []*Log { +func (x *JobUpdate) GetWorkspaceProvisionLogs() []*Log { if x != nil { - return x.Logs + return x.WorkspaceProvisionLogs + } + return nil +} + +func (x *JobUpdate) GetProjectImportLogs() []*Log { + if x != nil { + return x.ProjectImportLogs } return nil } @@ -838,116 +754,6 @@ func (x *CompletedJob_ProjectImport) GetParameterSchemas() []*proto.ParameterSch return nil } -type Log_WorkspaceProvision struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - WorkspaceHistoryId string `protobuf:"bytes,1,opt,name=workspace_history_id,json=workspaceHistoryId,proto3" json:"workspace_history_id,omitempty"` - Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` -} - -func (x *Log_WorkspaceProvision) Reset() { - *x = Log_WorkspaceProvision{} - if protoimpl.UnsafeEnabled { - mi := &file_provisionerd_proto_provisionerd_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Log_WorkspaceProvision) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Log_WorkspaceProvision) ProtoMessage() {} - -func (x *Log_WorkspaceProvision) ProtoReflect() protoreflect.Message { - mi := &file_provisionerd_proto_provisionerd_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Log_WorkspaceProvision.ProtoReflect.Descriptor instead. -func (*Log_WorkspaceProvision) Descriptor() ([]byte, []int) { - return file_provisionerd_proto_provisionerd_proto_rawDescGZIP(), []int{4, 0} -} - -func (x *Log_WorkspaceProvision) GetWorkspaceHistoryId() string { - if x != nil { - return x.WorkspaceHistoryId - } - return "" -} - -func (x *Log_WorkspaceProvision) GetText() string { - if x != nil { - return x.Text - } - return "" -} - -type Log_ProjectImport struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ProjectHistoryId string `protobuf:"bytes,1,opt,name=project_history_id,json=projectHistoryId,proto3" json:"project_history_id,omitempty"` - Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"` -} - -func (x *Log_ProjectImport) Reset() { - *x = Log_ProjectImport{} - if protoimpl.UnsafeEnabled { - mi := &file_provisionerd_proto_provisionerd_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Log_ProjectImport) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Log_ProjectImport) ProtoMessage() {} - -func (x *Log_ProjectImport) ProtoReflect() protoreflect.Message { - mi := &file_provisionerd_proto_provisionerd_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Log_ProjectImport.ProtoReflect.Descriptor instead. -func (*Log_ProjectImport) Descriptor() ([]byte, []int) { - return file_provisionerd_proto_provisionerd_proto_rawDescGZIP(), []int{4, 1} -} - -func (x *Log_ProjectImport) GetProjectHistoryId() string { - if x != nil { - return x.ProjectHistoryId - } - return "" -} - -func (x *Log_ProjectImport) GetText() string { - if x != nil { - return x.Text - } - return "" -} - var File_provisionerd_proto_provisionerd_proto protoreflect.FileDescriptor var file_provisionerd_proto_provisionerd_proto_rawDesc = []byte{ @@ -1035,69 +841,52 @@ var file_provisionerd_proto_provisionerd_proto_rawDesc = []byte{ 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x10, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x53, 0x63, 0x68, 0x65, 0x6d, - 0x61, 0x73, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xdd, 0x03, 0x0a, 0x03, 0x4c, + 0x61, 0x73, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x9a, 0x01, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x2f, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x4c, 0x6f, 0x67, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x06, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, - 0x64, 0x2e, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, - 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, - 0x12, 0x57, 0x0a, 0x13, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x70, 0x72, - 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, - 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x4c, 0x6f, 0x67, - 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, - 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x12, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x48, 0x0a, 0x0e, 0x70, 0x72, 0x6f, - 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, - 0x2e, 0x4c, 0x6f, 0x67, 0x2e, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x6d, 0x70, 0x6f, - 0x72, 0x74, 0x48, 0x00, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x6d, 0x70, - 0x6f, 0x72, 0x74, 0x1a, 0x5a, 0x0a, 0x12, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x14, 0x77, 0x6f, 0x72, - 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, - 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x1a, - 0x51, 0x0a, 0x0d, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, - 0x12, 0x2c, 0x0a, 0x12, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x68, 0x69, 0x73, 0x74, - 0x6f, 0x72, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x70, 0x72, - 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x49, 0x64, 0x12, 0x12, - 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, - 0x78, 0x74, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x49, 0x0a, 0x09, 0x4a, 0x6f, - 0x62, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x15, 0x0a, 0x06, 0x6a, 0x6f, 0x62, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6a, 0x6f, 0x62, 0x49, 0x64, 0x12, 0x25, - 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x4c, 0x6f, 0x67, 0x52, - 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x2a, 0x28, 0x0a, 0x09, 0x4c, 0x6f, 0x67, 0x53, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x52, 0x4f, 0x56, 0x49, 0x53, 0x49, 0x4f, 0x4e, 0x45, - 0x52, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x41, 0x45, 0x4d, 0x4f, 0x4e, 0x10, 0x01, 0x2a, - 0x4a, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x09, 0x0a, 0x05, 0x54, - 0x52, 0x41, 0x43, 0x45, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x44, 0x45, 0x42, 0x55, 0x47, 0x10, - 0x01, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x57, - 0x41, 0x52, 0x4e, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x04, - 0x12, 0x09, 0x0a, 0x05, 0x46, 0x41, 0x54, 0x41, 0x4c, 0x10, 0x05, 0x32, 0x8c, 0x02, 0x0a, 0x11, - 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x44, 0x61, 0x65, 0x6d, 0x6f, - 0x6e, 0x12, 0x3c, 0x0a, 0x0a, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x4a, 0x6f, 0x62, 0x12, - 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, - 0x65, 0x72, 0x64, 0x2e, 0x41, 0x63, 0x71, 0x75, 0x69, 0x72, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x12, - 0x3b, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4a, 0x6f, 0x62, 0x12, 0x17, 0x2e, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x4a, 0x6f, 0x62, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, - 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x28, 0x01, 0x12, 0x3c, 0x0a, 0x09, - 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x4a, 0x6f, 0x62, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, - 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x6c, - 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, - 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x12, 0x3e, 0x0a, 0x0b, 0x43, 0x6f, - 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x4a, 0x6f, 0x62, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, - 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, - 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, - 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x2b, 0x5a, 0x29, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x2f, 0x63, - 0x6f, 0x64, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, - 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x63, 0x65, 0x12, 0x2b, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, + 0x2e, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, + 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, + 0x16, 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x22, 0xb2, 0x01, 0x0a, 0x09, 0x4a, 0x6f, 0x62, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x15, 0x0a, 0x06, 0x6a, 0x6f, 0x62, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6a, 0x6f, 0x62, 0x49, 0x64, 0x12, 0x4b, 0x0a, 0x18, + 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x5f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, + 0x69, 0x6f, 0x6e, 0x5f, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, + 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x4c, 0x6f, + 0x67, 0x52, 0x16, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x41, 0x0a, 0x13, 0x70, 0x72, 0x6f, + 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x73, + 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x11, 0x70, 0x72, 0x6f, 0x6a, 0x65, + 0x63, 0x74, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x6f, 0x67, 0x73, 0x2a, 0x34, 0x0a, 0x09, + 0x4c, 0x6f, 0x67, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x12, 0x50, 0x52, 0x4f, + 0x56, 0x49, 0x53, 0x49, 0x4f, 0x4e, 0x45, 0x52, 0x5f, 0x44, 0x41, 0x45, 0x4d, 0x4f, 0x4e, 0x10, + 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x52, 0x4f, 0x56, 0x49, 0x53, 0x49, 0x4f, 0x4e, 0x45, 0x52, + 0x10, 0x01, 0x32, 0x8c, 0x02, 0x0a, 0x11, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x65, 0x72, 0x44, 0x61, 0x65, 0x6d, 0x6f, 0x6e, 0x12, 0x3c, 0x0a, 0x0a, 0x41, 0x63, 0x71, 0x75, + 0x69, 0x72, 0x65, 0x4a, 0x6f, 0x62, 0x12, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x19, 0x2e, 0x70, 0x72, + 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x41, 0x63, 0x71, 0x75, 0x69, + 0x72, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x12, 0x3b, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x4a, 0x6f, 0x62, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, + 0x72, 0x64, 0x2e, 0x4a, 0x6f, 0x62, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x1a, 0x13, 0x2e, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x28, 0x01, 0x12, 0x3c, 0x0a, 0x09, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x4a, 0x6f, 0x62, + 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, + 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x6c, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x1a, 0x13, 0x2e, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x12, 0x3e, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x4a, 0x6f, 0x62, + 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, + 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x4a, 0x6f, 0x62, 0x1a, 0x13, 0x2e, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2e, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x42, 0x2b, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x63, 0x6f, 0x64, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1112,53 +901,50 @@ func file_provisionerd_proto_provisionerd_proto_rawDescGZIP() []byte { return file_provisionerd_proto_provisionerd_proto_rawDescData } -var file_provisionerd_proto_provisionerd_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_provisionerd_proto_provisionerd_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_provisionerd_proto_provisionerd_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_provisionerd_proto_provisionerd_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_provisionerd_proto_provisionerd_proto_goTypes = []interface{}{ (LogSource)(0), // 0: provisionerd.LogSource - (LogLevel)(0), // 1: provisionerd.LogLevel - (*Empty)(nil), // 2: provisionerd.Empty - (*AcquiredJob)(nil), // 3: provisionerd.AcquiredJob - (*CancelledJob)(nil), // 4: provisionerd.CancelledJob - (*CompletedJob)(nil), // 5: provisionerd.CompletedJob - (*Log)(nil), // 6: provisionerd.Log - (*JobUpdate)(nil), // 7: provisionerd.JobUpdate - (*AcquiredJob_WorkspaceProvision)(nil), // 8: provisionerd.AcquiredJob.WorkspaceProvision - (*AcquiredJob_ProjectImport)(nil), // 9: provisionerd.AcquiredJob.ProjectImport - (*CompletedJob_WorkspaceProvision)(nil), // 10: provisionerd.CompletedJob.WorkspaceProvision - (*CompletedJob_ProjectImport)(nil), // 11: provisionerd.CompletedJob.ProjectImport - (*Log_WorkspaceProvision)(nil), // 12: provisionerd.Log.WorkspaceProvision - (*Log_ProjectImport)(nil), // 13: provisionerd.Log.ProjectImport - (*proto.ParameterValue)(nil), // 14: provisioner.ParameterValue - (*proto.Resource)(nil), // 15: provisioner.Resource - (*proto.ParameterSchema)(nil), // 16: provisioner.ParameterSchema + (*Empty)(nil), // 1: provisionerd.Empty + (*AcquiredJob)(nil), // 2: provisionerd.AcquiredJob + (*CancelledJob)(nil), // 3: provisionerd.CancelledJob + (*CompletedJob)(nil), // 4: provisionerd.CompletedJob + (*Log)(nil), // 5: provisionerd.Log + (*JobUpdate)(nil), // 6: provisionerd.JobUpdate + (*AcquiredJob_WorkspaceProvision)(nil), // 7: provisionerd.AcquiredJob.WorkspaceProvision + (*AcquiredJob_ProjectImport)(nil), // 8: provisionerd.AcquiredJob.ProjectImport + (*CompletedJob_WorkspaceProvision)(nil), // 9: provisionerd.CompletedJob.WorkspaceProvision + (*CompletedJob_ProjectImport)(nil), // 10: provisionerd.CompletedJob.ProjectImport + (proto.LogLevel)(0), // 11: provisioner.LogLevel + (*proto.ParameterValue)(nil), // 12: provisioner.ParameterValue + (*proto.Resource)(nil), // 13: provisioner.Resource + (*proto.ParameterSchema)(nil), // 14: provisioner.ParameterSchema } var file_provisionerd_proto_provisionerd_proto_depIdxs = []int32{ - 8, // 0: provisionerd.AcquiredJob.workspace_provision:type_name -> provisionerd.AcquiredJob.WorkspaceProvision - 9, // 1: provisionerd.AcquiredJob.project_import:type_name -> provisionerd.AcquiredJob.ProjectImport - 10, // 2: provisionerd.CompletedJob.workspace_provision:type_name -> provisionerd.CompletedJob.WorkspaceProvision - 11, // 3: provisionerd.CompletedJob.project_import:type_name -> provisionerd.CompletedJob.ProjectImport + 7, // 0: provisionerd.AcquiredJob.workspace_provision:type_name -> provisionerd.AcquiredJob.WorkspaceProvision + 8, // 1: provisionerd.AcquiredJob.project_import:type_name -> provisionerd.AcquiredJob.ProjectImport + 9, // 2: provisionerd.CompletedJob.workspace_provision:type_name -> provisionerd.CompletedJob.WorkspaceProvision + 10, // 3: provisionerd.CompletedJob.project_import:type_name -> provisionerd.CompletedJob.ProjectImport 0, // 4: provisionerd.Log.source:type_name -> provisionerd.LogSource - 1, // 5: provisionerd.Log.level:type_name -> provisionerd.LogLevel - 12, // 6: provisionerd.Log.workspace_provision:type_name -> provisionerd.Log.WorkspaceProvision - 13, // 7: provisionerd.Log.project_import:type_name -> provisionerd.Log.ProjectImport - 6, // 8: provisionerd.JobUpdate.logs:type_name -> provisionerd.Log - 14, // 9: provisionerd.AcquiredJob.WorkspaceProvision.parameter_values:type_name -> provisioner.ParameterValue - 15, // 10: provisionerd.CompletedJob.WorkspaceProvision.resources:type_name -> provisioner.Resource - 16, // 11: provisionerd.CompletedJob.ProjectImport.parameter_schemas:type_name -> provisioner.ParameterSchema - 2, // 12: provisionerd.ProvisionerDaemon.AcquireJob:input_type -> provisionerd.Empty - 7, // 13: provisionerd.ProvisionerDaemon.UpdateJob:input_type -> provisionerd.JobUpdate - 4, // 14: provisionerd.ProvisionerDaemon.CancelJob:input_type -> provisionerd.CancelledJob - 5, // 15: provisionerd.ProvisionerDaemon.CompleteJob:input_type -> provisionerd.CompletedJob - 3, // 16: provisionerd.ProvisionerDaemon.AcquireJob:output_type -> provisionerd.AcquiredJob - 2, // 17: provisionerd.ProvisionerDaemon.UpdateJob:output_type -> provisionerd.Empty - 2, // 18: provisionerd.ProvisionerDaemon.CancelJob:output_type -> provisionerd.Empty - 2, // 19: provisionerd.ProvisionerDaemon.CompleteJob:output_type -> provisionerd.Empty - 16, // [16:20] is the sub-list for method output_type - 12, // [12:16] is the sub-list for method input_type - 12, // [12:12] is the sub-list for extension type_name - 12, // [12:12] is the sub-list for extension extendee - 0, // [0:12] is the sub-list for field type_name + 11, // 5: provisionerd.Log.level:type_name -> provisioner.LogLevel + 5, // 6: provisionerd.JobUpdate.workspace_provision_logs:type_name -> provisionerd.Log + 5, // 7: provisionerd.JobUpdate.project_import_logs:type_name -> provisionerd.Log + 12, // 8: provisionerd.AcquiredJob.WorkspaceProvision.parameter_values:type_name -> provisioner.ParameterValue + 13, // 9: provisionerd.CompletedJob.WorkspaceProvision.resources:type_name -> provisioner.Resource + 14, // 10: provisionerd.CompletedJob.ProjectImport.parameter_schemas:type_name -> provisioner.ParameterSchema + 1, // 11: provisionerd.ProvisionerDaemon.AcquireJob:input_type -> provisionerd.Empty + 6, // 12: provisionerd.ProvisionerDaemon.UpdateJob:input_type -> provisionerd.JobUpdate + 3, // 13: provisionerd.ProvisionerDaemon.CancelJob:input_type -> provisionerd.CancelledJob + 4, // 14: provisionerd.ProvisionerDaemon.CompleteJob:input_type -> provisionerd.CompletedJob + 2, // 15: provisionerd.ProvisionerDaemon.AcquireJob:output_type -> provisionerd.AcquiredJob + 1, // 16: provisionerd.ProvisionerDaemon.UpdateJob:output_type -> provisionerd.Empty + 1, // 17: provisionerd.ProvisionerDaemon.CancelJob:output_type -> provisionerd.Empty + 1, // 18: provisionerd.ProvisionerDaemon.CompleteJob:output_type -> provisionerd.Empty + 15, // [15:19] is the sub-list for method output_type + 11, // [11:15] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_provisionerd_proto_provisionerd_proto_init() } @@ -1287,30 +1073,6 @@ func file_provisionerd_proto_provisionerd_proto_init() { return nil } } - file_provisionerd_proto_provisionerd_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Log_WorkspaceProvision); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_provisionerd_proto_provisionerd_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Log_ProjectImport); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } } file_provisionerd_proto_provisionerd_proto_msgTypes[1].OneofWrappers = []interface{}{ (*AcquiredJob_WorkspaceProvision_)(nil), @@ -1320,17 +1082,13 @@ func file_provisionerd_proto_provisionerd_proto_init() { (*CompletedJob_WorkspaceProvision_)(nil), (*CompletedJob_ProjectImport_)(nil), } - file_provisionerd_proto_provisionerd_proto_msgTypes[4].OneofWrappers = []interface{}{ - (*Log_WorkspaceProvision_)(nil), - (*Log_ProjectImport_)(nil), - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_provisionerd_proto_provisionerd_proto_rawDesc, - NumEnums: 2, - NumMessages: 12, + NumEnums: 1, + NumMessages: 10, NumExtensions: 0, NumServices: 1, }, diff --git a/provisionerd/proto/provisionerd.proto b/provisionerd/proto/provisionerd.proto index aa55358ae0..836d2d5f49 100644 --- a/provisionerd/proto/provisionerd.proto +++ b/provisionerd/proto/provisionerd.proto @@ -57,37 +57,16 @@ message CompletedJob { // LogSource represents the sender of the log. enum LogSource { - PROVISIONER = 0; - DAEMON = 1; -} - -// LogLevel represents severity of the log. -enum LogLevel { - TRACE = 0; - DEBUG = 1; - INFO = 2; - WARN = 3; - ERROR = 4; - FATAL = 5; + PROVISIONER_DAEMON = 0; + PROVISIONER = 1; } // Log represents output from a job. message Log { - message WorkspaceProvision { - string workspace_history_id = 1; - string text = 2; - } - message ProjectImport { - string project_history_id = 1; - string text = 2; - } LogSource source = 1; - LogLevel level = 2; + provisioner.LogLevel level = 2; int64 created_at = 3; - oneof type { - WorkspaceProvision workspace_provision = 4; - ProjectImport project_import = 5; - } + string output = 4; } // JobUpdate represents an update to a job. @@ -95,7 +74,8 @@ message Log { // should still be sent periodically as a heartbeat. message JobUpdate { string job_id = 1; - repeated Log logs = 2; + repeated Log workspace_provision_logs = 2; + repeated Log project_import_logs = 3; } service ProvisionerDaemon { diff --git a/provisionersdk/proto/provisioner.pb.go b/provisionersdk/proto/provisioner.pb.go index 4801450d25..e3b16c832a 100644 --- a/provisionersdk/proto/provisioner.pb.go +++ b/provisionersdk/proto/provisioner.pb.go @@ -20,6 +20,62 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// LogLevel represents severity of the log. +type LogLevel int32 + +const ( + LogLevel_TRACE LogLevel = 0 + LogLevel_DEBUG LogLevel = 1 + LogLevel_INFO LogLevel = 2 + LogLevel_WARN LogLevel = 3 + LogLevel_ERROR LogLevel = 4 +) + +// Enum value maps for LogLevel. +var ( + LogLevel_name = map[int32]string{ + 0: "TRACE", + 1: "DEBUG", + 2: "INFO", + 3: "WARN", + 4: "ERROR", + } + LogLevel_value = map[string]int32{ + "TRACE": 0, + "DEBUG": 1, + "INFO": 2, + "WARN": 3, + "ERROR": 4, + } +) + +func (x LogLevel) Enum() *LogLevel { + p := new(LogLevel) + *p = x + return p +} + +func (x LogLevel) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (LogLevel) Descriptor() protoreflect.EnumDescriptor { + return file_provisionersdk_proto_provisioner_proto_enumTypes[0].Descriptor() +} + +func (LogLevel) Type() protoreflect.EnumType { + return &file_provisionersdk_proto_provisioner_proto_enumTypes[0] +} + +func (x LogLevel) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use LogLevel.Descriptor instead. +func (LogLevel) EnumDescriptor() ([]byte, []int) { + return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{0} +} + type ParameterSource_Scheme int32 const ( @@ -47,11 +103,11 @@ func (x ParameterSource_Scheme) String() string { } func (ParameterSource_Scheme) Descriptor() protoreflect.EnumDescriptor { - return file_provisionersdk_proto_provisioner_proto_enumTypes[0].Descriptor() + return file_provisionersdk_proto_provisioner_proto_enumTypes[1].Descriptor() } func (ParameterSource_Scheme) Type() protoreflect.EnumType { - return &file_provisionersdk_proto_provisioner_proto_enumTypes[0] + return &file_provisionersdk_proto_provisioner_proto_enumTypes[1] } func (x ParameterSource_Scheme) Number() protoreflect.EnumNumber { @@ -93,11 +149,11 @@ func (x ParameterDestination_Scheme) String() string { } func (ParameterDestination_Scheme) Descriptor() protoreflect.EnumDescriptor { - return file_provisionersdk_proto_provisioner_proto_enumTypes[1].Descriptor() + return file_provisionersdk_proto_provisioner_proto_enumTypes[2].Descriptor() } func (ParameterDestination_Scheme) Type() protoreflect.EnumType { - return &file_provisionersdk_proto_provisioner_proto_enumTypes[1] + return &file_provisionersdk_proto_provisioner_proto_enumTypes[2] } func (x ParameterDestination_Scheme) Number() protoreflect.EnumNumber { @@ -136,11 +192,11 @@ func (x ParameterSchema_TypeSystem) String() string { } func (ParameterSchema_TypeSystem) Descriptor() protoreflect.EnumDescriptor { - return file_provisionersdk_proto_provisioner_proto_enumTypes[2].Descriptor() + return file_provisionersdk_proto_provisioner_proto_enumTypes[3].Descriptor() } func (ParameterSchema_TypeSystem) Type() protoreflect.EnumType { - return &file_provisionersdk_proto_provisioner_proto_enumTypes[2] + return &file_provisionersdk_proto_provisioner_proto_enumTypes[3] } func (x ParameterSchema_TypeSystem) Number() protoreflect.EnumNumber { @@ -456,6 +512,62 @@ func (x *ParameterSchema) GetValidationCondition() string { return "" } +// Log represents output from a request. +type Log struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Level LogLevel `protobuf:"varint,1,opt,name=level,proto3,enum=provisioner.LogLevel" json:"level,omitempty"` + Output string `protobuf:"bytes,2,opt,name=output,proto3" json:"output,omitempty"` +} + +func (x *Log) Reset() { + *x = Log{} + if protoimpl.UnsafeEnabled { + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Log) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Log) ProtoMessage() {} + +func (x *Log) ProtoReflect() protoreflect.Message { + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Log.ProtoReflect.Descriptor instead. +func (*Log) Descriptor() ([]byte, []int) { + return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{4} +} + +func (x *Log) GetLevel() LogLevel { + if x != nil { + return x.Level + } + return LogLevel_TRACE +} + +func (x *Log) GetOutput() string { + if x != nil { + return x.Output + } + return "" +} + // Parse consumes source-code from a directory to produce inputs. type Parse struct { state protoimpl.MessageState @@ -466,7 +578,7 @@ type Parse struct { func (x *Parse) Reset() { *x = Parse{} if protoimpl.UnsafeEnabled { - mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[4] + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -479,7 +591,7 @@ func (x *Parse) String() string { func (*Parse) ProtoMessage() {} func (x *Parse) ProtoReflect() protoreflect.Message { - mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[4] + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -492,7 +604,7 @@ func (x *Parse) ProtoReflect() protoreflect.Message { // Deprecated: Use Parse.ProtoReflect.Descriptor instead. func (*Parse) Descriptor() ([]byte, []int) { - return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{4} + return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{5} } // Resource is a provisioned unit. @@ -508,7 +620,7 @@ type Resource struct { func (x *Resource) Reset() { *x = Resource{} if protoimpl.UnsafeEnabled { - mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[5] + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -521,7 +633,7 @@ func (x *Resource) String() string { func (*Resource) ProtoMessage() {} func (x *Resource) ProtoReflect() protoreflect.Message { - mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[5] + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -534,7 +646,7 @@ func (x *Resource) ProtoReflect() protoreflect.Message { // Deprecated: Use Resource.ProtoReflect.Descriptor instead. func (*Resource) Descriptor() ([]byte, []int) { - return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{5} + return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{6} } func (x *Resource) GetName() string { @@ -561,7 +673,7 @@ type Provision struct { func (x *Provision) Reset() { *x = Provision{} if protoimpl.UnsafeEnabled { - mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[6] + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -574,7 +686,7 @@ func (x *Provision) String() string { func (*Provision) ProtoMessage() {} func (x *Provision) ProtoReflect() protoreflect.Message { - mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[6] + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -587,7 +699,7 @@ func (x *Provision) ProtoReflect() protoreflect.Message { // Deprecated: Use Provision.ProtoReflect.Descriptor instead. func (*Provision) Descriptor() ([]byte, []int) { - return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{6} + return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{7} } type Parse_Request struct { @@ -601,7 +713,7 @@ type Parse_Request struct { func (x *Parse_Request) Reset() { *x = Parse_Request{} if protoimpl.UnsafeEnabled { - mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[7] + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -614,7 +726,7 @@ func (x *Parse_Request) String() string { func (*Parse_Request) ProtoMessage() {} func (x *Parse_Request) ProtoReflect() protoreflect.Message { - mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[7] + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[8] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -627,7 +739,7 @@ func (x *Parse_Request) ProtoReflect() protoreflect.Message { // Deprecated: Use Parse_Request.ProtoReflect.Descriptor instead. func (*Parse_Request) Descriptor() ([]byte, []int) { - return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{4, 0} + return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{5, 0} } func (x *Parse_Request) GetDirectory() string { @@ -637,18 +749,68 @@ func (x *Parse_Request) GetDirectory() string { return "" } +type Parse_Complete struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ParameterSchemas []*ParameterSchema `protobuf:"bytes,2,rep,name=parameter_schemas,json=parameterSchemas,proto3" json:"parameter_schemas,omitempty"` +} + +func (x *Parse_Complete) Reset() { + *x = Parse_Complete{} + if protoimpl.UnsafeEnabled { + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Parse_Complete) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Parse_Complete) ProtoMessage() {} + +func (x *Parse_Complete) ProtoReflect() protoreflect.Message { + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Parse_Complete.ProtoReflect.Descriptor instead. +func (*Parse_Complete) Descriptor() ([]byte, []int) { + return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{5, 1} +} + +func (x *Parse_Complete) GetParameterSchemas() []*ParameterSchema { + if x != nil { + return x.ParameterSchemas + } + return nil +} + type Parse_Response struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ParameterSchemas []*ParameterSchema `protobuf:"bytes,1,rep,name=parameter_schemas,json=parameterSchemas,proto3" json:"parameter_schemas,omitempty"` + // Types that are assignable to Type: + // *Parse_Response_Log + // *Parse_Response_Complete + Type isParse_Response_Type `protobuf_oneof:"type"` } func (x *Parse_Response) Reset() { *x = Parse_Response{} if protoimpl.UnsafeEnabled { - mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[8] + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -661,7 +823,7 @@ func (x *Parse_Response) String() string { func (*Parse_Response) ProtoMessage() {} func (x *Parse_Response) ProtoReflect() protoreflect.Message { - mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[8] + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -674,16 +836,46 @@ func (x *Parse_Response) ProtoReflect() protoreflect.Message { // Deprecated: Use Parse_Response.ProtoReflect.Descriptor instead. func (*Parse_Response) Descriptor() ([]byte, []int) { - return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{4, 1} + return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{5, 2} } -func (x *Parse_Response) GetParameterSchemas() []*ParameterSchema { - if x != nil { - return x.ParameterSchemas +func (m *Parse_Response) GetType() isParse_Response_Type { + if m != nil { + return m.Type } return nil } +func (x *Parse_Response) GetLog() *Log { + if x, ok := x.GetType().(*Parse_Response_Log); ok { + return x.Log + } + return nil +} + +func (x *Parse_Response) GetComplete() *Parse_Complete { + if x, ok := x.GetType().(*Parse_Response_Complete); ok { + return x.Complete + } + return nil +} + +type isParse_Response_Type interface { + isParse_Response_Type() +} + +type Parse_Response_Log struct { + Log *Log `protobuf:"bytes,1,opt,name=log,proto3,oneof"` +} + +type Parse_Response_Complete struct { + Complete *Parse_Complete `protobuf:"bytes,2,opt,name=complete,proto3,oneof"` +} + +func (*Parse_Response_Log) isParse_Response_Type() {} + +func (*Parse_Response_Complete) isParse_Response_Type() {} + type Provision_Request struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -697,7 +889,7 @@ type Provision_Request struct { func (x *Provision_Request) Reset() { *x = Provision_Request{} if protoimpl.UnsafeEnabled { - mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[9] + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -710,7 +902,7 @@ func (x *Provision_Request) String() string { func (*Provision_Request) ProtoMessage() {} func (x *Provision_Request) ProtoReflect() protoreflect.Message { - mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[9] + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -723,7 +915,7 @@ func (x *Provision_Request) ProtoReflect() protoreflect.Message { // Deprecated: Use Provision_Request.ProtoReflect.Descriptor instead. func (*Provision_Request) Descriptor() ([]byte, []int) { - return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{6, 0} + return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{7, 0} } func (x *Provision_Request) GetDirectory() string { @@ -747,7 +939,7 @@ func (x *Provision_Request) GetState() []byte { return nil } -type Provision_Response struct { +type Provision_Complete struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -756,10 +948,67 @@ type Provision_Response struct { Resources []*Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` } +func (x *Provision_Complete) Reset() { + *x = Provision_Complete{} + if protoimpl.UnsafeEnabled { + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Provision_Complete) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Provision_Complete) ProtoMessage() {} + +func (x *Provision_Complete) ProtoReflect() protoreflect.Message { + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Provision_Complete.ProtoReflect.Descriptor instead. +func (*Provision_Complete) Descriptor() ([]byte, []int) { + return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{7, 1} +} + +func (x *Provision_Complete) GetState() []byte { + if x != nil { + return x.State + } + return nil +} + +func (x *Provision_Complete) GetResources() []*Resource { + if x != nil { + return x.Resources + } + return nil +} + +type Provision_Response struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Types that are assignable to Type: + // *Provision_Response_Log + // *Provision_Response_Complete + Type isProvision_Response_Type `protobuf_oneof:"type"` +} + func (x *Provision_Response) Reset() { *x = Provision_Response{} if protoimpl.UnsafeEnabled { - mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[10] + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -772,7 +1021,7 @@ func (x *Provision_Response) String() string { func (*Provision_Response) ProtoMessage() {} func (x *Provision_Response) ProtoReflect() protoreflect.Message { - mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[10] + mi := &file_provisionersdk_proto_provisioner_proto_msgTypes[13] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -785,23 +1034,46 @@ func (x *Provision_Response) ProtoReflect() protoreflect.Message { // Deprecated: Use Provision_Response.ProtoReflect.Descriptor instead. func (*Provision_Response) Descriptor() ([]byte, []int) { - return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{6, 1} + return file_provisionersdk_proto_provisioner_proto_rawDescGZIP(), []int{7, 2} } -func (x *Provision_Response) GetState() []byte { - if x != nil { - return x.State +func (m *Provision_Response) GetType() isProvision_Response_Type { + if m != nil { + return m.Type } return nil } -func (x *Provision_Response) GetResources() []*Resource { - if x != nil { - return x.Resources +func (x *Provision_Response) GetLog() *Log { + if x, ok := x.GetType().(*Provision_Response_Log); ok { + return x.Log } return nil } +func (x *Provision_Response) GetComplete() *Provision_Complete { + if x, ok := x.GetType().(*Provision_Response_Complete); ok { + return x.Complete + } + return nil +} + +type isProvision_Response_Type interface { + isProvision_Response_Type() +} + +type Provision_Response_Log struct { + Log *Log `protobuf:"bytes,1,opt,name=log,proto3,oneof"` +} + +type Provision_Response_Complete struct { + Complete *Provision_Complete `protobuf:"bytes,2,opt,name=complete,proto3,oneof"` +} + +func (*Provision_Response_Log) isProvision_Response_Type() {} + +func (*Provision_Response_Complete) isProvision_Response_Type() {} + var File_provisionersdk_proto_provisioner_proto protoreflect.FileDescriptor var file_provisionersdk_proto_provisioner_proto_rawDesc = []byte{ @@ -876,47 +1148,71 @@ var file_provisionersdk_proto_provisioner_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x15, 0x0a, 0x0a, 0x54, 0x79, 0x70, 0x65, 0x53, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x12, 0x07, 0x0a, 0x03, 0x48, 0x43, 0x4c, 0x10, 0x00, 0x22, 0x87, 0x01, 0x0a, 0x05, 0x50, - 0x61, 0x72, 0x73, 0x65, 0x1a, 0x27, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x1c, 0x0a, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x1a, 0x55, 0x0a, - 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x11, 0x70, 0x61, 0x72, - 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, - 0x65, 0x72, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x53, 0x63, 0x68, 0x65, - 0x6d, 0x61, 0x52, 0x10, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x53, 0x63, 0x68, - 0x65, 0x6d, 0x61, 0x73, 0x22, 0x32, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xea, 0x01, 0x0a, 0x09, 0x50, 0x72, 0x6f, - 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x85, 0x01, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, - 0x12, 0x46, 0x0a, 0x10, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x5f, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x72, 0x6f, - 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, - 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, - 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x1a, 0x55, - 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, - 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, - 0x12, 0x33, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, - 0x72, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x73, 0x32, 0x9d, 0x01, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, - 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x12, 0x40, 0x0a, 0x05, 0x50, 0x61, 0x72, 0x73, 0x65, 0x12, 0x1a, - 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x61, 0x72, - 0x73, 0x65, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x72, 0x6f, - 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x2e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4c, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x76, 0x69, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, - 0x65, 0x72, 0x2e, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, - 0x65, 0x72, 0x2e, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x2f, - 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x73, 0x64, 0x6b, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6d, 0x12, 0x07, 0x0a, 0x03, 0x48, 0x43, 0x4c, 0x10, 0x00, 0x22, 0x4a, 0x0a, 0x03, 0x4c, 0x6f, + 0x67, 0x12, 0x2b, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x4c, + 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x16, + 0x0a, 0x06, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x22, 0xfc, 0x01, 0x0a, 0x05, 0x50, 0x61, 0x72, 0x73, 0x65, + 0x1a, 0x27, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x64, + 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x1a, 0x55, 0x0a, 0x08, 0x43, 0x6f, 0x6d, + 0x70, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x49, 0x0a, 0x11, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, + 0x65, 0x72, 0x5f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x50, + 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x52, 0x10, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, + 0x1a, 0x73, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x03, + 0x6c, 0x6f, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x48, 0x00, 0x52, 0x03, 0x6c, + 0x6f, 0x67, 0x12, 0x39, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x65, 0x72, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, + 0x65, 0x48, 0x00, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x06, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x32, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xe3, 0x02, 0x0a, 0x09, 0x50, 0x72, + 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x85, 0x01, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, + 0x79, 0x12, 0x46, 0x0a, 0x10, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, 0x74, 0x65, 0x72, 0x5f, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x72, + 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x65, + 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x65, + 0x74, 0x65, 0x72, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, + 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 0x1a, + 0x55, 0x0a, 0x08, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, + 0x65, 0x12, 0x33, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, + 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x1a, 0x77, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x24, 0x0a, 0x03, 0x6c, 0x6f, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x4c, 0x6f, + 0x67, 0x48, 0x00, 0x52, 0x03, 0x6c, 0x6f, 0x67, 0x12, 0x3d, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x70, + 0x6c, 0x65, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x70, 0x72, 0x6f, + 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x48, 0x00, 0x52, 0x08, 0x63, + 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x42, 0x06, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x2a, + 0x3f, 0x0a, 0x08, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x09, 0x0a, 0x05, 0x54, + 0x52, 0x41, 0x43, 0x45, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x44, 0x45, 0x42, 0x55, 0x47, 0x10, + 0x01, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x57, + 0x41, 0x52, 0x4e, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x04, + 0x32, 0xa1, 0x01, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, + 0x12, 0x42, 0x0a, 0x05, 0x50, 0x61, 0x72, 0x73, 0x65, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x76, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x2e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x65, 0x72, 0x2e, 0x50, 0x61, 0x72, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x30, 0x01, 0x12, 0x4e, 0x0a, 0x09, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, + 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x2e, + 0x50, 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x30, 0x01, 0x42, 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x2f, 0x70, + 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x72, 0x73, 0x64, 0x6b, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -931,43 +1227,52 @@ func file_provisionersdk_proto_provisioner_proto_rawDescGZIP() []byte { return file_provisionersdk_proto_provisioner_proto_rawDescData } -var file_provisionersdk_proto_provisioner_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_provisionersdk_proto_provisioner_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_provisionersdk_proto_provisioner_proto_enumTypes = make([]protoimpl.EnumInfo, 4) +var file_provisionersdk_proto_provisioner_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_provisionersdk_proto_provisioner_proto_goTypes = []interface{}{ - (ParameterSource_Scheme)(0), // 0: provisioner.ParameterSource.Scheme - (ParameterDestination_Scheme)(0), // 1: provisioner.ParameterDestination.Scheme - (ParameterSchema_TypeSystem)(0), // 2: provisioner.ParameterSchema.TypeSystem - (*ParameterSource)(nil), // 3: provisioner.ParameterSource - (*ParameterDestination)(nil), // 4: provisioner.ParameterDestination - (*ParameterValue)(nil), // 5: provisioner.ParameterValue - (*ParameterSchema)(nil), // 6: provisioner.ParameterSchema - (*Parse)(nil), // 7: provisioner.Parse - (*Resource)(nil), // 8: provisioner.Resource - (*Provision)(nil), // 9: provisioner.Provision - (*Parse_Request)(nil), // 10: provisioner.Parse.Request - (*Parse_Response)(nil), // 11: provisioner.Parse.Response - (*Provision_Request)(nil), // 12: provisioner.Provision.Request - (*Provision_Response)(nil), // 13: provisioner.Provision.Response + (LogLevel)(0), // 0: provisioner.LogLevel + (ParameterSource_Scheme)(0), // 1: provisioner.ParameterSource.Scheme + (ParameterDestination_Scheme)(0), // 2: provisioner.ParameterDestination.Scheme + (ParameterSchema_TypeSystem)(0), // 3: provisioner.ParameterSchema.TypeSystem + (*ParameterSource)(nil), // 4: provisioner.ParameterSource + (*ParameterDestination)(nil), // 5: provisioner.ParameterDestination + (*ParameterValue)(nil), // 6: provisioner.ParameterValue + (*ParameterSchema)(nil), // 7: provisioner.ParameterSchema + (*Log)(nil), // 8: provisioner.Log + (*Parse)(nil), // 9: provisioner.Parse + (*Resource)(nil), // 10: provisioner.Resource + (*Provision)(nil), // 11: provisioner.Provision + (*Parse_Request)(nil), // 12: provisioner.Parse.Request + (*Parse_Complete)(nil), // 13: provisioner.Parse.Complete + (*Parse_Response)(nil), // 14: provisioner.Parse.Response + (*Provision_Request)(nil), // 15: provisioner.Provision.Request + (*Provision_Complete)(nil), // 16: provisioner.Provision.Complete + (*Provision_Response)(nil), // 17: provisioner.Provision.Response } var file_provisionersdk_proto_provisioner_proto_depIdxs = []int32{ - 0, // 0: provisioner.ParameterSource.scheme:type_name -> provisioner.ParameterSource.Scheme - 1, // 1: provisioner.ParameterDestination.scheme:type_name -> provisioner.ParameterDestination.Scheme - 1, // 2: provisioner.ParameterValue.destination_scheme:type_name -> provisioner.ParameterDestination.Scheme - 3, // 3: provisioner.ParameterSchema.default_source:type_name -> provisioner.ParameterSource - 4, // 4: provisioner.ParameterSchema.default_destination:type_name -> provisioner.ParameterDestination - 2, // 5: provisioner.ParameterSchema.validation_type_system:type_name -> provisioner.ParameterSchema.TypeSystem - 6, // 6: provisioner.Parse.Response.parameter_schemas:type_name -> provisioner.ParameterSchema - 5, // 7: provisioner.Provision.Request.parameter_values:type_name -> provisioner.ParameterValue - 8, // 8: provisioner.Provision.Response.resources:type_name -> provisioner.Resource - 10, // 9: provisioner.Provisioner.Parse:input_type -> provisioner.Parse.Request - 12, // 10: provisioner.Provisioner.Provision:input_type -> provisioner.Provision.Request - 11, // 11: provisioner.Provisioner.Parse:output_type -> provisioner.Parse.Response - 13, // 12: provisioner.Provisioner.Provision:output_type -> provisioner.Provision.Response - 11, // [11:13] is the sub-list for method output_type - 9, // [9:11] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 1, // 0: provisioner.ParameterSource.scheme:type_name -> provisioner.ParameterSource.Scheme + 2, // 1: provisioner.ParameterDestination.scheme:type_name -> provisioner.ParameterDestination.Scheme + 2, // 2: provisioner.ParameterValue.destination_scheme:type_name -> provisioner.ParameterDestination.Scheme + 4, // 3: provisioner.ParameterSchema.default_source:type_name -> provisioner.ParameterSource + 5, // 4: provisioner.ParameterSchema.default_destination:type_name -> provisioner.ParameterDestination + 3, // 5: provisioner.ParameterSchema.validation_type_system:type_name -> provisioner.ParameterSchema.TypeSystem + 0, // 6: provisioner.Log.level:type_name -> provisioner.LogLevel + 7, // 7: provisioner.Parse.Complete.parameter_schemas:type_name -> provisioner.ParameterSchema + 8, // 8: provisioner.Parse.Response.log:type_name -> provisioner.Log + 13, // 9: provisioner.Parse.Response.complete:type_name -> provisioner.Parse.Complete + 6, // 10: provisioner.Provision.Request.parameter_values:type_name -> provisioner.ParameterValue + 10, // 11: provisioner.Provision.Complete.resources:type_name -> provisioner.Resource + 8, // 12: provisioner.Provision.Response.log:type_name -> provisioner.Log + 16, // 13: provisioner.Provision.Response.complete:type_name -> provisioner.Provision.Complete + 12, // 14: provisioner.Provisioner.Parse:input_type -> provisioner.Parse.Request + 15, // 15: provisioner.Provisioner.Provision:input_type -> provisioner.Provision.Request + 14, // 16: provisioner.Provisioner.Parse:output_type -> provisioner.Parse.Response + 17, // 17: provisioner.Provisioner.Provision:output_type -> provisioner.Provision.Response + 16, // [16:18] is the sub-list for method output_type + 14, // [14:16] is the sub-list for method input_type + 14, // [14:14] is the sub-list for extension type_name + 14, // [14:14] is the sub-list for extension extendee + 0, // [0:14] is the sub-list for field type_name } func init() { file_provisionersdk_proto_provisioner_proto_init() } @@ -1025,7 +1330,7 @@ func file_provisionersdk_proto_provisioner_proto_init() { } } file_provisionersdk_proto_provisioner_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Parse); i { + switch v := v.(*Log); i { case 0: return &v.state case 1: @@ -1037,7 +1342,7 @@ func file_provisionersdk_proto_provisioner_proto_init() { } } file_provisionersdk_proto_provisioner_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Resource); i { + switch v := v.(*Parse); i { case 0: return &v.state case 1: @@ -1049,7 +1354,7 @@ func file_provisionersdk_proto_provisioner_proto_init() { } } file_provisionersdk_proto_provisioner_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Provision); i { + switch v := v.(*Resource); i { case 0: return &v.state case 1: @@ -1061,7 +1366,7 @@ func file_provisionersdk_proto_provisioner_proto_init() { } } file_provisionersdk_proto_provisioner_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Parse_Request); i { + switch v := v.(*Provision); i { case 0: return &v.state case 1: @@ -1073,7 +1378,7 @@ func file_provisionersdk_proto_provisioner_proto_init() { } } file_provisionersdk_proto_provisioner_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Parse_Response); i { + switch v := v.(*Parse_Request); i { case 0: return &v.state case 1: @@ -1085,7 +1390,7 @@ func file_provisionersdk_proto_provisioner_proto_init() { } } file_provisionersdk_proto_provisioner_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Provision_Request); i { + switch v := v.(*Parse_Complete); i { case 0: return &v.state case 1: @@ -1097,6 +1402,42 @@ func file_provisionersdk_proto_provisioner_proto_init() { } } file_provisionersdk_proto_provisioner_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Parse_Response); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_provisionersdk_proto_provisioner_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Provision_Request); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_provisionersdk_proto_provisioner_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Provision_Complete); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_provisionersdk_proto_provisioner_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Provision_Response); i { case 0: return &v.state @@ -1109,13 +1450,21 @@ func file_provisionersdk_proto_provisioner_proto_init() { } } } + file_provisionersdk_proto_provisioner_proto_msgTypes[10].OneofWrappers = []interface{}{ + (*Parse_Response_Log)(nil), + (*Parse_Response_Complete)(nil), + } + file_provisionersdk_proto_provisioner_proto_msgTypes[13].OneofWrappers = []interface{}{ + (*Provision_Response_Log)(nil), + (*Provision_Response_Complete)(nil), + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_provisionersdk_proto_provisioner_proto_rawDesc, - NumEnums: 3, - NumMessages: 11, + NumEnums: 4, + NumMessages: 14, NumExtensions: 0, NumServices: 1, }, diff --git a/provisionersdk/proto/provisioner.proto b/provisionersdk/proto/provisioner.proto index c865dced18..9150c7d9df 100644 --- a/provisionersdk/proto/provisioner.proto +++ b/provisionersdk/proto/provisioner.proto @@ -49,13 +49,34 @@ message ParameterSchema { string validation_condition = 11; } +// LogLevel represents severity of the log. +enum LogLevel { + TRACE = 0; + DEBUG = 1; + INFO = 2; + WARN = 3; + ERROR = 4; +} + +// Log represents output from a request. +message Log { + LogLevel level = 1; + string output = 2; +} + // Parse consumes source-code from a directory to produce inputs. message Parse { message Request { string directory = 1; } + message Complete { + repeated ParameterSchema parameter_schemas = 2; + } message Response { - repeated ParameterSchema parameter_schemas = 1; + oneof type { + Log log = 1; + Complete complete = 2; + } } } @@ -72,13 +93,19 @@ message Provision { repeated ParameterValue parameter_values = 2; bytes state = 3; } - message Response { + message Complete { bytes state = 1; repeated Resource resources = 2; } + message Response { + oneof type { + Log log = 1; + Complete complete = 2; + } + } } service Provisioner { - rpc Parse(Parse.Request) returns (Parse.Response); - rpc Provision(Provision.Request) returns (Provision.Response); + rpc Parse(Parse.Request) returns (stream Parse.Response); + rpc Provision(Provision.Request) returns (stream Provision.Response); } \ No newline at end of file diff --git a/provisionersdk/proto/provisioner_drpc.pb.go b/provisionersdk/proto/provisioner_drpc.pb.go index 7a023b6631..cff7c3b281 100644 --- a/provisionersdk/proto/provisioner_drpc.pb.go +++ b/provisionersdk/proto/provisioner_drpc.pb.go @@ -38,8 +38,8 @@ func (drpcEncoding_File_provisionersdk_proto_provisioner_proto) JSONUnmarshal(bu type DRPCProvisionerClient interface { DRPCConn() drpc.Conn - Parse(ctx context.Context, in *Parse_Request) (*Parse_Response, error) - Provision(ctx context.Context, in *Provision_Request) (*Provision_Response, error) + Parse(ctx context.Context, in *Parse_Request) (DRPCProvisioner_ParseClient, error) + Provision(ctx context.Context, in *Provision_Request) (DRPCProvisioner_ProvisionClient, error) } type drpcProvisionerClient struct { @@ -52,37 +52,91 @@ func NewDRPCProvisionerClient(cc drpc.Conn) DRPCProvisionerClient { func (c *drpcProvisionerClient) DRPCConn() drpc.Conn { return c.cc } -func (c *drpcProvisionerClient) Parse(ctx context.Context, in *Parse_Request) (*Parse_Response, error) { - out := new(Parse_Response) - err := c.cc.Invoke(ctx, "/provisioner.Provisioner/Parse", drpcEncoding_File_provisionersdk_proto_provisioner_proto{}, in, out) +func (c *drpcProvisionerClient) Parse(ctx context.Context, in *Parse_Request) (DRPCProvisioner_ParseClient, error) { + stream, err := c.cc.NewStream(ctx, "/provisioner.Provisioner/Parse", drpcEncoding_File_provisionersdk_proto_provisioner_proto{}) if err != nil { return nil, err } - return out, nil + x := &drpcProvisioner_ParseClient{stream} + if err := x.MsgSend(in, drpcEncoding_File_provisionersdk_proto_provisioner_proto{}); err != nil { + return nil, err + } + if err := x.CloseSend(); err != nil { + return nil, err + } + return x, nil } -func (c *drpcProvisionerClient) Provision(ctx context.Context, in *Provision_Request) (*Provision_Response, error) { - out := new(Provision_Response) - err := c.cc.Invoke(ctx, "/provisioner.Provisioner/Provision", drpcEncoding_File_provisionersdk_proto_provisioner_proto{}, in, out) +type DRPCProvisioner_ParseClient interface { + drpc.Stream + Recv() (*Parse_Response, error) +} + +type drpcProvisioner_ParseClient struct { + drpc.Stream +} + +func (x *drpcProvisioner_ParseClient) Recv() (*Parse_Response, error) { + m := new(Parse_Response) + if err := x.MsgRecv(m, drpcEncoding_File_provisionersdk_proto_provisioner_proto{}); err != nil { + return nil, err + } + return m, nil +} + +func (x *drpcProvisioner_ParseClient) RecvMsg(m *Parse_Response) error { + return x.MsgRecv(m, drpcEncoding_File_provisionersdk_proto_provisioner_proto{}) +} + +func (c *drpcProvisionerClient) Provision(ctx context.Context, in *Provision_Request) (DRPCProvisioner_ProvisionClient, error) { + stream, err := c.cc.NewStream(ctx, "/provisioner.Provisioner/Provision", drpcEncoding_File_provisionersdk_proto_provisioner_proto{}) if err != nil { return nil, err } - return out, nil + x := &drpcProvisioner_ProvisionClient{stream} + if err := x.MsgSend(in, drpcEncoding_File_provisionersdk_proto_provisioner_proto{}); err != nil { + return nil, err + } + if err := x.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type DRPCProvisioner_ProvisionClient interface { + drpc.Stream + Recv() (*Provision_Response, error) +} + +type drpcProvisioner_ProvisionClient struct { + drpc.Stream +} + +func (x *drpcProvisioner_ProvisionClient) Recv() (*Provision_Response, error) { + m := new(Provision_Response) + if err := x.MsgRecv(m, drpcEncoding_File_provisionersdk_proto_provisioner_proto{}); err != nil { + return nil, err + } + return m, nil +} + +func (x *drpcProvisioner_ProvisionClient) RecvMsg(m *Provision_Response) error { + return x.MsgRecv(m, drpcEncoding_File_provisionersdk_proto_provisioner_proto{}) } type DRPCProvisionerServer interface { - Parse(context.Context, *Parse_Request) (*Parse_Response, error) - Provision(context.Context, *Provision_Request) (*Provision_Response, error) + Parse(*Parse_Request, DRPCProvisioner_ParseStream) error + Provision(*Provision_Request, DRPCProvisioner_ProvisionStream) error } type DRPCProvisionerUnimplementedServer struct{} -func (s *DRPCProvisionerUnimplementedServer) Parse(context.Context, *Parse_Request) (*Parse_Response, error) { - return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +func (s *DRPCProvisionerUnimplementedServer) Parse(*Parse_Request, DRPCProvisioner_ParseStream) error { + return drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) } -func (s *DRPCProvisionerUnimplementedServer) Provision(context.Context, *Provision_Request) (*Provision_Response, error) { - return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +func (s *DRPCProvisionerUnimplementedServer) Provision(*Provision_Request, DRPCProvisioner_ProvisionStream) error { + return drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) } type DRPCProvisionerDescription struct{} @@ -94,19 +148,19 @@ func (DRPCProvisionerDescription) Method(n int) (string, drpc.Encoding, drpc.Rec case 0: return "/provisioner.Provisioner/Parse", drpcEncoding_File_provisionersdk_proto_provisioner_proto{}, func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { - return srv.(DRPCProvisionerServer). + return nil, srv.(DRPCProvisionerServer). Parse( - ctx, in1.(*Parse_Request), + &drpcProvisioner_ParseStream{in2.(drpc.Stream)}, ) }, DRPCProvisionerServer.Parse, true case 1: return "/provisioner.Provisioner/Provision", drpcEncoding_File_provisionersdk_proto_provisioner_proto{}, func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { - return srv.(DRPCProvisionerServer). + return nil, srv.(DRPCProvisionerServer). Provision( - ctx, in1.(*Provision_Request), + &drpcProvisioner_ProvisionStream{in2.(drpc.Stream)}, ) }, DRPCProvisionerServer.Provision, true default: @@ -120,32 +174,26 @@ func DRPCRegisterProvisioner(mux drpc.Mux, impl DRPCProvisionerServer) error { type DRPCProvisioner_ParseStream interface { drpc.Stream - SendAndClose(*Parse_Response) error + Send(*Parse_Response) error } type drpcProvisioner_ParseStream struct { drpc.Stream } -func (x *drpcProvisioner_ParseStream) SendAndClose(m *Parse_Response) error { - if err := x.MsgSend(m, drpcEncoding_File_provisionersdk_proto_provisioner_proto{}); err != nil { - return err - } - return x.CloseSend() +func (x *drpcProvisioner_ParseStream) Send(m *Parse_Response) error { + return x.MsgSend(m, drpcEncoding_File_provisionersdk_proto_provisioner_proto{}) } type DRPCProvisioner_ProvisionStream interface { drpc.Stream - SendAndClose(*Provision_Response) error + Send(*Provision_Response) error } type drpcProvisioner_ProvisionStream struct { drpc.Stream } -func (x *drpcProvisioner_ProvisionStream) SendAndClose(m *Provision_Response) error { - if err := x.MsgSend(m, drpcEncoding_File_provisionersdk_proto_provisioner_proto{}); err != nil { - return err - } - return x.CloseSend() +func (x *drpcProvisioner_ProvisionStream) Send(m *Provision_Response) error { + return x.MsgSend(m, drpcEncoding_File_provisionersdk_proto_provisioner_proto{}) } diff --git a/provisionersdk/serve_test.go b/provisionersdk/serve_test.go index a08180edb0..08ac393eb8 100644 --- a/provisionersdk/serve_test.go +++ b/provisionersdk/serve_test.go @@ -35,7 +35,9 @@ func TestProvisionerSDK(t *testing.T) { }() api := proto.NewDRPCProvisionerClient(drpcconn.New(client)) - _, err := api.Parse(context.Background(), &proto.Parse_Request{}) + stream, err := api.Parse(context.Background(), &proto.Parse_Request{}) + require.NoError(t, err) + _, err = stream.Recv() require.Equal(t, drpcerr.Unimplemented, int(drpcerr.Code(err))) }) t.Run("ServeClosedPipe", func(t *testing.T) {