Skip to content

Commit

Permalink
Merge branch 'yandex-cloud:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
suslovsergey authored Aug 10, 2022
2 parents 4052880 + 6bcf22c commit 9f83faa
Show file tree
Hide file tree
Showing 24 changed files with 491 additions and 217 deletions.
4 changes: 3 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ builds:
ignore:
- goos: darwin
goarch: '386'
- goos: windows
goarch: arm64
binary: '{{ .ProjectName }}_v{{ .Version }}'
archives:
- format: zip
Expand All @@ -38,7 +40,7 @@ checksum:
signs:
- artifacts: checksum
args:
# if you are using this is a GitHub action or some other automated pipeline, you
# if you are using this is a GitHub action or some other automated pipeline, you
# need to pass the batch flag to indicate its not interactive.
- "--batch"
- "--local-user"
Expand Down
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
## 0.77.0 (Unreleased)
## 0.78.0 (Unreleased)
BUG FIXES:
* cdn: fixed wrong documentation example

FEATURES:
* greenplum: add `maintenance_window` attribute to resource and data source
* greenplum: support for changing the user's password
* greenplum: support for changing segment and master resources

## 0.77.0 (July 27, 2022)
BUG FIXES:
* iam: fix access bindings deletion
* ydb: fixed panic if database was removed outside of terraform
Expand All @@ -10,6 +19,7 @@ BUG FIXES:
ENHANCEMENTS:
* mdb: add `sqlcollation` attribute to `yandex_mdb_sqlserver_cluster` resource and data source
* serverless: increase operation timeouts in `yandex_function` resource
* cdn: added the ability to set custom `folder_id` attribute for resources `yandex_cdn_origin_group` and `yandex_cdn_resource`

FEATURES:
* k8s: add `instance_template.name` attribute to `node group` resource and data source
Expand Down
6 changes: 3 additions & 3 deletions website/docs/d/datasource_cdn_origin_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ The following arguments are supported:
* `name` - (Optional) Name of the origin group.
* `folder_id` - (Optional) Folder that the resource belongs to. If value is omitted, the default provider folder is used.
* `origins` -A set of available origins, an origins group must contain at least one enabled origin with fields:
- source (Required) - IP address or Domain name of your origin and the port;
- enabled (Optional) - the origin is enabled and used as a source for the CDN. Default is enabled.
- backup (Optional) - specifies whether the origin is used in its origin group as backup. A backup origin is used when one of active origins becomes unavailable.
* `source` (Required) - IP address or Domain name of your origin and the port;
* `enabled` (Optional) - the origin is enabled and used as a source for the CDN. Default is enabled.
* `backup` (Optional) - specifies whether the origin is used in its origin group as backup. A backup origin is used when one of active origins becomes unavailable.

~> **NOTE:** One of `origin_group_id` or `name` should be specified.
2 changes: 2 additions & 0 deletions website/docs/d/datasource_cdn_resource.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ The following arguments are supported:

* `cname` (Required) - CDN endpoint CNAME, must be unique among resources.

* `folder_id` (Optional) - Folder that the resource belongs to. If value is omitted, the default provider folder is used.

* `active` (Optional) - Flag to create Resource either in active or disabled state. True - the content from CDN is available to clients.

* `options` (Optional) - CDN Resource settings and options to tune CDN edge behavior.
Expand Down
6 changes: 6 additions & 0 deletions website/docs/d/datasource_mdb_greenplum_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ exported:
* `segment_hosts` - Info about hosts in segment subcluster. The structure is documented below.

* `access` - Access policy to the Greenplum cluster. The structure is documented below.
* `maintenance_window` - Maintenance window settings of the Greenplum cluster. The structure is documented below.
* `backup_window_start` - Time to start the daily backup, in the UTC timezone. The structure is documented below.

