10000 chore: persist template import terraform plan in postgres by aslilac · Pull Request #17012 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: persist template import terraform plan in postgres #17012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
hi steven
  • Loading branch information
aslilac committed Mar 21, 2025
commit 295bceb9466cd2e6b065e3298c0fd245585ca2f9
4 changes: 4 additions & 0 deletions coderd/database/dbmem/dbmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -8837,6 +8837,10 @@ func (q *FakeQuerier) InsertTemplateVersionTerraformValuesByJobID(_ context.Cont
return sql.ErrNoRows
}

if !json.Valid(arg.CachedPlan) {
return xerrors.Errorf("cached plan must be valid json, received %q", string(arg.CachedPlan))
}

// Insert the new row
row := database.TemplateVersionTerraformValue{
TemplateVersionID: templateVersion.ID,
Expand Down
17 changes: 16 additions & 1 deletion provisioner/echo/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ var (
// PlanComplete is a helper to indicate an empty provision completion.
PlanComplete = []*proto.Response{{
Type: &proto.Response_Plan{
Plan: &proto.PlanComplete{},
Plan: &proto.PlanComplete{
Plan: []byte("{}"),
},
},
}}
// ApplyComplete is a helper to indicate an empty provision completion.
Expand Down Expand Up @@ -240,11 +242,23 @@ func TarWithOptions(ctx context.Context, logger slog.Logger, responses *Response
Resources: resp.GetApply().GetResources(),
Parameters: resp.GetApply().GetParameters(),
ExternalAuthProviders: resp.GetApply().GetExternalAuthProviders(),
Plan: []byte("{}"),
}},
})
}
}

for _, resp := range responses.ProvisionPlan {
plan := resp.GetPlan()
if plan == nil {
continue
}

if len(plan.Plan) == 0 {
plan.Plan = []byte("{}")
}
}

var buffer bytes.Buffer
writer := tar.NewWriter(&buffer)

Expand Down Expand Up @@ -322,6 +336,7 @@ func WithResources(resources []*proto.Resource) *Responses {
}}}},
ProvisionPlan: []*proto.Response{{Type: &proto.Response_Plan{Plan: &proto.PlanComplete{
Resources: resources,
Plan: []byte("{}"),
}}}},
}
}
Loading
0