mirror of
https://github.com/mudler/luet.git
synced 2025-09-05 09:10:43 +00:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
73c6cff15b | ||
|
65892f9bfc | ||
|
315bfb5a54 | ||
|
57c8236184 |
@@ -30,7 +30,7 @@ var cfgFile string
|
|||||||
var Verbose bool
|
var Verbose bool
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LuetCLIVersion = "0.19.1"
|
LuetCLIVersion = "0.19.2"
|
||||||
LuetEnvPrefix = "LUET"
|
LuetEnvPrefix = "LUET"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -122,6 +122,7 @@ func setDefaults(viper *viper.Viper) {
|
|||||||
viper.SetDefault("general.debug", false)
|
viper.SetDefault("general.debug", false)
|
||||||
viper.SetDefault("general.show_build_output", false)
|
viper.SetDefault("general.show_build_output", false)
|
||||||
viper.SetDefault("general.fatal_warnings", false)
|
viper.SetDefault("general.fatal_warnings", false)
|
||||||
|
viper.SetDefault("general.http_timeout", 360)
|
||||||
|
|
||||||
u, err := user.Current()
|
u, err := user.Current()
|
||||||
// os/user doesn't work in from scratch environments
|
// os/user doesn't work in from scratch environments
|
||||||
@@ -178,6 +179,7 @@ func InitViper(ctx *types.Context, RootCmd *cobra.Command) {
|
|||||||
}
|
}
|
||||||
pflags.Bool("same-owner", ctx.Config.GetGeneral().SameOwner, "Maintain same owner on uncompress.")
|
pflags.Bool("same-owner", ctx.Config.GetGeneral().SameOwner, "Maintain same owner on uncompress.")
|
||||||
pflags.Int("concurrency", runtime.NumCPU(), "Concurrency")
|
pflags.Int("concurrency", runtime.NumCPU(), "Concurrency")
|
||||||
|
pflags.Int("http-timeout", ctx.Config.General.HTTPTimeout, "Default timeout for http(s) requests")
|
||||||
|
|
||||||
viper.BindPFlag("logging.color", pflags.Lookup("color"))
|
viper.BindPFlag("logging.color", pflags.Lookup("color"))
|
||||||
viper.BindPFlag("logging.enable_emoji", pflags.Lookup("emoji"))
|
viper.BindPFlag("logging.enable_emoji", pflags.Lookup("emoji"))
|
||||||
@@ -189,6 +191,7 @@ func InitViper(ctx *types.Context, RootCmd *cobra.Command) {
|
|||||||
viper.BindPFlag("general.fatal_warnings", pflags.Lookup("fatal"))
|
viper.BindPFlag("general.fatal_warnings", pflags.Lookup("fatal"))
|
||||||
viper.BindPFlag("general.same_owner", pflags.Lookup("same-owner"))
|
viper.BindPFlag("general.same_owner", pflags.Lookup("same-owner"))
|
||||||
viper.BindPFlag("plugin", pflags.Lookup("plugin"))
|
viper.BindPFlag("plugin", pflags.Lookup("plugin"))
|
||||||
|
viper.BindPFlag("general.http_timeout", pflags.Lookup("http-timeout"))
|
||||||
|
|
||||||
// Currently I maintain this only from cli.
|
// Currently I maintain this only from cli.
|
||||||
viper.BindPFlag("no_spinner", pflags.Lookup("no-spinner"))
|
viper.BindPFlag("no_spinner", pflags.Lookup("no-spinner"))
|
||||||
|
@@ -60,6 +60,7 @@ type LuetGeneralConfig struct {
|
|||||||
Debug bool `yaml:"debug,omitempty" mapstructure:"debug"`
|
Debug bool `yaml:"debug,omitempty" mapstructure:"debug"`
|
||||||
ShowBuildOutput bool `yaml:"show_build_output,omitempty" mapstructure:"show_build_output"`
|
ShowBuildOutput bool `yaml:"show_build_output,omitempty" mapstructure:"show_build_output"`
|
||||||
FatalWarns bool `yaml:"fatal_warnings,omitempty" mapstructure:"fatal_warnings"`
|
FatalWarns bool `yaml:"fatal_warnings,omitempty" mapstructure:"fatal_warnings"`
|
||||||
|
HTTPTimeout int `yaml:"http_timeout,omitempty" mapstructure:"http_timeout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LuetSolverOptions struct {
|
type LuetSolverOptions struct {
|
||||||
|
@@ -288,7 +288,9 @@ func (c *Context) Msg(level LogLevel, ln bool, msg ...interface{}) {
|
|||||||
switch level {
|
switch level {
|
||||||
case WarningLevel:
|
case WarningLevel:
|
||||||
levelMsg = pterm.LightYellow(":construction: warning" + message)
|
levelMsg = pterm.LightYellow(":construction: warning" + message)
|
||||||
case InfoLevel, SuccessLevel:
|
case InfoLevel:
|
||||||
|
levelMsg = message
|
||||||
|
case SuccessLevel:
|
||||||
levelMsg = pterm.LightGreen(message)
|
levelMsg = pterm.LightGreen(message)
|
||||||
case ErrorLevel:
|
case ErrorLevel:
|
||||||
levelMsg = pterm.Red(message)
|
levelMsg = pterm.Red(message)
|
||||||
|
@@ -75,8 +75,11 @@ func (c *DockerClient) DownloadArtifact(a *artifact.PackageArtifact) (*artifact.
|
|||||||
// - Check how verification is done when calling DownloadArtifact outside, similarly we need to check DownloadFile, and how verification
|
// - Check how verification is done when calling DownloadArtifact outside, similarly we need to check DownloadFile, and how verification
|
||||||
// is done in such cases (see repository.go)
|
// is done in such cases (see repository.go)
|
||||||
|
|
||||||
|
// We discard checksum, that are checked while during pull and unpack by containerd
|
||||||
|
resultingArtifact.Checksums = artifact.Checksums{}
|
||||||
|
|
||||||
// Check if file is already in cache
|
// Check if file is already in cache
|
||||||
fileName, err := c.Cache.Get(a)
|
fileName, err := c.Cache.Get(resultingArtifact)
|
||||||
// Check if file is already in cache
|
// Check if file is already in cache
|
||||||
if err == nil {
|
if err == nil {
|
||||||
resultingArtifact = a
|
resultingArtifact = a
|
||||||
@@ -118,8 +121,6 @@ func (c *DockerClient) DownloadArtifact(a *artifact.PackageArtifact) (*artifact.
|
|||||||
c.context.Info(fmt.Sprintf("Size: %s", units.BytesSize(float64(info.Target.Size))))
|
c.context.Info(fmt.Sprintf("Size: %s", units.BytesSize(float64(info.Target.Size))))
|
||||||
c.context.Debug("\nCompressing result ", filepath.Join(temp), "to", tempArtifact.Name())
|
c.context.Debug("\nCompressing result ", filepath.Join(temp), "to", tempArtifact.Name())
|
||||||
|
|
||||||
// We discard checksum, that are checked while during pull and unpack
|
|
||||||
resultingArtifact.Checksums = artifact.Checksums{}
|
|
||||||
resultingArtifact.Path = tempArtifact.Name() // First set to cache file
|
resultingArtifact.Path = tempArtifact.Name() // First set to cache file
|
||||||
err = resultingArtifact.Compress(temp, 1)
|
err = resultingArtifact.Compress(temp, 1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -23,7 +23,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mudler/luet/pkg/api/core/types"
|
"github.com/mudler/luet/pkg/api/core/types"
|
||||||
@@ -48,20 +47,11 @@ func NewHttpClient(r RepoData, ctx *types.Context) *HttpClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGrabClient() *grab.Client {
|
func NewGrabClient(timeout int) *grab.Client {
|
||||||
httpTimeout := 360
|
|
||||||
timeout := os.Getenv("HTTP_TIMEOUT")
|
|
||||||
if timeout != "" {
|
|
||||||
timeoutI, err := strconv.Atoi(timeout)
|
|
||||||
if err == nil {
|
|
||||||
httpTimeout = timeoutI
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return &grab.Client{
|
return &grab.Client{
|
||||||
UserAgent: "grab",
|
UserAgent: "grab",
|
||||||
HTTPClient: &http.Client{
|
HTTPClient: &http.Client{
|
||||||
Timeout: time.Duration(httpTimeout) * time.Second,
|
Timeout: time.Duration(timeout) * time.Second,
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
Proxy: http.ProxyFromEnvironment,
|
Proxy: http.ProxyFromEnvironment,
|
||||||
},
|
},
|
||||||
@@ -101,7 +91,7 @@ func (c *HttpClient) DownloadFile(p string) (string, error) {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(temp)
|
defer os.RemoveAll(temp)
|
||||||
|
|
||||||
client := NewGrabClient()
|
client := NewGrabClient(c.context.Config.General.HTTPTimeout)
|
||||||
|
|
||||||
for _, uri := range c.RepoData.Urls {
|
for _, uri := range c.RepoData.Urls {
|
||||||
file, err = c.context.Config.GetSystem().TempFile("HttpClient")
|
file, err = c.context.Config.GetSystem().TempFile("HttpClient")
|
||||||
|
Reference in New Issue
Block a user