internal/rpmmd: return helpful error message when subscriptions == nil
It can happen that the system is not subscribed and the user requests a source with rhsm set to "true". Return useful error message in such case informing the user what to do about it.
This commit is contained in:
parent
04a62d677f
commit
1227633e7c
1 changed files with 3 additions and 0 deletions
|
|
@ -404,6 +404,9 @@ func (repo RepoConfig) toDNFRepoConfig(rpmmd *rpmmdImpl, i int, arch, releasever
|
|||
MetadataExpire: repo.MetadataExpire,
|
||||
}
|
||||
if repo.RHSM {
|
||||
if rpmmd.subscriptions == nil {
|
||||
return dnfRepoConfig{}, fmt.Errorf("This system does not have any valid subscriptions. Subscribe it before specifying rhsm: true in sources.")
|
||||
}
|
||||
secrets, err := rpmmd.subscriptions.GetSecretsForBaseurl(repo.BaseURL, arch, releasever)
|
||||
if err != nil {
|
||||
return dnfRepoConfig{}, fmt.Errorf("RHSM secrets not found on the host for this baseurl: %s", repo.BaseURL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue