go.fuchsia.dev/infra@v0.0.0-20240507153436-9b593402251b/cmd/autogardener/main.go (about)

     1  // Copyright 2022 The Fuchsia Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style license that can be
     3  // found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"log"
     9  	"os"
    10  
    11  	"cloud.google.com/go/bigquery"
    12  	"github.com/maruel/subcommands"
    13  	"go.chromium.org/luci/auth"
    14  	"go.chromium.org/luci/auth/client/authcli"
    15  	"go.chromium.org/luci/common/api/gitiles"
    16  	"go.chromium.org/luci/hardcoded/chromeinfra"
    17  )
    18  
    19  func getApplication(defaultAuthOpts auth.Options) *subcommands.DefaultApplication {
    20  	defaultAuthOpts.Scopes = []string{
    21  		auth.OAuthScopeEmail,
    22  		bigquery.Scope,
    23  		gitiles.OAuthScope,
    24  	}
    25  	return &subcommands.DefaultApplication{
    26  		Name:  "autogardener",
    27  		Title: "Tool for identifying culprit CLs that cause postsubmit breakages.",
    28  		Commands: []*subcommands.Command{
    29  			cmdCulprit(defaultAuthOpts),
    30  			authcli.SubcommandInfo(defaultAuthOpts, "whoami", false),
    31  			authcli.SubcommandLogin(defaultAuthOpts, "login", false),
    32  			authcli.SubcommandLogout(defaultAuthOpts, "logout", false),
    33  			subcommands.CmdHelp,
    34  		},
    35  	}
    36  }
    37  
    38  func main() {
    39  	log.SetFlags(log.Lmicroseconds)
    40  	app := getApplication(chromeinfra.DefaultAuthOptions())
    41  	os.Exit(subcommands.Run(app, nil))
    42  }