Skip to content

Commit 37a5cce

Browse files
authored
chore: minor updates to docs and Makefile (#1433)
* Deprecate old Makefile targets * Name Makefile targets to point to files they 'make' as per convention * Update the contributing doc * Update CLI docs left behind
1 parent 80de5e3 commit 37a5cce

10 files changed

+84
-51
lines changed

.golangci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ linters:
1010
- gocyclo
1111
- gofmt
1212
- gosec
13+
- govet

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ To get started we recommend:
2323

2424
1. Go (v1.20 or later)
2525
2. A Kubernetes cluster (we recommend <https://k3d.io/>. This requires Docker v20.10.5 or later)
26-
3. Fork and clone the repo to $GOPATH/src/github.com/replicatedhq/
27-
4. Run `make support-bundle preflight` to generate binaries
28-
5. Run `make run-troubleshoot` to generate a support bundle with the `sample-troubleshoot.yaml` in the root of the repo
26+
3. Fork and clone repo
27+
4. Run `make clean build` to generate binaries
28+
5. Run `make run-support-bundle` to generate a support bundle with the `sample-troubleshoot.yaml` in the root of the repo
2929

3030
> Note: recent versions of Go support easy cross-compilation. For example, to cross-compile a Linux binary from MacOS:
31-
> `GOOS=linux GOARCH=amd64 make support-bundle preflight`
31+
> `GOOS=linux GOARCH=amd64 make clean build`
3232
3333
6. Install [golangci-lint] linter and run `make lint` to execute additional code linters.
3434

Makefile

Lines changed: 68 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ BUILDPATHS = ./pkg/... ./cmd/... ./internal/...
3939
E2EPATHS = ./test/e2e/...
4040
TESTFLAGS ?= -v -coverprofile cover.out
4141

42-
.DEFAULT: all
43-
all: test build
42+
.DEFAULT_GOAL := all
43+
all: build test
4444

4545
.PHONY: ffi
4646
ffi: fmt vet
@@ -81,27 +81,35 @@ support-bundle-e2e-go-test:
8181
fi
8282

8383
# Build all binaries in parallel ( -j )
84-
build:
84+
build: tidy
8585
@echo "Build cli binaries"
86-
$(MAKE) -j support-bundle preflight analyze collect
87-
88-
mod-tidy:
86+
$(MAKE) -j bin/support-bundle bin/preflight bin/analyze bin/collect
87+
88+
.PHONY: clean
89+
clean:
90+
@rm -f bin/analyze
91+
@rm -f bin/support-bundle
92+
@rm -f bin/collect
93+
@rm -f bin/preflight
94+
@rm -f bin/troubleshoot.h
95+
@rm -f bin/troubleshoot.so
96+
@rm -f bin/schemagen
97+
@rm -f bin/docsgen
98+
99+
.PHONY: tidy
100+
tidy:
89101
go mod tidy
90102

91-
.PHONY: support-bundle
92-
support-bundle:
103+
bin/support-bundle:
93104
go build ${BUILDFLAGS} ${LDFLAGS} -o bin/support-bundle github.com/replicatedhq/troubleshoot/cmd/troubleshoot
94105

95-
.PHONY: preflight
96-
preflight:
106+
bin/preflight:
97107
go build ${BUILDFLAGS} ${LDFLAGS} -o bin/preflight github.com/replicatedhq/troubleshoot/cmd/preflight
98108

99-
.PHONY: analyze
100-
analyze:
109+
bin/analyze:
101110
go build ${BUILDFLAGS} ${LDFLAGS} -o bin/analyze github.com/replicatedhq/troubleshoot/cmd/analyze
102111

103-
.PHONY: collect
104-
collect:
112+
bin/collect:
105113
go build ${BUILDFLAGS} ${LDFLAGS} -o bin/collect github.com/replicatedhq/troubleshoot/cmd/collect
106114

107115
.PHONY: fmt
@@ -138,15 +146,19 @@ check-schemas: generate schemas
138146
fi
139147

140148
.PHONY: schemas
141-
schemas: fmt vet openapischema
142-
go build ${LDFLAGS} -o bin/schemagen github.com/replicatedhq/troubleshoot/cmd/schemagen
149+
schemas: fmt vet openapischema bin/schemagen
143150
./bin/schemagen --output-dir ./schemas
144151

152+
bin/schemagen:
153+
go build ${LDFLAGS} -o bin/schemagen github.com/replicatedhq/troubleshoot/cmd/schemagen
154+
145155
.PHONY: docs
146-
docs: fmt vet
147-
go build ${LDFLAGS} -o bin/docsgen github.com/replicatedhq/troubleshoot/cmd/docsgen
156+
docs: fmt vet bin/docsgen
148157
./bin/docsgen
149158

159+
bin/docsgen:
160+
go build ${LDFLAGS} -o bin/docsgen github.com/replicatedhq/troubleshoot/cmd/docsgen
161+
150162
controller-gen:
151163
go install sigs.k8s.io/controller-tools/cmd/[email protected]
152164
CONTROLLER_GEN=$(shell which controller-gen)
@@ -180,15 +192,15 @@ local-release:
180192
docker push localhost:32000/preflight:alpha
181193

182194
.PHONY: run-preflight
183-
run-preflight: preflight
195+
run-preflight: bin/preflight
184196
./bin/preflight ./examples/preflight/sample-preflight.yaml
185197

186-
.PHONY: run-troubleshoot
187-
run-troubleshoot: support-bundle
198+
.PHONY: run-support-bundle
199+
run-support-bundle: bin/support-bundle
188200
./bin/support-bundle ./examples/support-bundle/sample-supportbundle.yaml
189201

190202
.PHONY: run-analyze
191-
run-analyze: analyze
203+
run-analyze: bin/analyze
192204
./bin/analyze --analyzers ./examples/support-bundle/sample-analyzers.yaml ./support-bundle.tar.gz
193205

194206
.PHONY: init-sbom
@@ -212,20 +224,6 @@ sbom: sbom/assets/troubleshoot-sbom.tgz
212224
cosign sign-blob -key cosign.key sbom/assets/troubleshoot-sbom.tgz > sbom/assets/troubleshoot-sbom.tgz.sig
213225
cosign public-key -key cosign.key -outfile sbom/assets/key.pub
214226

215-
longhorn:
216-
git clone https://github.com/longhorn/longhorn-manager.git
217-
cd longhorn-manager && git checkout v1.2.2 && cd ..
218-
rm -rf pkg/longhorn
219-
mv longhorn-manager/k8s/pkg pkg/longhorn
220-
mv longhorn-manager/types pkg/longhorn/types
221-
mv longhorn-manager/util pkg/longhorn/util
222-
rm -rf pkg/longhorn/util/daemon
223-
rm -rf pkg/longhorn/util/server
224-
find pkg/longhorn -type f | xargs sed -i "s/github.com\/longhorn\/longhorn-manager\/k8s\/pkg/github.com\/replicatedhq\/troubleshoot\/pkg\/longhorn/g"
225-
find pkg/longhorn -type f | xargs sed -i "s/github.com\/longhorn\/longhorn-manager\/types/github.com\/replicatedhq\/troubleshoot\/pkg\/longhorn\/types/g"
226-
find pkg/longhorn -type f | xargs sed -i "s/github.com\/longhorn\/longhorn-manager\/util/github.com\/replicatedhq\/troubleshoot\/pkg\/longhorn\/util/g"
227-
rm -rf longhorn-manager
228-
229227
.PHONY: scan
230228
scan:
231229
trivy fs \
@@ -236,11 +234,11 @@ scan:
236234
./
237235

238236
.PHONY: lint
239-
lint: fmt vet
237+
lint:
240238
golangci-lint run --new -c .golangci.yaml ${BUILDPATHS}
241239

242240
.PHONY: lint-and-fix
243-
lint-and-fix: fmt vet
241+
lint-and-fix:
244242
golangci-lint run --new --fix -c .golangci.yaml ${BUILDPATHS}
245243

246244
.PHONY: watch
@@ -256,3 +254,35 @@ watchrsync: npm-install
256254
npm-install:
257255
npm --version 2>&1 >/dev/null || ( echo "npm not installed; install npm to set up watchrsync" && exit 1 )
258256
npm list gaze-run-interrupt || npm install install --no-save gaze-run-interrupt@~2.0.0
257+
258+
259+
######## Lagacy make targets ###########
260+
# Deprecated: These can be removed
261+
.PHONY: support-bundle
262+
support-bundle: clean bin/support-bundle
263+
264+
.PHONY: preflight
265+
preflight: clean bin/preflight
266+
267+
.PHONY: analyze
268+
analyze: clean bin/analyze
269+
270+
.PHONY: collect
271+
collect: clean bin/collect
272+
273+
.PHONY: run-troubleshoot
274+
run-troubleshoot: run-support-bundle
275+
276+
longhorn:
277+
git clone https://github.com/longhorn/longhorn-manager.git
278+
cd longhorn-manager && git checkout v1.2.2 && cd ..
279+
rm -rf pkg/longhorn
280+
mv longhorn-manager/k8s/pkg pkg/longhorn
281+
mv longhorn-manager/types pkg/longhorn/types
282+
mv longhorn-manager/util pkg/longhorn/util
283+
rm -rf pkg/longhorn/util/daemon
284+
rm -rf pkg/longhorn/util/server
285+
find pkg/longhorn -type f | xargs sed -i "s/github.com\/longhorn\/longhorn-manager\/k8s\/pkg/github.com\/replicatedhq\/troubleshoot\/pkg\/longhorn/g"
286+
find pkg/longhorn -type f | xargs sed -i "s/github.com\/longhorn\/longhorn-manager\/types/github.com\/replicatedhq\/troubleshoot\/pkg\/longhorn\/types/g"
287+
find pkg/longhorn -type f | xargs sed -i "s/github.com\/longhorn\/longhorn-manager\/util/github.com\/replicatedhq\/troubleshoot\/pkg\/longhorn\/util/g"
288+
rm -rf longhorn-manager

docs/preflight.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ preflight [url] [flags]
5454
* [preflight oci-fetch](preflight_oci-fetch.md) - Fetch a preflight from an OCI registry and print it to standard out
5555
* [preflight version](preflight_version.md) - Print the current version and exit
5656

57-
###### Auto generated by spf13/cobra on 31-Aug-2023
57+
###### Auto generated by spf13/cobra on 25-Jan-2024

docs/preflight_oci-fetch.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ preflight oci-fetch [URI] [flags]
99
### Options
1010

1111
```
12-
-h, --help help for oci-fetch
12+
-h, --help help for oci-fetch
13+
-v, --v Level number for the log level verbosity
1314
```
1415

1516
### Options inherited from parent commands
@@ -33,4 +34,4 @@ preflight oci-fetch [URI] [flags]
3334

3435
* [preflight](preflight.md) - Run and retrieve preflight checks in a cluster
3536

36-
###### Auto generated by spf13/cobra on 31-Aug-2023
37+
###### Auto generated by spf13/cobra on 25-Jan-2024

docs/preflight_version.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ preflight version [flags]
3737

3838
* [preflight](preflight.md) - Run and retrieve preflight checks in a cluster
3939

40-
###### Auto generated by spf13/cobra on 31-Aug-2023
40+
###### Auto generated by spf13/cobra on 25-Jan-2024

docs/support-bundle.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ support-bundle [urls...] [flags]
2727
--cpuprofile string File path to write cpu profiling data
2828
--debug enable debug logging. This is equivalent to --v=0
2929
--disable-compression If true, opt-out of response compression for all requests to the server
30+
--dry-run print support bundle spec without collecting anything
3031
-h, --help help for support-bundle
3132
--insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
3233
--interactive enable/disable interactive mode (default true)
3334
--kubeconfig string Path to the kubeconfig file to use for CLI requests.
3435
--load-cluster-specs enable/disable loading additional troubleshoot specs found within the cluster. required when no specs are provided on the command line
3536
--memprofile string File path to write memory profiling data
3637
-n, --namespace string If present, the namespace scope for this CLI request
37-
--no-uri When this flag is used, Troubleshoot does not attempt to retrieve the bundle referenced by the uri: field in the spec.`
38+
--no-uri When this flag is used, Troubleshoot does not attempt to retrieve the spec referenced by the uri: field`
3839
-o, --output string specify the output file path for the support bundle
3940
--redact enable/disable default redactions (default true)
4041
--redactors strings names of the additional redactors to use
@@ -55,4 +56,4 @@ support-bundle [urls...] [flags]
5556
* [support-bundle redact](support-bundle_redact.md) - Redact information from a generated support bundle archive
5657
* [support-bundle version](support-bundle_version.md) - Print the current version and exit
5758

58-
###### Auto generated by spf13/cobra on 31-Aug-2023
59+
###### Auto generated by spf13/cobra on 25-Jan-2024

docs/support-bundle_analyze.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ support-bundle analyze [url] [flags]
3030

3131
* [support-bundle](support-bundle.md) - Generate a support bundle
3232

33-
###### Auto generated by spf13/cobra on 31-Aug-2023
33+
###### Auto generated by spf13/cobra on 25-Jan-2024

docs/support-bundle_redact.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ support-bundle redact [urls...] [flags]
3939

4040
* [support-bundle](support-bundle.md) - Generate a support bundle
4141

42-
###### Auto generated by spf13/cobra on 31-Aug-2023
42+
###### Auto generated by spf13/cobra on 25-Jan-2024

docs/support-bundle_version.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ support-bundle version [flags]
2727

2828
* [support-bundle](support-bundle.md) - Generate a support bundle
2929

30-
###### Auto generated by spf13/cobra on 31-Aug-2023
30+
###### Auto generated by spf13/cobra on 25-Jan-2024

0 commit comments

Comments
 (0)