github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/api/plugin/download_plugin.go (about)

     1  package plugin
     2  
     3  import "io/ioutil"
     4  
     5  func (client *Client) DownloadPlugin(pluginURL string, path string, proxyReader ProxyReader) error {
     6  	request, err := client.newGETRequest(pluginURL)
     7  	if err != nil {
     8  		return err
     9  	}
    10  
    11  	response := Response{}
    12  	err = client.connection.Make(request, &response, proxyReader)
    13  	if err != nil {
    14  		return err
    15  	}
    16  
    17  	err = ioutil.WriteFile(path, response.RawResponse, 0700)
    18  	if err != nil {
    19  		return err
    20  	}
    21  
    22  	return nil
    23  }