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

Rewrite in Go #318

Merged
merged 52 commits into from
May 13, 2020
Merged

Rewrite in Go #318

merged 52 commits into from
May 13, 2020

Conversation

HarryMichal
Copy link
Member

@HarryMichal HarryMichal commented Oct 31, 2019

This is where the Go rewrite is happening. I welcome any kind of comment/contribution.

The shell script has been renamed to toolbox.sh so that toolbox.go can
be compiled.

The new codebase is based on Cobra which takes care of the CLI heavy lifting.

cmd/create.go Outdated Show resolved Hide resolved
cmd/create.go Outdated Show resolved Hide resolved
@cgwalters
Copy link
Collaborator

cgwalters commented Oct 31, 2019

So first: Let's try to get a vote among contributors here - do you really really want Go? I think the code in #319 is pretty good, Rust's "structopt" is a lot nicer than anything Go can do, etc. But, if you don't know Rust (and don't have the time to learn), that's a totally valid argument against. Go is very easy to learn. It's also valid that podman is in Go.

But I'd hope people at least take a careful look at the toolbox-rs code and think about it!

But I write Go a lot, and I just really dislike the language. The "Go strength" in web services doesn't apply here at all.

On the other hand, hopefully this project doesn't exceed 2000 lines, so it doesn't matter too much.

@dustymabe
Copy link
Collaborator

So first: Let's try to get a vote among contributors here - do you really really want Go? I think the code in #319 is pretty good, Rust's "structopt" is a lot nicer than anything Go can do, etc.

But, if you don't know Rust (and don't have the time to learn), that's a totally valid argument against.

I really want to learn more rust and I like the concept of the language.

Go is very easy to learn. It's also valid that podman is in Go.

I think these points are the biggest one in favor of Go and why we have centered on go in previous discussions.

But I'd hope people at least take a careful look at the toolbox-rs code and think about it!

+1 - I looked at it earlier today. I don't quite understand it, because I don't know rust, but it at least looks nice.

But I write Go a lot, and I just really dislike the language. The "Go strength" in web services doesn't apply here at all.

Understood.

On the other hand, hopefully this project doesn't exceed 2000 lines, so it doesn't matter too much.

Agree, Either one should be fine implmentations for this. We should hoist advanced features back into podman.

@evelineraine
Copy link
Contributor

evelineraine commented Nov 1, 2019

Switching to either opens opportunities for me to contribute to the code (I can't write bash).
Regarding the choice I feel the same as @dustymabe. In a vacuum, I would prefer Rust over Go, because I really like it's design principles (unlike Go's) and toolbox would be a perfect opportunity for me to practice Rust.

However, toolbox not in a vacuum and entire container domain is almost Go-exclusive, which is not exactly good, but means moving toolbox to Go would attract more contributions from people that already work on container projects and also new people (Go is really easy to get started with, after all). Podman being in Go is really important point.

Still, it seems to me an even better option is a scripting/interpreted language. As a wrapper around a complete container solution (podman), I'm not sure what benefit there will be from features of a compiled language like Rust or Go (performance, advanced memory management, complex data representations, direct system calls, etc.).
On the other hand, a scripting language allows easier inspection of the code and easier changing of it, lowering entry-barrier for new people to contribute. And really, until toolbox supports tons of runtime customization, being able to easily mess with the code is very beneficial.

I would make many points in favor of Python, but as I understood because of CoreOS it's a no-go. Is it the case?

@HarryMichal HarryMichal changed the title Initial commit of the Go rewrite Rewrite in Go Nov 1, 2019
@HarryMichal HarryMichal added 5. Help Wanted Extra attention is needed 6. Major Change May cause breakage labels Nov 1, 2019
@dustymabe
Copy link
Collaborator

I would make many points in favor of Python, but as I understood because of CoreOS it's a no-go. Is it the case?

It is true that the CoreOS team has a goal of keeping Python out of the base. See https://github.com/coreos/fedora-coreos-tracker/blob/master/Design.md#approach-towards-shipping-python

@evelineraine
Copy link
Contributor

evelineraine commented Nov 2, 2019

It is true that the CoreOS team has a goal of keeping Python out of the base. See https://github.com/coreos/fedora-coreos-tracker/blob/master/Design.md#approach-towards-shipping-python

