2023-01-18 22:39:22 +00:00
|
|
|
// Copyright 2021-2023 the Pinniped contributors. All Rights Reserved.
|
2021-07-26 16:18:43 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
// Package main is the combined entrypoint for all Pinniped server components.
|
|
|
|
//
|
|
|
|
// It dispatches to the appropriate Main() entrypoint based the name it is invoked as (os.Args[0]). In our server
|
|
|
|
// container image, this binary is symlinked to several names such as `/usr/local/bin/pinniped-concierge`.
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-04-16 02:43:53 +00:00
|
|
|
"fmt"
|
2021-07-26 16:18:43 +00:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
2023-01-20 13:16:40 +00:00
|
|
|
"k8s.io/apimachinery/pkg/util/sets"
|
|
|
|
|
2022-04-16 02:43:53 +00:00
|
|
|
concierge "go.pinniped.dev/internal/concierge/server"
|
2023-02-03 01:32:21 +00:00
|
|
|
// this side effect import ensures that we use fipsonly crypto in boringcrypto mode.
|
2022-03-29 23:58:41 +00:00
|
|
|
_ "go.pinniped.dev/internal/crypto/ptls"
|
2021-07-26 16:18:43 +00:00
|
|
|
lua "go.pinniped.dev/internal/localuserauthenticator"
|
2022-04-16 02:43:53 +00:00
|
|
|
"go.pinniped.dev/internal/plog"
|
2021-07-26 16:18:43 +00:00
|
|
|
supervisor "go.pinniped.dev/internal/supervisor/server"
|
|
|
|
)
|
|
|
|
|
2022-08-24 21:45:55 +00:00
|
|
|
//nolint:gochecknoglobals // these are swapped during unit tests.
|
2021-07-26 16:18:43 +00:00
|
|
|
var (
|
2022-04-16 02:43:53 +00:00
|
|
|
fail = plog.Fatal
|
2021-07-26 16:18:43 +00:00
|
|
|
subcommands = map[string]func(){
|
|
|
|
"pinniped-concierge": concierge.Main,
|
|
|
|
"pinniped-supervisor": supervisor.Main,
|
|
|
|
"local-user-authenticator": lua.Main,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
if len(os.Args) == 0 {
|
2022-04-16 02:43:53 +00:00
|
|
|
fail(fmt.Errorf("missing os.Args"))
|
2021-07-26 16:18:43 +00:00
|
|
|
}
|
|
|
|
binary := filepath.Base(os.Args[0])
|
|
|
|
if subcommands[binary] == nil {
|
2023-01-20 13:16:40 +00:00
|
|
|
fail(fmt.Errorf("must be invoked as one of %v, not %q", sets.StringKeySet(subcommands).List(), binary))
|
2021-07-26 16:18:43 +00:00
|
|
|
}
|
|
|
|
subcommands[binary]()
|
|
|
|
}
|