Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubecfg 0.8.0 (new formula) #25737

Closed
wants to merge 11 commits into from
Closed

kubecfg 0.8.0 (new formula) #25737

wants to merge 11 commits into from

Conversation

aecolley
Copy link
Contributor

@aecolley aecolley commented Mar 25, 2018

This is a Kubernetes tool developed at Bitnami. It is a prerequisite
for some development tasks with the better-known Kubeless project
(http://kubeless.io/docs/dev-guide/). It should not be confused with
the identically-named, defunct precursor to kubectl.

I am slightly concerned that it doesn't have its own website, except
for its Github repository and a couple of YouTube videos. But a quick
survey shows that 25% of homebrew-core formulae have homepages in
the github.com domain, so I suspect it's OK.

  • [✓] Have you followed the guidelines for contributing?
  • [✓] Have you checked that there aren't other open pull requests for the same formula update/change?
  • [✓] Have you built your formula locally with brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • [✓] Does your build pass brew audit --strict <formula> (after doing brew install <formula>)?

This is a Kubernetes tool developed at Bitnami. It is a prerequisite
for some development tasks with the better-known Kubeless project
(http://kubeless.io/docs/dev-guide/). It should not be confused with
the identically-named, defunct precursor to kubectl.

I am slightly concerned that it doesn't have its own website, except
for its Github repository and a couple of YouTube videos. But a quick
survey shows that 25% of homebrew-core formulae have homepages in
the github.com domain, so I suspect it's OK.

The "gopath shenanigans" mentioned in a comment seem to be a new
requirement with Go 1.10. Previous Go releases let you get away with
a symlink to buildpath, but 1.10 refuses to recognise the "vendor"
directory if it's found via a symlink.
@fxcoudert fxcoudert added the new formula PR adds a new formula to Homebrew/homebrew-core label Mar 25, 2018
@jjo
Copy link

jjo commented Mar 26, 2018

Thanks @aecolley for the PR, much appreciated !, will loop
someone else with brew'ing skills already to review it :)

Copy link
Contributor

@andresmgot andresmgot left a comment

Choose a reason for hiding this comment

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

I tested the formula and the installation, audit and test worked as expected. I just made some small comments. Apart from that wait for brew maintainers to have more details about other requirements they may have. Thanks!

class Kubecfg < Formula
desc "Manage complex enterprise Kubernetes environments as code"
homepage "https://github.com/ksonnet/kubecfg"
url "https://github.com/ksonnet/kubecfg/archive/v0.7.2.tar.gz"
Copy link
Contributor

Choose a reason for hiding this comment

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

for making it easier to update you can use the github repo as url and the tag and commit as versions:

url "https://github.com/ksonnet/kubecfg.git"
      :tag => "v0.7.2",
      :revision => "7c1e6e59cc5cdf7259f17d349e55b6287b419b13"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While that works fine, the Acceptable Formulae document says:

Tarballs are preferred to Git checkouts, and tarballs should include the version in the filename whenever possible.

Unless you specifically overrule that, I'm inclined to hew closely to it.

args.push("VERSION=#{version}") unless build.head?
system "make", "generate", *args if build.head?
system "make", *args
system "make", "test", *args if build.head?
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move the make test task if possible to the test hook

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 a good idea, but I'm not sure it's possible. The Formula API says that buildpath is only non-nil inside the install method. I don't see another way to find the extracted source code, or even a way to provoke its recreation. The man page describes brew test as something that

should generally indicate to the user if something is wrong with the installed formula.

end

test do
system "#{bin}/kubecfg", "show", "#{share}/lib/kubecfg_test.jsonnet"
Copy link
Contributor

Choose a reason for hiding this comment

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

I would compare the output of this command with an expected result

Choose a reason for hiding this comment

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

There's no need to compare the output. The test file uses asserts everywhere and is designed to cause a non-zero exit on failure. The "success" value
is just the bare minimum designed to cause kubecfg to exit successfully.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem.

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 reverted this after reading @anguslees' reply.

sharelib = share/"lib"
sharelib.mkpath
sharelib.install srcdir/"lib/kubecfg.libsonnet"
sharelib.install srcdir/"lib/kubecfg_test.jsonnet"

Choose a reason for hiding this comment

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

This _test lib is not relevant for an end user, and doesn't need to be installed.

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 true. I installed it only so it would be available for the test mode. If you come up with a good one-liner (for values of one up to 5) which tests the most basic functionality of kubecfg, I'll happily substitute it.

Choose a reason for hiding this comment

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

Oh I see - the homebrew "test" is on the installed result, not the intermediate build artifacts. In that case, it's a reasonable test 👍

bin.install srcdir/"kubecfg"
sharelib = share/"lib"
sharelib.mkpath
sharelib.install srcdir/"lib/kubecfg.libsonnet"

Choose a reason for hiding this comment

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

Note that the next and future releases (from vmware-archive/kubecfg#197) won't need this file to be separately installed - it now embeds kubecfg.libsonnet in the binary.

Current (and past) releases do need this separately installed, however.

Edit: Ah! I see from the caveats text below, that you're already aware of this, and just installing it as a reference for the user. Nice move.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I thought it was already embedded in 0.7.2.

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 included a tiny patch to inject the share/lib directory at the end of the search path. import "kubecfg.jsonnet" now looks in the right place. Obviously it should go on the next release with the internalfs stuff obviating it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still needed for 0.8.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but it's used in the brew test block.

cd srcdir do
args = []
args.push("VERSION=#{version}") unless build.head?
system "make", "generate", *args if build.head?

Choose a reason for hiding this comment

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

make generate (and go-bindata) are only required at dev-time, and the up-to-date generated file is supposed to be already included in git repo. .. So I think you should remove this step (and go-bindata dependency) from the homebrew formula.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Simpler is better, so I'll do that.

end

test do
system "#{bin}/kubecfg", "show", "#{share}/lib/kubecfg_test.jsonnet"

Choose a reason for hiding this comment

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

There's no need to compare the output. The test file uses asserts everywhere and is designed to cause a non-zero exit on failure. The "success" value
is just the bare minimum designed to cause kubecfg to exit successfully.

# The real build steps:
cd srcdir do
args = []
args.push("VERSION=#{version}") unless build.head?
Copy link

@anguslees anguslees Mar 28, 2018

Choose a reason for hiding this comment

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

what does #{version} look like once expanded? It would be good if it matched the regular kubecfg upstream release builds, which use git tag - eg v0.7.2 (including the v) and not just 0.7.2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the v.

Copy link

@anguslees anguslees left a comment

Choose a reason for hiding this comment

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

lgtm.

(and hi aecolley! :)

Copy link

@anguslees anguslees left a comment

Choose a reason for hiding this comment

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

(still lgtm)

@anguslees
Copy link

"At least 6 approving reviews are required by reviewers with write access." Wow.

@aecolley
Copy link
Contributor Author

aecolley commented Apr 3, 2018

@fxcoudert is this ready for review, or is there something else I should do first?

(Nice work on #26034 by the way!)

@aecolley aecolley changed the title kubecfg 0.7.2 (new formula) kubecfg 0.8.0 (new formula) Apr 3, 2018
@aecolley
Copy link
Contributor Author

@fxcoudert two-week ping

@commitay
Copy link
Contributor

@BrewTestBot test this please

homepage "https://github.com/ksonnet/kubecfg"
url "https://github.com/ksonnet/kubecfg/archive/v0.8.0.tar.gz"
sha256 "25d054af96a817bad0f33998895a9988c187e1399822c8220528e64f56ccb3ae"
head "https://github.com/ksonnet/kubecfg.git"
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove head

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Really? I will comply, but I suggest that the Acceptable Formulae document should document the deprecation of head and any conditions that apply.

bin.install srcdir/"kubecfg"
sharelib = share/"lib"
sharelib.mkpath
sharelib.install srcdir/"lib/kubecfg.libsonnet"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still needed for 0.8.0?

def install
ENV["GOPATH"] = buildpath
srcdir = buildpath/"src/github.com/ksonnet/kubecfg"
srcdir.install buildpath.children - [buildpath/".brew_home"]
Copy link
Contributor

Choose a reason for hiding this comment

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

    ENV["GOPATH"] = buildpath
    (buildpath/"src/github.com/ksonnet/kubecfg").install buildpath.children

    cd "src/github.com/ksonnet/kubecfg" do
      system "make", "VERSION=v#{version}"
      bin.install "kubecfg"
      ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Added.

@commitay
Copy link
Contributor

@BrewTestBot test this please

@aecolley
Copy link
Contributor Author

Is there something further I should do here?

@fxcoudert
Copy link
Member

@BrewTestBot test this please

end

test do
system bin/"kubecfg", "show", pkgshare/"kubecfg_test.jsonnet"
Copy link
Member

@fxcoudert fxcoudert Apr 30, 2018

Choose a reason for hiding this comment

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

Can we match the output?

output = shell_output("#{bin}/kubecfg show #{pkgshare}/kubecfg_test.jsonnet")
assert_match "result: SUCCESS", output

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The command spawned by shell_output uses its exit status to indicate success or failure. The kubecfg_test.jsonnet uses assertions to carry out all of its testing, and the output is trivial. We already discussed this earlier in this PR.

(zsh_completion/"_kubecfg").write output
end

def caveats; <<~EOS
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a standard location for Homebrew so I don't think we need this caveat

Copy link
Contributor Author

@aecolley aecolley May 3, 2018

Choose a reason for hiding this comment

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

Edit: never mind, I see now the deletion that made my comment obsolete.

Without the caveat, the user would naturally assume that the installed file is used by the kubecfg binary, and therefore that editing the file would be a way to debug it. The truth is that editing the file would be a waste of time. It is installed as a form of documentation, nothing more. Also, this is the only mention of the KUBECFG_JPATH feature, other than the source code. I freely admit I'm abusing caveats as documentation.

@stale
Copy link

stale bot commented May 24, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale No recent activity label May 24, 2018
@fxcoudert
Copy link
Member

@BrewTestBot test this please

@stale stale bot removed the stale No recent activity label May 24, 2018
@fxcoudert fxcoudert added the ready to merge PR can be merged once CI is green label May 24, 2018
@ilovezfs ilovezfs closed this in ccbae0f May 24, 2018
@ilovezfs
Copy link
Contributor

Thanks for your first contribution to Homebrew, and your patience, @aecolley! You're awesome.

@lock lock bot added the outdated PR was locked due to age label Jun 23, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jun 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new formula PR adds a new formula to Homebrew/homebrew-core outdated PR was locked due to age ready to merge PR can be merged once CI is green
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants