Skip to content

Commit

Permalink
Fixed forgeapi http transport to support proxy settings from envvars.…
Browse files Browse the repository at this point in the history
… Made forgeapi error logging more useful. Updated README with proxy settings.
  • Loading branch information
hsnodgrass committed Oct 12, 2020
1 parent 6df733c commit c727eaf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Pufctl allows you to quickly add modules to a Puppetfile from a git source or th
* [Working With Puppetfiles](#working-with-puppetfiles)
* [Git and Authentication](#git-and-authentication)
* [Using a Config File](#using-a-config-file)
* [Proxy Settings](#proxy-settings)
* [Features](#features)
* [Usage](#usage)
* [Basic Examples](#basic-examples)
Expand Down Expand Up @@ -88,6 +89,13 @@ Nearly every option provided by a command line flag can be configured using a co

The default location for the config file is `$HOME/.pufctl.yaml`. You can use a config file at a different path by passing the path to the `--config` global flag.

### Proxy Settings

If you are behind a proxy, so can configure Pufctl to use the proxy by settings the following environment variables:

* `HTTP_PROXY`
* `HTTPS_PROXY`
* `USE_PROXIES` (optional)

## Features

Expand Down
8 changes: 4 additions & 4 deletions pkg/forgeapi/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type GetError struct {
}

func (r *GetError) Error() string {
return fmt.Sprintf("%s HTTP GET request failed. URL: %s, Headers: %#v, Error: %#v", prefix(), r.URL, r.Headers, r.Err)
return fmt.Sprintf("%s HTTP GET request failed. URL: %s, Headers: %#v, Error: %s", prefix(), r.URL, r.Headers, r.Err.Error())
}

// GetNon200Error provides an error wrapper for when
Expand All @@ -41,7 +41,7 @@ type JSONDecodeError struct {
}

func (r *JSONDecodeError) Error() string {
return fmt.Sprintf("%s Failed to decode HTTP response body: %#v", prefix(), r.Err)
return fmt.Sprintf("%s Failed to decode HTTP response body: %#v", prefix(), r.Err.Error())
}

// FetchError provides a wrapper for errors encountered
Expand All @@ -51,7 +51,7 @@ type FetchError struct {
}

func (r *FetchError) Error() string {
return fmt.Sprintf("%s Fetch failed: %#v", prefix(), r.Err)
return fmt.Sprintf("%s Fetch failed: %#v", prefix(), r.Err.Error())
}

// ListError provides a wrapper for errors encountered
Expand All @@ -61,5 +61,5 @@ type ListError struct {
}

func (r *ListError) Error() string {
return fmt.Sprintf("%s List failed: %#v", prefix(), r.Err)
return fmt.Sprintf("%s List failed: %#v", prefix(), r.Err.Error())
}
1 change: 1 addition & 0 deletions pkg/forgeapi/forgeapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var (
MaxIdleConns: 3,
IdleConnTimeout: 5 * time.Second,
DisableCompression: true,
Proxy: http.ProxyFromEnvironment,
}
)

Expand Down

0 comments on commit c727eaf

Please sign in to comment.