Moves k8s and conduit client code to /pkg#103
Conversation
5b4ab3f to
942aae3
Compare
klingerf
left a comment
There was a problem hiding this comment.
Moving these files to a shared location makes sense to me. In the projects that I've worked with that have a top-level pkg dir, the organization of that dir always seems (to me) to be a bit inscrutable. It's usually not clear which packages belong in the dir, and the naming of the packages doesn't give a lot of context.
To help make sure we don't run into this, I think we should be really strict about naming, and we should move all shared packages into pkg. I've commented below with a few suggestions. I think we should also get rid of all of these util pacakges, and move them into better-named pkg directories: controller/api/util, web/util, controller/util.
|
|
||
| pb "github.com/runconduit/conduit/controller/gen/public" | ||
| "github.com/runconduit/conduit/pkg/k8s" | ||
| "github.com/spf13/cobra" |
There was a problem hiding this comment.
I think your sorting is slightly off here -- if you remove the blank line on line 7, then the pkg/conduit import should be grouped together with the pkg/k8s import.
controller/api/public/server.go
Outdated
| "net/http" | ||
|
|
||
| "github.com/runconduit/conduit/pkg/conduit" | ||
|
|
There was a problem hiding this comment.
Same comment here -- this import should be sorted into the list below it.
pkg/conduit/client.go
Outdated
| "net/url" | ||
|
|
||
| "github.com/runconduit/conduit/pkg/k8s" | ||
|
|
There was a problem hiding this comment.
Sorting issue here as well.
web/main.go
Outdated
| "github.com/runconduit/conduit/controller/api/public" | ||
| "github.com/runconduit/conduit/web/srv" | ||
| "github.com/runconduit/conduit/pkg/conduit" | ||
|
|
There was a problem hiding this comment.
And one more sorting issue here.
pkg/conduit/client.go
Outdated
| @@ -1,4 +1,4 @@ | |||
| package public | |||
| package conduit | |||
There was a problem hiding this comment.
I'm a bit worried that a pkg/conduit directory is going to turn into a dumping ground. Can we call this something more specific? Maybe pkg/apiclient?
On a related note, I have mixed feelings about separating controller/api/public/client.go and controller/api/public/server.go into separate packages. They represent two sides of our custom protobuf-over-http setup, so I think it makes sense to group them together.
How would you feel about renaming this package to api, and moving controller/api/public/server.go into it as well?
There was a problem hiding this comment.
I think you are right about the coupling. I was originally worried about not having "too smart" client libraries, but ultimately this lib is smart because it abstracts gRPC over HTTP and extension points. I moved it back in latest commits.
cli/cmd/status.go
Outdated
| @@ -8,8 +8,8 @@ import ( | |||
|
|
|||
| "github.com/runconduit/conduit/cli/healthcheck" | |||
There was a problem hiding this comment.
I think it makes sense to move the cli/healthcheck package to pkg/healthcheck as well, since it's imported by some of the files that you're moving to pkg/k8s.
There was a problem hiding this comment.
And I'd vote to move the cli/shell package to pkg/shell as well.
cli/cmd/install.go
Outdated
|
|
||
| "github.com/runconduit/conduit/controller" | ||
| uuid "github.com/satori/go.uuid" | ||
| "github.com/satori/go.uuid" |
There was a problem hiding this comment.
I don't think this is documented anywhere, but my preference is to explicitly set the package name when the last segment of the import path doesn't match the name of the package being imported.
siggy
left a comment
There was a problem hiding this comment.
overall i like the direction this is going. echoing some of kevin's comments, i'd like to understand/establish guiding principals on where things should go. a few questions along these lines:
- should anything without a main go under
/pkg? - when to put something under
controller/k8svs./pkg/k8s? is it strictly a matter of whether the code is shared? is it easier to reason about if all the k8s code is in one place? - building on the previous question: does it make sense to make a distinction between library code that is shared across mains vs. single-use? when browsing the repo, i'd prefer to see all library code in one place.
e5e0b25 to
d45f61f
Compare
As it is more commonly used in the codebase Signed-off-by: Phil Calcado <[email protected]>
Signed-off-by: Phil Calcado <[email protected]>
…rnal libs Signed-off-by: Phil Calcado <[email protected]>
Signed-off-by: Phil Calcado <[email protected]>
Signed-off-by: Phil Calcado <[email protected]>
Signed-off-by: Phil Calcado <[email protected]>
Signed-off-by: Phil Calcado <[email protected]>
Signed-off-by: Phil Calcado <[email protected]>
d45f61f to
372b558
Compare
|
@klingerf Agree on being strict. Actually, it's not about being strict, to me it is making sure that everyone contributing to this project has a way to answer the question of @siggy those are great questions and I have a suggestion on how to deal with this—hint, it has to do with not considering a go package an atomic module. I volunteer to open a PR with rationale, also dealing with @klingerf comments, just after this. wdyt? |
372b558 to
b3e32fe
Compare
Signed-off-by: Phil Calcado <[email protected]>
b3e32fe to
13de485
Compare
|
I think I've addressed all feedback. I'm still unsure about https://github.com/runconduit/conduit/pull/103/files#diff-a3991410d9e729a648de0e63d3f91d03R159 but couldn't track who to ask. |
Before I add Kubernetes API checks for the status command as part of #92 I'd like to start moving this shared code to the more standard
/pkgdirectory