Skip to content
This repository has been archived by the owner on Apr 6, 2024. It is now read-only.

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
itskingori committed Nov 16, 2022
1 parent d271e95 commit c52c02a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
17 changes: 17 additions & 0 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package cmd

import (
"context"

"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/ecs"
"github.com/rs/zerolog/log"
"github.com/shipatlas/ecs-toolkit/utils"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -28,6 +33,7 @@ var deployCmd = &cobra.Command{
Example: deployCmdExamples,
Run: func(cmd *cobra.Command, args []string) {
deployCmdOptions.validate()
deployCmdOptions.run()
},
}

Expand All @@ -46,3 +52,14 @@ func (options *deployOptions) validate() {
log.Fatal().Msg("image-tag flag must be set and should not be blank")
}
}

func (options *deployOptions) run() {
// Load the Shared AWS Configuration (~/.aws/config)
awsCfg, err := config.LoadDefaultConfig(context.TODO(), config.WithSharedConfigProfile("shipatlas-sandbox"))
if err != nil {
log.Fatal().Err(err).Msg("unable to read application config")
}
client := ecs.NewFromConfig(awsCfg)

Config.Application.DeployServices(&options.imageTag, client)
}
2 changes: 2 additions & 0 deletions pkg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ type Application struct {
type Service struct {
Name *string `mapstructure:"name" validate:"required"`
Containers []*string `mapstructure:"containers" validate:"required,min=1,dive"`
Force *bool `mapstructure:"force"`
}

type Task struct {
Name *string `mapstructure:"name" validate:"required"`
Containers []*string `mapstructure:"containers" validate:"required,min=1,dive"`
Force *bool `mapstructure:"force"`
}

func (application *Application) ServiceNames() []string {
Expand Down
2 changes: 1 addition & 1 deletion pkg/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (applicationConfig *Application) DeployServices(newContainerImageTag *strin
}

// Check if all services are stable.
clusterSublogger.Info().Msg("Check if all services are stable")
clusterSublogger.Info().Msg("checking if all services are stable")
waiter := ecs.NewServicesStableWaiter(client)
maxWaitTime := 15 * time.Minute
err = waiter.Wait(context.TODO(), servicesParams, maxWaitTime, func(o *ecs.ServicesStableWaiterOptions) {
Expand Down

0 comments on commit c52c02a

Please sign in to comment.