Skip to content

Commit

Permalink
chore(cmd/driver,pkg/driver): allow to disable kernel headers automat…
Browse files Browse the repository at this point in the history
…ic download.

Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP authored and poiana committed Jul 2, 2024
1 parent 76be634 commit 150ef39
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions cmd/driver/driver_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ func NewDriverCmd(ctx context.Context, opt *options.Common) *cobra.Command {
return err
}
allowedDriverTypes = append(allowedDriverTypes, drvType)
opt.Printer.Logger.Debug("Allowed driver",
opt.Printer.Logger.Args("type", drvType))
}

// Step 2: fetch system info (kernel release/version and distro)
Expand Down
8 changes: 5 additions & 3 deletions cmd/driver/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ type driverDownloadOptions struct {
type driverInstallOptions struct {
*options.Common
*options.Driver
Download bool
Compile bool
Download bool
Compile bool
DownloadHeaders bool
driverDownloadOptions
}

Expand Down Expand Up @@ -77,6 +78,7 @@ func NewDriverInstallCmd(ctx context.Context, opt *options.Common, driver *optio

cmd.Flags().BoolVar(&o.Download, "download", true, "Whether to enable download of prebuilt drivers")
cmd.Flags().BoolVar(&o.Compile, "compile", true, "Whether to enable local compilation of drivers")
cmd.Flags().BoolVar(&o.DownloadHeaders, "download-headers", true, "Whether to enable automatic kernel headers download where supported")
cmd.Flags().BoolVar(&o.InsecureDownload, "http-insecure", false, "Whether you want to allow insecure downloads or not")
cmd.Flags().DurationVar(&o.HTTPTimeout, "http-timeout", 60*time.Second, "Timeout for each http try")
cmd.Flags().StringVar(&o.HTTPHeaders, "http-headers",
Expand Down Expand Up @@ -191,7 +193,7 @@ func (o *driverInstallOptions) RunDriverInstall(ctx context.Context) (string, er
if !o.Printer.DisableStyling {
o.Printer.Spinner, _ = o.Printer.Spinner.Start("Trying to build the driver")
}
dest, err = driverdistro.Build(ctx, o.Distro, o.Printer.WithWriter(&buf), o.Kr, o.Driver.Name, o.Driver.Type, o.Driver.Version)
dest, err = driverdistro.Build(ctx, o.Distro, o.Printer.WithWriter(&buf), o.Kr, o.Driver.Name, o.Driver.Type, o.Driver.Version, o.DownloadHeaders)
if o.Printer.Spinner != nil {
_ = o.Printer.Spinner.Stop()
}
Expand Down
1 change: 1 addition & 0 deletions cmd/driver/install/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Usage:
Flags:
--compile Whether to enable local compilation of drivers (default true)
--download Whether to enable download of prebuilt drivers (default true)
--download-headers Whether to enable automatic kernel headers download where supported (default true)
-h, --help help for install
--http-headers string Optional comma-separated list of headers for the http GET request (e.g. --http-headers='x-emc-namespace: default,Proxy-Authenticate: Basic'). Not necessary if default repo is used
--http-insecure Whether you want to allow insecure downloads or not
Expand Down
2 changes: 1 addition & 1 deletion pkg/driver/distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ func Build(ctx context.Context,
driverName string,
driverType drivertype.DriverType,
driverVer string,
downloadHeaders bool,
) (string, error) {
printer.Logger.Info("Trying to compile the requested driver")
driverFileName := toFilename(d, &kr, driverName, driverType)
Expand All @@ -190,7 +191,6 @@ func Build(ctx context.Context,
// Disable automatic kernel headers fetching
// if customizeBuild already retrieved kernel headers for us
// (and has set the KernelDirEnv key)
downloadHeaders := true
if _, ok := env[drivertype.KernelDirEnv]; ok {
downloadHeaders = false
}
Expand Down

0 comments on commit 150ef39

Please sign in to comment.