-
Notifications
You must be signed in to change notification settings - Fork 914
feat: implement claiming of prebuilt workspaces #17458
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
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
8b9e30d
feat: implement claiming of prebuilt workspaces
evgeniy-scherbina d9497df
Merge branch 'main' of github.com:/coder/coder into yevhenii/512-clai…
dannykopping 217e46f
Reverting unncessary changes
dannykopping c459533
Refactoring
dannykopping f905219
Removing unnecessary field
dannykopping 8266338
make fmt
dannykopping 4098ed7
CR's fixes
evgeniy-scherbina 50d23e4
CR's fixes
evgeniy-scherbina 546b7ae
Update coderd/workspaces.go
evgeniy-scherbina 85f7926
CR's fixes
evgeniy-scherbina ee9908c
CR's fixes
evgeniy-scherbina 70bf179
CR's fixes
evgeniy-scherbina 7a72d03
CR's fixes
evgeniy-scherbina b246589
fix tests by updating noop.go
evgeniy-scherbina ff8d3de
Merge branch 'main' of github.com:/coder/coder into yevhenii/512-clai…
dannykopping fcdbba8
test: add failure testcase scenario
evgeniy-scherbina e7b7f80
refactor: revert interface changes
evgeniy-scherbina e7455db
refactor: simplify signature of claim method
evgeniy-scherbina 077d7f0
refactor: CR's fixes
evgeniy-scherbina 0d426c7
Merge remote-tracking branch 'origin/main' into yevhenii/512-claim-pr…
evgeniy-scherbina 663a8c0
refactor: CR's fixes
evgeniy-scherbina bc31fac
refactor: make lint
evgeniy-scherbina 087bd20
refactor: fix linter
evgeniy-scherbina 9f66169
refactor: remove PrebuildsOrchestrator context from claim tests
evgeniy-scherbina 7f25f24
refactor: don't fail test in a goroutine
evgeniy-scherbina ff9eeb4
docs: fix ssh coder example in testing-templates doc (#17550)
EdwardAngert 31b873f
fix: add websocket close handling (#17548)
jaaydenh 4fe770d
ci: move go install tools to separate action (#17552)
ethanndickson 8d8fc99
chore(dogfood): allow provider minor version updates (#17554)
matifali af32325
fix(examples/templates/docker-devcontainer): update folder path and p…
Aericio 0826e8a
feat: enable masking password inputs instead of blocking echo (#17469)
ibetitsmike cbb6c12
fix(examples/templates/kubernetes-devcontainer): update coder provide…
matifali e466844
docs: add automatic release calendar updates in docs (#17531)
matifali f24557b
chore(dogfood): add windsurf module (#17558)
matifali fa65564
Merge branch 'main' of github.com:/coder/coder into yevhenii/512-clai…
dannykopping 53b38d7
fix: use userCtx instead of prebuildCtx for claiming prebuild
evgeniy-scherbina 6c41e03
refactor: CR's fixes
evgeniy-scherbina 9173e9a
CR's fixes
evgeniy-scherbina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package prebuilds | ||
|
||
import ( | ||
"context" | ||
"database/sql" | ||
"errors" | ||
|
||
"github.com/google/uuid" | ||
"golang.org/x/xerrors" | ||
|
||
"github.com/coder/coder/v2/coderd/database" | ||
"github.com/coder/coder/v2/coderd/prebuilds" | ||
) | ||
|
||
type EnterpriseClaimer struct { | ||
store database.Store | ||
} | ||
|
||
func NewEnterpriseClaimer(store database.Store) *EnterpriseClaimer { | ||
return &EnterpriseClaimer{ | ||
store: store, | ||
} | ||
} | ||
|
||
func (c EnterpriseClaimer) Claim( | ||
ctx context.Context, | ||
userID uuid.UUID, | ||
name string, | ||
presetID uuid.UUID, | ||
) (*uuid.UUID, error) { | ||
result, err := c.store.ClaimPrebuiltWorkspace(ctx, database.ClaimPrebuiltWorkspaceParams{ | ||
NewUserID: userID, | ||
NewName: name, | ||
PresetID: presetID, | ||
}) | ||
if err != nil { | ||
switch { | ||
// No eligible prebuilds found | ||
case errors.Is(err, sql.ErrNoRows): | ||
return nil, prebuilds.ErrNoClaimablePrebuiltWorkspaces | ||
default: | ||
return nil, xerrors.Errorf("claim prebuild for user %q: %w", userID.String(), err) | ||
} | ||
} | ||
|
||
return &result.ID, nil | ||
} | ||
|
||
func (EnterpriseClaimer) Initiator() uuid.UUID { | ||
return prebuilds.SystemUserID | ||
} | ||
|
||
var _ prebuilds.Claimer = &EnterpriseClaimer{} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.