Skip to content

Commit

Permalink
Add check if os route group is available (#761)
Browse files Browse the repository at this point in the history
* Add check if os route group is available

* Update pkg/kube/discover.go

Co-authored-by: Prasad Ghangal <prasad.ghangal@gmail.com>

Co-authored-by: Prasad Ghangal <prasad.ghangal@gmail.com>
  • Loading branch information
viveksinghggits and PrasadG193 committed Sep 11, 2020
1 parent 33fb9f7 commit 0c553b7
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pkg/kube/discover.go
Expand Up @@ -7,7 +7,10 @@ import (
"k8s.io/client-go/discovery"
)

const osAppsGroupName = `apps.openshift.io`
const (
osAppsGroupName = `apps.openshift.io`
osRouteGroupName = `route.openshift.io/v1`
)

// IsOSAppsGroupAvailable returns true if the openshift apps group is registered in service discovery.
func IsOSAppsGroupAvailable(ctx context.Context, cli discovery.DiscoveryInterface) (bool, error) {
Expand All @@ -23,6 +26,20 @@ func IsOSAppsGroupAvailable(ctx context.Context, cli discovery.DiscoveryInterfac
return false, nil
}

// IsOSRouteGroupAvailable returns true is the openshift route group is registered in service discovery
func IsOSRouteGroupAvailable(ctx context.Context, cli discovery.DiscoveryInterface) (bool, error) {
sgs, err := cli.ServerGroups()
if err != nil {
return false, err
}
for _, g := range sgs.Groups {
if g.Name == osRouteGroupName {
return true, nil
}
}
return false, nil
}

// IsGroupVersionAvailable returns true if given group/version is registered.
func IsGroupVersionAvailable(ctx context.Context, cli discovery.DiscoveryInterface, groupName, version string) (bool, error) {
sgs, err := cli.ServerGroups()
Expand Down

0 comments on commit 0c553b7

Please sign in to comment.