Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Commit

Permalink
[fix] Fix logic for dealing with travisCI response codes (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo Lopez authored Oct 21, 2019
1 parent dc8c60b commit f5e7186
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/sink/travisCi.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package sink
import (
"context"
"fmt"
"net/http"

"github.com/pkg/errors"
"github.com/shuheiktgw/go-travis"
Expand Down Expand Up @@ -36,7 +35,7 @@ func (sink *TravisCiSink) Write(ctx context.Context, name string, val string) er
if err != nil {
return errors.Wrapf(err, "unable to list env vars in Travis CI for repo %s", sink.RepoSlug)
}
if resp.StatusCode != http.StatusOK {
if resp.StatusCode < 200 || 300 <= resp.StatusCode {
return errors.New(fmt.Sprintf("unable to list env vars in Travis CI for repo %s: invalid http status: %s", sink.RepoSlug, resp.Status))
}

Expand All @@ -60,7 +59,7 @@ func (sink *TravisCiSink) create(ctx context.Context, body *travis.EnvVarBody) e
if err != nil {
return errors.Wrapf(err, "unable to create env var %s in TravisCI repo %s", body.Name, sink.RepoSlug)
}
if resp.StatusCode != http.StatusOK {
if resp.StatusCode < 200 || 300 <= resp.StatusCode {
return errors.New(fmt.Sprintf("unable to create env var %s in Travis CI for repo %s: invalid http status: %s", body.Name, sink.RepoSlug, resp.Status))
}
return nil
Expand All @@ -71,7 +70,7 @@ func (sink *TravisCiSink) update(ctx context.Context, body *travis.EnvVarBody, e
if err != nil {
return errors.Wrapf(err, "unable to update env var %s in TravisCI repo %s", body.Name, sink.RepoSlug)
}
if resp.StatusCode != http.StatusOK {
if resp.StatusCode < 200 || 300 <= resp.StatusCode {
return errors.New(fmt.Sprintf("unable to update env var %s in Travis CI for repo %s: invalid http status: %s", body.Name, sink.RepoSlug, resp.Status))
}
return nil
Expand Down

0 comments on commit f5e7186

Please sign in to comment.