Skip to content

Commit

Permalink
Bump chart
Browse files Browse the repository at this point in the history
  • Loading branch information
xco-sk committed Feb 7, 2024
1 parent 65dfaea commit f39890d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ Configuration options are documented in [chart README file](charts/eck-custom-re

## Upgrade guide

### From 0.7.0 to 0.8.0
The CRD for Kibana DataView was changed - the `defaultView` field was added, to flag if the Data View should be configured as default in target instance Kibana. To update the CRD manually, run:
```
kubectl apply --server-side -f https://raw.githubusercontent.com/xco-sk/eck-custom-resources/v0.8.0/config/crd/bases/kibana.eck.github.com_dataviews.yaml
```

### From 0.6.0 to 0.7.0
There is a new `ComponentTemplate` CRD present. To apply the CRD, run:
```
Expand Down
15 changes: 8 additions & 7 deletions config/samples/kibana.eck_v1alpha1_dataview.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
apiVersion: kibana.eck.github.com/v1alpha1
kind: DataView
metadata:
name: dataview-sample
name: dataview-test2
spec:
targetInstance:
name: kibana-quickstart
space: space-sample
dependencies:
- type: lens
name: lens-sample
defaultView: true
# space: space-sample
# dependencies:
# - type: lens

# name: lens-sample
defaultView: false
body: |
{
"title": "sample-index-*",
"title": "sample-test2-*",
"type": "rollup",
"typeMeta": {
"params": {
Expand Down
14 changes: 8 additions & 6 deletions docs/cr_data_view.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ See [Data Views APIs](https://www.elastic.co/guide/en/kibana/current/data-views-
## Fields

| Key | Type | Description | Default |
|-----------------------------|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| `metadata.name` | string | Name of the Data View visualization, used also as its ID in Kibana | No default |
| `spec.space` | string | Name of the Kibana namespace to which the Data View is deployed to | No default (will be deployed to "default" namespace) |
| `spec.targetInstance.name` | string | Name of the [Kibana Instance](cr_kibana_instance.md) to which this DataView will be deployed to | The operator configuration |
| `spec.body` | string | Data View definition (the inner part of the requests) json | No default |
| `spec.dependencies` | List of objects | List of dependencies - the reconciler will wait for all resources from the list to be present in Kibana before deploying/updating this resource | - | |
| --------------------------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| `metadata.name` | string | Name of the Data View visualization, used also as its ID in Kibana | No default |
| `spec.space` | string | Name of the Kibana namespace to which the Data View is deployed to | No default (will be deployed to "default" namespace) |
| `spec.targetInstance.name` | string | Name of the [Kibana Instance](cr_kibana_instance.md) to which this DataView will be deployed to | The operator configuration |
| `spec.body` | string | Data View definition (the inner part of the requests) json | No default |
| `spec.defaultView` | boolean | Flag if the Data View should be configured as default in target instance Kibana | false |
| `spec.dependencies` | List of objects | List of dependencies - the reconciler will wait for all resources from the list to be present in Kibana before deploying/updating this resource | - | |
| `spec.dependencies[].space` | string | Kibana Space where to look for given resource | - |
| `spec.dependencies[].type` | string | Type of resource - one of `visualization, dashboard, search, index-pattern, lens` | - |
| `spec.dependencies[].name` | string | Name of resource | - |
Expand All @@ -39,6 +40,7 @@ spec:
dependencies:
- type: lens
name: lens-sample
defaultView: true
body: |
{
"title": "sample-index-*",
Expand Down
24 changes: 8 additions & 16 deletions utils/kibana/dataview_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ const REFRESH_FIELDS = true

func DeleteDataView(kClient Client, dataView kibanaeckv1alpha1.DataView) (ctrl.Result, error) {
_, deleteErr := kClient.DoDelete(formatExistingDataViewUrl(dataView.Name, dataView.Spec.Space))
if deleteErr != nil {
return ctrl.Result{}, deleteErr
}

defaultFlagErr := handleDefaultFlagOnDelete(dataView, kClient)

return ctrl.Result{}, defaultFlagErr
return ctrl.Result{}, deleteErr
}

func UpsertDataView(kClient Client, dataView kibanaeckv1alpha1.DataView) (ctrl.Result, error) {
Expand Down Expand Up @@ -142,21 +136,14 @@ func removeName(objectJson string, id string) (*string, error) {
}

func handleDefaultFlagOnUpsert(dataview kibanaeckv1alpha1.DataView, kClient Client) error {
if *dataview.Spec.DefaultView {
if dataview.Spec.DefaultView != nil && *dataview.Spec.DefaultView {
saveDefaultView(&dataview.Name, dataview.Spec.Space, kClient)
}
return nil
}

func handleDefaultFlagOnDelete(dataview kibanaeckv1alpha1.DataView, kClient Client) error {
if *dataview.Spec.DefaultView {
return saveDefaultView(nil, dataview.Spec.Space, kClient)
}
return nil
}

func saveDefaultView(dataViewName *string, space *string, kClient Client) error {
var body map[string]interface{}
body := make(map[string]interface{})
body["data_view_id"] = dataViewName
body["force"] = true

Expand All @@ -168,6 +155,11 @@ func saveDefaultView(dataViewName *string, space *string, kClient Client) error
return err
}

func getDefaultDataView(space *string, kClient Client) (*string, error) {
_, err = kClient.DoGet(formatDefaultDataViewUrl(space), string(marshalledBody))

}

func formatDefaultDataViewUrl(space *string) string {
if space == nil {
return "/api/data_views/default"
Expand Down

0 comments on commit f39890d

Please sign in to comment.