Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

Commit

Permalink
Fix not returning errors from mapping
Browse files Browse the repository at this point in the history
liztio committed Jul 15, 2019

Verified

This commit was signed with the committer’s verified signature.
chuckha Chuck Ha
1 parent 0e7a0bf commit d39da20
Showing 2 changed files with 11 additions and 14 deletions.
20 changes: 10 additions & 10 deletions cmd/capdctl/main.go
Original file line number Diff line number Diff line change
@@ -226,13 +226,8 @@ func NewAPIHelper(cfg *rest.Config) (*APIHelper, error) {
}
mapper := restmapper.NewDiscoveryRESTMapper(groupResources)

client, err := rest.RESTClientFor(cfg)
if err != nil {
return nil, errors.Wrap(err, "failed to create REST client")
}

return &APIHelper{
client,
discover.RESTClient(),
mapper,
}, nil
}
@@ -243,10 +238,15 @@ func (a *APIHelper) Create(obj runtime.Object) error {
return errors.Wrap(err, "couldn't create accessor")
}

mapping, err := a.mapper.RESTMapping(
obj.GetObjectKind().GroupVersionKind().GroupKind(),
obj.GetObjectKind().GroupVersionKind().Version,
)
gvk := obj.GetObjectKind().GroupVersionKind()

mapping, err := a.mapper.RESTMapping(gvk.GroupKind(), gvk.Version)

if err != nil {
return errors.Wrapf(err, "failed to retrieve mapping for %s %s", gvk.String(), accessor.GetName())
}

fmt.Printf("Creating %s %s\n", gvk.String(), accessor.GetName())

_, err = resource.NewHelper(a.client, mapping).Create(accessor.GetNamespace(), true, obj, nil)
return errors.Wrapf(err, "failed to create object %q", accessor.GetName())
5 changes: 1 addition & 4 deletions objects/capi.go
Original file line number Diff line number Diff line change
@@ -80,10 +80,7 @@ func getCAPIYAML(version, capiImage string) (io.Reader, error) {
}
}
}
s := buf.String()
fmt.Printf("<<<<<<>>>>>>\n%s\n<<<<<<<<<>>>>>>>>\n", s)

return strings.NewReader(s), nil
return &buf, nil
}

func decodeCAPIObjects(yaml io.Reader) ([]runtime.Object, error) {

0 comments on commit d39da20

Please sign in to comment.