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

add validation to all the things #30

Merged
merged 2 commits into from
Jan 23, 2019
Merged
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
4 changes: 4 additions & 0 deletions azuread/data_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package azuread
import (
"fmt"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/validate"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/tf"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"
Expand All @@ -20,13 +22,15 @@ func dataApplication() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validate.UUID,
ConflictsWith: []string{"name"},
},

"name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validate.NoEmptyStrings,
ConflictsWith: []string{"object_id"},
},

Expand Down
4 changes: 4 additions & 0 deletions azuread/data_service_principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/validate"

"github.com/Azure/azure-sdk-for-go/services/graphrbac/1.6/graphrbac"
"github.com/hashicorp/terraform/helper/schema"
Expand All @@ -18,20 +19,23 @@ func dataServicePrincipal() *schema.Resource {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validate.UUID,
ConflictsWith: []string{"display_name", "application_id"},
},

"display_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validate.NoEmptyStrings,
ConflictsWith: []string{"object_id", "application_id"},
},

"application_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validate.UUID,
ConflictsWith: []string{"object_id", "display_name"},
},
},
Expand Down
1 change: 0 additions & 1 deletion azuread/resource_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func resourceApplication() *schema.Resource {
Type: schema.TypeList,
Optional: true,
Computed: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validate.URLIsHTTPOrHTTPS,
Expand Down
9 changes: 6 additions & 3 deletions azuread/resource_service_principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"log"

"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/validate"

"github.com/hashicorp/go-azure-helpers/response"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/ar"
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/p"
Expand All @@ -25,9 +27,10 @@ func resourceServicePrincipal() *schema.Resource {

Schema: map[string]*schema.Schema{
"application_id": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validate.UUID,
},

"display_name": {
Expand Down
9 changes: 5 additions & 4 deletions azuread/resource_service_principal_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ func resourceServicePrincipalPassword() *schema.Resource {
},

"value": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Sensitive: true,
Type: schema.TypeString,
Required: true,
ForceNew: true,
Sensitive: true,
ValidateFunc: validate.NoEmptyStrings,
},

"start_date": {
Expand Down