|
|
|
@ -24,6 +24,7 @@ import (
|
|
|
|
|
"github.com/Masterminds/semver/v3"
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
v1 "k8s.io/api/apps/v1"
|
|
|
|
|
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
|
|
|
|
|
"k8s.io/client-go/kubernetes"
|
|
|
|
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
|
|
|
|
|
|
|
|
@ -95,9 +96,16 @@ func runCheckCmd(cmd *cobra.Command, args []string) error {
|
|
|
|
|
if !componentsCheck() {
|
|
|
|
|
checkFailed = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger.Actionf("checking crds")
|
|
|
|
|
if !crdsCheck() {
|
|
|
|
|
checkFailed = true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if checkFailed {
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger.Successf("all checks passed")
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
@ -205,3 +213,28 @@ func componentsCheck() bool {
|
|
|
|
|
}
|
|
|
|
|
return ok
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func crdsCheck() bool {
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), rootArgs.timeout)
|
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
|
|
kubeClient, err := utils.KubeClient(kubeconfigArgs, kubeclientOptions)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ok := true
|
|
|
|
|
selector := client.MatchingLabels{manifestgen.PartOfLabelKey: manifestgen.PartOfLabelValue}
|
|
|
|
|
var list apiextensionsv1.CustomResourceDefinitionList
|
|
|
|
|
if err := kubeClient.List(ctx, &list, client.InNamespace(*kubeconfigArgs.Namespace), selector); err == nil {
|
|
|
|
|
for _, crd := range list.Items {
|
|
|
|
|
if len(crd.Status.StoredVersions) > 0 {
|
|
|
|
|
logger.Successf(crd.Name + "/" + crd.Status.StoredVersions[0])
|
|
|
|
|
} else {
|
|
|
|
|
ok = false
|
|
|
|
|
logger.Failuref("no stored versions for %s", crd.Name)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ok
|
|
|
|
|
}
|
|
|
|
|