Skip to content

Commit

Permalink
cmd/clair: document constants
Browse files Browse the repository at this point in the history
  • Loading branch information
jzelinskie committed Sep 6, 2018
1 parent fffb67f commit b20482e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions cmd/clair/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017 clair authors
// Copyright 2018 clair authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -61,7 +61,17 @@ import (
_ "github.com/coreos/clair/ext/vulnsrc/ubuntu"
)

const maxDBConnectionAttempts = 20
// MaxDBConnectionAttempts is the total number of tries that Clair will use to
// initially connect to a database at start-up.
const MaxDBConnectionAttempts = 20

// BinaryDependencies are the programs that Clair expects to be on the $PATH
// because it creates subprocesses of these programs.
var BinaryDependencies = []string{
"git",
"rpm",
"xz",
}

func waitForSignals(signals ...os.Signal) {
interrupts := make(chan os.Signal, 1)
Expand Down Expand Up @@ -136,7 +146,7 @@ func Boot(config *Config) {
// Open database
var db database.Datastore
var dbError error
for attempts := 1; attempts <= maxDBConnectionAttempts; attempts++ {
for attempts := 1; attempts <= MaxDBConnectionAttempts; attempts++ {
db, dbError = database.Open(config.Database)
if dbError == nil {
break
Expand Down Expand Up @@ -180,7 +190,7 @@ func main() {
flag.Parse()

// Check for dependencies.
for _, bin := range []string{"git", "rpm", "xz"} {
for _, bin := range BinaryDependencies {
_, err := exec.LookPath(bin)
if err != nil {
log.WithError(err).WithField("dependency", bin).Fatal("failed to find dependency")
Expand Down

0 comments on commit b20482e

Please sign in to comment.