Skip to content

feat!: extract provisioner tags from coder_workspace_tags data source #15578

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 20 commits into from
Nov 25, 2024
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
fix tests
  • Loading branch information
johnstcn committed Nov 21, 2024
commit c6f33f7520cf60a87fd4d66abc64d4856afa7a19
4 changes: 1 addition & 3 deletions coderd/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1343,9 +1343,6 @@ func (api *API) postTemplateVersionsByOrganization(rw http.ResponseWriter, r *ht
}
}

// Ensures the "owner" is properly applied.
// tags := provisionersdk.MutateTags(apiKey.UserID, req.ProvisionerTags)

if req.ExampleID != "" && req.FileID != uuid.Nil {
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
Message: "You cannot specify both an example_id and a file_id.",
Expand Down Expand Up @@ -1480,6 +1477,7 @@ func (api *API) postTemplateVersionsByOrganization(rw http.ResponseWriter, r *ht
return
}

// Ensure the "owner" tag is properly applied in addition to request tags and coder_workspace_tags.
// Tag order precedence:
// 1) User-specified tags in the request
// 2) Tags parsed from coder_workspace_tags data source in template file
Expand Down
5 changes: 2 additions & 3 deletions coderd/templateversions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
// TODO(Cian): I'd also like to assert that the correct raw tag values are stored in the database,
// but in order to do this, we need to actually run the job! This isn't straightforward right now.

ctx := testutil.Context(t, testutil.WaitLong)
store, ps := dbtestutil.NewDB(t)
client := coderdtest.New(t, &coderdtest.Options{
Database: store,
Expand Down Expand Up @@ -434,6 +433,8 @@ data "coder_workspace_tags" "tags" {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitShort)

// Create an archive from the files provided in the test case.
tarFile := testutil.CreateTar(t, tt.files)

Expand All @@ -453,15 +454,13 @@ data "coder_workspace_tags" "tags" {

if tt.expectError == "" {
require.NoError(t, err)

// Assert the expected provisioner job is created from the template version import
pj, err := store.GetProvisionerJobByID(ctx, tv.Job.ID)
require.NoError(t, err)
require.EqualValues(t, tt.wantTags, pj.Tags)
} else {
require.ErrorContains(t, err, tt.expectError)
}

})
}
})
Expand Down
Loading