Ejemplo n.º 1
0
func main() {
	var res *check.Result
	// defer exiting so it runs after all other defers
	defer func() {
		if res != nil && !res.Passed() {
			os.Exit(1)
		}
	}()

	flynnrc = args.Flynnrc
	routerIP = args.RouterIP
	if flynnrc == "" {
		c := cluster.New(args.BootConfig, os.Stdout)
		rootFS, err := c.BuildFlynn(args.RootFS, "origin/master")
		if err != nil {
			log.Fatal("could not build flynn:", err)
		}
		if args.KeepRootFS {
			fmt.Println("Built Flynn in rootfs:", rootFS)
		} else {
			defer os.RemoveAll(rootFS)
		}
		if err := c.Boot(args.Backend, rootFS, 1); err != nil {
			log.Fatal("could not boot cluster: ", err)
		}
		if args.Kill {
			defer c.Shutdown()
		}

		if err := createFlynnrc(c); err != nil {
			log.Fatal(err)
		}
		defer os.RemoveAll(flynnrc)

		routerIP = c.RouterIP
	}

	ssh, err := genSSHKey()
	if err != nil {
		log.Fatal(err)
	}
	defer ssh.Cleanup()
	gitEnv = ssh.Env

	keyAdd := flynn("", "key", "add", ssh.Pub)
	if keyAdd.Err != nil {
		log.Fatalf("Error during `%s`:\n%s%s", strings.Join(keyAdd.Cmd, " "), keyAdd.Output, keyAdd.Err)
	}

	res = check.RunAll(&check.RunConf{
		Stream:      true,
		Verbose:     true,
		KeepWorkDir: args.Debug,
	})
	fmt.Println(res)
}
Ejemplo n.º 2
0
func main() {
	flynnrc = args.Flynnrc
	if flynnrc == "" {
		c := cluster.New(args.BootConfig, os.Stdout)
		dockerfs := args.DockerFS
		if dockerfs == "" {
			var err error
			if dockerfs, err = c.BuildFlynn("", util.Repos); err != nil {
				log.Fatal("could not build flynn:", err)
			}
			if !args.KeepDockerFS {
				defer os.RemoveAll(dockerfs)
			}
		}
		if err := c.Boot(dockerfs, 1); err != nil {
			log.Fatal("could not boot cluster: ", err)
		}
		if args.Kill {
			defer c.Shutdown()
		}

		if err := createFlynnrc(c); err != nil {
			log.Fatal(err)
		}
		defer os.RemoveAll(flynnrc)
	}

	ssh, err := genSSHKey()
	if err != nil {
		log.Fatal(err)
	}
	defer ssh.Cleanup()
	gitEnv = ssh.Env

	keyAdd := flynn("", "key-add", ssh.Pub)
	if keyAdd.Err != nil {
		log.Fatalf("Error during `%s`:\n%s%s", strings.Join(keyAdd.Cmd, " "), keyAdd.Output, keyAdd.Err)
	}

	res := check.RunAll(&check.RunConf{
		Stream:      true,
		Verbose:     true,
		KeepWorkDir: args.Debug,
	})
	fmt.Println(res)
}