@@ -22,20 +22,17 @@ import (
22
22
"strings"
23
23
24
24
mf "github.com/manifestival/manifestival"
25
- "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
26
- "k8s.io/apimachinery/pkg/runtime/schema"
25
+ "knative.dev/pkg/logging"
27
26
28
27
"knative.dev/operator/pkg/apis/operator/base"
29
28
"knative.dev/operator/pkg/apis/operator/v1beta1"
30
- "knative.dev/pkg/logging"
31
29
)
32
30
33
31
var (
34
- role mf.Predicate = mf .Any (mf .ByKind ("ClusterRole" ), mf .ByKind ("Role" ))
35
- rolebinding mf.Predicate = mf .Any (mf .ByKind ("ClusterRoleBinding" ), mf .ByKind ("RoleBinding" ))
36
- webhook mf.Predicate = mf .Any (mf .ByKind ("MutatingWebhookConfiguration" ), mf .ByKind ("ValidatingWebhookConfiguration" ))
37
- webhookDependentResources mf.Predicate = byGV (schema.GroupKind {Group : "networking.internal.knative.dev" , Kind : "Certificate" })
38
- gatewayNotMatch = "no matches for kind \" Gateway\" "
32
+ role mf.Predicate = mf .Any (mf .ByKind ("ClusterRole" ), mf .ByKind ("Role" ))
33
+ rolebinding mf.Predicate = mf .Any (mf .ByKind ("ClusterRoleBinding" ), mf .ByKind ("RoleBinding" ))
34
+ webhook mf.Predicate = mf .Any (mf .ByKind ("MutatingWebhookConfiguration" ), mf .ByKind ("ValidatingWebhookConfiguration" ))
35
+ gatewayNotMatch = "no matches for kind \" Gateway\" "
39
36
)
40
37
41
38
// Install applies the manifest resources for the given version and updates the given
@@ -55,7 +52,7 @@ func Install(ctx context.Context, manifest *mf.Manifest, instance base.KComponen
55
52
status .MarkInstallFailed (err .Error ())
56
53
return fmt .Errorf ("failed to apply (cluster)rolebindings: %w" , err )
57
54
}
58
- if err := manifest .Filter (mf .Not (mf .Any (role , rolebinding , webhook , webhookDependentResources ))).Apply (); err != nil {
55
+ if err := manifest .Filter (mf .Not (mf .Any (role , rolebinding , webhook ))).Apply (); err != nil {
59
56
status .MarkInstallFailed (err .Error ())
60
57
if ks , ok := instance .(* v1beta1.KnativeServing ); ok && strings .Contains (err .Error (), gatewayNotMatch ) &&
61
58
(ks .Spec .Ingress == nil || ks .Spec .Ingress .Istio .Enabled ) {
@@ -66,32 +63,10 @@ func Install(ctx context.Context, manifest *mf.Manifest, instance base.KComponen
66
63
67
64
return fmt .Errorf ("failed to apply non rbac manifest: %w" , err )
68
65
}
69
- return nil
70
- }
71
-
72
- // InstallWebhookConfigs applies the Webhook manifest resources and updates the given status accordingly.
73
- func InstallWebhookConfigs (ctx context.Context , manifest * mf.Manifest , instance base.KComponent ) error {
74
- status := instance .GetStatus ()
75
66
if err := manifest .Filter (webhook ).Apply (); err != nil {
76
67
status .MarkInstallFailed (err .Error ())
77
68
return fmt .Errorf ("failed to apply webhooks: %w" , err )
78
69
}
79
- return nil
80
- }
81
-
82
- // InstallWebhookDependentResources applies the Webhook dependent resources updates the given status accordingly.
83
- func InstallWebhookDependentResources (ctx context.Context , manifest * mf.Manifest , instance base.KComponent ) error {
84
- status := instance .GetStatus ()
85
- if err := manifest .Filter (webhookDependentResources ).Apply (); err != nil {
86
- status .MarkInstallFailed (err .Error ())
87
- return fmt .Errorf ("failed to apply webhooks: %w" , err )
88
- }
89
- return nil
90
- }
91
-
92
- // MarkStatusSuccess updates the component status to success.
93
- func MarkStatusSuccess (ctx context.Context , manifest * mf.Manifest , instance base.KComponent ) error {
94
- status := instance .GetStatus ()
95
70
status .MarkInstallSucceeded ()
96
71
status .SetVersion (TargetVersion (instance ))
97
72
return nil
@@ -108,9 +83,3 @@ func Uninstall(manifest *mf.Manifest) error {
108
83
}
109
84
return nil
110
85
}
111
-
112
- func byGV (gk schema.GroupKind ) mf.Predicate {
113
- return func (u * unstructured.Unstructured ) bool {
114
- return u .GroupVersionKind ().GroupKind () == gk
115
- }
116
- }
0 commit comments