Skip to content

Commit

Permalink
Merge branch 'IBM-Cloud:master' into POWERIAAS-6670-EPIC
Browse files Browse the repository at this point in the history
  • Loading branch information
bhagyagkwd authored Aug 10, 2022
2 parents b597f22 + dcdcef7 commit 109bbdd
Show file tree
Hide file tree
Showing 32 changed files with 67 additions and 6,786 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.16
require (
github.com/IBM-Cloud/bluemix-go v0.0.0-20220523145737-34645883de47
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20220622142911-811d18c8c775
github.com/IBM-Cloud/power-go-client v1.1.10
github.com/IBM-Cloud/power-go-client v1.1.11
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca
github.com/IBM/appconfiguration-go-admin-sdk v0.2.3
github.com/IBM/appid-management-go-sdk v0.0.0-20210908164609-dd0e0eaf732f
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20220622142911-811d18c8c77
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
github.com/IBM-Cloud/power-go-client v1.1.10 h1:NUGZwF5V0j2lFurA5LaigsYyOKDKwz4M0sCpm+YIbig=
github.com/IBM-Cloud/power-go-client v1.1.10/go.mod h1:Qfx0fNi+9hms+xu9Z6Euhu9088ByW6C/TCMLECTRWNE=
github.com/IBM-Cloud/power-go-client v1.1.11 h1:/qTWCCuSZsmiksvQSfhM+mZKkY/Vli/W6b82WoYD2NM=
github.com/IBM-Cloud/power-go-client v1.1.11/go.mod h1:Qfx0fNi+9hms+xu9Z6Euhu9088ByW6C/TCMLECTRWNE=
github.com/IBM-Cloud/softlayer-go v1.0.5-tf h1:koUAyF9b6X78lLLruGYPSOmrfY2YcGYKOj/Ug9nbKNw=
github.com/IBM-Cloud/softlayer-go v1.0.5-tf/go.mod h1:6HepcfAXROz0Rf63krk5hPZyHT6qyx2MNvYyHof7ik4=
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca h1:crniVcf+YcmgF03NmmfonXwSQ73oJF+IohFYBwknMxs=
Expand Down
46 changes: 0 additions & 46 deletions ibm/conns/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ import (
resourcecontroller "github.com/IBM/platform-services-go-sdk/resourcecontrollerv2"
resourcemanager "github.com/IBM/platform-services-go-sdk/resourcemanagerv2"
"github.com/IBM/push-notifications-go-sdk/pushservicev1"
"github.com/IBM/scc-go-sdk/findingsv1"
"github.com/IBM/scc-go-sdk/v3/adminserviceapiv1"
"github.com/IBM/scc-go-sdk/v3/configurationgovernancev1"
"github.com/IBM/scc-go-sdk/v3/posturemanagementv2"
Expand Down Expand Up @@ -286,7 +285,6 @@ type ClientSession interface {
AtrackerV1() (*atrackerv1.AtrackerV1, error)
AtrackerV2() (*atrackerv2.AtrackerV2, error)
ESschemaRegistrySession() (*schemaregistryv1.SchemaregistryV1, error)
FindingsV1() (*findingsv1.FindingsV1, error)
AdminServiceApiV1() (*adminserviceapiv1.AdminServiceApiV1, error)
ConfigurationGovernanceV1() (*configurationgovernancev1.ConfigurationGovernanceV1, error)
PostureManagementV1() (*posturemanagementv1.PostureManagementV1, error)
Expand Down Expand Up @@ -580,10 +578,6 @@ type clientSession struct {
esSchemaRegistryClient *schemaregistryv1.SchemaregistryV1
esSchemaRegistryErr error

// Security and Compliance Center (SCC)
findingsClient *findingsv1.FindingsV1
findingsClientErr error

// Security and Compliance Center (SCC) Admin
adminServiceApiClient *adminserviceapiv1.AdminServiceApiV1
adminServiceApiClientErr error
Expand Down Expand Up @@ -1123,14 +1117,6 @@ func (session clientSession) ESschemaRegistrySession() (*schemaregistryv1.Schema
return session.esSchemaRegistryClient, session.esSchemaRegistryErr
}

// Security and Compliance center Findings API
func (session clientSession) FindingsV1() (*findingsv1.FindingsV1, error) {
if session.findingsClientErr != nil {
return session.findingsClient, session.findingsClientErr
}
return session.findingsClient.Clone(), nil
}

//Security and Compliance center Admin API
func (session clientSession) AdminServiceApiV1() (*adminserviceapiv1.AdminServiceApiV1, error) {
return session.adminServiceApiClient, session.adminServiceApiClientErr
Expand Down Expand Up @@ -1646,38 +1632,6 @@ func (c *Config) ClientSession() (interface{}, error) {
session.atrackerClientV2Err = fmt.Errorf("Error occurred while configuring Activity Tracker API Version 2 service: %q", err)
}

// SCC FINDINGS Service
var findingsClientURL string
if c.Visibility == "public" || c.Visibility == "public-and-private" {
findingsClientURL, err = findingsv1.GetServiceURLForRegion(c.Region)
if err != nil {
session.findingsClientErr = fmt.Errorf("[ERROR] Error occurred while configuring Security Insights Findings API service: `%s` region not supported", c.Region)
}
} else {
session.findingsClientErr = fmt.Errorf("[ERROR] Error occurred while configuring Security Insights Findings API service: `%v` visibility not supported", c.Visibility)
}
if fileMap != nil && c.Visibility != "public-and-private" {
findingsClientURL = fileFallBack(fileMap, c.Visibility, "IBMCLOUD_SCC_FINDINGS_API_ENDPOINT", c.Region, findingsClientURL)
}
findingsClientOptions := &findingsv1.FindingsV1Options{
Authenticator: authenticator,
URL: EnvFallBack([]string{"IBMCLOUD_SCC_FINDINGS_API_ENDPOINT"}, findingsClientURL),
AccountID: core.StringPtr(userConfig.UserAccount),
}
// Construct the service client.
session.findingsClient, err = findingsv1.NewFindingsV1(findingsClientOptions)
if err != nil {
session.findingsClientErr = fmt.Errorf("[ERROR] Error occurred while configuring Security Insights Findings API service: %q", err)
}
if session.findingsClient != nil && session.findingsClient.Service != nil {
// Enable retries for API calls
session.findingsClient.Service.EnableRetries(c.RetryCount, c.RetryDelay)
// Add custom header for analytics
session.findingsClient.SetDefaultHeaders(gohttp.Header{
"X-Original-User-Agent": {fmt.Sprintf("terraform-provider-ibm/%s", version.Version)},
})
}

// SCC ADMIN Service
var adminServiceApiClientURL string
if c.Visibility == "private" || c.Visibility == "public-and-private" {
Expand Down
11 changes: 0 additions & 11 deletions ibm/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,15 +625,10 @@ func Provider() *schema.Provider {
"ibm_atracker_endpoints": atracker.DataSourceIBMAtrackerEndpoints(),

//Security and Compliance Center
"ibm_scc_si_providers": scc.DataSourceIBMSccSiProviders(),
"ibm_scc_si_note": scc.DataSourceIBMSccSiNote(),
"ibm_scc_si_notes": scc.DataSourceIBMSccSiNotes(),
"ibm_scc_account_location": scc.DataSourceIBMSccAccountLocation(),
"ibm_scc_account_locations": scc.DataSourceIBMSccAccountLocations(),
"ibm_scc_account_location_settings": scc.DataSourceIBMSccAccountLocationSettings(),
"ibm_scc_account_notification_settings": scc.DataSourceIBMSccNotificationSettings(),
"ibm_scc_si_occurrence": scc.DataSourceIBMSccSiOccurrence(),
"ibm_scc_si_occurrences": scc.DataSourceIBMSccSiOccurrences(),

// Compliance Posture Management
"ibm_scc_posture_scopes": scc.DataSourceIBMSccPostureScopes(),
Expand Down Expand Up @@ -1048,9 +1043,7 @@ func Provider() *schema.Provider {
"ibm_atracker_settings": atracker.ResourceIBMAtrackerSettings(),

// //Security and Compliance Center
"ibm_scc_si_note": scc.ResourceIBMSccSiNote(),
"ibm_scc_account_settings": scc.ResourceIBMSccAccountSettings(),
"ibm_scc_si_occurrence": scc.ResourceIBMSccSiOccurrence(),
"ibm_scc_rule": scc.ResourceIBMSccRule(),
"ibm_scc_rule_attachment": scc.ResourceIBMSccRuleAttachment(),
"ibm_scc_template": scc.ResourceIBMSccTemplate(),
Expand Down Expand Up @@ -1252,9 +1245,7 @@ func Validator() validate.ValidatorDict {
"ibm_atracker_route": atracker.ResourceIBMAtrackerRouteValidator(),
"ibm_atracker_settings": atracker.ResourceIBMAtrackerSettingsValidator(),
"ibm_satellite_endpoint": satellite.ResourceIBMSatelliteEndpointValidator(),
"ibm_scc_si_note": scc.ResourceIBMSccSiNoteValidator(),
"ibm_scc_account_settings": scc.ResourceIBMSccAccountSettingsValidator(),
"ibm_scc_si_occurrence": scc.ResourceIBMSccSiOccurrenceValidator(),
"ibm_scc_posture_collector": scc.ResourceIBMSccPostureCollectorsValidator(),
"ibm_scc_posture_scope": scc.ResourceIBMSccPostureScopesValidator(),
"ibm_scc_posture_credential": scc.ResourceIBMSccPostureCredentialsValidator(),
Expand Down Expand Up @@ -1311,8 +1302,6 @@ func Validator() validate.ValidatorDict {

"ibm_is_vpc": vpc.DataSourceIBMISVpcValidator(),
"ibm_is_volume": vpc.DataSourceIBMISVolumeValidator(),
"ibm_scc_si_notes": scc.DataSourceIBMSccSiNotesValidator(),
"ibm_scc_si_occurrences": scc.DataSourceIBMSccSiOccurrencesValidator(),
"ibm_secrets_manager_secret": secretsmanager.DataSourceIBMSecretsManagerSecretValidator(),
"ibm_secrets_manager_secrets": secretsmanager.DataSourceIBMSecretsManagerSecretsValidator(),
},
Expand Down
1 change: 1 addition & 0 deletions ibm/service/power/ibm_pi_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const (
Arg_DhcpCloudConnectionID = "pi_cloud_connection_id"
Arg_DhcpDnsServer = "pi_dns_server"
Arg_DhcpName = "pi_dhcp_name"
Arg_DhcpSnatEnabled = "pi_dhcp_snat_enabled"

Attr_DhcpServers = "servers"
Attr_DhcpID = "dhcp_id"
Expand Down
9 changes: 9 additions & 0 deletions ibm/service/power/resource_ibm_pi_dhcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ func ResourceIBMPIDhcp() *schema.Resource {
Description: "Optional name of DHCP Service (will be prefixed by DHCP identifier)",
ForceNew: true,
},
Arg_DhcpSnatEnabled: {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: "Indicates if SNAT will be enabled for the DHCP service",
ForceNew: true,
},

// Attributes
Attr_DhcpID: {
Expand Down Expand Up @@ -144,6 +151,8 @@ func resourceIBMPIDhcpCreate(ctx context.Context, d *schema.ResourceData, meta i
n := name.(string)
body.Name = &n
}
snatEnabled := d.Get(Arg_DhcpSnatEnabled).(bool)
body.SnatEnabled = &snatEnabled

// create dhcp
client := st.NewIBMPIDhcpClient(ctx, sess, cloudInstanceID)
Expand Down
27 changes: 27 additions & 0 deletions ibm/service/power/resource_ibm_pi_dhcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,30 @@ func testAccCheckIBMPIDhcpWithCidrNameConfig(name string) string {
}
`, acc.Pi_cloud_instance_id, name)
}

func TestAccIBMPIDhcpSNAT(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { acc.TestAccPreCheck(t) },
Providers: acc.TestAccProviders,
CheckDestroy: testAccCheckIBMPIDhcpDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckIBMPIDhcpConfigWithSNATDisabled(),
Check: resource.ComposeTestCheckFunc(
testAccCheckIBMPIDhcpExists("ibm_pi_dhcp.dhcp_service"),
resource.TestCheckResourceAttrSet(
"ibm_pi_dhcp.dhcp_service", "dhcp_id"),
),
},
},
})
}

func testAccCheckIBMPIDhcpConfigWithSNATDisabled() string {
return fmt.Sprintf(`
resource "ibm_pi_dhcp" "dhcp_service" {
pi_cloud_instance_id = "%s"
pi_dhcp_snat_enabled = false
}
`, acc.Pi_cloud_instance_id)
}
Loading

0 comments on commit 109bbdd

Please sign in to comment.