[ui] Edit volumes (#7061)

* Update volumes

* Proxy use ipv4

* Static ui files

* e2e tests
This commit is contained in:
Philippe Martin
2023-08-31 10:49:27 +02:00
committed by GitHub
parent 9089f9a637
commit 7ff38b7965
21 changed files with 387 additions and 14 deletions

View File

@@ -20,6 +20,7 @@ go/model__devstate_exec_command_post_request.go
go/model__devstate_image_post_request.go
go/model__devstate_quantity_valid_post_request.go
go/model__devstate_resource_post_request.go
go/model__devstate_volume__volume_name__patch_request.go
go/model__devstate_volume_post_request.go
go/model__instance_get_200_response.go
go/model_annotation.go

View File

@@ -53,6 +53,7 @@ type DevstateApiRouter interface {
DevstateResourceResourceNameDelete(http.ResponseWriter, *http.Request)
DevstateVolumePost(http.ResponseWriter, *http.Request)
DevstateVolumeVolumeNameDelete(http.ResponseWriter, *http.Request)
DevstateVolumeVolumeNamePatch(http.ResponseWriter, *http.Request)
}
// DefaultApiServicer defines the api actions for the DefaultApi service
@@ -96,4 +97,5 @@ type DevstateApiServicer interface {
DevstateResourceResourceNameDelete(context.Context, string) (ImplResponse, error)
DevstateVolumePost(context.Context, DevstateVolumePostRequest) (ImplResponse, error)
DevstateVolumeVolumeNameDelete(context.Context, string) (ImplResponse, error)
DevstateVolumeVolumeNamePatch(context.Context, string, DevstateVolumeVolumeNamePatchRequest) (ImplResponse, error)
}

View File

@@ -182,6 +182,12 @@ func (c *DevstateApiController) Routes() Routes {
"/api/v1/devstate/volume/{volumeName}",
c.DevstateVolumeVolumeNameDelete,
},
{
"DevstateVolumeVolumeNamePatch",
strings.ToUpper("Patch"),
"/api/v1/devstate/volume/{volumeName}",
c.DevstateVolumeVolumeNamePatch,
},
}
}
@@ -629,3 +635,29 @@ func (c *DevstateApiController) DevstateVolumeVolumeNameDelete(w http.ResponseWr
EncodeJSONResponse(result.Body, &result.Code, w)
}
// DevstateVolumeVolumeNamePatch -
func (c *DevstateApiController) DevstateVolumeVolumeNamePatch(w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)
volumeNameParam := params["volumeName"]
devstateVolumeVolumeNamePatchRequestParam := DevstateVolumeVolumeNamePatchRequest{}
d := json.NewDecoder(r.Body)
d.DisallowUnknownFields()
if err := d.Decode(&devstateVolumeVolumeNamePatchRequestParam); err != nil {
c.errorHandler(w, r, &ParsingError{Err: err}, nil)
return
}
if err := AssertDevstateVolumeVolumeNamePatchRequestRequired(devstateVolumeVolumeNamePatchRequestParam); err != nil {
c.errorHandler(w, r, err, nil)
return
}
result, err := c.service.DevstateVolumeVolumeNamePatch(r.Context(), volumeNameParam, devstateVolumeVolumeNamePatchRequestParam)
// 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)
}

View File

