Skip to content

Commit

Permalink
fix: solve PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
btfhernandez committed Nov 7, 2024
1 parent 0edeba8 commit 3f02c5d
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var zapLogger = logging.NewZapLogger(logger)
func Provider() *schema.Provider {
return &schema.Provider{
ResourcesMap: map[string]*schema.Resource{
"passwordsafe_create_managed_account": resourceManagedAccount(),
"passwordsafe_managed_account": resourceManagedAccount(),
},
DataSourcesMap: map[string]*schema.Resource{
"passwordsafe_secret": getSecretByPath(),
Expand Down Expand Up @@ -173,7 +173,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData) (interface{}

certificate := ""
certificateKey := ""
var err error = nil
var err error

if clientCertificateName != "" {
certificate, certificateKey, err = utils.GetPFXContent(clientCertificatePath, clientCertificateName, clientCertificatePassword, zapLogger)
Expand Down Expand Up @@ -495,7 +495,10 @@ func resourceManagedAccountCreate(d *schema.ResourceData, m interface{}) error {
atomic.AddUint64(&signInCount, ^uint64(0))
mu_out.Unlock()
} else {
authenticationObj.SignOut()
err = authenticationObj.SignOut()
if err != nil {
return err
}
zapLogger.Debug(fmt.Sprintf("%v %v", "signout user", atomic.LoadUint64(&signInCount)))
// decrement counter
atomic.AddUint64(&signInCount, ^uint64(0))
Expand Down Expand Up @@ -557,7 +560,12 @@ func getManagedAccountReadContext(ctx context.Context, d *schema.ResourceData, m
return diag.FromErr(err)
}

d.Set("value", gotManagedAccount)
err = d.Set("value", gotManagedAccount)

if err != nil {
return diag.FromErr(err)
}

d.SetId(hash(gotManagedAccount))

mu_out.Lock()
Expand All @@ -567,7 +575,10 @@ func getManagedAccountReadContext(ctx context.Context, d *schema.ResourceData, m
atomic.AddUint64(&signInCount, ^uint64(0))
mu_out.Unlock()
} else {
authenticationObj.SignOut()
err = authenticationObj.SignOut()
if err != nil {
return diag.FromErr(err)
}
zapLogger.Debug(fmt.Sprintf("%v %v", "signout user", atomic.LoadUint64(&signInCount)))
// decrement counter
atomic.AddUint64(&signInCount, ^uint64(0))
Expand Down Expand Up @@ -614,7 +625,12 @@ func getSecretByPathReadContext(ctx context.Context, d *schema.ResourceData, m i
return diag.FromErr(err)
}

d.Set("value", secret)
err = d.Set("value", secret)

if err != nil {
return diag.FromErr(err)
}

d.SetId(hash(secret))

mu_out.Lock()
Expand All @@ -624,7 +640,10 @@ func getSecretByPathReadContext(ctx context.Context, d *schema.ResourceData, m i
atomic.AddUint64(&signInCount, ^uint64(0))
mu_out.Unlock()
} else {
authenticationObj.SignOut()
err = authenticationObj.SignOut()
if err != nil {
return diag.FromErr(err)
}
zapLogger.Debug(fmt.Sprintf("%v %v", "signout user", atomic.LoadUint64(&signInCount)))
// decrement counter
atomic.AddUint64(&signInCount, ^uint64(0))
Expand Down

0 comments on commit 3f02c5d

Please sign in to comment.