I see, thanks for the reference. Python is not an option then (unless you feel like freezing binaries) :(

So to me it seems Go has more advantages if starting from scratch. At the same time there is cgwalters/coretoolbox which is an already functional implementation. Between the two, I'm not sure what I would choose. Very curious to see how this decision goes.

@giuseppe
Copy link
Member

giuseppe commented Nov 4, 2019

If you pick Go, I'd also suggest to use podman directly from the CLI, or alternatively through varlink.

The libpod version vendored by toolbox may be different than what Podman uses. I don't think we are ready for supporting two versions of libpod that run and manage the same storage.

@dustymabe
Copy link
Collaborator

The libpod version vendored by toolbox may be different than what Podman uses. I don't think we are ready for supporting two versions of libpod that run and manage the same storage.

Yes. Agree. This is something we had previously discussed as well and we agreed to not vendor libpod.

@softwarefactory-project-zuul
Copy link

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.

@softwarefactory-project-zuul
Copy link

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.

@softwarefactory-project-zuul
Copy link

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.

@softwarefactory-project-zuul
Copy link

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.

@softwarefactory-project-zuul
Copy link

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.

1 similar comment
@softwarefactory-project-zuul
Copy link

Merge Failed.

This change or one of its cross-repo dependencies was unable to be automatically merged with the current state of its repository. Please rebase the change and upload a new patchset.

debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request May 13, 2020
For some reason, the State:Pid value in the JSON returned by
'podman inspect --format json --type container' is a float64 [1], even
though internally Podman represents it as an int.

[1] containers/podman#6105

containers#318
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request May 13, 2020
debarshiray pushed a commit to debarshiray/toolbox that referenced this pull request May 13, 2020
The Go version supports specifying the name of the toolbox container as
'toolbox enter NAME', on top of the 'toolbox enter --container NAME'
form.

containers#318
debarshiray added a commit to debarshiray/toolbox that referenced this pull request May 13, 2020
HarryMichal and others added 7 commits May 13, 2020 13:22
The Go version supports specifying the name of the new toolbox
container as 'toolbox create NAME', in addition to the existing
'toolbox create --container NAME' form.

containers#318
For some reason, the State:Pid value in the JSON returned by
'podman inspect --format json --type container' is a float64 [1], even
though internally Podman represents it as an int.

[1] containers/podman#6105

containers#318
The Go version supports specifying the name of the toolbox container as
'toolbox enter NAME', on top of the 'toolbox enter --container NAME'
form.

containers#318
@debarshiray debarshiray merged commit ebd92b9 into containers:master May 13, 2020
@abitrolly
Copy link

No way! :D

debarshiray added a commit to debarshiray/toolbox that referenced this pull request Feb 22, 2024
The concept of a 'base' image for creating Toolbx containers hasn't
existed since Toolbx 0.0.10, when the Buildah dependency and the
user-specific customized image were dropped [1].  That was a long time
ago.  Toolbx containers created before that were never supported by the
Go implementation [2].

Therefore, it's time to update the terminology.

Only the images for currently maintained Fedoras (ie., 38 and 39) were
updated.

[1] Commit 8b84b5e
    containers@8b84b5e4604921fa
    containers#160

[2] Commit 238f245
    containers@238f2451e7d7d54a
    containers#318

containers#1456
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Feb 22, 2024
The concept of a 'base' image for creating Toolbx containers hasn't
existed since Toolbx 0.0.10, when the Buildah dependency and the
user-specific customized image were dropped [1].  That was a long time
ago.  Toolbx containers created before that were never supported by the
Go implementation [2].

Therefore, it's time to update the terminology.

[1] Commit 8b84b5e
    containers@8b84b5e4604921fa
    containers#160

[2] Commit 238f245
    containers@238f2451e7d7d54a
    containers#318

containers#1456
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Feb 22, 2024
The concept of a 'base' image for creating Toolbx containers hasn't
existed since Toolbx 0.0.10, when the Buildah dependency and the
user-specific customized image were dropped [1].  That was a long time
ago.  Toolbx containers created before that were never supported by the
Go implementation [2].

Therefore, it's time to update the terminology.

[1] Commit 8b84b5e
    containers@8b84b5e4604921fa
    containers#160

[2] Commit 238f245
    containers@238f2451e7d7d54a
    containers#318

containers#1456
debarshiray added a commit to debarshiray/toolbox that referenced this pull request May 15, 2024
Unmarshal the JSON from 'podman inspect --format json --type container'
directly inside podman.InspectContainer() to confine the details within
the podman package.

The JSON samples for the unit tests were taken using the default Toolbx
container on versions of Fedora that shipped a specific Podman and
Toolbx version.  This accounts for differences in the JSON output caused
by different major versions of Podman and the way different Toolbx
versions set up the containers over time.

The minimum required Podman version is 1.6.4 [1], and the Go
implementation has been encouraging users to create containers with
Toolbx version 0.0.17 or newer [2].  The versions used to collect the
JSON samples for the unit tests were chosen accordingly.  They don't
exhaustively cover all supported version combinations, but hopefully
cover enough to be useful.

[1] Commit 8e80dd5
    containers@8e80dd5db1e6f40b
    containers#1253

[2] Commit 238f245
    containers@238f2451e7d7d54a
    containers#318

containers#1490
debarshiray added a commit to debarshiray/toolbox that referenced this pull request May 16, 2024
Unmarshal the JSON from 'podman inspect --format json --type container'
directly inside podman.InspectContainer() to confine the details within
the podman package.

The JSON samples for the unit tests were taken using the default Toolbx
container on versions of Fedora that shipped a specific Podman and
Toolbx version.  This accounts for differences in the JSON caused by
different major versions of Podman and the way different Toolbx versions
set up the containers.

One exception was Fedora 28, which had Podman 1.1.2 and Toolbx 0.0.9,
which is the last Toolbx version before 'toolbox init-container' became
the entry point for all Toolbx containers [1].  However, the default
Toolbx image is no longer available from registry.fedoraproject.org.
Hence, the image for Fedora 29 was used.

The minimum required Podman version is 1.6.4 [2], and the Go
implementation has been encouraging users to create containers with
Toolbx version 0.0.17 or newer [3].  The versions used to collect the
JSON samples for the unit tests were chosen accordingly.  They don't
exhaustively cover all possible supported and unsupported version
combinations, but hopefully enough to be useful.

[1] Commit 8b84b5e
    containers@8b84b5e4604921fa
    https://github.com/debarshiray/toolbox/pull/160

[2] Commit 8e80dd5
    containers@8e80dd5db1e6f40b
    containers#1253

[3] Commit 238f245
    containers@238f2451e7d7d54a
    containers#318

containers#1490
debarshiray added a commit to debarshiray/toolbox that referenced this pull request May 16, 2024
Unmarshal the JSON from 'podman inspect --format json --type container'
directly inside podman.InspectContainer() to confine the details within
the podman package.

The JSON samples for the unit tests were taken using the default Toolbx
container on versions of Fedora that shipped a specific Podman and
Toolbx version.  This accounts for differences in the JSON caused by
different major versions of Podman and the way different Toolbx versions
set up the containers.

One exception was Fedora 28, which had Podman 1.1.2 and Toolbx 0.0.9,
which is the last Toolbx version before 'toolbox init-container' became
the entry point for all Toolbx containers [1].  However, the default
Toolbx image is no longer available from registry.fedoraproject.org.
Hence, the image for Fedora 29 was used.

The minimum required Podman version is 1.6.4 [2], and the Go
implementation has been encouraging users to create containers with
Toolbx version 0.0.17 or newer [3].  The versions used to collect the
JSON samples for the unit tests were chosen accordingly.  They don't
exhaustively cover all possible supported and unsupported version
combinations, but hopefully enough to be useful.

[1] Commit 8b84b5e
    containers@8b84b5e4604921fa
    https://github.com/debarshiray/toolbox/pull/160

[2] Commit 8e80dd5
    containers@8e80dd5db1e6f40b
    containers#1253

[3] Commit 238f245
    containers@238f2451e7d7d54a
    containers#318

containers#1490
debarshiray added a commit to debarshiray/toolbox that referenced this pull request May 16, 2024
Unmarshal the JSON from 'podman inspect --format json --type container'
directly inside podman.InspectContainer() to confine the details within
the podman package.

The JSON samples for the unit tests were taken using the default Toolbx
container on versions of Fedora that shipped a specific Podman and
Toolbx version.  This accounts for differences in the JSON caused by
different major versions of Podman and the way different Toolbx versions
set up the containers.

One exception was Fedora 28, which had Podman 1.1.2 and Toolbx 0.0.9,
which is the last Toolbx version before 'toolbox init-container' became
the entry point for all Toolbx containers [1].  However, the default
Toolbx image is no longer available from registry.fedoraproject.org.
Hence, the image for Fedora 29 was used.

The minimum required Podman version is 1.6.4 [2], and the Go
implementation has been encouraging users to create containers with
Toolbx version 0.0.17 or newer [3].  The versions used to collect the
JSON samples for the unit tests were chosen accordingly.  They don't
exhaustively cover all possible supported and unsupported version
combinations, but hopefully enough to be useful.

[1] Commit 8b84b5e
    containers@8b84b5e4604921fa
    https://github.com/debarshiray/toolbox/pull/160

[2] Commit 8e80dd5
    containers@8e80dd5db1e6f40b
    containers#1253

[3] Commit 238f245
    containers@238f2451e7d7d54a
    containers#318

containers#1490
debarshiray added a commit to debarshiray/toolbox that referenced this pull request May 16, 2024
Unmarshal the JSON from 'podman inspect --format json --type container'
directly inside podman.InspectContainer() to confine the details within
the podman package.

The JSON samples for the unit tests were taken using the default Toolbx
container on versions of Fedora that shipped a specific Podman and
Toolbx version.  This accounts for differences in the JSON caused by
different major versions of Podman and the way different Toolbx versions
set up the containers.

One exception was Fedora 28, which had Podman 1.1.2 and Toolbx 0.0.9,
which was the last Toolbx version before 'toolbox init-container' became
the entry point for all Toolbx containers [1].  However, the default
Toolbx image is no longer available from registry.fedoraproject.org.
Hence, the image for Fedora 29 was used.

The minimum required Podman version is 1.6.4 [2], and the Go
implementation has been encouraging users to create containers with
Toolbx version 0.0.17 or newer [3].  The versions used to collect the
JSON samples for the unit tests were chosen accordingly.  They don't
exhaustively cover all possible supported and unsupported version
combinations, but hopefully enough to be useful.

[1] Commit 8b84b5e
    containers@8b84b5e4604921fa
    https://github.com/debarshiray/toolbox/pull/160

[2] Commit 8e80dd5
    containers@8e80dd5db1e6f40b
    containers#1253

[3] Commit 238f245
    containers@238f2451e7d7d54a
    containers#318

containers#1490
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5. Help Wanted Extra attention is needed 6. Major Change May cause breakage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants