Skip to content

Commit

Permalink
Composer GA update (#5492)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubasieron authored Jan 4, 2022
1 parent c41fbd1 commit 45405d8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ var (
"config.0.node_config",
"config.0.software_config",
"config.0.private_environment_config",
<% unless version == "ga" -%>
"config.0.web_server_network_access_control",
"config.0.database_config",
"config.0.web_server_config",
"config.0.encryption_config",
<% unless version == "ga" -%>
"config.0.maintenance_window",
<% end -%>
"config.0.workloads_config",
Expand Down Expand Up @@ -90,7 +90,6 @@ var (
"config.0.node_config.0.ip_allocation_policy.0.services_ipv4_cidr_block",
}

<% unless version == "ga" -%>
allowedIpRangesConfig = &schema.Resource{
Schema: map[string]*schema.Schema{
"value": {
Expand All @@ -106,8 +105,6 @@ var (
},
}

<% end -%>
<% unless version == "ga" -%>
cidrBlocks = &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -462,7 +459,6 @@ func resourceComposerEnvironment() *schema.Resource {
},
},
},
<% unless version == "ga" -%>
"web_server_network_access_control": {
Type: schema.TypeList,
Optional: true,
Expand All @@ -482,8 +478,6 @@ func resourceComposerEnvironment() *schema.Resource {
},
},
},
<% end -%>
<% unless version == "ga" -%>
"database_config": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -536,6 +530,7 @@ func resourceComposerEnvironment() *schema.Resource {
},
},
},
<% unless version == "ga" -%>
"maintenance_window": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -975,7 +970,6 @@ func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{})
}
}

<% unless version == "ga" -%>
if d.HasChange("config.0.database_config.0.machine_type") {
patchObj := &composer.Environment{Config: &composer.EnvironmentConfig{}}
if config != nil {
Expand All @@ -998,6 +992,7 @@ func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{})
}
}

