Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions apps/workspace-engine/oapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2425,6 +2425,7 @@
}
},
"required": [
"id",
"name",
"jobAgent"
],
Expand Down
2 changes: 1 addition & 1 deletion apps/workspace-engine/oapi/spec/schemas/workflows.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local openapi = import '../lib/openapi.libsonnet';
{
WorkflowStepTemplate: {
type: 'object',
required: ['name', 'jobAgent'],
required: ['id', 'name', 'jobAgent'],
Copy link
Member

Choose a reason for hiding this comment

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

a template doesn't need an id

Copy link
Member

Choose a reason for hiding this comment

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

follow github patterns, you dont provide an id to the steps

Copy link
Member Author

Choose a reason for hiding this comment

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

after discussion - id is internal, later we will add referenceId which will be "id" in the yaml

properties: {
name: { type: 'string' },
id: { type: 'string' },
Expand Down
2 changes: 1 addition & 1 deletion apps/workspace-engine/pkg/oapi/oapi.gen.go

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

16 changes: 16 additions & 0 deletions apps/workspace-engine/pkg/oapi/persistence.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,19 @@ func (dvv *DeploymentVariableValue) CompactionKey() (string, string) {
func (jv *JobVerification) CompactionKey() (string, string) {
return "job_verification", jv.Id
}

func (wt *WorkflowTemplate) CompactionKey() (string, string) {
return "workflow_template", wt.Id
}

func (wtt *WorkflowStepTemplate) CompactionKey() (string, string) {
return "workflow_step_template", wtt.Id
}

func (w *Workflow) CompactionKey() (string, string) {
return "workflow", w.Id
}

func (wt *WorkflowStep) CompactionKey() (string, string) {
return "workflow_step", wt.Id
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func initGlobalRegistry() {
globalRegistry.Register("relationship_rule", func() persistence.Entity { return &oapi.RelationshipRule{} })
globalRegistry.Register("github_entity", func() persistence.Entity { return &oapi.GithubEntity{} })
globalRegistry.Register("job_verification", func() persistence.Entity { return &oapi.JobVerification{} })
globalRegistry.Register("workflow_template", func() persistence.Entity { return &oapi.WorkflowTemplate{} })
globalRegistry.Register("workflow_step_template", func() persistence.Entity { return &oapi.WorkflowStepTemplate{} })
globalRegistry.Register("workflow", func() persistence.Entity { return &oapi.Workflow{} })
globalRegistry.Register("workflow_step", func() persistence.Entity { return &oapi.WorkflowStep{} })
})
}

Expand Down
11 changes: 10 additions & 1 deletion apps/workspace-engine/pkg/workspace/store/repository/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func createMemDBStore[E persistence.Entity](router *persistence.RepositoryRouter
_, key := keyer.CompactionKey()
return key
}
return indexstore.NewStore[E](db, entityType, fn)
return indexstore.NewStore(db, entityType, fn)
}

func New(wsId string) *InMemoryStore {
Expand Down Expand Up @@ -61,6 +61,10 @@ func New(wsId string) *InMemoryStore {
UserApprovalRecords: createTypedStore[*oapi.UserApprovalRecord](router, "user_approval_record"),
RelationshipRules: createTypedStore[*oapi.RelationshipRule](router, "relationship_rule"),
GithubEntities: createTypedStore[*oapi.GithubEntity](router, "github_entity"),
WorkflowTemplates: createTypedStore[*oapi.WorkflowTemplate](router, "workflow_template"),
WorkflowStepTemplates: createTypedStore[*oapi.WorkflowStepTemplate](router, "workflow_step_template"),
Workflows: createTypedStore[*oapi.Workflow](router, "workflow"),
WorkflowSteps: createTypedStore[*oapi.WorkflowStep](router, "workflow_step"),
}
}

Expand Down Expand Up @@ -93,6 +97,11 @@ type InMemoryStore struct {
GithubEntities cmap.ConcurrentMap[string, *oapi.GithubEntity]
UserApprovalRecords cmap.ConcurrentMap[string, *oapi.UserApprovalRecord]
RelationshipRules cmap.ConcurrentMap[string, *oapi.RelationshipRule]

WorkflowTemplates cmap.ConcurrentMap[string, *oapi.WorkflowTemplate]
WorkflowStepTemplates cmap.ConcurrentMap[string, *oapi.WorkflowStepTemplate]
Workflows cmap.ConcurrentMap[string, *oapi.Workflow]
WorkflowSteps cmap.ConcurrentMap[string, *oapi.WorkflowStep]
}

func (s *InMemoryStore) Router() *persistence.RepositoryRouter {
Expand Down
8 changes: 8 additions & 0 deletions apps/workspace-engine/pkg/workspace/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func New(wsId string, changeset *statechange.ChangeSet[any]) *Store {
store.GithubEntities = NewGithubEntities(store)
store.Relations = NewRelations(store)
store.JobVerifications = NewJobVerifications(store)
store.WorkflowTemplates = NewWorkflowTemplates(store)
store.WorkflowStepTemplates = NewWorkflowStepTemplates(store)
store.Workflows = NewWorkflows(store)
store.WorkflowSteps = NewWorkflowSteps(store)

return store
}
Expand Down Expand Up @@ -65,6 +69,10 @@ type Store struct {
GithubEntities *GithubEntities
Relations *Relations
JobVerifications *JobVerifications
WorkflowTemplates *WorkflowTemplates
WorkflowStepTemplates *WorkflowStepTemplates
Workflows *Workflows
WorkflowSteps *WorkflowSteps
}

func (s *Store) ID() string {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package store

import (
"context"
"workspace-engine/pkg/oapi"
"workspace-engine/pkg/workspace/store/repository"
)

func NewWorkflowStepTemplates(store *Store) *WorkflowStepTemplates {
return &WorkflowStepTemplates{
repo: store.repo,
store: store,
}
}

type WorkflowStepTemplates struct {
repo *repository.InMemoryStore
store *Store
}

func (w *WorkflowStepTemplates) Items() map[string]*oapi.WorkflowStepTemplate {
return w.repo.WorkflowStepTemplates.Items()
}

func (w *WorkflowStepTemplates) Get(id string) (*oapi.WorkflowStepTemplate, bool) {
return w.repo.WorkflowStepTemplates.Get(id)
}

func (w *WorkflowStepTemplates) Upsert(ctx context.Context, workflowStepTemplate *oapi.WorkflowStepTemplate) {
w.repo.WorkflowStepTemplates.Set(workflowStepTemplate.Id, workflowStepTemplate)
w.store.changeset.RecordUpsert(workflowStepTemplate)
}

func (w *WorkflowStepTemplates) Remove(ctx context.Context, id string) {
workflowStepTemplate, ok := w.repo.WorkflowStepTemplates.Get(id)
if !ok || workflowStepTemplate == nil {
return
}
w.repo.WorkflowStepTemplates.Remove(id)
w.store.changeset.RecordDelete(workflowStepTemplate)
}
41 changes: 41 additions & 0 deletions apps/workspace-engine/pkg/workspace/store/workflow_tasks.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package store

import (
"context"
"workspace-engine/pkg/oapi"
"workspace-engine/pkg/workspace/store/repository"
)

func NewWorkflowSteps(store *Store) *WorkflowSteps {
return &WorkflowSteps{
repo: store.repo,
store: store,
}
}

type WorkflowSteps struct {
repo *repository.InMemoryStore
store *Store
}

func (w *WorkflowSteps) Items() map[string]*oapi.WorkflowStep {
return w.repo.WorkflowSteps.Items()
}

func (w *WorkflowSteps) Get(id string) (*oapi.WorkflowStep, bool) {
return w.repo.WorkflowSteps.Get(id)
}

func (w *WorkflowSteps) Upsert(ctx context.Context, workflowStep *oapi.WorkflowStep) {
w.repo.WorkflowSteps.Set(workflowStep.Id, workflowStep)
w.store.changeset.RecordUpsert(workflowStep)
}

func (w *WorkflowSteps) Remove(ctx context.Context, id string) {
workflowStep, ok := w.repo.WorkflowSteps.Get(id)
if !ok || workflowStep == nil {
return
}
w.repo.WorkflowSteps.Remove(id)
w.store.changeset.RecordDelete(workflowStep)
}
41 changes: 41 additions & 0 deletions apps/workspace-engine/pkg/workspace/store/workflow_templates.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package store

import (
"context"
"workspace-engine/pkg/oapi"
"workspace-engine/pkg/workspace/store/repository"
)

func NewWorkflowTemplates(store *Store) *WorkflowTemplates {
return &WorkflowTemplates{
repo: store.repo,
store: store,
}
}

type WorkflowTemplates struct {
repo *repository.InMemoryStore
store *Store
}

func (w *WorkflowTemplates) Items() map[string]*oapi.WorkflowTemplate {
return w.repo.WorkflowTemplates.Items()
}

func (w *WorkflowTemplates) Get(id string) (*oapi.WorkflowTemplate, bool) {
return w.repo.WorkflowTemplates.Get(id)
}

func (w *WorkflowTemplates) Upsert(ctx context.Context, workflowTemplate *oapi.WorkflowTemplate) {
w.repo.WorkflowTemplates.Set(workflowTemplate.Id, workflowTemplate)
w.store.changeset.RecordUpsert(workflowTemplate)
}

func (w *WorkflowTemplates) Remove(ctx context.Context, id string) {
workflowTemplate, ok := w.repo.WorkflowTemplates.Get(id)
if !ok || workflowTemplate == nil {
return
}
w.repo.WorkflowTemplates.Remove(id)
w.store.changeset.RecordDelete(workflowTemplate)
}
41 changes: 41 additions & 0 deletions apps/workspace-engine/pkg/workspace/store/workflows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package store

import (
"context"
"workspace-engine/pkg/oapi"
"workspace-engine/pkg/workspace/store/repository"
)

func NewWorkflows(store *Store) *Workflows {
return &Workflows{
repo: store.repo,
store: store,
}
}

type Workflows struct {
repo *repository.InMemoryStore
store *Store
}

func (w *Workflows) Items() map[string]*oapi.Workflow {
return w.repo.Workflows.Items()
}

func (w *Workflows) Get(id string) (*oapi.Workflow, bool) {
return w.repo.Workflows.Get(id)
}

func (w *Workflows) Upsert(ctx context.Context, workflow *oapi.Workflow) {
w.repo.Workflows.Set(workflow.Id, workflow)
w.store.changeset.RecordUpsert(workflow)
}

func (w *Workflows) Remove(ctx context.Context, id string) {
workflow, ok := w.repo.Workflows.Get(id)
if !ok || workflow == nil {
return
}
w.repo.Workflows.Remove(id)
w.store.changeset.RecordDelete(workflow)
}
Loading