-
Notifications
You must be signed in to change notification settings - Fork 120
Add profile flag to commands to allow running profiles at the same time #1368
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
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,6 +12,7 @@ import ( | |
"github.com/spf13/cobra" | ||
|
||
"github.com/elastic/elastic-package/internal/cobraext" | ||
"github.com/elastic/elastic-package/internal/install" | ||
"github.com/elastic/elastic-package/internal/packages" | ||
"github.com/elastic/elastic-package/internal/service" | ||
) | ||
|
@@ -35,6 +36,7 @@ func setupServiceCommand() *cobraext.Command { | |
Long: serviceLongDescription, | ||
} | ||
cmd.AddCommand(upCommand) | ||
cmd.PersistentFlags().StringP(cobraext.ProfileFlagName, "p", "", fmt.Sprintf(cobraext.ProfileFlagDescription, install.ProfileNameEnvVar)) | ||
|
||
return cobraext.NewCommand(cmd, cobraext.ContextPackage) | ||
} | ||
|
@@ -58,8 +60,14 @@ func upCommandAction(cmd *cobra.Command, args []string) error { | |
|
||
variantFlag, _ := cmd.Flags().GetString(cobraext.VariantFlagName) | ||
|
||
profile, err := cobraext.GetProfileFlag(cmd) | ||
if err != nil { | ||
return nil | ||
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. Also here. |
||
} | ||
|
||
_, serviceName := filepath.Split(packageRoot) | ||
err = service.BootUp(service.Options{ | ||
Profile: profile, | ||
ServiceName: serviceName, | ||
PackageRootPath: packageRoot, | ||
DataStreamRootPath: dataStreamPath, | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,20 @@ import ( | |
"github.com/elastic/elastic-package/internal/builder" | ||
"github.com/elastic/elastic-package/internal/configuration/locations" | ||
"github.com/elastic/elastic-package/internal/files" | ||
"github.com/elastic/elastic-package/internal/profile" | ||
) | ||
|
||
// DockerComposeProjectName is the name of the Docker Compose project used to boot up | ||
// baseComposeProjectName is the base name of the Docker Compose project used to boot up | ||
// Elastic Stack containers. | ||
const DockerComposeProjectName = "elastic-package-stack" | ||
const baseComposeProjectName = "elastic-package-stack" | ||
|
||
// DockerComposeProjectName returns the docker compose project name for a given profile. | ||
func DockerComposeProjectName(profile *profile.Profile) string { | ||
if profile.ProfileName == "default" { | ||
return baseComposeProjectName | ||
} | ||
Comment on lines
+25
to
+27
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. If this condition is added, the resulting container names would be the same as previously keeping backwards compatibility. |
||
return baseComposeProjectName + "-" + profile.ProfileName | ||
} | ||
|
||
// BootUp function boots up the Elastic stack. | ||
func BootUp(options Options) error { | ||
|
@@ -81,7 +90,7 @@ func BootUp(options Options) error { | |
// to fail too. | ||
// As a workaround, try to give another chance to docker-compose if only | ||
// elastic-agent failed. | ||
if onlyElasticAgentFailed() { | ||
if onlyElasticAgentFailed(options) { | ||
fmt.Println("Elastic Agent failed to start, trying again.") | ||
err = dockerComposeUp(options) | ||
} | ||
|
@@ -98,8 +107,8 @@ func BootUp(options Options) error { | |
return nil | ||
} | ||
|
||
func onlyElasticAgentFailed() bool { | ||
status, err := Status() | ||
func onlyElasticAgentFailed(options Options) bool { | ||
status, err := Status(options) | ||
if err != nil { | ||
fmt.Printf("Failed to check status of the stack after failure: %v\n", err) | ||
return false | ||
|
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
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
Oops, something went wrong.
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.
I have seen this now while updating #1230, shouldn't this be
return err
?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.
That's right, it should return the error.
Thanks for the heads up!
Opened a PR for this: #1370