mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
* chore: make specs an internal package * Some minor improvements * Use LoadClusterSpecs in support bundle implementation * Remove change accidentally committed * Use LoadFromCLIArgs in preflight CLI implementation * Update comment * Fix edge case where the label selector is an empty string * Fix failing test
33 lines
1.3 KiB
Go
33 lines
1.3 KiB
Go
package specs
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
specs "github.com/replicatedhq/troubleshoot/internal/specs"
|
|
"github.com/replicatedhq/troubleshoot/pkg/k8sutil"
|
|
"k8s.io/client-go/kubernetes"
|
|
)
|
|
|
|
// LoadFromConfigMap reads data from a configmap and returns the list of values extracted from the key
|
|
// Deprecated: Remove in a future version (v1.0). Future loader functions
|
|
// will be created
|
|
func LoadFromConfigMap(namespace string, configMapName string, key string) ([]byte, error) {
|
|
config, err := k8sutil.GetRESTConfig()
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "failed to convert kube flags to rest config")
|
|
}
|
|
|
|
client, err := kubernetes.NewForConfig(config)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "failed to convert create k8s client")
|
|
}
|
|
return specs.LoadFromConfigMap(context.TODO(), client, namespace, configMapName, key)
|
|
}
|
|
|
|
// LoadFromConfigMapMatchingLabel reads data from a configmap and returns the list of values extracted from the key
|
|
// Deprecated: Remove in a future version (v1.0). Future loader functions will be created
|
|
func LoadFromConfigMapMatchingLabel(client kubernetes.Interface, labelSelector string, namespace string, key string) ([]string, error) {
|
|
return specs.LoadFromConfigMapMatchingLabel(context.TODO(), client, labelSelector, namespace, key)
|
|
}
|