Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename some function #241

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions outscale/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ type Config struct {
X509key string
}

// OutscaleClient client
type OutscaleClient struct {
// Client client
type Client struct {
OSCAPI *oscgo.APIClient
}

// Client ...
func (c *Config) Client() (*OutscaleClient, error) {
func (c *Config) Client() (*Client, error) {
tlsconfig := &tls.Config{InsecureSkipVerify: false}
cert, err := tls.LoadX509KeyPair(c.X509cert, c.X509key)
if err == nil {
Expand Down Expand Up @@ -61,7 +61,7 @@ func (c *Config) Client() (*OutscaleClient, error) {

oscClient := oscgo.NewAPIClient(oscConfig)

client := &OutscaleClient{
client := &Client{
OSCAPI: oscClient,
}

Expand Down
12 changes: 6 additions & 6 deletions outscale/data_source_outscale_access_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
"github.com/terraform-providers/terraform-provider-outscale/utils"
)

func dataSourceOutscaleAccessKey() *schema.Resource {
func dataSourceAccessKey() *schema.Resource {
return &schema.Resource{
Read: dataSourceOutscaleAccessKeyRead,
Read: dataSourceAccessKeyRead,
Schema: map[string]*schema.Schema{
"filter": dataSourceFiltersSchema(),
"access_key_id": {
Expand Down Expand Up @@ -48,8 +48,8 @@ func dataSourceOutscaleAccessKey() *schema.Resource {
}
}

func dataSourceOutscaleAccessKeyRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*OutscaleClient).OSCAPI
func dataSourceAccessKeyRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*Client).OSCAPI

filters, filtersOk := d.GetOk("filter")
accessKeyID, accessKeyOk := d.GetOk("access_key_id")
Expand All @@ -61,7 +61,7 @@ func dataSourceOutscaleAccessKeyRead(d *schema.ResourceData, meta interface{}) e

filterReq := &oscgo.FiltersAccessKeys{}
if filtersOk {
filterReq = buildOutscaleDataSourceAccessKeyFilters(filters.(*schema.Set))
filterReq = buildDataSourceAccessKeyFilters(filters.(*schema.Set))
}
if accessKeyOk {
filterReq.SetAccessKeyIds([]string{accessKeyID.(string)})
Expand Down Expand Up @@ -115,7 +115,7 @@ func dataSourceOutscaleAccessKeyRead(d *schema.ResourceData, meta interface{}) e
return nil
}

func buildOutscaleDataSourceAccessKeyFilters(set *schema.Set) *oscgo.FiltersAccessKeys {
func buildDataSourceAccessKeyFilters(set *schema.Set) *oscgo.FiltersAccessKeys {
var filters oscgo.FiltersAccessKeys
for _, v := range set.List() {
m := v.(map[string]interface{})
Expand Down
4 changes: 2 additions & 2 deletions outscale/data_source_outscale_access_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccOutscaleDataSourceAccessKey_basic(t *testing.T) {
func TestAccDataSourceAccessKey_basic(t *testing.T) {
t.Parallel()
dataSourceName := "outscale_access_key.outscale_access_key"

Expand All @@ -28,7 +28,7 @@ func TestAccOutscaleDataSourceAccessKey_basic(t *testing.T) {
})
}

func TestAccOutscaleDataSourceAccessKey_withFilters(t *testing.T) {
func TestAccDataSourceAccessKey_withFilters(t *testing.T) {
t.Parallel()
dataSourceName := "outscale_access_key.outscale_access_key"

Expand Down
14 changes: 7 additions & 7 deletions outscale/data_source_outscale_access_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/terraform-providers/terraform-provider-outscale/utils"
)

func dataSourceOutscaleAccessKeys() *schema.Resource {
func dataSourceAccessKeys() *schema.Resource {
return &schema.Resource{
Read: dataSourceOutscaleAccessKeysRead,
Read: dataSourceAccessKeysRead,
Schema: map[string]*schema.Schema{
"filter": dataSourceFiltersSchema(),
"access_key_ids": {
Expand Down Expand Up @@ -67,8 +67,8 @@ func dataSourceOutscaleAccessKeys() *schema.Resource {
}
}

func dataSourceOutscaleAccessKeysRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*OutscaleClient).OSCAPI
func dataSourceAccessKeysRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*Client).OSCAPI

filters, filtersOk := d.GetOk("filter")
accessKeyID, accessKeyOk := d.GetOk("access_key_ids")
Expand All @@ -80,13 +80,13 @@ func dataSourceOutscaleAccessKeysRead(d *schema.ResourceData, meta interface{})

filterReq := &oscgo.FiltersAccessKeys{}
if filtersOk {
filterReq = buildOutscaleDataSourceAccessKeyFilters(filters.(*schema.Set))
filterReq = buildDataSourceAccessKeyFilters(filters.(*schema.Set))
}
if accessKeyOk {
filterReq.SetAccessKeyIds(expandStringValueList(accessKeyID.([]interface{})))
filterReq.SetAccessKeyIds(utils.InterfaceSliceToStringSlice(accessKeyID.([]interface{})))
}
if stateOk {
filterReq.SetStates(expandStringValueList(state.([]interface{})))
filterReq.SetStates(utils.InterfaceSliceToStringSlice(state.([]interface{})))
}

var resp oscgo.ReadAccessKeysResponse
Expand Down
4 changes: 2 additions & 2 deletions outscale/data_source_outscale_access_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccOutscaleDataSourceAccessKeys_basic(t *testing.T) {
func TestAccDataSourceAccessKeys_basic(t *testing.T) {
t.Parallel()
dataSourceName := "data.outscale_access_keys.outscale_access_key"

Expand All @@ -25,7 +25,7 @@ func TestAccOutscaleDataSourceAccessKeys_basic(t *testing.T) {
})
}

func TestAccOutscaleDataSourceAccessKeys_withFilters(t *testing.T) {
func TestAccDataSourceAccessKeys_withFilters(t *testing.T) {
t.Parallel()
dataSourceName := "data.outscale_access_keys.outscale_access_key"

Expand Down
4 changes: 2 additions & 2 deletions outscale/data_source_outscale_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func dataSourceAccounts() *schema.Resource {

func dataSourceAccountsRead(d *schema.ResourceData, meta interface{}) error {

conn := meta.(*OutscaleClient).OSCAPI
conn := meta.(*Client).OSCAPI

req := oscgo.ReadAccountsRequest{}

Expand Down Expand Up @@ -132,7 +132,7 @@ func flattenAccounts(accounts []oscgo.Account) []map[string]interface{} {
for i, account := range accounts {
accountsMap[i] = map[string]interface{}{
"account_id": account.GetAccountId(),
"additional_emails": flattenStringList(account.AdditionalEmails),
"additional_emails": utils.StringSlicePtrToInterfaceSlice(account.AdditionalEmails),
"city": account.GetCity(),
"company_name": account.GetCompanyName(),
"country": account.GetCountry(),
Expand Down
8 changes: 4 additions & 4 deletions outscale/data_source_outscale_api_access_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"github.com/terraform-providers/terraform-provider-outscale/utils"
)

func dataSourceOutscaleOAPIApiAccessPolicy() *schema.Resource {
func dataSourceApiAccessPolicy() *schema.Resource {
return &schema.Resource{
Read: dataSourceOutscaleOAPIApiAccessPolicyRead,
Read: dataSourceApiAccessPolicyRead,
Schema: map[string]*schema.Schema{
"max_access_key_expiration_seconds": {
Type: schema.TypeInt,
Expand All @@ -31,8 +31,8 @@ func dataSourceOutscaleOAPIApiAccessPolicy() *schema.Resource {
}
}

func dataSourceOutscaleOAPIApiAccessPolicyRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*OutscaleClient).OSCAPI
func dataSourceApiAccessPolicyRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*Client).OSCAPI

req := oscgo.ReadApiAccessPolicyRequest{}

Expand Down
6 changes: 3 additions & 3 deletions outscale/data_source_outscale_api_access_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

func TestAccDataSourceOutscaleOAPIApiAccessPolicy_basic(t *testing.T) {
func TestAccDataSourceApiAccessPolicy_basic(t *testing.T) {

resource.Test(t, resource.TestCase{
PreCheck: func() {
Expand All @@ -16,13 +16,13 @@ func TestAccDataSourceOutscaleOAPIApiAccessPolicy_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceOutscaleOAPIApiAccessPolicyConfig(),
Config: testAccDataSourceApiAccessPolicyConfig(),
},
},
})
}

func testAccDataSourceOutscaleOAPIApiAccessPolicyConfig() string {
func testAccDataSourceApiAccessPolicyConfig() string {
return fmt.Sprintf(`
data "outscale_api_access_policy" "api_access_policy" {}
`)
Expand Down
12 changes: 6 additions & 6 deletions outscale/data_source_outscale_api_access_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"github.com/terraform-providers/terraform-provider-outscale/utils"
)

func dataSourceOutscaleOAPIApiAccessRule() *schema.Resource {
func dataSourceApiAccessRule() *schema.Resource {
return &schema.Resource{
Read: dataSourceOutscaleOAPIApiAccessRuleRead,
Read: dataSourceApiAccessRuleRead,
Schema: map[string]*schema.Schema{
"filter": dataSourceFiltersSchema(),
"api_access_rule_id": {
Expand Down Expand Up @@ -48,16 +48,16 @@ func dataSourceOutscaleOAPIApiAccessRule() *schema.Resource {
}
}

func dataSourceOutscaleOAPIApiAccessRuleRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*OutscaleClient).OSCAPI
func dataSourceApiAccessRuleRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*Client).OSCAPI

filters, filtersOk := d.GetOk("filter")
if !filtersOk {
return fmt.Errorf("filters must be assigned")
}

req := oscgo.ReadApiAccessRulesRequest{
Filters: buildOutscaleApiAccessRuleFilters(filters.(*schema.Set)),
Filters: buildApiAccessRuleFilters(filters.(*schema.Set)),
}

var resp oscgo.ReadApiAccessRulesResponse
Expand Down Expand Up @@ -112,7 +112,7 @@ func dataSourceOutscaleOAPIApiAccessRuleRead(d *schema.ResourceData, meta interf
return nil
}

func buildOutscaleApiAccessRuleFilters(set *schema.Set) *oscgo.FiltersApiAccessRule {
func buildApiAccessRuleFilters(set *schema.Set) *oscgo.FiltersApiAccessRule {
var filters oscgo.FiltersApiAccessRule
for _, v := range set.List() {
m := v.(map[string]interface{})
Expand Down
14 changes: 7 additions & 7 deletions outscale/data_source_outscale_api_access_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func TestAccDataOutscaleOAPIApiAccessRule_basic(t *testing.T) {
func TestAccDataApiAccessRule_basic(t *testing.T) {
t.Parallel()
resourceName := "outscale_api_access_rule.rule_data"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccDataCheckOutscaleApiAccessRuleDestroy,
CheckDestroy: testAccDataCheckApiAccessRuleDestroy,
Steps: []resource.TestStep{
{
Config: testAccDataOutscaleOAPIApiAccessRuleConfig(utils.TestCaPem),
Config: testAccDataApiAccessRuleConfig(utils.TestCaPem),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleApiAccessRuleExists(resourceName),
testAccCheckApiAccessRuleExists(resourceName),
),
},
},
})
}

func testAccDataCheckOutscaleApiAccessRuleDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*OutscaleClient).OSCAPI
func testAccDataCheckApiAccessRuleDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*Client).OSCAPI

for _, rs := range s.RootModule().Resources {
if rs.Type != "outscale_api_access_rule" {
Expand Down Expand Up @@ -70,7 +70,7 @@ func testAccDataCheckOutscaleApiAccessRuleDestroy(s *terraform.State) error {
return nil
}

func testAccDataOutscaleOAPIApiAccessRuleConfig(ca_pem string) string {
func testAccDataApiAccessRuleConfig(ca_pem string) string {
return fmt.Sprintf(`
resource "outscale_ca" "ca_rule" {
ca_pem = %[1]q
Expand Down
10 changes: 5 additions & 5 deletions outscale/data_source_outscale_api_access_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"github.com/terraform-providers/terraform-provider-outscale/utils"
)

func dataSourceOutscaleOAPIApiAccessRules() *schema.Resource {
func dataSourceApiAccessRules() *schema.Resource {
return &schema.Resource{
Read: dataSourceOutscaleOAPIApiAccessRulesRead,
Read: dataSourceApiAccessRulesRead,
Schema: map[string]*schema.Schema{
"filter": dataSourceFiltersSchema(),
"api_access_rules": {
Expand Down Expand Up @@ -55,13 +55,13 @@ func dataSourceOutscaleOAPIApiAccessRules() *schema.Resource {
}
}

func dataSourceOutscaleOAPIApiAccessRulesRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*OutscaleClient).OSCAPI
func dataSourceApiAccessRulesRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*Client).OSCAPI

filters, filtersOk := d.GetOk("filter")
req := oscgo.ReadApiAccessRulesRequest{}
if filtersOk {
req.Filters = buildOutscaleApiAccessRuleFilters(filters.(*schema.Set))
req.Filters = buildApiAccessRuleFilters(filters.(*schema.Set))
}

var resp oscgo.ReadApiAccessRulesResponse
Expand Down
14 changes: 7 additions & 7 deletions outscale/data_source_outscale_api_access_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)

func TestAccDataOutscaleOAPIApiAccessRules_basic(t *testing.T) {
func TestAccDataApiAccessRules_basic(t *testing.T) {
t.Parallel()
resourceName := "outscale_api_access_rule.rule_data"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccDataCheckOutscaleApiAccessRuleDestroy,
CheckDestroy: testAccDataCheckApiAccessRuleDestroy,
Steps: []resource.TestStep{
{
Config: testAccDataOutscaleOAPIApiAccessRulesConfig(utils.TestCaPem),
Config: testAccDataApiAccessRulesConfig(utils.TestCaPem),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleApiAccessRuleExists(resourceName),
testAccCheckApiAccessRuleExists(resourceName),
),
},
},
})
}

func testAccDataCheckOutscaleApiAccessRulesDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*OutscaleClient).OSCAPI
func testAccDataCheckApiAccessRulesDestroy(s *terraform.State) error {
conn := testAccProvider.Meta().(*Client).OSCAPI

for _, rs := range s.RootModule().Resources {
if rs.Type != "outscale_api_access_rule" {
Expand Down Expand Up @@ -69,7 +69,7 @@ func testAccDataCheckOutscaleApiAccessRulesDestroy(s *terraform.State) error {
return nil
}

func testAccDataOutscaleOAPIApiAccessRulesConfig(ca_pem string) string {
func testAccDataApiAccessRulesConfig(ca_pem string) string {
return fmt.Sprintf(`
resource "outscale_ca" "ca_rule" {
ca_pem = %[1]q
Expand Down
Loading