Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 11 additions & 5 deletions pkg/app/piped/platformprovider/ecs/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,18 @@ func FindImageTag(taskDefinition types.TaskDefinition) (string, error) {
}

func parseContainerImage(image string) (name, tag string) {
parts := strings.Split(image, ":")
if len(parts) == 2 {
tag = parts[1]
paths := strings.Split(image, "/")
lastSegment := paths[len(paths)-1]

idx := strings.LastIndex(lastSegment, ":")
if idx == -1 {
name = lastSegment
tag = ""
return
}
paths := strings.Split(parts[0], "/")
name = paths[len(paths)-1]

name = lastSegment[:idx]
tag = lastSegment[idx+1:]
return
}

Expand Down
36 changes: 36 additions & 0 deletions pkg/app/piped/platformprovider/ecs/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,42 @@ func TestFindArtifactVersions(t *testing.T) {
expected []*model.ArtifactVersion
expectedErr bool
}{
{
name: "image with registry port",
input: []byte(`
{
"family": "nginx-canary-fam-1",
"compatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"memory": 512,
"cpu": 256,
"containerDefinitions" : [
{
"image": "localhost:5000/pipecd/helloworld:v1.0.0",
"name": "helloworld",
"portMappings": [
{
"containerPort": 80,
"hostPort": 9085,
"protocol": "tcp"
}
]
}
]
}
`),
expected: []*model.ArtifactVersion{
{
Kind: model.ArtifactVersion_CONTAINER_IMAGE,
Version: "v1.0.0",
Name: "helloworld",
Url: "localhost:5000/pipecd/helloworld:v1.0.0",
},
},
expectedErr: false,
},
{
name: "ok",
input: []byte(`
Expand Down