srpmproc/cmd/srpmproc/main.go

74 lines
2.1 KiB
Go
Raw Normal View History

2020-12-14 01:29:02 +00:00
package main
import (
"cloud.google.com/go/storage"
"context"
"log"
"strings"
2020-12-14 01:29:02 +00:00
"github.com/mstg/srpmproc/internal"
"github.com/spf13/cobra"
2020-12-14 01:29:02 +00:00
)
var (
sourceRpm string
sshKeyLocation string
sshUser string
upstreamPrefix string
branch string
gcsBucket string
2020-12-17 11:12:10 +00:00
gitCommitterName string
gitCommitterEmail string
2020-12-14 01:29:02 +00:00
)
var root = &cobra.Command{
Use: "srpmproc",
Run: mn,
2020-12-14 01:29:02 +00:00
}
func mn(_ *cobra.Command, _ []string) {
ctx := context.Background()
client, err := storage.NewClient(ctx)
if err != nil {
log.Fatalf("could not create gcloud client: %v", err)
}
sourceRpmLocation := ""
if strings.HasPrefix(sourceRpm, "file://") {
sourceRpmLocation = strings.TrimPrefix(sourceRpm, "file://")
} else {
log.Fatal("non-local SRPMs are currently not supported")
}
internal.ProcessRPM(&internal.ProcessData{
2020-12-17 11:12:10 +00:00
RpmLocation: sourceRpmLocation,
UpstreamPrefix: upstreamPrefix,
SshKeyLocation: sshKeyLocation,
SshUser: sshUser,
Branch: branch,
Bucket: client.Bucket(gcsBucket),
GitCommitterName: gitCommitterName,
GitCommitterEmail: gitCommitterEmail,
})
2020-12-14 01:29:02 +00:00
}
func main() {
root.Flags().StringVar(&sourceRpm, "source-rpm", "", "Location of RPM to process")
_ = root.MarkFlagRequired("source-rpm")
root.Flags().StringVar(&upstreamPrefix, "upstream-prefix", "", "Upstream git repository prefix")
_ = root.MarkFlagRequired("upstream-prefix")
root.Flags().StringVar(&branch, "branch", "", "Upstream branch")
_ = root.MarkFlagRequired("branch")
root.Flags().StringVar(&gcsBucket, "gcs-bucket", "", "Bucket to use as blob storage")
_ = root.MarkFlagRequired("gcs-bucket")
2020-12-17 11:12:10 +00:00
root.Flags().StringVar(&gitCommitterName, "git-committer-name", "distrobuild-bot", "Name of committer")
root.Flags().StringVar(&gitCommitterEmail, "git-committer-email", "mustafa+distrobuild@bycrates.com", "Email of committer")
2020-12-17 11:12:10 +00:00
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")
if err := root.Execute(); err != nil {
log.Fatal(err)
}
2020-12-14 01:29:02 +00:00
}