-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-1746] Add util method for policy config items
https://jira.hyperledger.org/browse/FAB-1746 This changeset completes the pattern of providing utility methods in the consumer packages for configuration transaction artifacts by implementing this for the signature policy. Change-Id: Ie74f366f7df2b64fd5fbc245dbd17f5cf61378d3 Signed-off-by: Jason Yellick <jyellick@us.ibm.com>
- Loading branch information
Jason Yellick
committed
Jan 19, 2017
1 parent
add2776
commit c7e3168
Showing
2 changed files
with
36 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
Copyright IBM Corp. 2016 All Rights Reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package cauthdsl | ||
|
||
import ( | ||
cb "github.com/hyperledger/fabric/protos/common" | ||
"github.com/hyperledger/fabric/protos/utils" | ||
) | ||
|
||
// TemplatePolicy creates a headerless configuration item representing a policy for a given key | ||
func TemplatePolicy(key string, sigPolicyEnv *cb.SignaturePolicyEnvelope) *cb.ConfigurationItem { | ||
return &cb.ConfigurationItem{ | ||
Type: cb.ConfigurationItem_Policy, | ||
Key: key, | ||
Value: utils.MarshalOrPanic(&cb.Policy{ | ||
Type: int32(cb.Policy_SIGNATURE), | ||
Policy: utils.MarshalOrPanic(sigPolicyEnv), | ||
}), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters