@@ -37,6 +37,7 @@ lazy_static! {
37
37
m. insert( "ap-southeast-2" , "328549459982" ) ;
38
38
m. insert( "ap-southeast-3" , "386774335080" ) ;
39
39
m. insert( "ap-southeast-4" , "731751899352" ) ;
40
+ m. insert( "ap-southeast-5" , "851725293737" ) ;
40
41
m. insert( "ca-central-1" , "328549459982" ) ;
41
42
m. insert( "ca-west-1" , "253897149516" ) ;
42
43
m. insert( "cn-north-1" , "183470599484" ) ;
@@ -69,52 +70,6 @@ lazy_static! {
69
70
const ECR_FALLBACK_REGION : & str = "us-east-1" ;
70
71
const ECR_FALLBACK_REGISTRY : & str = "328549459982" ;
71
72
72
- lazy_static ! {
73
- /// A map to tell us which registry to pull pause container images from for a given region.
74
- static ref PAUSE_CONTAINER_MAP : HashMap <& ' static str , & ' static str > = {
75
- let mut m = HashMap :: new( ) ;
76
- m. insert( "af-south-1" , "877085696533" ) ;
77
- m. insert( "ap-east-1" , "800184023465" ) ;
78
- m. insert( "ap-northeast-1" , "602401143452" ) ;
79
- m. insert( "ap-northeast-2" , "602401143452" ) ;
80
- m. insert( "ap-northeast-3" , "602401143452" ) ;
81
- m. insert( "ap-south-1" , "602401143452" ) ;
82
- m. insert( "ap-south-2" , "900889452093" ) ;
83
- m. insert( "ap-southeast-1" , "602401143452" ) ;
84
- m. insert( "ap-southeast-2" , "602401143452" ) ;
85
- m. insert( "ap-southeast-3" , "296578399912" ) ;
86
- m. insert( "ap-southeast-4" , "491585149902" ) ;
87
- m. insert( "ca-central-1" , "602401143452" ) ;
88
- m. insert( "ca-west-1" , "761377655185" ) ;
89
- m. insert( "cn-north-1" , "918309763551" ) ;
90
- m. insert( "cn-northwest-1" , "961992271922" ) ;
91
- m. insert( "eu-central-1" , "602401143452" ) ;
92
- m. insert( "eu-central-2" , "900612956339" ) ;
93
- m. insert( "eu-north-1" , "602401143452" ) ;
94
- m. insert( "eu-south-1" , "590381155156" ) ;
95
- m. insert( "eu-south-2" , "455263428931" ) ;
96
- m. insert( "eu-west-1" , "602401143452" ) ;
97
- m. insert( "eu-west-2" , "602401143452" ) ;
98
- m. insert( "eu-west-3" , "602401143452" ) ;
99
- m. insert( "il-central-1" , "066635153087" ) ;
100
- m. insert( "me-central-1" , "759879836304" ) ;
101
- m. insert( "me-south-1" , "558608220178" ) ;
102
- m. insert( "sa-east-1" , "602401143452" ) ;
103
- m. insert( "us-east-1" , "602401143452" ) ;
104
- m. insert( "us-east-2" , "602401143452" ) ;
105
- m. insert( "us-gov-east-1" , "151742754352" ) ;
106
- m. insert( "us-gov-west-1" , "013241004608" ) ;
107
- m. insert( "us-west-1" , "602401143452" ) ;
108
- m. insert( "us-west-2" , "602401143452" ) ;
109
- m
110
- } ;
111
- }
112
-
113
- /// But if there is a region that does not exist in our map (for example a new
114
- /// region is created or being tested), then we will fall back to this.
115
- const PAUSE_FALLBACK_REGISTRY : & str = "602401143452" ;
116
- const PAUSE_FALLBACK_REGION : & str = "us-east-1" ;
117
-
118
73
lazy_static ! {
119
74
/// A map to tell us which endpoint to pull updates from for a given region.
120
75
static ref TUF_ENDPOINT_MAP : HashMap <& ' static str , & ' static str > = {
@@ -175,12 +130,6 @@ mod error {
175
130
template : String ,
176
131
} ,
177
132
178
- #[ snafu( display(
179
- "Expected ecr helper to be called with either 'registry' or 'region', got '{}'" ,
180
- value,
181
- ) ) ]
182
- EcrParam { value : String } ,
183
-
184
133
#[ snafu( display(
185
134
"Incorrect number of params provided to helper '{}' in template '{}' - {} expected, {} received" ,
186
135
helper,
@@ -782,59 +731,6 @@ pub fn ecr_prefix(
782
731
Ok ( ( ) )
783
732
}
784
733
785
- /// The `pause-prefix` helper is used to map an AWS region to the correct pause
786
- /// container registry.
787
- ///
788
- /// Because the repo URL includes the the registry number, we created this helper
789
- /// to lookup the correct registry number for a given region.
790
- ///
791
- /// This helper takes the AWS region as its only parameter, and returns the
792
- /// fully qualified domain name to the correct registry.
793
- ///
794
- /// # Fallback
795
- ///
796
- /// If we do not have the region in our map, a fallback region and registry number
797
- /// are returned. This would allow a version of Bottlerocket to run in a new region
798
- /// before this map has been updated.
799
- ///
800
- /// # Example
801
- ///
802
- /// In this example the registry number for the region will be returned.
803
- /// `{{ pause-prefix settings.aws.region }}`
804
- ///
805
- /// This would result in something like:
806
- /// `602401143452.dkr.ecr.eu-central-1.amazonaws.com`
807
- pub fn pause_prefix (
808
- helper : & Helper < ' _ , ' _ > ,
809
- _: & Handlebars ,
810
- _: & Context ,
811
- renderctx : & mut RenderContext < ' _ , ' _ > ,
812
- out : & mut dyn Output ,
813
- ) -> Result < ( ) , RenderError > {
814
- trace ! ( "Starting pause prefix helper" ) ;
815
- let template_name = template_name ( renderctx) ;
816
- check_param_count ( helper, template_name, 1 ) ?;
817
-
818
- // get the region parameter, which is probably given by the template value
819
- // settings.aws.region. regardless, we expect it to be a string.
820
- let aws_region = get_param ( helper, 0 ) ?;
821
- let aws_region = aws_region. as_str ( ) . with_context ( || error:: AwsRegionSnafu {
822
- value : aws_region. to_owned ( ) ,
823
- template : template_name,
824
- } ) ?;
825
-
826
- // construct the registry fqdn
827
- let pause_registry = pause_registry ( aws_region) ;
828
-
829
- // write it to the template
830
- out. write ( & pause_registry)
831
- . with_context ( |_| error:: TemplateWriteSnafu {
832
- template : template_name. to_owned ( ) ,
833
- } ) ?;
834
-
835
- Ok ( ( ) )
836
- }
837
-
838
734
/// The `tuf-prefix` helper is used to map an AWS region to the correct TUF
839
735
/// repository.
840
736
///
@@ -1863,24 +1759,6 @@ fn ecr_registry<S: AsRef<str>>(region: S) -> String {
1863
1759
}
1864
1760
}
1865
1761
1866
- /// Constructs the fully qualified domain name for the pause container (pod infra
1867
- /// container) for the given region. Returns a default if the region is not mapped.
1868
- fn pause_registry < S : AsRef < str > > ( region : S ) -> String {
1869
- // lookup the registry ID or fallback to the default region and id
1870
- let ( region, registry_id) = match PAUSE_CONTAINER_MAP . borrow ( ) . get ( region. as_ref ( ) ) {
1871
- None => ( PAUSE_FALLBACK_REGION , PAUSE_FALLBACK_REGISTRY ) ,
1872
- Some ( registry_id) => ( region. as_ref ( ) , * registry_id) ,
1873
- } ;
1874
- let partition = match ALT_PARTITION_MAP . borrow ( ) . get ( region) {
1875
- None => STANDARD_PARTITION ,
1876
- Some ( partition) => * partition,
1877
- } ;
1878
- match partition {
1879
- "aws-cn" => format ! ( "{}.dkr.ecr.{}.amazonaws.com.cn" , registry_id, region) ,
1880
- _ => format ! ( "{}.dkr.ecr.{}.amazonaws.com" , registry_id, region) ,
1881
- }
1882
- }
1883
-
1884
1762
/// Constructs the fully qualified domain name for the TUF repository for the
1885
1763
/// given region. Returns a default if the region is not mapped.
1886
1764
fn tuf_repository < S : AsRef < str > > ( region : S ) -> String {
@@ -2413,63 +2291,6 @@ mod test_ecr_registry {
2413
2291
}
2414
2292
}
2415
2293
2416
- #[ cfg( test) ]
2417
- mod test_pause_registry {
2418
- use super :: * ;
2419
- use handlebars:: RenderError ;
2420
- use serde:: Serialize ;
2421
- use serde_json:: json;
2422
-
2423
- // A thin wrapper around the handlebars render_template method that includes
2424
- // setup and registration of helpers
2425
- fn setup_and_render_template < T > ( tmpl : & str , data : & T ) -> Result < String , RenderError >
2426
- where
2427
- T : Serialize ,
2428
- {
2429
- let mut registry = Handlebars :: new ( ) ;
2430
- registry. register_helper ( "pause-prefix" , Box :: new ( pause_prefix) ) ;
2431
-
2432
- registry. render_template ( tmpl, data)
2433
- }
2434
-
2435
- const CONTAINER_TEMPLATE : & str = "{{ pause-prefix settings.aws.region }}/container:tag" ;
2436
-
2437
- const PAUSE_REGISTRY_TESTS : & [ ( & str , & str ) ] = & [
2438
- (
2439
- "eu-central-1" ,
2440
- "602401143452.dkr.ecr.eu-central-1.amazonaws.com/container:tag" ,
2441
- ) ,
2442
- (
2443
- "af-south-1" ,
2444
- "877085696533.dkr.ecr.af-south-1.amazonaws.com/container:tag" ,
2445
- ) ,
2446
- (
2447
- "xy-ztown-1" ,
2448
- "602401143452.dkr.ecr.us-east-1.amazonaws.com/container:tag" ,
2449
- ) ,
2450
- (
2451
- "cn-north-1" ,
2452
- "918309763551.dkr.ecr.cn-north-1.amazonaws.com.cn/container:tag" ,
2453
- ) ,
2454
- (
2455
- "ap-southeast-4" ,
2456
- "491585149902.dkr.ecr.ap-southeast-4.amazonaws.com/container:tag" ,
2457
- ) ,
2458
- ] ;
2459
-
2460
- #[ test]
2461
- fn pause_container_registry ( ) {
2462
- for ( region, expected) in PAUSE_REGISTRY_TESTS {
2463
- let result = setup_and_render_template (
2464
- CONTAINER_TEMPLATE ,
2465
- & json ! ( { "settings" : { "aws" : { "region" : * region} } } ) ,
2466
- )
2467
- . unwrap ( ) ;
2468
- assert_eq ! ( result, * expected) ;
2469
- }
2470
- }
2471
- }
2472
-
2473
2294
#[ cfg( test) ]
2474
2295
mod test_tuf_repository {
2475
2296
use super :: * ;
0 commit comments