@@ -407,12 +407,24 @@ def make_channel_artifacts(metadata):
407
407
# Add templates for the default variant.
408
408
# Use keyword args to make not matching ordering a loud error around changes.
409
409
with logger .scope ("Creating {} deploy tools" .format (module .__name__ )):
410
+ # TODO(cmaloney): Cleanup by just having this make and pass another source.
411
+ module_specific_variant_arguments = copy .deepcopy (variant_arguments )
412
+ for arg_dict in module_specific_variant_arguments .values ():
413
+ if module .__name__ == 'gen.build_deploy.aws' :
414
+ arg_dict ['cloudformation_s3_url_full' ] = metadata ['cloudformation_s3_url_full' ]
415
+ elif module .__name__ == 'gen.build_deploy.azure' :
416
+ arg_dict ['azure_download_url' ] = metadata ['azure_download_url' ]
417
+ elif module .__name__ == 'gen.build_deploy.bash' :
418
+ pass
419
+ else :
420
+ raise NotImplementedError ("Unknown how to add args to deploy tool: {}" .format (module .__name__ ))
421
+
410
422
for built_resource in module .do_create (
411
423
tag = metadata ['tag' ],
412
424
build_name = metadata ['build_name' ],
413
425
reproducible_artifact_path = metadata ['reproducible_artifact_path' ],
414
426
commit = metadata ['commit' ],
415
- variant_arguments = variant_arguments ,
427
+ variant_arguments = module_specific_variant_arguments ,
416
428
all_bootstraps = metadata ["all_bootstraps" ]):
417
429
418
430
assert isinstance (built_resource , dict ), built_resource
@@ -543,7 +555,32 @@ def do_build_packages(cache_repository_url):
543
555
return result
544
556
545
557
546
- def set_repository_metadata (repository , metadata , storage_providers , preferred_provider ):
558
+ def get_azure_download_url (config ) -> str :
559
+ # TODO: HACK. Stashing and pulling the config from release/__init__.py
560
+ # is definitely not the right way to do this.
561
+ # See also gen/build_deploy/aws.py#get_cloudformation_s3_url
562
+
563
+ if 'storage' not in config :
564
+ raise RuntimeError ("No storage section in configuration" )
565
+
566
+ if 'azure' not in config ['storage' ]:
567
+ # No azure storage, inject a fake url for now so if people want to use
568
+ # the azure templates they know to come look here.
569
+ return "https://AZURE NOT CONFIGURED, ADD A storage.azure section to " \
570
+ "dcos-release.config.yaml to use the Azure templates"
571
+
572
+ if 'download_url' not in config ['storage' ]['azure' ]:
573
+ raise RuntimeError ("No download_url section in azure configuration" )
574
+
575
+ download_url = config ['storage' ]['azure' ]['download_url' ]
576
+
577
+ if not download_url .endswith ('/' ):
578
+ raise RuntimeError ("Azure download_url must end with a '/'" )
579
+
580
+ return download_url
581
+
582
+
583
+ def set_repository_metadata (repository , metadata , storage_providers , preferred_provider , config ) -> None :
547
584
metadata ['repository_path' ] = repository .path_prefix [:- 1 ]
548
585
metadata ['repository_url' ] = preferred_provider .url + repository .path_prefix [:- 1 ]
549
586
metadata ['build_name' ] = repository .path_channel_prefix [:- 1 ]
@@ -552,8 +589,17 @@ def set_repository_metadata(repository, metadata, storage_providers, preferred_p
552
589
for name , store in storage_providers .items ():
553
590
metadata ['storage_urls' ][name ] = store .url
554
591
555
- # Explicitly returning none since we modify in place
556
- return None
592
+ if 'options' not in config :
593
+ raise RuntimeError ("No options section in configuration" )
594
+
595
+ if 'cloudformation_s3_url' not in config ['options' ]:
596
+ raise RuntimeError ("No options.cloudformation_s3_url section in configuration" )
597
+
598
+ # TODO(cmaloney): get_session shouldn't live in release.storage
599
+ metadata ['cloudformation_s3_url_full' ] = config ['options' ]['cloudformation_s3_url' ] + \
600
+ '/{}/cloudformation' .format (metadata ['reproducible_artifact_path' ])
601
+
602
+ metadata ['azure_download_url' ] = get_azure_download_url (config )
557
603
558
604
559
605
def call_matching_arguments (function , arguments , allow_unused = False ):
@@ -710,7 +756,8 @@ def promote(self, src_channel, destination_repository, destination_channel):
710
756
self .fetch_key_artifacts (metadata )
711
757
712
758
repository = Repository (destination_repository , destination_channel , 'commit/{}' .format (metadata ['commit' ]))
713
- set_repository_metadata (repository , metadata , self .__storage_providers , self .__preferred_provider )
759
+ set_repository_metadata (
760
+ repository , metadata , self .__storage_providers , self .__preferred_provider , self .__config )
714
761
assert 'tag' in metadata
715
762
del metadata ['channel_artifacts' ]
716
763
@@ -757,7 +804,8 @@ def create(self, repository_path, channel, tag):
757
804
assert bootstrap_active_packages <= set (info ['packages' ])
758
805
759
806
repository = Repository (repository_path , channel , 'commit/{}' .format (metadata ['commit' ]))
760
- set_repository_metadata (repository , metadata , self .__storage_providers , self .__preferred_provider )
807
+ set_repository_metadata (
808
+ repository , metadata , self .__storage_providers , self .__preferred_provider , self .__config )
761
809
metadata ['tag' ] = tag
762
810
assert 'channel_artifacts' not in metadata
763
811
@@ -834,8 +882,8 @@ def main():
834
882
sys .exit (1 )
835
883
836
884
try :
837
- # TODO(cmaloney): HACK. This is so we can get to the config for aws
838
- # inside gen/build_deploy/aws.py
885
+ # TODO(cmaloney): HACK. This is so we can get to the config for aws and azure template
886
+ # testing inside gen/build_deploy/{ aws,azure} .py
839
887
global _config
840
888
config = load_config (options .config )
841
889
_config = config
0 commit comments