lang, lib, util: Rename fs to be more unique
Trying to do a big refactor and this will help.
This commit is contained in:
@@ -201,9 +201,9 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {
|
|||||||
readOnlyOsFs := afero.NewReadOnlyFs(osFs) // can't be readonly to dl!
|
readOnlyOsFs := afero.NewReadOnlyFs(osFs) // can't be readonly to dl!
|
||||||
//bp := afero.NewBasePathFs(osFs, base) // TODO: can this prevent parent dir access?
|
//bp := afero.NewBasePathFs(osFs, base) // TODO: can this prevent parent dir access?
|
||||||
afs := &afero.Afero{Fs: readOnlyOsFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: readOnlyOsFs} // wrap so that we're implementing ioutil
|
||||||
localFs := &util.Fs{Afero: afs} // always the local fs
|
localFs := &util.AferoFs{Afero: afs} // always the local fs
|
||||||
downloadAfs := &afero.Afero{Fs: osFs}
|
downloadAfs := &afero.Afero{Fs: osFs}
|
||||||
downloadFs := &util.Fs{Afero: downloadAfs} // TODO: use with a parent path preventer?
|
downloadFs := &util.AferoFs{Afero: downloadAfs} // TODO: use with a parent path preventer?
|
||||||
|
|
||||||
// the fs input here is the local fs we're reading to get the files from
|
// the fs input here is the local fs we're reading to get the files from
|
||||||
// this is different from the fs variable which is our output dest!!!
|
// this is different from the fs variable which is our output dest!!!
|
||||||
@@ -716,9 +716,9 @@ func (obj *GAPI) Get(getInfo *gapi.GetInfo) error {
|
|||||||
readOnlyOsFs := afero.NewReadOnlyFs(osFs) // can't be readonly to dl!
|
readOnlyOsFs := afero.NewReadOnlyFs(osFs) // can't be readonly to dl!
|
||||||
//bp := afero.NewBasePathFs(osFs, base) // TODO: can this prevent parent dir access?
|
//bp := afero.NewBasePathFs(osFs, base) // TODO: can this prevent parent dir access?
|
||||||
afs := &afero.Afero{Fs: readOnlyOsFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: readOnlyOsFs} // wrap so that we're implementing ioutil
|
||||||
localFs := &util.Fs{Afero: afs} // always the local fs
|
localFs := &util.AferoFs{Afero: afs} // always the local fs
|
||||||
downloadAfs := &afero.Afero{Fs: osFs}
|
downloadAfs := &afero.Afero{Fs: osFs}
|
||||||
downloadFs := &util.Fs{Afero: downloadAfs} // TODO: use with a parent path preventer?
|
downloadFs := &util.AferoFs{Afero: downloadAfs} // TODO: use with a parent path preventer?
|
||||||
|
|
||||||
// the fs input here is the local fs we're reading to get the files from
|
// the fs input here is the local fs we're reading to get the files from
|
||||||
// this is different from the fs variable which is our output dest!!!
|
// this is different from the fs variable which is our output dest!!!
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ func TestAstFunc1(t *testing.T) {
|
|||||||
}
|
}
|
||||||
mmFs := afero.NewMemMapFs()
|
mmFs := afero.NewMemMapFs()
|
||||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
||||||
fs := &util.Fs{Afero: afs}
|
fs := &util.AferoFs{Afero: afs}
|
||||||
|
|
||||||
// use this variant, so that we don't copy the dir name
|
// use this variant, so that we don't copy the dir name
|
||||||
// this is the equivalent to running `rsync -a src/ /`
|
// this is the equivalent to running `rsync -a src/ /`
|
||||||
@@ -797,7 +797,7 @@ func TestAstFunc2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
mmFs := afero.NewMemMapFs()
|
mmFs := afero.NewMemMapFs()
|
||||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
||||||
fs := &util.Fs{Afero: afs}
|
fs := &util.AferoFs{Afero: afs}
|
||||||
|
|
||||||
// implementation of the Local API (we only expect just this single one)
|
// implementation of the Local API (we only expect just this single one)
|
||||||
localAPI := (&local.API{
|
localAPI := (&local.API{
|
||||||
@@ -1599,7 +1599,7 @@ func TestAstFunc3(t *testing.T) {
|
|||||||
}
|
}
|
||||||
mmFs := afero.NewMemMapFs()
|
mmFs := afero.NewMemMapFs()
|
||||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
||||||
fs := &util.Fs{Afero: afs}
|
fs := &util.AferoFs{Afero: afs}
|
||||||
|
|
||||||
// implementation of the Local API (we only expect just this single one)
|
// implementation of the Local API (we only expect just this single one)
|
||||||
localAPI := (&local.API{
|
localAPI := (&local.API{
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ func runInterpret(t *testing.T, code string) (_ *pgraph.Graph, reterr error) {
|
|||||||
}
|
}
|
||||||
mmFs := afero.NewMemMapFs()
|
mmFs := afero.NewMemMapFs()
|
||||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
||||||
fs := &util.Fs{Afero: afs}
|
fs := &util.AferoFs{Afero: afs}
|
||||||
|
|
||||||
output, err := inputs.ParseInput(code, fs) // raw code can be passed in
|
output, err := inputs.ParseInput(code, fs) // raw code can be passed in
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ func run(c *cli.Context, name string, gapiObj gapi.GAPI) error {
|
|||||||
// create a memory backed temporary filesystem for storing runtime data
|
// create a memory backed temporary filesystem for storing runtime data
|
||||||
mmFs := afero.NewMemMapFs()
|
mmFs := afero.NewMemMapFs()
|
||||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
||||||
standaloneFs := &util.Fs{Afero: afs}
|
standaloneFs := &util.AferoFs{Afero: afs}
|
||||||
obj.DeployFs = standaloneFs
|
obj.DeployFs = standaloneFs
|
||||||
|
|
||||||
cliInfo := &gapi.CliInfo{
|
cliInfo := &gapi.CliInfo{
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ func TestCopyDiskToFs1(t *testing.T) {
|
|||||||
|
|
||||||
mmFs := afero.NewMemMapFs()
|
mmFs := afero.NewMemMapFs()
|
||||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
||||||
fs := &Fs{afs}
|
fs := &AferoFs{afs}
|
||||||
|
|
||||||
if err := CopyDiskToFs(fs, dir+f+"/", "/", false); err != nil {
|
if err := CopyDiskToFs(fs, dir+f+"/", "/", false); err != nil {
|
||||||
t.Errorf("copying to fs failed: %+v", err)
|
t.Errorf("copying to fs failed: %+v", err)
|
||||||
@@ -218,7 +218,7 @@ func TestCopyDiskToFs2(t *testing.T) {
|
|||||||
|
|
||||||
mmFs := afero.NewMemMapFs()
|
mmFs := afero.NewMemMapFs()
|
||||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
||||||
fs := &Fs{afs}
|
fs := &AferoFs{afs}
|
||||||
|
|
||||||
src := dir + f + "/"
|
src := dir + f + "/"
|
||||||
dst := "/dest/"
|
dst := "/dest/"
|
||||||
@@ -282,7 +282,7 @@ func TestCopyDiskContentsToFs1(t *testing.T) {
|
|||||||
|
|
||||||
mmFs := afero.NewMemMapFs()
|
mmFs := afero.NewMemMapFs()
|
||||||
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
afs := &afero.Afero{Fs: mmFs} // wrap so that we're implementing ioutil
|
||||||
fs := &Fs{afs}
|
fs := &AferoFs{afs}
|
||||||
|
|
||||||
if err := CopyDiskContentsToFs(fs, dir+f+"/", "/", false); err != nil {
|
if err := CopyDiskContentsToFs(fs, dir+f+"/", "/", false); err != nil {
|
||||||
t.Errorf("copying to fs failed: %+v", err)
|
t.Errorf("copying to fs failed: %+v", err)
|
||||||
|
|||||||
15
util/fs.go
15
util/fs.go
@@ -23,14 +23,15 @@ import (
|
|||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Fs is a simple wrapper to a file system to be used for standalone deploys.
|
// AferoFs is a simple wrapper to a file system to be used for standalone
|
||||||
// This is basically a pass-through so that we fulfill the same interface that
|
// deploys. This is basically a pass-through so that we fulfill the same
|
||||||
// the deploy mechanism uses. To use this, wrap it with the implied field name,
|
// interface that the deploy mechanism uses. To use this, wrap it with the
|
||||||
// which will prevent `go vet` warnings, eg: `fs := &util.Fs{Afero: afs}`.
|
// implied field name, which will prevent `go vet` warnings, eg:
|
||||||
// NOTE: This struct is here, since I don't know where else to put it for now.
|
// `fs := &util.AferoFs{Afero: afs}`. NOTE: This struct is here, since I don't
|
||||||
type Fs struct {
|
// know where else to put it for now.
|
||||||
|
type AferoFs struct {
|
||||||
*afero.Afero
|
*afero.Afero
|
||||||
}
|
}
|
||||||
|
|
||||||
// URI returns the unique URI of this filesystem. It returns the root path.
|
// URI returns the unique URI of this filesystem. It returns the root path.
|
||||||
func (obj *Fs) URI() string { return fmt.Sprintf("%s://"+"/", obj.Name()) }
|
func (obj *AferoFs) URI() string { return fmt.Sprintf("%s://"+"/", obj.Name()) }
|
||||||
|
|||||||
Reference in New Issue
Block a user