New 🌊 wave for @helm

Commit a3b1b7a7

a3b1b7a7a3bbMerged

zhilyaev <[email protected]> · 5 years ago · 14 files · +1 added · ~12 modified · -1 deleted

Description

uniqname.go

Details

Commit
a3b1b7a7a3bb
Parent
1382fccccc01

pkg/helper/func.gomodifiedView file

@@ -1,7 +1,10 @@
11 package helper
22
33 import (
4+ "fmt"
45 log "github.com/sirupsen/logrus"
6+ "io"
7+ "net/http"
58 "os"
69 "path/filepath"
710 "sort"
@@ -51,3 +54,28 @@
5154 }
5255
5356 }
57+
58+func Download(file, url string) error {
59+ f, err := CreateFile(file)
60+ if err != nil {
61+ return err
62+ }
63+
64+ r, err := http.Get(url)
65+ if err != nil {
66+ return err
67+ }
68+
69+ defer r.Body.Close()
70+
71+ if r.StatusCode != http.StatusOK {
72+ return fmt.Errorf("bad status: %s", r.Status)
73+ }
74+
75+ _, err = io.Copy(f, r.Body)
76+ if err != nil {
77+ return err
78+ }
79+
80+ return nil
81+}