Skip to content

Commit adc29a2

Browse files
authored
Merge pull request #774 from metadave/dp_report_bug
add an ark bug command
2 parents 8a5d6f9 + 342a1c6 commit adc29a2

File tree

9 files changed

+366
-1
lines changed

9 files changed

+366
-1
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ about: Tell us about a problem you are experiencing
2727

2828
**Environment:**
2929

30-
- Ark version (use `ark version`):
30+
- Ark version (use `ark version`):
3131
- Kubernetes version (use `kubectl version`):
3232
- Kubernetes installer & version:
3333
- Cloud provider or hardware configuration:

docs/cli-reference/ark.md

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ operations can also be performed as 'ark backup get' and 'ark schedule create'.
3131

3232
### SEE ALSO
3333
* [ark backup](ark_backup.md) - Work with backups
34+
* [ark bug](ark_bug.md) - Report an Ark bug
3435
* [ark client](ark_client.md) - Ark client related commands
3536
* [ark completion](ark_completion.md) - Output shell completion code for the specified shell (bash or zsh)
3637
* [ark create](ark_create.md) - Create ark resources

docs/cli-reference/ark_bug.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## ark bug
2+
3+
Report an Ark bug
4+
5+
### Synopsis
6+
7+
8+
Open a browser window to report an Ark bug
9+
10+
```
11+
ark bug [flags]
12+
```
13+
14+
### Options
15+
16+
```
17+
-h, --help help for bug
18+
```
19+
20+
### Options inherited from parent commands
21+
22+
```
23+
--alsologtostderr log to standard error as well as files
24+
--kubeconfig string Path to the kubeconfig file to use to talk to the Kubernetes apiserver. If unset, try the environment variable KUBECONFIG, as well as in-cluster configuration
25+
--kubecontext string The context to use to talk to the Kubernetes apiserver. If unset defaults to whatever your current-context is (kubectl config current-context)
26+
--log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0)
27+
--log_dir string If non-empty, write log files in this directory
28+
--logtostderr log to standard error instead of files
29+
-n, --namespace string The namespace in which Ark should operate (default "heptio-ark")
30+
--stderrthreshold severity logs at or above this threshold go to stderr (default 2)
31+
-v, --v Level log level for V logs
32+
--vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging
33+
```
34+
35+
### SEE ALSO
36+
* [ark](ark.md) - Back up and restore Kubernetes cluster resources.
37+

docs/issue-template-gen/main.go

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Copyright 2018 the Heptio Ark contributors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// This code renders the IssueTemplate string in pkg/cmd/cli/bug/bug.go to
18+
// .github/ISSUE_TEMPLATE/bug_report.md via the hack/update-generated-issue-template.sh script.
19+
20+
package main
21+
22+
import (
23+
"log"
24+
"os"
25+
"text/template"
26+
27+
"github.com/heptio/ark/pkg/cmd/cli/bug"
28+
)
29+
30+
func main() {
31+
outTemplateFilename := os.Args[1]
32+
outFile, err := os.OpenFile(outTemplateFilename, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
33+
if err != nil {
34+
log.Fatal(err)
35+
}
36+
defer outFile.Close()
37+
tmpl, err := template.New("ghissue").Parse(bug.IssueTemplate)
38+
if err != nil {
39+
log.Fatal(err)
40+
}
41+
err = tmpl.Execute(outFile, bug.ArkBugInfo{})
42+
if err != nil {
43+
log.Fatal(err)
44+
}
45+
}

docs/troubleshooting.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
These tips can help you troubleshoot known issues. If they don't help, you can [file an issue][4], or talk to us on the [#ark-dr channel][25] on the Kubernetes Slack server.
44

5+
In `ark` version >= `0.1.0`, you can use the `ark bug` command to open a [Github issue][4] by launching a browser window with some prepopulated values. Values included are OS, CPU architecture, `kubectl` client and server versions (if available) and the `ark` client version. This information isn't submitted to Github until you click the `Submit new issue` button in the Github UI, so feel free to add, remove or update whatever information you like.
6+
57
Some general commands for troubleshooting that may be helpful:
68

79
* `ark backup describe <backupName>` - describe the details of a backup
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash -e
2+
#
3+
# Copyright 2018 the Heptio Ark contributors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
ARK_ROOT=$(dirname ${BASH_SOURCE})/..
18+
BIN=${ARK_ROOT}/_output/bin
19+
20+
mkdir -p ${BIN}
21+
22+
echo "Updating generated Github issue template"
23+
go build -o ${BIN}/issue-tmpl-gen ./docs/issue-template-gen/main.go
24+
25+
if [[ $# -gt 1 ]]; then
26+
echo "usage: ${BASH_SOURCE} [OUTPUT_FILE]"
27+
exit 1
28+
fi
29+
30+
OUTPUT_ISSUE_FILE="$1"
31+
if [[ -z "${OUTPUT_ISSUE_FILE}" ]]; then
32+
OUTPUT_ISSUE_FILE=${ARK_ROOT}/.github/ISSUE_TEMPLATE/bug_report.md
33+
fi
34+
35+
${BIN}/issue-tmpl-gen ${OUTPUT_ISSUE_FILE}
36+
echo "Success!"
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash -e
2+
#
3+
# Copyright 2018 the Heptio Ark contributors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
ARK_ROOT=$(dirname ${BASH_SOURCE})/..
18+
HACK_DIR=$(dirname "${BASH_SOURCE}")
19+
ISSUE_TEMPLATE_FILE=${ARK_ROOT}/.github/ISSUE_TEMPLATE/bug_report.md
20+
OUT_TMP_FILE="$(mktemp -d)"/bug_report.md
21+
22+
23+
trap cleanup INT TERM HUP EXIT
24+
25+
cleanup() {
26+
rm -rf ${TMP_DIR}
27+
}
28+
29+
echo "Verifying generated Github issue template"
30+
${HACK_DIR}/update-generated-issue-template.sh ${OUT_TMP_FILE} > /dev/null
31+
output=$(echo "`diff ${ISSUE_TEMPLATE_FILE} ${OUT_TMP_FILE}`")
32+
33+
if [[ -n "${output}" ]] ; then
34+
echo "FAILURE: verification of generated template failed:"
35+
echo "${output}"
36+
exit 1
37+
fi
38+
39+
echo "Success!"

pkg/cmd/ark/ark.go

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"github.com/heptio/ark/pkg/client"
2525
"github.com/heptio/ark/pkg/cmd/cli/backup"
26+
"github.com/heptio/ark/pkg/cmd/cli/bug"
2627
cliclient "github.com/heptio/ark/pkg/cmd/cli/client"
2728
"github.com/heptio/ark/pkg/cmd/cli/completion"
2829
"github.com/heptio/ark/pkg/cmd/cli/create"
@@ -69,6 +70,7 @@ operations can also be performed as 'ark backup get' and 'ark schedule create'.`
6970
cliclient.NewCommand(),
7071
completion.NewCommand(),
7172
restic.NewCommand(f),
73+
bug.NewCommand(),
7274
)
7375

7476
// add the glog flags

0 commit comments

Comments
 (0)