-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfaeff6
commit c9192fc
Showing
5 changed files
with
41 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= | ||
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= | ||
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/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/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= | ||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,31 @@ | ||
package which_registry | ||
|
||
import "regexp" | ||
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) { | ||
// TODO: location check | ||
match, err := regexp.MatchString(".*-docker.pkg.dev", d) | ||
if err != nil { | ||
return false, err | ||
} | ||
return match, nil | ||
|
||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
package which_registry | ||
|
||
import "regexp" | ||
import ( | ||
"errors" | ||
"regexp" | ||
"strings" | ||
) | ||
|
||
// https://cloud.google.com/container-registry/docs/overview#registries | ||
func isGoogleContainerRegistry(d string) (bool, error) { | ||
// TODO: location check | ||
match, err := regexp.MatchString(".*gcr.io", d) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
if match { | ||
location := strings.Replace(d, "gcr.io", "", 1) | ||
if location == "" || location == "us." || location == "eu." || location == "asia." { | ||
return true, nil | ||
} | ||
return false, errors.New("Invalid location: " + location) | ||
} | ||
return match, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters