Skip to content

Commit 970caee

Browse files
authored
Merge pull request #147 from BlaineEXE/prow-check-generate
implement script to check generated files in prow
2 parents ac495ca + fb9f7a6 commit 970caee

File tree

13 files changed

+70
-36
lines changed

13 files changed

+70
-36
lines changed

Makefile

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,22 @@ SIDECAR_TAG ?= cosi-provisioner-sidecar:latest
4848
##@ Development
4949

5050
.PHONY: generate
51-
generate: controller-gen controller/Dockerfile sidecar/Dockerfile ## Generate files
51+
generate: crds controller/Dockerfile sidecar/Dockerfile ## Generate files
52+
53+
.PHONY: crds
54+
crds: controller-gen
5255
cd ./client && $(CONTROLLER_GEN) rbac:roleName=manager-role crd paths="./apis/objectstorage/..."
53-
# $(MAKE) -C client crds
54-
$(MAKE) -C proto generate
5556

5657
%/Dockerfile: hack/Dockerfile.in hack/gen-dockerfile.sh
5758
hack/gen-dockerfile.sh $* > "$@"
5859

5960
.PHONY: codegen
60-
codegen: controller-gen ## Generate code
61+
codegen: codegen.client codegen.proto ## Generate code
62+
63+
.PHONY: codegen.client codegen.proto
64+
codegen.client: controller-gen
6165
cd ./client && $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./apis/objectstorage/..."
66+
codegen.proto:
6267
$(MAKE) -C proto codegen
6368

6469
.PHONY: fmt
@@ -97,12 +102,24 @@ lint-fix: golangci-lint-fix.client golangci-lint-fix.controller golangci-lint-fi
97102
golangci-lint-fix.%: golangci-lint
98103
cd $* && $(GOLANGCI_LINT) run $(GOLANGCI_LINT_RUN_OPTS) --config $(CURDIR)/.golangci.yaml --new --fix
99104

105+
.PHONY: vendor
106+
vendor: tidy.client tidy.proto ## Update go vendor dir
107+
go mod tidy
108+
go mod vendor
109+
tidy.%: FORCE
110+
cd $* && go mod tidy
111+
100112
##@ Build
101113

102-
.PHONY: all .gen
114+
.PHONY: all
115+
.NOTPARALLEL: all # all generators must run before build
116+
all: prebuild build ## Build all container images, plus their prerequisites (faster with 'make -j')
117+
118+
.PHONY: prebuild .gen .doc-vendor
103119
.gen: generate codegen # can be done in parallel with 'make -j'
104-
.NOTPARALLEL: all # codegen must be finished before fmt/vet
105-
all: .gen fmt vet build ## Build all container images, plus their prerequisites (faster with 'make -j')
120+
.doc-vendor: build-docs vendor # can be done in parallel
121+
.NOTPARALLEL: prebuild # codegen must be finished before fmt
122+
prebuild: .gen fmt .doc-vendor ## Run all pre-build prerequisite steps (faster with 'make -j')
106123

107124
.PHONY: build
108125
build: build.controller build.sidecar ## Build container images without prerequisites
@@ -115,7 +132,6 @@ build.sidecar: sidecar/Dockerfile ## Build only the sidecar container image
115132

116133
.PHONY: build-docs
117134
build-docs: generate crd-ref-docs mdbook
118-
@echo "build-docs is temporarily disabled for v1alpha2 development"
119135
$(CRD_REF_DOCS) \
120136
--config=./docs/.crd-ref-docs.yaml \
121137
--source-path=./client/apis \
@@ -180,7 +196,7 @@ SPELL_LINT ?= $(TOOLBIN)/spell-lint
180196
# Tool Versions
181197
CHAINSAW_VERSION ?= v0.2.12
182198
CONTROLLER_TOOLS_VERSION ?= v0.19.0
183-
CRD_REF_DOCS_VERSION ?= v0.1.0
199+
CRD_REF_DOCS_VERSION ?= v0.2.0
184200
CTLPTL_VERSION ?= v0.8.39
185201
GOLANGCI_LINT_VERSION ?= v1.64.7
186202
KIND_VERSION ?= v0.27.0

