Skip to content

More robustly handle values passed to --distro and --release - #977

Merged
martymichal merged 3 commits into
containers:mainfrom
martymichal:cmd/create/more-distro-release-hints
Feb 21, 2022
Merged

martymichal merged 3 commits into
containers:mainfrom
martymichal:cmd/create/more-distro-release-hints

Conversation

@martymichal

Copy link
Copy Markdown
Member

This change is rather big despite my efforts to keep it as small as possible. The handling needed some separation and along the way I noticed some possible problems or duplication.

Read commits for detailed information.

Fixes #937

@martymichal martymichal added 3. Enhancement Improvement to an existing feature 6. Minor Change Should not cause breakage 3. Bugfix Fixes a bug 2. CLI Issue is related to the command line interface 2. Under The Hood Multiple areas of the app are influenced by this ticket labels Jan 9, 2022
@martymichal martymichal added this to the Release 0.1.0 milestone Jan 9, 2022
martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 9, 2022
...unless the selected distro matches the host system.

containers#977
martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 9, 2022
Having a list of supported distributions in the manual has been long
overdue. Complementing it with the expected formats should make lives of
users a bit easier.

containers#977
martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 9, 2022
…rors

Using a non-supported distribution via `--distro` resulted in a silent
fallback to the Fedora image which confuses users. When a faulty release
format was used with `--release` a message without any hint about the
correct format was shown to the user.

This separates distro and release parsing into two chunks that have
greater control over error reporting and provides more accurate error
reports for the user.

Fixes containers#937

containers#977
martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 9, 2022
martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 9, 2022
@martymichal
martymichal force-pushed the cmd/create/more-distro-release-hints branch from f68d253 to 2ec7556 Compare January 9, 2022 15:30
@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 9, 2022
...unless the selected distro matches the host system.

containers#977
martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 9, 2022
Having a list of supported distributions in the manual has been long
overdue. Complementing it with the expected formats should make lives of
users a bit easier.

containers#977
martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 9, 2022
…rors

Using a non-supported distribution via `--distro` resulted in a silent
fallback to the Fedora image which confuses users. When a faulty release
format was used with `--release` a message without any hint about the
correct format was shown to the user.

This separates distro and release parsing into two chunks that have
greater control over error reporting and provides more accurate error
reports for the user.

Fixes containers#937

containers#977
martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 9, 2022
martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 9, 2022
@martymichal
martymichal force-pushed the cmd/create/more-distro-release-hints branch from 2ec7556 to d13df7a Compare January 9, 2022 16:49
@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@debarshiray debarshiray left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Cool! Makes sense.

Comment thread doc/toolbox-create.1.md Resolved
Comment thread doc/toolbox.1.md Resolved
Comment thread doc/toolbox.1.md Resolved
Comment thread doc/toolbox.1.md Resolved

@debarshiray debarshiray left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This reminds me of commit fd756089efb89f05.

I have been having doubts about it, because splitting ResolveContainerAndImageNames into two public functions pushes the burden on the callers. The callers now need to carefully call the split functions in the right order, which opens the door for mistakes.

I think a good compromise would be to restore ResolveContainerAndImageNames as the single public API, but internally split it into smaller private functions. It would keep things simple for both the callers and the implementation.

Ultimately, the distro, release, image and container values are very tightly related here. So, we need a public API to which we feed the input values, and get back the resolved values, without worrying about the intricacies involved.

martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 13, 2022
...unless the selected distro matches the host system.

containers#977
martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 13, 2022
Having a list of supported distributions in the manual has been long
overdue. Complementing it with the expected formats should make lives of
users a bit easier.

containers#977
martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 13, 2022
…rors

Using a non-supported distribution via `--distro` resulted in a silent
fallback to the Fedora image which confuses users. When a faulty release
format was used with `--release` a message without any hint about the
correct format was shown to the user.

This separates distro and release parsing into two chunks that have
greater control over error reporting and provides more accurate error
reports for the user.

Fixes containers#937

containers#977
martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 13, 2022
martymichal added a commit to martymichal/toolbox that referenced this pull request Jan 13, 2022
@debarshiray

Copy link
Copy Markdown
Member

I merged the updates to the manuals in #986 after applying the above tweaks.

@martymichal

Copy link
Copy Markdown
Member Author

I merged the updates to the manuals in #986 after applying the above tweaks.

Thanks!

@softwarefactory-delete-me

Copy link
Copy Markdown

Build succeeded.

…rors

Using a non-supported distribution via `--distro` resulted in a silent
fallback to the Fedora image which confuses users. When a faulty release
format was used with `--release` a message without any hint about the
correct format was shown to the user.

This separates distro and release parsing into two chunks that have
greater control over error reporting and provides more accurate error
reports for the user.

Fixes containers#937

