Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print Version Number on startup #1659

Merged
merged 11 commits into from
Aug 23, 2022
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ WORKDIR /workspace

# Make it runnable on a distroless image/without libc
ENV CGO_ENABLED=0

# Enviroment Variable used inside main to display current ARC version
ENV ARC_VERSION=$VERSION
# Copy the Go Modules manifests
COPY go.mod go.sum ./

Expand Down
11 changes: 8 additions & 3 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ func (c *Config) NewClient() (*Client, error) {
}
}
}

client.UserAgent = "actions-runner-controller"
version := getVersion("ARC_VERSION", "dev")
client.UserAgent = "actions-runner-controller:" + version + ""

return &Client{
Client: client,
Expand Down Expand Up @@ -439,7 +439,12 @@ func splitOwnerAndRepo(repo string) (string, string, error) {
}
return chunk[0], chunk[1], nil
}

func getVersion(key, fallback string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
return fallback
}
func getEnterpriseApiUrl(baseURL string) (string, error) {
baseEndpoint, err := url.Parse(baseURL)
if err != nil {
Expand Down
11 changes: 8 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ func (i *stringSlice) Set(value string) error {
*i = append(*i, value)
return nil
}

func getVersion(key, fallback string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
return fallback
}
func main() {
var (
err error
Expand All @@ -87,7 +92,6 @@ func main() {

commonRunnerLabels commaSeparatedStringSlice
)

var c github.Config
err = envconfig.Process("github", &c)
if err != nil {
Expand Down Expand Up @@ -122,7 +126,7 @@ func main() {
flag.Parse()

logger := logging.NewLogger(logLevel)

version := getVersion("ARC_VERSION", "dev")
c.Log = &logger

ghClient, err = c.NewClient()
Expand Down Expand Up @@ -214,6 +218,7 @@ func main() {

log.Info(
"Initializing actions-runner-controller",
"version", version,
"default-scale-down-delay", defaultScaleDownDelay,
"sync-period", syncPeriod,
"default-runner-image", runnerImage,
Expand Down