docs/src/api/out.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ _Appears in:_
137137

138138
| Field | Description | Default | Validation |
139139
| --- | --- | --- | --- |
140-
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#condition-v1-meta) array_ | conditions represent the current state of the BucketAccessClass resource.<br />Each condition has a unique type and reflects the status of a specific aspect of the resource.<br /><br />Standard condition types include:<br />- "Available": the resource is fully functional<br />- "Progressing": the resource is being created or updated<br />- "Degraded": the resource failed to reach or maintain its desired state<br /><br />The status of each condition is one of True, False, or Unknown. | | |
140+
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#condition-v1-meta) array_ | conditions represent the current state of the BucketAccessClass resource.<br />Each condition has a unique type and reflects the status of a specific aspect of the resource.<br />Standard condition types include:<br />- "Available": the resource is fully functional<br />- "Progressing": the resource is being created or updated<br />- "Degraded": the resource failed to reach or maintain its desired state<br />The status of each condition is one of True, False, or Unknown. | | |
141141

142142

143143
#### BucketAccessList
@@ -189,7 +189,7 @@ _Appears in:_
189189

190190
| Field | Description | Default | Validation |
191191
| --- | --- | --- | --- |
192-
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#condition-v1-meta) array_ | conditions represent the current state of the BucketAccess resource.<br />Each condition has a unique type and reflects the status of a specific aspect of the resource.<br /><br />Standard condition types include:<br />- "Available": the resource is fully functional<br />- "Progressing": the resource is being created or updated<br />- "Degraded": the resource failed to reach or maintain its desired state<br /><br />The status of each condition is one of True, False, or Unknown. | | |
192+
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#condition-v1-meta) array_ | conditions represent the current state of the BucketAccess resource.<br />Each condition has a unique type and reflects the status of a specific aspect of the resource.<br />Standard condition types include:<br />- "Available": the resource is fully functional<br />- "Progressing": the resource is being created or updated<br />- "Degraded": the resource failed to reach or maintain its desired state<br />The status of each condition is one of True, False, or Unknown. | | |
193193

194194

195195
#### BucketClaim
@@ -263,7 +263,7 @@ _Appears in:_
263263

264264
| Field | Description | Default | Validation |
265265
| --- | --- | --- | --- |
266-
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#condition-v1-meta) array_ | conditions represent the current state of the BucketClaim resource.<br />Each condition has a unique type and reflects the status of a specific aspect of the resource.<br /><br />Standard condition types include:<br />- "Available": the resource is fully functional<br />- "Progressing": the resource is being created or updated<br />- "Degraded": the resource failed to reach or maintain its desired state<br /><br />The status of each condition is one of True, False, or Unknown. | | |
266+
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#condition-v1-meta) array_ | conditions represent the current state of the BucketClaim resource.<br />Each condition has a unique type and reflects the status of a specific aspect of the resource.<br />Standard condition types include:<br />- "Available": the resource is fully functional<br />- "Progressing": the resource is being created or updated<br />- "Degraded": the resource failed to reach or maintain its desired state<br />The status of each condition is one of True, False, or Unknown. | | |
267267

268268

269269
#### BucketClass
@@ -337,7 +337,7 @@ _Appears in:_
337337

338338
| Field | Description | Default | Validation |
339339
| --- | --- | --- | --- |
340-
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#condition-v1-meta) array_ | conditions represent the current state of the BucketClass resource.<br />Each condition has a unique type and reflects the status of a specific aspect of the resource.<br /><br />Standard condition types include:<br />- "Available": the resource is fully functional<br />- "Progressing": the resource is being created or updated<br />- "Degraded": the resource failed to reach or maintain its desired state<br /><br />The status of each condition is one of True, False, or Unknown. | | |
340+
| `conditions` _[Condition](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.34/#condition-v1-meta) array_ | conditions represent the current state of the BucketClass resource.<br />Each condition has a unique type and reflects the status of a specific aspect of the resource.<br />Standard condition types include:<br />- "Available": the resource is fully functional<br />- "Progressing": the resource is being created or updated<br />- "Degraded": the resource failed to reach or maintain its desired state<br />The status of each condition is one of True, False, or Unknown. | | |
341341

342342

343343
#### BucketList

docs/theme/index-template.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@
189189
});
190190
</script>
191191

