Skip to content

Commit 54ec3ce

Browse files
committed
[FAB-15038] remove unnecessary type assertions
And colonize one assignment Change-Id: Ieb6dcfd63cc637c556b8225053d0458662e1e501 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent 703f1d3 commit 54ec3ce

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

core/aclmgmt/resourceprovider.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,9 @@ func (rp *aclmgmtPolicyProviderImpl) CheckACL(polName string, idinfo interface{}
9595

9696
//we will implement other identifiers. In the end we just need a SignedData
9797
var sd []*protoutil.SignedData
98-
var err error
99-
switch idinfo.(type) {
98+
switch idinfo := idinfo.(type) {
10099
case *pb.SignedProposal:
101-
signedProp, _ := idinfo.(*pb.SignedProposal)
102-
// Prepare SignedData
100+
signedProp := idinfo
103101
proposal, err := protoutil.GetProposal(signedProp.ProposalBytes)
104102
if err != nil {
105103
return fmt.Errorf("Failing extracting proposal during check policy with policy [%s]: [%s]", polName, err)
@@ -120,17 +118,19 @@ func (rp *aclmgmtPolicyProviderImpl) CheckACL(polName string, idinfo interface{}
120118
Identity: shdr.Creator,
121119
Signature: signedProp.Signature,
122120
}}
121+
123122
case *common.Envelope:
124-
env := idinfo.(*common.Envelope)
125-
sd, err = protoutil.EnvelopeAsSignedData(env)
123+
var err error
124+
sd, err = protoutil.EnvelopeAsSignedData(idinfo)
126125
if err != nil {
127126
return err
128127
}
128+
129129
default:
130130
return InvalidIdInfo(polName)
131131
}
132132

133-
err = rp.pEvaluator.Evaluate(polName, sd)
133+
err := rp.pEvaluator.Evaluate(polName, sd)
134134
if err != nil {
135135
return fmt.Errorf("failed evaluating policy on signed data during check policy [%s]: [%s]", polName, err)
136136
}

core/aclmgmt/resourceprovider_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ func TestForceDefaultsForPType(t *testing.T) {
108108
}
109109

110110
func init() {
111-
var err error
112111
// setup the MSP manager so that we can sign/verify
113-
err = msptesttools.LoadMSPSetupForTesting()
112+
err := msptesttools.LoadMSPSetupForTesting()
114113
if err != nil {
115114
fmt.Printf("Could not load msp config, err %s", err)
116115
os.Exit(-1)

0 commit comments

Comments
 (0)