Skip to content

Commit

Permalink
Add field create_new_copies on kibana_copy_object
Browse files Browse the repository at this point in the history
Signed-off-by: disaster37 <[email protected]>
  • Loading branch information
disaster37 committed Sep 6, 2021
1 parent 6e9e806 commit ea91e04
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions kb/resource_kibana_copy_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ func resourceKibanaCopyObject() *schema.Resource {
Default: true,
},
"overwrite": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"create_new_copies": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Expand Down Expand Up @@ -98,6 +103,7 @@ func resourceKibanaCopyObjectRead(d *schema.ResourceData, meta interface{}) erro
objects := buildCopyObjects(d.Get("object").(*schema.Set).List())
includeReference := d.Get("include_reference").(bool)
overwrite := d.Get("overwrite").(bool)
createNewCopies := d.Get("create_new_copies").(bool)
forceUpdate := d.Get("force_update").(bool)

log.Debugf("Resource id: %s", id)
Expand All @@ -106,6 +112,7 @@ func resourceKibanaCopyObjectRead(d *schema.ResourceData, meta interface{}) erro
log.Debugf("Objects: %+v", objects)
log.Debugf("Include reference: %t", includeReference)
log.Debugf("Overwrite: %t", overwrite)
log.Debugf("CreateNewCopies: %t", createNewCopies)
log.Debugf("force_update: %t", forceUpdate)

// @ TODO
Expand All @@ -119,6 +126,7 @@ func resourceKibanaCopyObjectRead(d *schema.ResourceData, meta interface{}) erro
d.Set("object", objects)
d.Set("include_reference", includeReference)
d.Set("overwrite", overwrite)
d.Set("create_new_copies", createNewCopies)
d.Set("force_update", false)

log.Infof("Read resource %s successfully", id)
Expand Down Expand Up @@ -175,12 +183,14 @@ func copyObject(d *schema.ResourceData, meta interface{}) error {
objects := buildCopyObjects(d.Get("object").(*schema.Set).List())
includeReference := d.Get("include_reference").(bool)
overwrite := d.Get("overwrite").(bool)
createNewCopies := d.Get("create_new_copies").(bool)

log.Debugf("Source space: %s", sourceSpace)
log.Debugf("Target spaces: %+v", targetSpaces)
log.Debugf("Objects: %+v", objects)
log.Debugf("Include reference: %t", includeReference)
log.Debugf("Overwrite: %t", overwrite)
log.Debugf("CreateNewCopies: %t", createNewCopies)

client := meta.(*kibana.Client)

Expand All @@ -197,6 +207,7 @@ func copyObject(d *schema.ResourceData, meta interface{}) error {
Objects: objectsParameter,
IncludeReferences: includeReference,
Overwrite: overwrite,
CreateNewCopies: createNewCopies,
}

err := client.API.KibanaSpaces.CopySavedObjects(parameter, sourceSpace)
Expand Down
2 changes: 2 additions & 0 deletions kb/resource_kibana_copy_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ resource kibana_copy_object "test" {
id = "test"
type = "index-pattern"
}
overwrite = true
create_new_copies = false
depends_on = [kibana_object.test, kibana_user_space.test]
}
Expand Down

0 comments on commit ea91e04

Please sign in to comment.