Skip to content

Commit

Permalink
Merge branch 'release/7.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
disaster37 committed Dec 20, 2019
2 parents 8677c52 + 4cb72dd commit fd3b931
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- ELASTICSEARCH_URLS: "http://es:9200"
- ELASTICSEARCH_USERNAME: "elastic"
- ELASTICSEARCH_PASSWORD: "changeme"
- image: docker.elastic.co/elasticsearch/elasticsearch:7.4.0
- image: docker.elastic.co/elasticsearch/elasticsearch:7.5.1
name: es
environment:
- cluster.name: "test"
Expand Down
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ We fork this project for the following items:

## Installation

[Download a binary](https://github.com/phillbaker/terraform-provider-elasticsearch/releases), and put it in a good spot on your system. Then update your `~/.terraformrc` to refer to the binary:
[Download a binary](https://github.com/disaster37/terraform-provider-elasticsearch/releases), and put it in a good spot on your system. Then update your `~/.terraformrc` to refer to the binary:

```hcl
providers {
Expand Down Expand Up @@ -66,7 +66,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch

***Sample:***
```tf
resource "elasticsearch_role" "test" {
resource elasticsearch_role "test" {
name = "terraform-test"
indices {
names = ["logstash-*"]
Expand Down Expand Up @@ -114,7 +114,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch

***Sample***:
```tf
resource "elasticsearch_role_mapping" "test" {
resource elasticsearch_role_mapping "test" {
name = "terraform-test"
enabled = "true"
roles = ["superuser"]
Expand Down Expand Up @@ -149,7 +149,7 @@ You can see the API documenation: https://www.elastic.co/guide/en/elasticsearch/

***Sample:***
```tf
resource "elasticsearch_user" "test" {
resource elasticsearch_user "test" {
username = "terraform-test"
enabled = "true"
email = "[email protected]"
Expand Down Expand Up @@ -182,7 +182,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch

***Sample:***
```tf
resource "elasticsearch_index_lifecycle_policy" "test" {
resource elasticsearch_index_lifecycle_policy "test" {
name = "terraform-test"
policy = <<EOF
{
Expand Down Expand Up @@ -226,7 +226,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch

***Sample:***
```tf
resource "elasticsearch_index_template" "test" {
resource elasticsearch_index_template "test" {
name = "terraform-test"
template = <<EOF
{
Expand Down Expand Up @@ -262,7 +262,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch

***Sample:***
```tf
resource "elasticsearch_license" "test" {
resource elasticsearch_license "test" {
use_basic_license = "true"
}
```
Expand All @@ -284,7 +284,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch

***Sample:***
```tf
resource "elasticsearch_snapshot_repository" "test" {
resource elasticsearch_snapshot_repository "test" {
name = "terraform-test"
type = "fs"
settings = {
Expand All @@ -310,7 +310,7 @@ You can see the API documentation: https://www.elastic.co/guide/en/elasticsearch

***Sample:***
```tf
resource "elasticsearch_snapshot_lifecycle_policy" "test" {
resource elasticsearch_snapshot_lifecycle_policy "test" {
name = "terraform-test"
snapshot_name = "<daily-snap-{now/d}>"
schedule = "0 30 1 * * ?"
Expand All @@ -321,6 +321,13 @@ resource "elasticsearch_snapshot_lifecycle_policy" "test" {
"ignore_unavailable": false,
"include_global_state": false
}
EOF
retention = <<EOF
{
"expire_after": "7d",
"min_count": 5,
"max_count": 10
}
EOF
}
```
Expand All @@ -331,7 +338,7 @@ EOF
- **schedule**: (required) A periodic or absolute time schedule.
- **repository**: (required) The snapshot repository that will contain snapshots created by this policy.
- **configs**: (optional) Configuration for each snapshot that will be created by this policy. It's a string as JSON object.

- **retention**: (optional) Retention rules used to retain and delete snapshots created by the policy. It's a string as JSON object.
___

### Watcher resource
Expand Down
8 changes: 8 additions & 0 deletions es/resource_elasticsearch_snapshot_lifecycle_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type SnapshotLifecyclePolicySpec struct {
Name string `json:"name"`
Repository string `json:"repository"`
Configs interface{} `json:"config,omitempty"`
Retention interface{} `json:"retention,omitempty"`
}

// SnapshotLifecyclePolicyGet is the policy
Expand Down Expand Up @@ -68,6 +69,10 @@ func resourceElasticsearchSnapshotLifecyclePolicy() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},
"retention": {
Type: schema.TypeString,
Optional: true,
},
},
}
}
Expand Down Expand Up @@ -147,6 +152,7 @@ func resourceElasticsearchSnapshotLifecyclePolicyRead(d *schema.ResourceData, me
d.Set("schedule", snapshotLifecyclePolicy[id].Policy.Schedule)
d.Set("repository", snapshotLifecyclePolicy[id].Policy.Repository)
d.Set("configs", snapshotLifecyclePolicy[id].Policy.Configs)
d.Set("retention", snapshotLifecyclePolicy[id].Policy.Retention)

return nil
}
Expand Down Expand Up @@ -191,12 +197,14 @@ func createSnapshotLifecyclePolicy(d *schema.ResourceData, meta interface{}) err
schedule := d.Get("schedule").(string)
repository := d.Get("repository").(string)
configs := optionalInterfaceJSON(d.Get("configs").(string))
retention := optionalInterfaceJSON(d.Get("retention").(string))

snapshotLifecyclePolicy := &SnapshotLifecyclePolicySpec{
Name: snapshotName,
Schedule: schedule,
Repository: repository,
Configs: configs,
Retention: retention,
}

b, err := json.Marshal(snapshotLifecyclePolicy)
Expand Down
16 changes: 15 additions & 1 deletion es/resource_elasticsearch_snapshot_lifecycle_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestAccElasticsearchSnapshotLifecyclePolicy(t *testing.T) {
ResourceName: "elasticsearch_snapshot_lifecycle_policy.test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"configs"},
ImportStateVerifyIgnore: []string{"configs", "retention"},
},
},
})
Expand Down Expand Up @@ -153,6 +153,13 @@ resource "elasticsearch_snapshot_lifecycle_policy" "test" {
"ignore_unavailable": false,
"include_global_state": false
}
EOF
retention = <<EOF
{
"expire_after": "7d",
"min_count": 5,
"max_count": 10
}
EOF
}
`
Expand All @@ -178,6 +185,13 @@ resource "elasticsearch_snapshot_lifecycle_policy" "test" {
"ignore_unavailable": false,
"include_global_state": false
}
EOF
retention = <<EOF
{
"expire_after": "7d",
"min_count": 5,
"max_count": 10
}
EOF
}
`
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/disaster37/terraform-provider-elasticsearch
module github.com/disaster37/terraform-provider-elasticsearch/v7

go 1.12

require (
github.com/elastic/go-elasticsearch/v7 v7.4.1
github.com/elastic/go-elasticsearch/v7 v7.5.0
github.com/hashicorp/terraform-plugin-sdk v1.1.1
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/pkg/errors v0.8.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ github.com/elastic/go-elasticsearch/v7 v7.4.0 h1:3gLL9l1hazy0ZYLpSoD40Z7hpuYvKlL
github.com/elastic/go-elasticsearch/v7 v7.4.0/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4=
github.com/elastic/go-elasticsearch/v7 v7.4.1 h1:Kd/cwKNF5+tABpJ0t39Aucvb5QtYc8RAzy4nwVn1NnM=
github.com/elastic/go-elasticsearch/v7 v7.4.1/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4=
github.com/elastic/go-elasticsearch/v7 v7.5.0 h1:kXW+EKls2BwsyQujTmVrxANb3U0qoz9wEq8Zkf/JEco=
github.com/elastic/go-elasticsearch/v7 v7.5.0/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Read the doc to use it: https://github.com/disaster37/terraform-provider-elastic
package main

import (
"github.com/disaster37/terraform-provider-elasticsearch/es"
"github.com/disaster37/terraform-provider-elasticsearch/v7/es"
"github.com/hashicorp/terraform-plugin-sdk/plugin"
)

Expand Down

0 comments on commit fd3b931

Please sign in to comment.