|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "builder/installer" |
| 5 | + "flag" |
| 6 | + "fmt" |
| 7 | + "os" |
| 8 | + |
| 9 | + "github.com/roemer/gover" |
| 10 | +) |
| 11 | + |
| 12 | +// //////// |
| 13 | +// Main |
| 14 | +// //////// |
| 15 | + |
| 16 | +func main() { |
| 17 | + if err := runMain(); err != nil { |
| 18 | + fmt.Printf("Error: %v\n", err) |
| 19 | + os.Exit(1) |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +func runMain() error { |
| 24 | + // Create and process the feature |
| 25 | + yqVersion := flag.String("yqVersion", "system-default", "The version of yq to install.") |
| 26 | + gettextbaseVersion := flag.String("gettextbaseVersion", "system-default", "The version of gettext-base to install.") |
| 27 | + yamllintVersion := flag.String("yamllintVersion", "system-default", "The version of yamllint to install.") |
| 28 | + gitlfsVersion := flag.String("gitlfsVersion", "system-default", "The version of git-lfs to install.") |
| 29 | + sshpassVersion := flag.String("sshpassVersion", "system-default", "The version of sshpass to install.") |
| 30 | + |
| 31 | + feature := installer.NewFeature("CI Utility", true, |
| 32 | + &yqComponent{ |
| 33 | + ComponentBase: installer.NewComponentBase("yq", *yqVersion), |
| 34 | + }, |
| 35 | + &gettextbaseComponent{ |
| 36 | + ComponentBase: installer.NewComponentBase("gettext-base", *gettextbaseVersion), |
| 37 | + }, |
| 38 | + &yamllintComponent{ |
| 39 | + ComponentBase: installer.NewComponentBase("yamllint", *yamllintVersion), |
| 40 | + }, |
| 41 | + &gitlfsComponent{ |
| 42 | + ComponentBase: installer.NewComponentBase("git-lfs", *gitlfsVersion), |
| 43 | + }, |
| 44 | + &sshpassComponent{ |
| 45 | + ComponentBase: installer.NewComponentBase("sshpass", *sshpassVersion), |
| 46 | + }, |
| 47 | + ) |
| 48 | + return feature.Process() |
| 49 | +} |
| 50 | + |
| 51 | +// //////// |
| 52 | +// Implementation |
| 53 | +// //////// |
| 54 | + |
| 55 | +type yqComponent struct { |
| 56 | + *installer.ComponentBase |
| 57 | +} |
| 58 | + |
| 59 | +func (c *yqComponent) InstallVersion(*gover.Version) error { |
| 60 | + return installer.Tools.Apt.InstallDependencies("yq") |
| 61 | +} |
| 62 | + |
| 63 | +type gettextbaseComponent struct { |
| 64 | + *installer.ComponentBase |
| 65 | +} |
| 66 | + |
| 67 | +func (c *gettextbaseComponent) InstallVersion(*gover.Version) error { |
| 68 | + return installer.Tools.Apt.InstallDependencies("gettext-base") |
| 69 | +} |
| 70 | + |
| 71 | +type yamllintComponent struct { |
| 72 | + *installer.ComponentBase |
| 73 | +} |
| 74 | + |
| 75 | +func (c *yamllintComponent) InstallVersion(*gover.Version) error { |
| 76 | + return installer.Tools.Apt.InstallDependencies("yamllint") |
| 77 | +} |
| 78 | + |
| 79 | +type gitlfsComponent struct { |
| 80 | + *installer.ComponentBase |
| 81 | +} |
| 82 | + |
| 83 | +func (c *gitlfsComponent) InstallVersion(*gover.Version) error { |
| 84 | + return installer.Tools.Apt.InstallDependencies("git-lfs") |
| 85 | +} |
| 86 | + |
| 87 | +type sshpassComponent struct { |
| 88 | + *installer.ComponentBase |
| 89 | +} |
| 90 | + |
| 91 | +func (c *sshpassComponent) InstallVersion(*gover.Version) error { |
| 92 | + return installer.Tools.Apt.InstallDependencies("sshpass") |
| 93 | +} |
0 commit comments