Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions apps/workspace-engine/pkg/db/deployment_plan.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions apps/workspace-engine/pkg/db/queries/deployment_plan.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,38 @@ WHERE id = $1;
UPDATE deployment_plan
SET completed_at = NOW()
WHERE id = $1;

-- name: GetTargetContextByResultID :one
SELECT
t.id AS target_id,
t.plan_id,
dp.deployment_id,
dp.workspace_id,
dp.version_tag,
dp.version_metadata,
w.slug AS workspace_slug,
e.name AS environment_name,
res.name AS resource_name
FROM deployment_plan_target_result r
JOIN deployment_plan_target t ON t.id = r.target_id
JOIN deployment_plan dp ON dp.id = t.plan_id
JOIN workspace w ON w.id = dp.workspace_id
JOIN environment e ON e.id = t.environment_id
JOIN resource res ON res.id = t.resource_id
WHERE r.id = $1;

-- name: ListDeploymentPlanTargetResultsByTargetID :many
SELECT
r.id,
r.target_id,
r.dispatch_context,
r.status,
r.has_changes,
r.current,
r.proposed,
r.message,
r.started_at,
r.completed_at
FROM deployment_plan_target_result r
WHERE r.target_id = $1
ORDER BY r.started_at;
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ func (c *Controller) Process(ctx context.Context, item reconcile.Item) (reconcil
return reconcile.Result{}, fmt.Errorf("mark result unsupported: %w", updateErr)
}

if checkErr := MaybeUpdateTargetCheck(ctx, c.getter, resultID); checkErr != nil {
span.RecordError(checkErr)
}

return reconcile.Result{}, nil
}

Expand All @@ -119,6 +123,10 @@ func (c *Controller) Process(ctx context.Context, item reconcile.Item) (reconcil
)
}

if checkErr := MaybeUpdateTargetCheck(ctx, c.getter, resultID); checkErr != nil {
span.RecordError(checkErr)
}

return reconcile.Result{}, nil
}

Expand Down Expand Up @@ -169,6 +177,10 @@ func (c *Controller) Process(ctx context.Context, item reconcile.Item) (reconcil
return reconcile.Result{}, fmt.Errorf("save completed result: %w", err)
}

if checkErr := MaybeUpdateTargetCheck(ctx, c.getter, resultID); checkErr != nil {
span.RecordError(checkErr)
}

return reconcile.Result{}, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ func (m *mockGetter) GetDeploymentPlanTargetResult(
return m.result, m.err
}

func (m *mockGetter) GetTargetContextByResultID(
_ context.Context,
_ uuid.UUID,
) (db.GetTargetContextByResultIDRow, error) {
return db.GetTargetContextByResultIDRow{}, nil
}

func (m *mockGetter) ListDeploymentPlanTargetResultsByTargetID(
_ context.Context,
_ uuid.UUID,
) ([]db.ListDeploymentPlanTargetResultsByTargetIDRow, error) {
return nil, nil
}

type completedCall struct {
ID uuid.UUID
Status db.DeploymentPlanTargetStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,14 @@ type Getter interface {
ctx context.Context,
id uuid.UUID,
) (db.DeploymentPlanTargetResult, error)

GetTargetContextByResultID(
ctx context.Context,
resultID uuid.UUID,
) (db.GetTargetContextByResultIDRow, error)

ListDeploymentPlanTargetResultsByTargetID(
ctx context.Context,
targetID uuid.UUID,
) ([]db.ListDeploymentPlanTargetResultsByTargetIDRow, error)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ func (g *PostgresGetter) GetDeploymentPlanTargetResult(
return db.GetQueries(ctx).GetDeploymentPlanTargetResult(ctx, id)
}

func (g *PostgresGetter) GetTargetContextByResultID(
ctx context.Context,
resultID uuid.UUID,
) (db.GetTargetContextByResultIDRow, error) {
return db.GetQueries(ctx).GetTargetContextByResultID(ctx, resultID)
}

func (g *PostgresGetter) ListDeploymentPlanTargetResultsByTargetID(
ctx context.Context,
targetID uuid.UUID,
) ([]db.ListDeploymentPlanTargetResultsByTargetIDRow, error) {
return db.GetQueries(ctx).ListDeploymentPlanTargetResultsByTargetID(ctx, targetID)
}

func newRegistry() *jobagents.Registry {
registry := jobagents.NewRegistry(nil, nil)
registry.Register(
Expand Down
Loading
Loading