mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat: Add external provisioner daemons (#4935)
* Start to port over provisioner daemons PR * Move to Enterprise * Begin adding tests for external registration * Move provisioner daemons query to enterprise * Move around provisioner daemons schema * Add tags to provisioner daemons * make gen * Add user local provisioner daemons * Add provisioner daemons * Add feature for external daemons * Add command to start a provisioner daemon * Add provisioner tags to template push and create * Rename migration files * Fix tests * Fix entitlements test * PR comments * Update migration * Fix FE types
This commit is contained in:
@ -39,6 +39,7 @@ type Server struct {
|
||||
ID uuid.UUID
|
||||
Logger slog.Logger
|
||||
Provisioners []database.ProvisionerType
|
||||
Tags json.RawMessage
|
||||
Database database.Store
|
||||
Pubsub database.Pubsub
|
||||
Telemetry telemetry.Reporter
|
||||
@ -71,6 +72,7 @@ func (server *Server) AcquireJob(ctx context.Context, _ *proto.Empty) (*proto.Ac
|
||||
Valid: true,
|
||||
},
|
||||
Types: server.Provisioners,
|
||||
Tags: server.Tags,
|
||||
})
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
// The provisioner daemon assumes no jobs are available if
|
||||
|
33
coderd/provisionerdserver/provisionertags.go
Normal file
33
coderd/provisionerdserver/provisionertags.go
Normal file
@ -0,0 +1,33 @@
|
||||
package provisionerdserver
|
||||
|
||||
import "github.com/google/uuid"
|
||||
|
||||
const (
|
||||
TagScope = "scope"
|
||||
TagOwner = "owner"
|
||||
|
||||
ScopeUser = "user"
|
||||
ScopeOrganization = "organization"
|
||||
)
|
||||
|
||||
// MutateTags adjusts the "owner" tag dependent on the "scope".
|
||||
// If the scope is "user", the "owner" is changed to the user ID.
|
||||
// This is for user-scoped provisioner daemons, where users should
|
||||
// own their own operations.
|
||||
func MutateTags(userID uuid.UUID, tags map[string]string) map[string]string {
|
||||
if tags == nil {
|
||||
tags = map[string]string{}
|
||||
}
|
||||
_, ok := tags[TagScope]
|
||||
if !ok {
|
||||
tags[TagScope] = ScopeOrganization
|
||||
}
|
||||
switch tags[TagScope] {
|
||||
case ScopeUser:
|
||||
tags[TagOwner] = userID.String()
|
||||
case ScopeOrganization:
|
||||
default:
|
||||
tags[TagScope] = ScopeOrganization
|
||||
}
|
||||
return tags
|
||||
}
|
Reference in New Issue
Block a user