Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Extract command implementions into sub-packages #609

Closed
carolynvs opened this issue May 19, 2017 · 10 comments
Closed

Extract command implementions into sub-packages #609

carolynvs opened this issue May 19, 2017 · 10 comments

Comments

@carolynvs
Copy link
Collaborator

carolynvs commented May 19, 2017

As we bring on new maintainers/contributors, it will be helpful to organize the code into sub-packages. This would separate the various components of dep, for example:

  • Each command's implementation would have a pkg: init, ensure, and status.
  • Split up gps into components: solver, @sdboyer I forgot the others you mentioned 😅
  • Shared code which are used by multiple components, which of course would never, ever be named util, such as fs.go.

We also need to consider our plan for what's internal/exported which is a conversation that was started under #527.

UPDATE: Narrowed scope of this issue to only address the first bullet point.

@jonstacks
Copy link
Contributor

@carolynvs,

Still new to the dep, but I could try to tackle this one. Would it be okay to PR in stages? I'd assume starting by packaging up each command would be the easiest?

@carolynvs
Copy link
Collaborator Author

Oops! 😊 Before work can start working on this, we first need to decide what the subpackages will be, which wasn't clear at all from the issue description.

@sdboyer
Copy link
Member

sdboyer commented May 23, 2017

This is great! I'd say that focusing on refactoring the command structure so that we can have discrete subcommand packages is definitely step one. Let's say this issue is for that specifically, and ignore the rest for now. Because...

Split up gps into components: solver

Splitting up gps much more than it is right now is likely to be quite a chore, as it relies on package-internal type magic for Version and Constraint to make all the pieces hang together.

@carolynvs carolynvs changed the title Organize code into sub-packages Extract command implementions into sub-packages May 23, 2017
@carolynvs
Copy link
Collaborator Author

FYI, my mental timeline for this is:

  1. finish in-flight init work to avoid bad merges: Import glide configuration during init #500, WIP - Import godep #589
  2. move init into a sub-package
  3. move remaining commands into sub-packages
  4. finally tackle getting the ensure command to match the new spec

I suggest extracting command implementations into github.com/golang/dep/<command-name>, e.g. github.com/golang/dep/init. In each sub-package just the command and a single entrypoint function are exposed.

The init, ensure, and status commands would be extracted into the new sub-packages. The remove command will not be touched, as we are working in #481 to get rid of this deprecated command. I don't think hash-inputs is going to make it into the final set of commands either, so that should remain in place as well.

The cli command handlers in cmd/dep are responsible for flag parsing and other cli concerns, everything else should be moved into the sub-package. The handlers shouldn't be doing heavy lifting, such as simultaneously parsing args and tweaking the solver params like ensure does currently. 😀

When something is needed by multiple commands, such as deduceConstraint(), for now it should probably go under the root package and be exposed as minimally as possible. Making things internal should be out-of-scope, as otherwise circular dependencies will quickly cause this to balloon and impact many more areas of dep.

@davecheney
Copy link
Contributor

davecheney commented May 23, 2017 via email

@sdboyer
Copy link
Member

sdboyer commented May 23, 2017

@davecheney given that we're trying to split these up to maximize clarity for divided maintainership, any suggestions?

@carolynvs this all sounds pretty good to me, though I'll note that ensure is definitely going to need to monkey with params, and will likely also need to do some variable parsing of args.

@davecheney
Copy link
Contributor

davecheney commented May 24, 2017 via email

@sdboyer
Copy link
Member

sdboyer commented May 24, 2017

Ah, our concern wasn't about merges, so much as just having clear boundary lines around who's responsible for what. I suppose we can go file-by-file, at least where necessary.

(Or, just don't worry about drawing such precise lines...)

@carolynvs
Copy link
Collaborator Author

I'd just like to see the implementations for the commands be better separated. For example, extracting methods out of the Run functions and moving common functions out of the command's file into someplace where it is more clear that it's shared.

Up to you Sam ultimately, on how you'd like to see things organized/managed. 😃

@sdboyer
Copy link
Member

sdboyer commented May 26, 2017

@carolynvs OK, let's hold off on subpackaging them for now, unless we feel a strong need to do so for functional (as opposed to administrative) reasons.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants