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

Refactor capdctl #84

Merged
merged 14 commits into from
Jul 15, 2019
Merged

Conversation

liztio
Copy link
Contributor

@liztio liztio commented Jul 11, 2019

What this PR does / why we need it:
Removes all gnarly kubectl exec lines we have lying around in capdctl

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:
😅

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:

capdctl no longer requires `kubectl` to be installed and executable

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 11, 2019
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 11, 2019
@liztio
Copy link
Contributor Author

liztio commented Jul 11, 2019

/cc @vincepri

@liztio
Copy link
Contributor Author

liztio commented Jul 11, 2019

part of #23

Copy link
Contributor

@chuckha chuckha left a comment

Choose a reason for hiding this comment

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

A few things need cleanup and license files need to be in all new files. Besides that my only other point of discussion: Do you think these files referencing CAPI types could live in like a /v1alpha1/ directory so we know which ones to use for v1a1 and which ones to use for v1a2? Or do you think there's a better solution to that problem? I think that's out of scope for this PR but I'm curious about your thoughts since I'd like to be able to support both (and future) versions of CAPI

"k8s.io/client-go/restmapper"
"sigs.k8s.io/cluster-api-provider-docker/kind/controlplane"
"sigs.k8s.io/cluster-api-provider-docker/objects"
_ "sigs.k8s.io/cluster-api-provider-docker/objects"
Copy link
Contributor

Choose a reason for hiding this comment

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

imported twice but once with an underscore?

@@ -0,0 +1,41 @@
package controlplane
Copy link
Contributor

Choose a reason for hiding this comment

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

this and all new files are missing license header

)

// getCRDs should actually use kustomize to correctly build the manager yaml.
// HACK: this is a hacked function
Copy link
Contributor

Choose a reason for hiding this comment

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

the hack lives on

objects/capi Outdated
@@ -0,0 +1,70 @@
package objects
Copy link
Contributor

Choose a reason for hiding this comment

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

This file should be removed

Copy link
Contributor

@chuckha chuckha left a comment

Choose a reason for hiding this comment

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

lgtm, will approve after tests pass

@liztio
Copy link
Contributor Author

liztio commented Jul 15, 2019

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 15, 2019
@liztio
Copy link
Contributor Author

liztio commented Jul 15, 2019

It doesn't uh, actually work right now seemingly 😅

tgz := tar.NewReader(gz)
var buf bytes.Buffer

for {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we run tar -xvf using cmd.exec instead? That, I think, will greatly simplify this code.

Copy link
Contributor

Choose a reason for hiding this comment

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

This was just moved, I created it in a previous PR. I'm not execing for the same reason @liztio is removing the exec to kubectl. It is easier to manage dependencies through go.mod. In both cases it is very possible. If we were to exec we'd have to first make sure the right version of kubectl / tar /whatever are installed. It adds unnecessary complication for the end user when we can do it in Go and be done with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a valid reason that applies more to kubectl than utils like tar or any other linux utils we may want to use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we'd still need to walk the entire directory and read these files in. And we don't want to assume tar exists with the same arguments on every system we need to interact with. cmd.Exec() should always be a last resort IMO

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 this is avoidable complexity. But, I am OK with doing this 😄

limitations under the License.
*/

package objects
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest calling this package manifests. objects is a little confusing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's what Kubernetes calls them 🤷‍♀️

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@ashish-amarnath
Copy link
Contributor

/test pull-cluster-api-provider-docker-verify

@liztio liztio force-pushed the refactor-capdctl branch from 4454c57 to 419ec5c Compare July 15, 2019 18:16
@chuckha
Copy link
Contributor

chuckha commented Jul 15, 2019

After the last two PRs we uncovered an issue with the examples. This now works!

@chuckha
Copy link
Contributor

chuckha commented Jul 15, 2019

/approve
/lgtm
/hold cancel

We worked on this together for a long time which is why I am both approving and lgtm

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 15, 2019
@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 15, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chuckha, liztio

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 15, 2019
@k8s-ci-robot k8s-ci-robot merged commit 981249f into kubernetes-retired:master Jul 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants