-
Notifications
You must be signed in to change notification settings - Fork 547
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix deprecated installPlan step resource test
Signed-off-by: Alexander Greene <[email protected]>
- Loading branch information
Showing
8 changed files
with
145 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package catalog | ||
|
||
const ( | ||
PrometheusRuleKind = "PrometheusRule" | ||
ServiceMonitorKind = "ServiceMonitor" | ||
PodDisruptionBudgetKind = "PodDisruptionBudget" | ||
PriorityClassKind = "PriorityClass" | ||
VerticalPodAutoscalerKind = "VerticalPodAutoscaler" | ||
ConsoleYAMLSampleKind = "ConsoleYAMLSample" | ||
ConsoleQuickStartKind = "ConsoleQuickStart" | ||
ConsoleCLIDownloadKind = "ConsoleCLIDownload" | ||
ConsoleLinkKind = "ConsoleLink" | ||
) | ||
|
||
var supportedKinds = map[string]struct{}{ | ||
PrometheusRuleKind: {}, | ||
ServiceMonitorKind: {}, | ||
PodDisruptionBudgetKind: {}, | ||
PriorityClassKind: {}, | ||
VerticalPodAutoscalerKind: {}, | ||
ConsoleYAMLSampleKind: {}, | ||
ConsoleQuickStartKind: {}, | ||
ConsoleCLIDownloadKind: {}, | ||
ConsoleLinkKind: {}, | ||
} | ||
|
||
// isSupported returns true if OLM supports this type of CustomResource. | ||
func isSupported(kind string) bool { | ||
_, ok := supportedKinds[kind] | ||
return ok | ||
} |
9 changes: 9 additions & 0 deletions
9
pkg/controller/operators/catalog/supportedresourcesoveride.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package catalog | ||
|
||
const ( | ||
DeprecatedKind = "Deprecated" | ||
) | ||
|
||
func init() { | ||
supportedKinds[DeprecatedKind] = struct{}{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: operators.io.operator-framework/v1 | ||
kind: Deprecated | ||
metadata: | ||
namespace: placeholder | ||
name: foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
e2e.testName: Install Plan when an InstallPlan step contains a deprecated resource | ||
version increments a metric counting the warning | ||
name: deprecateds.operators.io.operator-framework | ||
spec: | ||
conversion: | ||
strategy: None | ||
group: operators.io.operator-framework | ||
names: | ||
kind: Deprecated | ||
listKind: DeprecatedList | ||
plural: deprecateds | ||
singular: deprecated | ||
scope: Namespaced | ||
versions: | ||
- deprecated: true | ||
name: v1 | ||
schema: | ||
openAPIV3Schema: | ||
properties: | ||
spec: | ||
description: Spec of a test object. | ||
properties: | ||
foo: | ||
type: string | ||
type: object | ||
status: | ||
description: Spec of a test object. | ||
type: object | ||
type: object | ||
served: true | ||
storage: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package util | ||
|
||
import ( | ||
"os" | ||
"strings" | ||
|
||
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/controller-runtime/client" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
utilyaml "k8s.io/apimachinery/pkg/util/yaml" | ||
) | ||
|
||
type clientObjectOption func(client.Object) | ||
|
||
func WithGVK(gvk schema.GroupVersionKind) clientObjectOption { | ||
return func(obj client.Object) { | ||
obj.GetObjectKind().SetGroupVersionKind(gvk) | ||
} | ||
} | ||
|
||
func DecodeFile(file string, to client.Object, options ...clientObjectOption) (client.Object, error) { | ||
manifest, err := yamlFromFilePath(file) | ||
if err != nil { | ||
return nil, err | ||
} | ||
dec := utilyaml.NewYAMLOrJSONDecoder(strings.NewReader(manifest), 10) | ||
if err := dec.Decode(to); err != nil { | ||
return nil, err | ||
} | ||
|
||
return to, nil | ||
} | ||
|
||
func yamlFromFilePath(fileName string) (string, error) { | ||
yaml, err := os.ReadFile(fileName) | ||
return string(yaml), err | ||
} |