-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/add new step file #2
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
ChristophBe
wants to merge
14
commits into
main
Choose a base branch
from
feature/add-new-step-file
base: main
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
Conversation
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
# Conflicts: # cmd/migration-tool/main.go # cmd/migration-tool/main_test.go diff --git c/cmd/migration-tool/cmd/actions.go i/cmd/migration-tool/cmd/actions.go index 4601ff4..a10f96a 100644 --- c/cmd/migration-tool/cmd/actions.go +++ i/cmd/migration-tool/cmd/actions.go @@ -4,4 +4,5 @@ type Actions interface { Run(folder string) error Verify(folder string) (bool, error) RecalculateHashes(folder string) error + AddStepFile(folder string, filename string) error } diff --git c/cmd/migration-tool/cmd/actions_mock.gen.go i/cmd/migration-tool/cmd/actions_mock.gen.go index f7aeecb..90cc6b8 100644 --- c/cmd/migration-tool/cmd/actions_mock.gen.go +++ i/cmd/migration-tool/cmd/actions_mock.gen.go @@ -17,6 +17,53 @@ func (_m *ActionsMock) EXPECT() *ActionsMock_Expecter { return &ActionsMock_Expecter{mock: &_m.Mock} } +// AddStepFile provides a mock function with given fields: folder, filename +func (_m *ActionsMock) AddStepFile(folder string, filename string) error { + ret := _m.Called(folder, filename) + + if len(ret) == 0 { + panic("no return value specified for AddStepFile") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r0 = rf(folder, filename) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// ActionsMock_AddStepFile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddStepFile' +type ActionsMock_AddStepFile_Call struct { + *mock.Call +} + +// AddStepFile is a helper method to define mock.On call +// - folder string +// - filename string +func (_e *ActionsMock_Expecter) AddStepFile(folder interface{}, filename interface{}) *ActionsMock_AddStepFile_Call { + return &ActionsMock_AddStepFile_Call{Call: _e.mock.On("AddStepFile", folder, filename)} +} + +func (_c *ActionsMock_AddStepFile_Call) Run(run func(folder string, filename string)) *ActionsMock_AddStepFile_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string)) + }) + return _c +} + +func (_c *ActionsMock_AddStepFile_Call) Return(_a0 error) *ActionsMock_AddStepFile_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ActionsMock_AddStepFile_Call) RunAndReturn(run func(string, string) error) *ActionsMock_AddStepFile_Call { + _c.Call.Return(run) + return _c +} + // RecalculateHashes provides a mock function with given fields: folder func (_m *ActionsMock) RecalculateHashes(folder string) error { ret := _m.Called(folder) diff --git c/cmd/migration-tool/cmd/add.go i/cmd/migration-tool/cmd/add.go new file mode 100644 index 0000000..feeb2d5 --- /dev/null +++ i/cmd/migration-tool/cmd/add.go @@ -0,0 +1,33 @@ +/* +Copyright © 2025 Christoph Becker <post@christopb.de> +*/ +package cmd + +import ( + "github.com/spf13/cobra" +) + +// addCmd represents the add command +var addCmd = &cobra.Command{ + Use: "add [filename]", + Short: "Add a file to the migration definition.", + Long: `Add a file to the migration definition. The file will be added to the end of the migration definition.`, + RunE: func(cmd *cobra.Command, args []string) error { + return acts.AddStepFile(baseFolder, args[0]) + }, +} + +func init() { + addCmd.Args = cobra.ExactArgs(1) + rootCmd.AddCommand(addCmd) + + // Here you will define your flags and configuration settings. + + // Cobra supports Persistent Flags which will work for this command + // and all subcommands, e.g.: + // addCmd.PersistentFlags().String("foo", "", "A help for foo") + + // Cobra supports local flags which will only run when this command + // is called directly, e.g.: + // addCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") +} diff --git c/docs/cli/migration-tool.md i/docs/cli/migration-tool.md index f85b4a0..00b4c38 100644 --- c/docs/cli/migration-tool.md +++ i/docs/cli/migration-tool.md @@ -20,6 +20,7 @@ To ensure consistency, the scripts are checked for unexecuted changes. ### SEE ALSO +* [migration-tool add](migration-tool_add.md) - Add a file to the migration definition. * [migration-tool regenerate-hashes](migration-tool_regenerate-hashes.md) - This command recalculates the hashes of the scripts. * [migration-tool run](migration-tool_run.md) - Runs every script that were not previously executed. * [migration-tool verify](migration-tool_verify.md) - Verify checks if the scripts have changed. diff --git c/docs/cli/migration-tool_add.md i/docs/cli/migration-tool_add.md new file mode 100644 index 0000000..11f4699 --- /dev/null +++ i/docs/cli/migration-tool_add.md @@ -0,0 +1,29 @@ +## migration-tool add + +Add a file to the migration definition. + +### Synopsis + +Add a file to the migration definition. The file will be added to the end of the migration definition. + +``` +migration-tool add [filename] [flags] +``` + +### Options + +``` + -h, --help help for add +``` + +### Options inherited from parent commands + +``` + -o, --execution-log-file string File where the execution log is written to. (default "execution-log.yaml") + --folder string Folder where the scripts and configurations file are located. +``` + +### SEE ALSO + +* [migration-tool](migration-tool.md) - migration-tool is a CLI that orchestrates the execution of scripts. + diff --git c/pkg/actions/add_step_file.go i/pkg/actions/add_step_file.go new file mode 100644 index 0000000..71febc8 --- /dev/null +++ i/pkg/actions/add_step_file.go @@ -0,0 +1,5 @@ +package actions + +func (a *Actions) AddStepFile(folder, filename string) error { + panic("implement me ") +} diff --git c/pkg/actions/add_step_file_test.go i/pkg/actions/add_step_file_test.go new file mode 100644 index 0000000..0f3a37f --- /dev/null +++ i/pkg/actions/add_step_file_test.go @@ -0,0 +1 @@ +package actions
� Conflicts: � cmd/migration-tool/main.go
# Conflicts: # README.md diff --git c/README.md i/README.md index 2463d8a..03fd8a1 100644 --- c/README.md +++ i/README.md @@ -9,7 +9,7 @@ The documentation of the Available commands and flags can be found [here](docs/c ## Run with Docker ```bash -docker run -v ./examples/migrations:/migrations -v ./output:/output ghcr.io/christophbe/migration-tool:latest -execution-filename ./output/execution-log.yaml run +docker run -v ./examples/migrations:/migrations -v ./output:/output ghcr.io/christophbe/migration-tool:latest run --folder ./migrations --execution-filename ./output/execution-log.yaml ``` ## Migrations File @@ -33,8 +33,7 @@ migrations: 1. Clone this Repository 2. Install needed development tooling. - [Golang CLI](https://go.dev/dl) Version 1.24 or later - - [mockery](https://vektra.github.io/mockery/latest/installation/) for generation of mocks - - (optional) [cobra-cli](https://github.com/spf13/cobra/tree/main?tab=readme-ov-file#usage) cobra-cli for generation code for new command + - (optional) [mockery](https://vektra.github.io/mockery/latest/installation/) for generation of mocks ## Run and Build ### Run from Code @@ -54,7 +53,6 @@ go test ./... ## Generate Code For testing mock implementations of interfaces are used. To generate the mocks [mockery](https://vektra.github.io/mockery/latest/) is used. -In addition to mock the documentation, for usage of the CLIs also gets generated. To run regenerate the generated files run the following command: ```bash
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.