Skip to content

Commit

Permalink
Google Java Format
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Jul 20, 2023
1 parent 307014b commit dedbfa4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ public static String getTag(String imageName) {
/**
* Extracts the image path from a given container URL.
*
* The method takes a container URL string in the format [hostName]/[imagePath]:[tag] and returns
* the image path. This includes the namespace and image name but excludes the host and the tag.
* If no tag is present in the URL, the method will return the full image path.
* <p>The method takes a container URL string in the format [hostName]/[imagePath]:[tag] and
* returns the image path. This includes the namespace and image name but excludes the host and
* the tag. If no tag is present in the URL, the method will return the full image path.
*
* @param containerURL A string representing the container URL. Should be in the format [hostName]/[imageName]:[tag].
* @return A string representing the image path (i.e., namespace and image name) from the container URL.
* @param containerURL A string representing the container URL. Should be in the format
* [hostName]/[imageName]:[tag].
* @return A string representing the image path (i.e., namespace and image name) from the
* container URL.
*/
public static String getImagePath(String containerURL) {
String imageName = containerURL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ public boolean checkEcrImageExists(
* Creates a repository in Amazon ECR with the provided repository name. If a repository with the
* same name already exists, then nothing happens and operation succeeds.
*
* @param repositoryName the name of the repository to be created. This is without the registry part of URI:
* e.g. if full URL is aws_account_id.dkr.ecr.us-west-2.amazonaws.com/my-ns/my-repository:tag ,
* the repository name is "my-ns/my-repository"
* @param repositoryName the name of the repository to be created. This is without the registry
* part of URI: e.g. if full URL is
* aws_account_id.dkr.ecr.us-west-2.amazonaws.com/my-ns/my-repository:tag , the repository
* name is "my-ns/my-repository"
* @param awsCredentialsDTO the DTO containing AWS credentials information
* @throws ExternalSystemError if other exception occurs during repository creation with container
* registry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,8 @@ public boolean buildImage(

if (REGISTRY_TYPE_ECR.equalsIgnoreCase(registryType)) {
ecrRegistryInterface.createRepository(
DockerImageName.getImagePath(dockerRepositoryUrl)
+ "/"
+ dataJob.getName(),
awsCredentialsService.createTemporaryCredentials());
DockerImageName.getImagePath(dockerRepositoryUrl) + "/" + dataJob.getName(),
awsCredentialsService.createTemporaryCredentials());
}

var args =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,22 @@ void testGetTag() {

@Test
void testUpdateImageWithTag() {
assertEquals(
"domain:5000/name:tag2",
updateImageWithTag("domain:5000/name:tag", "tag2"));
assertEquals("domain:5000/name:tag2", updateImageWithTag("domain:5000/name:tag", "tag2"));
assertEquals("name:v5", updateImageWithTag("name:v1.0.1", "v5"));
assertEquals(
"foo.bar/name:v6", updateImageWithTag("foo.bar/name:v1.0.2", "v6"));
assertEquals("foo.bar/name:v6", updateImageWithTag("foo.bar/name:v1.0.2", "v6"));

assertEquals("name:tag", updateImageWithTag("name", "tag"));
assertEquals(
"domain:5000/name:tag", updateImageWithTag("domain:5000/name", "tag"));
assertEquals("domain:5000/name:tag", updateImageWithTag("domain:5000/name", "tag"));
}

@Test
public void testGetImageName() {
assertEquals("alpine", getImagePath("alpine:latest"));
assertEquals("image", getImagePath("gcr.io/image:latest"));
assertEquals("project/another-image", getImagePath("gcr.io/project/another-image:1.0.0"));
assertEquals("namespace/subnamespace/image",
getImagePath("registry.com/namespace/subnamespace/image:tag"));
assertEquals(
"namespace/subnamespace/image",
getImagePath("registry.com/namespace/subnamespace/image:tag"));
}

@Test
Expand All @@ -52,7 +49,7 @@ public void testGetImageNameWithNoTag() {

@Test
public void testGetImageNameWithPortInURL() {
assertEquals("my-namespace/my-image", getImagePath("localhost:5000/my-namespace/my-image:latest"));
assertEquals(
"my-namespace/my-image", getImagePath("localhost:5000/my-namespace/my-image:latest"));
}

}

0 comments on commit dedbfa4

Please sign in to comment.