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

Add minikube license command #15158

Merged
merged 6 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1048,3 +1048,7 @@ update-gopogh-version: ## update gopogh version
update-gotestsum-version:
(cd hack/update/gotestsum_version && \
go run update_gotestsum_version.go)

.PHONY: generate-licenses
generate-licenses:
./hack/generate_licenses.sh
42 changes: 42 additions & 0 deletions cmd/minikube/cmd/license.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2022 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package cmd

import (
"github.com/spf13/cobra"
"k8s.io/minikube/pkg/minikube/download"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/reason"
)

var dir string

// licenseCmd represents the credits command
var licenseCmd = &cobra.Command{
Use: "license",
Short: "Outputs the licenses of dependencies to a directory",
Long: "Outputs the licenses of dependencies to a directory",
Run: func(cmd *cobra.Command, args []string) {
if err := download.Licenses(dir); err != nil {
exit.Error(reason.InetLicenses, "Failed to download licenses", err)
}
},
}

func init() {
licenseCmd.Flags().StringVarP(&dir, "dir", "d", ".", "Directory to output licenses to")
}
1 change: 1 addition & 0 deletions cmd/minikube/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ func init() {
updateCheckCmd,
versionCmd,
optionsCmd,
licenseCmd,
},
},
}
Expand Down
28 changes: 28 additions & 0 deletions hack/generate_licenses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Copyright 2022 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -eu -o pipefail

DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

GOBIN="$DIR" go install github.com/google/go-licenses@latest

rm -rf ./out/licenses
"${DIR}/go-licenses" save k8s.io/minikube/cmd/minikube --save_path="out/licenses" --force
pushd ./out
tar -zcvf licenses.tar.gz ./licenses
rm -rf ./licenses
popd
3 changes: 3 additions & 0 deletions hack/jenkins/release_build_and_upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export GOPATH=$HOME/go
echo "Verifying ISO exists ..."
make verify-iso

# Generate licenses
make generate-licenses

# Build and upload
env BUILD_IN_DOCKER=y \
make -j 16 \
Expand Down
12 changes: 6 additions & 6 deletions hack/release_notes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ function cleanup_token() {
}
trap cleanup_token EXIT

if ! [[ -x release-notes ]] || ! [[ -x pullsheet ]]; then
if ! [[ -x "${DIR}/release-notes" ]] || ! [[ -x "${DIR}/pullsheet" ]]; then
echo >&2 'Installing release-notes'
go install github.com/corneliusweig/release-notes@latest
go install github.com/google/pullsheet@latest
GOBIN="$DIR" go install github.com/corneliusweig/release-notes@latest
GOBIN="$DIR" go install github.com/google/pullsheet@latest
fi

git pull https://github.com/kubernetes/minikube.git master --tags
recent=$(git describe --abbrev=0)
recent_date=$(git log -1 --format=%as $recent)

release-notes kubernetes minikube --since $recent
"${DIR}/release-notes" kubernetes minikube --since $recent

echo ""
echo "For a more detailed changelog, including changes occurring in pre-release versions, see [CHANGELOG.md](https://github.com/kubernetes/minikube/blob/master/CHANGELOG.md)."
Expand All @@ -52,12 +52,12 @@ echo "Thank you to our PR reviewers for this release!"
echo ""
AWK_FORMAT_ITEM='{printf "- %s (%d comments)\n", $2, $1}'
AWK_REVIEW_COMMENTS='NR>1{arr[$4] += $6 + $7}END{for (a in arr) printf "%d %s\n", arr[a], a}'
pullsheet reviews --since "$recent_date" --repos kubernetes/minikube --token-path "$GH_TOKEN" --logtostderr=false --stderrthreshold=2 | awk -F ',' "$AWK_REVIEW_COMMENTS" | sort -k1nr -k2d | awk -F ' ' "$AWK_FORMAT_ITEM"
"${DIR}/pullsheet" reviews --since "$recent_date" --repos kubernetes/minikube --token-path "$GH_TOKEN" --logtostderr=false --stderrthreshold=2 | awk -F ',' "$AWK_REVIEW_COMMENTS" | sort -k1nr -k2d | awk -F ' ' "$AWK_FORMAT_ITEM"
echo ""
echo "Thank you to our triage members for this release!"
echo ""
AWK_ISSUE_COMMENTS='NR>1{arr[$4] += $7}END{for (a in arr) printf "%d %s\n", arr[a], a}'
pullsheet issue-comments --since "$recent_date" --repos kubernetes/minikube --token-path "$GH_TOKEN" --logtostderr=false --stderrthreshold=2 | awk -F ',' "$AWK_ISSUE_COMMENTS" | sort -k1nr -k2d | awk -F ' ' "$AWK_FORMAT_ITEM" | head -n 5
"${DIR}/pullsheet" issue-comments --since "$recent_date" --repos kubernetes/minikube --token-path "$GH_TOKEN" --logtostderr=false --stderrthreshold=2 | awk -F ',' "$AWK_ISSUE_COMMENTS" | sort -k1nr -k2d | awk -F ' ' "$AWK_FORMAT_ITEM" | head -n 5

