diff --git a/ododevapispec.yaml b/ododevapispec.yaml index 1a4e59495..173ab15b9 100644 --- a/ododevapispec.yaml +++ b/ododevapispec.yaml @@ -1642,6 +1642,7 @@ components: type: object required: - content + - version - commands - containers - images @@ -1652,6 +1653,8 @@ components: properties: content: type: string + version: + type: string commands: type: array items: diff --git a/pkg/apiserver-gen/go/model_devfile_content.go b/pkg/apiserver-gen/go/model_devfile_content.go index 1f0cb3623..dd5bb0102 100644 --- a/pkg/apiserver-gen/go/model_devfile_content.go +++ b/pkg/apiserver-gen/go/model_devfile_content.go @@ -12,6 +12,8 @@ package openapi type DevfileContent struct { Content string `json:"content"` + Version string `json:"version"` + Commands []Command `json:"commands"` Containers []Container `json:"containers"` @@ -31,6 +33,7 @@ type DevfileContent struct { func AssertDevfileContentRequired(obj DevfileContent) error { elements := map[string]interface{}{ "content": obj.Content, + "version": obj.Version, "commands": obj.Commands, "containers": obj.Containers, "images": obj.Images, diff --git a/pkg/apiserver-impl/devstate/commands_test.go b/pkg/apiserver-impl/devstate/commands_test.go index 79cc9a19a..56d094ffe 100644 --- a/pkg/apiserver-impl/devstate/commands_test.go +++ b/pkg/apiserver-impl/devstate/commands_test.go @@ -83,6 +83,7 @@ components: metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{ { Name: "an-exec-command", @@ -183,6 +184,7 @@ components: metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{ { Name: "an-apply-command", @@ -311,6 +313,7 @@ components: metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{ { Name: "an-exec-command", @@ -440,6 +443,7 @@ func TestDevfileState_DeleteCommand(t *testing.T) { metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{}, Containers: []Container{ { @@ -655,6 +659,7 @@ func TestDevfileState_MoveCommand(t *testing.T) { metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{ { Name: "an-exec-command", @@ -742,6 +747,7 @@ func TestDevfileState_SetDefaultCommand(t *testing.T) { metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{ { Name: "an-exec-command", @@ -831,6 +837,7 @@ func TestDevfileState_UnsetDefaultCommand(t *testing.T) { metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{ { Name: "an-exec-command", diff --git a/pkg/apiserver-impl/devstate/components_test.go b/pkg/apiserver-impl/devstate/components_test.go index 3683d9bae..cbbd6dfe9 100644 --- a/pkg/apiserver-impl/devstate/components_test.go +++ b/pkg/apiserver-impl/devstate/components_test.go @@ -78,6 +78,7 @@ func TestDevfileState_AddContainer(t *testing.T) { metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{}, Containers: []Container{ { @@ -150,6 +151,7 @@ schemaVersion: 2.2.0 metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{}, Containers: []Container{ { @@ -243,6 +245,7 @@ func TestDevfileState_DeleteContainer(t *testing.T) { Content: `metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{}, Containers: []Container{}, Images: []Image{}, @@ -349,6 +352,7 @@ func TestDevfileState_AddImage(t *testing.T) { metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{}, Containers: []Container{}, Images: []Image{ @@ -424,6 +428,7 @@ func TestDevfileState_DeleteImage(t *testing.T) { Content: `metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{}, Containers: []Container{}, Images: []Image{}, @@ -507,6 +512,7 @@ func TestDevfileState_AddResource(t *testing.T) { metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{}, Containers: []Container{}, Images: []Image{}, @@ -539,6 +545,7 @@ schemaVersion: 2.2.0 metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{}, Containers: []Container{}, Images: []Image{}, @@ -607,6 +614,7 @@ func TestDevfileState_Deleteresource(t *testing.T) { Content: `metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{}, Containers: []Container{}, Images: []Image{}, @@ -688,6 +696,7 @@ func TestDevfileState_AddVolume(t *testing.T) { metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{}, Containers: []Container{}, Images: []Image{}, @@ -753,6 +762,7 @@ func TestDevfileState_DeleteVolume(t *testing.T) { Content: `metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{}, Containers: []Container{}, Images: []Image{}, diff --git a/pkg/apiserver-impl/devstate/content.go b/pkg/apiserver-impl/devstate/content.go index a94eea18b..51536f974 100644 --- a/pkg/apiserver-impl/devstate/content.go +++ b/pkg/apiserver-impl/devstate/content.go @@ -54,6 +54,7 @@ func (o *DevfileState) GetContent() (DevfileContent, error) { return DevfileContent{ Content: string(result), + Version: o.Devfile.Data.GetSchemaVersion(), Commands: commands, Containers: containers, Images: images, diff --git a/pkg/apiserver-impl/devstate/content_test.go b/pkg/apiserver-impl/devstate/content_test.go index 817b3e260..511c1af3a 100644 --- a/pkg/apiserver-impl/devstate/content_test.go +++ b/pkg/apiserver-impl/devstate/content_test.go @@ -20,6 +20,7 @@ func TestDevfileState_GetContent(t *testing.T) { }, want: DevfileContent{ Content: "metadata: {}\nschemaVersion: 2.2.0\n", + Version: "2.2.0", Commands: []Command{}, Containers: []Container{}, Images: []Image{}, diff --git a/pkg/apiserver-impl/devstate/events_test.go b/pkg/apiserver-impl/devstate/events_test.go index a53e0a1cb..7b6796a32 100644 --- a/pkg/apiserver-impl/devstate/events_test.go +++ b/pkg/apiserver-impl/devstate/events_test.go @@ -35,6 +35,7 @@ func TestDevfileState_UpdateEvents(t *testing.T) { metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{}, Containers: []Container{}, Images: []Image{}, @@ -67,6 +68,7 @@ schemaVersion: 2.2.0 metadata: {} schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{}, Containers: []Container{}, Images: []Image{}, diff --git a/pkg/apiserver-impl/devstate/state_test.go b/pkg/apiserver-impl/devstate/state_test.go index 8e62381c6..52a9818b8 100644 --- a/pkg/apiserver-impl/devstate/state_test.go +++ b/pkg/apiserver-impl/devstate/state_test.go @@ -71,6 +71,7 @@ func TestDevfileState_SetMetadata(t *testing.T) { website: http://example.com schemaVersion: 2.2.0 `, + Version: "2.2.0", Commands: []Command{}, Containers: []Container{}, Images: []Image{}, diff --git a/pkg/apiserver-impl/swagger-ui/swagger.yaml b/pkg/apiserver-impl/swagger-ui/swagger.yaml index 1a4e59495..173ab15b9 100644 --- a/pkg/apiserver-impl/swagger-ui/swagger.yaml +++ b/pkg/apiserver-impl/swagger-ui/swagger.yaml @@ -1642,6 +1642,7 @@ components: type: object required: - content + - version - commands - containers - images @@ -1652,6 +1653,8 @@ components: properties: content: type: string + version: + type: string commands: type: array items: diff --git a/pkg/apiserver-impl/ui/index.html b/pkg/apiserver-impl/ui/index.html index 7bf665055..930b93e28 100644 --- a/pkg/apiserver-impl/ui/index.html +++ b/pkg/apiserver-impl/ui/index.html @@ -11,6 +11,6 @@