Skip to content

Commit

Permalink
Updated empty string checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jbristowe committed Sep 28, 2020
1 parent 51e936a commit 6826269
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions octopusdeploy/provider_test.go
Expand Up @@ -29,10 +29,10 @@ func TestProvider_impl(t *testing.T) {
}

func testAccPreCheck(t *testing.T) {
if v := os.Getenv("OCTOPUS_URL"); v == constEmptyString {
if v := os.Getenv("OCTOPUS_URL"); isEmpty(v) {
t.Fatal("OCTOPUS_URL must be set for acceptance tests")
}
if v := os.Getenv("OCTOPUS_APIKEY"); v == constEmptyString {
if v := os.Getenv("OCTOPUS_APIKEY"); isEmpty(v) {
t.Fatal("OCTOPUS_APIKEY must be set for acceptance tests")
}
}
4 changes: 2 additions & 2 deletions octopusdeploy/resource_aws_account.go
Expand Up @@ -126,7 +126,7 @@ func resourceAmazonWebServicesAccountUpdate(d *schema.ResourceData, m interface{
return err
}

if account.ID == constEmptyString {
if isEmpty(account.ID) {
log.Println("ID is nil")
} else {
account.ID = d.Id()
Expand All @@ -139,7 +139,7 @@ func resourceAmazonWebServicesAccountUpdate(d *schema.ResourceData, m interface{
return createResourceOperationError(errorUpdatingAWSAccount, d.Id(), err)
}

if updatedAccount.ID == constEmptyString {
if isEmpty(updatedAccount.ID) {
log.Println("ID is nil")
} else {
d.SetId(updatedAccount.ID)
Expand Down
8 changes: 3 additions & 5 deletions octopusdeploy/resource_azure_service_principal.go
Expand Up @@ -66,7 +66,7 @@ func buildAzureServicePrincipalResource(d *schema.ResourceData) (*model.Account,
name := d.Get(constName).(string)

password := d.Get(constKey).(string)
if password == constEmptyString {
if isEmpty(password) {
log.Println("Key is nil. Must add in a password")
}

Expand Down Expand Up @@ -200,21 +200,19 @@ func resourceAzureServicePrincipalUpdate(d *schema.ResourceData, m interface{})
return err
}

if account.ID == constEmptyString {
if isEmpty(account.ID) {
log.Println("ID is nil")
} else {
account.ID = d.Id()
}

apiClient := m.(*client.Client)

updatedAccount, err := apiClient.Accounts.Update(*account)

if err != nil {
return createResourceOperationError(errorUpdatingAzureServicePrincipal, d.Id(), err)
}

if updatedAccount.ID == constEmptyString {
if isEmpty(updatedAccount.ID) {
log.Println("ID is nil")
} else {
d.SetId(updatedAccount.ID)
Expand Down
2 changes: 1 addition & 1 deletion octopusdeploy/resource_usernamepassword_account.go
Expand Up @@ -65,7 +65,7 @@ func buildUsernamePasswordResource(d *schema.ResourceData) (*model.Account, erro
}

password := d.Get(constPassword).(string)
if password == constEmptyString {
if isEmpty(password) {
log.Println("Key is nil. Must add in a password")
}

Expand Down

0 comments on commit 6826269

Please sign in to comment.