* `pooler_config` - Configuration of the connection pooler. The structure is documented below.
Expand Down Expand Up @@ -102,6 +103,11 @@ The `access` block supports:
* `data_lens` - Allow access for [Yandex DataLens](https://cloud.yandex.com/services/datalens).
* `web_sql` - Allows access for SQL queries in the management console.

The `maintenance_window` block supports:

* `type` - Type of maintenance window. Can be either `ANYTIME` or `WEEKLY`.
* `day` - Day of the week (in `DDD` format). Value is one of: "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"
* `hour` - Hour of the day in UTC (in `HH` format). Value is between 1 and 24.

The `pooler_config` block supports:

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/cdn_resource.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resource "yandex_cdn_resource" "my_resource" {
origin_group_id = yandex_cdn_origin_group.foo_cdn_group_by_id.id
options = {
options {
edge_cache_settings = 345600
ignore_cookie = true
}
Expand Down
10 changes: 10 additions & 0 deletions website/docs/r/mdb_greenplum_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ The following arguments are supported:

* `access` - (Optional) Access policy to the Greenplum cluster. The structure is documented below.

* `maintenance_window` - (Optional) Maintenance policy of the Greenplum cluster. The structure is documented below.

* `backup_window_start` - (Optional) Time to start the daily backup, in the UTC timezone. The structure is documented below.

* `pooler_config` - (Optional) Configuration of the connection pooler. The structure is documented below.
Expand Down Expand Up @@ -166,6 +168,14 @@ The `access` block supports:

* `web_sql` - Allows access for SQL queries in the management console

The `maintenance_window` block supports:

* `type` - (Required) Type of maintenance window. Can be either `ANYTIME` or `WEEKLY`. A day and hour of window need to be specified with weekly window.

* `day` - (Optional) Day of the week (in `DDD` format). Allowed values: "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"

* `hour` - (Optional) Hour of the day in UTC (in `HH` format). Allowed value is between 0 and 23.

The `pooler_config` block supports:

* `pooling_mode` - (Optional) Mode that the connection pooler is working in. See descriptions of all modes in the [documentation for Odyssey](https://github.com/yandex/odyssey/blob/master/documentation/configuration.md#pool-string.
Expand Down
20 changes: 20 additions & 0 deletions yandex/data_source_yandex_mdb_greenplum_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,26 @@ func dataSourceYandexMDBGreenplumCluster() *schema.Resource {
Set: schema.HashString,
Computed: true,
},
"maintenance_window": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"type": {
Type: schema.TypeString,
Computed: true,
},
"day": {
Type: schema.TypeString,
Computed: true,
},
"hour": {
Type: schema.TypeInt,
Computed: true,
},
},
},
},
"deletion_protection": {
Type: schema.TypeBool,
Computed: true,
Expand Down
5 changes: 1 addition & 4 deletions yandex/data_source_yandex_mdb_mysql_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,7 @@ func dataSourceYandexMDBMySQLClusterRead(d *schema.ResourceData, meta interface{
return err
}

backupWindowStart, err := flattenMysqlBackupWindowStart(cluster.GetConfig().GetBackupWindowStart())
if err != nil {
return err
}
backupWindowStart := flattenMDBBackupWindowStart(cluster.GetConfig().GetBackupWindowStart())
if err := d.Set("backup_window_start", backupWindowStart); err != nil {
return err
}
Expand Down
5 changes: 1 addition & 4 deletions yandex/data_source_yandex_mdb_sqlserver_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,10 +299,7 @@ func dataSourceYandexMDBSQLServerClusterRead(d *schema.ResourceData, meta interf
return err
}

backupWindowStart, err := flattenSQLServerBackupWindowStart(cluster.GetConfig().GetBackupWindowStart())
if err != nil {
return err
}
backupWindowStart := flattenMDBBackupWindowStart(cluster.GetConfig().GetBackupWindowStart())
if err = d.Set("backup_window_start", backupWindowStart); err != nil {
return err
}
Expand Down
92 changes: 76 additions & 16 deletions yandex/mdb_greenplum_structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,62 @@ func flattenGreenplumAccess(c *greenplum.GreenplumConfig) []map[string]interface
return []map[string]interface{}{out}
}

func flattenBackupWindowsStart(c *greenplum.GreenplumConfig) []map[string]interface{} {
out := map[string]interface{}{}
if c != nil && c.BackupWindowStart != nil {
out["hours"] = c.BackupWindowStart.Hours
out["minutes"] = c.BackupWindowStart.Minutes
func flattenGreenplumMaintenanceWindow(mw *greenplum.MaintenanceWindow) ([]interface{}, error) {
maintenanceWindow := map[string]interface{}{}
if mw != nil {
switch p := mw.GetPolicy().(type) {
case *greenplum.MaintenanceWindow_Anytime:
maintenanceWindow["type"] = "ANYTIME"
// do nothing
case *greenplum.MaintenanceWindow_WeeklyMaintenanceWindow:
maintenanceWindow["type"] = "WEEKLY"
maintenanceWindow["hour"] = p.WeeklyMaintenanceWindow.Hour
maintenanceWindow["day"] = greenplum.WeeklyMaintenanceWindow_WeekDay_name[int32(p.WeeklyMaintenanceWindow.GetDay())]
default:
return nil, fmt.Errorf("unsupported greenplum maintenance policy type")
}
}
return []map[string]interface{}{out}

return []interface{}{maintenanceWindow}, nil
}

func expandGreenplumMaintenanceWindow(d *schema.ResourceData) (*greenplum.MaintenanceWindow, error) {
if _, ok := d.GetOkExists("maintenance_window"); !ok {
return nil, nil
}

out := &greenplum.MaintenanceWindow{}
typeMW, _ := d.GetOk("maintenance_window.0.type")
if typeMW == "ANYTIME" {
if hour, ok := d.GetOk("maintenance_window.0.hour"); ok && hour != "" {
return nil, fmt.Errorf("hour should be not set, when using ANYTIME")
}
if day, ok := d.GetOk("maintenance_window.0.day"); ok && day != "" {
return nil, fmt.Errorf("day should be not set, when using ANYTIME")
}
out.Policy = &greenplum.MaintenanceWindow_Anytime{
Anytime: &greenplum.AnytimeMaintenanceWindow{},
}
} else if typeMW == "WEEKLY" {
hour := d.Get("maintenance_window.0.hour").(int)
dayString := d.Get("maintenance_window.0.day").(string)

day, ok := greenplum.WeeklyMaintenanceWindow_WeekDay_value[dayString]
if !ok || day == 0 {
return nil, fmt.Errorf(`day value should be one of ("MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN")`)
}

out.Policy = &greenplum.MaintenanceWindow_WeeklyMaintenanceWindow{
WeeklyMaintenanceWindow: &greenplum.WeeklyMaintenanceWindow{
Hour: int64(hour),
Day: greenplum.WeeklyMaintenanceWindow_WeekDay(day),
},
}
} else {
return nil, fmt.Errorf("maintenance_window.0.type should be ANYTIME or WEEKLY")
}

return out, nil
}

func flattenGreenplumClusterConfig(c *greenplum.ClusterConfigSet) (map[string]string, error) {
Expand Down Expand Up @@ -144,17 +193,28 @@ func expandGreenplumAccess(d *schema.ResourceData) *greenplum.Access {

func expandGreenplumUpdatePath(d *schema.ResourceData, settingNames []string) []string {
mdbGreenplumUpdateFieldsMap := map[string]string{
"name": "name",
"description": "description",
"labels": "labels",
"access.0.data_lens": "config.access.data_lens",
"access.0.web_sql": "config.access.web_sql",
"backup_window_start": "config.backup_window_start",
"deletion_protection": "deletion_protection",
"security_group_ids": "security_group_ids",
"pooler_config.0.pooling_mode": "config_spec.pool.mode",
"pooler_config.0.pool_size": "config_spec.pool.size",
"name": "name",
"description": "description",
"user_password": "user_password",
"labels": "labels",
"access.0.data_lens": "config.access.data_lens",
"access.0.web_sql": "config.access.web_sql",
"backup_window_start": "config.backup_window_start",
"maintenance_window": "maintenance_window",
"deletion_protection": "deletion_protection",
"security_group_ids": "security_group_ids",

"pooler_config.0.pooling_mode": "config_spec.pool.mode",
"pooler_config.0.pool_size": "config_spec.pool.size",
"pooler_config.0.pool_client_idle_timeout": "config_spec.pool.client_idle_timeout",

"master_subcluster.0.resources.0.resource_preset_id": "master_config.resources.resource_preset_id",
"master_subcluster.0.resources.0.disk_type_id": "master_config.resources.disk_type_id",
"master_subcluster.0.resources.0.disk_size": "master_config.resources.disk_size",

"segment_subcluster.0.resources.0.resource_preset_id": "segment_config.resources.resource_preset_id",
"segment_subcluster.0.resources.0.disk_type_id": "segment_config.resources.disk_type_id",
"segment_subcluster.0.resources.0.disk_size": "segment_config.resources.disk_size",
}

updatePath := []string{}
Expand Down
37 changes: 1 addition & 36 deletions yandex/mdb_mysql_structures.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/yandex-cloud/go-genproto/yandex/cloud/mdb/mysql/v1"
config "github.com/yandex-cloud/go-genproto/yandex/cloud/mdb/mysql/v1/config"
"github.com/yandex-cloud/terraform-provider-yandex/yandex/internal/hashcode"
"google.golang.org/genproto/googleapis/type/timeofday"
)

func parseMysqlEnv(e string) (mysql.Cluster_Environment, error) {
Expand Down Expand Up @@ -273,29 +272,6 @@ func flattenMysqlResources(r *mysql.Resources) ([]map[string]interface{}, error)
return []map[string]interface{}{res}, nil
}

func flattenMysqlBackupWindowStart(t *timeofday.TimeOfDay) ([]interface{}, error) {
out := map[string]interface{}{}

out["hours"] = int(t.Hours)
out["minutes"] = int(t.Minutes)

return []interface{}{out}, nil
}

func expandMysqlBackupWindowStart(d *schema.ResourceData) *timeofday.TimeOfDay {
out := &timeofday.TimeOfDay{}

if v, ok := d.GetOk("backup_window_start.0.hours"); ok {
out.Hours = int32(v.(int))
}

if v, ok := d.GetOk("backup_window_start.0.minutes"); ok {
out.Minutes = int32(v.(int))
}

return out
}

type compareMySQLHostsInfoResult struct {
hostsInfo map[string]*myHostInfo // fqdn -> *myHostInfo
createHostsInfo []*myHostInfo // hosts to be created
Expand Down Expand Up @@ -1345,17 +1321,6 @@ func expandMySQLMaintenanceWindow(d *schema.ResourceData) (*mysql.MaintenanceWin
return out, nil
}

func mysqlMaintenanceWindowSchemaValidateFunc(v interface{}, k string) (s []string, es []error) {
dayString := v.(string)
day, ok := mysql.WeeklyMaintenanceWindow_WeekDay_value[dayString]
if !ok || day == 0 {
es = append(es, fmt.Errorf(`expected %s value should be one of ("MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"). Current value is %v`, k, v))
return
}

return
}

func convertSQLModes57ToInt32(sqlModes []config.MysqlConfig5_7_SQLMode) []int32 {
modes := make([]int32, 0)
for _, v := range sqlModes {
Expand Down Expand Up @@ -1421,7 +1386,7 @@ func expandMySQLConfigSpec(d *schema.ResourceData) (*mysql.ConfigSpec, error) {
configSpec := &mysql.ConfigSpec{
Version: d.Get("version").(string),
Resources: expandMysqlResources(d),
BackupWindowStart: expandMysqlBackupWindowStart(d),
BackupWindowStart: expandMDBBackupWindowStart(d, "backup_window_start.0"),
Access: expandMySQLAccess(d),
PerformanceDiagnostics: expandMyPerformanceDiagnostics(d),
}
Expand Down
Loading

0 comments on commit 9f83faa

Please sign in to comment.