Skip to content

Commit

Permalink
Auto-populate version and build properties in v3/info endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
gogolok committed May 16, 2024
1 parent 4d0b985 commit b4ee5f1
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 23 deletions.
2 changes: 0 additions & 2 deletions README.helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ Here are all the values that can be set for the chart:
- `image` (_String_): Reference to the API container image.
- `include` (_Boolean_): Deploy the API component.
- `infoConfig`: The /v3/info endpoint configuration.
- `build` (_String_): `build` attribute in the /v3/info endpoint
- `custom`: `custom` attribute in the /v3/info endpoint
- `description` (_String_): `description` attribute in the /v3/info endpoint
- `minCLIVersion` (_String_): `minimum` CLI version attribute in the /v3/info endpoint
- `name` (_String_): `name` attribute in the /v3/info endpoint
- `recommendedCLIVersion` (_String_): `recommended` CLI version attribute in the /v3/info endpoint
- `supportAddress` (_String_): `support` attribute in the /v3/info endpoint
- `version` (_Integer_): `version` attribute in the /v3/info endpoint
- `lifecycle`: Default lifecycle for apps.
- `stack` (_String_): Stack.
- `type` (_String_): Lifecycle type (only `buildpack` accepted currently).
Expand Down
2 changes: 0 additions & 2 deletions api/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,8 @@ type (
}

InfoConfig struct {
Build string `yaml:"build"`
Description string `yaml:"description"`
Name string `yaml:"name"`
Version int `yaml:"version"`
MinCLIVersion string `yaml:"minCLIVersion"`
RecommendedCLIVersion string `yaml:"recommendedCLIVersion"`
Custom map[string]interface{} `yaml:"custom"`
Expand Down
7 changes: 4 additions & 3 deletions api/presenter/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"net/url"

"code.cloudfoundry.org/korifi/api/config"
"code.cloudfoundry.org/korifi/version"
)

type InfoV3Response struct {
Build string `json:"build"`
CLIVersion InfoCLIVersion `json:"cli_version"`
Description string `json:"description"`
Name string `json:"name"`
Version int `json:"version"`
Version string `json:"version"`
Custom map[string]interface{} `json:"custom"`

Links map[string]Link `json:"links"`
Expand All @@ -24,10 +25,10 @@ type InfoCLIVersion struct {

func ForInfoV3(baseURL url.URL, infoConfig config.InfoConfig) InfoV3Response {
return InfoV3Response{
Build: infoConfig.Build,
Build: version.Version,
Description: infoConfig.Description,
Name: infoConfig.Name,
Version: infoConfig.Version,
Version: version.Version,
CLIVersion: InfoCLIVersion{
Minimum: infoConfig.MinCLIVersion,
Recommended: infoConfig.RecommendedCLIVersion,
Expand Down
4 changes: 2 additions & 2 deletions api/presenter/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ var _ = Describe("Info endpoints", func() {

It("produces expected info v3 json", func() {
Expect(output).To(MatchJSON(`{
"build": "",
"build": "v9999.99.99-local.dev",
"cli_version": {
"minimum": "",
"recommended": ""
},
"description": "",
"name": "",
"version": 0,
"version": "v9999.99.99-local.dev",
"custom": {},
"links": {
"self": {
Expand Down
2 changes: 0 additions & 2 deletions helm/korifi/api/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ data:
readHeaderTimeout: {{ .Values.api.apiServer.timeouts.readHeader }}
writeTimeout: {{ .Values.api.apiServer.timeouts.write }}
infoConfig:
build: {{ .Values.api.infoConfig.build }}
description: {{ .Values.api.infoConfig.description }}
name: {{ .Values.api.infoConfig.name }}
version: {{ .Values.api.infoConfig.version }}
minCLIVersion: {{ .Values.api.infoConfig.minCLIVersion }}
recommendedCLIVersion: {{ .Values.api.infoConfig.recommendedCLIVersion }}
{{- with .Values.api.infoConfig.custom }}
Expand Down
10 changes: 1 addition & 9 deletions helm/korifi/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,6 @@
"type": "object",
"description": "The /v3/info endpoint configuration.",
"properties": {
"build": {
"description": "`build` attribute in the /v3/info endpoint",
"type": "string"
},
"description": {
"description": "`description` attribute in the /v3/info endpoint",
"type": "string"
Expand All @@ -191,10 +187,6 @@
"description": "`name` attribute in the /v3/info endpoint",
"type": "string"
},
"version": {
"description": "`version` attribute in the /v3/info endpoint",
"type": "integer"
},
"minCLIVersion": {
"description": "`minimum` CLI version attribute in the /v3/info endpoint",
"type": "string"
Expand All @@ -213,7 +205,7 @@
"type": "string"
}
},
"required": ["build", "description", "name", "version", "minCLIVersion", "recommendedCLIVersion", "custom", "supportAddress"]
"required": ["description", "name", "minCLIVersion", "recommendedCLIVersion", "custom", "supportAddress"]
},
"lifecycle": {
"type": "object",
Expand Down
2 changes: 0 additions & 2 deletions helm/korifi/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ api:
readHeader: 10

infoConfig:
build: ""
description: ""
name: ""
version: 0
minCLIVersion: ""
recommendedCLIVersion: ""
custom: {}
Expand Down
1 change: 0 additions & 1 deletion scripts/deploy-on-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ function deploy_korifi() {
--set=debug="$DEBUG" \
--set=stagingRequirements.buildCacheMB="1024" \
--set=api.apiServer.url="localhost" \
--set=api.infoConfig.build="$VERSION" \
--set=controllers.taskTTL="5s" \
--set=jobTaskRunner.jobTTL="5s" \
--set=containerRepositoryPrefix="$REPOSITORY_PREFIX" \
Expand Down

0 comments on commit b4ee5f1

Please sign in to comment.