Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #3 from Luap99/fix-ports
Browse files Browse the repository at this point in the history
Fix using the plugin without ports
  • Loading branch information
rhatdan authored Sep 7, 2021
2 parents afab2d8 + 3c5837b commit 4ae55f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/*
3 changes: 2 additions & 1 deletion plugins/meta/podman-machine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func cmdAdd(args *skel.CmdArgs) error {
}
// No portmappings, do nothing
if len(portMaps.RuntimeConfig.PortMaps) < 1 {
return nil
// Have to do this for chained plugins, which this is
return types.PrintResult(portMaps.PrevResult, portMaps.CNIVersion)
}
// Iterate and send requests to the server
for _, pm := range portMaps.RuntimeConfig.PortMaps {
Expand Down
8 changes: 7 additions & 1 deletion plugins/meta/podman-machine/restful.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/url"
Expand Down Expand Up @@ -50,7 +52,11 @@ func postRequest(ctx context.Context, url *url.URL, body interface{}) error {
return err
}
if resp.StatusCode != http.StatusOK {
return errors.New("something went wrong with the request")
b, err := ioutil.ReadAll(resp.Body)
if err == nil && len(b) > 0 {
return fmt.Errorf("something went wrong with the request: %q", string(b))
}
return errors.New("something went wrong with the request, could not read response")
}
return nil
}

0 comments on commit 4ae55f6

Please sign in to comment.