-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathSchemas.scala
105 lines (94 loc) · 3.1 KB
/
Schemas.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package besom.scripts
import besom.codegen.Config
import os.*
object Schemas:
val cwd: os.Path = Config.besomDir
def main(args: String*): Unit =
args match
case "fetch" :: Nil => fetchSchemas(cwd)
case "all" :: Nil =>
fetchSchemas(cwd)
println("fetched")
case other =>
println(s"unknown command: $other")
sys.exit(1)
def fetchSchemas(cwd: os.Path): Unit =
val pulumiRepoPath = cwd / "target" / "pulumi-codegen-testdata"
val pulumiJavaRepoPath = cwd / "target" / "pulumi-java-codegen-testdata"
val relPulumiTestsPath = os.rel / "tests" / "testdata" / "codegen"
val relPulumiJavaTestsPath = os.rel / "pkg" / "codegen" / "testing" / "test" / "testdata"
val pulumiRepo = sparseCheckout(
pulumiRepoPath,
"github.com/pulumi/pulumi.git",
List(relPulumiTestsPath)
)
val pulumiJavaRepo = sparseCheckout(
pulumiJavaRepoPath,
"github.com/pulumi/pulumi-java.git",
List(relPulumiJavaTestsPath)
)
val targetPath = cwd / "integration-tests" / "resources" / "testdata"
os.remove.all(targetPath)
// copy test schemas
copySchemas(relPulumiTestsPath.resolveFrom(pulumiRepo), targetPath)
copySchemas(relPulumiJavaTestsPath.resolveFrom(pulumiJavaRepo), targetPath)
println("fetched test schema files")
def copySchemas(sourcePath: os.Path, targetPath: os.Path): Unit =
println(s"copying from $sourcePath to $targetPath")
val allowDirList = List(
// from Pulumi repo
"secrets",
"simple-plain-schema",
"simple-plain-schema-with-root-package",
"simple-enum-schema",
"simple-resource-schema",
"simple-resource-with-aliases",
"simple-methods-schema",
"simple-methods-schema-single-value-returns",
"simple-yaml-schema",
"simplified-invokes",
"nested-module",
"nested-module-thirdparty",
"enum-reference",
"external-resource-schema",
"external-enum",
"different-enum",
"embedded-crd-types",
"dash-named-schema",
"hyphen-url",
"hyphenated-symbols",
"naming-collisions",
"provider-config-schema",
"replace-on-change",
"resource-property-overlap",
"cyclic-types",
"plain-and-default",
"plain-object-defaults",
"plain-object-disable-defaults",
"different-package-name-conflict",
"azure-native-nested-types",
"functions-secrets",
"assets-and-archives",
"dashed-import-schema",
"other-owned",
"output-funcs-edgeorder",
"output-funcs",
"provider-type-schema",
"provider-config-schema",
"urn-id-properties",
"unions-inside-arrays",
"methods-return-plain-resource",
// from Pulumi Java repo
"mini-azurenative",
"mini-awsnative",
"mini-awsclassic",
"mini-azuread",
"mini-awsx",
"mini-kubernetes",
"jumbo-resources"
)
val allowFileList = List()
val allowExtensions = List("json", "yaml")
copyFilteredFiles(sourcePath, targetPath, allowDirList, allowFileList, allowExtensions)
end copySchemas
end Schemas