mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
[ui] Edit images (#7068)
* [api] Update Image * [ui] edit images * static ui files
This commit is contained in:
1
pkg/apiserver-gen/.openapi-generator/FILES
generated
1
pkg/apiserver-gen/.openapi-generator/FILES
generated
@@ -17,6 +17,7 @@ go/model__devstate_composite_command_post_request.go
|
||||
go/model__devstate_container_post_request.go
|
||||
go/model__devstate_events_put_request.go
|
||||
go/model__devstate_exec_command_post_request.go
|
||||
go/model__devstate_image__image_name__patch_request.go
|
||||
go/model__devstate_image_post_request.go
|
||||
go/model__devstate_quantity_valid_post_request.go
|
||||
go/model__devstate_resource__resource_name__patch_request.go
|
||||
|
||||
2
pkg/apiserver-gen/go/api.go
generated
2
pkg/apiserver-gen/go/api.go
generated
@@ -46,6 +46,7 @@ type DevstateApiRouter interface {
|
||||
DevstateEventsPut(http.ResponseWriter, *http.Request)
|
||||
DevstateExecCommandPost(http.ResponseWriter, *http.Request)
|
||||
DevstateImageImageNameDelete(http.ResponseWriter, *http.Request)
|
||||
DevstateImageImageNamePatch(http.ResponseWriter, *http.Request)
|
||||
DevstateImagePost(http.ResponseWriter, *http.Request)
|
||||
DevstateMetadataPut(http.ResponseWriter, *http.Request)
|
||||
DevstateQuantityValidPost(http.ResponseWriter, *http.Request)
|
||||
@@ -91,6 +92,7 @@ type DevstateApiServicer interface {
|
||||
DevstateEventsPut(context.Context, DevstateEventsPutRequest) (ImplResponse, error)
|
||||
DevstateExecCommandPost(context.Context, DevstateExecCommandPostRequest) (ImplResponse, error)
|
||||
DevstateImageImageNameDelete(context.Context, string) (ImplResponse, error)
|
||||
DevstateImageImageNamePatch(context.Context, string, DevstateImageImageNamePatchRequest) (ImplResponse, error)
|
||||
DevstateImagePost(context.Context, DevstateImagePostRequest) (ImplResponse, error)
|
||||
DevstateMetadataPut(context.Context, MetadataRequest) (ImplResponse, error)
|
||||
DevstateQuantityValidPost(context.Context, DevstateQuantityValidPostRequest) (ImplResponse, error)
|
||||
|
||||
32
pkg/apiserver-gen/go/api_devstate.go
generated
32
pkg/apiserver-gen/go/api_devstate.go
generated
@@ -140,6 +140,12 @@ func (c *DevstateApiController) Routes() Routes {
|
||||
"/api/v1/devstate/image/{imageName}",
|
||||
c.DevstateImageImageNameDelete,
|
||||
},
|
||||
{
|
||||
"DevstateImageImageNamePatch",
|
||||
strings.ToUpper("Patch"),
|
||||
"/api/v1/devstate/image/{imageName}",
|
||||
c.DevstateImageImageNamePatch,
|
||||
},
|
||||
{
|
||||
"DevstateImagePost",
|
||||
strings.ToUpper("Post"),
|
||||
@@ -492,6 +498,32 @@ func (c *DevstateApiController) DevstateImageImageNameDelete(w http.ResponseWrit
|
||||
|
||||
}
|
||||
|
||||
// DevstateImageImageNamePatch -
|
||||
func (c *DevstateApiController) DevstateImageImageNamePatch(w http.ResponseWriter, r *http.Request) {
|
||||
params := mux.Vars(r)
|
||||
imageNameParam := params["imageName"]
|
||||
devstateImageImageNamePatchRequestParam := DevstateImageImageNamePatchRequest{}
|
||||
d := json.NewDecoder(r.Body)
|
||||
d.DisallowUnknownFields()
|
||||
if err := d.Decode(&devstateImageImageNamePatchRequestParam); err != nil {
|
||||
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
|
||||
return
|
||||
}
|
||||
if err := AssertDevstateImageImageNamePatchRequestRequired(devstateImageImageNamePatchRequestParam); err != nil {
|
||||
c.errorHandler(w, r, err, nil)
|
||||
return
|
||||
}
|
||||
result, err := c.service.DevstateImageImageNamePatch(r.Context(), imageNameParam, devstateImageImageNamePatchRequestParam)
|
||||
// If an error occurred, encode the error with the status code
|
||||
if err != nil {
|
||||
c.errorHandler(w, r, err, &result)
|
||||
return
|
||||
}
|
||||
// If no error, encode the body and the result code
|
||||
EncodeJSONResponse(result.Body, &result.Code, w)
|
||||
|
||||
}
|
||||
|
||||
// DevstateImagePost -
|
||||
func (c *DevstateApiController) DevstateImagePost(w http.ResponseWriter, r *http.Request) {
|
||||
devstateImagePostRequestParam := DevstateImagePostRequest{}
|
||||
|
||||
41
pkg/apiserver-gen/go/model__devstate_image__image_name__patch_request.go
generated
Normal file
41
pkg/apiserver-gen/go/model__devstate_image__image_name__patch_request.go
generated
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* odo dev
|
||||
*
|
||||
* API interface for 'odo dev'
|
||||
*
|
||||
* API version: 0.1
|
||||
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
|
||||
*/
|
||||
|
||||
package openapi
|
||||
|
||||
type DevstateImageImageNamePatchRequest struct {
|
||||
ImageName string `json:"imageName,omitempty"`
|
||||
|
||||
Args []string `json:"args,omitempty"`
|
||||
|
||||
BuildContext string `json:"buildContext,omitempty"`
|
||||
|
||||
RootRequired bool `json:"rootRequired,omitempty"`
|
||||
|
||||
Uri string `json:"uri,omitempty"`
|
||||
|
||||
AutoBuild string `json:"autoBuild,omitempty"`
|
||||
}
|
||||
|
||||
// AssertDevstateImageImageNamePatchRequestRequired checks if the required fields are not zero-ed
|
||||
func AssertDevstateImageImageNamePatchRequestRequired(obj DevstateImageImageNamePatchRequest) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AssertRecurseDevstateImageImageNamePatchRequestRequired recursively checks if required fields are not zero-ed in a nested slice.
|
||||
// Accepts only nested slice of DevstateImageImageNamePatchRequest (e.g. [][]DevstateImageImageNamePatchRequest), otherwise ErrTypeAssertionError is thrown.
|
||||
func AssertRecurseDevstateImageImageNamePatchRequestRequired(objSlice interface{}) error {
|
||||
return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
|
||||
aDevstateImageImageNamePatchRequest, ok := obj.(DevstateImageImageNamePatchRequest)
|
||||
if !ok {
|
||||
return ErrTypeAssertionError
|
||||
}
|
||||
return AssertDevstateImageImageNamePatchRequestRequired(aDevstateImageImageNamePatchRequest)
|
||||
})
|
||||
}
|
||||
@@ -328,3 +328,22 @@ func (s *DevstateApiService) DevstateResourceResourceNamePatch(ctx context.Conte
|
||||
}
|
||||
return openapi.Response(http.StatusOK, newContent), nil
|
||||
}
|
||||
|
||||
func (s *DevstateApiService) DevstateImageImageNamePatch(ctx context.Context, name string, patch openapi.DevstateImageImageNamePatchRequest) (openapi.ImplResponse, error) {
|
||||
newContent, err := s.devfileState.PatchImage(
|
||||
name,
|
||||
patch.ImageName,
|
||||
patch.Args,
|
||||
patch.BuildContext,
|
||||
patch.RootRequired,
|
||||
patch.Uri,
|
||||
patch.AutoBuild,
|
||||
)
|
||||
if err != nil {
|
||||
return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{
|
||||
Message: fmt.Sprintf("Error updating the image: %s", err),
|
||||
}), nil
|
||||
}
|
||||
return openapi.Response(http.StatusOK, newContent), nil
|
||||
|
||||
}
|
||||
|
||||
@@ -165,6 +165,45 @@ func (o *DevfileState) AddImage(name string, imageName string, args []string, bu
|
||||
return o.GetContent()
|
||||
}
|
||||
|
||||
func (o *DevfileState) PatchImage(name string, imageName string, args []string, buildContext string, rootRequired bool, uri string, autoBuild string) (DevfileContent, error) {
|
||||
found, err := o.Devfile.Data.GetComponents(common.DevfileOptions{
|
||||
ComponentOptions: common.ComponentOptions{
|
||||
ComponentType: v1alpha2.ImageComponentType,
|
||||
},
|
||||
FilterByName: name,
|
||||
})
|
||||
if err != nil {
|
||||
return DevfileContent{}, err
|
||||
}
|
||||
if len(found) != 1 {
|
||||
return DevfileContent{}, fmt.Errorf("%d Image found with name %q", len(found), name)
|
||||
}
|
||||
|
||||
image := found[0]
|
||||
if image.Image == nil {
|
||||
image.Image = &v1alpha2.ImageComponent{}
|
||||
}
|
||||
image.Image.ImageName = imageName
|
||||
if image.Image.Dockerfile == nil {
|
||||
image.Image.Dockerfile = &v1alpha2.DockerfileImage{}
|
||||
}
|
||||
image.Image.Dockerfile.Args = args
|
||||
image.Image.Dockerfile.BuildContext = buildContext
|
||||
image.Image.Dockerfile.RootRequired = &rootRequired
|
||||
image.Image.Dockerfile.DockerfileSrc.Uri = uri
|
||||
image.Image.AutoBuild = nil
|
||||
if autoBuild == "never" {
|
||||
image.Image.AutoBuild = pointer.Bool(false)
|
||||
} else if autoBuild == "always" {
|
||||
image.Image.AutoBuild = pointer.Bool(true)
|
||||
}
|
||||
err = o.Devfile.Data.UpdateComponent(image)
|
||||
if err != nil {
|
||||
return DevfileContent{}, err
|
||||
}
|
||||
return o.GetContent()
|
||||
}
|
||||
|
||||
func (o *DevfileState) DeleteImage(name string) (DevfileContent, error) {
|
||||
|
||||
err := o.checkImageUsed(name)
|
||||
|
||||
@@ -757,6 +757,86 @@ paths:
|
||||
example:
|
||||
message: "Error deleting the image"
|
||||
|
||||
patch:
|
||||
tags:
|
||||
- devstate
|
||||
description: Update an image
|
||||
parameters:
|
||||
- name: imageName
|
||||
in: path
|
||||
description: Image name to update
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
imageName:
|
||||
type: string
|
||||
args:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
buildContext:
|
||||
type: string
|
||||
rootRequired:
|
||||
type: boolean
|
||||
uri:
|
||||
type: string
|
||||
autoBuild:
|
||||
type: string
|
||||
enum:
|
||||
- never
|
||||
- undefined
|
||||
- always
|
||||
responses:
|
||||
'200':
|
||||
description: image 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 image
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GeneralError'
|
||||
example:
|
||||
message: "Error updating the image"
|
||||
|
||||
/devstate/resource:
|
||||
post:
|
||||
tags:
|
||||
|
||||
2
pkg/apiserver-impl/ui/index.html
generated
2
pkg/apiserver-impl/ui/index.html
generated
@@ -11,6 +11,6 @@
|
||||
<body class="mat-typography">
|
||||
<div id="loading">Loading, please wait...</div>
|
||||
<app-root></app-root>
|
||||
<script src="runtime.1289ea0acffcdc5e.js" type="module"></script><script src="polyfills.8b3b37cedaf377c3.js" type="module"></script><script src="main.dccb7ac93e413890.js" type="module"></script>
|
||||
<script src="runtime.1289ea0acffcdc5e.js" type="module"></script><script src="polyfills.8b3b37cedaf377c3.js" type="module"></script><script src="main.bd69d1720b99cd4c.js" type="module"></script>
|
||||
|
||||
</body></html>
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user