Skip to content

Commit

Permalink
Fix #1237: check specific knative serving versions to determine if it…
Browse files Browse the repository at this point in the history
…'s installed
  • Loading branch information
nicolaferraro authored and astefanutti committed Feb 17, 2020
1 parent 8201aac commit cb75c5f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
13 changes: 13 additions & 0 deletions pkg/util/knative/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ var (
Resource: "brokers",
},
}

// RequiredKinds are Knative kinds used by Camel K for materializing integrations.
// They must be present on the cluster
RequiredKinds = []GroupVersionKindResource{
{
GroupVersionKind: schema.GroupVersionKind{
Kind: "Service",
Group: "serving.knative.dev",
Version: "v1",
},
Resource: "services",
},
}
)

// GroupVersionKindResource --
Expand Down
8 changes: 4 additions & 4 deletions pkg/util/knative/enabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func IsEnabledInNamespace(ctx context.Context, c client.Client, namespace string
log.Infof("could not create dynamic client to check knative installation in namespace %s, got error: %v", namespace, err)
return false
}
for _, kgv := range KnownEndpointKinds {
for _, kgv := range RequiredKinds {
_, err = dyn.Resource(schema.GroupVersionResource{
Group: kgv.Group,
Version: kgv.Version,
Expand All @@ -60,7 +60,7 @@ func IsEnabledInNamespace(ctx context.Context, c client.Client, namespace string
// This method should not be called from the operator, as it might require permissions that are not available.
func IsInstalled(ctx context.Context, c kubernetes.Interface) (bool, error) {
// check some Knative APIs
for _, api := range getKnativeGroupVersions() {
for _, api := range getRequiredKnativeGroupVersions() {
if installed, err := isInstalled(c, api); err != nil {
return false, err
} else if installed {
Expand All @@ -80,10 +80,10 @@ func isInstalled(c kubernetes.Interface, api schema.GroupVersion) (bool, error)
return true, nil
}

func getKnativeGroupVersions() []schema.GroupVersion {
func getRequiredKnativeGroupVersions() []schema.GroupVersion {
apis := make(map[schema.GroupVersion]bool)
res := make([]schema.GroupVersion, 0)
for _, gvk := range KnownEndpointKinds {
for _, gvk := range RequiredKinds {
if !apis[gvk.GroupVersion()] {
apis[gvk.GroupVersion()] = true
res = append(res, gvk.GroupVersion())
Expand Down

0 comments on commit cb75c5f

Please sign in to comment.