Skip to content

Commit

Permalink
[bugfix] Fix all Read() to not fail if object does not exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
lhercot committed May 13, 2022
1 parent a7acda8 commit b369786
Show file tree
Hide file tree
Showing 71 changed files with 80 additions and 80 deletions.
2 changes: 1 addition & 1 deletion aci/data_source_aci_isisdompol.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func dataSourceAciISISDomainPolicyRead(ctx context.Context, d *schema.ResourceDa
isisDomPol, err := getRemoteISISDomainPolicy(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setISISDomainPolicyAttributes(isisDomPol, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaa_domain_relationship.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func resourceAciDomainRelationshipRead(ctx context.Context, d *schema.ResourceDa
aaaDomainRef, err := getRemoteAaaDomainRelationship(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}

_, err = setAaaDomainRelationshipAttributes(aaaDomainRef, d)
Expand Down
6 changes: 3 additions & 3 deletions aci/resource_aci_aaaauthrealm.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func resourceAciAAAAuthenticationRead(ctx context.Context, d *schema.ResourceDat
aaaAuthRealm, err := getRemoteAAAAuthentication(aciClient, dnauthrealm)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setAAAAuthenticationAttributes(aaaAuthRealm, d)
if err != nil {
Expand All @@ -260,12 +260,12 @@ func resourceAciAAAAuthenticationRead(ctx context.Context, d *schema.ResourceDat
aaaPingEp, err := getRemoteDefaultRadiusAuthenticationSettings(aciClient, dnpingep)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setDefaultRadiusAuthenticationSettingsAttributes(aaaPingEp, d)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
log.Printf("[DEBUG] %s: Read finished successfully", d.Id())
return nil
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaaconsoleauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func resourceAciConsoleAuthenticationMethodRead(ctx context.Context, d *schema.R
aaaConsoleAuth, err := getRemoteConsoleAuthenticationMethod(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setConsoleAuthenticationMethodAttributes(aaaConsoleAuth, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaadefaultauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func resourceAciDefaultAuthenticationMethodforallLoginsRead(ctx context.Context,
aaaDefaultAuth, err := getRemoteDefaultAuthenticationMethodforallLogins(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setDefaultAuthenticationMethodforallLoginsAttributes(aaaDefaultAuth, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaaduoprovidergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func resourceAciDuoProviderGroupRead(ctx context.Context, d *schema.ResourceData
aaaDuoProviderGroup, err := getRemoteDuoProviderGroup(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setDuoProviderGroupAttributes(aaaDuoProviderGroup, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaaldapgroupmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func resourceAciLDAPGroupMapRead(ctx context.Context, d *schema.ResourceData, m
aaaLdapGroupMap, err := getRemoteLDAPGroupMap(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setLDAPGroupMapAttributes(aaaLdapGroupMap, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaaldapgroupmaprule.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func resourceAciLDAPGroupMapRuleRead(ctx context.Context, d *schema.ResourceData
aaaLdapGroupMapRule, err := getRemoteLDAPGroupMapRule(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
ldap_group_map_rule := strings.Split(dn, "/")

Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaaldapgroupmapruleref.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func resourceAciLDAPGroupMaprulerefRead(ctx context.Context, d *schema.ResourceD
aaaLdapGroupMapRuleRef, err := getRemoteLDAPGroupMapruleref(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setLDAPGroupMaprulerefAttributes(aaaLdapGroupMapRuleRef, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaaldapprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ func resourceAciLDAPProviderRead(ctx context.Context, d *schema.ResourceData, m
aaaLdapProvider, err := getRemoteLDAPProvider(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}

ldap_provider_group := strings.Split(dn, "/")
Expand Down
4 changes: 2 additions & 2 deletions aci/resource_aci_aaalogindomain.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func resourceAciLoginDomainRead(ctx context.Context, d *schema.ResourceData, m i
aaaLoginDomain, err := getRemoteLoginDomain(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setLoginDomainAttributes(aaaLoginDomain, d)
if err != nil {
Expand All @@ -256,7 +256,7 @@ func resourceAciLoginDomainRead(ctx context.Context, d *schema.ResourceData, m i
aaaDomainAuth, err := getRemoteAuthenticationMethodfortheDomain(aciClient, childDn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setAuthenticationMethodfortheDomainAttributes(aaaDomainAuth, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaaproviderref.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func resourceAciProviderGroupMemberRead(ctx context.Context, d *schema.ResourceD
aaaProviderRef, err := getRemoteProviderGroupMember(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setProviderGroupMemberAttributes(aaaProviderRef, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaaradiusprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func resourceAciRADIUSProviderRead(ctx context.Context, d *schema.ResourceData,
aaaRadiusProvider, err := getRemoteRADIUSProvider(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}

radius_provider_group := strings.Split(dn, "/")
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaaradiusprovidergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func resourceAciRADIUSProviderGroupRead(ctx context.Context, d *schema.ResourceD
aaaRadiusProviderGroup, err := getRemoteRADIUSProviderGroup(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setRADIUSProviderGroupAttributes(aaaRadiusProviderGroup, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaarsaprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func resourceAciRSAProviderRead(ctx context.Context, d *schema.ResourceData, m i
aaaRsaProvider, err := getRemoteRSAProvider(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setRSAProviderAttributes(aaaRsaProvider, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaasamlprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ func resourceAciSAMLProviderRead(ctx context.Context, d *schema.ResourceData, m
aaaSamlProvider, err := getRemoteSAMLProvider(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setSAMLProviderAttributes(aaaSamlProvider, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaasamlprovidergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func resourceAciSAMLProviderGroupRead(ctx context.Context, d *schema.ResourceDat
aaaSamlProviderGroup, err := getRemoteSAMLProviderGroup(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setSAMLProviderGroupAttributes(aaaSamlProviderGroup, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaatacacsplusprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ func resourceAciTACACSProviderRead(ctx context.Context, d *schema.ResourceData,
aaaTacacsPlusProvider, err := getRemoteTACACSProvider(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setTACACSProviderAttributes(aaaTacacsPlusProvider, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaatacacsplusprovidergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func resourceAciTACACSPlusProviderGroupRead(ctx context.Context, d *schema.Resou
aaaTacacsPlusProviderGroup, err := getRemoteTACACSPlusProviderGroup(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setTACACSPlusProviderGroupAttributes(aaaTacacsPlusProviderGroup, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaausercert.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func resourceAciX509CertificateRead(ctx context.Context, d *schema.ResourceData,

if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setX509CertificateAttributes(aaaUserCert, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaauserdomain.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func resourceAciUserDomainRead(ctx context.Context, d *schema.ResourceData, m in
aaaUserDomain, err := getRemoteUserDomain(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setUserDomainAttributes(aaaUserDomain, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaauserep.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ func resourceAciUserManagementRead(ctx context.Context, d *schema.ResourceData,
aaaUserEp, err := getRemoteUserManagement(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setUserManagementAttributes(aaaUserEp, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_aaauserrole.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func resourceAciUserRoleRead(ctx context.Context, d *schema.ResourceData, m inte
aaaUserRole, err := getRemoteUserRole(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setUserRoleAttributes(aaaUserRole, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_cooppol.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func resourceAciCOOPGroupPolicyRead(ctx context.Context, d *schema.ResourceData,
coopPol, err := getRemoteCOOPGroupPolicy(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setCOOPGroupPolicyAttributes(coopPol, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_edrerrdisrecoverpol.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func resourceAciErrorDisabledRecoveryPolicyRead(ctx context.Context, d *schema.R
edrErrDisRecoverPol, err := getRemoteErrorDisabledRecoveryPolicy(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setErrorDisabledRecoveryPolicyAttributes(edrErrDisRecoverPol, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_epcontrolp.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func resourceAciEndpointControlPolicyRead(ctx context.Context, d *schema.Resourc
epControlP, err := getRemoteEndpointControlPolicy(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setEndpointControlPolicyAttributes(epControlP, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_epipagingp.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func resourceAciIPAgingPolicyRead(ctx context.Context, d *schema.ResourceData, m
epIpAgingP, err := getRemoteIPAgingPolicy(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setIPAgingPolicyAttributes(epIpAgingP, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_eploopprotectp.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func resourceAciEPLoopProtectionPolicyRead(ctx context.Context, d *schema.Resour
epLoopProtectP, err := getRemoteEPLoopProtectionPolicy(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setEPLoopProtectionPolicyAttributes(epLoopProtectP, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_fabricnodecontrol.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func resourceAciFabricNodeControlRead(ctx context.Context, d *schema.ResourceDat
fabricNodeControl, err := getRemoteFabricNodeControl(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setFabricNodeControlAttributes(fabricNodeControl, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_fabricrsoospath.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func resourceAciOutofServiceFabricPathRead(ctx context.Context, d *schema.Resour
fabricRsOosPath, err := getRemoteOutofServiceFabricPath(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setOutofServiceFabricPathAttributes(fabricRsOosPath, d)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_fileremotepath.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func resourceAciRemotePathofaFileRead(ctx context.Context, d *schema.ResourceDat
fileRemotePath, err := getRemoteRemotePathofaFile(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
setRemotePathofaFileAttributes(fileRemotePath, d)

Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_fvepgselector.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func resourceAciEndpointSecurityGroupEPgSelectorRead(ctx context.Context, d *sch
fvEPgSelector, err := getRemoteEndpointSecurityGroupEPgSelector(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setEndpointSecurityGroupEPgSelectorAttributes(fvEPgSelector, d)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions aci/resource_aci_fvepselector.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ func resourceAciEndpointSecurityGroupSelectorRead(ctx context.Context, d *schema
fvEPSelector, err := getRemoteEndpointSecurityGroupSelector(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setEndpointSecurityGroupSelectorAttributes(fvEPSelector, d)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}

log.Printf("[DEBUG] %s: Read finished successfully", d.Id())
Expand Down
4 changes: 2 additions & 2 deletions aci/resource_aci_fvesg.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,12 +723,12 @@ func resourceAciEndpointSecurityGroupRead(ctx context.Context, d *schema.Resourc
fvESg, err := getRemoteEndpointSecurityGroup(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setEndpointSecurityGroupAttributes(fvESg, d)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}

fvRsConsData, err := aciClient.ReadRelationfvRsCons(dn)
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_fvrsconsif.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func resourceAciContractInterfaceRelationshipRead(ctx context.Context, d *schema
fvRsConsIf, err := getRemoteContractInterfaceRelationship(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}

_, err = setContractInterfaceRelationshipAttributes(fvRsConsIf, d)
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_fvrsctxtobgpctxafpol.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func resourceAciBGPAddressFamilyContextPolicyRelationshipRead(ctx context.Contex
fvRsCtxToBgpCtxAfPol, err := getRemoteBGPAddressFamilyContextPolicyRelationship(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}

_, err = setBGPAddressFamilyContextPolicyRelationshipAttributes(fvRsCtxToBgpCtxAfPol, d)
Expand Down
4 changes: 2 additions & 2 deletions aci/resource_aci_fvtagselector.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@ func resourceAciEndpointSecurityGroupTagSelectorRead(ctx context.Context, d *sch
fvTagSelector, err := getRemoteEndpointSecurityGroupTagSelector(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setEndpointSecurityGroupTagSelectorAttributes(fvTagSelector, d)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}

log.Printf("[DEBUG] %s: Read finished successfully", d.Id())
Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_infraaccnodepgrp.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ func resourceAciAccessSwitchPolicyGroupRead(ctx context.Context, d *schema.Resou
infraAccNodePGrp, err := getRemoteAccessSwitchPolicyGroup(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
setAccessSwitchPolicyGroupAttributes(infraAccNodePGrp, d)

Expand Down
2 changes: 1 addition & 1 deletion aci/resource_aci_infraporttrackpol.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func resourceAciPortTrackingRead(ctx context.Context, d *schema.ResourceData, m
infraPortTrackPol, err := getRemotePortTracking(aciClient, dn)
if err != nil {
d.SetId("")
return diag.FromErr(err)
return nil
}
_, err = setPortTrackingAttributes(infraPortTrackPol, d)
if err != nil {
Expand Down
Loading

0 comments on commit b369786

Please sign in to comment.