From 88ae9a71841d0d8377bfb84a64a0db6529e5ce78 Mon Sep 17 00:00:00 2001 From: Clayton Huff Date: Tue, 13 Sep 2022 16:11:12 -0400 Subject: [PATCH 1/3] support rhel8 in attach script and run fmt --- ibm/acctest/acctest.go | 10 +- ibm/conns/config.go | 14 +-- ibm/conns/config_functions.go | 4 +- ibm/flex/structures.go | 2 +- .../resource_ibm_compute_vm_instance.go | 4 +- .../resource_ibm_dns_record.go | 16 ++-- .../resource_ibm_dns_reverse_record.go | 16 ++-- .../resource_ibm_firewall_shared.go | 7 +- .../resource_ibm_multi_vlan_firewall.go | 4 +- .../resource_ibm_network_gateway.go | 4 +- ibm/service/cos/resource_ibm_cos_bucket.go | 2 +- .../cos/resource_ibm_cos_bucket_test.go | 3 +- .../resource_ibm_enterprise_account_test.go | 7 +- ibm/service/functions/qualified_name.go | 91 +++++++++++-------- ibm/service/kms/resource_ibm_kms_key.go | 2 +- .../data_source_ibm_pi_catalog_images.go | 1 - .../power/data_source_ibm_pi_images.go | 1 - .../power/resource_ibm_pi_volume_test.go | 2 +- .../data_source_ibm_satellite_host_script.go | 36 ++++++-- ...a_source_ibm_satellite_host_script_test.go | 2 +- .../resource_ibm_satellite_cluster.go | 2 +- ibm/validate/validators.go | 17 ++-- version/version.go | 2 +- 23 files changed, 140 insertions(+), 109 deletions(-) diff --git a/ibm/acctest/acctest.go b/ibm/acctest/acctest.go index 75fdc81b5f8..393b7f89d10 100644 --- a/ibm/acctest/acctest.go +++ b/ibm/acctest/acctest.go @@ -141,17 +141,17 @@ var Image_operating_system string var Tg_cross_network_account_id string var Tg_cross_network_id string -//Enterprise Management +// Enterprise Management var Account_to_be_imported string // Secuity and Complinace Center, Governance var Scc_gov_account_id string var Scc_resource_group_id string -//Security and Compliance Center, SI +// Security and Compliance Center, SI var Scc_si_account string -//Security and Compliance Center, Posture Management +// Security and Compliance Center, Posture Management var Scc_posture_scope_id string var Scc_posture_scan_id string var Scc_posture_profile_id string @@ -167,14 +167,14 @@ var Scc_posture_collector_id_scope_update []string var Scc_posture_collector_id string var Scc_posture_credential_id string -//ROKS Cluster +// ROKS Cluster var ClusterName string // Satellite instance var Satellite_location_id string var Satellite_Resource_instance_id string -//Dedicated host +// Dedicated host var HostPoolID string // Continuous Delivery diff --git a/ibm/conns/config.go b/ibm/conns/config.go index f6d6d10491d..d28ccd77683 100644 --- a/ibm/conns/config.go +++ b/ibm/conns/config.go @@ -120,14 +120,14 @@ import ( // RetryAPIDelay - retry api delay const RetryAPIDelay = 5 * time.Second -//BluemixRegion ... +// BluemixRegion ... var BluemixRegion string var ( errEmptyBluemixCredentials = errors.New("ibmcloud_api_key or bluemix_api_key or iam_token and iam_refresh_token must be provided. Please see the documentation on how to configure it") ) -//UserConfig ... +// UserConfig ... type UserConfig struct { UserID string UserEmail string @@ -137,7 +137,7 @@ type UserConfig struct { generation int `default:"2"` } -//Config stores user provider input +// Config stores user provider input type Config struct { //BluemixAPIKey is the Bluemix api key BluemixAPIKey string @@ -192,7 +192,7 @@ type Config struct { EndpointsFile string } -//Session stores the information required for communication with the SoftLayer and Bluemix API +// Session stores the information required for communication with the SoftLayer and Bluemix API type Session struct { // SoftLayerSesssion is the the SoftLayer session used to connect to the SoftLayer API SoftLayerSession *slsession.Session @@ -751,7 +751,7 @@ func (sess clientSession) CertificateManagerAPI() (certificatemanager.Certificat return sess.certManagementAPI, sess.certManagementErr } -//apigatewayAPI provides API Gateway APIs +// apigatewayAPI provides API Gateway APIs func (sess clientSession) APIGateway() (*apigateway.ApiGatewayControllerApiV1, error) { return sess.apigatewayAPI, sess.apigatewayErr } @@ -1117,7 +1117,7 @@ func (session clientSession) ESschemaRegistrySession() (*schemaregistryv1.Schema return session.esSchemaRegistryClient, session.esSchemaRegistryErr } -//Security and Compliance center Admin API +// Security and Compliance center Admin API func (session clientSession) AdminServiceApiV1() (*adminserviceapiv1.AdminServiceApiV1, error) { return session.adminServiceApiClient, session.adminServiceApiClientErr } @@ -1134,7 +1134,7 @@ func (session clientSession) PostureManagementV1() (*posturemanagementv1.Posture return session.postureManagementClient.Clone(), nil } -//Security and Compliance center Posture Management v2 +// Security and Compliance center Posture Management v2 func (session clientSession) PostureManagementV2() (*posturemanagementv2.PostureManagementV2, error) { if session.postureManagementClientErrv2 != nil { return session.postureManagementClientv2, session.postureManagementClientErrv2 diff --git a/ibm/conns/config_functions.go b/ibm/conns/config_functions.go index a827288262f..5e185bee582 100644 --- a/ibm/conns/config_functions.go +++ b/ibm/conns/config_functions.go @@ -19,7 +19,7 @@ import ( // DefaultServiceURL is the default URL to make service requests to. const DefaultServiceURL = "https://us-south.functions.cloud.ibm.com" -//FunctionClient ... +// FunctionClient ... func FunctionClient(c *bluemix.Config) (*whisk.Client, error) { baseEndpoint := getBaseURL(c.Region) u, err := url.Parse(fmt.Sprintf("%s/api", baseEndpoint)) @@ -35,7 +35,7 @@ func FunctionClient(c *bluemix.Config) (*whisk.Client, error) { return functionsClient, err } -//getBaseURL .. +// getBaseURL .. func getBaseURL(region string) string { baseEndpoint := fmt.Sprintf(DefaultServiceURL) if region != "us-south" { diff --git a/ibm/flex/structures.go b/ibm/flex/structures.go index c554c0f2342..46a44cfa92d 100644 --- a/ibm/flex/structures.go +++ b/ibm/flex/structures.go @@ -78,7 +78,7 @@ const ( isLBType = "type" ) -//HashInt ... +// HashInt ... func HashInt(v interface{}) int { return v.(int) } func ExpandStringList(input []interface{}) []string { diff --git a/ibm/service/classicinfrastructure/resource_ibm_compute_vm_instance.go b/ibm/service/classicinfrastructure/resource_ibm_compute_vm_instance.go index f53c1c8b7a3..77788fd3018 100644 --- a/ibm/service/classicinfrastructure/resource_ibm_compute_vm_instance.go +++ b/ibm/service/classicinfrastructure/resource_ibm_compute_vm_instance.go @@ -1711,8 +1711,8 @@ func detachSecurityGroupNetworkComponentBindings(d *schema.ResourceData, meta in return nil } -//genID generates a random string to be used for the optional -//hostname +// genID generates a random string to be used for the optional +// hostname func genID() (interface{}, error) { numBytes := 8 bytes := make([]byte, numBytes) diff --git a/ibm/service/classicinfrastructure/resource_ibm_dns_record.go b/ibm/service/classicinfrastructure/resource_ibm_dns_record.go index 0240bba4ae7..507b3f09305 100644 --- a/ibm/service/classicinfrastructure/resource_ibm_dns_record.go +++ b/ibm/service/classicinfrastructure/resource_ibm_dns_record.go @@ -189,8 +189,8 @@ func ResourceIBMDNSRecord() *schema.Resource { } } -// Creates DNS Domain Resource Record -// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain_ResourceRecord/createObject +// Creates DNS Domain Resource Record +// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain_ResourceRecord/createObject func resourceIBMDNSRecordCreate(d *schema.ResourceData, meta interface{}) error { sess := meta.(conns.ClientSession).SoftLayerSession() service := services.GetDnsDomainResourceRecordService(sess.SetRetries(0)) @@ -277,8 +277,8 @@ func resourceIBMDNSRecordCreate(d *schema.ResourceData, meta interface{}) error return resourceIBMDNSRecordRead(d, meta) } -// Reads DNS Domain Resource Record from SL system -// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain_ResourceRecord/getObject +// Reads DNS Domain Resource Record from SL system +// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain_ResourceRecord/getObject func resourceIBMDNSRecordRead(d *schema.ResourceData, meta interface{}) error { sess := meta.(conns.ClientSession).SoftLayerSession() service := services.GetDnsDomainResourceRecordService(sess) @@ -318,8 +318,8 @@ func resourceIBMDNSRecordRead(d *schema.ResourceData, meta interface{}) error { return nil } -// Updates DNS Domain Resource Record in SL system -// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain_ResourceRecord/editObject +// Updates DNS Domain Resource Record in SL system +// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain_ResourceRecord/editObject func resourceIBMDNSRecordUpdate(d *schema.ResourceData, meta interface{}) error { sess := meta.(conns.ClientSession).SoftLayerSession() service := services.GetDnsDomainResourceRecordService(sess) @@ -412,8 +412,8 @@ func resourceIBMDNSRecordUpdate(d *schema.ResourceData, meta interface{}) error return nil } -// Deletes DNS Domain Resource Record in SL system -// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain_ResourceRecord/deleteObject +// Deletes DNS Domain Resource Record in SL system +// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain_ResourceRecord/deleteObject func resourceIBMDNSRecordDelete(d *schema.ResourceData, meta interface{}) error { sess := meta.(conns.ClientSession).SoftLayerSession() service := services.GetDnsDomainResourceRecordService(sess) diff --git a/ibm/service/classicinfrastructure/resource_ibm_dns_reverse_record.go b/ibm/service/classicinfrastructure/resource_ibm_dns_reverse_record.go index 970413cd16b..f185fae992d 100644 --- a/ibm/service/classicinfrastructure/resource_ibm_dns_reverse_record.go +++ b/ibm/service/classicinfrastructure/resource_ibm_dns_reverse_record.go @@ -46,8 +46,8 @@ func ResourceIBMDNSReverseRecord() *schema.Resource { } } -// Creates DNS Domain Reverse Record -// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain/CreatePtrRecord +// Creates DNS Domain Reverse Record +// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain/CreatePtrRecord func resourceIBMDNSREVERSERecordCreate(d *schema.ResourceData, meta interface{}) error { sess := meta.(conns.ClientSession).SoftLayerSession() service := services.GetDnsDomainService(sess.SetRetries(0)) @@ -68,8 +68,8 @@ func resourceIBMDNSREVERSERecordCreate(d *schema.ResourceData, meta interface{}) return resourceIBMDNSREVERSERecordRead(d, meta) } -// Reads DNS Domain Reverse Record from SL system -// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain_ResourceRecord/getObject +// Reads DNS Domain Reverse Record from SL system +// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain_ResourceRecord/getObject func resourceIBMDNSREVERSERecordRead(d *schema.ResourceData, meta interface{}) error { sess := meta.(conns.ClientSession).SoftLayerSession() service := services.GetDnsDomainResourceRecordService(sess) @@ -85,8 +85,8 @@ func resourceIBMDNSREVERSERecordRead(d *schema.ResourceData, meta interface{}) e return nil } -// Updates DNS Domain Reverse Record in SL system -// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain_ResourceRecord/editObject +// Updates DNS Domain Reverse Record in SL system +// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain_ResourceRecord/editObject func resourceIBMDNSREVERSERecordUpdate(d *schema.ResourceData, meta interface{}) error { sess := meta.(conns.ClientSession).SoftLayerSession() service := services.GetDnsDomainResourceRecordService(sess) @@ -110,8 +110,8 @@ func resourceIBMDNSREVERSERecordUpdate(d *schema.ResourceData, meta interface{}) return nil } -// Deletes DNS Domain Reverse Record in SL system -// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain_ResourceRecord/deleteObject +// Deletes DNS Domain Reverse Record in SL system +// https://sldn.softlayer.com/reference/services/SoftLayer_Dns_Domain_ResourceRecord/deleteObject func resourceIBMDNSREVERSERecordDelete(d *schema.ResourceData, meta interface{}) error { sess := meta.(conns.ClientSession).SoftLayerSession() service := services.GetDnsDomainResourceRecordService(sess) diff --git a/ibm/service/classicinfrastructure/resource_ibm_firewall_shared.go b/ibm/service/classicinfrastructure/resource_ibm_firewall_shared.go index 4142858d3c2..8c6df2c2436 100644 --- a/ibm/service/classicinfrastructure/resource_ibm_firewall_shared.go +++ b/ibm/service/classicinfrastructure/resource_ibm_firewall_shared.go @@ -68,7 +68,8 @@ func ResourceIBMFirewallShared() *schema.Resource { } // keyName is in between:[10MBPS_HARDWARE_FIREWALL, 20MBPS_HARDWARE_FIREWALL, -// 100MBPS_HARDWARE_FIREWALL, 1000MBPS_HARDWARE_FIREWALL] +// +// 100MBPS_HARDWARE_FIREWALL, 1000MBPS_HARDWARE_FIREWALL] func resourceIBMFirewallSharedCreate(d *schema.ResourceData, meta interface{}) error { sess := meta.(conns.ClientSession).SoftLayerSession() @@ -255,7 +256,7 @@ func resourceIBMFirewallSharedRead(d *schema.ResourceData, meta interface{}) err return nil } -//detach hardware firewall from particular machine +// detach hardware firewall from particular machine func resourceIBMFirewallSharedDelete(d *schema.ResourceData, meta interface{}) error { sess := meta.(conns.ClientSession).SoftLayerSession() idd2 := (d.Get("billing_item_id")).(int) @@ -272,7 +273,7 @@ func resourceIBMFirewallSharedDelete(d *schema.ResourceData, meta interface{}) e return nil } -//exists method +// exists method func resourceIBMFirewallSharedExists(d *schema.ResourceData, meta interface{}) (bool, error) { sess := meta.(conns.ClientSession).SoftLayerSession() fservice := services.GetNetworkComponentFirewallService(sess) diff --git a/ibm/service/classicinfrastructure/resource_ibm_multi_vlan_firewall.go b/ibm/service/classicinfrastructure/resource_ibm_multi_vlan_firewall.go index b51e16443bd..8e3ddd44ba3 100644 --- a/ibm/service/classicinfrastructure/resource_ibm_multi_vlan_firewall.go +++ b/ibm/service/classicinfrastructure/resource_ibm_multi_vlan_firewall.go @@ -412,8 +412,8 @@ func resourceIBMMultiVLanFirewallExists(d *schema.ResourceData, meta interface{} return true, nil } -//This function takes two lists and returns the difference between the two lists -//listdifference([1,2] [2,3]) = [1] +// This function takes two lists and returns the difference between the two lists +// listdifference([1,2] [2,3]) = [1] func listdifference(a, b []string) []string { mb := map[string]bool{} for _, x := range b { diff --git a/ibm/service/classicinfrastructure/resource_ibm_network_gateway.go b/ibm/service/classicinfrastructure/resource_ibm_network_gateway.go index ab7cc6e250b..b838d9300cd 100644 --- a/ibm/service/classicinfrastructure/resource_ibm_network_gateway.go +++ b/ibm/service/classicinfrastructure/resource_ibm_network_gateway.go @@ -1049,8 +1049,8 @@ func setTagsAndNotes(m gatewayMember, meta interface{}) error { return nil } -//New types to resuse functions from other resources which does the same job -//Essentially mimic schema.ResourceData get functions +// New types to resuse functions from other resources which does the same job +// Essentially mimic schema.ResourceData get functions type dataRetriever interface { Get(string) interface{} GetOk(string) (interface{}, bool) diff --git a/ibm/service/cos/resource_ibm_cos_bucket.go b/ibm/service/cos/resource_ibm_cos_bucket.go index 4af5208a86f..6f138b1de28 100644 --- a/ibm/service/cos/resource_ibm_cos_bucket.go +++ b/ibm/service/cos/resource_ibm_cos_bucket.go @@ -1589,7 +1589,7 @@ func SelectCosApi(apiType string, bLocation string) (string, string, string) { return "", "", "" } -///Satellite ENdpoint configuration +// /Satellite ENdpoint configuration func SelectSatlocCosApi(apiType string, serviceID string, bLocation string) string { if apiType == "sl" { return fmt.Sprintf("s3.%s.%s.cloud-object-storage.appdomain.cloud", serviceID, bLocation) diff --git a/ibm/service/cos/resource_ibm_cos_bucket_test.go b/ibm/service/cos/resource_ibm_cos_bucket_test.go index b4f2c6c51fa..5f6c5875270 100644 --- a/ibm/service/cos/resource_ibm_cos_bucket_test.go +++ b/ibm/service/cos/resource_ibm_cos_bucket_test.go @@ -670,7 +670,6 @@ func TestAccIBMCosBucket_import(t *testing.T) { }) } -// // Satellite location func TestAccIBMCosBucket_Satellite(t *testing.T) { @@ -1027,7 +1026,7 @@ func testAccCheckIBMCosBucket_Satellite_Exists(resource string, bucket string, r } } -/// IBMCLOUD +// / IBMCLOUD func testAccCheckIBMCosBucketExists(resource string, bucket string, regiontype string, region string, bucketname string) resource.TestCheckFunc { return func(s *terraform.State) error { diff --git a/ibm/service/enterprise/resource_ibm_enterprise_account_test.go b/ibm/service/enterprise/resource_ibm_enterprise_account_test.go index 1893b0b7081..f7ec873bf03 100644 --- a/ibm/service/enterprise/resource_ibm_enterprise_account_test.go +++ b/ibm/service/enterprise/resource_ibm_enterprise_account_test.go @@ -54,8 +54,11 @@ func TestAccIbmEnterpriseAccountBasic(t *testing.T) { }) } -/* To run this test case ensure the IC_API_KEY belongs to an enterprise. -ACCOUNT_TO_BE_IMPORTED should invite enterprise and grant relevant iam policies before running this test case" */ +/* + To run this test case ensure the IC_API_KEY belongs to an enterprise. + +ACCOUNT_TO_BE_IMPORTED should invite enterprise and grant relevant iam policies before running this test case" +*/ func TestAccIbmEnterpriseImportAccountBasic(t *testing.T) { var conf enterprisemanagementv1.Account resource.Test(t, resource.TestCase{ diff --git a/ibm/service/functions/qualified_name.go b/ibm/service/functions/qualified_name.go index 6b5dfdfe1a8..105195868db 100644 --- a/ibm/service/functions/qualified_name.go +++ b/ibm/service/functions/qualified_name.go @@ -22,9 +22,11 @@ type QualifiedName struct { // QualifiedName Methods // /////////////////////////// -// GetFullQualifiedName() returns a full qualified name in proper string format -// from qualifiedName with proper syntax. -// Example: /namespace/[package/]entity +// GetFullQualifiedName() returns a full qualified name in proper string format +// +// from qualifiedName with proper syntax. +// +// Example: /namespace/[package/]entity func (qualifiedName *QualifiedName) GetFullQualifiedName() string { output := []string{} @@ -39,42 +41,47 @@ func (qualifiedName *QualifiedName) GetFullQualifiedName() string { return strings.Join(output, "") } -// GetPackageName() returns the package name from qualifiedName without a -// leading '/' +// GetPackageName() returns the package name from qualifiedName without a +// +// leading '/' func (qualifiedName *QualifiedName) GetPackageName() string { return qualifiedName.packageName } -// GetEntityName() returns the entity name ([package/]entity) of qualifiedName -// without a leading '/' +// GetEntityName() returns the entity name ([package/]entity) of qualifiedName +// +// without a leading '/' func (qualifiedName *QualifiedName) GetEntityName() string { return qualifiedName.EntityName } -// GetEntity() returns the name of entity in qualifiedName without a leading '/' +// GetEntity() returns the name of entity in qualifiedName without a leading '/' func (qualifiedName *QualifiedName) GetEntity() string { return qualifiedName.entity } -// GetNamespace() returns the name of the namespace in qualifiedName without -// a leading '/' +// GetNamespace() returns the name of the namespace in qualifiedName without +// +// a leading '/' func (qualifiedName *QualifiedName) GetNamespace() string { return qualifiedName.namespace } -// NewQualifiedName(name) initializes and constructs a (possibly fully qualified) -// QualifiedName struct. +// NewQualifiedName(name) initializes and constructs a (possibly fully qualified) +// +// QualifiedName struct. +// +// NOTE: If the given qualified name is None, then this is a default qualified +// name and it is resolved from properties. +// NOTE: If the namespace is missing from the qualified name, the namespace +// is also resolved from the property file. // -// NOTE: If the given qualified name is None, then this is a default qualified -// name and it is resolved from properties. -// NOTE: If the namespace is missing from the qualified name, the namespace -// is also resolved from the property file. +// Examples: // -// Examples: -// foo => qualifiedName {namespace: "_", entityName: foo} -// pkg/foo => qualifiedName {namespace: "_", entityName: pkg/foo} -// /ns/foo => qualifiedName {namespace: ns, entityName: foo} -// /ns/pkg/foo => qualifiedName {namespace: ns, entityName: pkg/foo} +// foo => qualifiedName {namespace: "_", entityName: foo} +// pkg/foo => qualifiedName {namespace: "_", entityName: pkg/foo} +// /ns/foo => qualifiedName {namespace: ns, entityName: foo} +// /ns/pkg/foo => qualifiedName {namespace: ns, entityName: pkg/foo} func NewQualifiedName(name string) (*QualifiedName, error) { qualifiedName := new(QualifiedName) @@ -122,15 +129,17 @@ func NewQualifiedName(name string) (*QualifiedName, error) { // Error Functions // ///////////////////// -// qualifiedNameNotSpecifiedErr() returns generic whisk error for -// invalid qualified names detected while building a new -// QualifiedName struct. +// qualifiedNameNotSpecifiedErr() returns generic whisk error for +// +// invalid qualified names detected while building a new +// QualifiedName struct. func qualifiedNameNotSpecifiedErr() error { return errors.New("[ERROR] valid qualified name must be specified") } -// NewQualifiedNameError(entityName, err) returns specific whisk error -// for invalid qualified names. +// NewQualifiedNameError(entityName, err) returns specific whisk error +// +// for invalid qualified names. func NewQualifiedNameError(entityName string, err error) error { errorMsg := fmt.Sprintf("%s is not a alid qualified name %s", entityName, err) return errors.New(errorMsg) @@ -140,9 +149,10 @@ func NewQualifiedNameError(entityName string, err error) error { // Helper/Misc Functions // /////////////////////////// -// addLeadSlash(name) returns a (possibly fully qualified) resource name, -// inserting a leading '/' if it is of 3 parts (namespace/package/action) -// and lacking the leading '/'. +// addLeadSlash(name) returns a (possibly fully qualified) resource name, +// +// inserting a leading '/' if it is of 3 parts (namespace/package/action) +// and lacking the leading '/'. func addLeadSlash(name string) string { parts := strings.Split(name, "/") if len(parts) == 3 && parts[0] != "" { @@ -151,22 +161,25 @@ func addLeadSlash(name string) string { return name } -// getNamespaceFromProp() returns a namespace from Properties if one exists, -// else defaults to returning "_" +// getNamespaceFromProp() returns a namespace from Properties if one exists, +// +// else defaults to returning "_" func getNamespaceFromProp() string { namespace := os.Getenv("FUNCTION_NAMESPACE") return namespace } -// getQualifiedName(name, namespace) returns a fully qualified name given a -// (possibly fully qualified) resource name and optional namespace. +// getQualifiedName(name, namespace) returns a fully qualified name given a +// +// (possibly fully qualified) resource name and optional namespace. +// +// Examples: // -// Examples: -// (foo, None) => /_/foo -// (pkg/foo, None) => /_/pkg/foo -// (foo, ns) => /ns/foo -// (/ns/pkg/foo, None) => /ns/pkg/foo -// (/ns/pkg/foo, otherns) => /ns/pkg/foo +// (foo, None) => /_/foo +// (pkg/foo, None) => /_/pkg/foo +// (foo, ns) => /ns/foo +// (/ns/pkg/foo, None) => /ns/pkg/foo +// (/ns/pkg/foo, otherns) => /ns/pkg/foo func getQualifiedName(name string, namespace string) string { name = addLeadSlash(name) if strings.HasPrefix(name, "/") { diff --git a/ibm/service/kms/resource_ibm_kms_key.go b/ibm/service/kms/resource_ibm_kms_key.go index b42a00574aa..2487dac3073 100644 --- a/ibm/service/kms/resource_ibm_kms_key.go +++ b/ibm/service/kms/resource_ibm_kms_key.go @@ -446,7 +446,7 @@ func resourceIBMKmsKeyExists(d *schema.ResourceData, meta interface{}) (bool, er } -//Construct KMS URL +// Construct KMS URL func KmsEndpointURL(kpAPI *kp.Client, endpointType string, extensions map[string]interface{}) (*url.URL, error) { exturl := extensions["endpoints"].(map[string]interface{})["public"] diff --git a/ibm/service/power/data_source_ibm_pi_catalog_images.go b/ibm/service/power/data_source_ibm_pi_catalog_images.go index ffdbbac610c..eb505ac0700 100644 --- a/ibm/service/power/data_source_ibm_pi_catalog_images.go +++ b/ibm/service/power/data_source_ibm_pi_catalog_images.go @@ -18,7 +18,6 @@ import ( /* Datasource to get the list of images that are available when a power instance is created - */ func DataSourceIBMPICatalogImages() *schema.Resource { diff --git a/ibm/service/power/data_source_ibm_pi_images.go b/ibm/service/power/data_source_ibm_pi_images.go index 6541c45dc51..9b6782aa9f4 100644 --- a/ibm/service/power/data_source_ibm_pi_images.go +++ b/ibm/service/power/data_source_ibm_pi_images.go @@ -20,7 +20,6 @@ import ( /* Datasource to get the list of images that are available when a power instance is created - */ func DataSourceIBMPIImages() *schema.Resource { diff --git a/ibm/service/power/resource_ibm_pi_volume_test.go b/ibm/service/power/resource_ibm_pi_volume_test.go index 8e5882c1ac4..74288308393 100644 --- a/ibm/service/power/resource_ibm_pi_volume_test.go +++ b/ibm/service/power/resource_ibm_pi_volume_test.go @@ -161,7 +161,7 @@ func testAccCheckIBMPIVolumePoolConfig(name string) string { `, name, acc.Pi_cloud_instance_id) } -//TestAccIBMPIVolumeGRS test the volume replication feature which is part of global replication service(GRS) +// TestAccIBMPIVolumeGRS test the volume replication feature which is part of global replication service(GRS) func TestAccIBMPIVolumeGRS(t *testing.T) { name := fmt.Sprintf("tf-pi-volume-%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ diff --git a/ibm/service/satellite/data_source_ibm_satellite_host_script.go b/ibm/service/satellite/data_source_ibm_satellite_host_script.go index a42a4778145..29b08a85c5b 100644 --- a/ibm/service/satellite/data_source_ibm_satellite_host_script.go +++ b/ibm/service/satellite/data_source_ibm_satellite_host_script.go @@ -165,28 +165,44 @@ func dataSourceIBMSatelliteAttachHostScriptRead(d *schema.ResourceData, meta int //if this is a RHEL host, continue with custom script if !coreos_enabled { for i, line := range lines { - if strings.Contains(line, "API_URL=") { - i = i + 1 + if strings.Contains(line, `export OPERATING_SYSTEM`) { + i = i + 5 if script, ok := d.GetOk("custom_script"); ok { lines[i] = script.(string) } else { if strings.ToLower(hostProvider) == "aws" { lines[i] = "yum update -y\nyum-config-manager --enable '*'\nyum repolist all\nyum install container-selinux -y" } else if strings.ToLower(hostProvider) == "ibm" { - lines[i] = `subscription-manager refresh -subscription-manager repos --enable rhel-server-rhscl-7-rpms -subscription-manager repos --enable rhel-7-server-optional-rpms -subscription-manager repos --enable rhel-7-server-rh-common-rpms -subscription-manager repos --enable rhel-7-server-supplementary-rpms -subscription-manager repos --enable rhel-7-server-extras-rpms` + lines[i] = ` +if [[ "${OPERATING_SYSTEM}" == "RHEL7" ]]; then + subscription-manager refresh + subscription-manager repos --enable rhel-server-rhscl-7-rpms + subscription-manager repos --enable rhel-7-server-optional-rpms + subscription-manager repos --enable rhel-7-server-rh-common-rpms + subscription-manager repos --enable rhel-7-server-supplementary-rpms + subscription-manager repos --enable rhel-7-server-extras-rpms +fi` } else if strings.ToLower(hostProvider) == "azure" { - lines[i] = fmt.Sprintf(`yum update --disablerepo=* --enablerepo="*microsoft*" -y + + lines[i] = fmt.Sprintf(` +if [[ "${OPERATING_SYSTEM}" == "RHEL8" ]]; then + yum install subscription-manager -y + sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 + sudo update-alternatives --set python3 /usr/bin/python3.8 +fi +yum update --disablerepo=* --enablerepo="*microsoft*" -y yum-config-manager --enable '*' yum repolist all yum install container-selinux -y `) } else if strings.ToLower(hostProvider) == "google" { - lines[i] = fmt.Sprintf(`yum update --disablerepo=* --enablerepo="*" -y + lines[i] = fmt.Sprintf(` +if [[ "${OPERATING_SYSTEM}" == "RHEL8" ]]; then + yum install subscription-manager -y + sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 + sudo update-alternatives --set python3 /usr/bin/python3.8 +fi +yum update --disablerepo=* --enablerepo="*" -y yum repolist all yum install container-selinux -y yum install subscription-manager -y diff --git a/ibm/service/satellite/data_source_ibm_satellite_host_script_test.go b/ibm/service/satellite/data_source_ibm_satellite_host_script_test.go index f5c1276fa94..6d3a98709fa 100644 --- a/ibm/service/satellite/data_source_ibm_satellite_host_script_test.go +++ b/ibm/service/satellite/data_source_ibm_satellite_host_script_test.go @@ -44,7 +44,7 @@ data "ibm_satellite_attach_host_script" "script" { }`, locationName) } -//test coreos-enabled locations +// test coreos-enabled locations func TestAccIBMSatelliteAttachHostScriptDataSourceBasicCoreos(t *testing.T) { locationName := fmt.Sprintf("tf-satellitelocation-coreos-%d", acctest.RandIntRange(10, 100)) resource.Test(t, resource.TestCase{ diff --git a/ibm/service/satellite/resource_ibm_satellite_cluster.go b/ibm/service/satellite/resource_ibm_satellite_cluster.go index 156c0f58023..01b47e57506 100644 --- a/ibm/service/satellite/resource_ibm_satellite_cluster.go +++ b/ibm/service/satellite/resource_ibm_satellite_cluster.go @@ -875,7 +875,7 @@ func waitForClusterToDelete(cluster string, d *schema.ResourceData, meta interfa return stateConf.WaitForState() } -// WaitForSatelliteWorkerVersionUpdate Waits for worker creation +// WaitForSatelliteWorkerVersionUpdate Waits for worker creation func WaitForSatelliteWorkerVersionUpdate(d *schema.ResourceData, meta interface{}, masterVersion string, target v1.ClusterTargetHeader) (interface{}, error) { satClient, err := meta.(conns.ClientSession).SatelliteClientSession() if err != nil { diff --git a/ibm/validate/validators.go b/ibm/validate/validators.go index 8c526b736a1..63cb4b923e4 100644 --- a/ibm/validate/validators.go +++ b/ibm/validate/validators.go @@ -392,7 +392,7 @@ func ValidateSecurityRuleEtherType(v interface{}, k string) (ws []string, errors return } -//ValidateIP... +// ValidateIP... func ValidateIP(v interface{}, k string) (ws []string, errors []error) { address := v.(string) if net.ParseIP(address) == nil { @@ -403,7 +403,7 @@ func ValidateIP(v interface{}, k string) (ws []string, errors []error) { return } -//ValidateCIDR... +// ValidateCIDR... func ValidateCIDR(v interface{}, k string) (ws []string, errors []error) { address := v.(string) _, _, err := net.ParseCIDR(address) @@ -415,7 +415,7 @@ func ValidateCIDR(v interface{}, k string) (ws []string, errors []error) { return } -//validateCIDRAddress... +// validateCIDRAddress... func validateCIDRAddress() schema.SchemaValidateFunc { return func(v interface{}, k string) (ws []string, errors []error) { address := v.(string) @@ -429,7 +429,7 @@ func validateCIDRAddress() schema.SchemaValidateFunc { } } -//validateOverlappingAddress... +// validateOverlappingAddress... func validateOverlappingAddress() schema.SchemaValidateFunc { return func(v interface{}, k string) (ws []string, errors []error) { nonOverlappingCIDR := map[string]bool{ @@ -451,7 +451,7 @@ func validateOverlappingAddress() schema.SchemaValidateFunc { } } -//ValidateRemoteIP... +// ValidateRemoteIP... func ValidateRemoteIP(v interface{}, k string) (ws []string, errors []error) { _, err1 := ValidateCIDR(v, k) _, err2 := ValidateIP(v, k) @@ -464,7 +464,7 @@ func ValidateRemoteIP(v interface{}, k string) (ws []string, errors []error) { return } -//validateIPorCIDR... +// validateIPorCIDR... func validateIPorCIDR() schema.SchemaValidateFunc { return func(v interface{}, k string) (ws []string, errors []error) { _, err1 := ValidateCIDR(v, k) @@ -862,7 +862,7 @@ func ValidateAuthProtocol(v interface{}, k string) (ws []string, errors []error) return } -//ValidateIPVersion +// ValidateIPVersion func ValidateIPVersion(v interface{}, k string) (ws []string, errors []error) { validVersions := map[string]bool{ "ipv4": true, @@ -997,7 +997,7 @@ func ValidateLBListenerConnectionLimit(v interface{}, k string) (ws []string, er return } -//ValidateISName +// ValidateISName func ValidateISName(v interface{}, k string) (ws []string, errors []error) { name := v.(string) acceptedcharacters, _ := regexp.MatchString(`^[a-z][-a-z0-9]*$`, name) @@ -1053,6 +1053,7 @@ const ( ) // MarshalText implements the encoding.TextMarshaler interface. +// // Without this function, when FunctionalIdentifier is marshaled, it prints 0,1,2.. instead // of printing IntBetween, IntAtLeast, IntAtMost.. in JSON Output func (f FunctionIdentifier) MarshalText() ([]byte, error) { diff --git a/version/version.go b/version/version.go index 95f121cbfc2..778947cca64 100644 --- a/version/version.go +++ b/version/version.go @@ -10,7 +10,7 @@ const Version = "1.45.0" // GitCommit is the git commit that was compiled. This will be filled in by the compiler. var GitCommit string -//VersionPrerelease is the marker for version. If this is "" (empty string) +// VersionPrerelease is the marker for version. If this is "" (empty string) // then it means that it is a final release. Otherwise, this is a pre-release // such as "dev" (in development), "beta", "rc1", etc. var VersionPrerelease = "" From 6b9523611e6fea5a9054c817af3ceb65fcdc96da Mon Sep 17 00:00:00 2001 From: Clayton Huff Date: Tue, 13 Sep 2022 16:30:57 -0400 Subject: [PATCH 2/3] go get tidy --- go.mod | 3 +-- go.sum | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 40bc426dd1d..0f2a69b4133 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( github.com/IBM/platform-services-go-sdk v0.28.2 github.com/IBM/push-notifications-go-sdk v0.0.0-20210310100607-5790b96c47f5 github.com/IBM/scc-go-sdk/v3 v3.1.6 - github.com/IBM/scc-go-sdk/v4 v4.0.0 // indirect + github.com/IBM/scc-go-sdk/v4 v4.0.0 github.com/IBM/schematics-go-sdk v0.2.1 github.com/IBM/secrets-manager-go-sdk v0.1.19 github.com/IBM/vpc-go-sdk v0.23.0 @@ -58,4 +58,3 @@ require ( replace github.com/softlayer/softlayer-go v1.0.3 => github.com/IBM-Cloud/softlayer-go v1.0.5-tf replace github.com/dgrijalva/jwt-go v3.2.0+incompatible => github.com/golang-jwt/jwt v3.2.1+incompatible - diff --git a/go.sum b/go.sum index d994fe39d43..d4ff44331b7 100644 --- a/go.sum +++ b/go.sum @@ -70,8 +70,6 @@ github.com/IBM/schematics-go-sdk v0.2.1 h1:byATysGD+Z1k/wdtNqQmKALcAPjgSLuSyzcab github.com/IBM/schematics-go-sdk v0.2.1/go.mod h1:Tw2OSAPdpC69AxcwoyqcYYaGTTW6YpERF9uNEU+BFRQ= github.com/IBM/secrets-manager-go-sdk v0.1.19 h1:0GPs5EoTaWNsjo4QPj64GNxlWfN8VHJy4RDFLqddSe8= github.com/IBM/secrets-manager-go-sdk v0.1.19/go.mod h1:eO3dBhzPrHkkt+yPex/jB2xD6qHZxBko+Aw+0tfqHeA= -github.com/IBM/vpc-go-sdk v0.22.0 h1:jo2WMfiFXhAyJkdJeCVHwvT6kgTg2tg8sDeP9zrMFVg= -github.com/IBM/vpc-go-sdk v0.22.0/go.mod h1:YPyIfI+/qhPqlYp+I7dyx2U1GLcXgp/jzVvsZfUH4y8= github.com/IBM/vpc-go-sdk v0.23.0 h1:C26g02pPtTEWyLHNKK0mlFdpHeb9+noku9Q6qJLmdkc= github.com/IBM/vpc-go-sdk v0.23.0/go.mod h1:YPyIfI+/qhPqlYp+I7dyx2U1GLcXgp/jzVvsZfUH4y8= github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 h1:vuquMR410psHNax14XKNWa0Ae/kYgWJcXi0IFuX60N0= From 5063303077300a59142027da125677548a7e46b9 Mon Sep 17 00:00:00 2001 From: Clayton Huff Date: Tue, 27 Sep 2022 11:41:40 -0400 Subject: [PATCH 3/3] reduce necessary attach script to mirror bootstrap testing setup --- .../data_source_ibm_satellite_host_script.go | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/ibm/service/satellite/data_source_ibm_satellite_host_script.go b/ibm/service/satellite/data_source_ibm_satellite_host_script.go index 29b08a85c5b..552da638647 100644 --- a/ibm/service/satellite/data_source_ibm_satellite_host_script.go +++ b/ibm/service/satellite/data_source_ibm_satellite_host_script.go @@ -166,52 +166,47 @@ func dataSourceIBMSatelliteAttachHostScriptRead(d *schema.ResourceData, meta int if !coreos_enabled { for i, line := range lines { if strings.Contains(line, `export OPERATING_SYSTEM`) { - i = i + 5 + i = i + 1 if script, ok := d.GetOk("custom_script"); ok { lines[i] = script.(string) } else { if strings.ToLower(hostProvider) == "aws" { - lines[i] = "yum update -y\nyum-config-manager --enable '*'\nyum repolist all\nyum install container-selinux -y" + lines[i] = ` +yum-config-manager --enable '*' +yum install container-selinux -y +` } else if strings.ToLower(hostProvider) == "ibm" { lines[i] = ` +subscription-manager refresh if [[ "${OPERATING_SYSTEM}" == "RHEL7" ]]; then - subscription-manager refresh subscription-manager repos --enable rhel-server-rhscl-7-rpms subscription-manager repos --enable rhel-7-server-optional-rpms subscription-manager repos --enable rhel-7-server-rh-common-rpms subscription-manager repos --enable rhel-7-server-supplementary-rpms subscription-manager repos --enable rhel-7-server-extras-rpms -fi` +elif [[ "${OPERATING_SYSTEM}" == "RHEL8" ]]; then + subscription-manager repos --enable rhel-8-for-x86_64-baseos-rpms + subscription-manager repos --enable rhel-8-for-x86_64-appstream-rpms; +fi +yum install container-selinux -y` } else if strings.ToLower(hostProvider) == "azure" { - - lines[i] = fmt.Sprintf(` + lines[i] = ` if [[ "${OPERATING_SYSTEM}" == "RHEL8" ]]; then - yum install subscription-manager -y - sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 - sudo update-alternatives --set python3 /usr/bin/python3.8 + update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 + update-alternatives --set python3 /usr/bin/python3.8 fi -yum update --disablerepo=* --enablerepo="*microsoft*" -y -yum-config-manager --enable '*' -yum repolist all yum install container-selinux -y - `) +` } else if strings.ToLower(hostProvider) == "google" { - lines[i] = fmt.Sprintf(` + lines[i] = ` if [[ "${OPERATING_SYSTEM}" == "RHEL8" ]]; then - yum install subscription-manager -y - sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 - sudo update-alternatives --set python3 /usr/bin/python3.8 + update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 + update-alternatives --set python3 /usr/bin/python3.8 fi -yum update --disablerepo=* --enablerepo="*" -y -yum repolist all yum install container-selinux -y -yum install subscription-manager -y - `) - } else { - lines[i] = "subscription-manager refresh\nyum update -y\n" +` } } - } } }