Skip to content

Commit

Permalink
feat: add onboarding job that will create configured tasks (#64)
Browse files Browse the repository at this point in the history
* feat: add onboarding tasks job that will create configured tasks for a new organization

Signed-off-by: Sarah Funkhouser <[email protected]>

* cleanup

Signed-off-by: Sarah Funkhouser <[email protected]>

* cleanup

Signed-off-by: Sarah Funkhouser <[email protected]>

* cleanup

Signed-off-by: Sarah Funkhouser <[email protected]>

* commit client file

Signed-off-by: Sarah Funkhouser <[email protected]>

---------

Signed-off-by: Sarah Funkhouser <[email protected]>
  • Loading branch information
golanglemonade authored Feb 14, 2025
1 parent f4bd582 commit a55f56c
Show file tree
Hide file tree
Showing 16 changed files with 516 additions and 69 deletions.
15 changes: 15 additions & 0 deletions config/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,18 @@ river:
fromEmail: [email protected]
testDir: fixtures/email
token: ""
onboardingWorker:
config:
apiBaseURL:
ForceQuery: false
Fragment: ""
Host: ""
OmitHost: false
Opaque: ""
Path: ""
RawFragment: ""
RawPath: ""
RawQuery: ""
Scheme: ""
User: null
starterTasks: null
50 changes: 46 additions & 4 deletions configgen/api-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,36 +38,46 @@ Workers that will be enabled on the server

|Name|Type|Description|Required|
|----|----|-----------|--------|
|[**emailWorker**](#riverworkersemailworker)|`object`|||
|[**databaseWorker**](#riverworkersdatabaseworker)|`object`|||
|[**emailWorker**](#riverworkersemailworker)|`object`|EmailWorker is a worker to send emails using the resend email provider the config defaults to dev mode, which will write the email to a file using the mock provider a token is required to send emails using the actual resend provider<br/>||
|[**databaseWorker**](#riverworkersdatabaseworker)|`object`|DatabaseWorker is a worker to create a dedicated database for an organization<br/>||
|[**onboardingWorker**](#riverworkersonboardingworker)|`object`|OnboardingWorker is a worker to create tasks for the organization after signup<br/>||

**Additional Properties:** not allowed
<a name="riverworkersemailworker"></a>
#### river\.workers\.emailWorker: object

EmailWorker is a worker to send emails using the resend email provider the config defaults to dev mode, which will write the email to a file using the mock provider a token is required to send emails using the actual resend provider


**Properties**

|Name|Type|Description|Required|
|----|----|-----------|--------|
|[**config**](#riverworkersemailworkerconfig)|`object`|||
|[**config**](#riverworkersemailworkerconfig)|`object`|EmailConfig contains the configuration for the email worker<br/>||

**Additional Properties:** not allowed
<a name="riverworkersemailworkerconfig"></a>
##### river\.workers\.emailWorker\.config: object

EmailConfig contains the configuration for the email worker


**Properties**

|Name|Type|Description|Required|
|----|----|-----------|--------|
|**devMode**|`boolean`|enable dev mode<br/>||
|**testDir**|`string`|the directory to use for dev mode<br/>||
|**token**|`string`|the token to use for the email provider<br/>||
|**fromEmail**|`string`|||
|**fromEmail**|`string`|FromEmail is the email address to use as the sender<br/>||

**Additional Properties:** not allowed
<a name="riverworkersdatabaseworker"></a>
#### river\.workers\.databaseWorker: object

DatabaseWorker is a worker to create a dedicated database for an organization


**Properties**

|Name|Type|Description|Required|
Expand All @@ -88,4 +98,36 @@ Workers that will be enabled on the server
|**debug**|`boolean`|Enable debug mode<br/>||

**Additional Properties:** not allowed
<a name="riverworkersonboardingworker"></a>
#### river\.workers\.onboardingWorker: object

OnboardingWorker is a worker to create tasks for the organization after signup


**Properties**

|Name|Type|Description|Required|
|----|----|-----------|--------|
|[**config**](#riverworkersonboardingworkerconfig)|`object`|OnboardingConfig contains the configuration for the onboarding worker<br/>||

**Additional Properties:** not allowed
<a name="riverworkersonboardingworkerconfig"></a>
##### river\.workers\.onboardingWorker\.config: object

OnboardingConfig contains the configuration for the onboarding worker


**Properties**

|Name|Type|Description|Required|
|----|----|-----------|--------|
|[**StarterTasks**](#riverworkersonboardingworkerconfigstartertasks)|`array`|||
|**APIBaseURL**|`string`|the base URL for the Openlane API<br/>Format: `"uri"`<br/>||

**Additional Properties:** not allowed
<a name="riverworkersonboardingworkerconfigstartertasks"></a>
###### river\.workers\.onboardingWorker\.config\.StarterTasks: array

**Items**


12 changes: 7 additions & 5 deletions configgen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const (
// any external packages must use the jsonschema description tags to add comments
var includedPackages = []string{
"internal/river",
"pkg/jobs",
"pkg/riverqueue",
}

// schemaConfig represents the configuration for the schema generator
Expand Down Expand Up @@ -86,10 +88,10 @@ func generateSchema(appName string, c schemaConfig, structure interface{}) {
genJSONSchema(s, c)

// generate yaml schema with default
genYAMLSchema(s, c)
genYAMLSchema(c)

// generate environment variables
configMapSchema := genEnvVarSchema(s, c)
configMapSchema := genEnvVarSchema(c)

// Get the configmap header
genConfigMapSchema(configMapSchema, c)
Expand All @@ -111,7 +113,7 @@ func genJSONSchema(s interface{}, c schemaConfig) {
}
}

func genYAMLSchema(s interface{}, c schemaConfig) {
func genYAMLSchema(c schemaConfig) {
yamlConfig := &config.Config{}
defaults.SetDefaults(yamlConfig)

Expand All @@ -126,7 +128,7 @@ func genYAMLSchema(s interface{}, c schemaConfig) {
}
}

func genEnvVarSchema(s interface{}, c schemaConfig) string {
func genEnvVarSchema(c schemaConfig) string {
cp := envparse.Config{
FieldTagName: koanfTagName,
Skipper: skipper,
Expand All @@ -153,7 +155,7 @@ func genEnvVarSchema(s interface{}, c schemaConfig) string {
switch k.Type.Kind() {
case reflect.String, reflect.Int64:
defaultVal = "\"" + defaultVal + "\"" // add quotes to the string
case reflect.Slice:
case reflect.Slice, reflect.Array:
defaultVal = strings.Replace(defaultVal, "[", "", 1)
defaultVal = strings.Replace(defaultVal, "]", "", 1)
defaultVal = "\"" + defaultVal + "\"" // add quotes to the string
Expand Down
69 changes: 66 additions & 3 deletions configgen/riverboat.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/theopenlane/riverboat/config/config.-config",
"$defs": {
"[]jobs.Task": {
"items": {
"$ref": "#/$defs/jobs.Task"
},
"type": "array"
},
"[]river.Queue": {
"items": {
"$ref": "#/$defs/river.Queue"
Expand Down Expand Up @@ -38,7 +44,8 @@
}
},
"additionalProperties": false,
"type": "object"
"type": "object",
"description": "DatabaseWorker is a worker to create a dedicated database for an organization"
},
"jobs.EmailConfig": {
"properties": {
Expand All @@ -55,11 +62,13 @@
"description": "the token to use for the email provider"
},
"fromEmail": {
"type": "string"
"type": "string",
"description": "FromEmail is the email address to use as the sender"
}
},
"additionalProperties": false,
"type": "object"
"type": "object",
"description": "EmailConfig contains the configuration for the email worker"
},
"jobs.EmailWorker": {
"properties": {
Expand All @@ -69,6 +78,56 @@
}
},
"additionalProperties": false,
"type": "object",
"description": "EmailWorker is a worker to send emails using the resend email provider the config defaults to dev mode, which will write the email to a file using the mock provider a token is required to send emails using the actual resend provider"
},
"jobs.OnboardingConfig": {
"properties": {
"StarterTasks": {
"$ref": "#/$defs/[]jobs.Task",
"description": "the tasks to create for the organization after signup"
},
"APIBaseURL": {
"type": "string",
"format": "uri",
"description": "the base URL for the Openlane API"
}
},
"additionalProperties": false,
"type": "object",
"description": "OnboardingConfig contains the configuration for the onboarding worker"
},
"jobs.OnboardingWorker": {
"properties": {
"config": {
"$ref": "#/$defs/jobs.OnboardingConfig",
"description": "the configuration for the onboarding worker"
}
},
"additionalProperties": false,
"type": "object",
"description": "OnboardingWorker is a worker to create tasks for the organization after signup"
},
"jobs.Task": {
"properties": {
"Title": {
"type": "string",
"description": "the title of the task to be created"
},
"Description": {
"type": "string",
"description": "a short description of the task to be created"
},
"Details": {
"$ref": "#/$defs/map[string]interface {}",
"description": "the steps the user needs to take to complete the task"
}
},
"additionalProperties": false,
"type": "object",
"description": "Task is the fields that need to be configured for task creation"
},
"map[string]interface {}": {
"type": "object"
},
"river.Config": {
Expand Down Expand Up @@ -114,6 +173,10 @@
"databaseWorker": {
"$ref": "#/$defs/jobs.DatabaseWorker",
"description": "DatabaseWorker configuration for creating databases using openlane/dbx"
},
"onboardingWorker": {
"$ref": "#/$defs/jobs.OnboardingWorker",
"description": "OnboardingWorker configuration for onboarding new organizations in openlane-core"
}
},
"additionalProperties": false,
Expand Down
4 changes: 2 additions & 2 deletions docker/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ tasks:
dir: ..
desc: brings up the compose environment for postgres development
cmds:
- "docker compose -f ./docker/docker-compose-pg.yml -p postgres up -d"
- "docker compose -f ./docker/docker-compose-pg.yml -p postgres-riverboat up -d"

postgres:down:
dir: ..
desc: brings the postgres compose environment down
cmds:
- docker compose -p postgres down
- docker compose -p postgres-riverboat down
4 changes: 2 additions & 2 deletions docker/docker-compose-pg.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
services:
postgres:
image: postgres:17
container_name: postgres
container_name: postgres-riverboat
command: postgres -c 'max_connections=150'
ports:
- "5432:5432"
- "5434:5432"
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ services:
ports:
- 8082:8080
environment:
- DATABASE_URL=postgres://postgres:[email protected]:5432/jobs?sslmode=disable
- DATABASE_URL=postgres://postgres:[email protected]:5434/jobs?sslmode=disable
networks:
- default
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
- --debug
- --pretty
environment:
- RIVERBOAT_JOBQUEUE_DATABASEHOST=postgres://postgres:password@postgres:5432/jobs?sslmode=disable
- RIVERBOAT_JOBQUEUE_DATABASEHOST=postgres://postgres:password@postgres-riverboat:5434/jobs?sslmode=disable
restart: unless-stopped
networks:
- default
Loading

0 comments on commit a55f56c

Please sign in to comment.