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

🐛 Validate source and target labels #243

Merged
merged 1 commit into from
May 30, 2024

Conversation

aufi
Copy link
Member

@aufi aufi commented May 27, 2024

Adding validation for analysis source and target labels.

Fixes: #176

Adding validation for analysis source and target labels.

Fixes: konveyor#176

Signed-off-by: Marek Aufart <[email protected]>
@aufi aufi changed the title Validate source and target labels 🐛 Validate source and target labels May 27, 2024
@@ -113,7 +114,7 @@ func NewAnalyzeCmd(log logr.Logger) *cobra.Command {
return err
}
}
err := analyzeCmd.Validate()
err := analyzeCmd.Validate(cmd.Context())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding context to Validate() for non-trivial validations (running analyzer container for listing sources/targets in this case).

// Validate source labels
if len(a.sources) > 0 {
var sourcesRaw bytes.Buffer
a.fetchLabels(ctx, true, false, &sourcesRaw)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-used ListLabels extracted method body to have the share the logic for fetching sources/targets from analyzer. However, this doesn't look as nice as I'd like, looking on update.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some way to use the slice created here https://github.com/konveyor/kantra/blob/main/cmd/analyze.go#L454 to return that in validate, and then re-use it to list everything after?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eemcmullan I guess it won't be possible because validation runs locally, list commands work in container

Copy link
Contributor

@pranavgaikwad pranavgaikwad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach makes sense to me, don't know if there's a better way, thanks!

// Validate source labels
if len(a.sources) > 0 {
var sourcesRaw bytes.Buffer
a.fetchLabels(ctx, true, false, &sourcesRaw)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eemcmullan I guess it won't be possible because validation runs locally, list commands work in container

@eemcmullan eemcmullan merged commit fdde270 into konveyor:main May 30, 2024
3 checks passed
aufi added a commit to aufi/kantra that referenced this pull request May 31, 2024
Fixing fmt.Fprintln to correctly recognize first argument as a writer
buffer. Bug was introduced in konveyor#243

Should fix kantra CI.

Signed-off-by: Marek Aufart <[email protected]>
aufi added a commit to aufi/kantra that referenced this pull request May 31, 2024
Fixing fmt.Fprintln to correctly recognize first argument as a writer
buffer. Bug was introduced in konveyor#243

Should fix kantra CI.

Signed-off-by: Marek Aufart <[email protected]>
aufi added a commit that referenced this pull request Jun 3, 2024
* Fix labels validation print

Fixing fmt.Fprintln to correctly recognize first argument as a writer
buffer. Bug was introduced in #243

Should fix kantra CI.

Signed-off-by: Marek Aufart <[email protected]>

* Force runnerImg env lookup

Signed-off-by: Marek Aufart <[email protected]>

* Fix env config load override

Signed-off-by: Marek Aufart <[email protected]>

* Revert "Fix env config load override"

This reverts commit 2950638.

Signed-off-by: Marek Aufart <[email protected]>

* Update env settings with field values

Signed-off-by: Marek Aufart <[email protected]>

* Adding RUNNER_IMG setting test

Signed-off-by: Marek Aufart <[email protected]>

* Revert Settings changes

Signed-off-by: Marek Aufart <[email protected]>

---------

Signed-off-by: Marek Aufart <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Kantra CLI doesn't throw an error when an invalid target is specified
3 participants