Skip to content

Commit f7ca041

Browse files
committed
Use fallback image tag
1 parent 52e644e commit f7ca041

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

cmd/gateway/commands.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"runtime/debug"
88
"strconv"
9+
"strings"
910
"time"
1011

1112
"github.com/spf13/cobra"
@@ -674,13 +675,19 @@ func createGatewayPodConfig(version, svcName string) (config.GatewayPodConfig, e
674675
return config.GatewayPodConfig{}, err
675676
}
676677

678+
// use image tag version if set, otherwise fall back to binary version
679+
ngfVersion := version
680+
if imageParts := strings.Split(image, ":"); len(imageParts) == 2 {
681+
ngfVersion = imageParts[1]
682+
}
683+
677684
c := config.GatewayPodConfig{
678685
ServiceName: svcName,
679686
Namespace: ns,
680687
Name: name,
681688
UID: podUID,
682689
InstanceName: instance,
683-
Version: version,
690+
Version: ngfVersion,
684691
Image: image,
685692
}
686693

cmd/gateway/commands_test.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -683,13 +683,21 @@ func TestCreateGatewayPodConfig(t *testing.T) {
683683
Name: "my-pod",
684684
UID: "1234",
685685
InstanceName: "my-pod-xyz",
686-
Version: version,
686+
Version: "tag",
687687
Image: "my-pod-image:tag",
688688
}
689689
cfg, err := createGatewayPodConfig(version, "svc")
690690
g.Expect(err).To(Not(HaveOccurred()))
691691
g.Expect(cfg).To(Equal(expCfg))
692692

693+
// unset image tag and use provided version
694+
g.Expect(os.Setenv("IMAGE_NAME", "my-pod-image")).To(Succeed())
695+
expCfg.Version = version
696+
expCfg.Image = "my-pod-image"
697+
cfg, err = createGatewayPodConfig(version, "svc")
698+
g.Expect(err).To(Not(HaveOccurred()))
699+
g.Expect(cfg).To(Equal(expCfg))
700+
693701
// unset image name
694702
g.Expect(os.Unsetenv("IMAGE_NAME")).To(Succeed())
695703
cfg, err = createGatewayPodConfig(version, "svc")

internal/mode/static/provisioner/objects.go

-2
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,6 @@ func (p *NginxProvisioner) buildNginxPodTemplateSpec(
456456

457457
func (p *NginxProvisioner) buildImage(nProxyCfg *graph.EffectiveNginxProxy) (string, corev1.PullPolicy) {
458458
image := defaultNginxImagePath
459-
// TODO(sberman): maybe default image tag should just be the tag on the control plane image,
460-
// instead of version
461459
tag := p.cfg.GatewayPodConfig.Version
462460
pullPolicy := defaultImagePullPolicy
463461

0 commit comments

Comments
 (0)