if [[ "$recent" != *"beta"* ]]; then
echo ""
Expand Down
4 changes: 2 additions & 2 deletions hack/update_contributions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set -eu -o pipefail
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

echo >&2 'Installing pullsheet'
go install github.com/google/pullsheet@latest
GOBIN="$DIR" go install github.com/google/pullsheet@latest

git fetch --tags -f
git pull https://github.com/kubernetes/minikube.git master --tags
Expand Down Expand Up @@ -69,6 +69,6 @@ while read -r tag_index tag_name tag_start tag_end; do
# Print header for page.
printf -- "---\ntitle: \"$tag_name - $tag_end\"\nlinkTitle: \"$tag_name - $tag_end\"\nweight: $tag_index\n---\n" > "$destination/$tag_name.html"
# Add pullsheet content
pullsheet leaderboard --token-path "$TMP_TOKEN" --repos kubernetes/minikube --since "$tag_start" --until "$tag_end" --hide-command --logtostderr=false --stderrthreshold=2 \
"${DIR}/pullsheet" leaderboard --token-path "$TMP_TOKEN" --repos kubernetes/minikube --since "$tag_start" --until "$tag_end" --hide-command --logtostderr=false --stderrthreshold=2 \
>> "$destination/$tag_name.html"
done <<< "$tags_with_range"
50 changes: 50 additions & 0 deletions pkg/minikube/download/licenses.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Copyright 2022 The Kubernetes Authors All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package download

import (
"fmt"
"io"
"net/http"
"os"
"os/exec"

"k8s.io/minikube/pkg/version"
)

