Skip to content

Commit ec690f5

Browse files
authored
Merge pull request #695 from mythi/PR-2021-045
webhooks: use common constant for plugin min version
2 parents b75b00e + c6b947e commit ec690f5

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

pkg/apis/deviceplugin/v1/dsadeviceplugin_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var (
3333
// dsadevicepluginlog is for logging in this package.
3434
dsadevicepluginlog = logf.Log.WithName("dsadeviceplugin-resource")
3535

36-
dsaMinVersion = version.MustParseSemantic("0.18.0")
36+
dsaMinVersion = version.MustParseSemantic(imageMinVersion)
3737
)
3838

3939
// SetupWebhookWithManager sets up a webhook for DsaDevicePlugin custom resources.
@@ -52,7 +52,7 @@ func (r *DsaDevicePlugin) Default() {
5252
dsadevicepluginlog.Info("default", "name", r.Name)
5353

5454
if len(r.Spec.Image) == 0 {
55-
r.Spec.Image = "intel/intel-dsa-plugin:0.18.0"
55+
r.Spec.Image = "intel/intel-dsa-plugin:" + dsaMinVersion.String()
5656
}
5757
}
5858

pkg/apis/deviceplugin/v1/fpgadeviceplugin_webhook.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var (
3333
// fpgadevicepluginlog is for logging in this package.
3434
fpgadevicepluginlog = logf.Log.WithName("fpgadeviceplugin-resource")
3535

36-
fpgaMinVersion = version.MustParseSemantic("0.19.0")
36+
fpgaMinVersion = version.MustParseSemantic(imageMinVersion)
3737
)
3838

3939
// SetupWebhookWithManager sets up a webhook for FpgaDevicePlugin custom resources.
@@ -52,11 +52,11 @@ func (r *FpgaDevicePlugin) Default() {
5252
fpgadevicepluginlog.Info("default", "name", r.Name)
5353

5454
if len(r.Spec.Image) == 0 {
55-
r.Spec.Image = "intel/intel-fpga-plugin:0.19.0"
55+
r.Spec.Image = "intel/intel-fpga-plugin:" + fpgaMinVersion.String()
5656
}
5757

5858
if len(r.Spec.InitImage) == 0 {
59-
r.Spec.InitImage = "intel/intel-fpga-initcontainer:0.19.0"
59+
r.Spec.InitImage = "intel/intel-fpga-initcontainer:" + fpgaMinVersion.String()
6060
}
6161
}
6262

pkg/apis/deviceplugin/v1/gpudeviceplugin_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var (
3333
// gpudevicepluginlog is for logging in this package.
3434
gpudevicepluginlog = logf.Log.WithName("gpudeviceplugin-resource")
3535

36-
gpuMinVersion = version.MustParseSemantic("0.18.0")
36+
gpuMinVersion = version.MustParseSemantic(imageMinVersion)
3737
)
3838

3939
// SetupWebhookWithManager sets up a webhook for GpuDevicePlugin custom resources.
@@ -52,7 +52,7 @@ func (r *GpuDevicePlugin) Default() {
5252
gpudevicepluginlog.Info("default", "name", r.Name)
5353

5454
if len(r.Spec.Image) == 0 {
55-
r.Spec.Image = "intel/intel-gpu-plugin:0.18.0"
55+
r.Spec.Image = "intel/intel-gpu-plugin:" + gpuMinVersion.String()
5656
}
5757
}
5858

pkg/apis/deviceplugin/v1/qatdeviceplugin_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var (
3333
// qatdevicepluginlog is for logging in this package.
3434
qatdevicepluginlog = logf.Log.WithName("qatdeviceplugin-resource")
3535

36-
qatMinVersion = version.MustParseSemantic("0.18.0")
36+
qatMinVersion = version.MustParseSemantic(imageMinVersion)
3737
)
3838

3939
// SetupWebhookWithManager sets up a webhook for QatDevicePlugin custom resources.
@@ -52,7 +52,7 @@ func (r *QatDevicePlugin) Default() {
5252
qatdevicepluginlog.Info("default", "name", r.Name)
5353

5454
if len(r.Spec.Image) == 0 {
55-
r.Spec.Image = "intel/intel-qat-plugin:0.18.0"
55+
r.Spec.Image = "intel/intel-qat-plugin:" + qatMinVersion.String()
5656
}
5757
}
5858

pkg/apis/deviceplugin/v1/sgxdeviceplugin_webhook.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var (
3333
// sgxdevicepluginlog is for logging in this package.
3434
sgxdevicepluginlog = logf.Log.WithName("sgxdeviceplugin-resource")
3535

36-
sgxMinVersion = version.MustParseSemantic("0.19.0")
36+
sgxMinVersion = version.MustParseSemantic(imageMinVersion)
3737
)
3838

3939
// SetupWebhookWithManager sets up a webhook for SgxDevicePlugin custom resources.
@@ -52,11 +52,11 @@ func (r *SgxDevicePlugin) Default() {
5252
sgxdevicepluginlog.Info("default", "name", r.Name)
5353

5454
if len(r.Spec.Image) == 0 {
55-
r.Spec.Image = "intel/intel-sgx-plugin:0.19.0"
55+
r.Spec.Image = "intel/intel-sgx-plugin:" + sgxMinVersion.String()
5656
}
5757

5858
if len(r.Spec.InitImage) == 0 {
59-
r.Spec.Image = "intel/intel-sgx-initcontainer:0.19.0"
59+
r.Spec.Image = "intel/intel-sgx-initcontainer:" + sgxMinVersion.String()
6060
}
6161
}
6262

pkg/apis/deviceplugin/v1/webhook_common.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import (
2222
"k8s.io/apimachinery/pkg/util/version"
2323
)
2424

25+
// common constants for webhooks.
26+
const imageMinVersion string = "0.21.0"
27+
2528
// common functions for webhooks
2629

2730
func validatePluginImage(image, expectedImageName string, expectedMinVersion *version.Version) error {

0 commit comments

Comments
 (0)