terrafaker 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/utilities/generators/aws-generator.js +2 -2
- package/dist/utilities/generators/azure-generator.js +2 -2
- package/dist/utilities/generators/gcp-generator.js +6 -2
- package/dist/utilities/generators/provider-generator.js +19 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ $ npm install -g terrafaker
|
|
|
51
51
|
$ terrafaker COMMAND
|
|
52
52
|
running command...
|
|
53
53
|
$ terrafaker (--version)
|
|
54
|
-
terrafaker/0.0.
|
|
54
|
+
terrafaker/0.0.7 darwin-arm64 node-v24.8.0
|
|
55
55
|
$ terrafaker --help [COMMAND]
|
|
56
56
|
USAGE
|
|
57
57
|
$ terrafaker COMMAND
|
|
@@ -121,7 +121,7 @@ DESCRIPTION
|
|
|
121
121
|
Generates a terraform file.
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
-
_See code: [src/commands/generate/file.ts](https://github.com/brandongregoryscott/terrafaker/blob/v0.0.
|
|
124
|
+
_See code: [src/commands/generate/file.ts](https://github.com/brandongregoryscott/terrafaker/blob/v0.0.7/src/commands/generate/file.ts)_
|
|
125
125
|
|
|
126
126
|
## `terrafaker generate repo`
|
|
127
127
|
|
|
@@ -192,7 +192,7 @@ DESCRIPTION
|
|
|
192
192
|
Generates repo(s) with multiple terraform files.
|
|
193
193
|
```
|
|
194
194
|
|
|
195
|
-
_See code: [src/commands/generate/repo.ts](https://github.com/brandongregoryscott/terrafaker/blob/v0.0.
|
|
195
|
+
_See code: [src/commands/generate/repo.ts](https://github.com/brandongregoryscott/terrafaker/blob/v0.0.7/src/commands/generate/repo.ts)_
|
|
196
196
|
|
|
197
197
|
## `terrafaker gh clone-repos`
|
|
198
198
|
|
|
@@ -211,7 +211,7 @@ DESCRIPTION
|
|
|
211
211
|
`gh` CLI to be installed. To install, run `brew install gh`.
|
|
212
212
|
```
|
|
213
213
|
|
|
214
|
-
_See code: [src/commands/gh/clone-repos.ts](https://github.com/brandongregoryscott/terrafaker/blob/v0.0.
|
|
214
|
+
_See code: [src/commands/gh/clone-repos.ts](https://github.com/brandongregoryscott/terrafaker/blob/v0.0.7/src/commands/gh/clone-repos.ts)_
|
|
215
215
|
|
|
216
216
|
## `terrafaker gh delete-repos`
|
|
217
217
|
|
|
@@ -231,7 +231,7 @@ DESCRIPTION
|
|
|
231
231
|
If the deletion fails, you may need to refresh your CLI permissions with `gh auth refresh -s delete_repo`
|
|
232
232
|
```
|
|
233
233
|
|
|
234
|
-
_See code: [src/commands/gh/delete-repos.ts](https://github.com/brandongregoryscott/terrafaker/blob/v0.0.
|
|
234
|
+
_See code: [src/commands/gh/delete-repos.ts](https://github.com/brandongregoryscott/terrafaker/blob/v0.0.7/src/commands/gh/delete-repos.ts)_
|
|
235
235
|
|
|
236
236
|
## `terrafaker help [COMMAND]`
|
|
237
237
|
|
|
@@ -29,7 +29,7 @@ class AwsGenerator extends ProviderGenerator {
|
|
|
29
29
|
ami,
|
|
30
30
|
instance_type: instanceType,
|
|
31
31
|
...rootBlockDevice,
|
|
32
|
-
|
|
32
|
+
...this.getTagsBlock(),
|
|
33
33
|
});
|
|
34
34
|
return this;
|
|
35
35
|
}
|
|
@@ -53,7 +53,7 @@ class AwsGenerator extends ProviderGenerator {
|
|
|
53
53
|
function_name: functionName,
|
|
54
54
|
memory_size: memorySize,
|
|
55
55
|
role,
|
|
56
|
-
|
|
56
|
+
...this.getTagsBlock(),
|
|
57
57
|
});
|
|
58
58
|
return this;
|
|
59
59
|
}
|
|
@@ -14,7 +14,7 @@ class AzureGenerator extends ProviderGenerator {
|
|
|
14
14
|
const instanceType = randomItem(AZURE_INSTANCE_TYPES);
|
|
15
15
|
this.tfg.resource(AzureResourceType.ComputeInstance, name, {
|
|
16
16
|
size: instanceType,
|
|
17
|
-
|
|
17
|
+
...this.getTagsBlock(),
|
|
18
18
|
});
|
|
19
19
|
return this;
|
|
20
20
|
}
|
|
@@ -32,7 +32,7 @@ class AzureGenerator extends ProviderGenerator {
|
|
|
32
32
|
...runtime,
|
|
33
33
|
name,
|
|
34
34
|
instance_memory_in_mb: instanceMemoryInMb,
|
|
35
|
-
|
|
35
|
+
...this.getTagsBlock(),
|
|
36
36
|
});
|
|
37
37
|
return this;
|
|
38
38
|
}
|
|
@@ -6,6 +6,10 @@ const GcpResourceType = {
|
|
|
6
6
|
LambdaFunction: "google_cloudfunctions_function",
|
|
7
7
|
};
|
|
8
8
|
class GcpGenerator extends ProviderGenerator {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
super(options);
|
|
11
|
+
this.tagKey = "labels";
|
|
12
|
+
}
|
|
9
13
|
addProvider() {
|
|
10
14
|
this.tfg.provider("google", { region: this.region });
|
|
11
15
|
}
|
|
@@ -24,7 +28,7 @@ class GcpGenerator extends ProviderGenerator {
|
|
|
24
28
|
zone: this.region,
|
|
25
29
|
machine_type: machineType,
|
|
26
30
|
...guestAccelerator,
|
|
27
|
-
|
|
31
|
+
...this.getTagsBlock(),
|
|
28
32
|
});
|
|
29
33
|
return this;
|
|
30
34
|
}
|
|
@@ -41,7 +45,7 @@ class GcpGenerator extends ProviderGenerator {
|
|
|
41
45
|
runtime,
|
|
42
46
|
name,
|
|
43
47
|
available_memory_mb: availableMemoryMb,
|
|
44
|
-
|
|
48
|
+
...this.getTagsBlock(),
|
|
45
49
|
});
|
|
46
50
|
return this;
|
|
47
51
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TerraformGenerator } from "terraform-generator";
|
|
1
|
+
import { map, TerraformGenerator } from "terraform-generator";
|
|
2
2
|
import { ResourceTypes } from "../../enums/resource-types.js";
|
|
3
3
|
import { randomItem, randomMemorableSlug, randomTags, } from "./generator-utils.js";
|
|
4
4
|
import { formatTfFileName } from "../string-utils.js";
|
|
@@ -6,11 +6,17 @@ class ProviderGenerator {
|
|
|
6
6
|
tfg;
|
|
7
7
|
region;
|
|
8
8
|
tags;
|
|
9
|
+
/**
|
|
10
|
+
* Provider-specific key for `tags` objects.
|
|
11
|
+
* @default tags
|
|
12
|
+
*/
|
|
13
|
+
tagKey;
|
|
9
14
|
constructor(options) {
|
|
10
15
|
this.tfg = new TerraformGenerator();
|
|
11
16
|
this.region = this.randomRegion();
|
|
12
17
|
this.addProvider();
|
|
13
18
|
this.tags = options?.tags;
|
|
19
|
+
this.tagKey = "tags";
|
|
14
20
|
}
|
|
15
21
|
addResourceByType(type) {
|
|
16
22
|
switch (type) {
|
|
@@ -32,6 +38,18 @@ class ProviderGenerator {
|
|
|
32
38
|
}
|
|
33
39
|
return this.tags;
|
|
34
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Constructs the tag object to spread onto a resource, where the key is provider specific
|
|
43
|
+
* (usually `tags` or `labels`) and the value is a `Map` constructed from the object returned from
|
|
44
|
+
* `getTags`.
|
|
45
|
+
*/
|
|
46
|
+
getTagsBlock() {
|
|
47
|
+
const tags = this.getTags();
|
|
48
|
+
if (tags === undefined) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
return { [this.tagKey]: map(tags) };
|
|
52
|
+
}
|
|
35
53
|
toString() {
|
|
36
54
|
const { tf } = this.tfg.generate();
|
|
37
55
|
return tf.trim();
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED