Exemple #1
0
func (s *ECSDeploymentStrategy) registerTask(taskJson string) {

	definitions := make([]*ecs.ContainerDefinition, len(s.Containers))

	for i, d := range s.Containers {
		definitions[i] = &ecs.ContainerDefinition{
			Essential: aws.Bool(d.Essential),
			Image:     aws.String(d.Image),
			Name:      aws.String(d.Name),
			Memory:    aws.Int64(int64(d.Memory)),
			PortMappings: []*ecs.PortMapping{
				{
					ContainerPort: aws.Int64(80),
					HostPort:      aws.Int64(80),
					Protocol:      aws.String("tcp"),
				},
			},
		}
	}

	params := &ecs.RegisterTaskDefinitionInput{
		ContainerDefinitions: definitions,
		Family:               aws.String(s.Application),
	}

	resp, err := s.ecs.RegisterTaskDefinition(params)

	if err != nil {
		log.Fatalf("%v", err)
	}

	s.taskDefinitionARN = *resp.TaskDefinition.TaskDefinitionArn
	log.Info("Task %s created", s.taskDefinitionARN)
}
Exemple #2
0
func (g *Godspeed) LoadPlugins() {
	// Load Configuration
	var err error
	var confLoader *plugo.ConfigLoader
	c := &PluginConfig{}
	if g.config.ConfigFile != "" {
		confLoader = &plugo.ConfigLoader{}
		err = confLoader.LoadFromFile(g.config.ConfigFile, &c)
		if err != nil {
			log.Fatalf("Unable to read configuration file: %s", err.Error())
		}
	} else {
		log.Fatal("No config file provided")
	}

	log.SetLevel(log.LogLevel(c.LogLevel))

	// Load all plugins
	g.DeploymentStrategies = make([]DeploymentStrategy, len(c.Deployment))
	plugins := plugo.LoadPluginsWithConfig(confLoader, c.Deployment)
	for i, p := range plugins {
		log.Debug("Loading plugin\t" + log.Colorize(log.YELLOW, c.Deployment[i].Name))
		g.DeploymentStrategies[i] = p.(DeploymentStrategy)
	}
}
Exemple #3
0
func (s *ECSDeploymentStrategy) checkCluster(cluster string) {

	params := &ecs.DescribeClustersInput{
		Clusters: []*string{
			aws.String(cluster),
		},
	}
	resp, err := s.ecs.DescribeClusters(params)

	if err != nil {
		log.Fatalf("%v", err)
		return
	}

	if len(resp.Clusters) == 0 {
		log.Fatalf("Cluster '%s' does not exist", cluster)
	}

	if *resp.Clusters[0].Status != "ACTIVE" {
		log.Info("Cluster not yet active, waiting...")
	}
}