main.go 1.86 KB
Newer Older
Mustafa Gezen's avatar
Mustafa Gezen committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main

import (
    "log"
    "strings"

    "github.com/mstg/srpmproc/internal"
    "github.com/spf13/cobra"
)

var (
    sourceRpm         string
    sshKeyLocation    string
    sshUser           string
    upstreamPrefix    string
    branch            string
    gcsBucket         string
    debrandedTarballs []string
)

var root = &cobra.Command{
    Use: "srpmproc",
    Run: mn,
}

func mn(_ *cobra.Command, _ []string) {
    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{
        RpmLocation:    sourceRpmLocation,
        UpstreamPrefix: upstreamPrefix,
        SshKeyLocation: sshKeyLocation,
        SshUser:        sshUser,
        Branch:         branch,
    })
}

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")

    root.Flags().StringVar(&sshKeyLocation, "ssh-key-location", "", "Location of the SSH key to use to authenticate against upstream (Optional)")
    root.Flags().StringVar(&sshUser, "ssh-user", "git", "SSH User (Optional, default git)")
    root.Flags().StringArrayVar(&debrandedTarballs, "debranded-tarball", []string{}, "GCS urls to debranded tarballs (stage 2) (Optional)")

    if err := root.Execute(); err != nil {
        log.Fatal(err)
    }
}