Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] Edit container #7077

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions ododevapispec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,126 @@ paths:
example:
message: "Error deleting the container"

patch:
tags:
- devstate
description: Update a container
parameters:
- name: containerName
in: path
description: Container name to update
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
type: object
required:
- name
- image
properties:
image:
description: Container image
type: string
command:
description: Entrypoint of the container
type: array
items: {
type: string
}
args:
description: Args passed to the Container entrypoint
type: array
items: {
type: string
}
env:
description: Environment variables to define
type: array
items:
$ref: '#/components/schemas/Env'
memReq:
description: Requested memory for the deployed container
type: string
memLimit:
description: Memory limit for the deployed container
type: string
cpuReq:
description: Requested CPU for the deployed container
type: string
cpuLimit:
description: CPU limit for the deployed container
type: string
volumeMounts:
description: Volume to mount into the container filesystem
type: array
items:
$ref: '#/components/schemas/VolumeMount'
configureSources:
description: If false, mountSources and sourceMapping values are not considered
type: boolean
mountSources:
description: If true, sources are mounted into container's filesystem
type: boolean
sourceMapping:
description: Specific directory on which to mount sources
type: string
annotation:
description: Annotations added to the resources created for this container
$ref: '#/components/schemas/Annotation'
endpoints:
description: Endpoints exposed by the container
type: array
items:
$ref: '#/components/schemas/Endpoint'

responses:
'200':
description: container was successfully updated
content:
application/json:
schema:
$ref: '#/components/schemas/DevfileContent'
example:
{
"content": "schemaVersion: 2.2.0\n",
"commands": [],
"containers": [],
"images": [],
"resources": [],
"events": {
"preStart": null,
"postStart": null,
"preStop": null,
"postStop": null
},
"metadata": {
"name": "",
"version": "",
"displayName": "",
description": "",
"tags": "",
"architectures": "",
"icon": "",
"globalMemoryLimit": "",
"projectType": "",
"language": "",
"website": "",
"provider": "",
"supportUrl": ""
}
}
'500':
description: Error updating the container
content:
application/json:
schema:
$ref: '#/components/schemas/GeneralError'
example:
message: "Error updating the container"

/devstate/image:
post:
tags:
Expand Down
1 change: 1 addition & 0 deletions pkg/apiserver-gen/.openapi-generator/FILES

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/apiserver-gen/go/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions pkg/apiserver-gen/go/api_devstate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 27 additions & 1 deletion pkg/apiserver-impl/devstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,33 @@ func (s *DevstateApiService) DevstateCompositeCommandCommandNamePatch(ctx contex
)
if err != nil {
return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{
Message: fmt.Sprintf("Error updating the Image Command: %s", err),
Message: fmt.Sprintf("Error updating the Composite Command: %s", err),
}), nil
}
return openapi.Response(http.StatusOK, newContent), nil
}

func (s *DevstateApiService) DevstateContainerContainerNamePatch(ctx context.Context, name string, patch openapi.DevstateContainerContainerNamePatchRequest) (openapi.ImplResponse, error) {
newContent, err := s.devfileState.PatchContainer(
name,
patch.Image,
patch.Command,
patch.Args,
patch.Env,
patch.MemReq,
patch.MemLimit,
patch.CpuReq,
patch.CpuLimit,
patch.VolumeMounts,
patch.ConfigureSources,
patch.MountSources,
patch.SourceMapping,
patch.Annotation,
patch.Endpoints,
)
if err != nil {
return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{
Message: fmt.Sprintf("Error updating the container: %s", err),
}), nil
}
return openapi.Response(http.StatusOK, newContent), nil
Expand Down
Loading