Skip to content

Commit

Permalink
Added source path information to image list and search. (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
brett19 committed Jan 30, 2024
1 parent 0589303 commit 72dd5c6
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 20 deletions.
16 changes: 11 additions & 5 deletions cmd/images-list.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import (
type ImagesListOutput []ImagesListOutput_Item

type ImagesListOutput_Item struct {
Source string `json:"source"`
Name string `json:"name"`
Source string `json:"source"`
Name string `json:"name"`
SourcePath string `json:"source-path"`
}

var imagesListCmd = &cobra.Command{
Expand All @@ -34,14 +35,19 @@ var imagesListCmd = &cobra.Command{
if !outputJson {
fmt.Printf("Images:\n")
for _, image := range images {
fmt.Printf(" %s [Source: %s]\n", image.Name, image.Source)
if image.SourcePath != "" {
fmt.Printf(" %s [Source: %s, Source Path: %s]\n", image.Name, image.Source, image.SourcePath)
} else {
fmt.Printf(" %s [Source: %s]\n", image.Name, image.Source)
}
}
} else {
var out ImagesListOutput
for _, image := range images {
out = append(out, ImagesListOutput_Item{
Source: image.Source,
Name: image.Name,
Source: image.Source,
Name: image.Name,
SourcePath: image.SourcePath,
})
}
helper.OutputJson(out)
Expand Down
16 changes: 11 additions & 5 deletions cmd/images-search.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import (
type ImagesSearchOutput []ImagesSearchOutput_Item

type ImagesSearchOutput_Item struct {
Source string `json:"source"`
Name string `json:"name"`
Source string `json:"source"`
Name string `json:"name"`
SourcePath string `json:"source-path"`
}

var imagesSearchCmd = &cobra.Command{
Expand Down Expand Up @@ -61,7 +62,11 @@ var imagesSearchCmd = &cobra.Command{
break
}

fmt.Printf(" %s [Source: %s]\n", image.Name, image.Source)
if image.SourcePath != "" {
fmt.Printf(" %s [Source: %s, Source Path: %s]\n", image.Name, image.Source, image.SourcePath)
} else {
fmt.Printf(" %s [Source: %s]\n", image.Name, image.Source)
}
}
} else {
var out ImagesSearchOutput
Expand All @@ -71,8 +76,9 @@ var imagesSearchCmd = &cobra.Command{
}

out = append(out, ImagesSearchOutput_Item{
Source: image.Source,
Name: image.Name,
Source: image.Source,
Name: image.Name,
SourcePath: image.SourcePath,
})
}
helper.OutputJson(out)
Expand Down
5 changes: 3 additions & 2 deletions deployment/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ type CollectionInfo struct {
}

type Image struct {
Source string
Name string
Source string
Name string
SourcePath string
}

type BlockNodeTrafficType string
Expand Down
10 changes: 6 additions & 4 deletions deployment/dockerdeploy/dockerhubimageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ func (p *DockerHubImageProvider) ListImages(ctx context.Context) ([]deployment.I
versionName := tagParts[1]

images = append(images, deployment.Image{
Source: "dockerhub",
Name: versionName,
Source: "dockerhub",
Name: versionName,
SourcePath: fmt.Sprintf("couchbase:%s", versionName),
})
}
}
Expand Down Expand Up @@ -111,8 +112,9 @@ func (p *DockerHubImageProvider) SearchImages(ctx context.Context, version strin
}

images = append(images, deployment.Image{
Source: "dockerhub",
Name: versionName,
Source: "dockerhub",
Name: versionName,
SourcePath: fmt.Sprintf("couchbase:%s", versionName),
})
}

Expand Down
10 changes: 6 additions & 4 deletions deployment/dockerdeploy/ghcrimageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ func (p *GhcrImageProvider) ListImages(ctx context.Context) ([]deployment.Image,
}

images = append(images, deployment.Image{
Source: "ghcr",
Name: versionName,
Source: "ghcr",
Name: versionName,
SourcePath: fmt.Sprintf("ghcr.io/cb-vanilla/server:%s", versionName),
})
}
}
Expand Down Expand Up @@ -140,8 +141,9 @@ func (p *GhcrImageProvider) SearchImages(ctx context.Context, version string) ([
}

images = append(images, deployment.Image{
Source: "ghcr",
Name: versionName,
Source: "ghcr",
Name: versionName,
SourcePath: fmt.Sprintf("ghcr.io/cb-vanilla/server:%s", versionName),
})
}

Expand Down

0 comments on commit 72dd5c6

Please sign in to comment.