-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TerraformElement, make list & map argument
- Loading branch information
Chang Zhe Jiet
authored and
Chang Zhe Jiet
committed
Nov 25, 2023
1 parent
f063935
commit 8a6e9ee
Showing
56 changed files
with
9,661 additions
and
1,363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Util } from '../utils'; | ||
import { Argument } from '.'; | ||
|
||
/** | ||
* @category Argument | ||
*/ | ||
export class List extends Argument { | ||
|
||
/** | ||
* Construct list. | ||
* | ||
* @param elements list elements | ||
*/ | ||
constructor(...elements: any[]) { | ||
super(List.#constructArgument(elements)); | ||
} | ||
|
||
static #constructArgument(elements: any[]): string { | ||
let str = '[\n'; | ||
elements.forEach((element, i) => { | ||
str += `${Util.argumentValueToString(element)}${i < elements.length - 1 ? ',' : ''}\n`; | ||
}); | ||
str += ']'; | ||
return str; | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Convenient function to construct new [[List]]. | ||
* | ||
* @param elements list elements | ||
* | ||
* @category Argument | ||
*/ | ||
export const list = (...elements: any[]): List => new List(...elements); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { TerraformArgs, Util } from '../utils'; | ||
import { Argument } from '.'; | ||
|
||
/** | ||
* @category Argument | ||
*/ | ||
export class Map extends Argument { | ||
|
||
readonly arguments: TerraformArgs; | ||
|
||
/** | ||
* Construct map. | ||
* | ||
* @param args map values | ||
*/ | ||
constructor(args: TerraformArgs) { | ||
super(Map.#constructArgument(args)); | ||
this.arguments = args; | ||
} | ||
|
||
static #constructArgument(args: TerraformArgs): string { | ||
return Util.argumentValueToString(args)!; | ||
} | ||
|
||
} | ||
|
||
/** | ||
* Convenient function to construct new [[Map]]. | ||
* | ||
* @param args map values | ||
* | ||
* @category Argument | ||
*/ | ||
export const map = (args: TerraformArgs): Map => new Map(args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.