containers#977
@martymichal
martymichal force-pushed the cmd/create/more-distro-release-hints branch from cf90340 to 1d641e3 Compare February 21, 2022 10:08
@softwarefactory-delete-me

Copy link
Copy Markdown

Build failed.

@martymichal
martymichal merged commit 5c8ad7a into containers:main Feb 21, 2022
martymichal added a commit that referenced this pull request Feb 21, 2022
…rors

Using a non-supported distribution via `--distro` resulted in a silent
fallback to the Fedora image which confuses users. When a faulty release
format was used with `--release` a message without any hint about the
correct format was shown to the user.

This separates distro and release parsing into two chunks that have
greater control over error reporting and provides more accurate error
reports for the user.

Fixes #937

#977
@martymichal
martymichal deleted the cmd/create/more-distro-release-hints branch February 21, 2022 11:43
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Jul 31, 2022
The idea of splitting ResolveContainerAndImageNames into two public
functions didn't turn out to be so useful [1].  It pushed the burden
on the callers, who needed to carefully call the split functions in
the right order, because the container, distro, image and release
values are very tightly related.  This opens the door for mistakes.

A better approach would be to restore ResolveContainerAndImageNames as
the single public API, but internally split it into smaller private
functions, if necessary.  It would keep things simple for both the
callers and the implementation.

Note that this commit doesn't include the private split, but leaves
that as a future exercise.

This reverts commit fd75608.

[1] containers#977
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Jul 31, 2022
The idea of splitting ResolveContainerAndImageNames into two public
functions didn't turn out to be so useful [1].  It pushed the burden
on the callers, who needed to carefully call the split functions in
the right order, because the container, distro, image and release
values are very tightly related.  This opens the door for mistakes.

A better approach would be to restore ResolveContainerAndImageNames as
the single public API, but internally split it into smaller private
functions, if necessary.  It would keep things simple for both the
callers and the implementation.

Note that this commit doesn't include the private split, but leaves
that as a future exercise.

This reverts commit fd75608.

[1] containers#977
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Jul 31, 2022
The idea of splitting ResolveContainerAndImageNames into two public
functions [1] didn't turn out to be so useful [2].  Splitting things
even further might make it worse.  A better approach might be to
(re-)unify the code further.

This is the first step towards that.

This reverts the following commits:
  * 5c8ad7a
  * 02f45fd
  * 8b6418d

... but retains the test cases that were not tied to the changes in
those commits.

[1] Commit fd75608
    containers#828
    containers#838

[2] containers#977

containers#937
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Jul 31, 2022
The idea of splitting ResolveContainerAndImageNames into two public
functions [1] didn't turn out to be so useful [2].  It pushed the
burden on the callers, who needed to carefully call the split
functions in the right order, because the container, distro, image and
release values are very tightly related.  This opens the door for
mistakes.

A better approach would be to restore ResolveContainerAndImageNames as
the single public API.  If necessary it could be internally split into
smaller private functions.  It would keep things simple for the
callers.

Note that this commit doesn't include the private split.  If necessary,
it can be done in future.

This reverts commit fd75608.

[1] Commit fd75608
    containers#828
    containers#838

[2] containers#977

containers#937
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Aug 1, 2022
The idea of splitting ResolveContainerAndImageNames into two public
functions [1] didn't turn out to be so useful [2].  Splitting things
even further might make it worse.  A better approach might be to
(re-)unify the code further.

This is the first step towards that.

This reverts the following commits:
  * 5c8ad7a
  * 02f45fd
  * 8b6418d

... but retains the test cases that were not tied to the changes in
those commits.

[1] Commit fd75608
    containers#828
    containers#838

[2] containers#977

containers#937
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Aug 1, 2022
The idea of splitting ResolveContainerAndImageNames into two public
functions [1] didn't turn out to be so useful [2].  It pushed the
burden on the callers, who needed to carefully call the split
functions in the right order, because the container, distro, image and
release values are very tightly related.  This opens the door for
mistakes.

A better approach would be to restore ResolveContainerAndImageNames as
the single public API.  If necessary it could be internally split into
smaller private functions.  It would keep things simple for the
callers.

Note that this commit doesn't include the private split.  If necessary,
it can be done in future.

This reverts commit fd75608.

[1] Commit fd75608
    containers#828
    containers#838

[2] containers#977

containers#937
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Aug 31, 2022
The idea of splitting ResolveContainerAndImageNames into two public
functions [1] didn't turn out to be so useful [2].  Splitting things
even further might make it worse.  A better approach might be to
(re-)unify the code further.

This is the first step towards that.

This reverts the following commits:
  * 5c8ad7a
  * 02f45fd
  * 8b6418d

... but retains the test cases that were not tied to the changes in
those commits.

[1] Commit fd75608
    containers#828
    containers#838

[2] containers#977

