Skip to content

Commit

Permalink
chore: remove webhook warning about endpoint annotations being unsupp…
Browse files Browse the repository at this point in the history
…orted

Signed-off-by: Andrew Obuchowicz <[email protected]>
  • Loading branch information
AObuchow committed Aug 6, 2024
1 parent c17d089 commit 4fdb177
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ input:
annotation:
service:
key: value
endpoints:
- name: web
targetPort: 8080
exposure: public
annotation:
key: value
- name: projects
volume:
ephemeral: true
Expand All @@ -43,15 +37,11 @@ input:
custom:
componentClass: "some-component-class"
events:
preStop:
- eventA
- eventB
- eventC
postStop:
- eventD
- eventE
- eventF

output:
expectedWarning: "Unsupported Devfile features are present in this workspace. The following features will have no effect: components[].container.annotation.service, used by components: testing-container-1; components[].container.endpoints[].annotations, used by components: testing-container-1; components[].container.dedicatedPod, used by components: testing-container-1; components[].image, used by components: image-component; components[].custom, used by components: custom-component; events.postStop: eventD, eventE, eventF"
expectedWarning: "Unsupported Devfile features are present in this workspace. The following features will have no effect: components[].container.annotation.service, used by components: testing-container-1; components[].container.dedicatedPod, used by components: testing-container-1; components[].image, used by components: image-component; components[].custom, used by components: custom-component; events.postStop: eventD, eventE, eventF"
newWarningsPresent: true
13 changes: 0 additions & 13 deletions webhook/workspace/handler/warning.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (

type unsupportedWarnings struct {
serviceAnnotations map[string]bool
endpointAnnotations map[string]bool
dedicatedPod map[string]bool
imageComponent map[string]bool
customComponent map[string]bool
Expand All @@ -36,7 +35,6 @@ type unsupportedWarnings struct {
func newUnsupportedWarnings() *unsupportedWarnings {
return &unsupportedWarnings{
serviceAnnotations: make(map[string]bool),
endpointAnnotations: make(map[string]bool),
dedicatedPod: make(map[string]bool),
imageComponent: make(map[string]bool),
customComponent: make(map[string]bool),
Expand All @@ -51,11 +49,6 @@ func checkUnsupportedFeatures(devWorkspaceSpec dwv2.DevWorkspaceTemplateSpec) (w
if component.Container.Annotation != nil && component.Container.Annotation.Service != nil {
warnings.serviceAnnotations[component.Name] = true
}
for _, endpoint := range component.Container.Endpoints {
if endpoint.Annotations != nil {
warnings.endpointAnnotations[component.Name] = true
}
}
if component.Container.DedicatedPod != nil && *component.Container.DedicatedPod {
warnings.dedicatedPod[component.Name] = true
}
Expand All @@ -80,7 +73,6 @@ func checkUnsupportedFeatures(devWorkspaceSpec dwv2.DevWorkspaceTemplateSpec) (w

func unsupportedWarningsPresent(warnings *unsupportedWarnings) bool {
return len(warnings.serviceAnnotations) > 0 ||
len(warnings.endpointAnnotations) > 0 ||
len(warnings.dedicatedPod) > 0 ||
len(warnings.imageComponent) > 0 ||
len(warnings.customComponent) > 0 ||
Expand All @@ -104,10 +96,6 @@ func formatUnsupportedFeaturesWarning(warnings *unsupportedWarnings) string {
serviceAnnotationsMsg := "components[].container.annotation.service, used by components: " + strings.Join(getWarningNames(warnings.serviceAnnotations), ", ")
msg = append(msg, serviceAnnotationsMsg)
}
if len(warnings.endpointAnnotations) > 0 {
endpointAnnotationsMsg := "components[].container.endpoints[].annotations, used by components: " + strings.Join(getWarningNames(warnings.endpointAnnotations), ", ")
msg = append(msg, endpointAnnotationsMsg)
}
if len(warnings.dedicatedPod) > 0 {
dedicatedPodMsg := "components[].container.dedicatedPod, used by components: " + strings.Join(getWarningNames(warnings.dedicatedPod), ", ")
msg = append(msg, dedicatedPodMsg)
Expand Down Expand Up @@ -145,7 +133,6 @@ func checkForAddedUnsupportedFeatures(oldWksp, newWksp *dwv2.DevWorkspace) *unsu
}

addedWarnings.serviceAnnotations = getAddedWarnings(oldWarnings.serviceAnnotations, newWarnings.serviceAnnotations)
addedWarnings.endpointAnnotations = getAddedWarnings(oldWarnings.endpointAnnotations, newWarnings.endpointAnnotations)
addedWarnings.dedicatedPod = getAddedWarnings(oldWarnings.dedicatedPod, newWarnings.dedicatedPod)
addedWarnings.imageComponent = getAddedWarnings(oldWarnings.imageComponent, newWarnings.imageComponent)
addedWarnings.customComponent = getAddedWarnings(oldWarnings.customComponent, newWarnings.customComponent)
Expand Down

0 comments on commit 4fdb177

Please sign in to comment.