Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnfjson: support dnf base proxy configuration #574

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pkg/dnfjson/dnfjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"crypto/sha256"
"encoding/json"
"fmt"
"net/url"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -142,6 +143,9 @@ type Solver struct {

rootDir string

// Proxy to use while depsolving. This is used in DNF's base configuration.
proxy string

subscriptions *rhsm.Subscriptions
}

Expand Down Expand Up @@ -170,6 +174,15 @@ func (s *Solver) GetCacheDir() string {
return filepath.Join(s.cache.root, b)
}

// Set the proxy to use while depsolving. The proxy will be set in DNF's base configuration.
func (s *Solver) SetProxy(proxy string) error {
if _, err := url.ParseRequestURI(proxy); err != nil {
return fmt.Errorf("proxy URL %q is invalid", proxy)
}
s.proxy = proxy
return nil
}

// Depsolve the list of required package sets with explicit excludes using
// their associated repositories. Each package set is depsolved as a separate
// transactions in a chain. It returns a list of all packages (with solved
Expand Down Expand Up @@ -453,6 +466,7 @@ func (s *Solver) makeDepsolveRequest(pkgSets []rpmmd.PackageSet) (*Request, map[
Arch: s.arch,
Releasever: s.releaseVer,
CacheDir: s.GetCacheDir(),
Proxy: s.proxy,
Arguments: args,
}

Expand All @@ -471,6 +485,7 @@ func (s *Solver) makeDumpRequest(repos []rpmmd.RepoConfig) (*Request, error) {
Arch: s.arch,
Releasever: s.releaseVer,
CacheDir: s.GetCacheDir(),
Proxy: s.proxy,
Arguments: arguments{
Repos: dnfRepos,
},
Expand All @@ -490,6 +505,7 @@ func (s *Solver) makeSearchRequest(repos []rpmmd.RepoConfig, packages []string)
Arch: s.arch,
CacheDir: s.GetCacheDir(),
Releasever: s.releaseVer,
Proxy: s.proxy,
Arguments: arguments{
Repos: dnfRepos,
Search: searchArgs{
Expand Down Expand Up @@ -579,6 +595,9 @@ type Request struct {
// Cache directory for the DNF metadata
CacheDir string `json:"cachedir"`

// Proxy to use
Proxy string `json:"proxy"`

// Arguments for the action defined by Command
Arguments arguments `json:"arguments"`
}
Expand Down
Loading