Skip to content

Commit ea4be4c

Browse files
authored
Publish json-schema (#867)
* Adds java-language-server; * Re-structure layout of file-names; * Adapt references to schema-files; * Fixes; * Fix missing cleanup-command; * Add script to flatten schemas; * Update development-environment; * Remove unnecessary file; * Add the binding-request-schema as an output; * 🔧 Fix issue with double `/` in file-path; * 🚧 Work in progress: Debugging; * Unset focus;
1 parent 46b3216 commit ea4be4c

25 files changed

+202
-124
lines changed

.editorconfig

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@ trim_trailing_whitespace = true
99
indent_style = space
1010
indent_size = 2
1111

12+
[{*.bash,*.sh}]
13+
indent_style = tab
14+
indent_size = 2
15+
softtabstop = 2
16+
17+
[Dockerfile]
18+
indent_size = 4
19+
indent_style = tab
20+
1221
[{Makefile,go.mod,go.sum,*.go,.gitmodules}]
1322
indent_style = tab
1423
indent_size = 4
1524

1625
[*.md]
1726
indent_size = 4
1827
trim_trailing_whitespace = false
19-
2028
eclint_indent_style = unset
2129

22-
[Dockerfile]
30+
[*.py]
2331
indent_size = 4
24-
indent_style = tab
25-
26-
[{*.bash,*.sh}]
27-
indent_style = tab
28-
indent_size = 2
29-
softtabstop = 2
30-
31-
32+
indent_style = space

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ aes_terminal_font_yellow := \033[38;2;255;255;0m
55
aes_terminal_reset := \033[0m
66
VERSION ?= 0.0.0-rc.1
77
DEST ?= /tmp/build
8+
TARGET_DIR ?= ./build
89
MTAR_FILENAME ?= app-autoscaler-release-v$(VERSION).mtar
910
ACCEPTANCE_TESTS_FILE ?= ${DEST}/app-autoscaler-acceptance-tests-v$(VERSION).tgz
1011
CI ?= false
@@ -199,7 +200,7 @@ ${gorouter-proxy.program}: ./go.mod ./go.sum ${gorouter-proxy.source}
199200
.PHONY: integration
200201
integration: generate-fakes init-db test-certs build_all build-gorouterproxy
201202
@echo "# Running integration tests"
202-
APP_AUTOSCALER_TEST_RUN='true' DBURL='${DBURL}' go run github.com/onsi/ginkgo/v2/ginkgo ${GINKGO_OPTS} integration DBURL="${DBURL}"
203+
APP_AUTOSCALER_TEST_RUN='true' DBURL='${DBURL}' ginkgo ${GINKGO_OPTS} integration DBURL="${DBURL}"
203204

204205
.PHONY: init-db
205206
init-db: check-db_type start-db db.java-libs target/init-db-${db_type}
@@ -249,6 +250,7 @@ clean: dbtasks.clean scheduler.clean
249250
@rm --force --recursive "${openapi-generated-clients-and-servers-api-dir}"
250251
@rm --force --recursive "${openapi-generated-clients-and-servers-scalingengine-dir}"
251252
@go clean -cache -testcache
253+
@rm --force --recursive 'build'
252254
@rm --force --recursive 'fakes'
253255
@rm --force --recursive 'test-certs'
254256
@rm --force --recursive 'target'
@@ -260,6 +262,16 @@ dbtasks.clean:
260262
scheduler.clean:
261263
pushd scheduler; mvn clean; popd
262264

265+
schema-files := $(shell find ./api/policyvalidator -type f -name '*.json')
266+
flattened-schema-file := ${TARGET_DIR}/bind-request.schema.json
267+
BIND_REQ_SCHEMA_VERSION ?= v0.1
268+
bind-request-schema: ${flattened-schema-file}
269+
${flattened-schema-file}: ${schema-files}
270+
mkdir -p "$$(dirname ${flattened-schema-file})"
271+
flatten_json-schema './api/policyvalidator/json-schema/${BIND_REQ_SCHEMA_VERSION}/meta.schema.json' \
272+
> '${flattened-schema-file}'
273+
echo '🔨 File created: ${flattened-schema-file}'
274+
263275
mta-deploy: mta-build build-extension-file
264276
$(MAKE) -f metricsforwarder/Makefile set-security-group
265277
@echo "Deploying with extension file: $(EXTENSION_FILE)"
@@ -301,7 +313,7 @@ release-draft: ## Create a draft GitHub release without artifacts
301313
./scripts/release.sh
302314

303315
.PHONY: create-assets
304-
create-assets: ## Create release assets (mtar and acceptance tests)
316+
create-assets: ## Create release assets (mtar and acceptance tests), please provide `VERSION` as environment-variable.
305317
./scripts/create-assets.sh
306318

307319
.PHONY: release-promote

acceptance/broker/broker_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,12 @@ var _ = Describe("AutoScaler Service Broker", func() {
272272

273273
It("fails", func() {
274274
// Preparation
275-
paramsTemplate := `
276-
{
277-
"schema-version": "0.1",
278-
"configuration": {
279-
"app_guid": "%s"
280-
}
281-
}
282-
`
275+
paramsTemplate := `{
276+
"schema-version": "0.1",
277+
"configuration": {
278+
"app_guid": "%s"
279+
}
280+
}`
283281
params := fmt.Sprintf(paramsTemplate, appGuid)
284282

285283
// Execution

api/broker/broker_suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var _ = BeforeSuite(func() {
5050
conf = &config.Config{
5151
CatalogPath: "../exampleconfig/catalog-example.json",
5252
DashboardRedirectURI: dashBoardURL,
53-
PolicySchemaPath: "../policyvalidator/meta.schema.json",
53+
PolicySchemaPath: "../policyvalidator/json-schema/meta.schema.json",
5454
DefaultCustomMetricsCredentialType: "binding-secret",
5555
}
5656

api/brokerserver/broker_handler_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,10 @@ var _ = Describe("BrokerHandler", func() {
11861186
It("fails with 400", func() {
11871187
Expect(resp.Code).To(Equal(http.StatusBadRequest))
11881188
Expect(resp.Body.String()).To(MatchJSON(
1189-
`{"error": "InvalidPolicy", "description": "invalid policy provided: [{\"context\":\"(root)\",\"description\":\"Must validate one and only one schema (oneOf)\"},{\"context\":\"(root).credential-type\",\"description\":\"credential-type must be one of the following: \\\"x509\\\", \\\"binding-secret\\\"\"}]"}`,
1189+
`{
1190+
"error": "InvalidPolicy",
1191+
"description": "invalid policy provided: [{\"context\":\"(root)\",\"description\":\"Must validate one and only one schema (oneOf)\"},{\"context\":\"(root)\",\"description\":\"Must validate one and only one schema (oneOf)\"},{\"context\":\"(root)\",\"description\":\"schema-version is required\"},{\"context\":\"(root).credential-type\",\"description\":\"credential-type must be one of the following: \\\"x509\\\", \\\"binding-secret\\\"\"}]"
1192+
}`,
11901193
))
11911194
})
11921195

api/brokerserver/broker_server_suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ var _ = BeforeSuite(func() {
129129
},
130130
CatalogPath: "../exampleconfig/catalog-example.json",
131131
CatalogSchemaPath: "../schemas/catalog.schema.json",
132-
PolicySchemaPath: "../policyvalidator/meta.schema.json",
132+
PolicySchemaPath: "../policyvalidator/json-schema/meta.schema.json",
133133
Scheduler: config.SchedulerConfig{
134134
SchedulerURL: schedulerServer.URL(),
135135
},

api/cmd/api/api_suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ var _ = SynchronizedBeforeSuite(func() []byte {
164164

165165
conf.CatalogPath = "../../exampleconfig/catalog-example.json"
166166
conf.CatalogSchemaPath = "../../schemas/catalog.schema.json"
167-
conf.PolicySchemaPath = "../policyvalidator/meta.schema.json"
167+
conf.PolicySchemaPath = "../policyvalidator/json-schema/meta.schema.json"
168168

169169
schedulerServer = ghttp.NewServer()
170170
conf.Scheduler.SchedulerURL = schedulerServer.URL()

api/default_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"catalog_schema_path": "/home/vcap/app/api/schemas/catalog.schema.json",
1111
"info_file_path": "/home/vcap/app/api/default_info.json",
12-
"policy_schema_path": "/home/vcap/app/api/policyvalidator/meta.schema.json",
12+
"policy_schema_path": "/home/vcap/app/api/policyvalidator/json-schema/meta.schema.json",
1313
"dashboard_redirect_uri": null,
1414
"default_credential_type": "binding-secret",
1515
"health": {
File renamed without changes.

api/policyvalidator/meta.schema.json renamed to api/policyvalidator/json-schema/meta.schema.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"description": "Unification of different schemas for scaling-policies for Autoscaler",
55

66
"oneOf": [
7-
{"$ref": "./scaling-policy.v0_1.schema.json"},
8-
{"$ref": "./legacy.schema.json"},
9-
{"$ref": "./service-key_only.v0_1.schema.json"}
7+
{"$ref": "./v0.1/meta.schema.json"},
8+
{"$ref": "./legacy.schema.json"}
109
]
1110
}

0 commit comments

Comments
 (0)