Skip to content
This repository has been archived by the owner on Mar 8, 2022. It is now read-only.

Commit

Permalink
Resource Server read remote values correctly (#14)
Browse files Browse the repository at this point in the history
* properly read remote values for rule config

* read remote values for rules and mark order as computed

* read remote values into resource server correctly

* mark signing_alg and token_lifetime computed

* remove redundant set
  • Loading branch information
alexkappa committed Jun 1, 2018
1 parent b82bb3a commit 8598ed3
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions auth0/resource_auth0_resource_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func newResourceServer() *schema.Resource {
Read: readResourceServer,
Update: updateResourceServer,
Delete: deleteResourceServer,

Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Expand Down Expand Up @@ -44,6 +45,7 @@ func newResourceServer() *schema.Resource {
"signing_alg": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"signing_secret": {
Type: schema.TypeString,
Expand All @@ -56,6 +58,7 @@ func newResourceServer() *schema.Resource {
"token_lifetime": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
},
"skip_consent_for_verifiable_first_party_clients": {
Type: schema.TypeBool,
Expand All @@ -81,8 +84,7 @@ func createResourceServer(d *schema.ResourceData, m interface{}) error {
return err
}
d.SetId(s.ID)
d.Set("identifier", s.Identifier)
return nil
return readResourceServer(d, m)
}

func readResourceServer(d *schema.ResourceData, m interface{}) error {
Expand All @@ -92,6 +94,24 @@ func readResourceServer(d *schema.ResourceData, m interface{}) error {
return err
}
d.SetId(s.ID)
d.Set("name", s.Name)
d.Set("identifier", s.Identifier)
d.Set("scopes", func() (m []map[string]interface{}) {
for _, scope := range s.Scopes {
m = append(m, map[string]interface{}{
"value": scope.Value,
"description": scope.Description,
})
}
return m
}())
d.Set("signing_alg", s.SigningAlgorithm)
d.Set("signing_secret", s.SigningSecret)
d.Set("allow_offline_access", s.AllowOfflineAccess)
d.Set("token_lifetime", s.TokenLifetime)
d.Set("skip_consent_for_verifiable_first_party_clients", s.SkipConsentForVerifiableFirstPartyClients)
d.Set("verification_location", s.VerificationLocation)
d.Set("options", s.Options)
return nil
}

Expand All @@ -103,7 +123,7 @@ func updateResourceServer(d *schema.ResourceData, m interface{}) error {
if err != nil {
return err
}
return nil
return readResourceServer(d, m)
}

func deleteResourceServer(d *schema.ResourceData, m interface{}) error {
Expand Down

0 comments on commit 8598ed3

Please sign in to comment.