Skip to content

Commit

Permalink
Refactor to expose release method to clients
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Kuznetsov <[email protected]>
  • Loading branch information
stevekuznetsov committed Jul 25, 2019
1 parent 765f8e3 commit 1403d05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions boskos/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ import (
"net/http"
"os"
"strings"
"sync"
"syscall"
"time"

"sync"

"github.com/hashicorp/go-multierror"
multierror "github.com/hashicorp/go-multierror"
"github.com/sirupsen/logrus"
"k8s.io/test-infra/boskos/common"
"k8s.io/test-infra/boskos/storage"
Expand Down Expand Up @@ -203,7 +202,7 @@ func (c *Client) ReleaseAll(dest string) error {
var allErrors error
for _, r := range resources {
c.storage.Delete(r.GetName())
err := c.release(r.GetName(), dest)
err := c.Release(r.GetName(), dest)
if err != nil {
allErrors = multierror.Append(allErrors, err)
}
Expand All @@ -220,7 +219,7 @@ func (c *Client) ReleaseOne(name, dest string) error {
return fmt.Errorf("no resource name %v", name)
}
c.storage.Delete(name)
if err := c.release(name, dest); err != nil {
if err := c.Release(name, dest); err != nil {
return err
}
return nil
Expand Down Expand Up @@ -387,7 +386,7 @@ func (c *Client) acquireByState(state, dest string, names []string) ([]common.Re
return nil, fmt.Errorf("status %s, status code %v", resp.Status, resp.StatusCode)
}

func (c *Client) release(name, dest string) error {
func (c *Client) Release(name, dest string) error {
resp, err := c.httpPost(fmt.Sprintf("%v/release?name=%v&dest=%v&owner=%v",
c.url, name, dest, c.owner), "", nil)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion boskos/cmd/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Examples:
$ boskosctl release --name my-thing --target-state dirty`,
Run: func(cmd *cobra.Command, args []string) {
options.initializeClient()
err := options.c.ReleaseOne(options.release.name, options.release.targetState)
err := options.c.Release(options.release.name, options.release.targetState)
if err != nil {
fmt.Fprintf(cmd.ErrOrStderr(), "failed to release resource %q: %v\n", options.release.name, err)
exit(1)
Expand Down

0 comments on commit 1403d05

Please sign in to comment.