@@ -0,0 +1,36 @@
/*
* odo dev
*
* API interface for 'odo dev'
*
* API version: 0.1
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package openapi
type DevstateVolumeVolumeNamePatchRequest struct {
// Minimal size of the volume
Size string `json:"size,omitempty"`
// True if the Volume is Ephemeral
Ephemeral bool `json:"ephemeral,omitempty"`
}
// AssertDevstateVolumeVolumeNamePatchRequestRequired checks if the required fields are not zero-ed
func AssertDevstateVolumeVolumeNamePatchRequestRequired(obj DevstateVolumeVolumeNamePatchRequest) error {
return nil
}
// AssertRecurseDevstateVolumeVolumeNamePatchRequestRequired recursively checks if required fields are not zero-ed in a nested slice.
// Accepts only nested slice of DevstateVolumeVolumeNamePatchRequest (e.g. [][]DevstateVolumeVolumeNamePatchRequest), otherwise ErrTypeAssertionError is thrown.
func AssertRecurseDevstateVolumeVolumeNamePatchRequestRequired(objSlice interface{}) error {
return AssertRecurseInterfaceRequired(objSlice, func(obj interface{}) error {
aDevstateVolumeVolumeNamePatchRequest, ok := obj.(DevstateVolumeVolumeNamePatchRequest)
if !ok {
return ErrTypeAssertionError
}
return AssertDevstateVolumeVolumeNamePatchRequestRequired(aDevstateVolumeVolumeNamePatchRequest)
})
}

View File

@@ -297,3 +297,18 @@ func (s *DevstateApiService) DevstateDevfileDelete(context.Context) (openapi.Imp
}
return openapi.Response(http.StatusOK, newContent), nil
}
func (s *DevstateApiService) DevstateVolumeVolumeNamePatch(ctx context.Context, name string, patch openapi.DevstateVolumeVolumeNamePatchRequest) (openapi.ImplResponse, error) {
newContent, err := s.devfileState.PatchVolume(
name,
patch.Ephemeral,
patch.Size,
)
if err != nil {
return openapi.Response(http.StatusInternalServerError, openapi.GeneralError{
Message: fmt.Sprintf("Error updating the volume: %s", err),
}), nil
}
return openapi.Response(http.StatusOK, newContent), nil
}

View File

@@ -267,8 +267,32 @@ func (o *DevfileState) AddVolume(name string, ephemeral bool, size string) (Devf
return o.GetContent()
}
func (o *DevfileState) DeleteVolume(name string) (DevfileContent, error) {
func (o *DevfileState) PatchVolume(name string, ephemeral bool, size string) (DevfileContent, error) {
found, err := o.Devfile.Data.GetComponents(common.DevfileOptions{
ComponentOptions: common.ComponentOptions{
ComponentType: v1alpha2.VolumeComponentType,
},
FilterByName: name,
})
if err != nil {
return DevfileContent{}, err
}
if len(found) != 1 {
return DevfileContent{}, fmt.Errorf("%d Volume found with name %q", len(found), name)
}
volume := found[0]
volume.Volume.Ephemeral = &ephemeral
volume.Volume.Size = size
err = o.Devfile.Data.UpdateComponent(volume)
if err != nil {
return DevfileContent{}, err
}
return o.GetContent()
}
func (o *DevfileState) DeleteVolume(name string) (DevfileContent, error) {
err := o.checkVolumeUsed(name)
if err != nil {
return DevfileContent{}, fmt.Errorf("error deleting volume %q: %w", name, err)

View File

@@ -939,6 +939,47 @@ paths:
example:
message: "Error deleting the volume"
patch:
tags:
- devstate
description: "Update a volume"
parameters:
- name: volumeName
in: path
description: Volume name to update
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
type: object
properties:
size:
description: Minimal size of the volume
type: string
ephemeral:
description: True if the Volume is Ephemeral
type: boolean
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/GeneralSuccess'
example:
message: "Volume has been updated"
description: "Volume has been updated"
'500':
description: Error updating the volume
content:
application/json:
schema:
$ref: '#/components/schemas/GeneralError'
example:
message: "Error updating the volume"
/devstate/applyCommand:
post:
tags:

View File

@@ -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.fcdb01b1f229861f.js" type="module"></script>
<script src="runtime.1289ea0acffcdc5e.js" type="module"></script><script src="polyfills.8b3b37cedaf377c3.js" type="module"></script><script src="main.74249c789bca5336.js" type="module"></script>
</body></html>

File diff suppressed because one or more lines are too long