Skip to content

Commit c527a43

Browse files
committed
Drop unused related image environment variables
Drop RELATED_IMAGE_* environment variables for images that are no longer used in DevWorkspace Operator. Signed-off-by: Angel Misevski <amisevsk@redhat.com>
1 parent 62e866b commit c527a43

3 files changed

Lines changed: 4 additions & 59 deletions

File tree

deploy/templates/components/manager/manager.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ spec:
8282
value: 200m
8383
- name: WEBHOOKS_SERVER_CPU_REQUEST
8484
value: 100m
85-
- name: RELATED_IMAGE_plugin_redhat_developer_web_terminal_4_5_0
86-
value: "quay.io/eclipse/che-machine-exec:nightly"
87-
- name: RELATED_IMAGE_web_terminal_tooling
88-
value: "quay.io/wto/web-terminal-tooling:latest"
8985
- name: RELATED_IMAGE_devworkspace_webhook_server
9086
value: "quay.io/devfile/devworkspace-controller:next"
9187
- name: RELATED_IMAGE_pvc_cleanup_job

internal/images/image.go

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414
//
15+
1516
// Package images is intended to support deploying the operator on restricted networks. It contains
1617
// utilities for translating images referenced by environment variables to regular image references,
1718
// allowing images that are defined by a tag to be replaced by digests automatically. This allows all
@@ -25,18 +26,13 @@ package images
2526
import (
2627
"fmt"
2728
"os"
28-
"regexp"
2929

30-
dw "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
3130
logf "sigs.k8s.io/controller-runtime/pkg/log"
3231
)
3332

3433
var log = logf.Log.WithName("container-images")
3534

36-
var envRegexp = regexp.MustCompile(`\${(RELATED_IMAGE_.*)}`)
37-
3835
const (
39-
webTerminalToolingImageEnvVar = "RELATED_IMAGE_web_terminal_tooling"
4036
webhookServerImageEnvVar = "RELATED_IMAGE_devworkspace_webhook_server"
4137
kubeRBACProxyImageEnvVar = "RELATED_IMAGE_kube_rbac_proxy"
4238
pvcCleanupJobImageEnvVar = "RELATED_IMAGE_pvc_cleanup_job"
@@ -67,17 +63,6 @@ func GetKubeRBACProxyImage() string {
6763
return val
6864
}
6965

70-
// GetWebTerminalToolingImage returns the image reference for the default web tooling image. Returns
71-
// the empty string if environment variable RELATED_IMAGE_web_terminal_tooling is not defined
72-
func GetWebTerminalToolingImage() string {
73-
val, ok := os.LookupEnv(webTerminalToolingImageEnvVar)
74-
if !ok {
75-
log.Error(fmt.Errorf("environment variable %s is not set", webTerminalToolingImageEnvVar), "Could not get web terminal tooling image")
76-
return ""
77-
}
78-
return val
79-
}
80-
8166
// GetPVCCleanupJobImage returns the image reference for the PVC cleanup job used to clean workspace
8267
// files from the common PVC in a namespace.
8368
func GetPVCCleanupJobImage() string {
@@ -107,48 +92,11 @@ func GetAsyncStorageSidecarImage() string {
10792
return val
10893
}
10994

110-
func GetProjectClonerImage() string {
95+
func GetProjectCloneImage() string {
11196
val, ok := os.LookupEnv(projectCloneImageEnvVar)
11297
if !ok {
11398
log.Info(fmt.Sprintf("Could not get initial project clone image: environment variable %s is not set", projectCloneImageEnvVar))
11499
return ""
115100
}
116101
return val
117102
}
118-
119-
// FillPluginEnvVars replaces plugin devworkspaceTemplate .spec.components[].container.image environment
120-
// variables of the form ${RELATED_IMAGE_*} with values from environment variables with the same name.
121-
//
122-
// Returns error if any referenced environment variable is undefined.
123-
func FillPluginEnvVars(pluginDWT *dw.DevWorkspaceTemplate) (*dw.DevWorkspaceTemplate, error) {
124-
for idx, component := range pluginDWT.Spec.Components {
125-
if component.Container == nil {
126-
continue
127-
}
128-
img, err := getImageForEnvVar(component.Container.Image)
129-
if err != nil {
130-
return nil, err
131-
}
132-
pluginDWT.Spec.Components[idx].Container.Image = img
133-
}
134-
return pluginDWT, nil
135-
}
136-
137-
func isImageEnvVar(query string) bool {
138-
return envRegexp.MatchString(query)
139-
}
140-
141-
func getImageForEnvVar(envStr string) (string, error) {
142-
if !isImageEnvVar(envStr) {
143-
// Value passed in is not env var, return unmodified
144-
return envStr, nil
145-
}
146-
matches := envRegexp.FindStringSubmatch(envStr)
147-
env := matches[1]
148-
val, ok := os.LookupEnv(env)
149-
if !ok {
150-
log.Info(fmt.Sprintf("Environment variable '%s' is unset. Cannot determine image to use", env))
151-
return "", fmt.Errorf("environment variable %s is unset", env)
152-
}
153-
return val, nil
154-
}

pkg/library/projects/clone.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414
//
15+
1516
// Package projects defines library functions for reconciling projects in a Devfile (i.e. cloning and maintaining state)
1617
package projects
1718

@@ -43,7 +44,7 @@ func GetProjectCloneInitContainer(workspace *dw.DevWorkspaceTemplateSpec, pullPo
4344
return nil, nil
4445
}
4546

46-
cloneImage := images.GetProjectClonerImage()
47+
cloneImage := images.GetProjectCloneImage()
4748
if cloneImage == "" {
4849
// Assume project clone is intentionally disabled if project clone image is not defined
4950
return nil, nil

0 commit comments

Comments
 (0)