func main() {
	rootConfig, err := config.NewConfig(os.Args)
	if err != nil {
		panic(fmt.Sprintf("Failed to parse config: %s", err.Error()))
	}

	err = rootConfig.Validate()
	if err != nil {
		panic(fmt.Sprintf("Invalid config: %s", err.Error()))
	}

	err = rootConfig.BuildLogger()
	if err != nil {
		panic(fmt.Sprintf("Failed to build logger: %s", err.Error()))
	}
	logger := rootConfig.Logger

	nodeManager := node_manager.New(rootConfig, clock.DefaultClock())
	bootstrapper := bootstrapperPkg.New(nodeManager)

	if rootConfig.RepairMode == "bootstrap" {
		err = bootstrapper.Bootstrap()
	} else if rootConfig.RepairMode == "rejoin-unsafe" {
		err = bootstrapper.RejoinUnsafe()
	} else {
		logger.Error("Invalid repair mode:", errors.New(fmt.Sprintf("%s", rootConfig.RepairMode)))
		printHumanReadableErr(err)
		os.Exit(1)
	}

	if err != nil {
		logger.Error("Failed to repair cluster", err, lager.Data{
			"config": rootConfig,
		})
		printHumanReadableErr(err)
		os.Exit(1)
	}

	logger.Info("Successfully repaired cluster")
	fmt.Println("Successfully repaired cluster")
}
	bootstrapperPkg "github.com/cloudfoundry-incubator/cf-mysql-bootstrap/bootstrapper"
	"github.com/cloudfoundry-incubator/cf-mysql-bootstrap/bootstrapper/node_manager/fakes"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var (
	bootstrapper    *bootstrapperPkg.Bootstrapper
	fakeNodeManager *fakes.FakeNodeManager
)

var _ = Describe("Bootstrap", func() {

	BeforeEach(func() {
		fakeNodeManager = &fakes.FakeNodeManager{}
		bootstrapper = bootstrapperPkg.New(fakeNodeManager)
	})

	Context("when all nodeManager calls succeed", func() {

		BeforeEach(func() {
			fakeNodeManager.GetSequenceNumbersReturns(map[string]int{
				"url1": 1,
				"url3": 3,
				"url2": 2,
			}, nil)
		})

		It("bootstraps the node with the highest sequence number", func() {
			err := bootstrapper.Bootstrap()
			Expect(err).ToNot(HaveOccurred())