Skip to content

Commit fdd464a

Browse files
authored
fix: harness image name generation (#195)
* fix: harness image generation * update logic * fix job stack ctrl unit test
1 parent a75f804 commit fdd464a

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

pkg/controller/stacks/job.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"strings"
88

99
console "github.com/pluralsh/console-client-go"
10-
consoleclient "github.com/pluralsh/deployment-operator/pkg/client"
1110
"github.com/pluralsh/polly/algorithms"
1211
"github.com/samber/lo"
1312
batchv1 "k8s.io/api/batch/v1"
@@ -16,6 +15,8 @@ import (
1615
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1716
"k8s.io/apimachinery/pkg/types"
1817
"sigs.k8s.io/controller-runtime/pkg/log"
18+
19+
consoleclient "github.com/pluralsh/deployment-operator/pkg/client"
1920
)
2021

2122
const (
@@ -33,11 +34,11 @@ var (
3334
}
3435

3536
defaultContainerVersions = map[console.StackType]string{
36-
console.StackTypeTerraform: "latest",
37+
console.StackTypeTerraform: "1.8.2",
3738
console.StackTypeAnsible: "latest",
3839
}
3940

40-
defaultImageTag = "0.4.28"
41+
defaultImageTag = "0.4.29"
4142
)
4243

4344
func init() {
@@ -191,15 +192,16 @@ func (r *StackReconciler) getDefaultContainer(run *console.StackRunFragment) cor
191192

192193
func (r *StackReconciler) getDefaultContainerImage(run *console.StackRunFragment) string {
193194
image := defaultContainerImages[run.Type]
194-
if run.Configuration != nil && run.Configuration.Image != nil && *run.Configuration.Image != "" {
195-
image = *run.Configuration.Image
196-
}
197-
198195
version := defaultContainerVersions[run.Type]
199196
if run.Configuration != nil && run.Configuration.Version != "" {
200197
version = run.Configuration.Version
201198
}
202199

200+
if run.Configuration != nil && run.Configuration.Image != nil && *run.Configuration.Image != "" {
201+
image = *run.Configuration.Image
202+
return fmt.Sprintf("%s:%s", image, version)
203+
}
204+
203205
return fmt.Sprintf("%s:%s-%s-%s", image, defaultImageTag, strings.ToLower(string(run.Type)), version)
204206
}
205207

pkg/controller/stacks/job_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import (
55
"time"
66

77
console "github.com/pluralsh/console-client-go"
8-
"github.com/pluralsh/deployment-operator/pkg/test/mocks"
98
"github.com/stretchr/testify/assert"
109
"sigs.k8s.io/controller-runtime/pkg/client"
10+
11+
"github.com/pluralsh/deployment-operator/pkg/test/mocks"
1112
)
1213

1314
func TestGetDefaultContainerImage(t *testing.T) {
@@ -23,5 +24,5 @@ func TestGetDefaultContainerImage(t *testing.T) {
2324
}
2425

2526
img := reconciler.getDefaultContainerImage(run)
26-
assert.Equal(t, img, "ghcr.io/pluralsh/harness:0.4.28-terraform-1.8.4")
27+
assert.Equal(t, img, "ghcr.io/pluralsh/harness:0.4.29-terraform-1.8.4")
2728
}

0 commit comments

Comments
 (0)