Skip to content

Commit

Permalink
fix: Use configmap function
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <gaoce@caicloud.io>
  • Loading branch information
gaocegege committed Sep 29, 2019
1 parent e4166a2 commit a92953f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/util/v1alpha3/katibclient/katib_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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 {
Expand Down

0 comments on commit a92953f

Please sign in to comment.