mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-04-30 21:06:10 +00:00
* Remove `logger` module * Remove `shared` module * Move `cli` folder contents into project root * Fix linter * Change the module name from `github.com/kubeshark/kubeshark/cli` to `github.com/kubeshark/kubeshark` * Set the default `Makefile` rule to `build` * Add `lint` rule * Fix the linter errors
32 lines
1015 B
Go
32 lines
1015 B
Go
package check
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
|
|
"github.com/kubeshark/kubeshark/config"
|
|
"github.com/kubeshark/kubeshark/kubernetes"
|
|
"github.com/kubeshark/kubeshark/semver"
|
|
"github.com/kubeshark/kubeshark/uiUtils"
|
|
)
|
|
|
|
func KubernetesApi() (*kubernetes.Provider, *semver.SemVersion, bool) {
|
|
log.Printf("\nkubernetes-api\n--------------------")
|
|
|
|
kubernetesProvider, err := kubernetes.NewProvider(config.Config.KubeConfigPath(), config.Config.KubeContext)
|
|
if err != nil {
|
|
log.Printf("%v can't initialize the client, err: %v", fmt.Sprintf(uiUtils.Red, "✗"), err)
|
|
return nil, nil, false
|
|
}
|
|
log.Printf("%v can initialize the client", fmt.Sprintf(uiUtils.Green, "√"))
|
|
|
|
kubernetesVersion, err := kubernetesProvider.GetKubernetesVersion()
|
|
if err != nil {
|
|
log.Printf("%v can't query the Kubernetes API, err: %v", fmt.Sprintf(uiUtils.Red, "✗"), err)
|
|
return nil, nil, false
|
|
}
|
|
log.Printf("%v can query the Kubernetes API", fmt.Sprintf(uiUtils.Green, "√"))
|
|
|
|
return kubernetesProvider, kubernetesVersion, true
|
|
}
|