192+
<div id="version" class="version">VERSION-PLACEHOLDER</div>
192193
<div id="content" class="content">
193194
<main>
194195
{{{ content }}}

hack/prow-check-generate.sh

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,32 @@ set -o errexit
33
set -o nounset
44
set -o xtrace
55

6-
# TODO: make fmt generate codegen
7-
# TODO: check git for file changes
8-
echo "intentionally running no commands"
6+
generate_cmd="make prebuild"
7+
$generate_cmd
8+
9+
git="git --no-pager"
10+
11+
# if a developer is having trouble with any generator on their local system, git diff output
12+
# can give a fallback mechanism for applying necessary changes
13+
$git diff
14+
15+
# if there are generated changes, status output (with human-readable newlines) could be helpful
16+
status_cmd="$git status --porcelain"
17+
$status_cmd
18+
19+
{ set +o xtrace; } 2>/dev/null # helpful "pretty" output below is more legible without xtrace output
20+
21+
s="$($status_cmd)"
22+
if [[ -n "$s" ]]; then
23+
cat <<EOF >/dev/stderr
24+
25+
==============================================================================
26+
27+
Generated file changes are missing. Run '$generate_cmd'"
28+
29+
==============================================================================
30+
31+
EOF
32+
33+
exit 1
34+
fi

hack/tools/install-mdbook.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,11 @@ trap 'rm -rf "$TEMP"' EXIT
5656

5757
cd "${TEMP}"
5858

59-
TEMPLATE='<div id="version" class="version">\n VERSION-PLACEHOLDER\n</div>'
59+
TEMPLATE='<div id="version" class="version">VERSION-PLACEHOLDER</div>'
6060

6161
"${MDBOOK}" init --theme --title "template" --ignore "none"
6262

63-
cp theme/index.hbs "${CURDIR}/docs/theme/index-template.hbs"
64-
sed -i "/<div id=\"content\" class=\"content\">/i ${TEMPLATE}" "${CURDIR}/docs/theme/index-template.hbs"
65-
63+
sed -e "/<div id=\"content\" class=\"content\">/i\\
64+
${TEMPLATE}" theme/index.hbs > "${CURDIR}/docs/theme/index-template.hbs"
6665

6766
echo "$("${MDBOOK}" --version) installed successfully!"

proto/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,6 @@ help: ## Display this help.
129129

130130
##@ Development
131131

132-
.PHONY: generate
133-
generate: $(COSI_PROTO) ## Generate cosi.proto
134-
135132
.PHONY: codegen
136133
codegen: $(COSI_GO) $(COSI_GO_GRPC) $(COSI_GO_JSON) $(COSI_GO_FAKE) ## Generate protobuf files
137134

proto/cosi.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/cosi.proto

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ message ObjectProtocol {
130130
Type type = 1;
131131
}
132132

133-
134133
message S3BucketInfo {
135134
// S3 endpoint URL.
136135
string endpoint = 1;
@@ -141,7 +140,7 @@ message S3BucketInfo {
141140
// Geographical region where the S3 server is running.
142141
string region = 3;
143142

144-
// sS3 signature version for signing all S3 requests.
143+
// S3 signature version for signing all S3 requests.
145144
S3SignatureVersion signature_version = 4;
146145
}
147146

proto/spec.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ message S3BucketInfo {
286286
// Geographical region where the S3 server is running.
287287
string region = 3;
288288
289-
// sS3 signature version for signing all s3 requests.
289+
// S3 signature version for signing all S3 requests.
290290
S3SignatureVersion signature_version = 4;
291291
}
292292
@@ -298,7 +298,7 @@ message S3AccessInfo {
298298
string access_secret_key = 2;
299299
}
300300
301-
// S3SignatureVersion is the version of the signing algorithm for all s3 requests
301+
// S3SignatureVersion is the version of the signing algorithm for all S3 requests
302302
message S3SignatureVersion {
303303
enum Version {
304304
UNKNOWN = 0;

vendor/sigs.k8s.io/container-object-storage-interface/proto/Makefile

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)