Skip to content

Commit

Permalink
fix: correctly handle tags with sha256
Browse files Browse the repository at this point in the history
  • Loading branch information
j4m3s-s committed Feb 8, 2022
1 parent 05ebfb1 commit 7646174
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: k8s-proxy-image-swapper
description: A Helm chart for Kubernetes
type: application
version: 0.3.1
appVersion: 0.3.1
version: 0.3.2
appVersion: 0.3.2
2 changes: 1 addition & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ replicaCount: 2
image:
repository: registry.example.com/toto/k8s-proxy-image-swapper
pullPolicy: IfNotPresent
tag: "v0.3.1"
tag: "v0.3.2"

# Change config.{tlskeypath,tlscertpath} accordingly if you change this
tlsdirpath: "/tls"
Expand Down
6 changes: 3 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
patch-docker-image-name = pkgs.buildGoModule {
CGO_ENABLED = "0";
pname = "patch-docker-image-name";
version = "0.1.0";
version = "0.1.1";

src = ./.;

Expand All @@ -22,7 +22,7 @@
normalize-docker-image-name = pkgs.buildGoModule {
CGO_ENABLED = "0";
pname = "normalize-docker-image-name";
version = "0.1.0";
version = "0.1.1";

src = ./.;

Expand All @@ -34,7 +34,7 @@
CGO_ENABLED = "0";

pname = "k8s-proxy-image-swapper";
version = "0.3.1";
version = "0.3.2";

src = ./.;

Expand Down
10 changes: 8 additions & 2 deletions mutate/mutate.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ type dockerImageUrl struct {
func getImgTag(img string) string {
imgTagArr := strings.Split(img, ":")
tag := "latest"
if len(imgTagArr) == 2 {
tag = imgTagArr[1]

if len(imgTagArr) != 1 {
tag = ""
for _, v := range(imgTagArr[1:]) {
tag += v + ":"
}
// remove last ":"
tag = tag[:len(tag) - 1]
}

return tag
Expand Down
5 changes: 5 additions & 0 deletions mutate/mutate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ func TestImage(t *testing.T) {
registry: "example.com",
expected: "gcr.io/toto/tata:titi",
},
{
image: "gcr.io/toto/tata:titi@sha256:XXXXX",
registry: "example.com",
expected: "gcr.io/toto/tata:titi@sha256:XXXXX",
},
}

for _, test := range testTable {
Expand Down

0 comments on commit 7646174

Please sign in to comment.