Ejemplo n.º 1
0
// NewEmpire returns a new Empire instance suitable for testing. It ensures that
// the database is clean before returning.
func NewEmpire(t testing.TB) *empire.Empire {
	opts := empire.Options{
		DB: DatabaseURL,
		Runner: empire.RunnerOptions{
			API: "fake",
		},
		AWSConfig: nil,
		Docker: empire.DockerOptions{
			Auth: &docker.AuthConfigurations{
				Configs: map[string]docker.AuthConfiguration{
					"https://index.docker.io/v1/": docker.AuthConfiguration{
						Username: "",
						Password: "",
					},
				},
			},
		},
	}

	e, err := empire.New(opts)
	if err != nil {
		t.Fatal(err)
	}

	if err := e.Reset(); err != nil {
		t.Fatal(err)
	}

	return e
}
Ejemplo n.º 2
0
func newEmpire(c *cli.Context) (*empire.Empire, error) {
	opts := empire.Options{}

	opts.Docker.Socket = c.String(FlagDockerSocket)
	opts.Docker.CertPath = c.String(FlagDockerCert)
	opts.Runner.API = c.String(FlagRunner)
	opts.AWSConfig = aws.DefaultConfig
	if c.Bool(FlagAWSDebug) {
		opts.AWSConfig.LogLevel = 1
	}
	opts.ECS.Cluster = c.String(FlagECSCluster)
	opts.ECS.ServiceRole = c.String(FlagECSServiceRole)
	opts.ELB.InternalSecurityGroupID = c.String(FlagELBSGPrivate)
	opts.ELB.ExternalSecurityGroupID = c.String(FlagELBSGPublic)
	opts.ELB.InternalSubnetIDs = c.StringSlice(FlagEC2SubnetsPrivate)
	opts.ELB.ExternalSubnetIDs = c.StringSlice(FlagEC2SubnetsPublic)
	opts.ELB.InternalZoneID = c.String(FlagRoute53InternalZoneID)
	opts.DB = c.String(FlagDB)
	opts.Secret = c.String(FlagSecret)

	auth, err := dockerAuth(c.String(FlagDockerAuth))
	if err != nil {
		return nil, err
	}

	opts.Docker.Auth = auth

	e, err := empire.New(opts)
	if err != nil {
		return e, err
	}

	reporter, err := newReporter(c.String(FlagReporter))
	if err != nil {
		return e, err
	}

	e.Reporter = reporter

	return e, nil
}