func Licenses(dir string) error {
resp, err := http.Get(fmt.Sprintf("https://storage.googleapis.com/minikube/releases/%s/licenses.tar.gz", version.GetVersion()))
if err != nil {
return fmt.Errorf("failed to download licenses: %v", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("download request did not return a 200, received: %d", resp.StatusCode)
}
f, err := os.CreateTemp("", "licenses")
if err != nil {
return fmt.Errorf("failed to create file in tmp dir: %v", err)
}
defer os.Remove(f.Name())
if _, err := io.Copy(f, resp.Body); err != nil {
return fmt.Errorf("failed to copy: %v", err)
}
if err := exec.Command("tar", "-xvzf", f.Name(), "-C", dir).Run(); err != nil {
return fmt.Errorf("failed to untar licenses: %v", err)
}
return nil
}
2 changes: 2 additions & 0 deletions pkg/minikube/reason/reason.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ var (
InetCacheKubectl = Kind{ID: "INET_CACHE_KUBECTL", ExitCode: ExInternetError}
// minikube failed to cache required images to tar files
InetCacheTar = Kind{ID: "INET_CACHE_TAR", ExitCode: ExInternetError}
// minikube failed to download licenses
InetLicenses = Kind{ID: "INET_LICENSES", ExitCode: ExInternetError}
// minikube was unable to access main repository and mirrors for images
InetRepo = Kind{ID: "INET_REPO", ExitCode: ExInternetError}
// minikube was unable to access any known image repositories
Expand Down
48 changes: 48 additions & 0 deletions site/content/en/docs/commands/license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: "license"
description: >
Outputs the licenses of dependencies to a directory
---


## minikube license

Outputs the licenses of dependencies to a directory

### Synopsis

Outputs the licenses of dependencies to a directory

```shell
minikube license [flags]
```

### Options

```
-d, --dir string Directory to output licenses to (default ".")
```

### Options inherited from parent commands

```
--add_dir_header If true, adds the file directory to the header of the log messages
--alsologtostderr log to standard error as well as files (no effect when -logtostderr=true)
-b, --bootstrapper string The name of the cluster bootstrapper that will set up the Kubernetes cluster. (default "kubeadm")
-h, --help
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
--log_dir string If non-empty, write log files in this directory (no effect when -logtostderr=true)
--log_file string If non-empty, use this log file (no effect when -logtostderr=true)
--log_file_max_size uint Defines the maximum size a log file can grow to (no effect when -logtostderr=true). Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--logtostderr log to standard error instead of files
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
--user string Specifies the user executing the operation. Useful for auditing operations executed by 3rd party tools. Defaults to the operating system username.
-v, --v Level number for the log level verbosity
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging
```

3 changes: 3 additions & 0 deletions site/content/en/docs/contrib/errorcodes.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ minikube failed to cache the kubectl binary
"INET_CACHE_TAR" (Exit code ExInternetError)
minikube failed to cache required images to tar files

"INET_LICENSES" (Exit code ExInternetError)
minikube failed to download licenses

"INET_REPO" (Exit code ExInternetError)
minikube was unable to access main repository and mirrors for images

Expand Down
2 changes: 1 addition & 1 deletion site/content/en/docs/contrib/releasing/binaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Run the `kic-release` job in Jenkins, which will automatically create a PR which
Run the following script from your local upstream repo copy to generate updated release notes:

```shell
hack/release_notes.sh
make release-notes
```

Paste the output into CHANGELOG.md, sorting changes by importance to an end-user. If there are >8 changes, split them into *Improvements* and *Bug fixes*
Expand Down
3 changes: 3 additions & 0 deletions translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
"Deleting container \"{{.name}}\" ...": "Lösche Container \"{{.name}}\" ...",
"Deleting existing cluster {{.name}} with different driver {{.driver_name}} due to --delete-on-failure flag set by the user. ": "Lösche den existierenden Cluster {{.name}} mit unterschiedlichem Treiber {{.driver_name}} aufgrund des vom Benutzer gesetzten --delete-on-failure Parameters. ",
"Deleting node {{.name}} from cluster {{.cluster}}": "Lösche Node {{.name}} von Cluster {{.cluster}}",
"Directory to output licenses to": "",
"Disable checking for the availability of hardware virtualization before the vm is started (virtualbox driver only)": "Deaktivieren Sie die Überprüfung der Verfügbarkeit der Hardwarevirtualisierung vor dem Starten der VM (nur Virtualbox-Treiber)",
"Disable dynamic memory in your VM manager, or pass in a larger --memory value": "Deaktiveren Sie die dynmaische Memory-Verwaltung in ihrem VM manager oder verwenden Sie einen größeren --memory Wert",
"Disables the addon w/ADDON_NAME within minikube (example: minikube addons disable dashboard). For a list of available addons use: minikube addons list ": "Deaktiviere das Addon mit dem Namen ADDON_NAME in Minikube (Beispiel: minikube addons disable dashboard). Um eine Liste aller verfügbaren Addons zu erhalten, führen Sie folgenden Befehl aus: minikube addons list ",
Expand Down Expand Up @@ -260,6 +261,7 @@
"Failed to delete cluster: {{.error}}__1": "Fehler beim Löschen des Clusters: {{.error}}",
"Failed to delete images": "Löschen der Images fehlgeschlagen",
"Failed to delete images from config": "Löschen der Images aus der Konfiguration fehlgeschlagen",
"Failed to download licenses": "",
"Failed to enable container runtime": "Aktivieren der Container Runtime fehlgeschlagen",
"Failed to get bootstrapper": "Fehler beim Ermitteln des Bootstrappers",
"Failed to get command runner": "Fehler beim Ermitteln des Command Runner",
Expand Down Expand Up @@ -459,6 +461,7 @@
"Output format. Accepted values: [json, yaml]": "",
"Output format. Accepted values: [json]": "Ausgabe Format. Akzeptierte Werte: [json]",
"Outputs minikube shell completion for the given shell (bash, zsh or fish)\n\n\tThis depends on the bash-completion binary. Example installation instructions:\n\tOS X:\n\t\t$ brew install bash-completion\n\t\t$ source $(brew --prefix)/etc/bash_completion\n\t\t$ minikube completion bash \u003e ~/.minikube-completion # for bash users\n\t\t$ minikube completion zsh \u003e ~/.minikube-completion # for zsh users\n\t\t$ source ~/.minikube-completion\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\tUbuntu:\n\t\t$ apt-get install bash-completion\n\t\t$ source /etc/bash_completion\n\t\t$ source \u003c(minikube completion bash) # for bash users\n\t\t$ source \u003c(minikube completion zsh) # for zsh users\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\n\tAdditionally, you may want to output the completion to a file and source in your .bashrc\n\n\tNote for zsh users: [1] zsh completions are only supported in versions of zsh \u003e= 5.2\n\tNote for fish users: [2] please refer to this docs for more details https://fishshell.com/docs/current/#tab-completion\n": "",
"Outputs the licenses of dependencies to a directory": "",
"Overwrite image even if same image:tag name exists": "Überschreibe das Image, auch wenn ein Image mit dem gleichen Image:Tag-Namen existiert",
"Path to socket vmnet binary": "",
"Path to the Dockerfile to use (optional)": "Pfad des zu verwendenden Dockerfiles (optional)",
Expand Down
3 changes: 3 additions & 0 deletions translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
"Deleting container \"{{.name}}\" ...": "Eliminando contenedor \"{{.name}}\" ...",
"Deleting existing cluster {{.name}} with different driver {{.driver_name}} due to --delete-on-failure flag set by the user. ": "",
"Deleting node {{.name}} from cluster {{.cluster}}": "Eliminando nodo {{.name}} del clúster {{.cluster}}",
"Directory to output licenses to": "",
"Disable checking for the availability of hardware virtualization before the vm is started (virtualbox driver only)": "Permite inhabilitar la comprobación de disponibilidad de la virtualización de hardware antes de iniciar la VM (solo con el controlador de Virtualbox)",
"Disable dynamic memory in your VM manager, or pass in a larger --memory value": "Desactivar memoria dinámica in tu administrador de VM, o pasa un mayor valor --memory",
"Disables the addon w/ADDON_NAME within minikube (example: minikube addons disable dashboard). For a list of available addons use: minikube addons list ": "Desactiva un complemento con ADDON_NAME dentro de minikube (Por ejemplo minikube addons disable dashboard). Para ver los complementos disponibles usa: minikube addons list",
Expand Down Expand Up @@ -269,6 +270,7 @@
"Failed to delete cluster: {{.error}}__1": "No se ha podido eliminar el clúster: {{.error}}",
"Failed to delete images": "No se pudo borrar las imagenes",
"Failed to delete images from config": "",
"Failed to download licenses": "",
"Failed to enable container runtime": "",
"Failed to get bootstrapper": "",
"Failed to get command runner": "",
Expand Down Expand Up @@ -466,6 +468,7 @@
"Options: {{.options}}": "",
"Output format. Accepted values: [json, yaml]": "",
"Outputs minikube shell completion for the given shell (bash, zsh or fish)\n\n\tThis depends on the bash-completion binary. Example installation instructions:\n\tOS X:\n\t\t$ brew install bash-completion\n\t\t$ source $(brew --prefix)/etc/bash_completion\n\t\t$ minikube completion bash \u003e ~/.minikube-completion # for bash users\n\t\t$ minikube completion zsh \u003e ~/.minikube-completion # for zsh users\n\t\t$ source ~/.minikube-completion\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\tUbuntu:\n\t\t$ apt-get install bash-completion\n\t\t$ source /etc/bash_completion\n\t\t$ source \u003c(minikube completion bash) # for bash users\n\t\t$ source \u003c(minikube completion zsh) # for zsh users\n\t\t$ minikube completion fish \u003e ~/.config/fish/completions/minikube.fish # for fish users\n\n\tAdditionally, you may want to output the completion to a file and source in your .bashrc\n\n\tNote for zsh users: [1] zsh completions are only supported in versions of zsh \u003e= 5.2\n\tNote for fish users: [2] please refer to this docs for more details https://fishshell.com/docs/current/#tab-completion\n": "",
"Outputs the licenses of dependencies to a directory": "",
"Overwrite image even if same image:tag name exists": "",
"Path to socket vmnet binary": "",
"Path to the Dockerfile to use (optional)": "",
Expand Down
Loading