|
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 |
| 15 | + |
| 16 | +basicConfig() |
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_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") |
| 29 | +parser.add_argument("--dry-run", action='store_true') |
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 |
|
117 | 191 | for filename in os.listdir(yaml_db_path): |
118 | 192 | if not filename.endswith('.yaml'): |
119 | 193 | continue |
120 | | - if target and target != filename.removesuffix(".yaml"): |
| 194 | + if args.target and args.target != filename.removesuffix(".yaml"): |
121 | 195 | continue |
122 | 196 |
|
123 | 197 | filepath = os.path.join(yaml_db_path, filename) |
|
140 | 214 | if publisher_display == "DEPRECATED": |
141 | 215 | continue |
142 | 216 | elif publisher_display not in publishers: |
143 | | - raise Exception(f"Missing publisher entry for {publisher_display}") |
| 217 | + raise Exception(f'Missing publisher entry for "{publisher_display}"') |
144 | 218 | publisher = publishers[publisher_display] |
145 | 219 |
|
146 | 220 |
|
147 | | - package_version_name = f"{source}/{publisher}/{name}@{version}" |
| 221 | + package_version_name = f"{source}/{publisher}/{name}@{version.removeprefix("v")}" |
148 | 222 | info(f"Preparing command for {package_version_name}") |
149 | 223 |
|
150 | 224 | # We skip azure-native-v1, since it will (1) never be updated again and (2) isn't |
|
155 | 229 | if name.startswith("azure-native") and name != "azure-native": |
156 | 230 | continue |
157 | 231 |
|
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 |
| 232 | + |
| 233 | + api_url = f"https://api.pulumi.com/api/preview/registry/packages/{source}/{publisher}/{name}/versions/{version.removeprefix("v")}" |
| 234 | + existence_check = requests.get(api_url, headers={ |
| 235 | + "Authorization": f"token {token}", |
| 236 | + }).status_code |
160 | 237 |
|
161 | 238 | if existence_check == 404: |
162 | 239 | schema_file = os.path.join(tmpdir, name, "schema.json") |
|
175 | 252 |
|
176 | 253 | if "version" not in schema: |
177 | 254 | schema["version"] = version.removeprefix("v") |
178 | | - json.dump(schema, sf) |
| 255 | + json.dump(schema, sf) |
179 | 256 |
|
180 | 257 | cmd = [ |
181 | | - "pulumi", "package", "publish", schema_file, |
182 | | - f"--readme={docs_path}/{name}/_index.md", |
183 | | - f"--source={source}", |
184 | | - f"--publisher={publisher}", |
| 258 | + "/Users/ianwahbe/.pulumi/bin/pulumi", "package", "publish", |
| 259 | + schema_file, |
| 260 | + "--readme", f"{docs_path}/{name}/_index.md", |
| 261 | + "--source", source, |
| 262 | + "--publisher", publisher, |
185 | 263 | ] |
186 | 264 |
|
187 | 265 | if os.path.isfile(os.path.join(docs_path, name, "_installation-configuration.md")): |
188 | 266 | cmd.extend(["--installation-configuration", f"{docs_path}/{name}/installation-configuration.md"]) |
189 | 267 |
|
190 | | - run_script.append(' '.join(cmd)) |
| 268 | + if args.dry_run: |
| 269 | + print(" ".join(cmd)) |
| 270 | + else: |
| 271 | + try: |
| 272 | + subprocess.run(cmd, shell=False) |
| 273 | + except subprocess.CalledProcessError: |
| 274 | + warning(f"Failed to run {" ".join(cmd)}") |
| 275 | + |
| 276 | + os.remove(schema_file) |
| 277 | + os.removedirs(os.path.dirname(schema_file)) |
191 | 278 | elif existence_check == 200: |
192 | 279 | info("Package already exists in the registry DB") |
193 | 280 | else: |
194 | 281 | info(f"Unable to check on package {package_version_name}") |
195 | 282 | exit(1) |
196 | | - |
197 | | -for cmd in run_script: |
198 | | - print(cmd) |
|
0 commit comments