Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add support for template version messages in api and cli#8336

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mafredri merged 13 commits intomainfrommafredri/feat-add-template-push-message
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
13 commits
Select commitHold shift + click to select a range
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
PrevPrevious commit
NextNext commit
propagate message in api response
  • Loading branch information
@mafredri
mafredri committedJul 6, 2023
commitf40bcc782c1539db697cc09da6eacbe8f10250d0
1 change: 1 addition & 0 deletionscoderd/database/dbfake/dbfake.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3932,6 +3932,7 @@ func (q *fakeQuerier) InsertTemplateVersion(_ context.Context, arg database.Inse
CreatedAt: arg.CreatedAt,
UpdatedAt: arg.UpdatedAt,
Name: arg.Name,
Message: arg.Message,
Readme: arg.Readme,
JobID: arg.JobID,
CreatedBy: arg.CreatedBy,
Expand Down
1 change: 1 addition & 0 deletionscoderd/database/dbgen/dbgen.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -477,6 +477,7 @@ func TemplateVersion(t testing.TB, db database.Store, orig database.TemplateVers
CreatedAt: takeFirst(orig.CreatedAt, database.Now()),
UpdatedAt: takeFirst(orig.UpdatedAt, database.Now()),
Name: takeFirst(orig.Name, namesgenerator.GetRandomName(1)),
Message: orig.Message,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nit: what about testing? do we need a random message generated for unit tests or maybe benchmarks in the future?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It's a valid concern, although I didn't do it because I'm sure how we'd set an empty message if we usetakeFirst here on a randomly generated one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@mafredri the emptytakeFirst is such an annoying problem 😢

Readme: takeFirst(orig.Readme, namesgenerator.GetRandomName(1)),
JobID: takeFirst(orig.JobID, uuid.New()),
CreatedBy: takeFirst(orig.CreatedBy, uuid.New()),
Expand Down
2 changes: 2 additions & 0 deletionscoderd/templateversions.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1306,6 +1306,7 @@ func (api *API) postTemplateVersionsByOrganization(rw http.ResponseWriter, r *ht
CreatedAt: database.Now(),
UpdatedAt: database.Now(),
Name: req.Name,
Message: req.Message,
Readme: "",
JobID: provisionerJob.ID,
CreatedBy: apiKey.UserID,
Expand DownExpand Up@@ -1420,6 +1421,7 @@ func convertTemplateVersion(version database.TemplateVersion, job codersdk.Provi
CreatedAt: version.CreatedAt,
UpdatedAt: version.UpdatedAt,
Name: version.Name,
Message: version.Message,
Job: job,
Readme: version.Readme,
CreatedBy: createdBy,
Expand Down
8 changes: 7 additions & 1 deletioncoderd/templateversions_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,10 @@ func TestTemplateVersion(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)
authz := coderdtest.AssertRBAC(t, api, client).Reset()

version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil, func(req *codersdk.CreateTemplateVersionRequest) {
req.Name = "bananas"
req.Message = "first try"
})
authz.AssertChecked(t, rbac.ActionCreate, rbac.ResourceTemplate.InOrg(user.OrganizationID))

ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
Expand All@@ -43,6 +46,9 @@ func TestTemplateVersion(t *testing.T) {
tv, err := client.TemplateVersion(ctx, version.ID)
authz.AssertChecked(t, rbac.ActionRead, tv)
require.NoError(t, err)

assert.Equal(t, "bananas", tv.Name)
assert.Equal(t, "first try", tv.Message)
})

t.Run("MemberCanRead", func(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletioncodersdk/organizations.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,7 +42,8 @@ type OrganizationMember struct {

// CreateTemplateVersionRequest enables callers to create a new Template Version.
type CreateTemplateVersionRequest struct {
Name string `json:"name,omitempty" validate:"omitempty,template_version_name"`
Name string `json:"name,omitempty" validate:"omitempty,template_version_name"`
Message string `json:"message,omitempty"`
// TemplateID optionally associates a version with a template.
TemplateID uuid.UUID `json:"template_id,omitempty" format:"uuid"`
StorageMethod ProvisionerStorageMethod `json:"storage_method" validate:"oneof=file,required" enums:"file"`
Expand Down
1 change: 1 addition & 0 deletionscodersdk/templateversions.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,6 +25,7 @@ type TemplateVersion struct {
CreatedAt time.Time `json:"created_at" format:"date-time"`
UpdatedAt time.Time `json:"updated_at" format:"date-time"`
Name string `json:"name"`
Message string `json:"message"`
Job ProvisionerJob `json:"job"`
Readme string `json:"readme"`
CreatedBy User `json:"created_by"`
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp