From a92953fbc7f91f0a883d12601e81756b90fe6ea1 Mon Sep 17 00:00:00 2001 From: Ce Gao Date: Sun, 29 Sep 2019 10:48:04 +0800 Subject: [PATCH] fix: Use configmap function Signed-off-by: Ce Gao --- pkg/util/v1alpha3/katibclient/katib_client.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/util/v1alpha3/katibclient/katib_client.go b/pkg/util/v1alpha3/katibclient/katib_client.go index 7a47ceeb845..05542d7dda3 100644 --- a/pkg/util/v1alpha3/katibclient/katib_client.go +++ b/pkg/util/v1alpha3/katibclient/katib_client.go @@ -135,6 +135,7 @@ func (k *KatibClient) GetExperiment(name string, namespace ...string) (*experime return exp, nil } +// GetConfigMap returns the configmap for the given name and namespace. func (k *KatibClient) GetConfigMap(name string, namespace ...string) (map[string]string, error) { ns := getNamespace(namespace...) configMap := &apiv1.ConfigMap{} @@ -144,19 +145,17 @@ func (k *KatibClient) GetConfigMap(name string, namespace ...string) (map[string return configMap.Data, nil } +// GetTrialTemplates returns the trial template if it exists. func (k *KatibClient) GetTrialTemplates(namespace ...string) (map[string]string, error) { - ns := getNamespace(namespace...) - trialTemplates := &apiv1.ConfigMap{} - err := k.client.Get(context.TODO(), types.NamespacedName{Name: experimentsv1alpha3.DefaultTrialConfigMapName, Namespace: ns}, trialTemplates) + data, err := k.GetConfigMap(experimentsv1alpha3.DefaultTrialConfigMapName, ns) if err != nil && errors.IsNotFound(err) { return map[string]string{}, nil } else if err != nil { return nil, err } - return trialTemplates.Data, nil - + return data, nil } func (k *KatibClient) UpdateTrialTemplates(newTrialTemplates map[string]string, namespace ...string) error {