Remove unused go-getter driver funcs (#643)
The go-getter driver (named `Remote`) is used to implement remote values. I found some unused functions in its implementation. This commit removes those unused functions so that it becomes more maintainable. Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com> Signed-off-by: Yusuke Kuoka <ykuoka@gmail.com>
This commit is contained in:
parent
cff674b7e9
commit
543629f335
|
|
@ -2,7 +2,6 @@ package remote
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
neturl "net/url"
|
neturl "net/url"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -17,7 +16,6 @@ import (
|
||||||
|
|
||||||
"github.com/helmfile/helmfile/pkg/envvar"
|
"github.com/helmfile/helmfile/pkg/envvar"
|
||||||
"github.com/helmfile/helmfile/pkg/filesystem"
|
"github.com/helmfile/helmfile/pkg/filesystem"
|
||||||
"github.com/helmfile/helmfile/pkg/yaml"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var disableInsecureFeatures bool
|
var disableInsecureFeatures bool
|
||||||
|
|
@ -53,51 +51,6 @@ type Remote struct {
|
||||||
fs *filesystem.FileSystem
|
fs *filesystem.FileSystem
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Remote) Unmarshal(src string, dst interface{}) error {
|
|
||||||
bytes, err := r.GetBytes(src)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
strs := strings.Split(src, "/")
|
|
||||||
file := strs[len(strs)-1]
|
|
||||||
ext := filepath.Ext(file)
|
|
||||||
|
|
||||||
{
|
|
||||||
r.Logger.Debugf("remote> unmarshalling %s", string(bytes))
|
|
||||||
|
|
||||||
var err error
|
|
||||||
switch ext {
|
|
||||||
case "json":
|
|
||||||
err = json.Unmarshal(bytes, dst)
|
|
||||||
default:
|
|
||||||
err = yaml.Unmarshal(bytes, dst)
|
|
||||||
}
|
|
||||||
|
|
||||||
r.Logger.Debugf("remote> unmarshalled to %v", dst)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Remote) GetBytes(goGetterSrc string) ([]byte, error) {
|
|
||||||
f, err := r.Fetch(goGetterSrc)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
bytes, err := r.fs.ReadFile(f)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("read file: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return bytes, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Locate takes an URL to a remote file or a path to a local file.
|
// Locate takes an URL to a remote file or a path to a local file.
|
||||||
// If the argument was an URL, it fetches the remote directory contained within the URL,
|
// If the argument was an URL, it fetches the remote directory contained within the URL,
|
||||||
// and returns the path to the file in the fetched directory
|
// and returns the path to the file in the fetched directory
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue