Skip to content

feat: add template version creator #3001

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 8 commits into from
Jul 15, 2022
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
use nullable created_by
  • Loading branch information
AbhineetJain committed Jul 15, 2022
commit c8d0d45fe2f924579298aa18a7280c44f0d40729
2 changes: 1 addition & 1 deletion coderd/database/dump.sql

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

2 changes: 1 addition & 1 deletion coderd/database/models.go

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

2 changes: 1 addition & 1 deletion coderd/database/queries.sql.go

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

14 changes: 10 additions & 4 deletions coderd/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,10 @@ func (api *API) postTemplateVersionsByOrganization(rw http.ResponseWriter, r *ht
Name: namesgenerator.GetRandomName(1),
Readme: "",
JobID: provisionerJob.ID,
CreatedBy: apiKey.UserID,
CreatedBy: uuid.NullUUID{
UUID: apiKey.UserID,
Valid: true,
},
})
if err != nil {
return xerrors.Errorf("insert template version: %w", err)
Expand Down Expand Up @@ -833,8 +836,11 @@ func (api *API) templateVersionLogs(rw http.ResponseWriter, r *http.Request) {
api.provisionerJobLogs(rw, r, job)
}

func getUsernameByUserID(ctx context.Context, db database.Store, userID uuid.UUID) (string, error) {
user, err := db.GetUserByID(ctx, userID)
func getUsernameByUserID(ctx context.Context, db database.Store, userID uuid.NullUUID) (string, error) {
if !userID.Valid {
return "", nil
}
user, err := db.GetUserByID(ctx, userID.UUID)
if err != nil {
return "", err
}
Expand All @@ -851,7 +857,7 @@ func convertTemplateVersion(version database.TemplateVersion, job codersdk.Provi
Name: version.Name,
Job: job,
Readme: version.Readme,
CreatedByID: version.CreatedBy,
CreatedByID: version.CreatedBy.UUID,
CreatedByName: createdByName,
}
}