diff --git a/.editorconfig b/.editorconfig index 7f610eff8..05738f603 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,6 +9,15 @@ trim_trailing_whitespace = true indent_style = space indent_size = 2 +[{*.bash,*.sh}] +indent_style = tab +indent_size = 2 +softtabstop = 2 + +[Dockerfile] +indent_size = 4 +indent_style = tab + [{Makefile,go.mod,go.sum,*.go,.gitmodules}] indent_style = tab indent_size = 4 @@ -16,16 +25,8 @@ indent_size = 4 [*.md] indent_size = 4 trim_trailing_whitespace = false - eclint_indent_style = unset -[Dockerfile] +[*.py] indent_size = 4 -indent_style = tab - -[{*.bash,*.sh}] -indent_style = tab -indent_size = 2 -softtabstop = 2 - - +indent_style = space diff --git a/Makefile b/Makefile index 35a228b81..350906daa 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ aes_terminal_font_yellow := \033[38;2;255;255;0m aes_terminal_reset := \033[0m VERSION ?= 0.0.0-rc.1 DEST ?= /tmp/build +TARGET_DIR ?= ./build MTAR_FILENAME ?= app-autoscaler-release-v$(VERSION).mtar ACCEPTANCE_TESTS_FILE ?= ${DEST}/app-autoscaler-acceptance-tests-v$(VERSION).tgz CI ?= false @@ -199,7 +200,7 @@ ${gorouter-proxy.program}: ./go.mod ./go.sum ${gorouter-proxy.source} .PHONY: integration integration: generate-fakes init-db test-certs build_all build-gorouterproxy @echo "# Running integration tests" - APP_AUTOSCALER_TEST_RUN='true' DBURL='${DBURL}' go run github.com/onsi/ginkgo/v2/ginkgo ${GINKGO_OPTS} integration DBURL="${DBURL}" + APP_AUTOSCALER_TEST_RUN='true' DBURL='${DBURL}' ginkgo ${GINKGO_OPTS} integration DBURL="${DBURL}" .PHONY: init-db init-db: check-db_type start-db db.java-libs target/init-db-${db_type} @@ -249,6 +250,7 @@ clean: dbtasks.clean scheduler.clean @rm --force --recursive "${openapi-generated-clients-and-servers-api-dir}" @rm --force --recursive "${openapi-generated-clients-and-servers-scalingengine-dir}" @go clean -cache -testcache + @rm --force --recursive 'build' @rm --force --recursive 'fakes' @rm --force --recursive 'test-certs' @rm --force --recursive 'target' @@ -260,6 +262,16 @@ dbtasks.clean: scheduler.clean: pushd scheduler; mvn clean; popd +schema-files := $(shell find ./api/policyvalidator -type f -name '*.json') +flattened-schema-file := ${TARGET_DIR}/bind-request.schema.json +BIND_REQ_SCHEMA_VERSION ?= v0.1 +bind-request-schema: ${flattened-schema-file} +${flattened-schema-file}: ${schema-files} + mkdir -p "$$(dirname ${flattened-schema-file})" + flatten_json-schema './api/policyvalidator/json-schema/${BIND_REQ_SCHEMA_VERSION}/meta.schema.json' \ + > '${flattened-schema-file}' + echo '🔨 File created: ${flattened-schema-file}' + mta-deploy: mta-build build-extension-file $(MAKE) -f metricsforwarder/Makefile set-security-group @echo "Deploying with extension file: $(EXTENSION_FILE)" @@ -301,7 +313,7 @@ release-draft: ## Create a draft GitHub release without artifacts ./scripts/release.sh .PHONY: create-assets -create-assets: ## Create release assets (mtar and acceptance tests) +create-assets: ## Create release assets (mtar and acceptance tests), please provide `VERSION` as environment-variable. ./scripts/create-assets.sh .PHONY: release-promote diff --git a/acceptance/broker/broker_test.go b/acceptance/broker/broker_test.go index 7d649f413..4ed4c6844 100644 --- a/acceptance/broker/broker_test.go +++ b/acceptance/broker/broker_test.go @@ -272,14 +272,12 @@ var _ = Describe("AutoScaler Service Broker", func() { It("fails", func() { // Preparation - paramsTemplate := ` -{ - "schema-version": "0.1", - "configuration": { - "app_guid": "%s" - } -} -` + paramsTemplate := `{ + "schema-version": "0.1", + "configuration": { + "app_guid": "%s" + } + }` params := fmt.Sprintf(paramsTemplate, appGuid) // Execution diff --git a/api/broker/broker_suite_test.go b/api/broker/broker_suite_test.go index bf7048e67..ac8806a87 100644 --- a/api/broker/broker_suite_test.go +++ b/api/broker/broker_suite_test.go @@ -50,7 +50,7 @@ var _ = BeforeSuite(func() { conf = &config.Config{ CatalogPath: "../exampleconfig/catalog-example.json", DashboardRedirectURI: dashBoardURL, - PolicySchemaPath: "../policyvalidator/meta.schema.json", + PolicySchemaPath: "../policyvalidator/json-schema/meta.schema.json", DefaultCustomMetricsCredentialType: "binding-secret", } diff --git a/api/brokerserver/broker_handler_test.go b/api/brokerserver/broker_handler_test.go index 830d43f18..02ebdd0bc 100644 --- a/api/brokerserver/broker_handler_test.go +++ b/api/brokerserver/broker_handler_test.go @@ -1186,7 +1186,10 @@ var _ = Describe("BrokerHandler", func() { It("fails with 400", func() { Expect(resp.Code).To(Equal(http.StatusBadRequest)) Expect(resp.Body.String()).To(MatchJSON( - `{"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\\\"\"}]"}`, + `{ + "error": "InvalidPolicy", + "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\\\"\"}]" + }`, )) }) diff --git a/api/brokerserver/broker_server_suite_test.go b/api/brokerserver/broker_server_suite_test.go index ce10d522f..2d40fdd35 100644 --- a/api/brokerserver/broker_server_suite_test.go +++ b/api/brokerserver/broker_server_suite_test.go @@ -129,7 +129,7 @@ var _ = BeforeSuite(func() { }, CatalogPath: "../exampleconfig/catalog-example.json", CatalogSchemaPath: "../schemas/catalog.schema.json", - PolicySchemaPath: "../policyvalidator/meta.schema.json", + PolicySchemaPath: "../policyvalidator/json-schema/meta.schema.json", Scheduler: config.SchedulerConfig{ SchedulerURL: schedulerServer.URL(), }, diff --git a/api/cmd/api/api_suite_test.go b/api/cmd/api/api_suite_test.go index ec753460b..47df123ed 100644 --- a/api/cmd/api/api_suite_test.go +++ b/api/cmd/api/api_suite_test.go @@ -164,7 +164,7 @@ var _ = SynchronizedBeforeSuite(func() []byte { conf.CatalogPath = "../../exampleconfig/catalog-example.json" conf.CatalogSchemaPath = "../../schemas/catalog.schema.json" - conf.PolicySchemaPath = "../policyvalidator/meta.schema.json" + conf.PolicySchemaPath = "../policyvalidator/json-schema/meta.schema.json" schedulerServer = ghttp.NewServer() conf.Scheduler.SchedulerURL = schedulerServer.URL() diff --git a/api/default_config.json b/api/default_config.json index e0e7230d6..afec4d826 100644 --- a/api/default_config.json +++ b/api/default_config.json @@ -9,7 +9,7 @@ }, "catalog_schema_path": "/home/vcap/app/api/schemas/catalog.schema.json", "info_file_path": "/home/vcap/app/api/default_info.json", - "policy_schema_path": "/home/vcap/app/api/policyvalidator/meta.schema.json", + "policy_schema_path": "/home/vcap/app/api/policyvalidator/json-schema/meta.schema.json", "dashboard_redirect_uri": null, "default_credential_type": "binding-secret", "health": { diff --git a/api/policyvalidator/legacy.schema.json b/api/policyvalidator/json-schema/legacy.schema.json similarity index 100% rename from api/policyvalidator/legacy.schema.json rename to api/policyvalidator/json-schema/legacy.schema.json diff --git a/api/policyvalidator/meta.schema.json b/api/policyvalidator/json-schema/meta.schema.json similarity index 59% rename from api/policyvalidator/meta.schema.json rename to api/policyvalidator/json-schema/meta.schema.json index ef595ede1..67b084087 100644 --- a/api/policyvalidator/meta.schema.json +++ b/api/policyvalidator/json-schema/meta.schema.json @@ -4,8 +4,7 @@ "description": "Unification of different schemas for scaling-policies for Autoscaler", "oneOf": [ - {"$ref": "./scaling-policy.v0_1.schema.json"}, - {"$ref": "./legacy.schema.json"}, - {"$ref": "./service-key_only.v0_1.schema.json"} + {"$ref": "./v0.1/meta.schema.json"}, + {"$ref": "./legacy.schema.json"} ] } diff --git a/api/policyvalidator/shared_definitions.json b/api/policyvalidator/json-schema/shared_definitions.json similarity index 100% rename from api/policyvalidator/shared_definitions.json rename to api/policyvalidator/json-schema/shared_definitions.json diff --git a/api/policyvalidator/json-schema/v0.1/meta.schema.json b/api/policyvalidator/json-schema/v0.1/meta.schema.json new file mode 100644 index 000000000..12a3530de --- /dev/null +++ b/api/policyvalidator/json-schema/v0.1/meta.schema.json @@ -0,0 +1,10 @@ +{ + "$schema": "http://json-schema.org/draft-05/schema#", + "title": "Autoscaler Policy JSON Schema", + "description": "Unification of different schemas for scaling-policies for Autoscaler", + + "oneOf": [ + {"$ref": "./scaling-policy.schema.json"}, + {"$ref": "./service-key_only.schema.json"} + ] +} diff --git a/api/policyvalidator/policy-configuration.schema.json b/api/policyvalidator/json-schema/v0.1/policy-configuration.schema.json similarity index 94% rename from api/policyvalidator/policy-configuration.schema.json rename to api/policyvalidator/json-schema/v0.1/policy-configuration.schema.json index 8805cce6f..989a3617a 100644 --- a/api/policyvalidator/policy-configuration.schema.json +++ b/api/policyvalidator/json-schema/v0.1/policy-configuration.schema.json @@ -30,7 +30,7 @@ "additionalProperties": false }, "app_guid": { - "$ref": "./shared_definitions.json#/schemas/guid" + "$ref": "../shared_definitions.json#/schemas/guid" } }, "anyOf": [ diff --git a/api/policyvalidator/scaling-policy.v0_1.schema.json b/api/policyvalidator/json-schema/v0.1/scaling-policy.schema.json similarity index 99% rename from api/policyvalidator/scaling-policy.v0_1.schema.json rename to api/policyvalidator/json-schema/v0.1/scaling-policy.schema.json index 1555138b7..3db3365b8 100644 --- a/api/policyvalidator/scaling-policy.v0_1.schema.json +++ b/api/policyvalidator/json-schema/v0.1/scaling-policy.schema.json @@ -5,7 +5,7 @@ "properties": { "schema-version": { - "$ref": "./shared_definitions.json#/schemas/app-scaling-config-schema" + "$ref": "../shared_definitions.json#/schemas/app-scaling-config-schema" }, "credential-type": { "type": "string", diff --git a/api/policyvalidator/service-key_only.v0_1.schema.json b/api/policyvalidator/json-schema/v0.1/service-key_only.schema.json similarity index 76% rename from api/policyvalidator/service-key_only.v0_1.schema.json rename to api/policyvalidator/json-schema/v0.1/service-key_only.schema.json index 2515b3c12..bd0e9484b 100644 --- a/api/policyvalidator/service-key_only.v0_1.schema.json +++ b/api/policyvalidator/json-schema/v0.1/service-key_only.schema.json @@ -5,13 +5,13 @@ "properties": { "schema-version": { - "$ref": "./shared_definitions.json#/schemas/app-scaling-config-schema" + "$ref": "../shared_definitions.json#/schemas/app-scaling-config-schema" }, "configuration": { "type": "object", "properties": { "app_guid": { - "$ref": "./shared_definitions.json#/schemas/guid" + "$ref": "../shared_definitions.json#/schemas/guid" } }, "required": ["app_guid"], diff --git a/api/policyvalidator/policy_validator_test.go b/api/policyvalidator/policy_validator_test.go index f4d5d3a2d..735160ff1 100644 --- a/api/policyvalidator/policy_validator_test.go +++ b/api/policyvalidator/policy_validator_test.go @@ -48,7 +48,7 @@ var _ = Describe("PolicyValidator", func() { upperDiskThreshold = 2 * 1024 policyValidator = NewPolicyValidator( - "./meta.schema.json", + "./json-schema/meta.schema.json", lowerCPUThreshold, upperCPUThreshold, lowerCPUUtilThreshold, diff --git a/api/publicapiserver/publicapiserver_suite_test.go b/api/publicapiserver/publicapiserver_suite_test.go index 3fbd873f0..22318276f 100644 --- a/api/publicapiserver/publicapiserver_suite_test.go +++ b/api/publicapiserver/publicapiserver_suite_test.go @@ -104,7 +104,7 @@ var _ = BeforeSuite(func() { CFServer: helpers.ServerConfig{ Port: 14000 + GinkgoParallelProcess(), }, - PolicySchemaPath: "../policyvalidator/meta.schema.json", + PolicySchemaPath: "../policyvalidator/json-schema/meta.schema.json", Scheduler: config.SchedulerConfig{ SchedulerURL: schedulerServer.URL(), }, diff --git a/devbox.json b/devbox.json index 519b21f5c..a3ec0e880 100644 --- a/devbox.json +++ b/devbox.json @@ -1,11 +1,12 @@ { "packages": { - "path:./nix#bosh-bootloader": "", - "path:./nix#app-autoscaler-cli-plugin": "", - "path:./nix#log-cache-cli-plugin": "", - "path:./nix#cf-deploy-plugin": "", - "path:./nix#cloud-mta-build-tool": "", - "path:./nix#uaac": "", + "path:.#bosh-bootloader": "", + "path:.#app-autoscaler-cli-plugin": "", + "path:.#log-cache-cli-plugin": "", + "path:.#cf-deploy-plugin": "", + "path:.#cloud-mta-build-tool": "", + "path:.#uaac": "", + "path:.#flatten_json-schema": "", "act": "0.2.80", "bosh-cli": "7.3.1", "bundix": "2.5.2", @@ -26,6 +27,7 @@ "google-java-format": "1.27.0", "gopls": "0.18.1", "gum": "0.16.2", + "jdt-language-server": "", "jq": "latest", "markdownlint-cli2": "0.17.1", "maven": "3.9.11", @@ -42,8 +44,8 @@ "which": "latest", "xq-xml": "1.3.0", "yq-go": "4.45.4", - "apple-sdk":{ - "version": "latest", + "apple-sdk": { + "version": "latest", "platforms": ["aarch64-darwin"] } }, diff --git a/devbox.lock b/devbox.lock index a7abec8ef..0e2cd3e1e 100644 --- a/devbox.lock +++ b/devbox.lock @@ -1093,6 +1093,10 @@ } } }, + "jdt-language-server": { + "resolved": "github:NixOS/nixpkgs/e99366c665bdd53b7b500ccdc5226675cfc51f45?narHash=sha256-EiED5k6gXTWoAIS8yQqi5mAX6ojnzpHwAQTS3ykeYMg%3D#jdt-language-server", + "source": "nixpkg" + }, "jq@latest": { "last_modified": "2025-10-12T08:13:11Z", "resolved": "github:NixOS/nixpkgs/832e3b6db48508ae436c2c7bfc0cf914eac6938e#jq", diff --git a/nix/flake.lock b/flake.lock similarity index 70% rename from nix/flake.lock rename to flake.lock index b0e9ff3f3..8a30674d2 100644 --- a/nix/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1760284886, - "narHash": "sha256-TK9Kr0BYBQ/1P5kAsnNQhmWWKgmZXwUQr4ZMjCzWf2c=", + "lastModified": 1765186076, + "narHash": "sha256-hM20uyap1a0M9d344I692r+ik4gTMyj60cQWO+hAYP8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "cf3f5c4def3c7b5f1fc012b3d839575dbe552d43", + "rev": "addf7cf5f383a3101ecfba091b98d0a1263dc9b8", "type": "github" }, "original": { diff --git a/nix/flake.nix b/flake.nix similarity index 96% rename from nix/flake.nix rename to flake.nix index 71bf87e5d..d2680524f 100644 --- a/nix/flake.nix +++ b/flake.nix @@ -19,7 +19,7 @@ let nixpkgs = nixpkgsFor.${system}; callPackages = nixpkgs.lib.customisation.callPackagesWith nixpkgs; - in callPackages ./packages.nix {} + in callPackages ./nix/packages.nix {} ); # 🚸 Having flake.nix on top-level makes this definition easily consumable with Nix, e.g. for @@ -32,5 +32,5 @@ (path: type: builtins.match ".*\.ya?ml" (baseNameOf path) != null && type == "regular") apiPath; }; - }; + }; } diff --git a/integration/components_test.go b/integration/components_test.go index 04b7890b5..46adc8331 100644 --- a/integration/components_test.go +++ b/integration/components_test.go @@ -232,7 +232,7 @@ func DefaultGolangAPITestConfig() apiConfig.Config { }, CatalogPath: "../servicebroker/config/catalog.json", CatalogSchemaPath: "../api/schemas/catalog.schema.json", - PolicySchemaPath: "../api/policyvalidator/meta.schema.json", + PolicySchemaPath: "../api/policyvalidator/json-schema/meta.schema.json", InfoFilePath: "../api/exampleconfig/catalog-example.json", DashboardRedirectURI: "", CF: cf.Config{ diff --git a/nix/packages.nix b/nix/packages.nix index 724a7df7a..0f3dfcc54 100644 --- a/nix/packages.nix +++ b/nix/packages.nix @@ -1,8 +1,10 @@ -{ buildGoModule -, callPackage -, fetchFromGitHub -, fetchgit -, lib +{ buildGoModule, + callPackage, + fetchFromGitHub, + fetchgit, + lib, + python3Packages, + writers }: { app-autoscaler-cli-plugin = buildGoModule rec { pname = "app-autoscaler-cli-plugin"; @@ -29,9 +31,9 @@ meta = { longDescription = '' - App-AutoScaler plug-in provides the command line interface to manage - [App AutoScaler]() - policies, retrieve metrics and scaling event history. + App-AutoScaler plug-in provides the command line interface to manage + [App AutoScaler]() + policies, retrieve metrics and scaling event history. ''; homepage = "https://github.com/cloudfoundry/app-autoscaler-cli-plugin"; license = [lib.licenses.asl20]; @@ -67,6 +69,38 @@ }; }; + cf-deploy-plugin = buildGoModule rec { + pname = "CF Deploy Plugin"; + version = "3.5.0"; + + src = fetchFromGitHub { + owner = "cloudfoundry"; + repo = "multiapps-cli-plugin"; + rev = "v${version}"; + hash = "sha256-SVPVPJJWOk08ivZWu9UwD9sIISajIukQpcFpc0tU1zg="; + }; + vendorHash = "sha256-S066sNHhKxL4anH5qSSBngtOcAswopiYBXgKAvHyfAM="; + + env.CGO_ENABLED = 0; + ldflags = ["-w -X main.Version=${version}"]; + + meta = with lib; { + description = ""; + longDescription = '' + This is a Cloud Foundry CLI plugin (formerly known as CF MTA Plugin) for performing + operations on + [Multitarget Applications (MTAs)]() + in Cloud Foundry, such as deploying, removing, viewing, etc. It is a client for the + [CF MultiApps Controller]() + (known also as CF MTA Deploy Service), which is an MTA deployer implementation for Cloud + Foundry. The business logic and actual processing of MTAs happens into + CF MultiApps Controller backend. + ''; + homepage = "https://github.com/cloudfoundry/multiapps-cli-plugin"; + license = licenses.asl20; + }; + }; + cloud-mta-build-tool = buildGoModule rec { pname = "Cloud MTA Build Tool"; version = "1.2.30"; @@ -85,7 +119,7 @@ postInstall = '' pushd "''${out}/bin" &> /dev/null - ln --symbolic 'cloud-mta-build-tool' 'mbt' + ln --symbolic 'cloud-mta-build-tool' 'mbt' popd ''; @@ -118,37 +152,16 @@ }; }; - cf-deploy-plugin = buildGoModule rec { - pname = "CF Deploy Plugin"; - version = "3.5.0"; - - src = fetchFromGitHub { - owner = "cloudfoundry"; - repo = "multiapps-cli-plugin"; - rev = "v${version}"; - hash = "sha256-SVPVPJJWOk08ivZWu9UwD9sIISajIukQpcFpc0tU1zg="; - }; - vendorHash = "sha256-S066sNHhKxL4anH5qSSBngtOcAswopiYBXgKAvHyfAM="; - - env.CGO_ENABLED = 0; - ldflags = ["-w -X main.Version=${version}"]; - - meta = with lib; { - description = ""; - longDescription = '' - This is a Cloud Foundry CLI plugin (formerly known as CF MTA Plugin) for performing - operations on - [Multitarget Applications (MTAs)]() - in Cloud Foundry, such as deploying, removing, viewing, etc. It is a client for the - [CF MultiApps Controller]() - (known also as CF MTA Deploy Service), which is an MTA deployer implementation for Cloud - Foundry. The business logic and actual processing of MTAs happens into - CF MultiApps Controller backend. - ''; - homepage = "https://github.com/cloudfoundry/multiapps-cli-plugin"; - license = licenses.asl20; - }; - }; + flatten_json-schema = + let + programName = "flatten_json-schema"; + programSourceCode = (builtins.readFile ../scripts/flatten_json-schema.py); + in writers.writePython3Bin programName { + libraries = [ + python3Packages.jsonref + ]; + flakeIgnore = [ "E265" "E501" ]; + } programSourceCode; uaac = callPackage ./packages/uaac {}; } diff --git a/scripts/create-assets.sh b/scripts/create-assets.sh index 0ab92b07a..78c96ea78 100755 --- a/scripts/create-assets.sh +++ b/scripts/create-assets.sh @@ -14,58 +14,69 @@ SUM_FILE="${build_path}/artifacts/files.sum.sha256" # Determine version if not set if [ -z "${VERSION}" ]; then - if [ -f "${build_path}/name" ]; then - VERSION=$(cat "${build_path}/name") - else - echo " - VERSION not set, determining version..." - mkdir -p "${build_path}" - determine_next_version - VERSION=$(cat "${build_path}/name") - fi + if [ -f "${build_path}/name" ]; then + VERSION=$(cat "${build_path}/name") + else + echo " - VERSION not set, determining version..." + mkdir -p "${build_path}" + determine_next_version + VERSION=$(cat "${build_path}/name") + fi fi function create_mtar() { - set -e - mkdir -p "${build_path}/artifacts" - local version=$1 - local build_path=$2 - echo " - creating autoscaler mtar artifact" - pushd "${autoscaler_dir}" > /dev/null - make mta-release VERSION="${version}" DEST="${build_path}/artifacts/" - popd > /dev/null + set -e + mkdir -p "${build_path}/artifacts" + local version=$1 + local build_path=$2 + echo " - creating autoscaler mtar artifact" + pushd "${autoscaler_dir}" > /dev/null + make mta-release VERSION="${version}" DEST="${build_path}/artifacts" + popd > /dev/null } function create_tests() { - set -e - mkdir -p "${build_path}/artifacts" - local version=$1 - local build_path=$2 - echo " - creating acceptance test artifact" - pushd "${autoscaler_dir}" > /dev/null - make acceptance-release VERSION="${version}" DEST="${build_path}/artifacts/" - popd > /dev/null + set -e + mkdir -p "${build_path}/artifacts" + local version=$1 + local build_path=$2 + echo " - creating acceptance test artifact" + pushd "${autoscaler_dir}" > /dev/null + make acceptance-release VERSION="${version}" DEST="${build_path}/artifacts" + popd > /dev/null +} + +function create_bindreq_schema() { + local -r target_dir="${1}" + echo " - creating bind request schema artifact in ${target_dir}" + make bind-request-schema TARGET_DIR="${target_dir}" + return 0 } echo " - Creating assets for version ${VERSION}..." pushd "${autoscaler_dir}" > /dev/null - mkdir -p "${build_path}/artifacts" + mkdir -p "${build_path}/artifacts" - create_tests "${VERSION}" "${build_path}" - create_mtar "${VERSION}" "${build_path}" + create_bindreq_schema "${build_path}/artifacts" + create_tests "${VERSION}" "${build_path}" + create_mtar "${VERSION}" "${build_path}" - echo " - Generating checksums..." - sha256sum "${build_path}/artifacts/"* > "${build_path}/artifacts/files.sum.sha256" + echo " - Generating checksums..." + sha256sum "${build_path}/artifacts/"* > "${build_path}/artifacts/files.sum.sha256" - ACCEPTANCE_TEST_TGZ="app-autoscaler-acceptance-tests-v${VERSION}.tgz" - AUTOSCALER_MTAR="app-autoscaler-release-v${VERSION}.mtar" + ACCEPTANCE_TEST_TGZ="app-autoscaler-acceptance-tests-v${VERSION}.tgz" + AUTOSCALER_MTAR="app-autoscaler-release-v${VERSION}.mtar" + BIND_REQ_SCHEMA='bind-request.schema.json' - ACCEPTANCE_SHA256=$( grep "${ACCEPTANCE_TEST_TGZ}$" "${SUM_FILE}" | awk '{print $1}' ) - MTAR_SHA256=$( grep "${AUTOSCALER_MTAR}$" "${SUM_FILE}" | awk '{print $1}') + ACCEPTANCE_SHA256=$( grep "${ACCEPTANCE_TEST_TGZ}$" "${SUM_FILE}" | awk '{print $1}' ) + MTAR_SHA256=$( grep "${AUTOSCALER_MTAR}$" "${SUM_FILE}" | awk '{print $1}') + BR_SCHEMA_SHA256=$( grep "${BIND_REQ_SCHEMA}$" "${SUM_FILE}" | awk '{print $1}') - echo " - Assets created successfully:" - echo " - Acceptance tests: ${ACCEPTANCE_TEST_TGZ} (SHA256: ${ACCEPTANCE_SHA256})" - echo " - MTAR: ${AUTOSCALER_MTAR} (SHA256: ${MTAR_SHA256})" + echo " - Assets created successfully:" + echo " - Acceptance tests: ${ACCEPTANCE_TEST_TGZ} (SHA256: ${ACCEPTANCE_SHA256})" + echo " - MTAR: ${AUTOSCALER_MTAR} (SHA256: ${MTAR_SHA256})" + echo " - Bind Request Schema: ${BIND_REQ_SCHEMA} (SHA256: ${BR_SCHEMA_SHA256})" popd > /dev/null echo " - Completed" diff --git a/scripts/flatten_json-schema.py b/scripts/flatten_json-schema.py new file mode 100644 index 000000000..3607f24df --- /dev/null +++ b/scripts/flatten_json-schema.py @@ -0,0 +1,25 @@ +#! /usr/bin/env python3 + +import argparse +import json +import jsonref +from pathlib import Path +import sys + + +def merge_schemas(input_file_path): + input_file_path_abs = Path(input_file_path).absolute() + + with open(input_file_path_abs, 'r') as f: + policy_schema = jsonref.load(f, base_uri=input_file_path_abs.as_uri()) + + json.dump(policy_schema, sys.stdout, indent=2) + return None + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Flatten JSON schema by resolving references') + parser.add_argument('input_file_path', help='Path to the input JSON schema file') + args = parser.parse_args() + + merge_schemas(args.input_file_path)