forked from stolostron/multicluster-observability-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add user number in kube-state-metrics (stolostron#1474)
Signed-off-by: Thibault Mange <[email protected]>
- Loading branch information
1 parent
bcbdee1
commit 5cd3570
Showing
4 changed files
with
59 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) Red Hat, Inc. | ||
// Copyright Contributors to the Open Cluster Management project | ||
// Licensed under the Apache License 2.0 | ||
|
||
package microshift | ||
|
||
import ( | ||
"context" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/errors" | ||
"k8s.io/apimachinery/pkg/types" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
// IsMicroshiftCluster checks if the cluster is a microshift cluster. | ||
// It verifies the existence of the configmap microshift-version in namespace kube-public. | ||
// If the configmap exists, it returns the version of the microshift cluster. | ||
// If the configmap does not exist, it returns an empty string. | ||
func IsMicroshiftCluster(ctx context.Context, client client.Client) (string, error) { | ||
res := &corev1.ConfigMap{} | ||
err := client.Get(ctx, types.NamespacedName{ | ||
Name: "microshift-version", | ||
Namespace: "kube-public", | ||
}, res) | ||
if err != nil { | ||
if errors.IsNotFound(err) { | ||
return "", nil | ||
} | ||
return "", err | ||
} | ||
|
||
return res.Data["version"], nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters