Update 3rd party license information
This commit is contained in:
parent
bd24865076
commit
815c557f9a
1023 changed files with 158572 additions and 0 deletions
134
third-party/github.com/letsencrypt/boulder/cmd/boulder/main.go
vendored
Normal file
134
third-party/github.com/letsencrypt/boulder/cmd/boulder/main.go
vendored
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
_ "github.com/letsencrypt/boulder/cmd/admin-revoker"
|
||||
_ "github.com/letsencrypt/boulder/cmd/akamai-purger"
|
||||
_ "github.com/letsencrypt/boulder/cmd/bad-key-revoker"
|
||||
_ "github.com/letsencrypt/boulder/cmd/boulder-ca"
|
||||
_ "github.com/letsencrypt/boulder/cmd/boulder-observer"
|
||||
_ "github.com/letsencrypt/boulder/cmd/boulder-publisher"
|
||||
_ "github.com/letsencrypt/boulder/cmd/boulder-ra"
|
||||
_ "github.com/letsencrypt/boulder/cmd/boulder-sa"
|
||||
_ "github.com/letsencrypt/boulder/cmd/boulder-va"
|
||||
_ "github.com/letsencrypt/boulder/cmd/boulder-wfe2"
|
||||
_ "github.com/letsencrypt/boulder/cmd/cert-checker"
|
||||
_ "github.com/letsencrypt/boulder/cmd/contact-auditor"
|
||||
_ "github.com/letsencrypt/boulder/cmd/crl-checker"
|
||||
_ "github.com/letsencrypt/boulder/cmd/crl-storer"
|
||||
_ "github.com/letsencrypt/boulder/cmd/crl-updater"
|
||||
_ "github.com/letsencrypt/boulder/cmd/expiration-mailer"
|
||||
_ "github.com/letsencrypt/boulder/cmd/id-exporter"
|
||||
_ "github.com/letsencrypt/boulder/cmd/log-validator"
|
||||
_ "github.com/letsencrypt/boulder/cmd/nonce-service"
|
||||
_ "github.com/letsencrypt/boulder/cmd/notify-mailer"
|
||||
_ "github.com/letsencrypt/boulder/cmd/ocsp-responder"
|
||||
_ "github.com/letsencrypt/boulder/cmd/remoteva"
|
||||
_ "github.com/letsencrypt/boulder/cmd/reversed-hostname-checker"
|
||||
_ "github.com/letsencrypt/boulder/cmd/rocsp-tool"
|
||||
"github.com/letsencrypt/boulder/core"
|
||||
|
||||
"github.com/letsencrypt/boulder/cmd"
|
||||
)
|
||||
|
||||
// readAndValidateConfigFile uses the ConfigValidator registered for the given
|
||||
// command to validate the provided config file. If the command does not have a
|
||||
// registered ConfigValidator, this function does nothing.
|
||||
func readAndValidateConfigFile(name, filename string) error {
|
||||
cv := cmd.LookupConfigValidator(name)
|
||||
if cv == nil {
|
||||
return nil
|
||||
}
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
if name == "boulder-observer" {
|
||||
// Only the boulder-observer uses YAML config files.
|
||||
return cmd.ValidateYAMLConfig(cv, file)
|
||||
}
|
||||
return cmd.ValidateJSONConfig(cv, file)
|
||||
}
|
||||
|
||||
// getConfigPath returns the path to the config file if it was provided as a
|
||||
// command line flag. If the flag was not provided, it returns an empty string.
|
||||
func getConfigPath() string {
|
||||
for i := range len(os.Args) {
|
||||
arg := os.Args[i]
|
||||
if arg == "--config" || arg == "-config" {
|
||||
if i+1 < len(os.Args) {
|
||||
return os.Args[i+1]
|
||||
}
|
||||
}
|
||||
if strings.HasPrefix(arg, "--config=") {
|
||||
return strings.TrimPrefix(arg, "--config=")
|
||||
}
|
||||
if strings.HasPrefix(arg, "-config=") {
|
||||
return strings.TrimPrefix(arg, "-config=")
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var boulderUsage = fmt.Sprintf(`Usage: %s <subcommand> [flags]
|
||||
|
||||
Each boulder component has its own subcommand. Use --list to see
|
||||
a list of the available components. Use <subcommand> --help to
|
||||
see the usage for a specific component.
|
||||
`,
|
||||
core.Command())
|
||||
|
||||
func main() {
|
||||
defer cmd.AuditPanic()
|
||||
var command string
|
||||
if core.Command() == "boulder" {
|
||||
// Operator passed the boulder component as a subcommand.
|
||||
if len(os.Args) <= 1 {
|
||||
// No arguments passed.
|
||||
fmt.Fprint(os.Stderr, boulderUsage)
|
||||
return
|
||||
}
|
||||
|
||||
if os.Args[1] == "--help" || os.Args[1] == "-help" {
|
||||
// Help flag passed.
|
||||
fmt.Fprint(os.Stderr, boulderUsage)
|
||||
return
|
||||
}
|
||||
|
||||
if os.Args[1] == "--list" || os.Args[1] == "-list" {
|
||||
// List flag passed.
|
||||
for _, c := range cmd.AvailableCommands() {
|
||||
fmt.Println(c)
|
||||
}
|
||||
return
|
||||
}
|
||||
command = os.Args[1]
|
||||
|
||||
// Remove the subcommand from the arguments.
|
||||
os.Args = os.Args[1:]
|
||||
} else {
|
||||
// Operator ran a boulder component using a symlink.
|
||||
command = core.Command()
|
||||
}
|
||||
|
||||
config := getConfigPath()
|
||||
if config != "" {
|
||||
// Config flag passed.
|
||||
err := readAndValidateConfigFile(command, config)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error validating config file %q for command %q: %s\n", config, command, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
commandFunc := cmd.LookupCommand(command)
|
||||
if commandFunc == nil {
|
||||
fmt.Fprintf(os.Stderr, "Unknown subcommand %q.\n", command)
|
||||
os.Exit(1)
|
||||
}
|
||||
commandFunc()
|
||||
}
|
||||
74
third-party/github.com/letsencrypt/boulder/cmd/boulder/main_test.go
vendored
Normal file
74
third-party/github.com/letsencrypt/boulder/cmd/boulder/main_test.go
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/letsencrypt/boulder/cmd"
|
||||
"github.com/letsencrypt/boulder/test"
|
||||
)
|
||||
|
||||
// TestConfigValidation checks that each of the components which register a
|
||||
// validation tagged Config struct at init time can be used to successfully
|
||||
// validate their corresponding test configuration files.
|
||||
func TestConfigValidation(t *testing.T) {
|
||||
configPath := "../../test/config"
|
||||
if os.Getenv("BOULDER_CONFIG_DIR") == "test/config-next" {
|
||||
configPath = "../../test/config-next"
|
||||
}
|
||||
|
||||
// Each component is a set of `cmd` package name and a list of paths to
|
||||
// configuration files to validate.
|
||||
components := make(map[string][]string)
|
||||
|
||||
// For each component, add the paths to the configuration files to validate.
|
||||
// By default we assume that the configuration file is named after the
|
||||
// component. However, there are some exceptions to this rule. We've added
|
||||
// special cases for these components.
|
||||
for _, cmdName := range cmd.AvailableConfigValidators() {
|
||||
var fileNames []string
|
||||
switch cmdName {
|
||||
case "boulder-ca":
|
||||
fileNames = []string{"ca.json"}
|
||||
case "boulder-observer":
|
||||
fileNames = []string{"observer.yml"}
|
||||
case "boulder-publisher":
|
||||
fileNames = []string{"publisher.json"}
|
||||
case "boulder-ra":
|
||||
fileNames = []string{"ra.json"}
|
||||
case "boulder-sa":
|
||||
fileNames = []string{"sa.json"}
|
||||
case "boulder-va":
|
||||
fileNames = []string{
|
||||
"va.json",
|
||||
"va-remote-a.json",
|
||||
"va-remote-b.json",
|
||||
}
|
||||
case "remoteva":
|
||||
fileNames = []string{
|
||||
"remoteva-a.json",
|
||||
"remoteva-b.json",
|
||||
}
|
||||
case "boulder-wfe2":
|
||||
fileNames = []string{"wfe2.json"}
|
||||
case "nonce-service":
|
||||
fileNames = []string{
|
||||
"nonce-a.json",
|
||||
"nonce-b.json",
|
||||
}
|
||||
default:
|
||||
fileNames = []string{cmdName + ".json"}
|
||||
}
|
||||
components[cmdName] = append(components[cmdName], fileNames...)
|
||||
}
|
||||
t.Parallel()
|
||||
for cmdName, paths := range components {
|
||||
for _, path := range paths {
|
||||
t.Run(path, func(t *testing.T) {
|
||||
err := readAndValidateConfigFile(cmdName, fmt.Sprintf("%s/%s", configPath, path))
|
||||
test.AssertNotError(t, err, fmt.Sprintf("Failed to validate config file %q", path))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue