|
38 | 38 | - 'inspect' |
39 | 39 | - '--bootstrap' |
40 | 40 | waitFor: ['multi_arch_step2'] |
| 41 | +{SCANNINGSTEPS} |
41 | 42 | {BUILDSTEPS} |
42 | 43 | # END OF PROD BUILDING STEPS |
43 | 44 | {MULTIARCH_BUILDSTEPS} |
|
59 | 60 |
|
60 | 61 | GCRIO_PROJECT='google.com/cloudsdktool' |
61 | 62 | GCR_PREFIXES = [('us-docker.pkg.dev', 'gcr.io'), ('us-docker.pkg.dev', 'us.gcr.io'), ('europe-docker.pkg.dev','eu.gcr.io'), ('asia-docker.pkg.dev', 'asia.gcr.io')] |
| 63 | +SCANNING_PREFIXES = [('us-docker.pkg.dev', 'scanning')] |
62 | 64 | DOCKERHUB_PREFIX='google' |
63 | 65 | OLD_NAME='cloud-sdk' |
64 | 66 | REBRAND_NAME='google-cloud-cli' |
65 | 67 | IMAGES=['alpine', 'debian_slim', 'default', 'debian_component_based', 'emulators', 'stable'] |
66 | 68 | MULTI_ARCH=['debian_slim', 'debian_component_based', 'alpine', 'emulators', 'stable'] |
| 69 | +SCANNING_IMAGES=['all_components'] |
67 | 70 | LABEL_FOR_IMAGE={ |
68 | 71 | 'alpine': 'alpine', |
69 | 72 | 'debian_slim': 'slim', |
70 | 73 | 'default': '', |
71 | 74 | 'debian_component_based': 'debian_component_based', |
72 | 75 | 'emulators': 'emulators', |
73 | | - 'stable': 'stable' # change it to stable when the image is ready to release. |
| 76 | + 'stable': 'stable', |
| 77 | + 'all_components': 'all_components' |
74 | 78 | } |
75 | 79 |
|
| 80 | +def MakeScanningTags (label): |
| 81 | + t = [] |
| 82 | + for gcr_prefix, gcr_suffix in SCANNING_PREFIXES: |
| 83 | + t.append( |
| 84 | + '\'{gcrprefix}/{gcrio_project}/{gcrio_suffix}/{rebrand_name}:{label}\'' |
| 85 | + .format(gcrprefix=gcr_prefix, |
| 86 | + gcrio_project=GCRIO_PROJECT, |
| 87 | + gcrio_suffix=gcr_suffix, |
| 88 | + rebrand_name=REBRAND_NAME, |
| 89 | + label=label)) |
| 90 | + return t |
| 91 | + |
76 | 92 | def MakeGcrTags(label_without_tag, |
77 | 93 | label_with_tag, |
78 | 94 | maybe_hypen, |
@@ -178,6 +194,32 @@ def MakeGcrTags(label_without_tag, |
178 | 194 | label_with_tag, |
179 | 195 | maybe_hypen, |
180 | 196 | include_old_name=False)) |
| 197 | +# Make scanning tags and save them |
| 198 | +scanning_tags={} |
| 199 | +for i in SCANNING_IMAGES: |
| 200 | + scanning_tags[i]=[] |
| 201 | + label_name = LABEL_FOR_IMAGE[i] |
| 202 | + if i == 'default': |
| 203 | + label_name = 'latest' |
| 204 | + scanning_tags[i].extend(MakeScanningTags(label_name)) |
| 205 | + |
| 206 | +scanning_steps='' |
| 207 | +for i in SCANNING_IMAGES: |
| 208 | + image_directory = '{}/'.format(i) |
| 209 | + if i == 'default': |
| 210 | + image_directory = '.' |
| 211 | + |
| 212 | + scanning_step = """- name: 'gcr.io/cloud-builders/docker' |
| 213 | + id: scanning_{image_name} |
| 214 | + args: ['build', '--build-arg', 'CLOUD_SDK_VERSION=$_CLI_VERSION', {scanning_tags}, '{image_directory}'] |
| 215 | + waitFor: ['-']""" |
| 216 | + output_scanning_step = scanning_step.format( |
| 217 | + image_name=i, |
| 218 | + scanning_tags=', '.join(['\'-t\', {}'.format(t) for t in scanning_tags[i]]), |
| 219 | + image_directory=image_directory) |
| 220 | + if len(scanning_steps) > 0: |
| 221 | + scanning_steps+='\n' |
| 222 | + scanning_steps+=output_scanning_step |
181 | 223 |
|
182 | 224 | build_steps='' |
183 | 225 | for i in IMAGES: |
@@ -230,12 +272,15 @@ def MakeGcrTags(label_without_tag, |
230 | 272 | all_images_tags=[] |
231 | 273 | for i in IMAGES: |
232 | 274 | all_images_tags.extend([t for t in tags[i] if not t.startswith('\'google/cloud-sdk')]) |
| 275 | +for i in SCANNING_IMAGES: |
| 276 | + all_images_tags.extend(t for t in scanning_tags[i]) |
233 | 277 | for tag in sorted(all_images_tags): |
234 | 278 | if len(all_gcr_io_tags_for_images) > 0: |
235 | 279 | all_gcr_io_tags_for_images+='\n' |
236 | 280 | all_gcr_io_tags_for_images+='- {}'.format(tag) |
237 | 281 |
|
238 | 282 | print(MAIN_TEMPLATE.format( |
| 283 | + SCANNINGSTEPS=scanning_steps, |
239 | 284 | BUILDSTEPS=build_steps, |
240 | 285 | MULTIARCH_BUILDSTEPS=multi_arch_build_steps, |
241 | 286 | DOCKER_PUSHSTEPS=docker_push_steps, |
|
0 commit comments