nerdctl icon indicating copy to clipboard operation
nerdctl copied to clipboard

Move image pull args into struct

Open sondavidb opened this issue 1 year ago • 7 comments

In the image pull workflow, the function headers are getting far too large. (imgutil.EnsureImage had 13 required arguments as of the time of this PR.) This change consolidates many of the arguments in imgutil.PullImage into types.ImagePullTypes, and the necessary refactors that come with this change.

I did as much pre-processing in processPullCommandFlags as possible. So, anything that cannot be declared from the function flags did not fall in the options.

Did some basic testing with make and running some basic image commands to do a sanity check that functionality remained intact.

Very open to suggestions on how to structure this a bit more logically. I made a best effort but a fresh pair of eyes always helps 😅

sondavidb avatar Mar 22 '24 00:03 sondavidb

Rebased with main and addressed reviews.

Wondering why lint check seems to fail though...

sondavidb avatar Mar 29 '24 23:03 sondavidb

Can I just confirm that the lint check failing is unrelated?

sondavidb avatar Apr 04 '24 20:04 sondavidb

Can I just confirm that the lint check failing is unrelated?

I think it's unrelated. You can rebase which should retrigger the CI.

djdongjin avatar Apr 04 '24 20:04 djdongjin

Rebased

Rebase below this fixes lint issues

sondavidb avatar Apr 04 '24 21:04 sondavidb

Sorry, needs another rebase

AkihiroSuda avatar May 18 '24 19:05 AkihiroSuda

Rebased, but I think I would like to hold off on this PR for a bit. IMO, this needs to be part of a larger refactor. It would be strange to have all of the image args in a config for image pull, but not for any of the other commands.

If you'd still like this change feel free to merge, but I also think it would be good to do similar refactors for our other commands.

sondavidb avatar May 21 '24 17:05 sondavidb

I think it's okay to have this PR, given some methods like EnsureImage indeed has many args and having a config struct improve that a bit.

djdongjin avatar May 22 '24 01:05 djdongjin

Rebased

Rebase below this fixes lint issues

Hey @sondavidb

FWIW +1 on merging this and continuing the effort on other image methods as subsequent PRs.

It does not look like the current CI failures are related to your changes - but then if you would like to rebase one last time and kick another CI run, that would be nice (there has been a lot of fixes & efforts recently to make it more reliable).

apostasie avatar Jul 13 '24 17:07 apostasie

Thanks, rebased.

FWIW +1 on merging this and continuing the effort on other image methods as subsequent PRs.

IMO ideally the PRs to refactor this all come out around the same time, but I can't guarantee it's something I can handle currently due to other priorities.

I can make a tracking issue and list what commands need to be reconfigured into structs. ~~I think anything in pkg/api/types is probably usable for this purpose.~~ Maybe not, actually, but we should ideally use these options structs as much as possible. I'm not sure if we have any other function headers we want to change in a similar fashion?

sondavidb avatar Jul 15 '24 21:07 sondavidb