containers#937
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Aug 31, 2022
The idea of splitting ResolveContainerAndImageNames into two public
functions [1] didn't turn out to be so useful [2].  It pushed the
burden on the callers, who needed to carefully call the split
functions in the right order, because the container, distro, image and
release values are very tightly related.  This opens the door for
mistakes.

A better approach would be to restore ResolveContainerAndImageNames as
the single public API.  If necessary it could be internally split into
smaller private functions.  It would keep things simple for the
callers.

Note that this commit doesn't include the private split.  If necessary,
it can be done in future.

This reverts commit fd75608.

[1] Commit fd75608
    containers#828
    containers#838

[2] containers#977

containers#937
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Aug 31, 2022
The idea of splitting ResolveContainerAndImageNames into two public
functions [1] didn't turn out to be so useful [2].  Splitting things
even further might make it worse.  A better approach might be to
(re-)unify the code further.

This is the first step towards that.

This reverts the following commits:
  * 5c8ad7a
  * 02f45fd
  * 8b6418d

... but retains the test cases that were not tied to the changes in
those commits.

[1] Commit fd75608
    containers#828
    containers#838

[2] containers#977

containers#937
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Aug 31, 2022
The idea of splitting ResolveContainerAndImageNames into two public
functions [1] didn't turn out to be so useful [2].  It pushed the
burden on the callers, who needed to carefully call the split
functions in the right order, because the container, distro, image and
release values are very tightly related.  This opens the door for
mistakes.

A better approach would be to restore ResolveContainerAndImageNames as
the single public API.  If necessary it could be internally split into
smaller private functions.  It would keep things simple for the
callers.

Note that this commit doesn't include the private split.  If necessary,
it can be done in future.

This reverts commit fd75608.

[1] Commit fd75608
    containers#828
    containers#838

[2] containers#977

containers#937
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Sep 1, 2022
The idea of splitting ResolveContainerAndImageNames into two public
functions [1] didn't turn out to be so useful [2].  Splitting things
even further might make it worse.  A better approach might be to
(re-)unify the code further.

This is the first step towards that.

This reverts the following commits:
  * 5c8ad7a
  * 02f45fd
  * 8b6418d

... but retains the test cases that were not tied to the changes in
those commits.

[1] Commit fd75608
    containers#828
    containers#838

[2] containers#977

containers#937
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Sep 1, 2022
The idea of splitting ResolveContainerAndImageNames into two public
functions [1] didn't turn out to be so useful [2].  It pushed the
burden on the callers, who needed to carefully call the split
functions in the right order, because the container, distro, image and
release values are very tightly related.  This opens the door for
mistakes.

A better approach would be to restore ResolveContainerAndImageNames as
the single public API.  If necessary it could be internally split into
smaller private functions.  It would keep things simple for the
callers.

Note that this commit doesn't include the private split.  If necessary,
it can be done in future.

This reverts commit fd75608.

[1] Commit fd75608
    containers#828
    containers#838

[2] containers#977

containers#937
Comment thread src/pkg/utils/utils.go Resolved
Comment thread src/pkg/utils/utils.go Resolved

@debarshiray debarshiray left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Time has only made me lean further towards my earlier comment. We should re-unify the resolution of container, distro, image and release, and not split it even further.

Comment thread src/cmd/create.go Resolved
Comment thread src/pkg/utils/utils.go Resolved
Comment thread src/pkg/utils/utils.go Resolved
Comment thread src/pkg/utils/utils.go Resolved
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Sep 1, 2022
The idea of splitting ResolveContainerAndImageNames into two public
functions [1] didn't turn out to be so useful [2].  Splitting things
even further might make it worse.  A better approach might be to
(re-)unify the code further.

This is the first step towards that.

This reverts the following commits:
  * 5c8ad7a
  * 02f45fd
  * 8b6418d

... but retains the test cases that were not tied to the changes in
those commits.

[1] Commit fd75608
    containers#828
    containers#838

[2] containers#977

containers#937
containers#1080
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Sep 1, 2022
The idea of splitting ResolveContainerAndImageNames into two public
functions [1] didn't turn out to be so useful [2].  It pushed the
burden on the callers, who needed to carefully call the split
functions in the right order, because the container, distro, image and
release values are very tightly related.  This opens the door for
mistakes.

A better approach would be to restore ResolveContainerAndImageNames as
the single public API.  If necessary it could be internally split into
smaller private functions.  It would keep things simple for the
callers.

Note that this commit doesn't include the private split.  If necessary,
it can be done in future.

This reverts commit fd75608.

[1] Commit fd75608
    containers#828
    containers#838

[2] containers#977

containers#937
containers#1080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. CLI Issue is related to the command line interface 2. Under The Hood Multiple areas of the app are influenced by this ticket 3. Bugfix Fixes a bug 3. Enhancement Improvement to an existing feature 6. Minor Change Should not cause breakage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

toolbox create argument 'distro' and 'release' invalid values handling

2 participants