<% unless version == "ga" -%>
if d.HasChange("config.0.maintenance_window") {
patchObj := &composer.Environment{Config: &composer.EnvironmentConfig{}}
if config != nil {
Expand Down Expand Up @@ -1159,11 +1154,11 @@ func flattenComposerEnvironmentConfig(envCfg *composer.EnvironmentConfig) interf
transformed["node_config"] = flattenComposerEnvironmentConfigNodeConfig(envCfg.NodeConfig)
transformed["software_config"] = flattenComposerEnvironmentConfigSoftwareConfig(envCfg.SoftwareConfig)
transformed["private_environment_config"] = flattenComposerEnvironmentConfigPrivateEnvironmentConfig(envCfg.PrivateEnvironmentConfig)
<% unless version == "ga" -%>
transformed["web_server_network_access_control"] = flattenComposerEnvironmentConfigWebServerNetworkAccessControl(envCfg.WebServerNetworkAccessControl)
transformed["database_config"] = flattenComposerEnvironmentConfigDatabaseConfig(envCfg.DatabaseConfig)
transformed["web_server_config"] = flattenComposerEnvironmentConfigWebServerConfig(envCfg.WebServerConfig)
transformed["encryption_config"] = flattenComposerEnvironmentConfigEncryptionConfig(envCfg.EncryptionConfig)
<% unless version == "ga" -%>
transformed["maintenance_window"] = flattenComposerEnvironmentConfigMaintenanceWindow(envCfg.MaintenanceWindow)
<% end -%>
transformed["workloads_config"] = flattenComposerEnvironmentConfigWorkloadsConfig(envCfg.WorkloadsConfig)
Expand All @@ -1174,7 +1169,6 @@ func flattenComposerEnvironmentConfig(envCfg *composer.EnvironmentConfig) interf
return []interface{}{transformed}
}

<% unless version == "ga" -%>
func flattenComposerEnvironmentConfigWebServerNetworkAccessControl(accessControl *composer.WebServerNetworkAccessControl) interface{} {
if accessControl == nil || accessControl.AllowedIpRanges == nil {
return nil
Expand All @@ -1195,9 +1189,7 @@ func flattenComposerEnvironmentConfigWebServerNetworkAccessControl(accessControl

return []interface{}{webServerNetworkAccessControl}
}
<% end -%>

<% unless version == "ga" -%>
func flattenComposerEnvironmentConfigDatabaseConfig(databaseCfg *composer.DatabaseConfig) interface{} {
if databaseCfg == nil {
return nil
Expand Down Expand Up @@ -1231,6 +1223,8 @@ func flattenComposerEnvironmentConfigEncryptionConfig(encryptionCfg *composer.En
return []interface{}{transformed}
}

<% unless version == "ga" -%>

func flattenComposerEnvironmentConfigMaintenanceWindow(maintenanceWindow *composer.MaintenanceWindow) interface{} {
if maintenanceWindow == nil {
return nil
Expand Down Expand Up @@ -1435,16 +1429,12 @@ func expandComposerEnvironmentConfig(v interface{}, d *schema.ResourceData, conf
}
transformed.PrivateEnvironmentConfig = transformedPrivateEnvironmentConfig

<% unless version == "ga" -%>
transformedWebServerNetworkAccessControl, err := expandComposerEnvironmentConfigWebServerNetworkAccessControl(original["web_server_network_access_control"], d, config)
if err != nil {
return nil, err
}
transformed.WebServerNetworkAccessControl = transformedWebServerNetworkAccessControl

<% end -%>
<% unless version == "ga" -%>
transformedDatabaseConfig, err := expandComposerEnvironmentConfigDatabaseConfig(original["database_config"], d, config)
if err != nil {
return nil, err
Expand All @@ -1463,6 +1453,7 @@ func expandComposerEnvironmentConfig(v interface{}, d *schema.ResourceData, conf
}
transformed.EncryptionConfig = transformedEncryptionConfig

<% unless version == "ga" -%>
transformedMaintenanceWindow, err := expandComposerEnvironmentConfigMaintenanceWindow(original["maintenance_window"], d, config)
if err != nil {
return nil, err
Expand Down Expand Up @@ -1497,7 +1488,6 @@ func expandComposerEnvironmentConfigNodeCount(v interface{}, d *schema.ResourceD
return int64(v.(int)), nil
}

<% unless version == "ga" -%>
func expandComposerEnvironmentConfigWebServerNetworkAccessControl(v interface{}, d *schema.ResourceData, config *Config) (*composer.WebServerNetworkAccessControl, error) {
l := v.([]interface{})
if len(l) == 0 {
Expand Down Expand Up @@ -1527,8 +1517,6 @@ func expandComposerEnvironmentConfigWebServerNetworkAccessControl(v interface{},
return transformed, nil
}

<% end -%>
<% unless version == "ga" -%>
func expandComposerEnvironmentConfigMasterAuthorizedNetworksConfig(v interface{}, d *schema.ResourceData, config *Config) (*composer.MasterAuthorizedNetworksConfig, error) {
l := v.([]interface{})
Expand Down Expand Up @@ -1559,7 +1547,6 @@ func expandComposerEnvironmentConfigMasterAuthorizedNetworksConfig(v interface{}

<% end -%>

<% unless version == "ga" -%>
func expandComposerEnvironmentConfigDatabaseConfig(v interface{}, d *schema.ResourceData, config *Config) (*composer.DatabaseConfig, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand Down Expand Up @@ -1588,9 +1575,6 @@ func expandComposerEnvironmentConfigWebServerConfig(v interface{}, d *schema.Res
return transformed, nil
}

<% end -%>
<% unless version == "ga" -%>
func expandComposerEnvironmentConfigEncryptionConfig(v interface{}, d *schema.ResourceData, config *Config) (*composer.EncryptionConfig, error) {
l := v.([]interface{})
if len(l) == 0 || l[0] == nil {
Expand All @@ -1605,6 +1589,7 @@ func expandComposerEnvironmentConfigEncryptionConfig(v interface{}, d *schema.Re
return transformed, nil
}

<% unless version == "ga" -%>
func expandComposerEnvironmentConfigMaintenanceWindow(v interface{}, d *schema.ResourceData, config *Config) (*composer.MaintenanceWindow, error) {
l := v.([]interface{})
if len(l) == 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ func TestAccComposerEnvironment_private(t *testing.T) {
})
}

<% unless version == "ga" -%>
// Checks environment creation with minimum required information.
func TestAccComposerEnvironment_privateWithWebServerControl(t *testing.T) {
t.Parallel()
Expand Down Expand Up @@ -222,9 +221,6 @@ func TestAccComposerEnvironment_privateWithWebServerControl(t *testing.T) {
})
}

<% end -%>
<% unless version == "ga" -%>
func TestAccComposerEnvironment_withDatabaseConfig(t *testing.T) {
t.Parallel()
envName := fmt.Sprintf("%s-%d", testComposerEnvironmentPrefix, randInt(t))
Expand Down Expand Up @@ -330,6 +326,7 @@ func TestAccComposerEnvironment_withEncryptionConfig(t *testing.T) {
})
}

<% unless version == "ga" -%>
func TestAccComposerEnvironment_withMaintenanceWindow(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -843,7 +840,6 @@ resource "google_compute_subnetwork" "test" {
`, name, network, subnetwork)
}

<% unless version == "ga" -%>
func testAccComposerEnvironment_privateWithWebServerControl(name, network, subnetwork string) string {
return fmt.Sprintf(`
resource "google_composer_environment" "test" {
Expand Down Expand Up @@ -948,9 +944,6 @@ resource "google_compute_subnetwork" "test" {
`, name, network, subnetwork)
}

<% end -%>
<% unless version == "ga" -%>
func testAccComposerEnvironment_databaseCfg(name, network, subnetwork string) string {
return fmt.Sprintf(`
resource "google_composer_environment" "test" {
Expand Down Expand Up @@ -1150,6 +1143,7 @@ resource "google_compute_subnetwork" "test" {
`, pid, kmsKey, name, kmsKey, network, subnetwork)
}

<% unless version == "ga" -%>
func testAccComposerEnvironment_maintenanceWindow(pid, envName, network, subnetwork string) string {
return fmt.Sprintf(`
resource "google_composer_environment" "test" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,25 +291,21 @@ The following arguments are supported:
The configuration used for the Private IP Cloud Composer environment. Structure is [documented below](#nested_private_environment_config).

* `web_server_network_access_control` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html),
Cloud Composer 1 only)
(Optional, Cloud Composer 1 only)
The network-level access control policy for the Airflow web server.
If unspecified, no network-level access restrictions are applied.

* `database_config` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html),
Cloud Composer 1 only)
(Optional, Cloud Composer 1 only)
The configuration settings for Cloud SQL instance used internally
by Apache Airflow software.

* `web_server_config` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html),
Cloud Composer 1 only)
(Optional, Cloud Composer 1 only)
The configuration settings for the Airflow web server App Engine instance.

* `encryption_config` -
(Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html),
Cloud Composer 1 only)
(Optional, Cloud Composer 1 only)
The encryption options for the Cloud Composer environment and its
dependencies.

Expand Down

0 comments on commit 45405d8

Please sign in to comment.