Skip to content

Commit

Permalink
feat: Added lock option to providers target. (#199)
Browse files Browse the repository at this point in the history
Enhanced the providers executor to be able to pass the lock option.
  • Loading branch information
TriPSs authored Dec 15, 2023
2 parents 8a4a906 + 5c839fd commit c5abf01
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion packages/terraform/src/executors/providers/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@
"type": "object",
"title": "Providers executor",
"description": "Providers",
"properties": {}
"properties": {
"lock": {
"type": "boolean",
"title": "Write out dependency locks for the configured providers.",
"description": "Write out dependency locks for the configured providers.",
"default": false
}
}
}
3 changes: 2 additions & 1 deletion packages/terraform/src/generators/init/init.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export default async function (
providers: {
executor: '@nx-extend/terraform:providers',
options: {
ciMode: true
ciMode: true,
lock: true
}
},
fmt: {
Expand Down
4 changes: 3 additions & 1 deletion packages/terraform/src/utils/create-executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ExecutorOptions {
formatWrite: boolean
upgrade: boolean
migrateState: boolean
lock: boolean

[key: string]: string | unknown
}
Expand All @@ -25,7 +26,7 @@ export function createExecutor(command: string) {
}

const { sourceRoot } = context.workspace.projects[context.projectName]
const { backendConfig = [], planFile, ciMode, autoApproval, formatWrite, upgrade, migrateState } = options
const { backendConfig = [], planFile, ciMode, autoApproval, formatWrite, upgrade, migrateState, lock } = options

let env = {}
if (ciMode) {
Expand All @@ -50,6 +51,7 @@ export function createExecutor(command: string) {
command === 'fmt' && !formatWrite && '--check --list',
command === 'init' && upgrade && '-upgrade',
command === 'init' && migrateState && '-migrate-state',
command === 'providers' && lock && 'lock',
]),
{
cwd: sourceRoot,
Expand Down

0 comments on commit c5abf01

Please sign in to comment.