Add git name option for source-rpm

Adds the ability to set a source git repo name for the package that will
be imported.
This commit is contained in:
Louis Abel 2024-06-09 21:40:53 -07:00
parent f2864a875a
commit 18f9f5c77c
Signed by: label
GPG Key ID: 3331F061D1D9990E
2 changed files with 14 additions and 5 deletions

View File

@ -32,6 +32,7 @@ import (
var (
sourceRpm string
sourceRpmGitName string
sshKeyLocation string
sshUser string
upstreamPrefix string
@ -72,6 +73,7 @@ func mn(_ *cobra.Command, _ []string) {
Version: version,
StorageAddr: storageAddr,
Package: sourceRpm,
PackageGitName: sourceRpmGitName,
ModuleMode: moduleMode,
TmpFsMode: tmpFsMode,
ModulePrefix: modulePrefix,
@ -125,6 +127,7 @@ func main() {
root.Flags().StringVar(&storageAddr, "storage-addr", "", "Bucket to use as blob storage")
_ = root.MarkFlagRequired("storage-addr")
root.Flags().StringVar(&sourceRpmGitName, "source-rpm-git-name", "", "Actual git repo name of package if name is different from source-rpm value")
root.Flags().StringVar(&sshKeyLocation, "ssh-key-location", "", "Location of the SSH key to use to authenticate against upstream")
root.Flags().StringVar(&sshUser, "ssh-user", "git", "SSH User")
root.Flags().StringVar(&gitCommitterName, "git-committer-name", "rockyautomation", "Name of committer")

View File

@ -68,9 +68,10 @@ const (
type ProcessDataRequest struct {
// Required
Version int
StorageAddr string
Package string
Version int
StorageAddr string
Package string
PackageGitName string
// Optional
ModuleMode bool
@ -219,6 +220,11 @@ func NewProcessData(req *ProcessDataRequest) (*data.ProcessData, error) {
return nil, fmt.Errorf("package cannot be empty")
}
// tells srpmproc what the source name actually is
if req.PackageGitName == "" {
req.PackageGitName = req.Package
}
var importer data.ImportMode
var blobStorage blob.Storage
@ -238,9 +244,9 @@ func NewProcessData(req *ProcessDataRequest) (*data.ProcessData, error) {
sourceRpmLocation := ""
if req.ModuleMode {
sourceRpmLocation = fmt.Sprintf("%s/%s", req.ModulePrefix, req.Package)
sourceRpmLocation = fmt.Sprintf("%s/%s", req.ModulePrefix, req.PackageGitName)
} else {
sourceRpmLocation = fmt.Sprintf("%s/%s", req.RpmPrefix, req.Package)
sourceRpmLocation = fmt.Sprintf("%s/%s", req.RpmPrefix, req.PackageGitName)
}
importer = &modes.GitMode{}