main.go 1.29 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
package main

import (
	"os"
	"path/filepath"
	"strings"

	"github.com/mattn/go-isatty"
	"github.com/urfave/cli/v2"

	"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
12
	oplog "github.com/ethereum-optimism/optimism/op-service/log"
13 14 15 16
	"github.com/ethereum/go-ethereum/log"
)

func main() {
17 18
	color := isatty.IsTerminal(os.Stderr.Fd())
	oplog.SetGlobalLogHandler(log.NewTerminalHandler(os.Stderr, color))
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

	app := &cli.App{
		Name:  "check-deploy-config",
		Usage: "Check that a deploy config is valid",
		Flags: []cli.Flag{
			&cli.StringFlag{
				Name:     "path",
				Required: true,
				Usage:    "File system path to the deploy config",
			},
		},
		Action: entrypoint,
	}

	if err := app.Run(os.Args); err != nil {
		log.Crit("error checking deploy config", "err", err)
	}
}

func entrypoint(ctx *cli.Context) error {
	path := ctx.String("path")

	name := strings.TrimSuffix(filepath.Base(path), filepath.Ext(path))
	log.Info("Checking deploy config", "name", name, "path", path)

	config, err := genesis.NewDeployConfig(path)
	if err != nil {
		return err
	}

49 50 51
	cfg := oplog.DefaultCLIConfig()
	logger := oplog.NewLogger(ctx.App.Writer, cfg)

52
	// Check the config, no need to call `CheckAddresses()`
53
	if err := config.Check(logger); err != nil {
54 55 56 57 58 59
		return err
	}

	log.Info("Valid deploy config")
	return nil
}