Skip to content

Commit

Permalink
Add LicenseProvided helper
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha committed Dec 1, 2023
1 parent 030665f commit 9aacdfe
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions kubernetes/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import (
"k8s.io/klog/v2"
"k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset"
core_util "kmodules.xyz/client-go/core/v1"
"kmodules.xyz/client-go/discovery"
"kmodules.xyz/client-go/dynamic"
"kmodules.xyz/client-go/meta"
"kmodules.xyz/client-go/tools/clusterid"
Expand Down Expand Up @@ -394,3 +395,18 @@ func CheckLicenseEndpoint(config *rest.Config, apiServiceName string, features [
}
return nil
}

func LicenseProvided(cfg *rest.Config, licenseFile string) bool {
if licenseFile != "" {
return true
}

if cfg != nil {
ok, _ := discovery.HasGVK(
kubernetes.NewForConfigOrDie(cfg).Discovery(),
proxyserver.SchemeGroupVersion.String(),
proxyserver.ResourceKindLicenseRequest)
return ok
}
return false
}

0 comments on commit 9aacdfe

Please sign in to comment.