Skip to content

Commit

Permalink
Merge pull request #2349 from cbgbt/pause-container-update
Browse files Browse the repository at this point in the history
schnauzer: add new regions to pause registry map
  • Loading branch information
cbgbt authored Aug 15, 2022
2 parents e79d47b + 734cf04 commit d3d4017
Showing 1 changed file with 36 additions and 48 deletions.
84 changes: 36 additions & 48 deletions sources/api/schnauzer/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,23 @@ lazy_static! {
m.insert("ap-northeast-2", "602401143452");
m.insert("ap-northeast-3", "602401143452");
m.insert("ap-south-1", "602401143452");
m.insert("ap-south-2", "900889452093");
m.insert("ap-southeast-1", "602401143452");
m.insert("ap-southeast-2", "602401143452");
m.insert("ap-southeast-3", "296578399912");
m.insert("ap-southeast-4", "491585149902");
m.insert("ca-central-1", "602401143452");
m.insert("cn-north-1", "918309763551");
m.insert("cn-northwest-1", "961992271922");
m.insert("eu-central-1", "602401143452");
m.insert("eu-central-2", "900612956339");
m.insert("eu-north-1", "602401143452");
m.insert("eu-south-1", "590381155156");
m.insert("eu-south-2", "455263428931");
m.insert("eu-west-1", "602401143452");
m.insert("eu-west-2", "602401143452");
m.insert("eu-west-3", "602401143452");
m.insert("me-central-1", "759879836304");
m.insert("me-south-1", "558608220178");
m.insert("sa-east-1", "602401143452");
m.insert("us-east-1", "602401143452");
Expand Down Expand Up @@ -1840,56 +1845,39 @@ mod test_pause_registry {

const CONTAINER_TEMPLATE: &str = "{{ pause-prefix settings.aws.region }}/container:tag";

const EXPECTED_URL_EU_CENTRAL_1: &str =
"602401143452.dkr.ecr.eu-central-1.amazonaws.com/container:tag";

const EXPECTED_URL_AF_SOUTH_1: &str =
"877085696533.dkr.ecr.af-south-1.amazonaws.com/container:tag";

const EXPECTED_URL_XY_ZTOWN_1: &str =
"602401143452.dkr.ecr.us-east-1.amazonaws.com/container:tag";

const EXPECTED_URL_CN_NORTH_1: &str =
"918309763551.dkr.ecr.cn-north-1.amazonaws.com.cn/container:tag";

#[test]
fn url_eu_central_1() {
let result = setup_and_render_template(
CONTAINER_TEMPLATE,
&json!({"settings": {"aws": {"region": "eu-central-1"}}}),
)
.unwrap();
assert_eq!(result, EXPECTED_URL_EU_CENTRAL_1);
}

#[test]
fn url_af_south_1() {
let result = setup_and_render_template(
CONTAINER_TEMPLATE,
&json!({"settings": {"aws": {"region": "af-south-1"}}}),
)
.unwrap();
assert_eq!(result, EXPECTED_URL_AF_SOUTH_1);
}

#[test]
fn url_fallback() {
let result = setup_and_render_template(
CONTAINER_TEMPLATE,
&json!({"settings": {"aws": {"region": "xy-ztown-1"}}}),
)
.unwrap();
assert_eq!(result, EXPECTED_URL_XY_ZTOWN_1);
}
const PAUSE_REGISTRY_TESTS: &[(&str, &str)] = &[
(
"eu-central-1",
"602401143452.dkr.ecr.eu-central-1.amazonaws.com/container:tag",
),
(
"af-south-1",
"877085696533.dkr.ecr.af-south-1.amazonaws.com/container:tag",
),
(
"xy-ztown-1",
"602401143452.dkr.ecr.us-east-1.amazonaws.com/container:tag",
),
(
"cn-north-1",
"918309763551.dkr.ecr.cn-north-1.amazonaws.com.cn/container:tag",
),
(
"ap-southeast-4",
"491585149902.dkr.ecr.ap-southeast-4.amazonaws.com/container:tag",
),
];

#[test]
fn url_china() {
let result = setup_and_render_template(
CONTAINER_TEMPLATE,
&json!({"settings": {"aws": {"region": "cn-north-1"}}}),
)
.unwrap();
assert_eq!(result, EXPECTED_URL_CN_NORTH_1);
fn pause_container_registry() {
for (region, expected) in PAUSE_REGISTRY_TESTS {
let result = setup_and_render_template(
CONTAINER_TEMPLATE,
&json!({"settings": {"aws": {"region": *region}}}),
)
.unwrap();
assert_eq!(result, *expected);
}
}
}

Expand Down

0 comments on commit d3d4017

Please sign in to comment.