init
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/aerokube/images/build"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
chromeCmd = &cobra.Command{
|
||||
Use: "chrome",
|
||||
Short: "build Chrome image",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
req := build.Requirements{
|
||||
BrowserSource: build.BrowserSource(browserSource),
|
||||
BrowserChannel: browserChannel,
|
||||
DriverVersion: driverVersion,
|
||||
NoCache: noCache,
|
||||
TestsDir: testsDir,
|
||||
RunTests: test,
|
||||
IgnoreTests: ignoreTests,
|
||||
Tags: tags,
|
||||
PushImage: push,
|
||||
}
|
||||
chrome := &build.Chrome{req}
|
||||
return chrome.Build()
|
||||
},
|
||||
}
|
||||
)
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/aerokube/images/build"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
edgeCmd = &cobra.Command{
|
||||
Use: "edge",
|
||||
Short: "build Microsoft Edge image",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
req := build.Requirements{
|
||||
BrowserSource: build.BrowserSource(browserSource),
|
||||
BrowserChannel: browserChannel,
|
||||
DriverVersion: driverVersion,
|
||||
NoCache: noCache,
|
||||
TestsDir: testsDir,
|
||||
RunTests: test,
|
||||
IgnoreTests: ignoreTests,
|
||||
Tags: tags,
|
||||
PushImage: push,
|
||||
}
|
||||
edge := &build.Edge{req}
|
||||
return edge.Build()
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,36 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/aerokube/images/build"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
selenoidVersion string
|
||||
seleniumVersion string
|
||||
|
||||
firefoxCmd = &cobra.Command{
|
||||
Use: "firefox",
|
||||
Short: "build Firefox image",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
req := build.Requirements{
|
||||
BrowserSource: build.BrowserSource(browserSource),
|
||||
BrowserChannel: browserChannel,
|
||||
DriverVersion: driverVersion,
|
||||
NoCache: noCache,
|
||||
TestsDir: testsDir,
|
||||
RunTests: test,
|
||||
IgnoreTests: ignoreTests,
|
||||
Tags: tags,
|
||||
PushImage: push,
|
||||
}
|
||||
firefox := &build.Firefox{SelenoidVersion: selenoidVersion, SeleniumVersion: seleniumVersion, Requirements: req}
|
||||
return firefox.Build()
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
firefoxCmd.Flags().StringVar(&selenoidVersion, "selenoid-version", build.LatestVersion, "Selenoid binary version")
|
||||
firefoxCmd.Flags().StringVar(&seleniumVersion, "selenium-version", "", "Selenium JAR version")
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/aerokube/images/build"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
operaCmd = &cobra.Command{
|
||||
Use: "opera",
|
||||
Short: "build Opera image",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
req := build.Requirements{
|
||||
BrowserSource: build.BrowserSource(browserSource),
|
||||
BrowserChannel: browserChannel,
|
||||
DriverVersion: driverVersion,
|
||||
NoCache: noCache,
|
||||
TestsDir: testsDir,
|
||||
RunTests: test,
|
||||
IgnoreTests: ignoreTests,
|
||||
Tags: tags,
|
||||
PushImage: push,
|
||||
}
|
||||
opera := &build.Opera{req}
|
||||
return opera.Build()
|
||||
},
|
||||
}
|
||||
)
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/aerokube/images/build"
|
||||
"github.com/spf13/cobra"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var (
|
||||
browserSource string
|
||||
browserChannel string
|
||||
driverVersion string
|
||||
noCache bool
|
||||
testsDir string
|
||||
test bool
|
||||
ignoreTests bool
|
||||
push bool
|
||||
tags []string
|
||||
|
||||
rootCmd = &cobra.Command{
|
||||
Use: "images",
|
||||
Short: "images is a tool for building Docker images with browsers",
|
||||
SilenceUsage: true,
|
||||
SilenceErrors: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return cmd.Usage()
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func initFlags() {
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatalf("get current dir: %v", err)
|
||||
}
|
||||
defaultTestsDir := filepath.Join(cwd, "../selenoid-container-tests")
|
||||
|
||||
rootCmd.PersistentFlags().StringSliceVarP(&tags, "tag", "t", []string{}, "image tag")
|
||||
rootCmd.PersistentFlags().StringVarP(&browserSource, "browser", "b", "", "browser APT package version, package file path, package file URL")
|
||||
rootCmd.PersistentFlags().StringVarP(&driverVersion, "driver-version", "d", build.LatestVersion, "webdriver version")
|
||||
rootCmd.PersistentFlags().StringVarP(&browserChannel, "channel", "c", "default", "browser channel")
|
||||
rootCmd.PersistentFlags().BoolVarP(&noCache, "no-cache", "n", false, "do not use Docker cache")
|
||||
rootCmd.PersistentFlags().StringVar(&testsDir, "tests-dir", defaultTestsDir, "directory with tests")
|
||||
rootCmd.PersistentFlags().BoolVar(&test, "test", false, "run tests")
|
||||
rootCmd.PersistentFlags().BoolVar(&ignoreTests, "ignore-tests", false, "continue to run even if tests failed")
|
||||
rootCmd.PersistentFlags().BoolVarP(&push, "push", "p", false, "push image to Docker registry")
|
||||
}
|
||||
|
||||
func init() {
|
||||
initFlags()
|
||||
rootCmd.AddCommand(chromeCmd)
|
||||
rootCmd.AddCommand(edgeCmd)
|
||||
rootCmd.AddCommand(firefoxCmd)
|
||||
rootCmd.AddCommand(operaCmd)
|
||||
rootCmd.AddCommand(yandexCmd)
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
if _, err := rootCmd.ExecuteC(); err != nil {
|
||||
log.Fatalf("command error: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
)
|
||||
|
||||
var (
|
||||
gitRevision = "HEAD"
|
||||
buildStamp = "unknown"
|
||||
)
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Show version",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("Git Revision: %s\n", gitRevision)
|
||||
fmt.Printf("UTC Build Time: %s\n", buildStamp)
|
||||
os.Exit(0)
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/aerokube/images/build"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
yandexCmd = &cobra.Command{
|
||||
Use: "yandex",
|
||||
Short: "build Yandex.Browser image",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
req := build.Requirements{
|
||||
BrowserSource: build.BrowserSource(browserSource),
|
||||
BrowserChannel: browserChannel,
|
||||
DriverVersion: driverVersion,
|
||||
NoCache: noCache,
|
||||
TestsDir: testsDir,
|
||||
RunTests: test,
|
||||
IgnoreTests: ignoreTests,
|
||||
Tags: tags,
|
||||
PushImage: push,
|
||||
}
|
||||
yandexBrowser := &build.YandexBrowser{req}
|
||||
return yandexBrowser.Build()
|
||||
},
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user