|
2 | 2 |
|
3 | 3 | # Can be run without dependencies with
|
4 | 4 | #
|
5 |
| -# uv run --with requests,pyyaml scripts/push-registry.py |
| 5 | +# uv run --with requests,pyyaml scripts/ci/push-registry.py |
6 | 6 |
|
7 | 7 | import os
|
8 | 8 | import tempfile
|
9 | 9 | import requests
|
| 10 | +import subprocess |
10 | 11 | import json
|
11 | 12 | import yaml
|
12 |
| -import sys |
13 |
| -from logging import info, basicConfig, INFO |
| 13 | +import argparse |
| 14 | +from logging import info, warning, basicConfig, WARNING |
| 15 | + |
| 16 | +basicConfig(level=WARNING) |
14 | 17 |
|
15 | 18 | yaml_db_path = "themes/default/data/registry/packages"
|
16 | 19 | docs_path = "themes/default/content/registry/packages"
|
17 | 20 | tmpdir = tempfile.mkdtemp()
|
18 | 21 |
|
19 |
| -basicConfig(level=INFO) |
| 22 | +token = os.getenv("PULUMI_ACCESS_TOKEN") |
20 | 23 |
|
21 |
| -info(f"Tempdir: {tmpdir}") |
| 24 | +parser = argparse.ArgumentParser( |
| 25 | + prog='push-registry', |
| 26 | + description='Push the contents of the pulumi/registry GitHub repo to the live registry service', |
| 27 | + epilog='This is a Pulumi internal tool - it is not intended for external use') |
| 28 | +parser.add_argument("--target", default=None, help='Only focus on one provider. This should just be the name, like "aws"') |
| 29 | +parser.add_argument("--dry-run", action='store_true', help="Don't actually publish provider, but do everything else") |
22 | 30 |
|
23 |
| -run_script = [] |
| 31 | +args = parser.parse_args() |
24 | 32 |
|
25 |
| -target = None |
26 |
| -if len(sys.argv) >= 2: |
27 |
| - target = sys.argv[1] |
| 33 | +info(f"Tempdir: {tmpdir}") |
28 | 34 |
|
29 | 35 | publishers = {
|
30 | 36 | "1Password": "1Password",
|
31 |
| - "airbytehq": "airbytehq", |
32 | 37 | "Aviatrix": "Aviatrix",
|
33 |
| - "azaurus1": "azaurus1", |
34 |
| - "castai": "castai", |
35 |
| - "celest-dev": "celest-dev", |
| 38 | + "CTFer.io": "ctfer", |
36 | 39 | "Checkly": "checkly",
|
37 | 40 | "Christian Nunciato": "christian_nunciato",
|
38 | 41 | "Chronosphere": "chronosphere",
|
39 | 42 | "Cisco": "cisco",
|
40 |
| - "civo": "civo", |
41 |
| - "constellix": "constellix", |
42 | 43 | "CrowdStrike": "crowdstrike",
|
43 |
| - "CTFer.io": "ctfer", |
44 | 44 | "Daniel Muehlbachler-Pietrzykowski": "daniel_muehlbachler_pietrzykowski",
|
45 | 45 | "DataRobot, Inc.": "datarobot",
|
46 | 46 | "Defang": "defang",
|
47 | 47 | "Descope": "descope",
|
48 |
| - "dirien": "dirien", |
49 |
| - "dmacvicar": "dmacvicar", |
50 | 48 | "Equinix": "equinix",
|
51 | 49 | "EventStore": "eventstore",
|
| 50 | + "Genesiscloud": "genesiscloud", |
| 51 | + "Grapl Security": "grapl_security", |
| 52 | + "Ian Wahbe": "ian_wahbe", |
| 53 | + "Impart Security": "impart_security", |
| 54 | + "Koyeb": "koyeb", |
| 55 | + "Lee Zen": "lee_zen", |
| 56 | + "Nuage-Studio": "nuage_studio", |
| 57 | + "OVHcloud": "ovhcloud", |
| 58 | + "Paul Stack": "paul_stack", |
| 59 | + "Piers Karsenbarg": "piers_karsenbarg", |
| 60 | + "Prodvana": "prodvana", |
| 61 | + "Pulumi": "pulumi", |
| 62 | + "Pulumiverse": "pulumiverse", |
| 63 | + "RedisLabs": "redislabs", |
| 64 | + "Rootly": "rootly", |
| 65 | + "Runpod": "runpod", |
| 66 | + "Symbiosis": "symbiosis", |
| 67 | + "Theo Gravity": "theo_gravity", |
| 68 | + "Three141": "three141", |
| 69 | + "Threefold": "threefold", |
| 70 | + "Twingate": "twingate", |
| 71 | + "UpCloudLtd": "upcloudltd", |
| 72 | + "Upstash": "upstash", |
| 73 | + "Vates": "vates", |
| 74 | + "Volcengine": "volcengine", |
| 75 | + "Wttech": "wttech", |
| 76 | + "Zscaler": "zscaler", |
| 77 | + "airbytehq": "airbytehq", |
| 78 | + "akeyless-community": "akeyless-community", |
| 79 | + "aptible": "aptible", |
| 80 | + "athenz": "athenz", |
| 81 | + "azaurus1": "azaurus1", |
| 82 | + "castai": "castai", |
| 83 | + "celest-dev": "celest-dev", |
| 84 | + "chainguard-dev": "chainguard-dev", |
| 85 | + "checkpointsw": "checkpointsw", |
| 86 | + "ciscodevnet": "ciscodevnet", |
| 87 | + "ciscodevnet": "ciscodevnet", |
| 88 | + "civo": "civo", |
| 89 | + "cloudfoundry-community": "cloudfoundry-community", |
| 90 | + "coder": "coder", |
| 91 | + "constellix": "constellix", |
| 92 | + "coralogix": "coralogix", |
| 93 | + "cox-automotive": "cox-automotive", |
| 94 | + "cyralinc": "cyralinc", |
| 95 | + "datadrivers": "datadrivers", |
| 96 | + "dell": "dell", |
| 97 | + "dell": "dell", |
| 98 | + "dell": "dell", |
| 99 | + "denouche": "denouche", |
| 100 | + "dirien": "dirien", |
| 101 | + "dmacvicar": "dmacvicar", |
| 102 | + "dome9": "dome9", |
| 103 | + "drfaust92": "drfaust92", |
| 104 | + "e-breuninger": "e-breuninger", |
| 105 | + "edge-center": "edge-center", |
| 106 | + "elastic": "elastic", |
| 107 | + "elastic-infra": "elastic-infra", |
| 108 | + "ferlab-ste-justine": "ferlab-ste-justine", |
| 109 | + "ferlab-ste-justine": "ferlab-ste-justine", |
52 | 110 | "fivetran": "fivetran",
|
| 111 | + "flexibleenginecloud": "flexibleenginecloud", |
53 | 112 | "fortinetdev": "fortinetdev",
|
54 |
| - "Genesiscloud": "genesiscloud", |
| 113 | + "g-core": "g-core", |
| 114 | + "glesys": "glesys", |
55 | 115 | "goauthentik": "goauthentik",
|
56 |
| - "Grapl Security": "grapl_security", |
57 | 116 | "hashicorp": "hashicorp",
|
58 | 117 | "honeycombio": "honeycomb",
|
59 |
| - "Ian Wahbe": "ian_wahbe", |
60 |
| - "Impart Security": "impart_security", |
| 118 | + "hpe": "hpe", |
| 119 | + "ibm-cloud": "ibm-cloud", |
| 120 | + "imperva": "imperva", |
61 | 121 | "incident-io": "incident_io",
|
| 122 | + "infobloxopen": "infobloxopen", |
| 123 | + "ionos-cloud": "ionos-cloud", |
| 124 | + "iterative": "iterative", |
| 125 | + "jdamata": "jdamata", |
62 | 126 | "jfrog": "jfrog",
|
63 | 127 | "joneshf": "joneshf",
|
| 128 | + "juju": "juju", |
| 129 | + "k-yomo": "k-yomo", |
64 | 130 | "komminarlabs": "komminarlabs",
|
65 | 131 | "kong": "kong",
|
66 |
| - "Koyeb": "koyeb", |
67 | 132 | "labd": "labd",
|
| 133 | + "lacework": "lacework", |
68 | 134 | "lbrlabs": "lbrlabs",
|
69 |
| - "Lee Zen": "lee_zen", |
70 | 135 | "littlejo": "littlejo",
|
| 136 | + "logdna": "logdna", |
| 137 | + "logzio": "logzio", |
71 | 138 | "lucky3028": "lucky3028",
|
| 139 | + "mastercard": "mastercard", |
| 140 | + "maxlaverse": "maxlaverse", |
| 141 | + "megaport": "megaport", |
| 142 | + "mrolla": "mrolla", |
| 143 | + "nats-io": "nats-io", |
| 144 | + "netapp": "netapp", |
72 | 145 | "netlify": "netlify",
|
73 |
| - "Nuage-Studio": "nuage_studio", |
| 146 | + "octopusdeploylabs": "octopusdeploylabs", |
74 | 147 | "onelogin": "onelogin",
|
| 148 | + "opennebula": "opennebula", |
| 149 | + "opensearch-project": "opensearch-project", |
| 150 | + "opentelekomcloud": "opentelekomcloud", |
75 | 151 | "oun": "oun",
|
76 | 152 | "outscale": "outscale",
|
77 |
| - "OVHcloud": "ovhcloud", |
78 |
| - "Paul Stack": "paul_stack", |
| 153 | + "paloaltonetworks": "paloaltonetworks", |
| 154 | + "paloaltonetworks": "paloaltonetworks", |
| 155 | + "pan-net": "pan-net", |
| 156 | + "paultyng": "paultyng", |
79 | 157 | "pgEdge": "pgedge",
|
80 |
| - "Piers Karsenbarg": "piers_karsenbarg", |
| 158 | + "philips-software": "philips-software", |
81 | 159 | "pinecone-io": "pinecone",
|
82 | 160 | "planetscale": "planetscale",
|
83 | 161 | "port-labs": "port_labs",
|
84 | 162 | "prefecthq": "prefecthq",
|
85 |
| - "Prodvana": "prodvana", |
86 | 163 | "propelauth": "propelauth",
|
87 |
| - "Pulumi": "pulumi", |
88 | 164 | "pulumiverse - Marcel Arns": "pulumiverse",
|
89 | 165 | "pulumiverse": "pulumiverse",
|
90 |
| - "Pulumiverse": "pulumiverse", |
91 | 166 | "qdrant": "qdrant",
|
92 | 167 | "rancher": "rancher",
|
93 |
| - "RedisLabs": "redislabs", |
94 | 168 | "redpanda-data": "redpanda_data",
|
95 |
| - "Rootly": "rootly", |
96 |
| - "Runpod": "runpod", |
| 169 | + "rollbar": "rollbar", |
| 170 | + "selectel": "selectel", |
| 171 | + "spectrocloud": "spectrocloud", |
97 | 172 | "splightplatform": "splightplatform",
|
98 | 173 | "supabase": "supabase",
|
99 |
| - "Symbiosis": "symbiosis", |
| 174 | + "sysdiglabs": "sysdiglabs", |
100 | 175 | "temporalio": "temporalio",
|
| 176 | + "tencentcloudstack": "tencentcloudstack", |
101 | 177 | "terraform-lxd": "terraform_lxd",
|
102 |
| - "Theo Gravity": "theo_gravity", |
103 |
| - "Three141": "three141", |
104 |
| - "Threefold": "threefold", |
| 178 | + "terraform-routeros": "terraform-routeros", |
105 | 179 | "timescale": "timescale",
|
106 |
| - "Twingate": "twingate", |
107 |
| - "UpCloudLtd": "upcloudltd", |
108 |
| - "Upstash": "upstash", |
| 180 | + "ucloud": "ucloud", |
109 | 181 | "vantage-sh": "vantage-sh",
|
110 |
| - "Vates": "vates", |
111 |
| - "Volcengine": "volcengine", |
112 |
| - "Wttech": "wttech", |
| 182 | + "vk-cs": "vk-cs", |
| 183 | + "vmware": "vmware", |
| 184 | + "vmware": "vmware", |
| 185 | + "vmware": "vmware", |
| 186 | + "vmware": "vmware", |
| 187 | + "vmware": "vmware", |
113 | 188 | "zenduty": "zenduty",
|
114 |
| - "Zscaler": "zscaler", |
115 | 189 | }
|
116 | 190 |
|
| 191 | +has_failed = False |
| 192 | + |
117 | 193 | for filename in os.listdir(yaml_db_path):
|
118 | 194 | if not filename.endswith('.yaml'):
|
119 | 195 | continue
|
120 |
| - if target and target != filename.removesuffix(".yaml"): |
| 196 | + if args.target and args.target != filename.removesuffix(".yaml"): |
121 | 197 | continue
|
122 | 198 |
|
123 | 199 | filepath = os.path.join(yaml_db_path, filename)
|
|
140 | 216 | if publisher_display == "DEPRECATED":
|
141 | 217 | continue
|
142 | 218 | elif publisher_display not in publishers:
|
143 |
| - raise Exception(f"Missing publisher entry for {publisher_display}") |
| 219 | + raise Exception(f'Missing publisher entry for "{publisher_display}"') |
144 | 220 | publisher = publishers[publisher_display]
|
145 | 221 |
|
146 | 222 |
|
147 |
| - package_version_name = f"{source}/{publisher}/{name}@{version}" |
| 223 | + package_version_name = f"{source}/{publisher}/{name}@{version.removeprefix("v")}" |
148 | 224 | info(f"Preparing command for {package_version_name}")
|
149 | 225 |
|
150 | 226 | # We skip azure-native-v1, since it will (1) never be updated again and (2) isn't
|
|
155 | 231 | if name.startswith("azure-native") and name != "azure-native":
|
156 | 232 | continue
|
157 | 233 |
|
158 |
| - api_url = f"https://api.pulumi.com/api/registry/preview/packages/{source}/{publisher}/{name}/versions/{version}" |
159 |
| - existence_check = requests.head(api_url).status_code |
| 234 | + |
| 235 | + api_url = f"https://api.pulumi.com/api/preview/registry/packages/{source}/{publisher}/{name}/versions/{version.removeprefix("v")}" |
| 236 | + existence_check = requests.get(api_url, headers={ |
| 237 | + "Authorization": f"token {token}", |
| 238 | + }).status_code |
160 | 239 |
|
161 | 240 | if existence_check == 404:
|
162 | 241 | schema_file = os.path.join(tmpdir, name, "schema.json")
|
|
173 | 252 | else:
|
174 | 253 | schema = json.loads(response.content)
|
175 | 254 |
|
176 |
| - if "version" not in schema: |
| 255 | + |
| 256 | + if "version" not in schema or schema["version"] != version.removeprefix("v"): |
177 | 257 | schema["version"] = version.removeprefix("v")
|
178 |
| - json.dump(schema, sf) |
| 258 | + json.dump(schema, sf) |
| 259 | + |
179 | 260 |
|
180 | 261 | cmd = [
|
181 |
| - "pulumi", "package", "publish", schema_file, |
182 |
| - f"--readme={docs_path}/{name}/_index.md", |
183 |
| - f"--source={source}", |
184 |
| - f"--publisher={publisher}", |
| 262 | + "pulumi", "package", "publish", |
| 263 | + schema_file, |
| 264 | + "--readme", f"{docs_path}/{name}/_index.md", |
| 265 | + "--source", source, |
| 266 | + "--publisher", publisher, |
185 | 267 | ]
|
186 | 268 |
|
187 | 269 | if os.path.isfile(os.path.join(docs_path, name, "_installation-configuration.md")):
|
188 | 270 | cmd.extend(["--installation-configuration", f"{docs_path}/{name}/installation-configuration.md"])
|
189 | 271 |
|
190 |
| - run_script.append(' '.join(cmd)) |
| 272 | + if args.dry_run: |
| 273 | + print(" ".join(cmd)) |
| 274 | + else: |
| 275 | + try: |
| 276 | + subprocess.run(cmd, shell=False) |
| 277 | + except subprocess.CalledProcessError: |
| 278 | + warning(f"Failed to run {" ".join(cmd)}") |
| 279 | + has_failed=True |
| 280 | + |
| 281 | + os.remove(schema_file) |
| 282 | + os.removedirs(os.path.dirname(schema_file)) |
191 | 283 | elif existence_check == 200:
|
192 | 284 | info("Package already exists in the registry DB")
|
193 | 285 | else:
|
194 |
| - info(f"Unable to check on package {package_version_name}") |
195 |
| - exit(1) |
| 286 | + warning(f"Unable to check on package {package_version_name}") |
| 287 | + has_failed=True |
196 | 288 |
|
197 |
| -for cmd in run_script: |
198 |
| - print(cmd) |
| 289 | +if has_failed: |
| 290 | + exit(1) |
0 commit comments