Skip to content

Commit

Permalink
feat(config): add version key to runtime.* template context
Browse files Browse the repository at this point in the history
Allows referencing service or task versions via e.g.
`${runtime.services.my-service.version}` or
`${runtime.tasks.my-task.version}`.
  • Loading branch information
edvald authored and thsig committed May 21, 2021
1 parent a48b168 commit 1c64741
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions core/src/config/template-contexts/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,13 @@ export class ServiceRuntimeContext extends ConfigContext {
)
public outputs: PrimitiveMap

constructor(root: ConfigContext, outputs: PrimitiveMap) {
@schema(joi.string().required().description("The current version of the service.").example(exampleVersion))
public version: string

constructor(root: ConfigContext, outputs: PrimitiveMap, version: string) {
super(root)
this.outputs = outputs
this.version = version
}
}

Expand All @@ -118,6 +122,9 @@ export class TaskRuntimeContext extends ServiceRuntimeContext {
.meta({ keyPlaceholder: "<output-name>" })
)
public outputs: PrimitiveMap

@schema(joi.string().required().description("The current version of the task.").example(exampleVersion))
public version: string
}

class RuntimeConfigContext extends ConfigContext {
Expand Down Expand Up @@ -146,9 +153,9 @@ class RuntimeConfigContext extends ConfigContext {
if (runtimeContext) {
for (const dep of runtimeContext.dependencies) {
if (dep.type === "service") {
this.services.set(dep.name, new ServiceRuntimeContext(this, dep.outputs))
this.services.set(dep.name, new ServiceRuntimeContext(this, dep.outputs, dep.version))
} else if (dep.type === "task") {
this.tasks.set(dep.name, new TaskRuntimeContext(this, dep.outputs))
this.tasks.set(dep.name, new TaskRuntimeContext(this, dep.outputs, dep.version))
}
}
}
Expand Down

0 comments on commit 1c64741

Please sign in to comment.