refactor: use one provider for default cache url
This commit is contained in:
parent
60a1d19042
commit
4e77cf82d3
2
cache/cache.go
vendored
2
cache/cache.go
vendored
@ -18,7 +18,7 @@ import (
|
|||||||
"code.dumpstack.io/tools/out-of-tree/config"
|
"code.dumpstack.io/tools/out-of-tree/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
var URL string
|
var URL = "https://out-of-tree.fra1.digitaloceanspaces.com/1.0.0/"
|
||||||
|
|
||||||
func unpackTar(archive, destination string) (err error) {
|
func unpackTar(archive, destination string) (err error) {
|
||||||
// NOTE: If you're change anything in tar command please check also
|
// NOTE: If you're change anything in tar command please check also
|
||||||
|
1
cache/cache_test.go
vendored
1
cache/cache_test.go
vendored
@ -17,7 +17,6 @@ func TestDownloadQemuImage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(tmp)
|
defer os.RemoveAll(tmp)
|
||||||
|
|
||||||
URL = "https://out-of-tree.fra1.digitaloceanspaces.com/1.0.0/"
|
|
||||||
file := "out_of_tree_ubuntu_12__04.img"
|
file := "out_of_tree_ubuntu_12__04.img"
|
||||||
|
|
||||||
err = DownloadQemuImage(tmp, file)
|
err = DownloadQemuImage(tmp, file)
|
||||||
|
@ -3,12 +3,10 @@ package debian
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.dumpstack.io/tools/out-of-tree/cache"
|
|
||||||
"code.dumpstack.io/tools/out-of-tree/config"
|
"code.dumpstack.io/tools/out-of-tree/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMatchImagePkg(t *testing.T) {
|
func TestMatchImagePkg(t *testing.T) {
|
||||||
cache.URL = "https://out-of-tree.fra1.digitaloceanspaces.com/1.0.0/"
|
|
||||||
t.Log("tested with cache by default")
|
t.Log("tested with cache by default")
|
||||||
|
|
||||||
km := config.KernelMask{
|
km := config.KernelMask{
|
||||||
|
8
main.go
8
main.go
@ -8,6 +8,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/user"
|
"os/user"
|
||||||
@ -33,7 +34,7 @@ type Globals struct {
|
|||||||
|
|
||||||
WorkDir string `help:"path to work directory" default:"./" type:"path"`
|
WorkDir string `help:"path to work directory" default:"./" type:"path"`
|
||||||
|
|
||||||
CacheURL string `default:"https://out-of-tree.fra1.digitaloceanspaces.com/1.0.0/" hidden:""`
|
CacheURL url.URL
|
||||||
}
|
}
|
||||||
|
|
||||||
type CLI struct {
|
type CLI struct {
|
||||||
@ -190,7 +191,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
container.Runtime = cli.ContainerRuntime
|
container.Runtime = cli.ContainerRuntime
|
||||||
|
|
||||||
cache.URL = cli.Globals.CacheURL
|
if cli.Globals.CacheURL.String() != "" {
|
||||||
|
cache.URL = cli.Globals.CacheURL.String()
|
||||||
|
}
|
||||||
|
log.Debug().Msgf("set cache url to %s", cache.URL)
|
||||||
|
|
||||||
err = ctx.Run(&cli.Globals)
|
err = ctx.Run(&cli.Globals)
|
||||||
ctx.FatalIfErrorf(err)
|
ctx.FatalIfErrorf(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user