Skip to content

Commit

Permalink
Support UpdateStrategy and DeleteOption (#99)
Browse files Browse the repository at this point in the history
* Support UpdateStrategy and DeleteOption

Signed-off-by: clyang82 <[email protected]>

* Return delete_option and update_strategy

Signed-off-by: clyang82 <[email protected]>

* Add e2e tests

Signed-off-by: clyang82 <[email protected]>

---------

Signed-off-by: clyang82 <[email protected]>
  • Loading branch information
clyang82 authored May 30, 2024
1 parent 15b243a commit 253a300
Show file tree
Hide file tree
Showing 19 changed files with 730 additions and 92 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,26 @@ ocm post /api/maestro/v1/resources << EOF
}
}
}
},
"update_strategy": {
"type": "ServerSideApply"
},
"delete_option": {
"propagationPolicy": "Foreground"
}
}
EOF

```
delete_option defines the option to delete the resource. It is optional when creating a resource. The propagationPolicy of `delete_option` can be:
- `Foreground` represents that the resource should be fourground deleted. This is a default value.
- `Orphan` represents that the resource is orphaned when deleting the resource.

update_strategy defines the strategy to update the resource. It is optional when creating a resource. The type of `update_strategy` can be:
- `ServerSideApply` means to update resource using server side apply with work-controller as the field manager. This is a default value.
- `Update` means to update resource by an update call.
- `CreateOnly` means do not update resource based on current manifest.
- `ReadOnly` means only check the existence of the resource based on the resource's metadata.

#### Get your Resource

Expand All @@ -219,6 +234,9 @@ ocm get /api/maestro/v1/resources
{
"consumer_name": "cluster1",
"created_at": "2023-11-23T09:26:13.43061Z",
"delete_option": {
"propagationPolicy":"Foreground"
},
"href": "/api/maestro/v1/resources/f428e21d-71cb-47a4-8d7f-82a65d9a4048",
"id": "f428e21d-71cb-47a4-8d7f-82a65d9a4048",
"kind": "Resource",
Expand Down Expand Up @@ -307,6 +325,9 @@ ocm get /api/maestro/v1/resources
"SequenceID": "1744926882802962432"
}
},
"update_strategy": {
"type":"ServerSideApply"
},
"updated_at": "2023-11-23T09:26:13.457419Z",
"version": 1
}
Expand Down
4 changes: 2 additions & 2 deletions data/generated/openapi/openapi.go

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,10 @@ components:
format: date-time
manifest:
type: object
delete_option:
type: object
update_strategy:
type: object
status:
type: object
ResourceList:
Expand All @@ -527,6 +531,10 @@ components:
type: integer
manifest:
type: object
delete_option:
type: object
update_strategy:
type: object
Consumer:
allOf:
- $ref: '#/components/schemas/ObjectReference'
Expand Down
10 changes: 10 additions & 0 deletions pkg/api/openapi/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -774,13 +774,19 @@ components:
- $ref: '#/components/schemas/ResourceList_allOf'
ResourcePatchRequest:
example:
delete_option: "{}"
update_strategy: "{}"
manifest: "{}"
version: 0
properties:
version:
type: integer
manifest:
type: object
delete_option:
type: object
update_strategy:
type: object
type: object
Consumer:
allOf:
Expand Down Expand Up @@ -834,6 +840,10 @@ components:
type: string
manifest:
type: object
delete_option:
type: object
update_strategy:
type: object
status:
type: object
type: object
Expand Down
52 changes: 52 additions & 0 deletions pkg/api/openapi/docs/Resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Name | Type | Description | Notes
**CreatedAt** | Pointer to **time.Time** | | [optional]
**UpdatedAt** | Pointer to **time.Time** | | [optional]
**Manifest** | Pointer to **map[string]interface{}** | | [optional]
**DeleteOption** | Pointer to **map[string]interface{}** | | [optional]
**UpdateStrategy** | Pointer to **map[string]interface{}** | | [optional]
**Status** | Pointer to **map[string]interface{}** | | [optional]

## Methods
Expand Down Expand Up @@ -259,6 +261,56 @@ SetManifest sets Manifest field to given value.

HasManifest returns a boolean if a field has been set.

### GetDeleteOption

`func (o *Resource) GetDeleteOption() map[string]interface{}`

GetDeleteOption returns the DeleteOption field if non-nil, zero value otherwise.

### GetDeleteOptionOk

`func (o *Resource) GetDeleteOptionOk() (*map[string]interface{}, bool)`

GetDeleteOptionOk returns a tuple with the DeleteOption field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetDeleteOption

`func (o *Resource) SetDeleteOption(v map[string]interface{})`

SetDeleteOption sets DeleteOption field to given value.

### HasDeleteOption

`func (o *Resource) HasDeleteOption() bool`

HasDeleteOption returns a boolean if a field has been set.

### GetUpdateStrategy

`func (o *Resource) GetUpdateStrategy() map[string]interface{}`

GetUpdateStrategy returns the UpdateStrategy field if non-nil, zero value otherwise.

### GetUpdateStrategyOk

`func (o *Resource) GetUpdateStrategyOk() (*map[string]interface{}, bool)`

GetUpdateStrategyOk returns a tuple with the UpdateStrategy field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetUpdateStrategy

`func (o *Resource) SetUpdateStrategy(v map[string]interface{})`

SetUpdateStrategy sets UpdateStrategy field to given value.

### HasUpdateStrategy

`func (o *Resource) HasUpdateStrategy() bool`

HasUpdateStrategy returns a boolean if a field has been set.

### GetStatus

`func (o *Resource) GetStatus() map[string]interface{}`
Expand Down
52 changes: 52 additions & 0 deletions pkg/api/openapi/docs/ResourceAllOf.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Name | Type | Description | Notes
**CreatedAt** | Pointer to **time.Time** | | [optional]
**UpdatedAt** | Pointer to **time.Time** | | [optional]
**Manifest** | Pointer to **map[string]interface{}** | | [optional]
**DeleteOption** | Pointer to **map[string]interface{}** | | [optional]
**UpdateStrategy** | Pointer to **map[string]interface{}** | | [optional]
**Status** | Pointer to **map[string]interface{}** | | [optional]

## Methods
Expand Down Expand Up @@ -181,6 +183,56 @@ SetManifest sets Manifest field to given value.

HasManifest returns a boolean if a field has been set.

### GetDeleteOption

`func (o *ResourceAllOf) GetDeleteOption() map[string]interface{}`

GetDeleteOption returns the DeleteOption field if non-nil, zero value otherwise.

### GetDeleteOptionOk

`func (o *ResourceAllOf) GetDeleteOptionOk() (*map[string]interface{}, bool)`

GetDeleteOptionOk returns a tuple with the DeleteOption field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetDeleteOption

`func (o *ResourceAllOf) SetDeleteOption(v map[string]interface{})`

SetDeleteOption sets DeleteOption field to given value.

### HasDeleteOption

`func (o *ResourceAllOf) HasDeleteOption() bool`

HasDeleteOption returns a boolean if a field has been set.

### GetUpdateStrategy

`func (o *ResourceAllOf) GetUpdateStrategy() map[string]interface{}`

GetUpdateStrategy returns the UpdateStrategy field if non-nil, zero value otherwise.

### GetUpdateStrategyOk

`func (o *ResourceAllOf) GetUpdateStrategyOk() (*map[string]interface{}, bool)`

GetUpdateStrategyOk returns a tuple with the UpdateStrategy field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetUpdateStrategy

`func (o *ResourceAllOf) SetUpdateStrategy(v map[string]interface{})`

SetUpdateStrategy sets UpdateStrategy field to given value.

### HasUpdateStrategy

`func (o *ResourceAllOf) HasUpdateStrategy() bool`

HasUpdateStrategy returns a boolean if a field has been set.

### GetStatus

`func (o *ResourceAllOf) GetStatus() map[string]interface{}`
Expand Down
52 changes: 52 additions & 0 deletions pkg/api/openapi/docs/ResourcePatchRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Version** | Pointer to **int32** | | [optional]
**Manifest** | Pointer to **map[string]interface{}** | | [optional]
**DeleteOption** | Pointer to **map[string]interface{}** | | [optional]
**UpdateStrategy** | Pointer to **map[string]interface{}** | | [optional]

## Methods

Expand Down Expand Up @@ -76,6 +78,56 @@ SetManifest sets Manifest field to given value.

HasManifest returns a boolean if a field has been set.

### GetDeleteOption

`func (o *ResourcePatchRequest) GetDeleteOption() map[string]interface{}`

GetDeleteOption returns the DeleteOption field if non-nil, zero value otherwise.

### GetDeleteOptionOk

`func (o *ResourcePatchRequest) GetDeleteOptionOk() (*map[string]interface{}, bool)`

GetDeleteOptionOk returns a tuple with the DeleteOption field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetDeleteOption

`func (o *ResourcePatchRequest) SetDeleteOption(v map[string]interface{})`

SetDeleteOption sets DeleteOption field to given value.

### HasDeleteOption

`func (o *ResourcePatchRequest) HasDeleteOption() bool`

HasDeleteOption returns a boolean if a field has been set.

### GetUpdateStrategy

`func (o *ResourcePatchRequest) GetUpdateStrategy() map[string]interface{}`

GetUpdateStrategy returns the UpdateStrategy field if non-nil, zero value otherwise.

### GetUpdateStrategyOk

`func (o *ResourcePatchRequest) GetUpdateStrategyOk() (*map[string]interface{}, bool)`

GetUpdateStrategyOk returns a tuple with the UpdateStrategy field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetUpdateStrategy

`func (o *ResourcePatchRequest) SetUpdateStrategy(v map[string]interface{})`

SetUpdateStrategy sets UpdateStrategy field to given value.

### HasUpdateStrategy

`func (o *ResourcePatchRequest) HasUpdateStrategy() bool`

HasUpdateStrategy returns a boolean if a field has been set.


[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
Loading

0 comments on commit 253a300

Please sign in to comment.