From 9a67b215f7f8d26c7f89dcb124a720f07745fb80 Mon Sep 17 00:00:00 2001 From: Ohki Nozomu Date: Sun, 13 Nov 2022 09:15:52 +0900 Subject: [PATCH] Remove validations (#22) --- ecr.go | 15 --------------- ecr_test.go | 19 ------------------- go.mod | 6 +----- go.sum | 12 ------------ google_artifact_registry.go | 13 ------------- 5 files changed, 1 insertion(+), 64 deletions(-) delete mode 100644 ecr_test.go diff --git a/ecr.go b/ecr.go index 8045876..9e589ad 100644 --- a/ecr.go +++ b/ecr.go @@ -1,24 +1,13 @@ package which_registry import ( - "errors" "strings" - - regions "github.com/jsonmaur/aws-regions/v2" ) func isECRPublic(domain string) bool { return domain == "public.ecr.aws" } -func validateRegion(region string) error { - _, err := regions.LookupByCode(region) - if err != nil { - return errors.New("Invalid Region: " + region) - } - return nil -} - // https://docs.aws.amazon.com/AmazonECR/latest/userguide/Registries.html#registry_concepts func isECRPrivate(d string) (bool, error) { s := strings.Split(d, ".") @@ -27,10 +16,6 @@ func isECRPrivate(d string) (bool, error) { } if s[1] == "dkr" && s[2] == "ecr" && s[4] == "amazonaws" && s[5] == "com" { - err := validateRegion(s[3]) - if err != nil { - return false, err - } return true, nil } return false, nil diff --git a/ecr_test.go b/ecr_test.go deleted file mode 100644 index 6855145..0000000 --- a/ecr_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package which_registry - -import ( - "testing" -) - -func TestValidateRegion(t *testing.T) { - region := "us-east-1" - err := validateRegion(region) - if err != nil { - t.Fatalf("failed test: %v\n", region) - } - - region = "us-east-1000000" - err = validateRegion(region) - if err.Error() != "Invalid Region: "+region { - t.Fatalf("failed test: %v\n", region) - } -} diff --git a/go.mod b/go.mod index 317c8ca..05ddca7 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,6 @@ module github.com/ohkinozomu/which-registry go 1.19 -require ( - github.com/docker/distribution v2.8.1+incompatible - github.com/jsonmaur/aws-regions/v2 v2.3.1 - github.com/ohkinozomu/gcp-regions v0.2.0 -) +require github.com/docker/distribution v2.8.1+incompatible require github.com/opencontainers/go-digest v1.0.0 // indirect diff --git a/go.sum b/go.sum index 7b2278e..8a45ef5 100644 --- a/go.sum +++ b/go.sum @@ -1,16 +1,4 @@ -github.com/docker/distribution v2.8.0+incompatible h1:l9EaZDICImO1ngI+uTifW+ZYvvz7fKISBAKpg+MbWbY= -github.com/docker/distribution v2.8.0+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/jsonmaur/aws-regions/v2 v2.3.1 h1:WWt452LyhjI4ZCRKBSULVHqIGE8/9UqVQOSAzuc2woE= -github.com/jsonmaur/aws-regions/v2 v2.3.1/go.mod h1:NqtmZ2wG5HkrTYFQ+II3BDysj0yek59yjtZjAaCn8lE= -github.com/ohkinozomu/gcp-regions v0.0.1 h1:OCOCPyhwIGMR6ao0bwIMQwz5rDMDRLN9O2SH3kvzuyw= -github.com/ohkinozomu/gcp-regions v0.0.1/go.mod h1:a69vJkNVbFBMhvI68qO36vYNC76eG9eWWBtoXIz5AaY= -github.com/ohkinozomu/gcp-regions v0.0.2 h1:zEU4/ejggS7+a6J/vOPvAHj0Lv8DD1oRnJ4bRP1Y9kk= -github.com/ohkinozomu/gcp-regions v0.0.2/go.mod h1:a69vJkNVbFBMhvI68qO36vYNC76eG9eWWBtoXIz5AaY= -github.com/ohkinozomu/gcp-regions v0.1.0 h1:Pv9EYoJB0TKGXlAukbcl+o70k7BQMb2XllExNDb7hLE= -github.com/ohkinozomu/gcp-regions v0.1.0/go.mod h1:5FiT3E0SVumwPdrxQnJvVHiSCXqyC2UCWiz3fyiospQ= -github.com/ohkinozomu/gcp-regions v0.2.0 h1:+tctsMjvtmVSlGkFK6Gwq/kWwNY4SLDEdMcNo5XnKQY= -github.com/ohkinozomu/gcp-regions v0.2.0/go.mod h1:5FiT3E0SVumwPdrxQnJvVHiSCXqyC2UCWiz3fyiospQ= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= diff --git a/google_artifact_registry.go b/google_artifact_registry.go index 2642e08..d98c839 100644 --- a/google_artifact_registry.go +++ b/google_artifact_registry.go @@ -1,18 +1,9 @@ package which_registry import ( - "errors" "regexp" - "strings" - - regions "github.com/ohkinozomu/gcp-regions" ) -// https://cloud.google.com/artifact-registry/docs/repo-locations#location-mr -func isMultiRegion(l string) bool { - return l == "asia" || l == "europe" || l == "us" -} - // https://cloud.google.com/artifact-registry/docs/docker/pushing-and-pulling#tag func isGoogleArtifactRegistry(d string) (bool, error) { match, err := regexp.MatchString(".*-docker.pkg.dev", d) @@ -21,10 +12,6 @@ func isGoogleArtifactRegistry(d string) (bool, error) { } if match { - location := strings.Replace(d, "-docker.pkg.dev", "", 1) - if !regions.IsValid(location) && !isMultiRegion(location) { - return false, errors.New("Invalid location: " + location) - } return true, nil } return false, nil