Skip to content

Moves k8s and conduit client code to /pkg#103

Merged
pcalcado merged 9 commits intomasterfrom
phil/conduit-status-kubeapi
Jan 4, 2018
Merged

Moves k8s and conduit client code to /pkg#103
pcalcado merged 9 commits intomasterfrom
phil/conduit-status-kubeapi

Conversation

@pcalcado
Copy link
Contributor

@pcalcado pcalcado commented Jan 2, 2018

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 /pkg directory

Copy link
Contributor

@klingerf klingerf left a comment

Choose a reason for hiding this comment

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

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"
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

"net/http"

"github.com/runconduit/conduit/pkg/conduit"

Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment here -- this import should be sorted into the list below it.

"net/url"

"github.com/runconduit/conduit/pkg/k8s"

Copy link
Contributor

Choose a reason for hiding this comment

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

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"

Copy link
Contributor

Choose a reason for hiding this comment

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

And one more sorting issue here.

@@ -1,4 +1,4 @@
package public
package conduit
Copy link
Contributor

@klingerf klingerf Jan 2, 2018

Choose a reason for hiding this comment

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

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@@ -8,8 +8,8 @@ import (

"github.com/runconduit/conduit/cli/healthcheck"
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

And I'd vote to move the cli/shell package to pkg/shell as well.


"github.com/runconduit/conduit/controller"
uuid "github.com/satori/go.uuid"
"github.com/satori/go.uuid"
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Member

@siggy siggy left a comment

Choose a reason for hiding this comment

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

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/k8s vs. /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.

@pcalcado pcalcado force-pushed the phil/conduit-status-kubeapi branch from e5e0b25 to d45f61f Compare January 4, 2018 08:09
Phil Calcado added 8 commits January 4, 2018 00:09
As it is more commonly used in the codebase

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]>
@pcalcado pcalcado force-pushed the phil/conduit-status-kubeapi branch from d45f61f to 372b558 Compare January 4, 2018 08:09
@pcalcado
Copy link
Contributor Author

pcalcado commented Jan 4, 2018

@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 "where does this module go?" without being blocked.

@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?

@pcalcado pcalcado force-pushed the phil/conduit-status-kubeapi branch from 372b558 to b3e32fe Compare January 4, 2018 08:14
Signed-off-by: Phil Calcado <[email protected]>
@pcalcado pcalcado force-pushed the phil/conduit-status-kubeapi branch from b3e32fe to 13de485 Compare January 4, 2018 08:16
@pcalcado
Copy link
Contributor Author

pcalcado commented Jan 4, 2018

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.

Copy link
Member

@siggy siggy left a comment

Choose a reason for hiding this comment

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

:shipit:

@pcalcado pcalcado merged commit 709de5a into master Jan 4, 2018
@pcalcado pcalcado deleted the phil/conduit-status-kubeapi branch February 5, 2018 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants