forked from awslabs/fargatecli
-
Notifications
You must be signed in to change notification settings - Fork 18
get rid of docker-compose shell out #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mchastain-turner
wants to merge
1
commit into
turnerlabs:master
Choose a base branch
from
mchastain-turner:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
get rid of docker-compose shell out
- Loading branch information
commit 0fa4ccdb7ee6b1b6d13bdd3ef04af90be9166bff
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ import ( | |
type ServiceDeployOperation struct { | ||
ServiceName string | ||
Image string | ||
ComposeFile string | ||
ComposeFiles []string | ||
Region string | ||
Revision string | ||
WaitForService bool | ||
|
@@ -21,7 +21,7 @@ type ServiceDeployOperation struct { | |
const deployDockerComposeLabel = "aws.ecs.fargate.deploy" | ||
|
||
var flagServiceDeployImage string | ||
var flagServiceDeployDockerComposeFile string | ||
var flagServiceDeployDockerComposeFile []string | ||
var flagServiceDeployDockerComposeImageOnly bool | ||
var flagServiceDeployRevision string | ||
var flagServiceDeployWaitForService bool | ||
|
@@ -53,7 +53,7 @@ fargate service deploy -r 37 | |
ServiceName: getServiceName(), | ||
Region: region, | ||
Image: flagServiceDeployImage, | ||
ComposeFile: flagServiceDeployDockerComposeFile, | ||
ComposeFiles: flagServiceDeployDockerComposeFile, | ||
Revision: flagServiceDeployRevision, | ||
WaitForService: flagServiceDeployWaitForService, | ||
} | ||
|
@@ -63,6 +63,7 @@ fargate service deploy -r 37 | |
return | ||
} | ||
|
||
console.Info("here") | ||
deployService(operation) | ||
}, | ||
} | ||
|
@@ -72,7 +73,7 @@ func init() { | |
|
||
serviceDeployCmd.Flags().StringVarP(&flagServiceDeployRevision, "revision", "r", "", "Task definition revision number") | ||
|
||
serviceDeployCmd.Flags().StringVarP(&flagServiceDeployDockerComposeFile, "file", "f", "", "Specify a docker-compose.yml file to deploy. The image and environment variables in the file will be deployed.") | ||
serviceDeployCmd.Flags().StringArrayVarP(&flagServiceDeployDockerComposeFile, "file", "f", []string{}, "Specify a docker-compose.yml file to deploy. The image and environment variables in the file will be deployed.") | ||
|
||
serviceDeployCmd.Flags().BoolVar(&flagServiceDeployDockerComposeImageOnly, "image-only", false, "Only deploy the image when a docker-compose.yml file is specified.") | ||
|
||
|
@@ -82,9 +83,10 @@ func init() { | |
} | ||
|
||
func deployService(operation *ServiceDeployOperation) { | ||
console.Info("Hello?!") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this |
||
var taskDefinitionArn string | ||
|
||
if operation.ComposeFile != "" { | ||
if len(operation.ComposeFiles) > 0 { | ||
taskDefinitionArn = deployDockerComposeFile(operation) | ||
} else if operation.Revision != "" { | ||
taskDefinitionArn = deployRevision(operation) | ||
|
@@ -112,11 +114,10 @@ func deployService(operation *ServiceDeployOperation) { | |
func deployDockerComposeFile(operation *ServiceDeployOperation) string { | ||
var taskDefinitionArn string | ||
|
||
dockerService := getDockerServiceFromComposeFile(operation.ComposeFiles) | ||
ecs := ECS.New(sess, getClusterName()) | ||
ecsService := ecs.DescribeService(operation.ServiceName) | ||
|
||
dockerService := getDockerServiceFromComposeFile(operation.ComposeFile) | ||
|
||
envvars := convertDockerComposeEnvVarsToECSEnvVars(dockerService) | ||
secrets := convertDockerComposeSecretsToECSSecrets(dockerService) | ||
|
||
|
@@ -135,7 +136,7 @@ func deployDockerComposeFile(operation *ServiceDeployOperation) string { | |
if flagServiceDeployDockerComposeImageOnly { | ||
console.Info("Deployed %s to service %s", dockerService.Image, operation.ServiceName) | ||
} else { | ||
console.Info("Deployed %s to service %s as revision %s", operation.ComposeFile, operation.ServiceName, ecs.GetRevisionNumber(taskDefinitionArn)) | ||
console.Info("Deployed %s to service %s as revision %s", operation.ComposeFiles, operation.ServiceName, ecs.GetRevisionNumber(taskDefinitionArn)) | ||
} | ||
|
||
return taskDefinitionArn | ||
|
@@ -177,9 +178,9 @@ func deployImage(operation *ServiceDeployOperation) string { | |
return taskDefinitionArn | ||
} | ||
|
||
func getDockerServiceFromComposeFile(dockerComposeFile string) *dockercompose.Service { | ||
func getDockerServiceFromComposeFile(dockerComposeFiles []string) *dockercompose.Service { | ||
//read the compose file configuration | ||
composeFile := dockercompose.Read(dockerComposeFile) | ||
composeFile := dockercompose.Read(dockerComposeFiles) | ||
|
||
//determine which docker-compose service/container to deploy | ||
_, dockerService := getDockerServiceToDeploy(&composeFile.Data) | ||
|
@@ -234,7 +235,11 @@ func getDockerServiceToDeploy(dc *dockercompose.DockerCompose) (string, *dockerc | |
|
||
//Check incompatible flag combinations | ||
func validateFlags(operation *ServiceDeployOperation) bool { | ||
strFlags := []string{operation.Image, operation.ComposeFile, operation.Revision} | ||
var cf string | ||
if len(operation.ComposeFiles) > 0 { | ||
cf = operation.ComposeFiles[0] | ||
} | ||
strFlags := []string{operation.Image, cf, operation.Revision} | ||
setFlags := make([]string, 0) | ||
|
||
for _, v := range strFlags { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to take this out :)