Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schnauzer: add new regions to pause registry map #2349

Merged
merged 1 commit into from
Aug 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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