Skip to content
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

✨ Add settings file option to openrewrite #141

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions cmd/openrewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ import (
)

type openRewriteCommand struct {
listTargets bool
input string
target string
goal string
miscOpts string
log logr.Logger
cleanup bool
listTargets bool
input string
target string
goal string
miscOpts string
log logr.Logger
cleanup bool
mavenSettingsFile string
}

func NewOpenRewriteCommand(log logr.Logger) *cobra.Command {
Expand Down Expand Up @@ -58,6 +59,7 @@ func NewOpenRewriteCommand(log logr.Logger) *cobra.Command {
openRewriteCommand.Flags().StringVarP(&openRewriteCmd.target, "target", "t", "", "target openrewrite recipe to use. Run --list-targets to get a list of packaged recipes.")
openRewriteCommand.Flags().StringVarP(&openRewriteCmd.goal, "goal", "g", "dryRun", "target goal")
openRewriteCommand.Flags().StringVarP(&openRewriteCmd.input, "input", "i", "", "path to application source code directory")
openRewriteCommand.Flags().StringVarP(&openRewriteCmd.mavenSettingsFile, "maven-settings", "s", "", "path to a custom maven settings file to use")

return openRewriteCommand
}
Expand Down Expand Up @@ -143,6 +145,12 @@ func (o *openRewriteCommand) Run(ctx context.Context) error {
}
o.log.Info("executing openrewrite recipe",
"recipe", o.target, "input", o.input, "args", strings.Join(args, " "))

if o.mavenSettingsFile != "" {
o.log.Info("using custom maven settings file", "path", o.mavenSettingsFile)
args = append(args, "-s", o.mavenSettingsFile)
}

err := NewContainer(o.log).Run(
ctx,
WithEntrypointArgs(args...),
Expand Down