зеркало из https://github.com/Azure/ARO-RP.git
fix/delete usage of flags at package-level and include Go test directive with -coverpkg in Makefile
This commit is contained in:
Родитель
d230a7f95b
Коммит
a3fb28cfc6
|
@ -23,6 +23,7 @@ gomock_reflect_*
|
|||
/mdm_statsd.socket
|
||||
/uts.txt
|
||||
/cover.out
|
||||
/cover_coverpkg.out
|
||||
/coverage.*
|
||||
/report.xml
|
||||
/e2e-report.xml
|
||||
|
|
3
Makefile
3
Makefile
|
@ -189,6 +189,9 @@ validate-fips:
|
|||
unit-test-go:
|
||||
go run ./vendor/gotest.tools/gotestsum/main.go --format pkgname --junitfile report.xml -- -tags=aro,containers_image_openpgp -coverprofile=cover.out ./...
|
||||
|
||||
unit-test-go-coverpkg:
|
||||
go run ./vendor/gotest.tools/gotestsum/main.go --format pkgname --junitfile report.xml -- -tags=aro,containers_image_openpgp -coverpkg=./... -coverprofile=cover_coverpkg.out ./...
|
||||
|
||||
lint-go:
|
||||
hack/lint-go.sh
|
||||
|
||||
|
|
|
@ -21,11 +21,9 @@ import (
|
|||
utillog "github.com/Azure/ARO-RP/pkg/util/log"
|
||||
)
|
||||
|
||||
var (
|
||||
fileName = flag.String("file", "-", "File to read. '-' for stdin.")
|
||||
)
|
||||
|
||||
func run(ctx context.Context, log *logrus.Entry) error {
|
||||
fileName := flag.String("file", "-", "File to read. '-' for stdin.")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
var (
|
||||
|
|
|
@ -19,10 +19,6 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/util/purge"
|
||||
)
|
||||
|
||||
var (
|
||||
dryRun = flag.Bool("dryRun", true, `Dry run`)
|
||||
)
|
||||
|
||||
// denylist exists as belt and braces protection for important RGs, even though
|
||||
// they may already have the persist=true tag set, especially if it is easy to
|
||||
// accidentally redeploy the RG without the persist=true tag set.
|
||||
|
@ -45,11 +41,13 @@ const (
|
|||
)
|
||||
|
||||
func main() {
|
||||
dryRun := flag.Bool("dryRun", true, `Dry run`)
|
||||
|
||||
flag.Parse()
|
||||
ctx := context.Background()
|
||||
log := utillog.GetLogger()
|
||||
|
||||
if err := run(ctx, log); err != nil {
|
||||
if err := run(ctx, log, dryRun); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +58,7 @@ type settings struct {
|
|||
deleteGroupPrefixes []string
|
||||
}
|
||||
|
||||
func run(ctx context.Context, log *logrus.Entry) error {
|
||||
func run(ctx context.Context, log *logrus.Entry, dryRun *bool) error {
|
||||
for _, key := range []string{
|
||||
"AZURE_CLIENT_ID",
|
||||
"AZURE_CLIENT_SECRET",
|
||||
|
|
|
@ -26,14 +26,12 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/util/version"
|
||||
)
|
||||
|
||||
var (
|
||||
certFile = flag.String("certFile", "secrets/proxy.crt", "file containing server certificate")
|
||||
keyFile = flag.String("keyFile", "secrets/proxy.key", "file containing server key")
|
||||
port = flag.Int("port", 6443, "Port to listen on")
|
||||
host = flag.String("host", "localhost", "Host to listen on")
|
||||
)
|
||||
|
||||
func run(ctx context.Context, l *logrus.Entry) error {
|
||||
certFile := flag.String("certFile", "secrets/proxy.crt", "file containing server certificate")
|
||||
keyFile := flag.String("keyFile", "secrets/proxy.key", "file containing server key")
|
||||
port := flag.Int("port", 6443, "Port to listen on")
|
||||
host := flag.String("host", "localhost", "Host to listen on")
|
||||
|
||||
l.Printf("starting, git commit %s", version.GitCommit)
|
||||
|
||||
flag.Parse()
|
||||
|
|
|
@ -15,19 +15,12 @@ import (
|
|||
utiltls "github.com/Azure/ARO-RP/pkg/util/tls"
|
||||
)
|
||||
|
||||
var (
|
||||
client = flag.Bool("client", false, "generate client certificate")
|
||||
ca = flag.Bool("ca", false, "generate ca certificate")
|
||||
keyFile = flag.String("keyFile", "", `file containing signing key in der format (default "" - self-signed)`)
|
||||
certFile = flag.String("certFile", "", `file containing signing certificate in der format (default "" - self-signed)`)
|
||||
)
|
||||
|
||||
func run(name string) error {
|
||||
func run(name string, flags flagsType) error {
|
||||
var signingKey *rsa.PrivateKey
|
||||
var signingCert *x509.Certificate
|
||||
|
||||
if *keyFile != "" {
|
||||
b, err := os.ReadFile(*keyFile)
|
||||
if *flags.keyFile != "" {
|
||||
b, err := os.ReadFile(*flags.keyFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -38,8 +31,8 @@ func run(name string) error {
|
|||
}
|
||||
}
|
||||
|
||||
if *certFile != "" {
|
||||
b, err := os.ReadFile(*certFile)
|
||||
if *flags.certFile != "" {
|
||||
b, err := os.ReadFile(*flags.certFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -50,7 +43,7 @@ func run(name string) error {
|
|||
}
|
||||
}
|
||||
|
||||
key, cert, err := utiltls.GenerateKeyAndCertificate(name, signingKey, signingCert, *ca, *client)
|
||||
key, cert, err := utiltls.GenerateKeyAndCertificate(name, signingKey, signingCert, *flags.ca, *flags.client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -92,7 +85,21 @@ func usage() {
|
|||
flag.PrintDefaults()
|
||||
}
|
||||
|
||||
type flagsType struct {
|
||||
client *bool
|
||||
ca *bool
|
||||
keyFile *string
|
||||
certFile *string
|
||||
}
|
||||
|
||||
func main() {
|
||||
flags := flagsType{
|
||||
client: flag.Bool("client", false, "generate client certificate"),
|
||||
ca: flag.Bool("ca", false, "generate ca certificate"),
|
||||
keyFile: flag.String("keyFile", "", `file containing signing key in der format (default "" - self-signed)`),
|
||||
certFile: flag.String("certFile", "", `file containing signing certificate in der format (default "" - self-signed)`),
|
||||
}
|
||||
|
||||
flag.Usage = usage
|
||||
flag.Parse()
|
||||
|
||||
|
@ -101,7 +108,7 @@ func main() {
|
|||
os.Exit(2)
|
||||
}
|
||||
|
||||
if err := run(flag.Arg(0)); err != nil {
|
||||
if err := run(flag.Arg(0), flags); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,12 +27,10 @@ const (
|
|||
SessionKeyGroups = "groups"
|
||||
)
|
||||
|
||||
var (
|
||||
username = flag.String("username", "testuser", "username of the portal user")
|
||||
groups = flag.String("groups", "", "comma-separated list of groups the user is in")
|
||||
)
|
||||
|
||||
func run(ctx context.Context, log *logrus.Entry) error {
|
||||
username := flag.String("username", "testuser", "username of the portal user")
|
||||
groups := flag.String("groups", "", "comma-separated list of groups the user is in")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
_env, err := env.NewCore(ctx, log)
|
||||
|
|
|
@ -11,14 +11,12 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/util/version"
|
||||
)
|
||||
|
||||
var (
|
||||
certFile = flag.String("certFile", "secrets/proxy.crt", "file containing server certificate")
|
||||
keyFile = flag.String("keyFile", "secrets/proxy.key", "file containing server key")
|
||||
clientCertFile = flag.String("clientCertFile", "secrets/proxy-client.crt", "file containing client certificate")
|
||||
subnet = flag.String("subnet", "10.0.0.0/8", "allowed subnet")
|
||||
)
|
||||
|
||||
func main() {
|
||||
certFile := flag.String("certFile", "secrets/proxy.crt", "file containing server certificate")
|
||||
keyFile := flag.String("keyFile", "secrets/proxy.key", "file containing server key")
|
||||
clientCertFile := flag.String("clientCertFile", "secrets/proxy-client.crt", "file containing client certificate")
|
||||
subnet := flag.String("subnet", "10.0.0.0/8", "allowed subnet")
|
||||
|
||||
log := utillog.GetLogger()
|
||||
|
||||
log.Printf("starting, git commit %s", version.GitCommit)
|
||||
|
|
|
@ -35,19 +35,12 @@ import (
|
|||
// TLS client certificate. For better or worse, this means we can avoid having
|
||||
// to add more configurability to the client libraries.
|
||||
|
||||
var (
|
||||
certFile = flag.String("certFile", "secrets/localhost.crt", "file containing server certificate")
|
||||
keyFile = flag.String("keyFile", "secrets/localhost.key", "file containing server key")
|
||||
clientCertFile = flag.String("clientCertFile", "secrets/dev-client.crt", "file containing client certificate")
|
||||
clientKeyFile = flag.String("clientKeyFile", "secrets/dev-client.key", "file containing client key")
|
||||
)
|
||||
|
||||
func run(ctx context.Context, log *logrus.Entry) error {
|
||||
func run(ctx context.Context, log *logrus.Entry, flags flagsType) error {
|
||||
if len(flag.Args()) != 1 {
|
||||
return fmt.Errorf("usage: %s IP", os.Args[0])
|
||||
}
|
||||
|
||||
certb, err := os.ReadFile(*certFile)
|
||||
certb, err := os.ReadFile(*flags.certFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -60,7 +53,7 @@ func run(ctx context.Context, log *logrus.Entry) error {
|
|||
pool := x509.NewCertPool()
|
||||
pool.AddCert(cert)
|
||||
|
||||
keyb, err := os.ReadFile(*keyFile)
|
||||
keyb, err := os.ReadFile(*flags.keyFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -70,12 +63,12 @@ func run(ctx context.Context, log *logrus.Entry) error {
|
|||
return err
|
||||
}
|
||||
|
||||
clientCertb, err := os.ReadFile(*clientCertFile)
|
||||
clientCertb, err := os.ReadFile(*flags.clientCertFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clientKeyb, err := os.ReadFile(*clientKeyFile)
|
||||
clientKeyb, err := os.ReadFile(*flags.clientKeyFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -151,14 +144,28 @@ func run(ctx context.Context, log *logrus.Entry) error {
|
|||
}
|
||||
}
|
||||
|
||||
type flagsType struct {
|
||||
certFile *string
|
||||
keyFile *string
|
||||
clientCertFile *string
|
||||
clientKeyFile *string
|
||||
}
|
||||
|
||||
func main() {
|
||||
log := utillog.GetLogger()
|
||||
|
||||
log.Printf("starting, git commit %s", version.GitCommit)
|
||||
|
||||
flags := flagsType{
|
||||
certFile: flag.String("certFile", "secrets/localhost.crt", "file containing server certificate"),
|
||||
keyFile: flag.String("keyFile", "secrets/localhost.key", "file containing server key"),
|
||||
clientCertFile: flag.String("clientCertFile", "secrets/dev-client.crt", "file containing client certificate"),
|
||||
clientKeyFile: flag.String("clientKeyFile", "secrets/dev-client.key", "file containing client key"),
|
||||
}
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if err := run(context.Background(), log); err != nil {
|
||||
if err := run(context.Background(), log, flags); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче