From 4175cd420e2bced3d99eb671ed0e56311d0c42ef Mon Sep 17 00:00:00 2001 From: Aditya Joshi Date: Thu, 29 Jun 2023 01:43:08 +0200 Subject: [PATCH 1/7] channel management api added Signed-off-by: adityajoshi12 --- .gitignore | 3 +- controllers/testutils/genesis.go | 776 ++++++++++++++++ .../hyperledger/fabric/bccsp/aesopts.go | 86 ++ .../hyperledger/fabric/bccsp/bccsp.go | 138 +++ .../hyperledger/fabric/bccsp/ecdsaopts.go | 53 ++ .../hyperledger/fabric/bccsp/hashopts.go | 74 ++ .../hyperledger/fabric/bccsp/keystore.go | 38 + .../hyperledger/fabric/bccsp/opts.go | 270 ++++++ .../hyperledger/fabric/bccsp/signer/signer.go | 83 ++ .../hyperledger/fabric/bccsp/utils/ecdsa.go | 113 +++ .../fabric/common/capabilities/application.go | 167 ++++ .../common/capabilities/capabilities.go | 55 ++ .../fabric/common/capabilities/channel.go | 105 +++ .../fabric/common/capabilities/orderer.go | 99 ++ .../fabric/common/channelconfig/acls.go | 47 + .../fabric/common/channelconfig/api.go | 266 ++++++ .../common/channelconfig/application.go | 83 ++ .../common/channelconfig/applicationorg.go | 76 ++ .../fabric/common/channelconfig/bundle.go | 21 + .../fabric/common/channelconfig/channel.go | 217 +++++ .../fabric/common/channelconfig/consortium.go | 65 ++ .../common/channelconfig/consortiums.go | 45 + .../fabric/common/channelconfig/msp.go | 113 +++ .../fabric/common/channelconfig/orderer.go | 277 ++++++ .../common/channelconfig/organization.go | 101 +++ .../common/channelconfig/standardvalues.go | 115 +++ .../fabric/common/channelconfig/utils.go | 263 ++++++ .../fabric/common/configtx/configtx.go | 34 + .../fabric/common/genesis/genesis.go | 61 ++ .../common/metrics/disabled/provider.go | 43 + .../common/metrics/internal/namer/namer.go | 148 +++ .../common/metrics/prometheus/provider.go | 81 ++ .../fabric/common/metrics/provider.go | 173 ++++ .../metrics/statsd/goruntime/collector.go | 134 +++ .../metrics/statsd/goruntime/metrics.go | 47 + .../fabric/common/metrics/statsd/provider.go | 132 +++ .../common/policies/implicitmetaparser.go | 42 + .../fabric/common/policies/policy.go | 129 +++ .../fabric/common/policies/util.go | 86 ++ .../common/policydsl/policydsl_builder.go | 206 +++++ .../fabric/common/policydsl/policyparser.go | 357 ++++++++ .../hyperledger/fabric/common/util/utils.go | 97 ++ .../hyperledger/fabric/msp/cache/cache.go | 58 ++ .../fabric/msp/cache/second_chance.go | 117 +++ .../github.com/hyperledger/fabric/msp/cert.go | 154 ++++ .../hyperledger/fabric/msp/configbuilder.go | 329 +++++++ .../hyperledger/fabric/msp/factory.go | 71 ++ .../hyperledger/fabric/msp/identities.go | 273 ++++++ .../github.com/hyperledger/fabric/msp/msp.go | 230 +++++ .../hyperledger/fabric/msp/mspimpl.go | 857 ++++++++++++++++++ .../hyperledger/fabric/msp/mspimplsetup.go | 674 ++++++++++++++ .../hyperledger/fabric/msp/mspimplvalidate.go | 355 ++++++++ .../hyperledger/fabric/msp/mspmgrimpl.go | 112 +++ .../fabric/protoutil/blockutils.go | 224 +++++ .../fabric/protoutil/commonutils.go | 269 ++++++ .../fabric/protoutil/configtxutils.go | 25 + .../hyperledger/fabric/protoutil/proputils.go | 414 +++++++++ .../fabric/protoutil/signeddata.go | 86 ++ .../hyperledger/fabric/protoutil/txutils.go | 520 +++++++++++ .../fabric/protoutil/unmarshalers.go | 213 +++++ .../configtxgen/encoder/encoder.go | 627 +++++++++++++ .../configtxgen/genesisconfig/config.go | 164 ++++ .../configtxlator/update/update.go | 242 +++++ .../fabric/sdkinternal/pkg/comm/config.go | 173 ++++ .../sdkinternal/pkg/identity/identity.go | 33 + .../pkg/txflags/validation_flags.go | 64 ++ .../fabric/sdkpatch/cachebridge/cache.go | 125 +++ .../cryptosuitebridge/cryptosuitebridge.go | 104 +++ .../fabric/sdkpatch/keyutil/keys.go | 73 ++ .../sdkpatch/logbridge/httpadmin/spec.go | 85 ++ .../fabric/sdkpatch/logbridge/logbridge.go | 55 ++ kubectl-hlf/cmd/channel/addanchorpeer.go | 162 ++++ kubectl-hlf/cmd/channel/addorg.go | 153 ++++ kubectl-hlf/cmd/channel/channel.go | 11 + kubectl-hlf/cmd/channel/consenter/add.go | 138 +++ .../cmd/channel/consenter/consenter.go | 19 + kubectl-hlf/cmd/channel/consenter/remove.go | 132 +++ kubectl-hlf/cmd/channel/consenter/replace.go | 145 +++ kubectl-hlf/cmd/channel/create.go | 167 ++++ kubectl-hlf/cmd/channel/delanchorpeer.go | 108 +++ kubectl-hlf/cmd/channel/generate.go | 231 +++++ kubectl-hlf/cmd/channel/join.go | 79 ++ kubectl-hlf/cmd/channel/ordorg/add.go | 129 +++ kubectl-hlf/cmd/channel/ordorg/ordorg.go | 18 + kubectl-hlf/cmd/channel/ordorg/remove.go | 100 ++ kubectl-hlf/cmd/channel/signupdate.go | 103 +++ kubectl-hlf/cmd/helpers/channel.go | 74 ++ kubectl-hlf/cmd/helpers/hlf.go | 4 +- 88 files changed, 14015 insertions(+), 3 deletions(-) create mode 100644 controllers/testutils/genesis.go create mode 100644 internal/github.com/hyperledger/fabric/bccsp/aesopts.go create mode 100644 internal/github.com/hyperledger/fabric/bccsp/bccsp.go create mode 100644 internal/github.com/hyperledger/fabric/bccsp/ecdsaopts.go create mode 100644 internal/github.com/hyperledger/fabric/bccsp/hashopts.go create mode 100644 internal/github.com/hyperledger/fabric/bccsp/keystore.go create mode 100644 internal/github.com/hyperledger/fabric/bccsp/opts.go create mode 100644 internal/github.com/hyperledger/fabric/bccsp/signer/signer.go create mode 100644 internal/github.com/hyperledger/fabric/bccsp/utils/ecdsa.go create mode 100644 internal/github.com/hyperledger/fabric/common/capabilities/application.go create mode 100644 internal/github.com/hyperledger/fabric/common/capabilities/capabilities.go create mode 100644 internal/github.com/hyperledger/fabric/common/capabilities/channel.go create mode 100644 internal/github.com/hyperledger/fabric/common/capabilities/orderer.go create mode 100644 internal/github.com/hyperledger/fabric/common/channelconfig/acls.go create mode 100644 internal/github.com/hyperledger/fabric/common/channelconfig/api.go create mode 100644 internal/github.com/hyperledger/fabric/common/channelconfig/application.go create mode 100644 internal/github.com/hyperledger/fabric/common/channelconfig/applicationorg.go create mode 100644 internal/github.com/hyperledger/fabric/common/channelconfig/bundle.go create mode 100644 internal/github.com/hyperledger/fabric/common/channelconfig/channel.go create mode 100644 internal/github.com/hyperledger/fabric/common/channelconfig/consortium.go create mode 100644 internal/github.com/hyperledger/fabric/common/channelconfig/consortiums.go create mode 100644 internal/github.com/hyperledger/fabric/common/channelconfig/msp.go create mode 100644 internal/github.com/hyperledger/fabric/common/channelconfig/orderer.go create mode 100644 internal/github.com/hyperledger/fabric/common/channelconfig/organization.go create mode 100644 internal/github.com/hyperledger/fabric/common/channelconfig/standardvalues.go create mode 100644 internal/github.com/hyperledger/fabric/common/channelconfig/utils.go create mode 100644 internal/github.com/hyperledger/fabric/common/configtx/configtx.go create mode 100644 internal/github.com/hyperledger/fabric/common/genesis/genesis.go create mode 100644 internal/github.com/hyperledger/fabric/common/metrics/disabled/provider.go create mode 100644 internal/github.com/hyperledger/fabric/common/metrics/internal/namer/namer.go create mode 100644 internal/github.com/hyperledger/fabric/common/metrics/prometheus/provider.go create mode 100644 internal/github.com/hyperledger/fabric/common/metrics/provider.go create mode 100644 internal/github.com/hyperledger/fabric/common/metrics/statsd/goruntime/collector.go create mode 100644 internal/github.com/hyperledger/fabric/common/metrics/statsd/goruntime/metrics.go create mode 100644 internal/github.com/hyperledger/fabric/common/metrics/statsd/provider.go create mode 100644 internal/github.com/hyperledger/fabric/common/policies/implicitmetaparser.go create mode 100644 internal/github.com/hyperledger/fabric/common/policies/policy.go create mode 100644 internal/github.com/hyperledger/fabric/common/policies/util.go create mode 100644 internal/github.com/hyperledger/fabric/common/policydsl/policydsl_builder.go create mode 100644 internal/github.com/hyperledger/fabric/common/policydsl/policyparser.go create mode 100644 internal/github.com/hyperledger/fabric/common/util/utils.go create mode 100644 internal/github.com/hyperledger/fabric/msp/cache/cache.go create mode 100644 internal/github.com/hyperledger/fabric/msp/cache/second_chance.go create mode 100644 internal/github.com/hyperledger/fabric/msp/cert.go create mode 100644 internal/github.com/hyperledger/fabric/msp/configbuilder.go create mode 100644 internal/github.com/hyperledger/fabric/msp/factory.go create mode 100644 internal/github.com/hyperledger/fabric/msp/identities.go create mode 100644 internal/github.com/hyperledger/fabric/msp/msp.go create mode 100644 internal/github.com/hyperledger/fabric/msp/mspimpl.go create mode 100644 internal/github.com/hyperledger/fabric/msp/mspimplsetup.go create mode 100644 internal/github.com/hyperledger/fabric/msp/mspimplvalidate.go create mode 100644 internal/github.com/hyperledger/fabric/msp/mspmgrimpl.go create mode 100644 internal/github.com/hyperledger/fabric/protoutil/blockutils.go create mode 100644 internal/github.com/hyperledger/fabric/protoutil/commonutils.go create mode 100644 internal/github.com/hyperledger/fabric/protoutil/configtxutils.go create mode 100644 internal/github.com/hyperledger/fabric/protoutil/proputils.go create mode 100644 internal/github.com/hyperledger/fabric/protoutil/signeddata.go create mode 100644 internal/github.com/hyperledger/fabric/protoutil/txutils.go create mode 100644 internal/github.com/hyperledger/fabric/protoutil/unmarshalers.go create mode 100644 internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/encoder/encoder.go create mode 100644 internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/genesisconfig/config.go create mode 100644 internal/github.com/hyperledger/fabric/sdkinternal/configtxlator/update/update.go create mode 100644 internal/github.com/hyperledger/fabric/sdkinternal/pkg/comm/config.go create mode 100644 internal/github.com/hyperledger/fabric/sdkinternal/pkg/identity/identity.go create mode 100644 internal/github.com/hyperledger/fabric/sdkinternal/pkg/txflags/validation_flags.go create mode 100644 internal/github.com/hyperledger/fabric/sdkpatch/cachebridge/cache.go create mode 100644 internal/github.com/hyperledger/fabric/sdkpatch/cryptosuitebridge/cryptosuitebridge.go create mode 100644 internal/github.com/hyperledger/fabric/sdkpatch/keyutil/keys.go create mode 100644 internal/github.com/hyperledger/fabric/sdkpatch/logbridge/httpadmin/spec.go create mode 100644 internal/github.com/hyperledger/fabric/sdkpatch/logbridge/logbridge.go create mode 100644 kubectl-hlf/cmd/channel/addanchorpeer.go create mode 100644 kubectl-hlf/cmd/channel/addorg.go create mode 100644 kubectl-hlf/cmd/channel/consenter/add.go create mode 100644 kubectl-hlf/cmd/channel/consenter/consenter.go create mode 100644 kubectl-hlf/cmd/channel/consenter/remove.go create mode 100644 kubectl-hlf/cmd/channel/consenter/replace.go create mode 100644 kubectl-hlf/cmd/channel/create.go create mode 100644 kubectl-hlf/cmd/channel/delanchorpeer.go create mode 100644 kubectl-hlf/cmd/channel/generate.go create mode 100644 kubectl-hlf/cmd/channel/join.go create mode 100644 kubectl-hlf/cmd/channel/ordorg/add.go create mode 100644 kubectl-hlf/cmd/channel/ordorg/ordorg.go create mode 100644 kubectl-hlf/cmd/channel/ordorg/remove.go create mode 100644 kubectl-hlf/cmd/channel/signupdate.go create mode 100644 kubectl-hlf/cmd/helpers/channel.go diff --git a/.gitignore b/.gitignore index 31420a72..ea19c5e5 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ bin *.swp *.swo *~ +**/.DS_Store crypto-config keystore @@ -33,4 +34,4 @@ dist/ /hlf-operator /kubectl-hlf/hlf-operator node_modules -istio-* \ No newline at end of file +istio-* diff --git a/controllers/testutils/genesis.go b/controllers/testutils/genesis.go new file mode 100644 index 00000000..225c6380 --- /dev/null +++ b/controllers/testutils/genesis.go @@ -0,0 +1,776 @@ +package testutils + +import ( + "bytes" + "fmt" + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-config/protolator" + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-protos-go/orderer/etcdraft" + "github.com/hyperledger/fabric-sdk-go/pkg/fab/resource/genesisconfig" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/channelconfig" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/encoder" + + genesisconfig2 "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/genesisconfig" + "io/ioutil" + "log" + "os" + "path" + "time" +) + +type ConsortiumMember struct { + MSPID string +} + +type Consortium struct { + Name string + Organizations []*ConsortiumMember +} + +func ordererCapabilities() map[string]bool { + return map[string]bool{ + "V2_0": true, + } +} + +type PeerNode struct { + Host string + Port int +} +type PeerOrganization struct { + RootCert string + TLSRootCert string + MspID string + Peers []PeerNode +} + +func memberToOrg(member PeerOrganization) (*genesisconfig.Organization, error) { + serverTlsCertPem := []byte(member.TLSRootCert) + serverRootCert := []byte(member.RootCert) + mspID := member.MspID + mspDir, err := ioutil.TempDir("", fmt.Sprintf("mspdir_%s", mspID)) + if err != nil { + return nil, err + } + tlsCaCertsPath := path.Join(mspDir, "tlscacerts") + err = os.Mkdir(tlsCaCertsPath, os.ModePerm) + if err != nil { + return nil, err + } + caCertsPath := path.Join(mspDir, "cacerts") + err = os.Mkdir(caCertsPath, os.ModePerm) + if err != nil { + return nil, err + } + err = ioutil.WriteFile(path.Join(caCertsPath, "cacert.pem"), serverRootCert, os.ModePerm) + if err != nil { + return nil, err + } + err = ioutil.WriteFile(path.Join(tlsCaCertsPath, "tlscacert.pem"), serverTlsCertPem, os.ModePerm) + if err != nil { + return nil, err + } + configNodeOU := ` +NodeOUs: + Enable: true + ClientOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: client + PeerOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: peer + AdminOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: admin + OrdererOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: orderer +` + err = ioutil.WriteFile(path.Join(mspDir, "config.yaml"), []byte(configNodeOU), os.ModePerm) + if err != nil { + return nil, err + } + log.Printf("MSPDIR=%s", mspDir) + anchorPeers := []*genesisconfig.AnchorPeer{} + + for _, peer := range member.Peers { + anchorPeers = append(anchorPeers, &genesisconfig.AnchorPeer{ + Host: peer.Host, + Port: peer.Port, + }) + } + genesisOrg := &genesisconfig.Organization{ + Name: mspID, + ID: mspID, + MSPDir: mspDir, + MSPType: "bccsp", + Policies: map[string]*genesisconfig.Policy{ + "Admins": { + Type: "Signature", + Rule: fmt.Sprintf("OR('%s.admin')", mspID), + }, + "Readers": { + Type: "Signature", + Rule: fmt.Sprintf("OR('%s.member')", mspID), + }, + "Writers": { + Type: "Signature", + Rule: fmt.Sprintf("OR('%s.member')", mspID), + }, + }, + AnchorPeers: anchorPeers, + SkipAsForeign: false, + } + return genesisOrg, nil +} + +type OrdererNode struct { + TLSCert string + Host string + Port int +} +type OrdererOrganization struct { + Nodes []OrdererNode + RootTLSCert string + RootSignCert string + MspID string +} + +func memberToOrgUpdate(member PeerOrganization) (*genesisconfig2.Organization, error) { + serverTlsCertPem := []byte(member.TLSRootCert) + rootCertPem := []byte(member.RootCert) + mspID := member.MspID + mspDir, err := ioutil.TempDir("", fmt.Sprintf("mspdir_%s", mspID)) + if err != nil { + return nil, err + } + tlsCaCertsPath := path.Join(mspDir, "tlscacerts") + err = os.Mkdir(tlsCaCertsPath, os.ModePerm) + if err != nil { + return nil, err + } + caCertsPath := path.Join(mspDir, "cacerts") + err = os.Mkdir(caCertsPath, os.ModePerm) + if err != nil { + return nil, err + } + err = ioutil.WriteFile(path.Join(caCertsPath, "cacert.pem"), rootCertPem, os.ModePerm) + if err != nil { + return nil, err + } + err = ioutil.WriteFile(path.Join(tlsCaCertsPath, "tlscacert.pem"), serverTlsCertPem, os.ModePerm) + if err != nil { + return nil, err + } + configNodeOU := ` +NodeOUs: + Enable: true + ClientOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: client + PeerOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: peer + AdminOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: admin + OrdererOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: orderer +` + err = ioutil.WriteFile(path.Join(mspDir, "config.yaml"), []byte(configNodeOU), os.ModePerm) + if err != nil { + return nil, err + } + log.Printf("MSPDIR=%s", mspDir) + anchorPeers := []*genesisconfig2.AnchorPeer{} + for _, peer := range member.Peers { + anchorPeers = append(anchorPeers, &genesisconfig2.AnchorPeer{ + Host: peer.Host, + Port: peer.Port, + }) + } + genesisOrg := &genesisconfig2.Organization{ + Name: mspID, + ID: mspID, + MSPDir: mspDir, + MSPType: "bccsp", + Policies: map[string]*genesisconfig2.Policy{ + "Admins": { + Type: "Signature", + Rule: fmt.Sprintf("OR('%s.admin')", mspID), + }, + "Endorsement": { + Type: "Signature", + Rule: fmt.Sprintf("OR('%s.peer')", mspID), + }, + "Readers": { + Type: "Signature", + Rule: fmt.Sprintf("OR('%s.admin', '%s.peer', '%s.client')", mspID, mspID, mspID), + }, + "Writers": { + Type: "Signature", + Rule: fmt.Sprintf("OR('%s.admin', '%s.client')", mspID, mspID), + }, + }, + AnchorPeers: anchorPeers, + SkipAsForeign: false, + } + return genesisOrg, nil +} + +type AddConsortiumRequest struct { + Name string + Organizations []PeerOrganization +} + +func AddConsortiumToConfig(channelConfig *cb.Config, request AddConsortiumRequest) (*cb.Config, error) { + modifiedConfig := &cb.Config{} + modifiedConfigBytes, err := proto.Marshal(channelConfig) + if err != nil { + return nil, err + } + err = proto.Unmarshal(modifiedConfigBytes, modifiedConfig) + if err != nil { + return nil, err + } + + consortiumGroups := map[string]*cb.ConfigGroup{} + peerOrgs := []*genesisconfig2.Organization{} + for _, member := range request.Organizations { + mspID := member.MspID + peerOrg, err := memberToOrgUpdate(member) + if err != nil { + return nil, err + } + peerOrgs = append(peerOrgs, peerOrg) + configGroup, err := encoder.NewConsortiumOrgGroup(peerOrg) + if err != nil { + return nil, err + } + consortiumGroups[mspID] = configGroup + } + _, ok := modifiedConfig.ChannelGroup.Groups["Consortiums"] + if !ok { + modifiedConfig.ChannelGroup.Groups["Consortiums"] = &cb.ConfigGroup{} + modifiedConfig.ChannelGroup.Groups["Consortiums"].Groups[request.Name] = &cb.ConfigGroup{ + Version: 0, + Groups: nil, + Values: nil, + Policies: nil, + } + } + conf := map[string]*genesisconfig2.Consortium{ + request.Name: { + Organizations: peerOrgs, + }, + } + consortiums, err := encoder.NewConsortiumsGroup( + conf, + ) + if err != nil { + return nil, err + } + modifiedConfig.ChannelGroup.Groups[channelconfig.ConsortiumsGroupKey] = consortiums + return modifiedConfig, nil +} + +type OrdererCapabilities struct { + V2_0 bool +} +type ApplicationCapabilities struct { + V2_0 bool +} +type ChannelCapabilities struct { + V2_0 bool +} +type GenesisConfig struct { + BatchTimeout time.Duration // 2 seconds + MaxMessageCount int // 500 + AbsoluteMaxBytes int // 10 * 1024 * 1024 = 10MB + PreferredMaxBytes int // 2 * 1024 * 1024 = 2MB + OrdererCapabilities OrdererCapabilities + ApplicationCapabilities ApplicationCapabilities + ChannelCapabilities ChannelCapabilities + SnapshotIntervalSize int // 19 + TickInterval string // 500ms + ElectionTick int // 10 + HeartbeatTick int // 1 + MaxInflightBlocks int // 5 +} + +const MB = 1024 * 1024 + +func fillWithDefaultOps(opts *GenesisConfig) { + if opts.BatchTimeout.Seconds() <= 1 { + opts.BatchTimeout = 2 * time.Second + } + if opts.MaxMessageCount == 0 { + opts.MaxMessageCount = 500 + } + if opts.AbsoluteMaxBytes == 0 { + opts.AbsoluteMaxBytes = 10 * MB + } + if opts.PreferredMaxBytes == 0 { + opts.PreferredMaxBytes = 2 * MB + } + if opts.SnapshotIntervalSize == 0 { + opts.SnapshotIntervalSize = 19 + } + if opts.MaxInflightBlocks == 0 { + opts.MaxInflightBlocks = 5 + } + if opts.HeartbeatTick == 0 { + opts.HeartbeatTick = 1 + } + if opts.ElectionTick == 0 { + opts.ElectionTick = 10 + } + if opts.SnapshotIntervalSize == 0 { + opts.SnapshotIntervalSize = 19 + } + if opts.TickInterval == "" { + opts.TickInterval = "500ms" + } +} +func GetProfileConfig( + ordOrgs []OrdererOrganization, + config GenesisConfig, +) (*genesisconfig.Profile, error) { + fillWithDefaultOps(&config) + organizations := []*genesisconfig.Organization{} + ordererOrganizations := []*genesisconfig.Organization{} + consenters := []*etcdraft.Consenter{} + ordererAddresses := []string{} + log.Printf("Orderer organization: %d", len(ordOrgs)) + for _, org := range ordOrgs { + serverRootTlsCertPem := []byte(org.RootTLSCert) + serverRootSignCertPem := []byte(org.RootSignCert) + for _, node := range org.Nodes { + clientTlsCertPem := []byte(node.TLSCert) + serverTlsCertPem := []byte(node.TLSCert) + clientCertFile, err := ioutil.TempFile("", "clientcert") + if err != nil { + return nil, err + } + err = ioutil.WriteFile(clientCertFile.Name(), clientTlsCertPem, 644) + if err != nil { + return nil, err + } + + serverCertFile, err := ioutil.TempFile("", "servercert") + if err != nil { + return nil, err + } + err = ioutil.WriteFile(serverCertFile.Name(), serverTlsCertPem, 644) + if err != nil { + return nil, err + } + ordererHost := node.Host + ordererPort := node.Port + consenters = append(consenters, &etcdraft.Consenter{ + Host: ordererHost, + Port: uint32(ordererPort), + ClientTlsCert: []byte(clientCertFile.Name()), + ServerTlsCert: []byte(serverCertFile.Name()), + }) + + ordererAddresses = append(ordererAddresses, fmt.Sprintf("%s:%d", ordererHost, ordererPort)) + } + ordererOrgMspDir, err := ioutil.TempDir("", fmt.Sprintf("mspdir_%s", org.MspID)) + if err != nil { + return nil, err + } + tlsCaCertsPath := path.Join(ordererOrgMspDir, "tlscacerts") + err = os.Mkdir(tlsCaCertsPath, os.ModePerm) + if err != nil { + return nil, err + } + caCertsPath := path.Join(ordererOrgMspDir, "cacerts") + err = os.Mkdir(caCertsPath, os.ModePerm) + if err != nil { + return nil, err + } + err = ioutil.WriteFile(path.Join(caCertsPath, "cacert.pem"), serverRootSignCertPem, os.ModePerm) + if err != nil { + return nil, err + } + err = ioutil.WriteFile(path.Join(tlsCaCertsPath, "tlscacert.pem"), serverRootTlsCertPem, os.ModePerm) + if err != nil { + return nil, err + } + configNodeOU := ` +NodeOUs: + Enable: true + ClientOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: client + PeerOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: peer + AdminOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: admin + OrdererOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: orderer +` + err = ioutil.WriteFile(path.Join(ordererOrgMspDir, "config.yaml"), []byte(configNodeOU), os.ModePerm) + if err != nil { + return nil, err + } + log.Printf("MSPDIR=%s", ordererOrgMspDir) + ordererOrganizations = append(ordererOrganizations, &genesisconfig.Organization{ + Name: org.MspID, + ID: org.MspID, + MSPDir: ordererOrgMspDir, + MSPType: "bccsp", + Policies: map[string]*genesisconfig.Policy{ + "Readers": { + Type: "Signature", + Rule: fmt.Sprintf("OR('%s.member')", org.MspID), + }, + "Writers": { + Type: "Signature", + Rule: fmt.Sprintf("OR('%s.member')", org.MspID), + }, + "Admins": { + Type: "Signature", + Rule: fmt.Sprintf("OR('%s.admin')", org.MspID), + }, + }, + AnchorPeers: nil, + SkipAsForeign: false, + }) + } + profileConfig := &genesisconfig.Profile{ + Application: &genesisconfig.Application{ + Organizations: organizations, + Capabilities: map[string]bool{ + "V2_0": config.ApplicationCapabilities.V2_0, + }, + Policies: map[string]*genesisconfig.Policy{ + "Admins": { + Type: "ImplicitMeta", + Rule: "MAJORITY Admins", + }, + "Endorsement": { + Type: "ImplicitMeta", + Rule: "MAJORITY Endorsement", + }, + "LifecycleEndorsement": { + Type: "ImplicitMeta", + Rule: "MAJORITY Endorsement", + }, + "Readers": { + Type: "ImplicitMeta", + Rule: "ANY Readers", + }, + "Writers": { + Type: "ImplicitMeta", + Rule: "ANY Writers", + }, + }, + ACLs: nil, + }, + Orderer: &genesisconfig.Orderer{ + OrdererType: "etcdraft", + EtcdRaft: &etcdraft.ConfigMetadata{ + Consenters: consenters, + Options: &etcdraft.Options{ + SnapshotIntervalSize: uint32(config.SnapshotIntervalSize), + TickInterval: config.TickInterval, + ElectionTick: uint32(config.ElectionTick), + HeartbeatTick: uint32(config.HeartbeatTick), + MaxInflightBlocks: uint32(config.MaxInflightBlocks), + }, + }, + Addresses: ordererAddresses, + BatchTimeout: config.BatchTimeout, + BatchSize: genesisconfig.BatchSize{ + MaxMessageCount: uint32(config.MaxMessageCount), + AbsoluteMaxBytes: uint32(config.AbsoluteMaxBytes), + PreferredMaxBytes: uint32(config.PreferredMaxBytes), + }, + Organizations: ordererOrganizations, + Policies: map[string]*genesisconfig.Policy{ + "Readers": { + Type: "ImplicitMeta", + Rule: "ANY Readers", + }, + "Writers": { + Type: "ImplicitMeta", + Rule: "ANY Writers", + }, + "Admins": { + Type: "ImplicitMeta", + Rule: "ANY Admins", + }, + "BlockValidation": { + Type: "ImplicitMeta", + Rule: "ANY Writers", + }, + }, + Capabilities: map[string]bool{ + "V2_0": config.OrdererCapabilities.V2_0, + }, + }, + Consortiums: map[string]*genesisconfig.Consortium{}, + Capabilities: map[string]bool{ + "V2_0": config.ChannelCapabilities.V2_0, + }, + Policies: map[string]*genesisconfig.Policy{ + "Admins": { + Type: "ImplicitMeta", + Rule: "MAJORITY Admins", + }, + "Readers": { + Type: "ImplicitMeta", + Rule: "ANY Readers", + }, + "Writers": { + Type: "ImplicitMeta", + Rule: "ANY Writers", + }, + }, + } + return profileConfig, nil +} + +func GetConfigEnvelopeBytes(configUpdate *cb.ConfigUpdate) ([]byte, error) { + var buf bytes.Buffer + if err := protolator.DeepMarshalJSON(&buf, configUpdate); err != nil { + return nil, err + } + channelConfigBytes, err := proto.Marshal(configUpdate) + if err != nil { + return nil, err + } + configUpdateEnvelope := &cb.ConfigUpdateEnvelope{ + ConfigUpdate: channelConfigBytes, + Signatures: nil, + } + configUpdateEnvelopeBytes, err := proto.Marshal(configUpdateEnvelope) + if err != nil { + return nil, err + } + payload := &cb.Payload{ + Data: configUpdateEnvelopeBytes, + } + payloadBytes, err := proto.Marshal(payload) + if err != nil { + return nil, err + } + configEnvelope := &cb.Envelope{ + Payload: payloadBytes, + } + return proto.Marshal(configEnvelope) +} + +func GetChannelProfileConfig( + ordService OrdererOrganization, + members []PeerOrganization, + consortiumName string, + adminPolicy string, +) (*genesisconfig.Profile, error) { + var organizations []*genesisconfig.Organization + + var ordererOrganizations []*genesisconfig.Organization + var consenters []*etcdraft.Consenter + var ordererAddresses []string + + for _, node := range ordService.Nodes { + clientTlsCertPem := []byte(node.TLSCert) + serverTlsCertPem := []byte(node.TLSCert) + clientCertFile, err := ioutil.TempFile("", "clientcert") + if err != nil { + return nil, err + } + err = ioutil.WriteFile(clientCertFile.Name(), clientTlsCertPem, 644) + if err != nil { + return nil, err + } + + serverCertFile, err := ioutil.TempFile("", "servercert") + if err != nil { + return nil, err + } + err = ioutil.WriteFile(serverCertFile.Name(), serverTlsCertPem, 644) + if err != nil { + return nil, err + } + ordererHost := node.Host + ordererPort := node.Port + consenters = append(consenters, &etcdraft.Consenter{ + Host: ordererHost, + Port: uint32(ordererPort), + ClientTlsCert: []byte(clientCertFile.Name()), + ServerTlsCert: []byte(serverCertFile.Name()), + }) + + ordererAddresses = append(ordererAddresses, fmt.Sprintf("%s:%d", ordererHost, ordererPort)) + } + ordererOrgMspDir, err := ioutil.TempDir("", fmt.Sprintf("mspdir_%s", ordService.MspID)) + if err != nil { + return nil, err + } + tlsCaCertsPath := path.Join(ordererOrgMspDir, "tlscacerts") + err = os.Mkdir(tlsCaCertsPath, os.ModePerm) + if err != nil { + return nil, err + } + caCertsPath := path.Join(ordererOrgMspDir, "cacerts") + err = os.Mkdir(caCertsPath, os.ModePerm) + if err != nil { + return nil, err + } + + serverRootCertPem := []byte(ordService.RootSignCert) + serverRootTlsCertPem := []byte(ordService.RootTLSCert) + err = ioutil.WriteFile(path.Join(caCertsPath, "cacert.pem"), serverRootCertPem, os.ModePerm) + if err != nil { + return nil, err + } + err = ioutil.WriteFile(path.Join(tlsCaCertsPath, "tlscacert.pem"), serverRootTlsCertPem, os.ModePerm) + if err != nil { + return nil, err + } + configNodeOU := ` +NodeOUs: + Enable: true + ClientOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: client + PeerOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: peer + AdminOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: admin + OrdererOUIdentifier: + Certificate: cacerts/cacert.pem + OrganizationalUnitIdentifier: orderer +` + err = ioutil.WriteFile(path.Join(ordererOrgMspDir, "config.yaml"), []byte(configNodeOU), os.ModePerm) + if err != nil { + return nil, err + } + log.Printf("MSPDIR=%s", ordererOrgMspDir) + ordererOrganizations = append(ordererOrganizations, &genesisconfig.Organization{ + Name: ordService.MspID, + ID: ordService.MspID, + MSPDir: ordererOrgMspDir, + MSPType: "bccsp", + Policies: map[string]*genesisconfig.Policy{ + "Readers": { + Type: "Signature", + Rule: fmt.Sprintf("OR('%s.member')", ordService.MspID), + }, + "Writers": { + Type: "Signature", + Rule: fmt.Sprintf("OR('%s.member')", ordService.MspID), + }, + "Admins": { + Type: "Signature", + Rule: fmt.Sprintf("OR('%s.admin')", ordService.MspID), + }, + }, + AnchorPeers: nil, + SkipAsForeign: false, + }) + log.Printf("Members: %d", len(members)) + for _, member := range members { + peerOrg, err := memberToOrg(member) + if err != nil { + return nil, err + } + organizations = append(organizations, peerOrg) + } + profileConfig := &genesisconfig.Profile{ + Consortium: consortiumName, + Application: &genesisconfig.Application{ + Organizations: organizations, + Capabilities: ordererCapabilities(), + Policies: map[string]*genesisconfig.Policy{ + "Admins": { + Type: "Signature", + Rule: adminPolicy, + }, + "Endorsement": { + Type: "ImplicitMeta", + Rule: "MAJORITY Endorsement", + }, + "LifecycleEndorsement": { + Type: "ImplicitMeta", + Rule: "MAJORITY Endorsement", + }, + "Readers": { + Type: "ImplicitMeta", + Rule: "ANY Readers", + }, + "Writers": { + Type: "ImplicitMeta", + Rule: "ANY Writers", + }, + }, + ACLs: nil, + }, + Orderer: &genesisconfig.Orderer{ + OrdererType: "etcdraft", + EtcdRaft: &etcdraft.ConfigMetadata{ + Consenters: consenters, + Options: &etcdraft.Options{ + SnapshotIntervalSize: 19, + TickInterval: "500ms", + ElectionTick: 10, + HeartbeatTick: 1, + MaxInflightBlocks: 5, + }, + }, + Addresses: ordererAddresses, + BatchTimeout: 2 * time.Second, + BatchSize: genesisconfig.BatchSize{ + MaxMessageCount: 500, + AbsoluteMaxBytes: 10 * 1024 * 1024, + PreferredMaxBytes: 2 * 1024 * 1024, + }, + Organizations: ordererOrganizations, + Policies: map[string]*genesisconfig.Policy{ + "Readers": { + Type: "ImplicitMeta", + Rule: "ANY Readers", + }, + "Writers": { + Type: "ImplicitMeta", + Rule: "ANY Writers", + }, + "Admins": { + Type: "ImplicitMeta", + Rule: "ANY Admins", + }, + "BlockValidation": { + Type: "ImplicitMeta", + Rule: "ANY Writers", + }, + }, + Capabilities: ordererCapabilities(), + }, + Capabilities: ordererCapabilities(), + Policies: map[string]*genesisconfig.Policy{ + "Admins": { + Type: "ImplicitMeta", + Rule: "MAJORITY Admins", + }, + "Readers": { + Type: "ImplicitMeta", + Rule: "ANY Readers", + }, + "Writers": { + Type: "ImplicitMeta", + Rule: "ANY Writers", + }, + }, + } + return profileConfig, nil +} diff --git a/internal/github.com/hyperledger/fabric/bccsp/aesopts.go b/internal/github.com/hyperledger/fabric/bccsp/aesopts.go new file mode 100644 index 00000000..f2ea84d2 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/bccsp/aesopts.go @@ -0,0 +1,86 @@ +/* +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. +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package bccsp + +import "io" + +// AES128KeyGenOpts contains options for AES key generation at 128 security level +type AES128KeyGenOpts struct { + Temporary bool +} + +// Algorithm returns the key generation algorithm identifier (to be used). +func (opts *AES128KeyGenOpts) Algorithm() string { + return AES128 +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (opts *AES128KeyGenOpts) Ephemeral() bool { + return opts.Temporary +} + +// AES192KeyGenOpts contains options for AES key generation at 192 security level +type AES192KeyGenOpts struct { + Temporary bool +} + +// Algorithm returns the key generation algorithm identifier (to be used). +func (opts *AES192KeyGenOpts) Algorithm() string { + return AES192 +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (opts *AES192KeyGenOpts) Ephemeral() bool { + return opts.Temporary +} + +// AES256KeyGenOpts contains options for AES key generation at 256 security level +type AES256KeyGenOpts struct { + Temporary bool +} + +// Algorithm returns the key generation algorithm identifier (to be used). +func (opts *AES256KeyGenOpts) Algorithm() string { + return AES256 +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (opts *AES256KeyGenOpts) Ephemeral() bool { + return opts.Temporary +} + +// AESCBCPKCS7ModeOpts contains options for AES encryption in CBC mode +// with PKCS7 padding. +// Notice that both IV and PRNG can be nil. In that case, the BCCSP implementation +// is supposed to sample the IV using a cryptographic secure PRNG. +// Notice also that either IV or PRNG can be different from nil. +type AESCBCPKCS7ModeOpts struct { + // IV is the initialization vector to be used by the underlying cipher. + // The length of IV must be the same as the Block's block size. + // It is used only if different from nil. + IV []byte + // PRNG is an instance of a PRNG to be used by the underlying cipher. + // It is used only if different from nil. + PRNG io.Reader +} diff --git a/internal/github.com/hyperledger/fabric/bccsp/bccsp.go b/internal/github.com/hyperledger/fabric/bccsp/bccsp.go new file mode 100644 index 00000000..8d15c082 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/bccsp/bccsp.go @@ -0,0 +1,138 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package bccsp + +import ( + "crypto" + "hash" +) + +// Key represents a cryptographic key +type Key interface { + + // Bytes converts this key to its byte representation, + // if this operation is allowed. + Bytes() ([]byte, error) + + // SKI returns the subject key identifier of this key. + SKI() []byte + + // Symmetric returns true if this key is a symmetric key, + // false is this key is asymmetric + Symmetric() bool + + // Private returns true if this key is a private key, + // false otherwise. + Private() bool + + // PublicKey returns the corresponding public key part of an asymmetric public/private key pair. + // This method returns an error in symmetric key schemes. + PublicKey() (Key, error) +} + +// KeyGenOpts contains options for key-generation with a CSP. +type KeyGenOpts interface { + + // Algorithm returns the key generation algorithm identifier (to be used). + Algorithm() string + + // Ephemeral returns true if the key to generate has to be ephemeral, + // false otherwise. + Ephemeral() bool +} + +// KeyDerivOpts contains options for key-derivation with a CSP. +type KeyDerivOpts interface { + + // Algorithm returns the key derivation algorithm identifier (to be used). + Algorithm() string + + // Ephemeral returns true if the key to derived has to be ephemeral, + // false otherwise. + Ephemeral() bool +} + +// KeyImportOpts contains options for importing the raw material of a key with a CSP. +type KeyImportOpts interface { + + // Algorithm returns the key importation algorithm identifier (to be used). + Algorithm() string + + // Ephemeral returns true if the key generated has to be ephemeral, + // false otherwise. + Ephemeral() bool +} + +// HashOpts contains options for hashing with a CSP. +type HashOpts interface { + + // Algorithm returns the hash algorithm identifier (to be used). + Algorithm() string +} + +// SignerOpts contains options for signing with a CSP. +type SignerOpts interface { + crypto.SignerOpts +} + +// EncrypterOpts contains options for encrypting with a CSP. +type EncrypterOpts interface{} + +// DecrypterOpts contains options for decrypting with a CSP. +type DecrypterOpts interface{} + +// BCCSP is the blockchain cryptographic service provider that offers +// the implementation of cryptographic standards and algorithms. +type BCCSP interface { + + // KeyGen generates a key using opts. + KeyGen(opts KeyGenOpts) (k Key, err error) + + // KeyDeriv derives a key from k using opts. + // The opts argument should be appropriate for the primitive used. + KeyDeriv(k Key, opts KeyDerivOpts) (dk Key, err error) + + // KeyImport imports a key from its raw representation using opts. + // The opts argument should be appropriate for the primitive used. + KeyImport(raw interface{}, opts KeyImportOpts) (k Key, err error) + + // GetKey returns the key this CSP associates to + // the Subject Key Identifier ski. + GetKey(ski []byte) (k Key, err error) + + // Hash hashes messages msg using options opts. + // If opts is nil, the default hash function will be used. + Hash(msg []byte, opts HashOpts) (hash []byte, err error) + + // GetHash returns and instance of hash.Hash using options opts. + // If opts is nil, the default hash function will be returned. + GetHash(opts HashOpts) (h hash.Hash, err error) + + // Sign signs digest using key k. + // The opts argument should be appropriate for the algorithm used. + // + // Note that when a signature of a hash of a larger message is needed, + // the caller is responsible for hashing the larger message and passing + // the hash (as digest). + Sign(k Key, digest []byte, opts SignerOpts) (signature []byte, err error) + + // Verify verifies signature against key k and digest + // The opts argument should be appropriate for the algorithm used. + Verify(k Key, signature, digest []byte, opts SignerOpts) (valid bool, err error) + + // Encrypt encrypts plaintext using key k. + // The opts argument should be appropriate for the algorithm used. + Encrypt(k Key, plaintext []byte, opts EncrypterOpts) (ciphertext []byte, err error) + + // Decrypt decrypts ciphertext using key k. + // The opts argument should be appropriate for the algorithm used. + Decrypt(k Key, ciphertext []byte, opts DecrypterOpts) (plaintext []byte, err error) +} diff --git a/internal/github.com/hyperledger/fabric/bccsp/ecdsaopts.go b/internal/github.com/hyperledger/fabric/bccsp/ecdsaopts.go new file mode 100644 index 00000000..b105a1fa --- /dev/null +++ b/internal/github.com/hyperledger/fabric/bccsp/ecdsaopts.go @@ -0,0 +1,53 @@ +/* +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. +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package bccsp + +// ECDSAP256KeyGenOpts contains options for ECDSA key generation with curve P-256. +type ECDSAP256KeyGenOpts struct { + Temporary bool +} + +// Algorithm returns the key generation algorithm identifier (to be used). +func (opts *ECDSAP256KeyGenOpts) Algorithm() string { + return ECDSAP256 +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (opts *ECDSAP256KeyGenOpts) Ephemeral() bool { + return opts.Temporary +} + +// ECDSAP384KeyGenOpts contains options for ECDSA key generation with curve P-384. +type ECDSAP384KeyGenOpts struct { + Temporary bool +} + +// Algorithm returns the key generation algorithm identifier (to be used). +func (opts *ECDSAP384KeyGenOpts) Algorithm() string { + return ECDSAP384 +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (opts *ECDSAP384KeyGenOpts) Ephemeral() bool { + return opts.Temporary +} diff --git a/internal/github.com/hyperledger/fabric/bccsp/hashopts.go b/internal/github.com/hyperledger/fabric/bccsp/hashopts.go new file mode 100644 index 00000000..6209feca --- /dev/null +++ b/internal/github.com/hyperledger/fabric/bccsp/hashopts.go @@ -0,0 +1,74 @@ +/* +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. +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package bccsp + +import "fmt" + +// SHA256Opts contains options relating to SHA-256. +type SHA256Opts struct { +} + +// Algorithm returns the hash algorithm identifier (to be used). +func (opts *SHA256Opts) Algorithm() string { + return SHA256 +} + +// SHA384Opts contains options relating to SHA-384. +type SHA384Opts struct { +} + +// Algorithm returns the hash algorithm identifier (to be used). +func (opts *SHA384Opts) Algorithm() string { + return SHA384 +} + +// SHA3_256Opts contains options relating to SHA3-256. +type SHA3_256Opts struct { +} + +// Algorithm returns the hash algorithm identifier (to be used). +func (opts *SHA3_256Opts) Algorithm() string { + return SHA3_256 +} + +// SHA3_384Opts contains options relating to SHA3-384. +type SHA3_384Opts struct { +} + +// Algorithm returns the hash algorithm identifier (to be used). +func (opts *SHA3_384Opts) Algorithm() string { + return SHA3_384 +} + +// GetHashOpt returns the HashOpts corresponding to the passed hash function +func GetHashOpt(hashFunction string) (HashOpts, error) { + switch hashFunction { + case SHA256: + return &SHA256Opts{}, nil + case SHA384: + return &SHA384Opts{}, nil + case SHA3_256: + return &SHA3_256Opts{}, nil + case SHA3_384: + return &SHA3_384Opts{}, nil + } + return nil, fmt.Errorf("hash function not recognized [%s]", hashFunction) +} diff --git a/internal/github.com/hyperledger/fabric/bccsp/keystore.go b/internal/github.com/hyperledger/fabric/bccsp/keystore.go new file mode 100644 index 00000000..6df3aa3d --- /dev/null +++ b/internal/github.com/hyperledger/fabric/bccsp/keystore.go @@ -0,0 +1,38 @@ +/* +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. +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ +package bccsp + +// KeyStore represents a storage system for cryptographic keys. +// It allows to store and retrieve bccsp.Key objects. +// The KeyStore can be read only, in that case StoreKey will return +// an error. +type KeyStore interface { + + // ReadOnly returns true if this KeyStore is read only, false otherwise. + // If ReadOnly is true then StoreKey will fail. + ReadOnly() bool + + // GetKey returns a key object whose SKI is the one passed. + GetKey(ski []byte) (k Key, err error) + + // StoreKey stores the key k in this KeyStore. + // If this KeyStore is read only then the method will fail. + StoreKey(k Key) (err error) +} diff --git a/internal/github.com/hyperledger/fabric/bccsp/opts.go b/internal/github.com/hyperledger/fabric/bccsp/opts.go new file mode 100644 index 00000000..96dd985e --- /dev/null +++ b/internal/github.com/hyperledger/fabric/bccsp/opts.go @@ -0,0 +1,270 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package bccsp + +const ( + // ECDSA Elliptic Curve Digital Signature Algorithm (key gen, import, sign, verify), + // at default security level. + // Each BCCSP may or may not support default security level. If not supported than + // an error will be returned. + ECDSA = "ECDSA" + + // ECDSA Elliptic Curve Digital Signature Algorithm over P-256 curve + ECDSAP256 = "ECDSAP256" + + // ECDSA Elliptic Curve Digital Signature Algorithm over P-384 curve + ECDSAP384 = "ECDSAP384" + + // ECDSAReRand ECDSA key re-randomization + ECDSAReRand = "ECDSA_RERAND" + + // AES Advanced Encryption Standard at the default security level. + // Each BCCSP may or may not support default security level. If not supported than + // an error will be returned. + AES = "AES" + // AES Advanced Encryption Standard at 128 bit security level + AES128 = "AES128" + // AES Advanced Encryption Standard at 192 bit security level + AES192 = "AES192" + // AES Advanced Encryption Standard at 256 bit security level + AES256 = "AES256" + + // HMAC keyed-hash message authentication code + HMAC = "HMAC" + // HMACTruncated256 HMAC truncated at 256 bits. + HMACTruncated256 = "HMAC_TRUNCATED_256" + + // SHA Secure Hash Algorithm using default family. + // Each BCCSP may or may not support default security level. If not supported than + // an error will be returned. + SHA = "SHA" + + // SHA2 is an identifier for SHA2 hash family + SHA2 = "SHA2" + // SHA3 is an identifier for SHA3 hash family + SHA3 = "SHA3" + + // SHA256 + SHA256 = "SHA256" + // SHA384 + SHA384 = "SHA384" + // SHA3_256 + SHA3_256 = "SHA3_256" + // SHA3_384 + SHA3_384 = "SHA3_384" + + // X509Certificate Label for X509 certificate related operation + X509Certificate = "X509Certificate" +) + +// ECDSAKeyGenOpts contains options for ECDSA key generation. +type ECDSAKeyGenOpts struct { + Temporary bool +} + +// Algorithm returns the key generation algorithm identifier (to be used). +func (opts *ECDSAKeyGenOpts) Algorithm() string { + return ECDSA +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (opts *ECDSAKeyGenOpts) Ephemeral() bool { + return opts.Temporary +} + +// ECDSAPKIXPublicKeyImportOpts contains options for ECDSA public key importation in PKIX format +type ECDSAPKIXPublicKeyImportOpts struct { + Temporary bool +} + +// Algorithm returns the key importation algorithm identifier (to be used). +func (opts *ECDSAPKIXPublicKeyImportOpts) Algorithm() string { + return ECDSA +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (opts *ECDSAPKIXPublicKeyImportOpts) Ephemeral() bool { + return opts.Temporary +} + +// ECDSAPrivateKeyImportOpts contains options for ECDSA secret key importation in DER format +// or PKCS#8 format. +type ECDSAPrivateKeyImportOpts struct { + Temporary bool +} + +// Algorithm returns the key importation algorithm identifier (to be used). +func (opts *ECDSAPrivateKeyImportOpts) Algorithm() string { + return ECDSA +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (opts *ECDSAPrivateKeyImportOpts) Ephemeral() bool { + return opts.Temporary +} + +// ECDSAGoPublicKeyImportOpts contains options for ECDSA key importation from ecdsa.PublicKey +type ECDSAGoPublicKeyImportOpts struct { + Temporary bool +} + +// Algorithm returns the key importation algorithm identifier (to be used). +func (opts *ECDSAGoPublicKeyImportOpts) Algorithm() string { + return ECDSA +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (opts *ECDSAGoPublicKeyImportOpts) Ephemeral() bool { + return opts.Temporary +} + +// ECDSAReRandKeyOpts contains options for ECDSA key re-randomization. +type ECDSAReRandKeyOpts struct { + Temporary bool + Expansion []byte +} + +// Algorithm returns the key derivation algorithm identifier (to be used). +func (opts *ECDSAReRandKeyOpts) Algorithm() string { + return ECDSAReRand +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (opts *ECDSAReRandKeyOpts) Ephemeral() bool { + return opts.Temporary +} + +// ExpansionValue returns the re-randomization factor +func (opts *ECDSAReRandKeyOpts) ExpansionValue() []byte { + return opts.Expansion +} + +// AESKeyGenOpts contains options for AES key generation at default security level +type AESKeyGenOpts struct { + Temporary bool +} + +// Algorithm returns the key generation algorithm identifier (to be used). +func (opts *AESKeyGenOpts) Algorithm() string { + return AES +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (opts *AESKeyGenOpts) Ephemeral() bool { + return opts.Temporary +} + +// HMACTruncated256AESDeriveKeyOpts contains options for HMAC truncated +// at 256 bits key derivation. +type HMACTruncated256AESDeriveKeyOpts struct { + Temporary bool + Arg []byte +} + +// Algorithm returns the key derivation algorithm identifier (to be used). +func (opts *HMACTruncated256AESDeriveKeyOpts) Algorithm() string { + return HMACTruncated256 +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (opts *HMACTruncated256AESDeriveKeyOpts) Ephemeral() bool { + return opts.Temporary +} + +// Argument returns the argument to be passed to the HMAC +func (opts *HMACTruncated256AESDeriveKeyOpts) Argument() []byte { + return opts.Arg +} + +// HMACDeriveKeyOpts contains options for HMAC key derivation. +type HMACDeriveKeyOpts struct { + Temporary bool + Arg []byte +} + +// Algorithm returns the key derivation algorithm identifier (to be used). +func (opts *HMACDeriveKeyOpts) Algorithm() string { + return HMAC +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (opts *HMACDeriveKeyOpts) Ephemeral() bool { + return opts.Temporary +} + +// Argument returns the argument to be passed to the HMAC +func (opts *HMACDeriveKeyOpts) Argument() []byte { + return opts.Arg +} + +// AES256ImportKeyOpts contains options for importing AES 256 keys. +type AES256ImportKeyOpts struct { + Temporary bool +} + +// Algorithm returns the key importation algorithm identifier (to be used). +func (opts *AES256ImportKeyOpts) Algorithm() string { + return AES +} + +// Ephemeral returns true if the key generated has to be ephemeral, +// false otherwise. +func (opts *AES256ImportKeyOpts) Ephemeral() bool { + return opts.Temporary +} + +// HMACImportKeyOpts contains options for importing HMAC keys. +type HMACImportKeyOpts struct { + Temporary bool +} + +// Algorithm returns the key importation algorithm identifier (to be used). +func (opts *HMACImportKeyOpts) Algorithm() string { + return HMAC +} + +// Ephemeral returns true if the key generated has to be ephemeral, +// false otherwise. +func (opts *HMACImportKeyOpts) Ephemeral() bool { + return opts.Temporary +} + +// SHAOpts contains options for computing SHA. +type SHAOpts struct{} + +// Algorithm returns the hash algorithm identifier (to be used). +func (opts *SHAOpts) Algorithm() string { + return SHA +} + +// X509PublicKeyImportOpts contains options for importing public keys from an x509 certificate +type X509PublicKeyImportOpts struct { + Temporary bool +} + +// Algorithm returns the key importation algorithm identifier (to be used). +func (opts *X509PublicKeyImportOpts) Algorithm() string { + return X509Certificate +} + +// Ephemeral returns true if the key to generate has to be ephemeral, +// false otherwise. +func (opts *X509PublicKeyImportOpts) Ephemeral() bool { + return opts.Temporary +} diff --git a/internal/github.com/hyperledger/fabric/bccsp/signer/signer.go b/internal/github.com/hyperledger/fabric/bccsp/signer/signer.go new file mode 100644 index 00000000..c93f63b7 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/bccsp/signer/signer.go @@ -0,0 +1,83 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package signer + +import ( + "crypto" + "crypto/x509" + "io" + + "github.com/pkg/errors" + + "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core" +) + +// bccspCryptoSigner is the BCCSP-based implementation of a crypto.Signer +type bccspCryptoSigner struct { + csp core.CryptoSuite + key core.Key + pk interface{} +} + +// New returns a new BCCSP-based crypto.Signer +// for the given BCCSP instance and key. +func New(csp core.CryptoSuite, key core.Key) (crypto.Signer, error) { + // Validate arguments + if csp == nil { + return nil, errors.New("bccsp instance must be different from nil.") + } + if key == nil { + return nil, errors.New("key must be different from nil.") + } + if key.Symmetric() { + return nil, errors.New("key must be asymmetric.") + } + + // Marshall the bccsp public key as a crypto.PublicKey + pub, err := key.PublicKey() + if err != nil { + return nil, errors.Wrap(err, "failed getting public key") + } + + raw, err := pub.Bytes() + if err != nil { + return nil, errors.Wrap(err, "failed marshalling public key") + } + + pk, err := x509.ParsePKIXPublicKey(raw) + if err != nil { + return nil, errors.Wrap(err, "failed marshalling der to public key") + } + + return &bccspCryptoSigner{csp, key, pk}, nil +} + +// Public returns the public key corresponding to the opaque, +// private key. +func (s *bccspCryptoSigner) Public() crypto.PublicKey { + return s.pk +} + +// Sign signs digest with the private key, possibly using entropy from rand. +// For an (EC)DSA key, it should be a DER-serialised, ASN.1 signature +// structure. +// +// Hash implements the SignerOpts interface and, in most cases, one can +// simply pass in the hash function used as opts. Sign may also attempt +// to type assert opts to other types in order to obtain algorithm +// specific values. See the documentation in each package for details. +// +// Note that when a signature of a hash of a larger message is needed, +// the caller is responsible for hashing the larger message and passing +// the hash (as digest) and the hash function (as opts) to Sign. +func (s *bccspCryptoSigner) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error) { + return s.csp.Sign(s.key, digest, opts) +} diff --git a/internal/github.com/hyperledger/fabric/bccsp/utils/ecdsa.go b/internal/github.com/hyperledger/fabric/bccsp/utils/ecdsa.go new file mode 100644 index 00000000..c8132a71 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/bccsp/utils/ecdsa.go @@ -0,0 +1,113 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package utils + +import ( + "crypto/ecdsa" + "crypto/elliptic" + "encoding/asn1" + "errors" + "fmt" + "math/big" +) + +type ECDSASignature struct { + R, S *big.Int +} + +var ( + // curveHalfOrders contains the precomputed curve group orders halved. + // It is used to ensure that signature' S value is lower or equal to the + // curve group order halved. We accept only low-S signatures. + // They are precomputed for efficiency reasons. + curveHalfOrders = map[elliptic.Curve]*big.Int{ + elliptic.P224(): new(big.Int).Rsh(elliptic.P224().Params().N, 1), + elliptic.P256(): new(big.Int).Rsh(elliptic.P256().Params().N, 1), + elliptic.P384(): new(big.Int).Rsh(elliptic.P384().Params().N, 1), + elliptic.P521(): new(big.Int).Rsh(elliptic.P521().Params().N, 1), + } +) + +func GetCurveHalfOrdersAt(c elliptic.Curve) *big.Int { + return big.NewInt(0).Set(curveHalfOrders[c]) +} + +func MarshalECDSASignature(r, s *big.Int) ([]byte, error) { + return asn1.Marshal(ECDSASignature{r, s}) +} + +func UnmarshalECDSASignature(raw []byte) (*big.Int, *big.Int, error) { + // Unmarshal + sig := new(ECDSASignature) + _, err := asn1.Unmarshal(raw, sig) + if err != nil { + return nil, nil, fmt.Errorf("failed unmashalling signature [%s]", err) + } + + // Validate sig + if sig.R == nil { + return nil, nil, errors.New("invalid signature, R must be different from nil") + } + if sig.S == nil { + return nil, nil, errors.New("invalid signature, S must be different from nil") + } + + if sig.R.Sign() != 1 { + return nil, nil, errors.New("invalid signature, R must be larger than zero") + } + if sig.S.Sign() != 1 { + return nil, nil, errors.New("invalid signature, S must be larger than zero") + } + + return sig.R, sig.S, nil +} + +func SignatureToLowS(k *ecdsa.PublicKey, signature []byte) ([]byte, error) { + r, s, err := UnmarshalECDSASignature(signature) + if err != nil { + return nil, err + } + + s, err = ToLowS(k, s) + if err != nil { + return nil, err + } + + return MarshalECDSASignature(r, s) +} + +// IsLow checks that s is a low-S +func IsLowS(k *ecdsa.PublicKey, s *big.Int) (bool, error) { + halfOrder, ok := curveHalfOrders[k.Curve] + if !ok { + return false, fmt.Errorf("curve not recognized [%s]", k.Curve) + } + + return s.Cmp(halfOrder) != 1, nil + +} + +func ToLowS(k *ecdsa.PublicKey, s *big.Int) (*big.Int, error) { + lowS, err := IsLowS(k, s) + if err != nil { + return nil, err + } + + if !lowS { + // Set s to N - s that will be then in the lower part of signature space + // less or equal to half order + s.Sub(k.Params().N, s) + + return s, nil + } + + return s, nil +} diff --git a/internal/github.com/hyperledger/fabric/common/capabilities/application.go b/internal/github.com/hyperledger/fabric/common/capabilities/application.go new file mode 100644 index 00000000..7bdfa790 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/capabilities/application.go @@ -0,0 +1,167 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package capabilities + +import ( + cb "github.com/hyperledger/fabric-protos-go/common" +) + +const ( + applicationTypeName = "Application" + + // ApplicationV1_1 is the capabilities string for standard new non-backwards compatible fabric v1.1 application capabilities. + ApplicationV1_1 = "V1_1" + + // ApplicationV1_2 is the capabilities string for standard new non-backwards compatible fabric v1.2 application capabilities. + ApplicationV1_2 = "V1_2" + + // ApplicationV1_3 is the capabilities string for standard new non-backwards compatible fabric v1.3 application capabilities. + ApplicationV1_3 = "V1_3" + + // ApplicationV1_4_2 is the capabilities string for standard new non-backwards compatible fabric v1.4.2 application capabilities. + ApplicationV1_4_2 = "V1_4_2" + + // ApplicationV2_0 is the capabilities string for standard new non-backwards compatible fabric v2.0 application capabilities. + ApplicationV2_0 = "V2_0" + + // ApplicationPvtDataExperimental is the capabilities string for private data using the experimental feature of collections/sideDB. + ApplicationPvtDataExperimental = "V1_1_PVTDATA_EXPERIMENTAL" + + // ApplicationResourcesTreeExperimental is the capabilities string for private data using the experimental feature of collections/sideDB. + ApplicationResourcesTreeExperimental = "V1_1_RESOURCETREE_EXPERIMENTAL" +) + +// ApplicationProvider provides capabilities information for application level config. +type ApplicationProvider struct { + *registry + v11 bool + v12 bool + v13 bool + v142 bool + v20 bool + v11PvtDataExperimental bool +} + +// NewApplicationProvider creates a application capabilities provider. +func NewApplicationProvider(capabilities map[string]*cb.Capability) *ApplicationProvider { + ap := &ApplicationProvider{} + ap.registry = newRegistry(ap, capabilities) + _, ap.v11 = capabilities[ApplicationV1_1] + _, ap.v12 = capabilities[ApplicationV1_2] + _, ap.v13 = capabilities[ApplicationV1_3] + _, ap.v142 = capabilities[ApplicationV1_4_2] + _, ap.v20 = capabilities[ApplicationV2_0] + _, ap.v11PvtDataExperimental = capabilities[ApplicationPvtDataExperimental] + return ap +} + +// Type returns a descriptive string for logging purposes. +func (ap *ApplicationProvider) Type() string { + return applicationTypeName +} + +// ACLs returns whether ACLs may be specified in the channel application config +func (ap *ApplicationProvider) ACLs() bool { + return ap.v12 || ap.v13 || ap.v142 || ap.v20 +} + +// ForbidDuplicateTXIdInBlock specifies whether two transactions with the same TXId are permitted +// in the same block or whether we mark the second one as TxValidationCode_DUPLICATE_TXID +func (ap *ApplicationProvider) ForbidDuplicateTXIdInBlock() bool { + return ap.v11 || ap.v12 || ap.v13 || ap.v142 || ap.v20 +} + +// PrivateChannelData returns true if support for private channel data (a.k.a. collections) is enabled. +// In v1.1, the private channel data is experimental and has to be enabled explicitly. +// In v1.2, the private channel data is enabled by default. +func (ap *ApplicationProvider) PrivateChannelData() bool { + return ap.v11PvtDataExperimental || ap.v12 || ap.v13 || ap.v142 || ap.v20 +} + +// CollectionUpgrade returns true if this channel is configured to allow updates to +// existing collection or add new collections through chaincode upgrade (as introduced in v1.2) +func (ap ApplicationProvider) CollectionUpgrade() bool { + return ap.v12 || ap.v13 || ap.v142 || ap.v20 +} + +// V1_1Validation returns true is this channel is configured to perform stricter validation +// of transactions (as introduced in v1.1). +func (ap *ApplicationProvider) V1_1Validation() bool { + return ap.v11 || ap.v12 || ap.v13 || ap.v142 || ap.v20 +} + +// V1_2Validation returns true if this channel is configured to perform stricter validation +// of transactions (as introduced in v1.2). +func (ap *ApplicationProvider) V1_2Validation() bool { + return ap.v12 || ap.v13 || ap.v142 || ap.v20 +} + +// V1_3Validation returns true if this channel is configured to perform stricter validation +// of transactions (as introduced in v1.3). +func (ap *ApplicationProvider) V1_3Validation() bool { + return ap.v13 || ap.v142 || ap.v20 +} + +// V2_0Validation returns true if this channel supports transaction validation +// as introduced in v2.0. This includes: +// - new chaincode lifecycle +// - implicit per-org collections +func (ap *ApplicationProvider) V2_0Validation() bool { + return ap.v20 +} + +// LifecycleV20 indicates whether the peer should use the deprecated and problematic +// v1.x lifecycle, or whether it should use the newer per channel approve/commit definitions +// process introduced in v2.0. Note, this should only be used on the endorsing side +// of peer processing, so that we may safely remove all checks against it in v2.1. +func (ap *ApplicationProvider) LifecycleV20() bool { + return ap.v20 +} + +// MetadataLifecycle always returns false +func (ap *ApplicationProvider) MetadataLifecycle() bool { + return false +} + +// KeyLevelEndorsement returns true if this channel supports endorsement +// policies expressible at a ledger key granularity, as described in FAB-8812 +func (ap *ApplicationProvider) KeyLevelEndorsement() bool { + return ap.v13 || ap.v142 || ap.v20 +} + +// StorePvtDataOfInvalidTx returns true if the peer needs to store +// the pvtData of invalid transactions. +func (ap *ApplicationProvider) StorePvtDataOfInvalidTx() bool { + return ap.v142 || ap.v20 +} + +// HasCapability returns true if the capability is supported by this binary. +func (ap *ApplicationProvider) HasCapability(capability string) bool { + switch capability { + // Add new capability names here + case ApplicationV1_1: + return true + case ApplicationV1_2: + return true + case ApplicationV1_3: + return true + case ApplicationV1_4_2: + return true + case ApplicationV2_0: + return true + case ApplicationPvtDataExperimental: + return true + case ApplicationResourcesTreeExperimental: + return true + default: + return false + } +} diff --git a/internal/github.com/hyperledger/fabric/common/capabilities/capabilities.go b/internal/github.com/hyperledger/fabric/common/capabilities/capabilities.go new file mode 100644 index 00000000..f3cfdc48 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/capabilities/capabilities.go @@ -0,0 +1,55 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package capabilities + +import ( + cb "github.com/hyperledger/fabric-protos-go/common" + flogging "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/logbridge" + "github.com/pkg/errors" +) + +var logger = flogging.MustGetLogger("common.capabilities") + +// provider is the 'plugin' parameter for registry. +type provider interface { + // HasCapability should report whether the binary supports this capability. + HasCapability(capability string) bool + + // Type is used to make error messages more legible. + Type() string +} + +// registry is a common structure intended to be used to support specific aspects of capabilities +// such as orderer, application, and channel. +type registry struct { + provider provider + capabilities map[string]*cb.Capability +} + +func newRegistry(p provider, capabilities map[string]*cb.Capability) *registry { + return ®istry{ + provider: p, + capabilities: capabilities, + } +} + +// Supported checks that all of the required capabilities are supported by this binary. +func (r *registry) Supported() error { + for capabilityName := range r.capabilities { + if r.provider.HasCapability(capabilityName) { + logger.Debugf("%s capability %s is supported and is enabled", r.provider.Type(), capabilityName) + continue + } + + return errors.Errorf("%s capability %s is required but not supported", r.provider.Type(), capabilityName) + } + return nil +} diff --git a/internal/github.com/hyperledger/fabric/common/capabilities/channel.go b/internal/github.com/hyperledger/fabric/common/capabilities/channel.go new file mode 100644 index 00000000..22d6882a --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/capabilities/channel.go @@ -0,0 +1,105 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package capabilities + +import ( + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/msp" +) + +const ( + channelTypeName = "Channel" + + // ChannelV1_1 is the capabilities string for standard new non-backwards compatible fabric v1.1 channel capabilities. + ChannelV1_1 = "V1_1" + + // ChannelV1_3 is the capabilities string for standard new non-backwards compatible fabric v1.3 channel capabilities. + ChannelV1_3 = "V1_3" + + // ChannelV1_4_2 is the capabilities string for standard new non-backwards compatible fabric v1.4.2 channel capabilities. + ChannelV1_4_2 = "V1_4_2" + + // ChannelV1_4_3 is the capabilities string for standard new non-backwards compatible fabric v1.4.3 channel capabilities. + ChannelV1_4_3 = "V1_4_3" + + // ChannelV2_0 is the capabilities string for standard new non-backwards compatible fabric v2.0 channel capabilities. + ChannelV2_0 = "V2_0" +) + +// ChannelProvider provides capabilities information for channel level config. +type ChannelProvider struct { + *registry + v11 bool + v13 bool + v142 bool + v143 bool + v20 bool +} + +// NewChannelProvider creates a channel capabilities provider. +func NewChannelProvider(capabilities map[string]*cb.Capability) *ChannelProvider { + cp := &ChannelProvider{} + cp.registry = newRegistry(cp, capabilities) + _, cp.v11 = capabilities[ChannelV1_1] + _, cp.v13 = capabilities[ChannelV1_3] + _, cp.v142 = capabilities[ChannelV1_4_2] + _, cp.v143 = capabilities[ChannelV1_4_3] + _, cp.v20 = capabilities[ChannelV2_0] + return cp +} + +// Type returns a descriptive string for logging purposes. +func (cp *ChannelProvider) Type() string { + return channelTypeName +} + +// HasCapability returns true if the capability is supported by this binary. +func (cp *ChannelProvider) HasCapability(capability string) bool { + switch capability { + // Add new capability names here + case ChannelV2_0: + return true + case ChannelV1_4_3: + return true + case ChannelV1_4_2: + return true + case ChannelV1_3: + return true + case ChannelV1_1: + return true + default: + return false + } +} + +// MSPVersion returns the level of MSP support required by this channel. +func (cp *ChannelProvider) MSPVersion() msp.MSPVersion { + switch { + case cp.v143 || cp.v20: + return msp.MSPv1_4_3 + case cp.v13 || cp.v142: + return msp.MSPv1_3 + case cp.v11: + return msp.MSPv1_1 + default: + return msp.MSPv1_0 + } +} + +// ConsensusTypeMigration return true if consensus-type migration is supported and permitted in both orderer and peer. +func (cp *ChannelProvider) ConsensusTypeMigration() bool { + return cp.v142 || cp.v143 || cp.v20 +} + +// OrgSpecificOrdererEndpoints allows for individual orderer orgs to specify their external addresses for their OSNs. +func (cp *ChannelProvider) OrgSpecificOrdererEndpoints() bool { + return cp.v142 || cp.v143 || cp.v20 +} diff --git a/internal/github.com/hyperledger/fabric/common/capabilities/orderer.go b/internal/github.com/hyperledger/fabric/common/capabilities/orderer.go new file mode 100644 index 00000000..c4fee532 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/capabilities/orderer.go @@ -0,0 +1,99 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package capabilities + +import ( + cb "github.com/hyperledger/fabric-protos-go/common" +) + +const ( + ordererTypeName = "Orderer" + + // OrdererV1_1 is the capabilities string for standard new non-backwards compatible Fabric v1.1 orderer capabilities. + OrdererV1_1 = "V1_1" + + // OrdererV1_4_2 is the capabilities string for standard new non-backwards compatible Fabric v1.4.2 orderer capabilities. + OrdererV1_4_2 = "V1_4_2" + + // OrdererV2_0 is the capabilities string that defines new Fabric v2.0 orderer capabilities. + OrdererV2_0 = "V2_0" +) + +// OrdererProvider provides capabilities information for orderer level config. +type OrdererProvider struct { + *registry + v11BugFixes bool + v142 bool + V20 bool +} + +// NewOrdererProvider creates an orderer capabilities provider. +func NewOrdererProvider(capabilities map[string]*cb.Capability) *OrdererProvider { + cp := &OrdererProvider{} + cp.registry = newRegistry(cp, capabilities) + _, cp.v11BugFixes = capabilities[OrdererV1_1] + _, cp.v142 = capabilities[OrdererV1_4_2] + _, cp.V20 = capabilities[OrdererV2_0] + return cp +} + +// Type returns a descriptive string for logging purposes. +func (cp *OrdererProvider) Type() string { + return ordererTypeName +} + +// HasCapability returns true if the capability is supported by this binary. +func (cp *OrdererProvider) HasCapability(capability string) bool { + switch capability { + // Add new capability names here + case OrdererV1_1: + return true + case OrdererV1_4_2: + return true + case OrdererV2_0: + return true + default: + return false + } +} + +// PredictableChannelTemplate specifies whether the v1.0 undesirable behavior of setting the /Channel +// group's mod_policy to "" and copying versions from the channel config should be fixed or not. +func (cp *OrdererProvider) PredictableChannelTemplate() bool { + return cp.v11BugFixes || cp.v142 || cp.V20 +} + +// Resubmission specifies whether the v1.0 non-deterministic commitment of tx should be fixed by re-submitting +// the re-validated tx. +func (cp *OrdererProvider) Resubmission() bool { + return cp.v11BugFixes || cp.v142 || cp.V20 +} + +// ExpirationCheck specifies whether the orderer checks for identity expiration checks +// when validating messages +func (cp *OrdererProvider) ExpirationCheck() bool { + return cp.v11BugFixes || cp.v142 || cp.V20 +} + +// ConsensusTypeMigration checks whether the orderer permits a consensus-type migration. +// +// A Kafka-based Ordering Service Node requires these capabilities in order to receive and process a config update +// with consensus-type migration change. Migration is supported from Kafka to Raft only. +// If not present, these config updates will be rejected. +func (cp *OrdererProvider) ConsensusTypeMigration() bool { + return cp.v142 || cp.V20 +} + +// UseChannelCreationPolicyAsAdmins determines whether the orderer should use the name +// "Admins" instead of "ChannelCreationPolicy" in the new channel config template. +func (cp *OrdererProvider) UseChannelCreationPolicyAsAdmins() bool { + return cp.V20 +} diff --git a/internal/github.com/hyperledger/fabric/common/channelconfig/acls.go b/internal/github.com/hyperledger/fabric/common/channelconfig/acls.go new file mode 100644 index 00000000..dd6281e9 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/channelconfig/acls.go @@ -0,0 +1,47 @@ +/* +Copyright State Street Corp. 2018 All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package channelconfig + +import ( + pb "github.com/hyperledger/fabric-protos-go/peer" +) + +// aclsProvider provides mappings for resource to policy names +type aclsProvider struct { + aclPolicyRefs map[string]string +} + +func (ag *aclsProvider) PolicyRefForAPI(aclName string) string { + return ag.aclPolicyRefs[aclName] +} + +// this translates policies to absolute paths if needed +func newAPIsProvider(acls map[string]*pb.APIResource) *aclsProvider { + aclPolicyRefs := make(map[string]string) + + for key, acl := range acls { + if len(acl.PolicyRef) == 0 { + logger.Warningf("Policy reference for resource '%s' is specified, but empty, falling back to default", key) + continue + } + // If the policy is fully qualified, ie to /Channel/Application/Readers leave it alone + // otherwise, make it fully qualified referring to /Channel/Application/policyName + if acl.PolicyRef[0] != '/' { + aclPolicyRefs[key] = "/" + ChannelGroupKey + "/" + ApplicationGroupKey + "/" + acl.PolicyRef + } else { + aclPolicyRefs[key] = acl.PolicyRef + } + } + + return &aclsProvider{ + aclPolicyRefs: aclPolicyRefs, + } +} diff --git a/internal/github.com/hyperledger/fabric/common/channelconfig/api.go b/internal/github.com/hyperledger/fabric/common/channelconfig/api.go new file mode 100644 index 00000000..f471609e --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/channelconfig/api.go @@ -0,0 +1,266 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package channelconfig + +import ( + "time" + + cb "github.com/hyperledger/fabric-protos-go/common" + ab "github.com/hyperledger/fabric-protos-go/orderer" + pb "github.com/hyperledger/fabric-protos-go/peer" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/configtx" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/policies" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/msp" +) + +// Org stores the common organizational config +type Org interface { + // Name returns the name this org is referred to in config + Name() string + + // MSPID returns the MSP ID associated with this org + MSPID() string + + // MSP returns the MSP implementation for this org. + MSP() msp.MSP +} + +// ApplicationOrg stores the per org application config +type ApplicationOrg interface { + Org + + // AnchorPeers returns the list of gossip anchor peers + AnchorPeers() []*pb.AnchorPeer +} + +// OrdererOrg stores the per org orderer config. +type OrdererOrg interface { + Org + + // Endpoints returns the endpoints of orderer nodes. + Endpoints() []string +} + +// Application stores the common shared application config +type Application interface { + // Organizations returns a map of org ID to ApplicationOrg + Organizations() map[string]ApplicationOrg + + // APIPolicyMapper returns a PolicyMapper that maps API names to policies + APIPolicyMapper() PolicyMapper + + // Capabilities defines the capabilities for the application portion of a channel + Capabilities() ApplicationCapabilities +} + +// Channel gives read only access to the channel configuration +type Channel interface { + // HashingAlgorithm returns the default algorithm to be used when hashing + // such as computing block hashes, and CreationPolicy digests + HashingAlgorithm() func(input []byte) []byte + + // BlockDataHashingStructureWidth returns the width to use when constructing the + // Merkle tree to compute the BlockData hash + BlockDataHashingStructureWidth() uint32 + + // OrdererAddresses returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver + OrdererAddresses() []string + + // Capabilities defines the capabilities for a channel + Capabilities() ChannelCapabilities +} + +// Consortiums represents the set of consortiums serviced by an ordering service +type Consortiums interface { + // Consortiums returns the set of consortiums + Consortiums() map[string]Consortium +} + +// Consortium represents a group of orgs which may create channels together +type Consortium interface { + // ChannelCreationPolicy returns the policy to check when instantiating a channel for this consortium + ChannelCreationPolicy() *cb.Policy + + // Organizations returns the organizations for this consortium + Organizations() map[string]Org +} + +// Orderer stores the common shared orderer config +type Orderer interface { + // ConsensusType returns the configured consensus type + ConsensusType() string + + // ConsensusMetadata returns the metadata associated with the consensus type. + ConsensusMetadata() []byte + + // ConsensusState returns the consensus-type state. + ConsensusState() ab.ConsensusType_State + + // BatchSize returns the maximum number of messages to include in a block + BatchSize() *ab.BatchSize + + // BatchTimeout returns the amount of time to wait before creating a batch + BatchTimeout() time.Duration + + // MaxChannelsCount returns the maximum count of channels to allow for an ordering network + MaxChannelsCount() uint64 + + // KafkaBrokers returns the addresses (IP:port notation) of a set of "bootstrap" + // Kafka brokers, i.e. this is not necessarily the entire set of Kafka brokers + // used for ordering + KafkaBrokers() []string + + // Organizations returns the organizations for the ordering service + Organizations() map[string]OrdererOrg + + // Capabilities defines the capabilities for the orderer portion of a channel + Capabilities() OrdererCapabilities +} + +// ChannelCapabilities defines the capabilities for a channel +type ChannelCapabilities interface { + // Supported returns an error if there are unknown capabilities in this channel which are required + Supported() error + + // MSPVersion specifies the version of the MSP this channel must understand, including the MSP types + // and MSP principal types. + MSPVersion() msp.MSPVersion + + // ConsensusTypeMigration return true if consensus-type migration is permitted in both orderer and peer. + ConsensusTypeMigration() bool + + // OrgSpecificOrdererEndpoints return true if the channel config processing allows orderer orgs to specify their own endpoints + OrgSpecificOrdererEndpoints() bool +} + +// ApplicationCapabilities defines the capabilities for the application portion of a channel +type ApplicationCapabilities interface { + // Supported returns an error if there are unknown capabilities in this channel which are required + Supported() error + + // ForbidDuplicateTXIdInBlock specifies whether two transactions with the same TXId are permitted + // in the same block or whether we mark the second one as TxValidationCode_DUPLICATE_TXID + ForbidDuplicateTXIdInBlock() bool + + // ACLs returns true is ACLs may be specified in the Application portion of the config tree + ACLs() bool + + // PrivateChannelData returns true if support for private channel data (a.k.a. collections) is enabled. + // In v1.1, the private channel data is experimental and has to be enabled explicitly. + // In v1.2, the private channel data is enabled by default. + PrivateChannelData() bool + + // CollectionUpgrade returns true if this channel is configured to allow updates to + // existing collection or add new collections through chaincode upgrade (as introduced in v1.2) + CollectionUpgrade() bool + + // V1_1Validation returns true is this channel is configured to perform stricter validation + // of transactions (as introduced in v1.1). + V1_1Validation() bool + + // V1_2Validation returns true is this channel is configured to perform stricter validation + // of transactions (as introduced in v1.2). + V1_2Validation() bool + + // V1_3Validation returns true if this channel supports transaction validation + // as introduced in v1.3. This includes: + // - policies expressible at a ledger key granularity, as described in FAB-8812 + // - new chaincode lifecycle, as described in FAB-11237 + V1_3Validation() bool + + // StorePvtDataOfInvalidTx() returns true if the peer needs to store the pvtData of + // invalid transactions (as introduced in v142). + StorePvtDataOfInvalidTx() bool + + // V2_0Validation returns true if this channel supports transaction validation + // as introduced in v2.0. This includes: + // - new chaincode lifecycle + // - implicit per-org collections + V2_0Validation() bool + + // LifecycleV20 indicates whether the peer should use the deprecated and problematic + // v1.x lifecycle, or whether it should use the newer per channel approve/commit definitions + // process introduced in v2.0. Note, this should only be used on the endorsing side + // of peer processing, so that we may safely remove all checks against it in v2.1. + LifecycleV20() bool + + // MetadataLifecycle always returns false + MetadataLifecycle() bool + + // KeyLevelEndorsement returns true if this channel supports endorsement + // policies expressible at a ledger key granularity, as described in FAB-8812 + KeyLevelEndorsement() bool +} + +// OrdererCapabilities defines the capabilities for the orderer portion of a channel +type OrdererCapabilities interface { + // PredictableChannelTemplate specifies whether the v1.0 undesirable behavior of setting the /Channel + // group's mod_policy to "" and copy versions from the orderer system channel config should be fixed or not. + PredictableChannelTemplate() bool + + // Resubmission specifies whether the v1.0 non-deterministic commitment of tx should be fixed by re-submitting + // the re-validated tx. + Resubmission() bool + + // Supported returns an error if there are unknown capabilities in this channel which are required + Supported() error + + // ExpirationCheck specifies whether the orderer checks for identity expiration checks + // when validating messages + ExpirationCheck() bool + + // ConsensusTypeMigration checks whether the orderer permits a consensus-type migration. + ConsensusTypeMigration() bool + + // UseChannelCreationPolicyAsAdmins checks whether the orderer should use more sophisticated + // channel creation logic using channel creation policy as the Admins policy if + // the creation transaction appears to support it. + UseChannelCreationPolicyAsAdmins() bool +} + +// PolicyMapper is an interface for +type PolicyMapper interface { + // PolicyRefForAPI takes the name of an API, and returns the policy name + // or the empty string if the API is not found + PolicyRefForAPI(apiName string) string +} + +// Resources is the common set of config resources for all channels +// Depending on whether chain is used at the orderer or at the peer, other +// config resources may be available +type Resources interface { + // ConfigtxValidator returns the configtx.Validator for the channel + ConfigtxValidator() configtx.Validator + + // PolicyManager returns the policies.Manager for the channel + PolicyManager() policies.Manager + + // ChannelConfig returns the config.Channel for the chain + ChannelConfig() Channel + + // OrdererConfig returns the config.Orderer for the channel + // and whether the Orderer config exists + OrdererConfig() (Orderer, bool) + + // ConsortiumsConfig() returns the config.Consortiums for the channel + // and whether the consortiums config exists + ConsortiumsConfig() (Consortiums, bool) + + // ApplicationConfig returns the configtxapplication.SharedConfig for the channel + // and whether the Application config exists + ApplicationConfig() (Application, bool) + + // MSPManager returns the msp.MSPManager for the chain + MSPManager() msp.MSPManager + + // ValidateNew should return an error if a new set of configuration resources is incompatible with the current one + ValidateNew(resources Resources) error +} diff --git a/internal/github.com/hyperledger/fabric/common/channelconfig/application.go b/internal/github.com/hyperledger/fabric/common/channelconfig/application.go new file mode 100644 index 00000000..b2a4f06f --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/channelconfig/application.go @@ -0,0 +1,83 @@ +/* +Copyright IBM Corp. 2017 All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package channelconfig + +import ( + cb "github.com/hyperledger/fabric-protos-go/common" + pb "github.com/hyperledger/fabric-protos-go/peer" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/capabilities" + "github.com/pkg/errors" +) + +const ( + // ApplicationGroupKey is the group name for the Application config + ApplicationGroupKey = "Application" + + // ACLsKey is the name of the ACLs config + ACLsKey = "ACLs" +) + +// ApplicationProtos is used as the source of the ApplicationConfig +type ApplicationProtos struct { + ACLs *pb.ACLs + Capabilities *cb.Capabilities +} + +// ApplicationConfig implements the Application interface +type ApplicationConfig struct { + applicationOrgs map[string]ApplicationOrg + protos *ApplicationProtos +} + +// NewApplicationConfig creates config from an Application config group +func NewApplicationConfig(appGroup *cb.ConfigGroup, mspConfig *MSPConfigHandler) (*ApplicationConfig, error) { + ac := &ApplicationConfig{ + applicationOrgs: make(map[string]ApplicationOrg), + protos: &ApplicationProtos{}, + } + + if err := DeserializeProtoValuesFromGroup(appGroup, ac.protos); err != nil { + return nil, errors.Wrap(err, "failed to deserialize values") + } + + if !ac.Capabilities().ACLs() { + if _, ok := appGroup.Values[ACLsKey]; ok { + return nil, errors.New("ACLs may not be specified without the required capability") + } + } + + var err error + for orgName, orgGroup := range appGroup.Groups { + ac.applicationOrgs[orgName], err = NewApplicationOrgConfig(orgName, orgGroup, mspConfig) + if err != nil { + return nil, err + } + } + + return ac, nil +} + +// Organizations returns a map of org ID to ApplicationOrg +func (ac *ApplicationConfig) Organizations() map[string]ApplicationOrg { + return ac.applicationOrgs +} + +// Capabilities returns a map of capability name to Capability +func (ac *ApplicationConfig) Capabilities() ApplicationCapabilities { + return capabilities.NewApplicationProvider(ac.protos.Capabilities.Capabilities) +} + +// APIPolicyMapper returns a PolicyMapper that maps API names to policies +func (ac *ApplicationConfig) APIPolicyMapper() PolicyMapper { + pm := newAPIsProvider(ac.protos.ACLs.Acls) + + return pm +} diff --git a/internal/github.com/hyperledger/fabric/common/channelconfig/applicationorg.go b/internal/github.com/hyperledger/fabric/common/channelconfig/applicationorg.go new file mode 100644 index 00000000..56e77eb6 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/channelconfig/applicationorg.go @@ -0,0 +1,76 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package channelconfig + +import ( + "fmt" + + cb "github.com/hyperledger/fabric-protos-go/common" + pb "github.com/hyperledger/fabric-protos-go/peer" + "github.com/pkg/errors" +) + +const ( + // AnchorPeersKey is the key name for the AnchorPeers ConfigValue + AnchorPeersKey = "AnchorPeers" +) + +// ApplicationOrgProtos are deserialized from the config +type ApplicationOrgProtos struct { + AnchorPeers *pb.AnchorPeers +} + +// ApplicationOrgConfig defines the configuration for an application org +type ApplicationOrgConfig struct { + *OrganizationConfig + protos *ApplicationOrgProtos + name string +} + +// NewApplicationOrgConfig creates a new config for an application org +func NewApplicationOrgConfig(id string, orgGroup *cb.ConfigGroup, mspConfig *MSPConfigHandler) (*ApplicationOrgConfig, error) { + if len(orgGroup.Groups) > 0 { + return nil, fmt.Errorf("ApplicationOrg config does not allow sub-groups") + } + + protos := &ApplicationOrgProtos{} + orgProtos := &OrganizationProtos{} + + if err := DeserializeProtoValuesFromGroup(orgGroup, protos, orgProtos); err != nil { + return nil, errors.Wrap(err, "failed to deserialize values") + } + + aoc := &ApplicationOrgConfig{ + name: id, + protos: protos, + OrganizationConfig: &OrganizationConfig{ + name: id, + protos: orgProtos, + mspConfigHandler: mspConfig, + }, + } + + if err := aoc.Validate(); err != nil { + return nil, err + } + + return aoc, nil +} + +// AnchorPeers returns the list of anchor peers of this Organization +func (aog *ApplicationOrgConfig) AnchorPeers() []*pb.AnchorPeer { + return aog.protos.AnchorPeers.AnchorPeers +} + +func (aoc *ApplicationOrgConfig) Validate() error { + logger.Debugf("Anchor peers for org %s are %v", aoc.name, aoc.protos.AnchorPeers) + return aoc.OrganizationConfig.Validate() +} diff --git a/internal/github.com/hyperledger/fabric/common/channelconfig/bundle.go b/internal/github.com/hyperledger/fabric/common/channelconfig/bundle.go new file mode 100644 index 00000000..1886ab06 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/channelconfig/bundle.go @@ -0,0 +1,21 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package channelconfig + +import ( + flogging "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/logbridge" +) + +var logger = flogging.MustGetLogger("common.channelconfig") + +// RootGroupKey is the key for namespacing the channel config, especially for +// policy evaluation. +const RootGroupKey = "Channel" diff --git a/internal/github.com/hyperledger/fabric/common/channelconfig/channel.go b/internal/github.com/hyperledger/fabric/common/channelconfig/channel.go new file mode 100644 index 00000000..5abe82fa --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/channelconfig/channel.go @@ -0,0 +1,217 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package channelconfig + +import ( + "fmt" + "math" + + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/bccsp" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/capabilities" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/util" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/msp" + "github.com/pkg/errors" +) + +// Channel config keys +const ( + // ConsortiumKey is the key for the cb.ConfigValue for the Consortium message + ConsortiumKey = "Consortium" + + // HashingAlgorithmKey is the cb.ConfigItem type key name for the HashingAlgorithm message + HashingAlgorithmKey = "HashingAlgorithm" + + // BlockDataHashingStructureKey is the cb.ConfigItem type key name for the BlockDataHashingStructure message + BlockDataHashingStructureKey = "BlockDataHashingStructure" + + // OrdererAddressesKey is the cb.ConfigItem type key name for the OrdererAddresses message + OrdererAddressesKey = "OrdererAddresses" + + // GroupKey is the name of the channel group + ChannelGroupKey = "Channel" + + // CapabilitiesKey is the name of the key which refers to capabilities, it appears at the channel, + // application, and orderer levels and this constant is used for all three. + CapabilitiesKey = "Capabilities" +) + +// ChannelValues gives read only access to the channel configuration +type ChannelValues interface { + // HashingAlgorithm returns the default algorithm to be used when hashing + // such as computing block hashes, and CreationPolicy digests + HashingAlgorithm() func(input []byte) []byte + + // BlockDataHashingStructureWidth returns the width to use when constructing the + // Merkle tree to compute the BlockData hash + BlockDataHashingStructureWidth() uint32 + + // OrdererAddresses returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver + OrdererAddresses() []string +} + +// ChannelProtos is where the proposed configuration is unmarshaled into +type ChannelProtos struct { + HashingAlgorithm *cb.HashingAlgorithm + BlockDataHashingStructure *cb.BlockDataHashingStructure + OrdererAddresses *cb.OrdererAddresses + Consortium *cb.Consortium + Capabilities *cb.Capabilities +} + +// ChannelConfig stores the channel configuration +type ChannelConfig struct { + protos *ChannelProtos + + hashingAlgorithm func(input []byte) []byte + + mspManager msp.MSPManager + + appConfig *ApplicationConfig + ordererConfig *OrdererConfig + consortiumsConfig *ConsortiumsConfig +} + +// NewChannelConfig creates a new ChannelConfig +func NewChannelConfig(channelGroup *cb.ConfigGroup, bccsp core.CryptoSuite) (*ChannelConfig, error) { + cc := &ChannelConfig{ + protos: &ChannelProtos{}, + } + + if err := DeserializeProtoValuesFromGroup(channelGroup, cc.protos); err != nil { + return nil, errors.Wrap(err, "failed to deserialize values") + } + + capabilities := cc.Capabilities() + + if err := cc.Validate(capabilities); err != nil { + return nil, err + } + + mspConfigHandler := NewMSPConfigHandler(capabilities.MSPVersion(), bccsp) + + var err error + for groupName, group := range channelGroup.Groups { + switch groupName { + case ApplicationGroupKey: + cc.appConfig, err = NewApplicationConfig(group, mspConfigHandler) + case OrdererGroupKey: + cc.ordererConfig, err = NewOrdererConfig(group, mspConfigHandler, capabilities) + case ConsortiumsGroupKey: + cc.consortiumsConfig, err = NewConsortiumsConfig(group, mspConfigHandler) + default: + return nil, fmt.Errorf("Disallowed channel group: %s", group) + } + if err != nil { + return nil, errors.Wrapf(err, "could not create channel %s sub-group config", groupName) + } + } + + if cc.mspManager, err = mspConfigHandler.CreateMSPManager(); err != nil { + return nil, err + } + + return cc, nil +} + +// MSPManager returns the MSP manager for this config +func (cc *ChannelConfig) MSPManager() msp.MSPManager { + return cc.mspManager +} + +// OrdererConfig returns the orderer config associated with this channel +func (cc *ChannelConfig) OrdererConfig() *OrdererConfig { + return cc.ordererConfig +} + +// ApplicationConfig returns the application config associated with this channel +func (cc *ChannelConfig) ApplicationConfig() *ApplicationConfig { + return cc.appConfig +} + +// ConsortiumsConfig returns the consortium config associated with this channel if it exists +func (cc *ChannelConfig) ConsortiumsConfig() *ConsortiumsConfig { + return cc.consortiumsConfig +} + +// HashingAlgorithm returns a function pointer to the chain hashing algorithm +func (cc *ChannelConfig) HashingAlgorithm() func(input []byte) []byte { + return cc.hashingAlgorithm +} + +// BlockDataHashingStructure returns the width to use when forming the block data hashing structure +func (cc *ChannelConfig) BlockDataHashingStructureWidth() uint32 { + return cc.protos.BlockDataHashingStructure.Width +} + +// OrdererAddresses returns the list of valid orderer addresses to connect to to invoke Broadcast/Deliver +func (cc *ChannelConfig) OrdererAddresses() []string { + return cc.protos.OrdererAddresses.Addresses +} + +// ConsortiumName returns the name of the consortium this channel was created under +func (cc *ChannelConfig) ConsortiumName() string { + return cc.protos.Consortium.Name +} + +// Capabilities returns information about the available capabilities for this channel +func (cc *ChannelConfig) Capabilities() ChannelCapabilities { + _ = cc.protos + _ = cc.protos.Capabilities + _ = cc.protos.Capabilities.Capabilities + return capabilities.NewChannelProvider(cc.protos.Capabilities.Capabilities) +} + +// Validate inspects the generated configuration protos and ensures that the values are correct +func (cc *ChannelConfig) Validate(channelCapabilities ChannelCapabilities) error { + for _, validator := range []func() error{ + cc.validateHashingAlgorithm, + cc.validateBlockDataHashingStructure, + } { + if err := validator(); err != nil { + return err + } + } + + if !channelCapabilities.OrgSpecificOrdererEndpoints() { + return cc.validateOrdererAddresses() + } + + return nil +} + +func (cc *ChannelConfig) validateHashingAlgorithm() error { + switch cc.protos.HashingAlgorithm.Name { + case bccsp.SHA256: + cc.hashingAlgorithm = util.ComputeSHA256 + case bccsp.SHA3_256: + cc.hashingAlgorithm = util.ComputeSHA3256 + default: + return fmt.Errorf("Unknown hashing algorithm type: %s", cc.protos.HashingAlgorithm.Name) + } + + return nil +} + +func (cc *ChannelConfig) validateBlockDataHashingStructure() error { + if cc.protos.BlockDataHashingStructure.Width != math.MaxUint32 { + return fmt.Errorf("BlockDataHashStructure width only supported at MaxUint32 in this version") + } + return nil +} + +func (cc *ChannelConfig) validateOrdererAddresses() error { + if len(cc.protos.OrdererAddresses.Addresses) == 0 { + return fmt.Errorf("Must set some OrdererAddresses") + } + return nil +} diff --git a/internal/github.com/hyperledger/fabric/common/channelconfig/consortium.go b/internal/github.com/hyperledger/fabric/common/channelconfig/consortium.go new file mode 100644 index 00000000..c94b974a --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/channelconfig/consortium.go @@ -0,0 +1,65 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package channelconfig + +import ( + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/pkg/errors" +) + +const ( + // ChannelCreationPolicyKey is the key used in the consortium config to denote the policy + // to be used in evaluating whether a channel creation request is authorized + ChannelCreationPolicyKey = "ChannelCreationPolicy" +) + +// ConsortiumProtos holds the config protos for the consortium config +type ConsortiumProtos struct { + ChannelCreationPolicy *cb.Policy +} + +// ConsortiumConfig holds the consortium's configuration information +type ConsortiumConfig struct { + protos *ConsortiumProtos + orgs map[string]Org +} + +// NewConsortiumConfig creates a new instance of the consortium's config +func NewConsortiumConfig(consortiumGroup *cb.ConfigGroup, mspConfig *MSPConfigHandler) (*ConsortiumConfig, error) { + cc := &ConsortiumConfig{ + protos: &ConsortiumProtos{}, + orgs: make(map[string]Org), + } + + if err := DeserializeProtoValuesFromGroup(consortiumGroup, cc.protos); err != nil { + return nil, errors.Wrap(err, "failed to deserialize values") + } + + for orgName, orgGroup := range consortiumGroup.Groups { + var err error + if cc.orgs[orgName], err = NewOrganizationConfig(orgName, orgGroup, mspConfig); err != nil { + return nil, err + } + } + + return cc, nil +} + +// Organizations returns the set of organizations in the consortium +func (cc *ConsortiumConfig) Organizations() map[string]Org { + return cc.orgs +} + +// CreationPolicy returns the policy structure used to validate +// the channel creation +func (cc *ConsortiumConfig) ChannelCreationPolicy() *cb.Policy { + return cc.protos.ChannelCreationPolicy +} diff --git a/internal/github.com/hyperledger/fabric/common/channelconfig/consortiums.go b/internal/github.com/hyperledger/fabric/common/channelconfig/consortiums.go new file mode 100644 index 00000000..a0d9ada1 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/channelconfig/consortiums.go @@ -0,0 +1,45 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package channelconfig + +import ( + cb "github.com/hyperledger/fabric-protos-go/common" +) + +const ( + // ConsortiumsGroupKey is the group name for the consortiums config + ConsortiumsGroupKey = "Consortiums" +) + +// ConsortiumsConfig holds the consoritums configuration information +type ConsortiumsConfig struct { + consortiums map[string]Consortium +} + +// NewConsortiumsConfig creates a new instance of the consoritums config +func NewConsortiumsConfig(consortiumsGroup *cb.ConfigGroup, mspConfig *MSPConfigHandler) (*ConsortiumsConfig, error) { + cc := &ConsortiumsConfig{ + consortiums: make(map[string]Consortium), + } + + for consortiumName, consortiumGroup := range consortiumsGroup.Groups { + var err error + if cc.consortiums[consortiumName], err = NewConsortiumConfig(consortiumGroup, mspConfig); err != nil { + return nil, err + } + } + return cc, nil +} + +// Consortiums returns a map of the current consortiums +func (cc *ConsortiumsConfig) Consortiums() map[string]Consortium { + return cc.consortiums +} diff --git a/internal/github.com/hyperledger/fabric/common/channelconfig/msp.go b/internal/github.com/hyperledger/fabric/common/channelconfig/msp.go new file mode 100644 index 00000000..4163d5d2 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/channelconfig/msp.go @@ -0,0 +1,113 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package channelconfig + +import ( + "fmt" + + "github.com/golang/protobuf/proto" + mspprotos "github.com/hyperledger/fabric-protos-go/msp" + "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/msp" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/msp/cache" + "github.com/pkg/errors" +) + +type pendingMSPConfig struct { + mspConfig *mspprotos.MSPConfig + msp msp.MSP +} + +// MSPConfigHandler +type MSPConfigHandler struct { + version msp.MSPVersion + idMap map[string]*pendingMSPConfig + bccsp core.CryptoSuite +} + +func NewMSPConfigHandler(mspVersion msp.MSPVersion, bccsp core.CryptoSuite) *MSPConfigHandler { + return &MSPConfigHandler{ + version: mspVersion, + idMap: make(map[string]*pendingMSPConfig), + bccsp: bccsp, + } +} + +// ProposeMSP called when an org defines an MSP +func (bh *MSPConfigHandler) ProposeMSP(mspConfig *mspprotos.MSPConfig) (msp.MSP, error) { + var theMsp msp.MSP + var err error + + switch mspConfig.Type { + case int32(msp.FABRIC): + // create the bccsp msp instance + mspInst, err := msp.New( + &msp.BCCSPNewOpts{NewBaseOpts: msp.NewBaseOpts{Version: bh.version}}, + bh.bccsp, + ) + if err != nil { + return nil, errors.WithMessage(err, "creating the MSP manager failed") + } + + // add a cache layer on top + theMsp, err = cache.New(mspInst) + if err != nil { + return nil, errors.WithMessage(err, "creating the MSP cache failed") + } + case int32(msp.IDEMIX): + // create the idemix msp instance + theMsp, err = msp.New( + &msp.IdemixNewOpts{NewBaseOpts: msp.NewBaseOpts{Version: bh.version}}, + bh.bccsp, + ) + if err != nil { + return nil, errors.WithMessage(err, "creating the MSP manager failed") + } + default: + return nil, errors.New(fmt.Sprintf("Setup error: unsupported msp type %d", mspConfig.Type)) + } + + // set it up + err = theMsp.Setup(mspConfig) + if err != nil { + return nil, errors.WithMessage(err, "setting up the MSP manager failed") + } + + // add the MSP to the map of pending MSPs + mspID, _ := theMsp.GetIdentifier() + + existingPendingMSPConfig, ok := bh.idMap[mspID] + if ok && !proto.Equal(existingPendingMSPConfig.mspConfig, mspConfig) { + return nil, errors.New(fmt.Sprintf("Attempted to define two different versions of MSP: %s", mspID)) + } + + if !ok { + bh.idMap[mspID] = &pendingMSPConfig{ + mspConfig: mspConfig, + msp: theMsp, + } + } + + return theMsp, nil +} + +func (bh *MSPConfigHandler) CreateMSPManager() (msp.MSPManager, error) { + mspList := make([]msp.MSP, len(bh.idMap)) + i := 0 + for _, pendingMSP := range bh.idMap { + mspList[i] = pendingMSP.msp + i++ + } + + manager := msp.NewMSPManager() + err := manager.Setup(mspList) + return manager, err +} diff --git a/internal/github.com/hyperledger/fabric/common/channelconfig/orderer.go b/internal/github.com/hyperledger/fabric/common/channelconfig/orderer.go new file mode 100644 index 00000000..f9481d51 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/channelconfig/orderer.go @@ -0,0 +1,277 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package channelconfig + +import ( + "fmt" + "regexp" + "strconv" + "strings" + "time" + + cb "github.com/hyperledger/fabric-protos-go/common" + ab "github.com/hyperledger/fabric-protos-go/orderer" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/capabilities" + "github.com/pkg/errors" +) + +const ( + // OrdererGroupKey is the group name for the orderer config. + OrdererGroupKey = "Orderer" +) + +const ( + // ConsensusTypeKey is the cb.ConfigItem type key name for the ConsensusType message. + ConsensusTypeKey = "ConsensusType" + + // BatchSizeKey is the cb.ConfigItem type key name for the BatchSize message. + BatchSizeKey = "BatchSize" + + // BatchTimeoutKey is the cb.ConfigItem type key name for the BatchTimeout message. + BatchTimeoutKey = "BatchTimeout" + + // ChannelRestrictionsKey is the key name for the ChannelRestrictions message. + ChannelRestrictionsKey = "ChannelRestrictions" + + // KafkaBrokersKey is the cb.ConfigItem type key name for the KafkaBrokers message. + KafkaBrokersKey = "KafkaBrokers" + + // EndpointsKey is the cb.COnfigValue key name for the Endpoints message in the OrdererOrgGroup. + EndpointsKey = "Endpoints" +) + +// OrdererProtos is used as the source of the OrdererConfig. +type OrdererProtos struct { + ConsensusType *ab.ConsensusType + BatchSize *ab.BatchSize + BatchTimeout *ab.BatchTimeout + KafkaBrokers *ab.KafkaBrokers + ChannelRestrictions *ab.ChannelRestrictions + Capabilities *cb.Capabilities +} + +// OrdererConfig holds the orderer configuration information. +type OrdererConfig struct { + protos *OrdererProtos + orgs map[string]OrdererOrg + + batchTimeout time.Duration +} + +// OrdererOrgProtos are deserialized from the Orderer org config values +type OrdererOrgProtos struct { + Endpoints *cb.OrdererAddresses +} + +// OrdererOrgConfig defines the configuration for an orderer org +type OrdererOrgConfig struct { + *OrganizationConfig + protos *OrdererOrgProtos + name string +} + +// Endpoints returns the set of addresses this ordering org exposes as orderers +func (oc *OrdererOrgConfig) Endpoints() []string { + return oc.protos.Endpoints.Addresses +} + +// NewOrdererOrgConfig returns an orderer org config built from the given ConfigGroup. +func NewOrdererOrgConfig(orgName string, orgGroup *cb.ConfigGroup, mspConfigHandler *MSPConfigHandler, channelCapabilities ChannelCapabilities) (*OrdererOrgConfig, error) { + if len(orgGroup.Groups) > 0 { + return nil, fmt.Errorf("OrdererOrg config does not allow sub-groups") + } + + if !channelCapabilities.OrgSpecificOrdererEndpoints() { + if _, ok := orgGroup.Values[EndpointsKey]; ok { + return nil, errors.Errorf("Orderer Org %s cannot contain endpoints value until V1_4_2+ capabilities have been enabled", orgName) + } + } + + protos := &OrdererOrgProtos{} + orgProtos := &OrganizationProtos{} + + if err := DeserializeProtoValuesFromGroup(orgGroup, protos, orgProtos); err != nil { + return nil, errors.Wrap(err, "failed to deserialize values") + } + + ooc := &OrdererOrgConfig{ + name: orgName, + protos: protos, + OrganizationConfig: &OrganizationConfig{ + name: orgName, + protos: orgProtos, + mspConfigHandler: mspConfigHandler, + }, + } + + if err := ooc.Validate(); err != nil { + return nil, err + } + + return ooc, nil +} + +func (ooc *OrdererOrgConfig) Validate() error { + return ooc.OrganizationConfig.Validate() +} + +// NewOrdererConfig creates a new instance of the orderer config. +func NewOrdererConfig(ordererGroup *cb.ConfigGroup, mspConfig *MSPConfigHandler, channelCapabilities ChannelCapabilities) (*OrdererConfig, error) { + oc := &OrdererConfig{ + protos: &OrdererProtos{}, + orgs: make(map[string]OrdererOrg), + } + + if err := DeserializeProtoValuesFromGroup(ordererGroup, oc.protos); err != nil { + return nil, errors.Wrap(err, "failed to deserialize values") + } + + if err := oc.Validate(); err != nil { + return nil, err + } + + for orgName, orgGroup := range ordererGroup.Groups { + var err error + if oc.orgs[orgName], err = NewOrdererOrgConfig(orgName, orgGroup, mspConfig, channelCapabilities); err != nil { + return nil, err + } + } + return oc, nil +} + +// ConsensusType returns the configured consensus type. +func (oc *OrdererConfig) ConsensusType() string { + return oc.protos.ConsensusType.Type +} + +// ConsensusMetadata returns the metadata associated with the consensus type. +func (oc *OrdererConfig) ConsensusMetadata() []byte { + return oc.protos.ConsensusType.Metadata +} + +// ConsensusState return the consensus type state. +func (oc *OrdererConfig) ConsensusState() ab.ConsensusType_State { + return oc.protos.ConsensusType.State +} + +// BatchSize returns the maximum number of messages to include in a block. +func (oc *OrdererConfig) BatchSize() *ab.BatchSize { + return oc.protos.BatchSize +} + +// BatchTimeout returns the amount of time to wait before creating a batch. +func (oc *OrdererConfig) BatchTimeout() time.Duration { + return oc.batchTimeout +} + +// KafkaBrokers returns the addresses (IP:port notation) of a set of "bootstrap" +// Kafka brokers, i.e. this is not necessarily the entire set of Kafka brokers +// used for ordering. +func (oc *OrdererConfig) KafkaBrokers() []string { + return oc.protos.KafkaBrokers.Brokers +} + +// MaxChannelsCount returns the maximum count of channels this orderer supports. +func (oc *OrdererConfig) MaxChannelsCount() uint64 { + return oc.protos.ChannelRestrictions.MaxCount +} + +// Organizations returns a map of the orgs in the channel. +func (oc *OrdererConfig) Organizations() map[string]OrdererOrg { + return oc.orgs +} + +// Capabilities returns the capabilities the ordering network has for this channel. +func (oc *OrdererConfig) Capabilities() OrdererCapabilities { + return capabilities.NewOrdererProvider(oc.protos.Capabilities.Capabilities) +} + +func (oc *OrdererConfig) Validate() error { + for _, validator := range []func() error{ + oc.validateBatchSize, + oc.validateBatchTimeout, + oc.validateKafkaBrokers, + } { + if err := validator(); err != nil { + return err + } + } + + return nil +} + +func (oc *OrdererConfig) validateBatchSize() error { + if oc.protos.BatchSize.MaxMessageCount == 0 { + return fmt.Errorf("Attempted to set the batch size max message count to an invalid value: 0") + } + if oc.protos.BatchSize.AbsoluteMaxBytes == 0 { + return fmt.Errorf("Attempted to set the batch size absolute max bytes to an invalid value: 0") + } + if oc.protos.BatchSize.PreferredMaxBytes == 0 { + return fmt.Errorf("Attempted to set the batch size preferred max bytes to an invalid value: 0") + } + if oc.protos.BatchSize.PreferredMaxBytes > oc.protos.BatchSize.AbsoluteMaxBytes { + return fmt.Errorf("Attempted to set the batch size preferred max bytes (%v) greater than the absolute max bytes (%v).", oc.protos.BatchSize.PreferredMaxBytes, oc.protos.BatchSize.AbsoluteMaxBytes) + } + return nil +} + +func (oc *OrdererConfig) validateBatchTimeout() error { + var err error + oc.batchTimeout, err = time.ParseDuration(oc.protos.BatchTimeout.Timeout) + if err != nil { + return fmt.Errorf("Attempted to set the batch timeout to a invalid value: %s", err) + } + if oc.batchTimeout <= 0 { + return fmt.Errorf("Attempted to set the batch timeout to a non-positive value: %s", oc.batchTimeout) + } + return nil +} + +func (oc *OrdererConfig) validateKafkaBrokers() error { + for _, broker := range oc.protos.KafkaBrokers.Brokers { + if !brokerEntrySeemsValid(broker) { + return fmt.Errorf("Invalid broker entry: %s", broker) + } + } + return nil +} + +// This does just a barebones sanity check. +func brokerEntrySeemsValid(broker string) bool { + if !strings.Contains(broker, ":") { + return false + } + + parts := strings.Split(broker, ":") + if len(parts) > 2 { + return false + } + + host := parts[0] + port := parts[1] + + if _, err := strconv.ParseUint(port, 10, 16); err != nil { + return false + } + + // Valid hostnames may contain only the ASCII letters 'a' through 'z' (in a + // case-insensitive manner), the digits '0' through '9', and the hyphen. IP + // v4 addresses are represented in dot-decimal notation, which consists of + // four decimal numbers, each ranging from 0 to 255, separated by dots, + // e.g., 172.16.254.1 + // The following regular expression: + // 1. allows just a-z (case-insensitive), 0-9, and the dot and hyphen characters + // 2. does not allow leading trailing dots or hyphens + re, _ := regexp.Compile("^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9.-]*[a-zA-Z0-9])$") + matched := re.FindString(host) + return len(matched) == len(host) +} diff --git a/internal/github.com/hyperledger/fabric/common/channelconfig/organization.go b/internal/github.com/hyperledger/fabric/common/channelconfig/organization.go new file mode 100644 index 00000000..8e3ede26 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/channelconfig/organization.go @@ -0,0 +1,101 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package channelconfig + +import ( + "fmt" + + cb "github.com/hyperledger/fabric-protos-go/common" + mspprotos "github.com/hyperledger/fabric-protos-go/msp" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/msp" + "github.com/pkg/errors" +) + +const ( + // MSPKey is the key for the MSP definition in orderer groups + MSPKey = "MSP" +) + +// OrganizationProtos are used to deserialize the organization config +type OrganizationProtos struct { + MSP *mspprotos.MSPConfig +} + +// OrganizationConfig stores the configuration for an organization +type OrganizationConfig struct { + protos *OrganizationProtos + + mspConfigHandler *MSPConfigHandler + msp msp.MSP + mspID string + name string +} + +// NewOrganizationConfig creates a new config for an organization +func NewOrganizationConfig(name string, orgGroup *cb.ConfigGroup, mspConfigHandler *MSPConfigHandler) (*OrganizationConfig, error) { + if len(orgGroup.Groups) > 0 { + return nil, fmt.Errorf("organizations do not support sub-groups") + } + + oc := &OrganizationConfig{ + protos: &OrganizationProtos{}, + name: name, + mspConfigHandler: mspConfigHandler, + } + + if err := DeserializeProtoValuesFromGroup(orgGroup, oc.protos); err != nil { + return nil, errors.Wrap(err, "failed to deserialize values") + } + + if err := oc.Validate(); err != nil { + return nil, err + } + + return oc, nil +} + +// Name returns the name this org is referred to in config +func (oc *OrganizationConfig) Name() string { + return oc.name +} + +// MSPID returns the MSP ID associated with this org +func (oc *OrganizationConfig) MSPID() string { + return oc.mspID +} + +// MSP returns the actual MSP implementation for this org. +func (oc *OrganizationConfig) MSP() msp.MSP { + return oc.msp +} + +// Validate returns whether the configuration is valid +func (oc *OrganizationConfig) Validate() error { + return oc.validateMSP() +} + +func (oc *OrganizationConfig) validateMSP() error { + var err error + + logger.Debugf("Setting up MSP for org %s", oc.name) + oc.msp, err = oc.mspConfigHandler.ProposeMSP(oc.protos.MSP) + if err != nil { + return err + } + + oc.mspID, _ = oc.msp.GetIdentifier() + + if oc.mspID == "" { + return fmt.Errorf("MSP for org %s has empty MSP ID", oc.name) + } + + return nil +} diff --git a/internal/github.com/hyperledger/fabric/common/channelconfig/standardvalues.go b/internal/github.com/hyperledger/fabric/common/channelconfig/standardvalues.go new file mode 100644 index 00000000..3dbdec27 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/channelconfig/standardvalues.go @@ -0,0 +1,115 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package channelconfig + +import ( + "fmt" + "reflect" + + "github.com/golang/protobuf/proto" + cb "github.com/hyperledger/fabric-protos-go/common" +) + +// DeserializeGroup deserializes the value for all values in a config group +func DeserializeProtoValuesFromGroup(group *cb.ConfigGroup, protosStructs ...interface{}) error { + sv, err := NewStandardValues(protosStructs...) + if err != nil { + logger.Panicf("This is a compile time bug only, the proto structures are somehow invalid: %s", err) + } + + for key, value := range group.Values { + if _, err := sv.Deserialize(key, value.Value); err != nil { + return err + } + } + return nil +} + +type StandardValues struct { + lookup map[string]proto.Message +} + +// NewStandardValues accepts a structure which must contain only protobuf message +// types. The structure may embed other (non-pointer) structures which satisfy +// the same condition. NewStandard values will instantiate memory for all the proto +// messages and build a lookup map from structure field name to proto message instance +// This is a useful way to easily implement the Values interface +func NewStandardValues(protosStructs ...interface{}) (*StandardValues, error) { + sv := &StandardValues{ + lookup: make(map[string]proto.Message), + } + + for _, protosStruct := range protosStructs { + logger.Debugf("Initializing protos for %T\n", protosStruct) + if err := sv.initializeProtosStruct(reflect.ValueOf(protosStruct)); err != nil { + return nil, err + } + } + + return sv, nil +} + +// Deserialize looks up the backing Values proto of the given name, unmarshals the given bytes +// to populate the backing message structure, and returns a referenced to the retained deserialized +// message (or an error, either because the key did not exist, or there was an an error unmarshaling +func (sv *StandardValues) Deserialize(key string, value []byte) (proto.Message, error) { + msg, ok := sv.lookup[key] + if !ok { + return nil, fmt.Errorf("Unexpected key %s", key) + } + + err := proto.Unmarshal(value, msg) + if err != nil { + return nil, err + } + + return msg, nil +} + +func (sv *StandardValues) initializeProtosStruct(objValue reflect.Value) error { + objType := objValue.Type() + if objType.Kind() != reflect.Ptr { + return fmt.Errorf("Non pointer type") + } + if objType.Elem().Kind() != reflect.Struct { + return fmt.Errorf("Non struct type") + } + + numFields := objValue.Elem().NumField() + for i := 0; i < numFields; i++ { + structField := objType.Elem().Field(i) + logger.Debugf("Processing field: %s\n", structField.Name) + switch structField.Type.Kind() { + case reflect.Ptr: + fieldPtr := objValue.Elem().Field(i) + if !fieldPtr.CanSet() { + return fmt.Errorf("Cannot set structure field %s (unexported?)", structField.Name) + } + fieldPtr.Set(reflect.New(structField.Type.Elem())) + default: + return fmt.Errorf("Bad type supplied: %s", structField.Type.Kind()) + } + + proto, ok := objValue.Elem().Field(i).Interface().(proto.Message) + if !ok { + return fmt.Errorf("Field type %T does not implement proto.Message", objValue.Elem().Field(i)) + } + + _, ok = sv.lookup[structField.Name] + if ok { + return fmt.Errorf("Ambiguous field name specified, multiple occurrences of %s", structField.Name) + } + + sv.lookup[structField.Name] = proto + } + + return nil +} diff --git a/internal/github.com/hyperledger/fabric/common/channelconfig/utils.go b/internal/github.com/hyperledger/fabric/common/channelconfig/utils.go new file mode 100644 index 00000000..8cb8cfa6 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/channelconfig/utils.go @@ -0,0 +1,263 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package channelconfig + +import ( + "fmt" + "io/ioutil" + "math" + + "github.com/golang/protobuf/proto" + cb "github.com/hyperledger/fabric-protos-go/common" + mspprotos "github.com/hyperledger/fabric-protos-go/msp" + ab "github.com/hyperledger/fabric-protos-go/orderer" + "github.com/hyperledger/fabric-protos-go/orderer/etcdraft" + pb "github.com/hyperledger/fabric-protos-go/peer" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/bccsp" +) + +const ( + // ReadersPolicyKey is the key used for the read policy + ReadersPolicyKey = "Readers" + + // WritersPolicyKey is the key used for the read policy + WritersPolicyKey = "Writers" + + // AdminsPolicyKey is the key used for the read policy + AdminsPolicyKey = "Admins" + + defaultHashingAlgorithm = bccsp.SHA256 + + defaultBlockDataHashingStructureWidth = math.MaxUint32 +) + +// ConfigValue defines a common representation for different *cb.ConfigValue values. +type ConfigValue interface { + // Key is the key this value should be stored in the *cb.ConfigGroup.Values map. + Key() string + + // Value is the message which should be marshaled to opaque bytes for the *cb.ConfigValue.value. + Value() proto.Message +} + +// StandardConfigValue implements the ConfigValue interface. +type StandardConfigValue struct { + key string + value proto.Message +} + +// Key is the key this value should be stored in the *cb.ConfigGroup.Values map. +func (scv *StandardConfigValue) Key() string { + return scv.key +} + +// Value is the message which should be marshaled to opaque bytes for the *cb.ConfigValue.value. +func (scv *StandardConfigValue) Value() proto.Message { + return scv.value +} + +// ConsortiumValue returns the config definition for the consortium name. +// It is a value for the channel group. +func ConsortiumValue(name string) *StandardConfigValue { + return &StandardConfigValue{ + key: ConsortiumKey, + value: &cb.Consortium{ + Name: name, + }, + } +} + +// HashingAlgorithm returns the only currently valid hashing algorithm. +// It is a value for the /Channel group. +func HashingAlgorithmValue() *StandardConfigValue { + return &StandardConfigValue{ + key: HashingAlgorithmKey, + value: &cb.HashingAlgorithm{ + Name: defaultHashingAlgorithm, + }, + } +} + +// BlockDataHashingStructureValue returns the only currently valid block data hashing structure. +// It is a value for the /Channel group. +func BlockDataHashingStructureValue() *StandardConfigValue { + return &StandardConfigValue{ + key: BlockDataHashingStructureKey, + value: &cb.BlockDataHashingStructure{ + Width: defaultBlockDataHashingStructureWidth, + }, + } +} + +// OrdererAddressesValue returns the a config definition for the orderer addresses. +// It is a value for the /Channel group. +func OrdererAddressesValue(addresses []string) *StandardConfigValue { + return &StandardConfigValue{ + key: OrdererAddressesKey, + value: &cb.OrdererAddresses{ + Addresses: addresses, + }, + } +} + +// ConsensusTypeValue returns the config definition for the orderer consensus type. +// It is a value for the /Channel/Orderer group. +func ConsensusTypeValue(consensusType string, consensusMetadata []byte) *StandardConfigValue { + return &StandardConfigValue{ + key: ConsensusTypeKey, + value: &ab.ConsensusType{ + Type: consensusType, + Metadata: consensusMetadata, + }, + } +} + +// BatchSizeValue returns the config definition for the orderer batch size. +// It is a value for the /Channel/Orderer group. +func BatchSizeValue(maxMessages, absoluteMaxBytes, preferredMaxBytes uint32) *StandardConfigValue { + return &StandardConfigValue{ + key: BatchSizeKey, + value: &ab.BatchSize{ + MaxMessageCount: maxMessages, + AbsoluteMaxBytes: absoluteMaxBytes, + PreferredMaxBytes: preferredMaxBytes, + }, + } +} + +// BatchTimeoutValue returns the config definition for the orderer batch timeout. +// It is a value for the /Channel/Orderer group. +func BatchTimeoutValue(timeout string) *StandardConfigValue { + return &StandardConfigValue{ + key: BatchTimeoutKey, + value: &ab.BatchTimeout{ + Timeout: timeout, + }, + } +} + +// ChannelRestrictionsValue returns the config definition for the orderer channel restrictions. +// It is a value for the /Channel/Orderer group. +func ChannelRestrictionsValue(maxChannelCount uint64) *StandardConfigValue { + return &StandardConfigValue{ + key: ChannelRestrictionsKey, + value: &ab.ChannelRestrictions{ + MaxCount: maxChannelCount, + }, + } +} + +// KafkaBrokersValue returns the config definition for the addresses of the ordering service's Kafka brokers. +// It is a value for the /Channel/Orderer group. +func KafkaBrokersValue(brokers []string) *StandardConfigValue { + return &StandardConfigValue{ + key: KafkaBrokersKey, + value: &ab.KafkaBrokers{ + Brokers: brokers, + }, + } +} + +// MSPValue returns the config definition for an MSP. +// It is a value for the /Channel/Orderer/*, /Channel/Application/*, and /Channel/Consortiums/*/*/* groups. +func MSPValue(mspDef *mspprotos.MSPConfig) *StandardConfigValue { + return &StandardConfigValue{ + key: MSPKey, + value: mspDef, + } +} + +// CapabilitiesValue returns the config definition for a a set of capabilities. +// It is a value for the /Channel/Orderer, Channel/Application/, and /Channel groups. +func CapabilitiesValue(capabilities map[string]bool) *StandardConfigValue { + c := &cb.Capabilities{ + Capabilities: make(map[string]*cb.Capability), + } + + for capability, required := range capabilities { + if !required { + continue + } + c.Capabilities[capability] = &cb.Capability{} + } + + return &StandardConfigValue{ + key: CapabilitiesKey, + value: c, + } +} + +// EndpointsValue returns the config definition for the orderer addresses at an org scoped level. +// It is a value for the /Channel/Orderer/ group. +func EndpointsValue(addresses []string) *StandardConfigValue { + return &StandardConfigValue{ + key: EndpointsKey, + value: &cb.OrdererAddresses{ + Addresses: addresses, + }, + } +} + +// AnchorPeersValue returns the config definition for an org's anchor peers. +// It is a value for the /Channel/Application/*. +func AnchorPeersValue(anchorPeers []*pb.AnchorPeer) *StandardConfigValue { + return &StandardConfigValue{ + key: AnchorPeersKey, + value: &pb.AnchorPeers{AnchorPeers: anchorPeers}, + } +} + +// ChannelCreationPolicyValue returns the config definition for a consortium's channel creation policy +// It is a value for the /Channel/Consortiums/*/*. +func ChannelCreationPolicyValue(policy *cb.Policy) *StandardConfigValue { + return &StandardConfigValue{ + key: ChannelCreationPolicyKey, + value: policy, + } +} + +// ACLValues returns the config definition for an applications resources based ACL definitions. +// It is a value for the /Channel/Application/. +func ACLValues(acls map[string]string) *StandardConfigValue { + a := &pb.ACLs{ + Acls: make(map[string]*pb.APIResource), + } + + for apiResource, policyRef := range acls { + a.Acls[apiResource] = &pb.APIResource{PolicyRef: policyRef} + } + + return &StandardConfigValue{ + key: ACLsKey, + value: a, + } +} + +// MarshalEtcdRaftMetadata serializes etcd RAFT metadata. +func MarshalEtcdRaftMetadata(md *etcdraft.ConfigMetadata) ([]byte, error) { + copyMd := proto.Clone(md).(*etcdraft.ConfigMetadata) + for _, c := range copyMd.Consenters { + // Expect the user to set the config value for client/server certs to the + // path where they are persisted locally, then load these files to memory. + clientCert, err := ioutil.ReadFile(string(c.GetClientTlsCert())) + if err != nil { + return nil, fmt.Errorf("cannot load client cert for consenter %s:%d: %s", c.GetHost(), c.GetPort(), err) + } + c.ClientTlsCert = clientCert + + serverCert, err := ioutil.ReadFile(string(c.GetServerTlsCert())) + if err != nil { + return nil, fmt.Errorf("cannot load server cert for consenter %s:%d: %s", c.GetHost(), c.GetPort(), err) + } + c.ServerTlsCert = serverCert + } + return proto.Marshal(copyMd) +} diff --git a/internal/github.com/hyperledger/fabric/common/configtx/configtx.go b/internal/github.com/hyperledger/fabric/common/configtx/configtx.go new file mode 100644 index 00000000..77eae510 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/configtx/configtx.go @@ -0,0 +1,34 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package configtx + +import ( + cb "github.com/hyperledger/fabric-protos-go/common" +) + +// Validator provides a mechanism to propose config updates, see the config update results +// and validate the results of a config update. +type Validator interface { + // Validate attempts to apply a configtx to become the new config + Validate(configEnv *cb.ConfigEnvelope) error + + // Validate attempts to validate a new configtx against the current config state + ProposeConfigUpdate(configtx *cb.Envelope) (*cb.ConfigEnvelope, error) + + // ChannelID retrieves the channel ID associated with this manager + ChannelID() string + + // ConfigProto returns the current config as a proto + ConfigProto() *cb.Config + + // Sequence returns the current sequence number of the config + Sequence() uint64 +} diff --git a/internal/github.com/hyperledger/fabric/common/genesis/genesis.go b/internal/github.com/hyperledger/fabric/common/genesis/genesis.go new file mode 100644 index 00000000..24fdfac7 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/genesis/genesis.go @@ -0,0 +1,61 @@ +/* +Copyright IBM Corp. 2017 All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package genesis + +import ( + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/protoutil" +) + +const ( + msgVersion = int32(1) + + // These values are fixed for the genesis block. + epoch = 0 +) + +// Factory facilitates the creation of genesis blocks. +type Factory interface { + // Block returns a genesis block for a given channel ID. + Block(channelID string) *cb.Block +} + +type factory struct { + channelGroup *cb.ConfigGroup +} + +// NewFactoryImpl creates a new Factory. +func NewFactoryImpl(channelGroup *cb.ConfigGroup) Factory { + return &factory{channelGroup: channelGroup} +} + +// Block constructs and returns a genesis block for a given channel ID. +func (f *factory) Block(channelID string) *cb.Block { + payloadChannelHeader := protoutil.MakeChannelHeader(cb.HeaderType_CONFIG, msgVersion, channelID, epoch) + payloadSignatureHeader := protoutil.MakeSignatureHeader(nil, protoutil.CreateNonceOrPanic()) + protoutil.SetTxID(payloadChannelHeader, payloadSignatureHeader) + payloadHeader := protoutil.MakePayloadHeader(payloadChannelHeader, payloadSignatureHeader) + payload := &cb.Payload{Header: payloadHeader, Data: protoutil.MarshalOrPanic(&cb.ConfigEnvelope{Config: &cb.Config{ChannelGroup: f.channelGroup}})} + envelope := &cb.Envelope{Payload: protoutil.MarshalOrPanic(payload), Signature: nil} + + block := protoutil.NewBlock(0, nil) + block.Data = &cb.BlockData{Data: [][]byte{protoutil.MarshalOrPanic(envelope)}} + block.Header.DataHash = protoutil.BlockDataHash(block.Data) + block.Metadata.Metadata[cb.BlockMetadataIndex_LAST_CONFIG] = protoutil.MarshalOrPanic(&cb.Metadata{ + Value: protoutil.MarshalOrPanic(&cb.LastConfig{Index: 0}), + }) + block.Metadata.Metadata[cb.BlockMetadataIndex_SIGNATURES] = protoutil.MarshalOrPanic(&cb.Metadata{ + Value: protoutil.MarshalOrPanic(&cb.OrdererBlockMetadata{ + LastConfig: &cb.LastConfig{Index: 0}, + }), + }) + return block +} diff --git a/internal/github.com/hyperledger/fabric/common/metrics/disabled/provider.go b/internal/github.com/hyperledger/fabric/common/metrics/disabled/provider.go new file mode 100644 index 00000000..1eca0ad9 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/metrics/disabled/provider.go @@ -0,0 +1,43 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package disabled + +import ( + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/metrics" +) + +type Provider struct{} + +func (p *Provider) NewCounter(o metrics.CounterOpts) metrics.Counter { return &Counter{} } +func (p *Provider) NewGauge(o metrics.GaugeOpts) metrics.Gauge { return &Gauge{} } +func (p *Provider) NewHistogram(o metrics.HistogramOpts) metrics.Histogram { return &Histogram{} } + +type Counter struct{} + +func (c *Counter) Add(delta float64) {} +func (c *Counter) With(labelValues ...string) metrics.Counter { + return c +} + +type Gauge struct{} + +func (g *Gauge) Add(delta float64) {} +func (g *Gauge) Set(delta float64) {} +func (g *Gauge) With(labelValues ...string) metrics.Gauge { + return g +} + +type Histogram struct{} + +func (h *Histogram) Observe(value float64) {} +func (h *Histogram) With(labelValues ...string) metrics.Histogram { + return h +} diff --git a/internal/github.com/hyperledger/fabric/common/metrics/internal/namer/namer.go b/internal/github.com/hyperledger/fabric/common/metrics/internal/namer/namer.go new file mode 100644 index 00000000..ba461dd3 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/metrics/internal/namer/namer.go @@ -0,0 +1,148 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package namer + +import ( + "fmt" + "regexp" + "strings" + + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/metrics" +) + +type Namer struct { + namespace string + subsystem string + name string + nameFormat string + labelNames map[string]struct{} +} + +func NewCounterNamer(c metrics.CounterOpts) *Namer { + return &Namer{ + namespace: c.Namespace, + subsystem: c.Subsystem, + name: c.Name, + nameFormat: c.StatsdFormat, + labelNames: sliceToSet(c.LabelNames), + } +} + +func NewGaugeNamer(g metrics.GaugeOpts) *Namer { + return &Namer{ + namespace: g.Namespace, + subsystem: g.Subsystem, + name: g.Name, + nameFormat: g.StatsdFormat, + labelNames: sliceToSet(g.LabelNames), + } +} + +func NewHistogramNamer(h metrics.HistogramOpts) *Namer { + return &Namer{ + namespace: h.Namespace, + subsystem: h.Subsystem, + name: h.Name, + nameFormat: h.StatsdFormat, + labelNames: sliceToSet(h.LabelNames), + } +} + +func (n *Namer) validateKey(name string) { + if _, ok := n.labelNames[name]; !ok { + panic("invalid label name: " + name) + } +} + +func (n *Namer) FullyQualifiedName() string { + switch { + case n.namespace != "" && n.subsystem != "": + return strings.Join([]string{n.namespace, n.subsystem, n.name}, ".") + case n.namespace != "": + return strings.Join([]string{n.namespace, n.name}, ".") + case n.subsystem != "": + return strings.Join([]string{n.subsystem, n.name}, ".") + default: + return n.name + } +} + +func (n *Namer) labelsToMap(labelValues []string) map[string]string { + labels := map[string]string{} + for i := 0; i < len(labelValues); i += 2 { + key := labelValues[i] + n.validateKey(key) + if i == len(labelValues)-1 { + labels[key] = "unknown" + } else { + labels[key] = labelValues[i+1] + } + } + return labels +} + +var formatRegexp = regexp.MustCompile(`%{([#?[:alnum:]_]+)}`) +var invalidLabelValueRegexp = regexp.MustCompile(`[.|:\s]`) + +func (n *Namer) Format(labelValues ...string) string { + labels := n.labelsToMap(labelValues) + + cursor := 0 + var segments []string + // iterate over the regex groups and convert to formatters + matches := formatRegexp.FindAllStringSubmatchIndex(n.nameFormat, -1) + for _, m := range matches { + start, end := m[0], m[1] + labelStart, labelEnd := m[2], m[3] + + if start > cursor { + segments = append(segments, n.nameFormat[cursor:start]) + } + + key := n.nameFormat[labelStart:labelEnd] + var value string + switch key { + case "#namespace": + value = n.namespace + case "#subsystem": + value = n.subsystem + case "#name": + value = n.name + case "#fqname": + value = n.FullyQualifiedName() + default: + var ok bool + value, ok = labels[key] + if !ok { + panic(fmt.Sprintf("invalid label in name format: %s", key)) + } + value = invalidLabelValueRegexp.ReplaceAllString(value, "_") + } + segments = append(segments, value) + + cursor = end + } + + // handle any trailing suffix + if cursor != len(n.nameFormat) { + segments = append(segments, n.nameFormat[cursor:]) + } + + return strings.Join(segments, "") +} + +func sliceToSet(set []string) map[string]struct{} { + labelSet := map[string]struct{}{} + for _, s := range set { + labelSet[s] = struct{}{} + } + return labelSet +} diff --git a/internal/github.com/hyperledger/fabric/common/metrics/prometheus/provider.go b/internal/github.com/hyperledger/fabric/common/metrics/prometheus/provider.go new file mode 100644 index 00000000..a3c797b3 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/metrics/prometheus/provider.go @@ -0,0 +1,81 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package prometheus + +import ( + kitmetrics "github.com/go-kit/kit/metrics" + "github.com/go-kit/kit/metrics/prometheus" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/metrics" + prom "github.com/prometheus/client_golang/prometheus" +) + +type Provider struct{} + +func (p *Provider) NewCounter(o metrics.CounterOpts) metrics.Counter { + return &Counter{ + Counter: prometheus.NewCounterFrom( + prom.CounterOpts{ + Namespace: o.Namespace, + Subsystem: o.Subsystem, + Name: o.Name, + Help: o.Help, + }, + o.LabelNames, + ), + } +} + +func (p *Provider) NewGauge(o metrics.GaugeOpts) metrics.Gauge { + return &Gauge{ + Gauge: prometheus.NewGaugeFrom( + prom.GaugeOpts{ + Namespace: o.Namespace, + Subsystem: o.Subsystem, + Name: o.Name, + Help: o.Help, + }, + o.LabelNames, + ), + } +} + +func (p *Provider) NewHistogram(o metrics.HistogramOpts) metrics.Histogram { + return &Histogram{ + Histogram: prometheus.NewHistogramFrom( + prom.HistogramOpts{ + Namespace: o.Namespace, + Subsystem: o.Subsystem, + Name: o.Name, + Help: o.Help, + Buckets: o.Buckets, + }, + o.LabelNames, + ), + } +} + +type Counter struct{ kitmetrics.Counter } + +func (c *Counter) With(labelValues ...string) metrics.Counter { + return &Counter{Counter: c.Counter.With(labelValues...)} +} + +type Gauge struct{ kitmetrics.Gauge } + +func (g *Gauge) With(labelValues ...string) metrics.Gauge { + return &Gauge{Gauge: g.Gauge.With(labelValues...)} +} + +type Histogram struct{ kitmetrics.Histogram } + +func (h *Histogram) With(labelValues ...string) metrics.Histogram { + return &Histogram{Histogram: h.Histogram.With(labelValues...)} +} diff --git a/internal/github.com/hyperledger/fabric/common/metrics/provider.go b/internal/github.com/hyperledger/fabric/common/metrics/provider.go new file mode 100644 index 00000000..f03b07ce --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/metrics/provider.go @@ -0,0 +1,173 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package metrics + +// A Provider is an abstraction for a metrics provider. It is a factory for +// Counter, Gauge, and Histogram meters. +type Provider interface { + // NewCounter creates a new instance of a Counter. + NewCounter(CounterOpts) Counter + // NewGauge creates a new instance of a Gauge. + NewGauge(GaugeOpts) Gauge + // NewHistogram creates a new instance of a Histogram. + NewHistogram(HistogramOpts) Histogram +} + +// A Counter represents a monotonically increasing value. +type Counter interface { + // With is used to provide label values when updating a Counter. This must be + // used to provide values for all LabelNames provided to CounterOpts. + With(labelValues ...string) Counter + + // Add increments a counter value. + Add(delta float64) +} + +// CounterOpts is used to provide basic information about a counter to the +// metrics subsystem. +type CounterOpts struct { + // Namespace, Subsystem, and Name are components of the fully-qualified name + // of the Metric. The fully-qualified aneme is created by joining these + // components with an appropriate separator. Only Name is mandatory, the + // others merely help structuring the name. + Namespace string + Subsystem string + Name string + + // Help provides information about this metric. + Help string + + // LabelNames provides the names of the labels that can be attached to this + // metric. When a metric is recorded, label values must be provided for each + // of these label names. + LabelNames []string + + // LabelHelp provides help information for labels. When set, this information + // will be used to populate the documentation. + LabelHelp map[string]string + + // StatsdFormat determines how the fully-qualified statsd bucket name is + // constructed from Namespace, Subsystem, Name, and Labels. This is done by + // including field references in `%{reference}` escape sequences. + // + // The following reference names are supported: + // - #namespace - the value of Namespace + // - #subsystem - the value of Subsystem + // - #name - the value of Name + // - #fqname - the fully-qualified metric name + // - label_name - the value associated with the named label + // + // The result of the formatting must be a valid statsd bucket name. + StatsdFormat string +} + +// A Gauge is a meter that expresses the current value of some metric. +type Gauge interface { + // With is used to provide label values when recording a Gauge value. This + // must be used to provide values for all LabelNames provided to GaugeOpts. + With(labelValues ...string) Gauge + + // Add increments a Gauge value. + Add(delta float64) // TODO: consider removing + + // Set is used to update the current value associted with a Gauge. + Set(value float64) +} + +// GaugeOpts is used to provide basic information about a gauge to the +// metrics subsystem. +type GaugeOpts struct { + // Namespace, Subsystem, and Name are components of the fully-qualified name + // of the Metric. The fully-qualified aneme is created by joining these + // components with an appropriate separator. Only Name is mandatory, the + // others merely help structuring the name. + Namespace string + Subsystem string + Name string + + // Help provides information about this metric. + Help string + + // LabelNames provides the names of the labels that can be attached to this + // metric. When a metric is recorded, label values must be provided for each + // of these label names. + LabelNames []string + + // LabelHelp provides help information for labels. When set, this information + // will be used to populate the documentation. + LabelHelp map[string]string + + // StatsdFormat determines how the fully-qualified statsd bucket name is + // constructed from Namespace, Subsystem, Name, and Labels. This is done by + // including field references in `%{reference}` escape sequences. + // + // The following reference names are supported: + // - #namespace - the value of Namespace + // - #subsystem - the value of Subsystem + // - #name - the value of Name + // - #fqname - the fully-qualified metric name + // - label_name - the value associated with the named label + // + // The result of the formatting must be a valid statsd bucket name. + StatsdFormat string +} + +// A Histogram is a meter that records an observed value into quantized +// buckets. +type Histogram interface { + // With is used to provide label values when recording a Histogram + // observation. This must be used to provide values for all LabelNames + // provided to HistogramOpts. + With(labelValues ...string) Histogram + Observe(value float64) +} + +// HistogramOpts is used to provide basic information about a histogram to the +// metrics subsystem. +type HistogramOpts struct { + // Namespace, Subsystem, and Name are components of the fully-qualified name + // of the Metric. The fully-qualified aneme is created by joining these + // components with an appropriate separator. Only Name is mandatory, the + // others merely help structuring the name. + Namespace string + Subsystem string + Name string + + // Help provides information about this metric. + Help string + + // Buckets can be used to provide the bucket boundaries for Prometheus. When + // omitted, the default Prometheus bucket values are used. + Buckets []float64 + + // LabelNames provides the names of the labels that can be attached to this + // metric. When a metric is recorded, label values must be provided for each + // of these label names. + LabelNames []string + + // LabelHelp provides help information for labels. When set, this information + // will be used to populate the documentation. + LabelHelp map[string]string + + // StatsdFormat determines how the fully-qualified statsd bucket name is + // constructed from Namespace, Subsystem, Name, and Labels. This is done by + // including field references in `%{reference}` escape sequences. + // + // The following reference names are supported: + // - #namespace - the value of Namespace + // - #subsystem - the value of Subsystem + // - #name - the value of Name + // - #fqname - the fully-qualified metric name + // - label_name - the value associated with the named label + // + // The result of the formatting must be a valid statsd bucket name. + StatsdFormat string +} diff --git a/internal/github.com/hyperledger/fabric/common/metrics/statsd/goruntime/collector.go b/internal/github.com/hyperledger/fabric/common/metrics/statsd/goruntime/collector.go new file mode 100644 index 00000000..8371f10d --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/metrics/statsd/goruntime/collector.go @@ -0,0 +1,134 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package goruntime + +import ( + "runtime" + "time" + + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/metrics" +) + +type Collector struct { + CgoCalls metrics.Gauge + GoRoutines metrics.Gauge + ThreadsCreated metrics.Gauge + HeapAlloc metrics.Gauge + TotalAlloc metrics.Gauge + Mallocs metrics.Gauge + Frees metrics.Gauge + HeapSys metrics.Gauge + HeapIdle metrics.Gauge + HeapInuse metrics.Gauge + HeapReleased metrics.Gauge + HeapObjects metrics.Gauge + StackInuse metrics.Gauge + StackSys metrics.Gauge + MSpanInuse metrics.Gauge + MSpanSys metrics.Gauge + MCacheInuse metrics.Gauge + MCacheSys metrics.Gauge + BuckHashSys metrics.Gauge + GCSys metrics.Gauge + OtherSys metrics.Gauge + NextGC metrics.Gauge + LastGC metrics.Gauge + PauseTotalNs metrics.Gauge + PauseNs metrics.Gauge + NumGC metrics.Gauge + NumForcedGC metrics.Gauge +} + +func NewCollector(p metrics.Provider) *Collector { + return &Collector{ + CgoCalls: p.NewGauge(cgoCallsGaugeOpts), + GoRoutines: p.NewGauge(goRoutinesGaugeOpts), + ThreadsCreated: p.NewGauge(threadsCreatedGaugeOpts), + HeapAlloc: p.NewGauge(heapAllocGaugeOpts), + TotalAlloc: p.NewGauge(totalAllocGaugeOpts), + Mallocs: p.NewGauge(mallocsGaugeOpts), + Frees: p.NewGauge(freesGaugeOpts), + HeapSys: p.NewGauge(heapSysGaugeOpts), + HeapIdle: p.NewGauge(heapIdleGaugeOpts), + HeapInuse: p.NewGauge(heapInuseGaugeOpts), + HeapReleased: p.NewGauge(heapReleasedGaugeOpts), + HeapObjects: p.NewGauge(heapObjectsGaugeOpts), + StackInuse: p.NewGauge(stackInuseGaugeOpts), + StackSys: p.NewGauge(stackSysGaugeOpts), + MSpanInuse: p.NewGauge(mSpanInuseGaugeOpts), + MSpanSys: p.NewGauge(mSpanSysGaugeOpts), + MCacheInuse: p.NewGauge(mCacheInuseGaugeOpts), + MCacheSys: p.NewGauge(mCacheSysGaugeOpts), + BuckHashSys: p.NewGauge(buckHashSysGaugeOpts), + GCSys: p.NewGauge(gCSysGaugeOpts), + OtherSys: p.NewGauge(otherSysGaugeOpts), + NextGC: p.NewGauge(nextGCGaugeOpts), + LastGC: p.NewGauge(lastGCGaugeOpts), + PauseTotalNs: p.NewGauge(pauseTotalNsGaugeOpts), + PauseNs: p.NewGauge(pauseNsGaugeOpts), + NumGC: p.NewGauge(numGCGaugeOpts), + NumForcedGC: p.NewGauge(numForcedGCGaugeOpts), + } +} + +func (c *Collector) CollectAndPublish(ticks <-chan time.Time) { + for range ticks { + stats := CollectStats() + c.Publish(stats) + } +} + +func (c *Collector) Publish(stats Stats) { + c.CgoCalls.Set(float64(stats.CgoCalls)) + c.GoRoutines.Set(float64(stats.GoRoutines)) + c.ThreadsCreated.Set(float64(stats.ThreadsCreated)) + c.HeapAlloc.Set(float64(stats.MemStats.HeapAlloc)) + c.TotalAlloc.Set(float64(stats.MemStats.TotalAlloc)) + c.Mallocs.Set(float64(stats.MemStats.Mallocs)) + c.Frees.Set(float64(stats.MemStats.Frees)) + c.HeapSys.Set(float64(stats.MemStats.HeapSys)) + c.HeapIdle.Set(float64(stats.MemStats.HeapIdle)) + c.HeapInuse.Set(float64(stats.MemStats.HeapInuse)) + c.HeapReleased.Set(float64(stats.MemStats.HeapReleased)) + c.HeapObjects.Set(float64(stats.MemStats.HeapObjects)) + c.StackInuse.Set(float64(stats.MemStats.StackInuse)) + c.StackSys.Set(float64(stats.MemStats.StackSys)) + c.MSpanInuse.Set(float64(stats.MemStats.MSpanInuse)) + c.MSpanSys.Set(float64(stats.MemStats.MSpanSys)) + c.MCacheInuse.Set(float64(stats.MemStats.MCacheInuse)) + c.MCacheSys.Set(float64(stats.MemStats.MCacheSys)) + c.BuckHashSys.Set(float64(stats.MemStats.BuckHashSys)) + c.GCSys.Set(float64(stats.MemStats.GCSys)) + c.OtherSys.Set(float64(stats.MemStats.OtherSys)) + c.NextGC.Set(float64(stats.MemStats.NextGC)) + c.LastGC.Set(float64(stats.MemStats.LastGC)) + c.PauseTotalNs.Set(float64(stats.MemStats.PauseTotalNs)) + c.PauseNs.Set(float64(stats.MemStats.PauseNs[(stats.MemStats.NumGC+255)%256])) + c.NumGC.Set(float64(stats.MemStats.NumGC)) + c.NumForcedGC.Set(float64(stats.MemStats.NumForcedGC)) +} + +type Stats struct { + CgoCalls int64 + GoRoutines int + ThreadsCreated int + MemStats runtime.MemStats +} + +func CollectStats() Stats { + stats := Stats{ + CgoCalls: runtime.NumCgoCall(), + GoRoutines: runtime.NumGoroutine(), + } + stats.ThreadsCreated, _ = runtime.ThreadCreateProfile(nil) + runtime.ReadMemStats(&stats.MemStats) + return stats +} diff --git a/internal/github.com/hyperledger/fabric/common/metrics/statsd/goruntime/metrics.go b/internal/github.com/hyperledger/fabric/common/metrics/statsd/goruntime/metrics.go new file mode 100644 index 00000000..17681be9 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/metrics/statsd/goruntime/metrics.go @@ -0,0 +1,47 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package goruntime + +import ( + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/metrics" +) + +//gendoc:ignore + +var ( + cgoCallsGaugeOpts = metrics.GaugeOpts{Namespace: "go", Name: "cgo_calls"} + goRoutinesGaugeOpts = metrics.GaugeOpts{Namespace: "go", Name: "goroutine_count"} + threadsCreatedGaugeOpts = metrics.GaugeOpts{Namespace: "go", Name: "threads_created"} + heapAllocGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "heap_alloc_bytes"} + totalAllocGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "heap_total_alloc_bytes"} + mallocsGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "heap_malloc_count"} + freesGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "heap_free_count"} + heapSysGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "heap_sys_bytes"} + heapIdleGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "heap_idle_bytes"} + heapInuseGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "heap_inuse_bytes"} + heapReleasedGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "heap_released_bytes"} + heapObjectsGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "heap_objects"} + stackInuseGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "stack_inuse_bytes"} + stackSysGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "stack_sys_bytes"} + mSpanInuseGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "mspan_inuse_bytes"} + mSpanSysGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "mspan_sys_bytes"} + mCacheInuseGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "mcache_inuse_bytes"} + mCacheSysGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "mcache_sys_bytes"} + buckHashSysGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "buckethash_sys_bytes"} + gCSysGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "gc_sys_bytes"} + otherSysGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "other_sys_bytes"} + nextGCGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "gc_next_bytes"} + lastGCGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "gc_last_epoch_nanotime"} + pauseTotalNsGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "gc_pause_total_ns"} + pauseNsGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "gc_pause_last_ns"} + numGCGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "gc_completed_count"} + numForcedGCGaugeOpts = metrics.GaugeOpts{Namespace: "go", Subsystem: "mem", Name: "gc_forced_count"} +) diff --git a/internal/github.com/hyperledger/fabric/common/metrics/statsd/provider.go b/internal/github.com/hyperledger/fabric/common/metrics/statsd/provider.go new file mode 100644 index 00000000..6b05d26d --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/metrics/statsd/provider.go @@ -0,0 +1,132 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package statsd + +import ( + "github.com/go-kit/kit/metrics/statsd" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/metrics" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/metrics/internal/namer" +) + +const defaultFormat = "%{#fqname}" + +type Provider struct { + Statsd *statsd.Statsd +} + +func (p *Provider) NewCounter(o metrics.CounterOpts) metrics.Counter { + if o.StatsdFormat == "" { + o.StatsdFormat = defaultFormat + } + counter := &Counter{ + statsdProvider: p.Statsd, + namer: namer.NewCounterNamer(o), + } + + if len(o.LabelNames) == 0 { + counter.Counter = p.Statsd.NewCounter(counter.namer.Format(), 1) + } + + return counter +} + +func (p *Provider) NewGauge(o metrics.GaugeOpts) metrics.Gauge { + if o.StatsdFormat == "" { + o.StatsdFormat = defaultFormat + } + gauge := &Gauge{ + statsdProvider: p.Statsd, + namer: namer.NewGaugeNamer(o), + } + + if len(o.LabelNames) == 0 { + gauge.Gauge = p.Statsd.NewGauge(gauge.namer.Format()) + } + + return gauge +} + +func (p *Provider) NewHistogram(o metrics.HistogramOpts) metrics.Histogram { + if o.StatsdFormat == "" { + o.StatsdFormat = defaultFormat + } + histogram := &Histogram{ + statsdProvider: p.Statsd, + namer: namer.NewHistogramNamer(o), + } + + if len(o.LabelNames) == 0 { + histogram.Timing = p.Statsd.NewTiming(histogram.namer.Format(), 1.0) + } + + return histogram +} + +type Counter struct { + Counter *statsd.Counter + namer *namer.Namer + statsdProvider *statsd.Statsd +} + +func (c *Counter) Add(delta float64) { + if c.Counter == nil { + panic("label values must be provided by calling With") + } + c.Counter.Add(delta) +} + +func (c *Counter) With(labelValues ...string) metrics.Counter { + name := c.namer.Format(labelValues...) + return &Counter{Counter: c.statsdProvider.NewCounter(name, 1)} +} + +type Gauge struct { + Gauge *statsd.Gauge + namer *namer.Namer + statsdProvider *statsd.Statsd +} + +func (g *Gauge) Add(delta float64) { + if g.Gauge == nil { + panic("label values must be provided by calling With") + } + g.Gauge.Add(delta) +} + +func (g *Gauge) Set(value float64) { + if g.Gauge == nil { + panic("label values must be provided by calling With") + } + g.Gauge.Set(value) +} + +func (g *Gauge) With(labelValues ...string) metrics.Gauge { + name := g.namer.Format(labelValues...) + return &Gauge{Gauge: g.statsdProvider.NewGauge(name)} +} + +type Histogram struct { + Timing *statsd.Timing + namer *namer.Namer + statsdProvider *statsd.Statsd +} + +func (h *Histogram) With(labelValues ...string) metrics.Histogram { + name := h.namer.Format(labelValues...) + return &Histogram{Timing: h.statsdProvider.NewTiming(name, 1)} +} + +func (h *Histogram) Observe(value float64) { + if h.Timing == nil { + panic("label values must be provided by calling With") + } + h.Timing.Observe(value) +} diff --git a/internal/github.com/hyperledger/fabric/common/policies/implicitmetaparser.go b/internal/github.com/hyperledger/fabric/common/policies/implicitmetaparser.go new file mode 100644 index 00000000..80baf171 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/policies/implicitmetaparser.go @@ -0,0 +1,42 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package policies + +import ( + "strings" + + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/pkg/errors" +) + +func ImplicitMetaFromString(input string) (*cb.ImplicitMetaPolicy, error) { + args := strings.Split(input, " ") + if len(args) != 2 { + return nil, errors.Errorf("expected two space separated tokens, but got %d", len(args)) + } + + res := &cb.ImplicitMetaPolicy{ + SubPolicy: args[1], + } + + switch args[0] { + case cb.ImplicitMetaPolicy_ANY.String(): + res.Rule = cb.ImplicitMetaPolicy_ANY + case cb.ImplicitMetaPolicy_ALL.String(): + res.Rule = cb.ImplicitMetaPolicy_ALL + case cb.ImplicitMetaPolicy_MAJORITY.String(): + res.Rule = cb.ImplicitMetaPolicy_MAJORITY + default: + return nil, errors.Errorf("unknown rule type '%s', expected ALL, ANY, or MAJORITY", args[0]) + } + + return res, nil +} diff --git a/internal/github.com/hyperledger/fabric/common/policies/policy.go b/internal/github.com/hyperledger/fabric/common/policies/policy.go new file mode 100644 index 00000000..65f341e0 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/policies/policy.go @@ -0,0 +1,129 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package policies + +import ( + "github.com/golang/protobuf/proto" + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-protos-go/msp" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/protoutil" + flogging "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/logbridge" +) + +const ( + // Path separator is used to separate policy names in paths + PathSeparator = "/" + + // ChannelPrefix is used in the path of standard channel policy managers + ChannelPrefix = "Channel" + + // ApplicationPrefix is used in the path of standard application policy paths + ApplicationPrefix = "Application" + + // OrdererPrefix is used in the path of standard orderer policy paths + OrdererPrefix = "Orderer" + + // ChannelReaders is the label for the channel's readers policy (encompassing both orderer and application readers) + ChannelReaders = PathSeparator + ChannelPrefix + PathSeparator + "Readers" + + // ChannelWriters is the label for the channel's writers policy (encompassing both orderer and application writers) + ChannelWriters = PathSeparator + ChannelPrefix + PathSeparator + "Writers" + + // ChannelApplicationReaders is the label for the channel's application readers policy + ChannelApplicationReaders = PathSeparator + ChannelPrefix + PathSeparator + ApplicationPrefix + PathSeparator + "Readers" + + // ChannelApplicationWriters is the label for the channel's application writers policy + ChannelApplicationWriters = PathSeparator + ChannelPrefix + PathSeparator + ApplicationPrefix + PathSeparator + "Writers" + + // ChannelApplicationAdmins is the label for the channel's application admin policy + ChannelApplicationAdmins = PathSeparator + ChannelPrefix + PathSeparator + ApplicationPrefix + PathSeparator + "Admins" + + // BlockValidation is the label for the policy which should validate the block signatures for the channel + BlockValidation = PathSeparator + ChannelPrefix + PathSeparator + OrdererPrefix + PathSeparator + "BlockValidation" + + // ChannelOrdererAdmins is the label for the channel's orderer admin policy + ChannelOrdererAdmins = PathSeparator + ChannelPrefix + PathSeparator + OrdererPrefix + PathSeparator + "Admins" + + // ChannelOrdererWriters is the label for the channel's orderer writers policy + ChannelOrdererWriters = PathSeparator + ChannelPrefix + PathSeparator + OrdererPrefix + PathSeparator + "Writers" + + // ChannelOrdererReaders is the label for the channel's orderer readers policy + ChannelOrdererReaders = PathSeparator + ChannelPrefix + PathSeparator + OrdererPrefix + PathSeparator + "Readers" +) + +var logger = flogging.MustGetLogger("policies") + +// PrincipalSet is a collection of MSPPrincipals +type PrincipalSet []*msp.MSPPrincipal + +// PrincipalSets aggregates PrincipalSets +type PrincipalSets []PrincipalSet + +// Converter represents a policy +// which may be translated into a SignaturePolicyEnvelope +type Converter interface { + Convert() (*cb.SignaturePolicyEnvelope, error) +} + +// Policy is used to determine if a signature is valid +type Policy interface { + // EvaluateSignedData takes a set of SignedData and evaluates whether + // 1) the signatures are valid over the related message + // 2) the signing identities satisfy the policy + EvaluateSignedData(signatureSet []*protoutil.SignedData) error +} + +// InquireablePolicy is a Policy that one can inquire +type InquireablePolicy interface { + // SatisfiedBy returns a slice of PrincipalSets that each of them + // satisfies the policy. + SatisfiedBy() []PrincipalSet +} + +// Manager is a read only subset of the policy ManagerImpl +type Manager interface { + // GetPolicy returns a policy and true if it was the policy requested, or false if it is the default policy + GetPolicy(id string) (Policy, bool) + + // Manager returns the sub-policy manager for a given path and whether it exists + Manager(path []string) (Manager, bool) +} + +// Provider provides the backing implementation of a policy +type Provider interface { + // NewPolicy creates a new policy based on the policy bytes + NewPolicy(data []byte) (Policy, proto.Message, error) +} + +// ChannelPolicyManagerGetter is a support interface +// to get access to the policy manager of a given channel +type ChannelPolicyManagerGetter interface { + // Returns the policy manager associated with the specified channel. + Manager(channelID string) Manager +} + +// PolicyManagerGetterFunc is a function adapater for ChannelPolicyManagerGetter. +type PolicyManagerGetterFunc func(channelID string) Manager + +// ManagerImpl is an implementation of Manager and configtx.ConfigHandler +// In general, it should only be referenced as an Impl for the configtx.ConfigManager +type ManagerImpl struct { + path string // The group level path + Policies map[string]Policy + managers map[string]*ManagerImpl +} + +type rejectPolicy string + +type PolicyLogger struct { + Policy Policy + policyName string +} diff --git a/internal/github.com/hyperledger/fabric/common/policies/util.go b/internal/github.com/hyperledger/fabric/common/policies/util.go new file mode 100644 index 00000000..023e05e1 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/policies/util.go @@ -0,0 +1,86 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package policies + +import ( + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/protoutil" +) + +// ConfigPolicy defines a common representation for different *cb.ConfigPolicy values. +type ConfigPolicy interface { + // Key is the key this value should be stored in the *cb.ConfigGroup.Policies map. + Key() string + + // Value is the backing policy implementation for this ConfigPolicy + Value() *cb.Policy +} + +// StandardConfigValue implements the ConfigValue interface. +type StandardConfigPolicy struct { + key string + value *cb.Policy +} + +// Key is the key this value should be stored in the *cb.ConfigGroup.Values map. +func (scv *StandardConfigPolicy) Key() string { + return scv.key +} + +// Value is the *cb.Policy which should be stored as the *cb.ConfigPolicy.Policy. +func (scv *StandardConfigPolicy) Value() *cb.Policy { + return scv.value +} + +func makeImplicitMetaPolicy(subPolicyName string, rule cb.ImplicitMetaPolicy_Rule) *cb.Policy { + return &cb.Policy{ + Type: int32(cb.Policy_IMPLICIT_META), + Value: protoutil.MarshalOrPanic(&cb.ImplicitMetaPolicy{ + Rule: rule, + SubPolicy: subPolicyName, + }), + } +} + +// ImplicitMetaAllPolicy defines an implicit meta policy whose sub_policy and key is policyname with rule ALL. +func ImplicitMetaAllPolicy(policyName string) *StandardConfigPolicy { + return &StandardConfigPolicy{ + key: policyName, + value: makeImplicitMetaPolicy(policyName, cb.ImplicitMetaPolicy_ALL), + } +} + +// ImplicitMetaAnyPolicy defines an implicit meta policy whose sub_policy and key is policyname with rule ANY. +func ImplicitMetaAnyPolicy(policyName string) *StandardConfigPolicy { + return &StandardConfigPolicy{ + key: policyName, + value: makeImplicitMetaPolicy(policyName, cb.ImplicitMetaPolicy_ANY), + } +} + +// ImplicitMetaMajorityPolicy defines an implicit meta policy whose sub_policy and key is policyname with rule MAJORITY. +func ImplicitMetaMajorityPolicy(policyName string) *StandardConfigPolicy { + return &StandardConfigPolicy{ + key: policyName, + value: makeImplicitMetaPolicy(policyName, cb.ImplicitMetaPolicy_MAJORITY), + } +} + +// SignaturePolicy defines a policy with key policyName and the given signature policy. +func SignaturePolicy(policyName string, sigPolicy *cb.SignaturePolicyEnvelope) *StandardConfigPolicy { + return &StandardConfigPolicy{ + key: policyName, + value: &cb.Policy{ + Type: int32(cb.Policy_SIGNATURE), + Value: protoutil.MarshalOrPanic(sigPolicy), + }, + } +} diff --git a/internal/github.com/hyperledger/fabric/common/policydsl/policydsl_builder.go b/internal/github.com/hyperledger/fabric/common/policydsl/policydsl_builder.go new file mode 100644 index 00000000..345684dc --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/policydsl/policydsl_builder.go @@ -0,0 +1,206 @@ +/* +Copyright IBM Corp. 2016 All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package policydsl + +import ( + "sort" + + "github.com/golang/protobuf/proto" + cb "github.com/hyperledger/fabric-protos-go/common" + mb "github.com/hyperledger/fabric-protos-go/msp" +) + +// AcceptAllPolicy always evaluates to true +var AcceptAllPolicy *cb.SignaturePolicyEnvelope + +// MarshaledAcceptAllPolicy is the Marshaled version of AcceptAllPolicy +var MarshaledAcceptAllPolicy []byte + +// RejectAllPolicy always evaluates to false +var RejectAllPolicy *cb.SignaturePolicyEnvelope + +// MarshaledRejectAllPolicy is the Marshaled version of RejectAllPolicy +var MarshaledRejectAllPolicy []byte + +func init() { + AcceptAllPolicy = Envelope(NOutOf(0, []*cb.SignaturePolicy{}), [][]byte{}) + MarshaledAcceptAllPolicy = protoMarshalOrPanic(AcceptAllPolicy) + + RejectAllPolicy = Envelope(NOutOf(1, []*cb.SignaturePolicy{}), [][]byte{}) + MarshaledRejectAllPolicy = protoMarshalOrPanic(RejectAllPolicy) +} + +// Envelope builds an envelope message embedding a SignaturePolicy +func Envelope(policy *cb.SignaturePolicy, identities [][]byte) *cb.SignaturePolicyEnvelope { + ids := make([]*mb.MSPPrincipal, len(identities)) + for i := range ids { + ids[i] = &mb.MSPPrincipal{PrincipalClassification: mb.MSPPrincipal_IDENTITY, Principal: identities[i]} + } + + return &cb.SignaturePolicyEnvelope{ + Version: 0, + Rule: policy, + Identities: ids, + } +} + +// SignedBy creates a SignaturePolicy requiring a given signer's signature +func SignedBy(index int32) *cb.SignaturePolicy { + return &cb.SignaturePolicy{ + Type: &cb.SignaturePolicy_SignedBy{ + SignedBy: index, + }, + } +} + +// SignedByMspMember creates a SignaturePolicyEnvelope +// requiring 1 signature from any member of the specified MSP +func SignedByMspMember(mspId string) *cb.SignaturePolicyEnvelope { + return signedByFabricEntity(mspId, mb.MSPRole_MEMBER) +} + +// SignedByMspClient creates a SignaturePolicyEnvelope +// requiring 1 signature from any client of the specified MSP +func SignedByMspClient(mspId string) *cb.SignaturePolicyEnvelope { + return signedByFabricEntity(mspId, mb.MSPRole_CLIENT) +} + +// SignedByMspPeer creates a SignaturePolicyEnvelope +// requiring 1 signature from any peer of the specified MSP +func SignedByMspPeer(mspId string) *cb.SignaturePolicyEnvelope { + return signedByFabricEntity(mspId, mb.MSPRole_PEER) +} + +// SignedByFabricEntity creates a SignaturePolicyEnvelope +// requiring 1 signature from any fabric entity, having the passed role, of the specified MSP +func signedByFabricEntity(mspId string, role mb.MSPRole_MSPRoleType) *cb.SignaturePolicyEnvelope { + // specify the principal: it's a member of the msp we just found + principal := &mb.MSPPrincipal{ + PrincipalClassification: mb.MSPPrincipal_ROLE, + Principal: protoMarshalOrPanic(&mb.MSPRole{Role: role, MspIdentifier: mspId})} + + // create the policy: it requires exactly 1 signature from the first (and only) principal + p := &cb.SignaturePolicyEnvelope{ + Version: 0, + Rule: NOutOf(1, []*cb.SignaturePolicy{SignedBy(0)}), + Identities: []*mb.MSPPrincipal{principal}, + } + + return p +} + +// SignedByMspAdmin creates a SignaturePolicyEnvelope +// requiring 1 signature from any admin of the specified MSP +func SignedByMspAdmin(mspId string) *cb.SignaturePolicyEnvelope { + // specify the principal: it's a member of the msp we just found + principal := &mb.MSPPrincipal{ + PrincipalClassification: mb.MSPPrincipal_ROLE, + Principal: protoMarshalOrPanic(&mb.MSPRole{Role: mb.MSPRole_ADMIN, MspIdentifier: mspId})} + + // create the policy: it requires exactly 1 signature from the first (and only) principal + p := &cb.SignaturePolicyEnvelope{ + Version: 0, + Rule: NOutOf(1, []*cb.SignaturePolicy{SignedBy(0)}), + Identities: []*mb.MSPPrincipal{principal}, + } + + return p +} + +//wrapper for generating "any of a given role" type policies +func signedByAnyOfGivenRole(role mb.MSPRole_MSPRoleType, ids []string) *cb.SignaturePolicyEnvelope { + return SignedByNOutOfGivenRole(1, role, ids) +} + +func SignedByNOutOfGivenRole(n int32, role mb.MSPRole_MSPRoleType, ids []string) *cb.SignaturePolicyEnvelope { + // we create an array of principals, one principal + // per application MSP defined on this chain + sort.Strings(ids) + principals := make([]*mb.MSPPrincipal, len(ids)) + sigspolicy := make([]*cb.SignaturePolicy, len(ids)) + + for i, id := range ids { + principals[i] = &mb.MSPPrincipal{ + PrincipalClassification: mb.MSPPrincipal_ROLE, + Principal: protoMarshalOrPanic(&mb.MSPRole{Role: role, MspIdentifier: id})} + sigspolicy[i] = SignedBy(int32(i)) + } + + // create the policy: it requires exactly 1 signature from any of the principals + p := &cb.SignaturePolicyEnvelope{ + Version: 0, + Rule: NOutOf(n, sigspolicy), + Identities: principals, + } + + return p +} + +// SignedByAnyMember returns a policy that requires one valid +// signature from a member of any of the orgs whose ids are +// listed in the supplied string array +func SignedByAnyMember(ids []string) *cb.SignaturePolicyEnvelope { + return signedByAnyOfGivenRole(mb.MSPRole_MEMBER, ids) +} + +// SignedByAnyClient returns a policy that requires one valid +// signature from a client of any of the orgs whose ids are +// listed in the supplied string array +func SignedByAnyClient(ids []string) *cb.SignaturePolicyEnvelope { + return signedByAnyOfGivenRole(mb.MSPRole_CLIENT, ids) +} + +// SignedByAnyPeer returns a policy that requires one valid +// signature from an orderer of any of the orgs whose ids are +// listed in the supplied string array +func SignedByAnyPeer(ids []string) *cb.SignaturePolicyEnvelope { + return signedByAnyOfGivenRole(mb.MSPRole_PEER, ids) +} + +// SignedByAnyAdmin returns a policy that requires one valid +// signature from a admin of any of the orgs whose ids are +// listed in the supplied string array +func SignedByAnyAdmin(ids []string) *cb.SignaturePolicyEnvelope { + return signedByAnyOfGivenRole(mb.MSPRole_ADMIN, ids) +} + +// And is a convenience method which utilizes NOutOf to produce And equivalent behavior +func And(lhs, rhs *cb.SignaturePolicy) *cb.SignaturePolicy { + return NOutOf(2, []*cb.SignaturePolicy{lhs, rhs}) +} + +// Or is a convenience method which utilizes NOutOf to produce Or equivalent behavior +func Or(lhs, rhs *cb.SignaturePolicy) *cb.SignaturePolicy { + return NOutOf(1, []*cb.SignaturePolicy{lhs, rhs}) +} + +// NOutOf creates a policy which requires N out of the slice of policies to evaluate to true +func NOutOf(n int32, policies []*cb.SignaturePolicy) *cb.SignaturePolicy { + return &cb.SignaturePolicy{ + Type: &cb.SignaturePolicy_NOutOf_{ + NOutOf: &cb.SignaturePolicy_NOutOf{ + N: n, + Rules: policies, + }, + }, + } +} + +// protoMarshalOrPanic serializes a protobuf message and panics if this +// operation fails +func protoMarshalOrPanic(pb proto.Message) []byte { + data, err := proto.Marshal(pb) + if err != nil { + panic(err) + } + + return data +} diff --git a/internal/github.com/hyperledger/fabric/common/policydsl/policyparser.go b/internal/github.com/hyperledger/fabric/common/policydsl/policyparser.go new file mode 100644 index 00000000..4df8622a --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/policydsl/policyparser.go @@ -0,0 +1,357 @@ +/* +Copyright IBM Corp. 2017 All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package policydsl + +import ( + "fmt" + "reflect" + "regexp" + "strconv" + "strings" + + "github.com/Knetic/govaluate" + "github.com/golang/protobuf/proto" + cb "github.com/hyperledger/fabric-protos-go/common" + mb "github.com/hyperledger/fabric-protos-go/msp" +) + +// Gate values +const ( + GateAnd = "And" + GateOr = "Or" + GateOutOf = "OutOf" +) + +// Role values for principals +const ( + RoleAdmin = "admin" + RoleMember = "member" + RoleClient = "client" + RolePeer = "peer" + RoleOrderer = "orderer" +) + +var ( + regex = regexp.MustCompile( + fmt.Sprintf("^([[:alnum:].-]+)([.])(%s|%s|%s|%s|%s)$", + RoleAdmin, RoleMember, RoleClient, RolePeer, RoleOrderer), + ) + regexErr = regexp.MustCompile("^No parameter '([^']+)' found[.]$") +) + +// a stub function - it returns the same string as it's passed. +// This will be evaluated by second/third passes to convert to a proto policy +func outof(args ...interface{}) (interface{}, error) { + toret := "outof(" + + if len(args) < 2 { + return nil, fmt.Errorf("expected at least two arguments to NOutOf. Given %d", len(args)) + } + + arg0 := args[0] + // govaluate treats all numbers as float64 only. But and/or may pass int/string. Allowing int/string for flexibility of caller + if n, ok := arg0.(float64); ok { + toret += strconv.Itoa(int(n)) + } else if n, ok := arg0.(int); ok { + toret += strconv.Itoa(n) + } else if n, ok := arg0.(string); ok { + toret += n + } else { + return nil, fmt.Errorf("unexpected type %s", reflect.TypeOf(arg0)) + } + + for _, arg := range args[1:] { + toret += ", " + + switch t := arg.(type) { + case string: + if regex.MatchString(t) { + toret += "'" + t + "'" + } else { + toret += t + } + default: + return nil, fmt.Errorf("unexpected type %s", reflect.TypeOf(arg)) + } + } + + return toret + ")", nil +} + +func and(args ...interface{}) (interface{}, error) { + args = append([]interface{}{len(args)}, args...) + return outof(args...) +} + +func or(args ...interface{}) (interface{}, error) { + args = append([]interface{}{1}, args...) + return outof(args...) +} + +func firstPass(args ...interface{}) (interface{}, error) { + toret := "outof(ID" + for _, arg := range args { + toret += ", " + + switch t := arg.(type) { + case string: + if regex.MatchString(t) { + toret += "'" + t + "'" + } else { + toret += t + } + case float32: + case float64: + toret += strconv.Itoa(int(t)) + default: + return nil, fmt.Errorf("unexpected type %s", reflect.TypeOf(arg)) + } + } + + return toret + ")", nil +} + +func secondPass(args ...interface{}) (interface{}, error) { + /* general sanity check, we expect at least 3 args */ + if len(args) < 3 { + return nil, fmt.Errorf("at least 3 arguments expected, got %d", len(args)) + } + + /* get the first argument, we expect it to be the context */ + var ctx *context + switch v := args[0].(type) { + case *context: + ctx = v + default: + return nil, fmt.Errorf("unrecognized type, expected the context, got %s", reflect.TypeOf(args[0])) + } + + /* get the second argument, we expect an integer telling us + how many of the remaining we expect to have*/ + var t int + switch arg := args[1].(type) { + case float64: + t = int(arg) + default: + return nil, fmt.Errorf("unrecognized type, expected a number, got %s", reflect.TypeOf(args[1])) + } + + /* get the n in the t out of n */ + var n int = len(args) - 2 + + /* sanity check - t should be positive, permit equal to n+1, but disallow over n+1 */ + if t < 0 || t > n+1 { + return nil, fmt.Errorf("invalid t-out-of-n predicate, t %d, n %d", t, n) + } + + policies := make([]*cb.SignaturePolicy, 0) + + /* handle the rest of the arguments */ + for _, principal := range args[2:] { + switch t := principal.(type) { + /* if it's a string, we expect it to be formed as + . , where MSP_ID is the MSP identifier + and ROLE is either a member, an admin, a client, a peer or an orderer*/ + case string: + /* split the string */ + subm := regex.FindAllStringSubmatch(t, -1) + if subm == nil || len(subm) != 1 || len(subm[0]) != 4 { + return nil, fmt.Errorf("error parsing principal %s", t) + } + + /* get the right role */ + var r mb.MSPRole_MSPRoleType + + switch subm[0][3] { + case RoleMember: + r = mb.MSPRole_MEMBER + case RoleAdmin: + r = mb.MSPRole_ADMIN + case RoleClient: + r = mb.MSPRole_CLIENT + case RolePeer: + r = mb.MSPRole_PEER + case RoleOrderer: + r = mb.MSPRole_ORDERER + default: + return nil, fmt.Errorf("error parsing role %s", t) + } + + /* build the principal we've been told */ + mspRole, err := proto.Marshal(&mb.MSPRole{MspIdentifier: subm[0][1], Role: r}) + if err != nil { + return nil, fmt.Errorf("error marshalling msp role: %s", err) + } + + p := &mb.MSPPrincipal{ + PrincipalClassification: mb.MSPPrincipal_ROLE, + Principal: mspRole, + } + ctx.principals = append(ctx.principals, p) + + /* create a SignaturePolicy that requires a signature from + the principal we've just built*/ + dapolicy := SignedBy(int32(ctx.IDNum)) + policies = append(policies, dapolicy) + + /* increment the identity counter. Note that this is + suboptimal as we are not reusing identities. We + can deduplicate them easily and make this puppy + smaller. For now it's fine though */ + // TODO: deduplicate principals + ctx.IDNum++ + + /* if we've already got a policy we're good, just append it */ + case *cb.SignaturePolicy: + policies = append(policies, t) + + default: + return nil, fmt.Errorf("unrecognized type, expected a principal or a policy, got %s", reflect.TypeOf(principal)) + } + } + + return NOutOf(int32(t), policies), nil +} + +type context struct { + IDNum int + principals []*mb.MSPPrincipal +} + +func newContext() *context { + return &context{IDNum: 0, principals: make([]*mb.MSPPrincipal, 0)} +} + +// FromString takes a string representation of the policy, +// parses it and returns a SignaturePolicyEnvelope that +// implements that policy. The supported language is as follows: +// +// GATE(P[, P]) +// +// where: +// - GATE is either "and" or "or" +// - P is either a principal or another nested call to GATE +// +// A principal is defined as: +// +// ORG.ROLE +// +// where: +// - ORG is a string (representing the MSP identifier) +// - ROLE takes the value of any of the RoleXXX constants representing +// the required role +func FromString(policy string) (*cb.SignaturePolicyEnvelope, error) { + // first we translate the and/or business into outof gates + intermediate, err := govaluate.NewEvaluableExpressionWithFunctions( + policy, map[string]govaluate.ExpressionFunction{ + GateAnd: and, + strings.ToLower(GateAnd): and, + strings.ToUpper(GateAnd): and, + GateOr: or, + strings.ToLower(GateOr): or, + strings.ToUpper(GateOr): or, + GateOutOf: outof, + strings.ToLower(GateOutOf): outof, + strings.ToUpper(GateOutOf): outof, + }, + ) + if err != nil { + return nil, err + } + + intermediateRes, err := intermediate.Evaluate(map[string]interface{}{}) + if err != nil { + // attempt to produce a meaningful error + if regexErr.MatchString(err.Error()) { + sm := regexErr.FindStringSubmatch(err.Error()) + if len(sm) == 2 { + return nil, fmt.Errorf("unrecognized token '%s' in policy string", sm[1]) + } + } + + return nil, err + } + + resStr, ok := intermediateRes.(string) + if !ok { + return nil, fmt.Errorf("invalid policy string '%s'", policy) + } + + // we still need two passes. The first pass just adds an extra + // argument ID to each of the outof calls. This is + // required because govaluate has no means of giving context + // to user-implemented functions other than via arguments. + // We need this argument because we need a global place where + // we put the identities that the policy requires + exp, err := govaluate.NewEvaluableExpressionWithFunctions( + resStr, + map[string]govaluate.ExpressionFunction{"outof": firstPass}, + ) + if err != nil { + return nil, err + } + + res, err := exp.Evaluate(map[string]interface{}{}) + if err != nil { + // attempt to produce a meaningful error + if regexErr.MatchString(err.Error()) { + sm := regexErr.FindStringSubmatch(err.Error()) + if len(sm) == 2 { + return nil, fmt.Errorf("unrecognized token '%s' in policy string", sm[1]) + } + } + + return nil, err + } + + resStr, ok = res.(string) + if !ok { + return nil, fmt.Errorf("invalid policy string '%s'", policy) + } + + ctx := newContext() + parameters := make(map[string]interface{}, 1) + parameters["ID"] = ctx + + exp, err = govaluate.NewEvaluableExpressionWithFunctions( + resStr, + map[string]govaluate.ExpressionFunction{"outof": secondPass}, + ) + if err != nil { + return nil, err + } + + res, err = exp.Evaluate(parameters) + if err != nil { + // attempt to produce a meaningful error + if regexErr.MatchString(err.Error()) { + sm := regexErr.FindStringSubmatch(err.Error()) + if len(sm) == 2 { + return nil, fmt.Errorf("unrecognized token '%s' in policy string", sm[1]) + } + } + + return nil, err + } + + rule, ok := res.(*cb.SignaturePolicy) + if !ok { + return nil, fmt.Errorf("invalid policy string '%s'", policy) + } + + p := &cb.SignaturePolicyEnvelope{ + Identities: ctx.principals, + Version: 0, + Rule: rule, + } + + return p, nil +} diff --git a/internal/github.com/hyperledger/fabric/common/util/utils.go b/internal/github.com/hyperledger/fabric/common/util/utils.go new file mode 100644 index 00000000..0ae4ece4 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/common/util/utils.go @@ -0,0 +1,97 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package util + +import ( + "crypto/rand" + + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/cryptosuitebridge" + + "fmt" + "io" + "time" + + "github.com/golang/protobuf/ptypes/timestamp" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/bccsp" +) + +// ComputeSHA256 returns SHA2-256 on data +func ComputeSHA256(data []byte) (hash []byte) { + hash, err := cryptosuitebridge.GetDefault().Hash(data, cryptosuitebridge.GetSHA256Opts()) + if err != nil { + panic(fmt.Errorf("Failed computing SHA256 on [% x]", data)) + } + return +} + +// ComputeSHA3256 returns SHA3-256 on data +func ComputeSHA3256(data []byte) (hash []byte) { + hash, err := cryptosuitebridge.GetDefault().Hash(data, &bccsp.SHA3_256Opts{}) + if err != nil { + panic(fmt.Errorf("Failed computing SHA3_256 on [% x]", data)) + } + return +} + +// GenerateBytesUUID returns a UUID based on RFC 4122 returning the generated bytes +func GenerateBytesUUID() []byte { + uuid := make([]byte, 16) + _, err := io.ReadFull(rand.Reader, uuid) + if err != nil { + panic(fmt.Sprintf("Error generating UUID: %s", err)) + } + + // variant bits; see section 4.1.1 + uuid[8] = uuid[8]&^0xc0 | 0x80 + + // version 4 (pseudo-random); see section 4.1.3 + uuid[6] = uuid[6]&^0xf0 | 0x40 + + return uuid +} + +// GenerateUUID returns a UUID based on RFC 4122 +func GenerateUUID() string { + uuid := GenerateBytesUUID() + return idBytesToStr(uuid) +} + +// CreateUtcTimestamp returns a google/protobuf/Timestamp in UTC +func CreateUtcTimestamp() *timestamp.Timestamp { + now := time.Now().UTC() + secs := now.Unix() + nanos := int32(now.UnixNano() - (secs * 1000000000)) + return &(timestamp.Timestamp{Seconds: secs, Nanos: nanos}) +} + +func idBytesToStr(id []byte) string { + return fmt.Sprintf("%x-%x-%x-%x-%x", id[0:4], id[4:6], id[6:8], id[8:10], id[10:]) +} + +const testchainid = "testchainid" + +// ConcatenateBytes is useful for combining multiple arrays of bytes, especially for +// signatures or digests over multiple fields +func ConcatenateBytes(data ...[]byte) []byte { + finalLength := 0 + for _, slice := range data { + finalLength += len(slice) + } + result := make([]byte, finalLength) + last := 0 + for _, slice := range data { + for i := range slice { + result[i+last] = slice[i] + } + last += len(slice) + } + return result +} diff --git a/internal/github.com/hyperledger/fabric/msp/cache/cache.go b/internal/github.com/hyperledger/fabric/msp/cache/cache.go new file mode 100644 index 00000000..4c7d6b46 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/msp/cache/cache.go @@ -0,0 +1,58 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package cache + +import ( + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/msp" + flogging "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/logbridge" + "github.com/pkg/errors" +) + +const ( + deserializeIdentityCacheSize = 100 + validateIdentityCacheSize = 100 + satisfiesPrincipalCacheSize = 100 +) + +var mspLogger = flogging.MustGetLogger("msp") + +func New(o msp.MSP) (msp.MSP, error) { + mspLogger.Debugf("Creating Cache-MSP instance") + if o == nil { + return nil, errors.Errorf("Invalid passed MSP. It must be different from nil.") + } + + theMsp := &cachedMSP{MSP: o} + theMsp.deserializeIdentityCache = newSecondChanceCache(deserializeIdentityCacheSize) + theMsp.satisfiesPrincipalCache = newSecondChanceCache(satisfiesPrincipalCacheSize) + theMsp.validateIdentityCache = newSecondChanceCache(validateIdentityCacheSize) + + return theMsp, nil +} + +type cachedMSP struct { + msp.MSP + + // cache for DeserializeIdentity. + deserializeIdentityCache *secondChanceCache + + // cache for validateIdentity + validateIdentityCache *secondChanceCache + + // basically a map of principals=>identities=>stringified to booleans + // specifying whether this identity satisfies this principal + satisfiesPrincipalCache *secondChanceCache +} + +type cachedIdentity struct { + msp.Identity + cache *cachedMSP +} diff --git a/internal/github.com/hyperledger/fabric/msp/cache/second_chance.go b/internal/github.com/hyperledger/fabric/msp/cache/second_chance.go new file mode 100644 index 00000000..d42c4a9b --- /dev/null +++ b/internal/github.com/hyperledger/fabric/msp/cache/second_chance.go @@ -0,0 +1,117 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package cache + +import ( + "sync" + "sync/atomic" +) + +// This package implements Second-Chance Algorithm, an approximate LRU algorithms. +// https://www.cs.jhu.edu/~yairamir/cs418/os6/tsld023.htm + +// secondChanceCache holds key-value items with a limited size. +// When the number cached items exceeds the limit, victims are selected based on the +// Second-Chance Algorithm and get purged +type secondChanceCache struct { + // manages mapping between keys and items + table map[string]*cacheItem + + // holds a list of cached items. + items []*cacheItem + + // indicates the next candidate of a victim in the items list + position int + + // read lock for get, and write lock for add + rwlock sync.RWMutex +} + +type cacheItem struct { + key string + value interface{} + // set to 1 when get() is called. set to 0 when victim scan + referenced int32 +} + +func newSecondChanceCache(cacheSize int) *secondChanceCache { + var cache secondChanceCache + cache.position = 0 + cache.items = make([]*cacheItem, cacheSize) + cache.table = make(map[string]*cacheItem) + + return &cache +} + +func (cache *secondChanceCache) len() int { + cache.rwlock.RLock() + defer cache.rwlock.RUnlock() + + return len(cache.table) +} + +func (cache *secondChanceCache) get(key string) (interface{}, bool) { + cache.rwlock.RLock() + defer cache.rwlock.RUnlock() + + item, ok := cache.table[key] + if !ok { + return nil, false + } + + // referenced bit is set to true to indicate that this item is recently accessed. + atomic.StoreInt32(&item.referenced, 1) + + return item.value, true +} + +func (cache *secondChanceCache) add(key string, value interface{}) { + cache.rwlock.Lock() + defer cache.rwlock.Unlock() + + if old, ok := cache.table[key]; ok { + old.value = value + atomic.StoreInt32(&old.referenced, 1) + return + } + + var item cacheItem + item.key = key + item.value = value + + size := len(cache.items) + num := len(cache.table) + if num < size { + // cache is not full, so just store the new item at the end of the list + cache.table[key] = &item + cache.items[num] = &item + return + } + + // starts victim scan since cache is full + for { + // checks whether this item is recently accessed or not + victim := cache.items[cache.position] + if atomic.LoadInt32(&victim.referenced) == 0 { + // a victim is found. delete it, and store the new item here. + delete(cache.table, victim.key) + cache.table[key] = &item + cache.items[cache.position] = &item + cache.position = (cache.position + 1) % size + return + } + + // referenced bit is set to false so that this item will be get purged + // unless it is accessed until a next victim scan + atomic.StoreInt32(&victim.referenced, 0) + cache.position = (cache.position + 1) % size + } +} diff --git a/internal/github.com/hyperledger/fabric/msp/cert.go b/internal/github.com/hyperledger/fabric/msp/cert.go new file mode 100644 index 00000000..ffac50a0 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/msp/cert.go @@ -0,0 +1,154 @@ +/* +Copyright IBM Corp. 2017 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. +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package msp + +import ( + "bytes" + "crypto/ecdsa" + "crypto/x509" + "crypto/x509/pkix" + "encoding/asn1" + "encoding/pem" + "fmt" + "math/big" + "time" + + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/bccsp/utils" + "github.com/pkg/errors" +) + +type validity struct { + NotBefore, NotAfter time.Time +} + +type publicKeyInfo struct { + Raw asn1.RawContent + Algorithm pkix.AlgorithmIdentifier + PublicKey asn1.BitString +} + +type certificate struct { + Raw asn1.RawContent + TBSCertificate tbsCertificate + SignatureAlgorithm pkix.AlgorithmIdentifier + SignatureValue asn1.BitString +} + +type tbsCertificate struct { + Raw asn1.RawContent + Version int `asn1:"optional,explicit,default:0,tag:0"` + SerialNumber *big.Int + SignatureAlgorithm pkix.AlgorithmIdentifier + Issuer asn1.RawValue + Validity validity + Subject asn1.RawValue + PublicKey publicKeyInfo + UniqueId asn1.BitString `asn1:"optional,tag:1"` + SubjectUniqueId asn1.BitString `asn1:"optional,tag:2"` + Extensions []pkix.Extension `asn1:"optional,explicit,tag:3"` +} + +func isECDSASignedCert(cert *x509.Certificate) bool { + return cert.SignatureAlgorithm == x509.ECDSAWithSHA1 || + cert.SignatureAlgorithm == x509.ECDSAWithSHA256 || + cert.SignatureAlgorithm == x509.ECDSAWithSHA384 || + cert.SignatureAlgorithm == x509.ECDSAWithSHA512 +} + +// sanitizeECDSASignedCert checks that the signatures signing a cert +// is in low-S. This is checked against the public key of parentCert. +// If the signature is not in low-S, then a new certificate is generated +// that is equals to cert but the signature that is in low-S. +func sanitizeECDSASignedCert(cert *x509.Certificate, parentCert *x509.Certificate) (*x509.Certificate, error) { + if cert == nil { + return nil, errors.New("certificate must be different from nil") + } + if parentCert == nil { + return nil, errors.New("parent certificate must be different from nil") + } + + expectedSig, err := utils.SignatureToLowS(parentCert.PublicKey.(*ecdsa.PublicKey), cert.Signature) + if err != nil { + return nil, err + } + + // if sig == cert.Signature, nothing needs to be done + if bytes.Equal(cert.Signature, expectedSig) { + return cert, nil + } + // otherwise create a new certificate with the new signature + + // 1. Unmarshal cert.Raw to get an instance of certificate, + // the lower level interface that represent an x509 certificate + // encoding + var newCert certificate + newCert, err = certFromX509Cert(cert) + if err != nil { + return nil, err + } + + // 2. Change the signature + newCert.SignatureValue = asn1.BitString{Bytes: expectedSig, BitLength: len(expectedSig) * 8} + + // 3. marshal again newCert. Raw must be nil + newCert.Raw = nil + newRaw, err := asn1.Marshal(newCert) + if err != nil { + return nil, errors.Wrap(err, "marshalling of the certificate failed") + } + + // 4. parse newRaw to get an x509 certificate + return x509.ParseCertificate(newRaw) +} + +func certFromX509Cert(cert *x509.Certificate) (certificate, error) { + var newCert certificate + _, err := asn1.Unmarshal(cert.Raw, &newCert) + if err != nil { + return certificate{}, errors.Wrap(err, "unmarshalling of the certificate failed") + } + return newCert, nil +} + +// String returns a PEM representation of a certificate +func (c certificate) String() string { + b, err := asn1.Marshal(c) + if err != nil { + return fmt.Sprintf("Failed marshaling cert: %v", err) + } + block := &pem.Block{ + Bytes: b, + Type: "CERTIFICATE", + } + b = pem.EncodeToMemory(block) + return string(b) +} + +// certToPEM converts the given x509.Certificate to a PEM +// encoded string +func certToPEM(certificate *x509.Certificate) string { + cert, err := certFromX509Cert(certificate) + if err != nil { + mspIdentityLogger.Warning("Failed converting certificate to asn1", err) + return "" + } + return cert.String() +} diff --git a/internal/github.com/hyperledger/fabric/msp/configbuilder.go b/internal/github.com/hyperledger/fabric/msp/configbuilder.go new file mode 100644 index 00000000..4b70adf2 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/msp/configbuilder.go @@ -0,0 +1,329 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package msp + +import ( + "encoding/pem" + "io/ioutil" + "os" + "path/filepath" + + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-protos-go/msp" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/bccsp" + "github.com/pkg/errors" + "gopkg.in/yaml.v2" +) + +// OrganizationalUnitIdentifiersConfiguration is used to represent an OU +// and an associated trusted certificate +type OrganizationalUnitIdentifiersConfiguration struct { + // Certificate is the path to a root or intermediate certificate + Certificate string `yaml:"Certificate,omitempty"` + // OrganizationalUnitIdentifier is the name of the OU + OrganizationalUnitIdentifier string `yaml:"OrganizationalUnitIdentifier,omitempty"` +} + +// NodeOUs contains information on how to tell apart clients, peers and orderers +// based on OUs. If the check is enforced, by setting Enabled to true, +// the MSP will consider an identity valid if it is an identity of a client, a peer or +// an orderer. An identity should have only one of these special OUs. +type NodeOUs struct { + // Enable activates the OU enforcement + Enable bool `yaml:"Enable,omitempty"` + // ClientOUIdentifier specifies how to recognize clients by OU + ClientOUIdentifier *OrganizationalUnitIdentifiersConfiguration `yaml:"ClientOUIdentifier,omitempty"` + // PeerOUIdentifier specifies how to recognize peers by OU + PeerOUIdentifier *OrganizationalUnitIdentifiersConfiguration `yaml:"PeerOUIdentifier,omitempty"` + // AdminOUIdentifier specifies how to recognize admins by OU + AdminOUIdentifier *OrganizationalUnitIdentifiersConfiguration `yaml:"AdminOUIdentifier,omitempty"` + // OrdererOUIdentifier specifies how to recognize admins by OU + OrdererOUIdentifier *OrganizationalUnitIdentifiersConfiguration `yaml:"OrdererOUIdentifier,omitempty"` +} + +// Configuration represents the accessory configuration an MSP can be equipped with. +// By default, this configuration is stored in a yaml file +type Configuration struct { + // OrganizationalUnitIdentifiers is a list of OUs. If this is set, the MSP + // will consider an identity valid only it contains at least one of these OUs + OrganizationalUnitIdentifiers []*OrganizationalUnitIdentifiersConfiguration `yaml:"OrganizationalUnitIdentifiers,omitempty"` + // NodeOUs enables the MSP to tell apart clients, peers and orderers based + // on the identity's OU. + NodeOUs *NodeOUs `yaml:"NodeOUs,omitempty"` +} + +func readFile(file string) ([]byte, error) { + fileCont, err := ioutil.ReadFile(file) + if err != nil { + return nil, errors.Wrapf(err, "could not read file %s", file) + } + + return fileCont, nil +} + +func readPemFile(file string) ([]byte, error) { + bytes, err := readFile(file) + if err != nil { + return nil, errors.Wrapf(err, "reading from file %s failed", file) + } + + b, _ := pem.Decode(bytes) + if b == nil { // TODO: also check that the type is what we expect (cert vs key..) + return nil, errors.Errorf("no pem content for file %s", file) + } + + return bytes, nil +} + +func getPemMaterialFromDir(dir string) ([][]byte, error) { + mspLogger.Debugf("Reading directory %s", dir) + + _, err := os.Stat(dir) + if os.IsNotExist(err) { + return nil, err + } + + content := make([][]byte, 0) + files, err := ioutil.ReadDir(dir) + if err != nil { + return nil, errors.Wrapf(err, "could not read directory %s", dir) + } + + for _, f := range files { + fullName := filepath.Join(dir, f.Name()) + + f, err := os.Stat(fullName) + if err != nil { + mspLogger.Warningf("Failed to stat %s: %s", fullName, err) + continue + } + if f.IsDir() { + continue + } + + mspLogger.Debugf("Inspecting file %s", fullName) + + item, err := readPemFile(fullName) + if err != nil { + mspLogger.Warningf("Failed reading file %s: %s", fullName, err) + continue + } + + content = append(content, item) + } + + return content, nil +} + +const ( + cacerts = "cacerts" + admincerts = "admincerts" + signcerts = "signcerts" + keystore = "keystore" + intermediatecerts = "intermediatecerts" + crlsfolder = "crls" + configfilename = "config.yaml" + tlscacerts = "tlscacerts" + tlsintermediatecerts = "tlsintermediatecerts" +) + +// GetVerifyingMspConfig returns an MSP config given directory, ID and type +func GetVerifyingMspConfig(dir, ID, mspType string) (*msp.MSPConfig, error) { + switch mspType { + case ProviderTypeToString(FABRIC): + return getMspConfig(dir, ID, nil) + default: + return nil, errors.Errorf("unknown MSP type '%s'", mspType) + } +} + +func getMspConfig(dir string, ID string, sigid *msp.SigningIdentityInfo) (*msp.MSPConfig, error) { + cacertDir := filepath.Join(dir, cacerts) + admincertDir := filepath.Join(dir, admincerts) + intermediatecertsDir := filepath.Join(dir, intermediatecerts) + crlsDir := filepath.Join(dir, crlsfolder) + configFile := filepath.Join(dir, configfilename) + tlscacertDir := filepath.Join(dir, tlscacerts) + tlsintermediatecertsDir := filepath.Join(dir, tlsintermediatecerts) + + cacerts, err := getPemMaterialFromDir(cacertDir) + if err != nil || len(cacerts) == 0 { + return nil, errors.WithMessagef(err, "could not load a valid ca certificate from directory %s", cacertDir) + } + + admincert, err := getPemMaterialFromDir(admincertDir) + if err != nil && !os.IsNotExist(err) { + return nil, errors.WithMessagef(err, "could not load a valid admin certificate from directory %s", admincertDir) + } + + intermediatecerts, err := getPemMaterialFromDir(intermediatecertsDir) + if os.IsNotExist(err) { + mspLogger.Debugf("Intermediate certs folder not found at [%s]. Skipping. [%s]", intermediatecertsDir, err) + } else if err != nil { + return nil, errors.WithMessagef(err, "failed loading intermediate ca certs at [%s]", intermediatecertsDir) + } + + tlsCACerts, err := getPemMaterialFromDir(tlscacertDir) + tlsIntermediateCerts := [][]byte{} + if os.IsNotExist(err) { + mspLogger.Debugf("TLS CA certs folder not found at [%s]. Skipping and ignoring TLS intermediate CA folder. [%s]", tlsintermediatecertsDir, err) + } else if err != nil { + return nil, errors.WithMessagef(err, "failed loading TLS ca certs at [%s]", tlsintermediatecertsDir) + } else if len(tlsCACerts) != 0 { + tlsIntermediateCerts, err = getPemMaterialFromDir(tlsintermediatecertsDir) + if os.IsNotExist(err) { + mspLogger.Debugf("TLS intermediate certs folder not found at [%s]. Skipping. [%s]", tlsintermediatecertsDir, err) + } else if err != nil { + return nil, errors.WithMessagef(err, "failed loading TLS intermediate ca certs at [%s]", tlsintermediatecertsDir) + } + } else { + mspLogger.Debugf("TLS CA certs folder at [%s] is empty. Skipping.", tlsintermediatecertsDir) + } + + crls, err := getPemMaterialFromDir(crlsDir) + if os.IsNotExist(err) { + mspLogger.Debugf("crls folder not found at [%s]. Skipping. [%s]", crlsDir, err) + } else if err != nil { + return nil, errors.WithMessagef(err, "failed loading crls at [%s]", crlsDir) + } + + // Load configuration file + // if the configuration file is there then load it + // otherwise skip it + var ouis []*msp.FabricOUIdentifier + var nodeOUs *msp.FabricNodeOUs + _, err = os.Stat(configFile) + if err == nil { + // load the file, if there is a failure in loading it then + // return an error + raw, err := ioutil.ReadFile(configFile) + if err != nil { + return nil, errors.Wrapf(err, "failed loading configuration file at [%s]", configFile) + } + + configuration := Configuration{} + err = yaml.Unmarshal(raw, &configuration) + if err != nil { + return nil, errors.Wrapf(err, "failed unmarshalling configuration file at [%s]", configFile) + } + + // Prepare OrganizationalUnitIdentifiers + if len(configuration.OrganizationalUnitIdentifiers) > 0 { + for _, ouID := range configuration.OrganizationalUnitIdentifiers { + f := filepath.Join(dir, ouID.Certificate) + raw, err = readFile(f) + if err != nil { + return nil, errors.Wrapf(err, "failed loading OrganizationalUnit certificate at [%s]", f) + } + + oui := &msp.FabricOUIdentifier{ + Certificate: raw, + OrganizationalUnitIdentifier: ouID.OrganizationalUnitIdentifier, + } + ouis = append(ouis, oui) + } + } + + // Prepare NodeOUs + if configuration.NodeOUs != nil && configuration.NodeOUs.Enable { + mspLogger.Debug("Loading NodeOUs") + nodeOUs = &msp.FabricNodeOUs{ + Enable: true, + } + if configuration.NodeOUs.ClientOUIdentifier != nil && len(configuration.NodeOUs.ClientOUIdentifier.OrganizationalUnitIdentifier) != 0 { + nodeOUs.ClientOuIdentifier = &msp.FabricOUIdentifier{OrganizationalUnitIdentifier: configuration.NodeOUs.ClientOUIdentifier.OrganizationalUnitIdentifier} + } + if configuration.NodeOUs.PeerOUIdentifier != nil && len(configuration.NodeOUs.PeerOUIdentifier.OrganizationalUnitIdentifier) != 0 { + nodeOUs.PeerOuIdentifier = &msp.FabricOUIdentifier{OrganizationalUnitIdentifier: configuration.NodeOUs.PeerOUIdentifier.OrganizationalUnitIdentifier} + } + if configuration.NodeOUs.AdminOUIdentifier != nil && len(configuration.NodeOUs.AdminOUIdentifier.OrganizationalUnitIdentifier) != 0 { + nodeOUs.AdminOuIdentifier = &msp.FabricOUIdentifier{OrganizationalUnitIdentifier: configuration.NodeOUs.AdminOUIdentifier.OrganizationalUnitIdentifier} + } + if configuration.NodeOUs.OrdererOUIdentifier != nil && len(configuration.NodeOUs.OrdererOUIdentifier.OrganizationalUnitIdentifier) != 0 { + nodeOUs.OrdererOuIdentifier = &msp.FabricOUIdentifier{OrganizationalUnitIdentifier: configuration.NodeOUs.OrdererOUIdentifier.OrganizationalUnitIdentifier} + } + + // Read certificates, if defined + + // ClientOU + if nodeOUs.ClientOuIdentifier != nil { + nodeOUs.ClientOuIdentifier.Certificate = loadCertificateAt(dir, configuration.NodeOUs.ClientOUIdentifier.Certificate, "ClientOU") + } + // PeerOU + if nodeOUs.PeerOuIdentifier != nil { + nodeOUs.PeerOuIdentifier.Certificate = loadCertificateAt(dir, configuration.NodeOUs.PeerOUIdentifier.Certificate, "PeerOU") + } + // AdminOU + if nodeOUs.AdminOuIdentifier != nil { + nodeOUs.AdminOuIdentifier.Certificate = loadCertificateAt(dir, configuration.NodeOUs.AdminOUIdentifier.Certificate, "AdminOU") + } + // OrdererOU + if nodeOUs.OrdererOuIdentifier != nil { + nodeOUs.OrdererOuIdentifier.Certificate = loadCertificateAt(dir, configuration.NodeOUs.OrdererOUIdentifier.Certificate, "OrdererOU") + } + } + } else { + mspLogger.Debugf("MSP configuration file not found at [%s]: [%s]", configFile, err) + } + + // Set FabricCryptoConfig + cryptoConfig := &msp.FabricCryptoConfig{ + SignatureHashFamily: bccsp.SHA2, + IdentityIdentifierHashFunction: bccsp.SHA256, + } + + // Compose FabricMSPConfig + fmspconf := &msp.FabricMSPConfig{ + Admins: admincert, + RootCerts: cacerts, + IntermediateCerts: intermediatecerts, + SigningIdentity: sigid, + Name: ID, + OrganizationalUnitIdentifiers: ouis, + RevocationList: crls, + CryptoConfig: cryptoConfig, + TlsRootCerts: tlsCACerts, + TlsIntermediateCerts: tlsIntermediateCerts, + FabricNodeOus: nodeOUs, + } + + fmpsjs, _ := proto.Marshal(fmspconf) + + mspconf := &msp.MSPConfig{Config: fmpsjs, Type: int32(FABRIC)} + + return mspconf, nil +} + +func loadCertificateAt(dir, certificatePath string, ouType string) []byte { + + if certificatePath == "" { + mspLogger.Debugf("Specific certificate for %s is not configured", ouType) + return nil + } + + f := filepath.Join(dir, certificatePath) + raw, err := readFile(f) + if err != nil { + mspLogger.Warnf("Failed loading %s certificate at [%s]: [%s]", ouType, f, err) + } else { + return raw + } + + return nil +} + +const ( + IdemixConfigDirMsp = "msp" + IdemixConfigDirUser = "user" + IdemixConfigFileIssuerPublicKey = "IssuerPublicKey" + IdemixConfigFileRevocationPublicKey = "RevocationPublicKey" + IdemixConfigFileSigner = "SignerConfig" +) diff --git a/internal/github.com/hyperledger/fabric/msp/factory.go b/internal/github.com/hyperledger/fabric/msp/factory.go new file mode 100644 index 00000000..734b9fd9 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/msp/factory.go @@ -0,0 +1,71 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package msp + +import ( + "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core" + "github.com/pkg/errors" +) + +type MSPVersion int + +const ( + MSPv1_0 = iota + MSPv1_1 + MSPv1_3 + MSPv1_4_3 +) + +// NewOpts represent +type NewOpts interface { + // GetVersion returns the MSP's version to be instantiated + GetVersion() MSPVersion +} + +// NewBaseOpts is the default base type for all MSP instantiation Opts +type NewBaseOpts struct { + Version MSPVersion +} + +func (o *NewBaseOpts) GetVersion() MSPVersion { + return o.Version +} + +// BCCSPNewOpts contains the options to instantiate a new BCCSP-based (X509) MSP +type BCCSPNewOpts struct { + NewBaseOpts +} + +// IdemixNewOpts contains the options to instantiate a new Idemix-based MSP +type IdemixNewOpts struct { + NewBaseOpts +} + +// New create a new MSP instance depending on the passed Opts +func New(opts NewOpts, cryptoProvider core.CryptoSuite) (MSP, error) { + switch opts.(type) { + case *BCCSPNewOpts: + switch opts.GetVersion() { + case MSPv1_0: + return newBccspMsp(MSPv1_0, cryptoProvider) + case MSPv1_1: + return newBccspMsp(MSPv1_1, cryptoProvider) + case MSPv1_3: + return newBccspMsp(MSPv1_3, cryptoProvider) + case MSPv1_4_3: + return newBccspMsp(MSPv1_4_3, cryptoProvider) + default: + return nil, errors.Errorf("Invalid *BCCSPNewOpts. Version not recognized [%v]", opts.GetVersion()) + } + default: + return nil, errors.Errorf("Invalid msp.NewOpts instance. It must be either *BCCSPNewOpts or *IdemixNewOpts. It was [%v]", opts) + } +} diff --git a/internal/github.com/hyperledger/fabric/msp/identities.go b/internal/github.com/hyperledger/fabric/msp/identities.go new file mode 100644 index 00000000..855f658e --- /dev/null +++ b/internal/github.com/hyperledger/fabric/msp/identities.go @@ -0,0 +1,273 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package msp + +import ( + "crypto" + "crypto/rand" + "crypto/x509" + "encoding/hex" + + "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core" + + "encoding/pem" + "fmt" + "sync" + "time" + + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-protos-go/msp" + bccsp "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/cryptosuitebridge" + flogging "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/logbridge" + logging "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/logbridge" + "github.com/pkg/errors" +) + +var mspIdentityLogger = flogging.MustGetLogger("msp.identity") + +type identity struct { + // id contains the identifier (MSPID and identity identifier) for this instance + id *IdentityIdentifier + + // cert contains the x.509 certificate that signs the public key of this instance + cert *x509.Certificate + + // this is the public key of this instance + pk core.Key + + // reference to the MSP that "owns" this identity + msp *bccspmsp + + // validationMutex is used to synchronise memory operation + // over validated and validationErr + validationMutex sync.Mutex + + // validated is true when the validateIdentity function + // has been called on this instance + validated bool + + // validationErr contains the validation error for this + // instance. It can be read if validated is true + validationErr error +} + +func newIdentity(cert *x509.Certificate, pk core.Key, msp *bccspmsp) (Identity, error) { + if mspIdentityLogger.IsEnabledFor(logging.DEBUG) { + mspIdentityLogger.Debugf("Creating identity instance for cert %s", certToPEM(cert)) + } + + // Sanitize first the certificate + cert, err := msp.sanitizeCert(cert) + if err != nil { + return nil, err + } + + // Compute identity identifier + + // Use the hash of the identity's certificate as id in the IdentityIdentifier + hashOpt, err := bccsp.GetHashOpt(msp.cryptoConfig.IdentityIdentifierHashFunction) + if err != nil { + return nil, errors.WithMessage(err, "failed getting hash function options") + } + + digest, err := msp.bccsp.Hash(cert.Raw, hashOpt) + if err != nil { + return nil, errors.WithMessage(err, "failed hashing raw certificate to compute the id of the IdentityIdentifier") + } + + id := &IdentityIdentifier{ + Mspid: msp.name, + Id: hex.EncodeToString(digest)} + + return &identity{id: id, cert: cert, pk: pk, msp: msp}, nil +} + +// ExpiresAt returns the time at which the Identity expires. +func (id *identity) ExpiresAt() time.Time { + return id.cert.NotAfter +} + +// SatisfiesPrincipal returns nil if this instance matches the supplied principal or an error otherwise +func (id *identity) SatisfiesPrincipal(principal *msp.MSPPrincipal) error { + return id.msp.SatisfiesPrincipal(id, principal) +} + +// GetIdentifier returns the identifier (MSPID/IDID) for this instance +func (id *identity) GetIdentifier() *IdentityIdentifier { + return id.id +} + +// GetMSPIdentifier returns the MSP identifier for this instance +func (id *identity) GetMSPIdentifier() string { + return id.id.Mspid +} + +// Validate returns nil if this instance is a valid identity or an error otherwise +func (id *identity) Validate() error { + return id.msp.Validate(id) +} + +type OUIDs []*OUIdentifier + +func (o OUIDs) String() string { + var res []string + for _, id := range o { + res = append(res, fmt.Sprintf("%s(%X)", id.OrganizationalUnitIdentifier, id.CertifiersIdentifier[0:8])) + } + + return fmt.Sprintf("%s", res) +} + +// GetOrganizationalUnits returns the OU for this instance +func (id *identity) GetOrganizationalUnits() []*OUIdentifier { + if id.cert == nil { + return nil + } + + cid, err := id.msp.getCertificationChainIdentifier(id) + if err != nil { + mspIdentityLogger.Errorf("Failed getting certification chain identifier for [%v]: [%+v]", id, err) + + return nil + } + + var res []*OUIdentifier + for _, unit := range id.cert.Subject.OrganizationalUnit { + res = append(res, &OUIdentifier{ + OrganizationalUnitIdentifier: unit, + CertifiersIdentifier: cid, + }) + } + + return res +} + +// Anonymous returns true if this identity provides anonymity +func (id *identity) Anonymous() bool { + return false +} + +// Verify checks against a signature and a message +// to determine whether this identity produced the +// signature; it returns nil if so or an error otherwise +func (id *identity) Verify(msg []byte, sig []byte) error { + // mspIdentityLogger.Infof("Verifying signature") + + // Compute Hash + hashOpt, err := id.getHashOpt(id.msp.cryptoConfig.SignatureHashFamily) + if err != nil { + return errors.WithMessage(err, "failed getting hash function options") + } + + digest, err := id.msp.bccsp.Hash(msg, hashOpt) + if err != nil { + return errors.WithMessage(err, "failed computing digest") + } + + if mspIdentityLogger.IsEnabledFor(logging.DEBUG) { + mspIdentityLogger.Debugf("Verify: digest = %s", hex.Dump(digest)) + mspIdentityLogger.Debugf("Verify: sig = %s", hex.Dump(sig)) + } + + valid, err := id.msp.bccsp.Verify(id.pk, sig, digest, nil) + if err != nil { + return errors.WithMessage(err, "could not determine the validity of the signature") + } else if !valid { + return errors.New("The signature is invalid") + } + + return nil +} + +// Serialize returns a byte array representation of this identity +func (id *identity) Serialize() ([]byte, error) { + pb := &pem.Block{Bytes: id.cert.Raw, Type: "CERTIFICATE"} + pemBytes := pem.EncodeToMemory(pb) + if pemBytes == nil { + return nil, errors.New("encoding of identity failed") + } + + // We serialize identities by prepending the MSPID and appending the ASN.1 DER content of the cert + sId := &msp.SerializedIdentity{Mspid: id.id.Mspid, IdBytes: pemBytes} + idBytes, err := proto.Marshal(sId) + if err != nil { + return nil, errors.Wrapf(err, "could not marshal a SerializedIdentity structure for identity %s", id.id) + } + + return idBytes, nil +} + +func (id *identity) getHashOpt(hashFamily string) (core.HashOpts, error) { + switch hashFamily { + case bccsp.SHA2: + return bccsp.GetHashOpt(bccsp.SHA256) + case bccsp.SHA3: + return bccsp.GetHashOpt(bccsp.SHA3_256) + } + return nil, errors.Errorf("hash familiy not recognized [%s]", hashFamily) +} + +type signingidentity struct { + // we embed everything from a base identity + identity + + // signer corresponds to the object that can produce signatures from this identity + signer crypto.Signer +} + +func newSigningIdentity(cert *x509.Certificate, pk core.Key, signer crypto.Signer, msp *bccspmsp) (SigningIdentity, error) { + //mspIdentityLogger.Infof("Creating signing identity instance for ID %s", id) + mspId, err := newIdentity(cert, pk, msp) + if err != nil { + return nil, err + } + return &signingidentity{ + identity: identity{ + id: mspId.(*identity).id, + cert: mspId.(*identity).cert, + msp: mspId.(*identity).msp, + pk: mspId.(*identity).pk, + }, + signer: signer, + }, nil +} + +// Sign produces a signature over msg, signed by this instance +func (id *signingidentity) Sign(msg []byte) ([]byte, error) { + //mspIdentityLogger.Infof("Signing message") + + // Compute Hash + hashOpt, err := id.getHashOpt(id.msp.cryptoConfig.SignatureHashFamily) + if err != nil { + return nil, errors.WithMessage(err, "failed getting hash function options") + } + + digest, err := id.msp.bccsp.Hash(msg, hashOpt) + if err != nil { + return nil, errors.WithMessage(err, "failed computing digest") + } + + if len(msg) < 32 { + mspIdentityLogger.Debugf("Sign: plaintext: %X \n", msg) + } else { + mspIdentityLogger.Debugf("Sign: plaintext: %X...%X \n", msg[0:16], msg[len(msg)-16:]) + } + mspIdentityLogger.Debugf("Sign: digest: %X \n", digest) + + // Sign + return id.signer.Sign(rand.Reader, digest, nil) +} + +// GetPublicVersion returns the public version of this identity, +// namely, the one that is only able to verify messages and not sign them +func (id *signingidentity) GetPublicVersion() Identity { + return &id.identity +} diff --git a/internal/github.com/hyperledger/fabric/msp/msp.go b/internal/github.com/hyperledger/fabric/msp/msp.go new file mode 100644 index 00000000..c1c9f836 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/msp/msp.go @@ -0,0 +1,230 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package msp + +import ( + "time" + + "github.com/hyperledger/fabric-protos-go/msp" +) + +// IdentityDeserializer is implemented by both MSPManger and MSP +type IdentityDeserializer interface { + // DeserializeIdentity deserializes an identity. + // Deserialization will fail if the identity is associated to + // an msp that is different from this one that is performing + // the deserialization. + DeserializeIdentity(serializedIdentity []byte) (Identity, error) + + // IsWellFormed checks if the given identity can be deserialized into its provider-specific form + IsWellFormed(identity *msp.SerializedIdentity) error +} + +// Membership service provider APIs for Hyperledger Fabric: +// +// By "membership service provider" we refer to an abstract component of the +// system that would provide (anonymous) credentials to clients, and peers for +// them to participate in Hyperledger/fabric network. Clients use these +// credentials to authenticate their transactions, and peers use these credentials +// to authenticate transaction processing results (endorsements). While +// strongly connected to the transaction processing components of the systems, +// this interface aims to have membership services components defined, in such +// a way such that alternate implementations of this can be smoothly plugged in +// without modifying the core of transaction processing components of the system. +// +// This file includes Membership service provider interface that covers the +// needs of a peer membership service provider interface. + +// MSPManager is an interface defining a manager of one or more MSPs. This +// essentially acts as a mediator to MSP calls and routes MSP related calls +// to the appropriate MSP. +// This object is immutable, it is initialized once and never changed. +type MSPManager interface { + + // IdentityDeserializer interface needs to be implemented by MSPManager + IdentityDeserializer + + // Setup the MSP manager instance according to configuration information + Setup(msps []MSP) error + + // GetMSPs Provides a list of Membership Service providers + GetMSPs() (map[string]MSP, error) +} + +// MSP is the minimal Membership Service Provider Interface to be implemented +// to accommodate peer functionality +type MSP interface { + + // IdentityDeserializer interface needs to be implemented by MSP + IdentityDeserializer + + // Setup the MSP instance according to configuration information + Setup(config *msp.MSPConfig) error + + // GetVersion returns the version of this MSP + GetVersion() MSPVersion + + // GetType returns the provider type + GetType() ProviderType + + // GetIdentifier returns the provider identifier + GetIdentifier() (string, error) + + // GetSigningIdentity returns a signing identity corresponding to the provided identifier + GetSigningIdentity(identifier *IdentityIdentifier) (SigningIdentity, error) + + // GetDefaultSigningIdentity returns the default signing identity + GetDefaultSigningIdentity() (SigningIdentity, error) + + // GetTLSRootCerts returns the TLS root certificates for this MSP + GetTLSRootCerts() [][]byte + + // GetTLSIntermediateCerts returns the TLS intermediate root certificates for this MSP + GetTLSIntermediateCerts() [][]byte + + // Validate checks whether the supplied identity is valid + Validate(id Identity) error + + // SatisfiesPrincipal checks whether the identity matches + // the description supplied in MSPPrincipal. The check may + // involve a byte-by-byte comparison (if the principal is + // a serialized identity) or may require MSP validation + SatisfiesPrincipal(id Identity, principal *msp.MSPPrincipal) error +} + +// OUIdentifier represents an organizational unit and +// its related chain of trust identifier. +type OUIdentifier struct { + // CertifiersIdentifier is the hash of certificates chain of trust + // related to this organizational unit + CertifiersIdentifier []byte + // OrganizationUnitIdentifier defines the organizational unit under the + // MSP identified with MSPIdentifier + OrganizationalUnitIdentifier string +} + +// From this point on, there are interfaces that are shared within the peer and client API +// of the membership service provider. + +// Identity interface defining operations associated to a "certificate". +// That is, the public part of the identity could be thought to be a certificate, +// and offers solely signature verification capabilities. This is to be used +// at the peer side when verifying certificates that transactions are signed +// with, and verifying signatures that correspond to these certificates./// +type Identity interface { + + // ExpiresAt returns the time at which the Identity expires. + // If the returned time is the zero value, it implies + // the Identity does not expire, or that its expiration + // time is unknown + ExpiresAt() time.Time + + // GetIdentifier returns the identifier of that identity + GetIdentifier() *IdentityIdentifier + + // GetMSPIdentifier returns the MSP Id for this instance + GetMSPIdentifier() string + + // Validate uses the rules that govern this identity to validate it. + // E.g., if it is a fabric TCert implemented as identity, validate + // will check the TCert signature against the assumed root certificate + // authority. + Validate() error + + // GetOrganizationalUnits returns zero or more organization units or + // divisions this identity is related to as long as this is public + // information. Certain MSP implementations may use attributes + // that are publicly associated to this identity, or the identifier of + // the root certificate authority that has provided signatures on this + // certificate. + // Examples: + // - if the identity is an x.509 certificate, this function returns one + // or more string which is encoded in the Subject's Distinguished Name + // of the type OU + // TODO: For X.509 based identities, check if we need a dedicated type + // for OU where the Certificate OU is properly namespaced by the + // signer's identity + GetOrganizationalUnits() []*OUIdentifier + + // Anonymous returns true if this is an anonymous identity, false otherwise + Anonymous() bool + + // Verify a signature over some message using this identity as reference + Verify(msg []byte, sig []byte) error + + // Serialize converts an identity to bytes + Serialize() ([]byte, error) + + // SatisfiesPrincipal checks whether this instance matches + // the description supplied in MSPPrincipal. The check may + // involve a byte-by-byte comparison (if the principal is + // a serialized identity) or may require MSP validation + SatisfiesPrincipal(principal *msp.MSPPrincipal) error +} + +// SigningIdentity is an extension of Identity to cover signing capabilities. +// E.g., signing identity should be requested in the case of a client who wishes +// to sign transactions, or fabric endorser who wishes to sign proposal +// processing outcomes. +type SigningIdentity interface { + + // Extends Identity + Identity + + // Sign the message + Sign(msg []byte) ([]byte, error) + + // GetPublicVersion returns the public parts of this identity + GetPublicVersion() Identity +} + +// IdentityIdentifier is a holder for the identifier of a specific +// identity, naturally namespaced, by its provider identifier. +type IdentityIdentifier struct { + + // The identifier of the associated membership service provider + Mspid string + + // The identifier for an identity within a provider + Id string +} + +// ProviderType indicates the type of an identity provider +type ProviderType int + +// The ProviderType of a member relative to the member API +const ( + FABRIC ProviderType = iota // MSP is of FABRIC type + IDEMIX // MSP is of IDEMIX type + OTHER // MSP is of OTHER TYPE + + // NOTE: as new types are added to this set, + // the mspTypes map below must be extended +) + +var mspTypeStrings = map[ProviderType]string{ + FABRIC: "bccsp", + IDEMIX: "idemix", +} + +var Options = map[string]NewOpts{ + ProviderTypeToString(FABRIC): &BCCSPNewOpts{NewBaseOpts: NewBaseOpts{Version: MSPv1_4_3}}, + ProviderTypeToString(IDEMIX): &IdemixNewOpts{NewBaseOpts: NewBaseOpts{Version: MSPv1_1}}, +} + +// ProviderTypeToString returns a string that represents the ProviderType integer +func ProviderTypeToString(id ProviderType) string { + if res, found := mspTypeStrings[id]; found { + return res + } + + return "" +} diff --git a/internal/github.com/hyperledger/fabric/msp/mspimpl.go b/internal/github.com/hyperledger/fabric/msp/mspimpl.go new file mode 100644 index 00000000..1a90b276 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/msp/mspimpl.go @@ -0,0 +1,857 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package msp + +import ( + "bytes" + "crypto/x509" + "crypto/x509/pkix" + "encoding/hex" + "encoding/pem" + + "github.com/golang/protobuf/proto" + m "github.com/hyperledger/fabric-protos-go/msp" + "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/bccsp/utils" + factory "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/cryptosuitebridge" + "github.com/pkg/errors" +) + +// mspSetupFuncType is the prototype of the setup function +type mspSetupFuncType func(config *m.FabricMSPConfig) error + +// validateIdentityOUsFuncType is the prototype of the function to validate identity's OUs +type validateIdentityOUsFuncType func(id *identity) error + +// satisfiesPrincipalInternalFuncType is the prototype of the function to check if principals are satisfied +type satisfiesPrincipalInternalFuncType func(id Identity, principal *m.MSPPrincipal) error + +//setupAdminInternalFuncType is a prototype of the function to setup the admins +type setupAdminInternalFuncType func(conf *m.FabricMSPConfig) error + +// This is an instantiation of an MSP that +// uses BCCSP for its cryptographic primitives. +type bccspmsp struct { + // version specifies the behaviour of this msp + version MSPVersion + // The following function pointers are used to change the behaviour + // of this MSP depending on its version. + // internalSetupFunc is the pointer to the setup function + internalSetupFunc mspSetupFuncType + + // internalValidateIdentityOusFunc is the pointer to the function to validate identity's OUs + internalValidateIdentityOusFunc validateIdentityOUsFuncType + + // internalSatisfiesPrincipalInternalFunc is the pointer to the function to check if principals are satisfied + internalSatisfiesPrincipalInternalFunc satisfiesPrincipalInternalFuncType + + // internalSetupAdmin is the pointer to the function that setup the administrators of this msp + internalSetupAdmin setupAdminInternalFuncType + + // list of CA certs we trust + rootCerts []Identity + + // list of intermediate certs we trust + intermediateCerts []Identity + + // list of CA TLS certs we trust + tlsRootCerts [][]byte + + // list of intermediate TLS certs we trust + tlsIntermediateCerts [][]byte + + // certificationTreeInternalNodesMap whose keys correspond to the raw material + // (DER representation) of a certificate casted to a string, and whose values + // are boolean. True means that the certificate is an internal node of the certification tree. + // False means that the certificate corresponds to a leaf of the certification tree. + certificationTreeInternalNodesMap map[string]bool + + // list of signing identities + signer SigningIdentity + + // list of admin identities + admins []Identity + + // the crypto provider + bccsp core.CryptoSuite + + // the provider identifier for this MSP + name string + + // verification options for MSP members + opts *x509.VerifyOptions + + // list of certificate revocation lists + CRL []*pkix.CertificateList + + // list of OUs + ouIdentifiers map[string][][]byte + + // cryptoConfig contains + cryptoConfig *m.FabricCryptoConfig + + // NodeOUs configuration + ouEnforcement bool + // These are the OUIdentifiers of the clients, peers, admins and orderers. + // They are used to tell apart these entities + clientOU, peerOU, adminOU, ordererOU *OUIdentifier +} + +// newBccspMsp returns an MSP instance backed up by a BCCSP +// crypto provider. It handles x.509 certificates and can +// generate identities and signing identities backed by +// certificates and keypairs +func newBccspMsp(version MSPVersion, defaultBCCSP core.CryptoSuite) (MSP, error) { + mspLogger.Debugf("Creating BCCSP-based MSP instance") + + theMsp := &bccspmsp{} + theMsp.version = version + theMsp.bccsp = defaultBCCSP + switch version { + case MSPv1_0: + theMsp.internalSetupFunc = theMsp.setupV1 + theMsp.internalValidateIdentityOusFunc = theMsp.validateIdentityOUsV1 + theMsp.internalSatisfiesPrincipalInternalFunc = theMsp.satisfiesPrincipalInternalPreV13 + theMsp.internalSetupAdmin = theMsp.setupAdminsPreV142 + case MSPv1_1: + theMsp.internalSetupFunc = theMsp.setupV11 + theMsp.internalValidateIdentityOusFunc = theMsp.validateIdentityOUsV11 + theMsp.internalSatisfiesPrincipalInternalFunc = theMsp.satisfiesPrincipalInternalPreV13 + theMsp.internalSetupAdmin = theMsp.setupAdminsPreV142 + case MSPv1_3: + theMsp.internalSetupFunc = theMsp.setupV11 + theMsp.internalValidateIdentityOusFunc = theMsp.validateIdentityOUsV11 + theMsp.internalSatisfiesPrincipalInternalFunc = theMsp.satisfiesPrincipalInternalV13 + theMsp.internalSetupAdmin = theMsp.setupAdminsPreV142 + case MSPv1_4_3: + theMsp.internalSetupFunc = theMsp.setupV142 + theMsp.internalValidateIdentityOusFunc = theMsp.validateIdentityOUsV142 + theMsp.internalSatisfiesPrincipalInternalFunc = theMsp.satisfiesPrincipalInternalV142 + theMsp.internalSetupAdmin = theMsp.setupAdminsV142 + default: + return nil, errors.Errorf("Invalid MSP version [%v]", version) + } + + return theMsp, nil +} + +func (msp *bccspmsp) getCertFromPem(idBytes []byte) (*x509.Certificate, error) { + if idBytes == nil { + return nil, errors.New("getCertFromPem error: nil idBytes") + } + + // Decode the pem bytes + pemCert, _ := pem.Decode(idBytes) + if pemCert == nil { + return nil, errors.Errorf("getCertFromPem error: could not decode pem bytes [%v]", idBytes) + } + + // get a cert + var cert *x509.Certificate + cert, err := x509.ParseCertificate(pemCert.Bytes) + if err != nil { + return nil, errors.Wrap(err, "getCertFromPem error: failed to parse x509 cert") + } + + return cert, nil +} + +func (msp *bccspmsp) getIdentityFromConf(idBytes []byte) (Identity, core.Key, error) { + // get a cert + cert, err := msp.getCertFromPem(idBytes) + if err != nil { + return nil, nil, err + } + + // get the public key in the right format + certPubK, err := msp.bccsp.KeyImport(cert, factory.GetX509PublicKeyImportOpts(true)) + if err != nil { + return nil, nil, err + } + + mspId, err := newIdentity(cert, certPubK, msp) + if err != nil { + return nil, nil, err + } + + return mspId, certPubK, nil +} + +func (msp *bccspmsp) getSigningIdentityFromConf(sidInfo *m.SigningIdentityInfo) (SigningIdentity, error) { + if sidInfo == nil { + return nil, errors.New("getIdentityFromBytes error: nil sidInfo") + } + + // Extract the public part of the identity + idPub, pubKey, err := msp.getIdentityFromConf(sidInfo.PublicSigner) + if err != nil { + return nil, err + } + + // Find the matching private key in the BCCSP keystore + privKey, err := msp.bccsp.GetKey(pubKey.SKI()) + // Less Secure: Attempt to import Private Key from KeyInfo, if BCCSP was not able to find the key + if err != nil { + mspLogger.Debugf("Could not find SKI [%s], trying KeyMaterial field: %+v\n", hex.EncodeToString(pubKey.SKI()), err) + if sidInfo.PrivateSigner == nil || sidInfo.PrivateSigner.KeyMaterial == nil { + return nil, errors.New("KeyMaterial not found in SigningIdentityInfo") + } + + pemKey, _ := pem.Decode(sidInfo.PrivateSigner.KeyMaterial) + if pemKey == nil { + return nil, errors.Errorf("%s: wrong PEM encoding", sidInfo.PrivateSigner.KeyIdentifier) + } + privKey, err = msp.bccsp.KeyImport(pemKey.Bytes, factory.GetECDSAPrivateKeyImportOpts(true)) + if err != nil { + return nil, errors.WithMessage(err, "getIdentityFromBytes error: Failed to import EC private key") + } + } + + // get the peer signer + peerSigner, err := factory.NewCspSigner(msp.bccsp, privKey) + if err != nil { + return nil, errors.WithMessage(err, "getIdentityFromBytes error: Failed initializing bccspCryptoSigner") + } + + return newSigningIdentity(idPub.(*identity).cert, idPub.(*identity).pk, peerSigner, msp) +} + +// Setup sets up the internal data structures +// for this MSP, given an MSPConfig ref; it +// returns nil in case of success or an error otherwise +func (msp *bccspmsp) Setup(conf1 *m.MSPConfig) error { + if conf1 == nil { + return errors.New("Setup error: nil conf reference") + } + + // given that it's an msp of type fabric, extract the MSPConfig instance + conf := &m.FabricMSPConfig{} + err := proto.Unmarshal(conf1.Config, conf) + if err != nil { + return errors.Wrap(err, "failed unmarshalling fabric msp config") + } + + // set the name for this msp + msp.name = conf.Name + mspLogger.Debugf("Setting up MSP instance %s", msp.name) + + // setup + return msp.internalSetupFunc(conf) +} + +// GetVersion returns the version of this MSP +func (msp *bccspmsp) GetVersion() MSPVersion { + return msp.version +} + +// GetType returns the type for this MSP +func (msp *bccspmsp) GetType() ProviderType { + return FABRIC +} + +// GetIdentifier returns the MSP identifier for this instance +func (msp *bccspmsp) GetIdentifier() (string, error) { + return msp.name, nil +} + +// GetTLSRootCerts returns the root certificates for this MSP +func (msp *bccspmsp) GetTLSRootCerts() [][]byte { + return msp.tlsRootCerts +} + +// GetTLSIntermediateCerts returns the intermediate root certificates for this MSP +func (msp *bccspmsp) GetTLSIntermediateCerts() [][]byte { + return msp.tlsIntermediateCerts +} + +// GetDefaultSigningIdentity returns the +// default signing identity for this MSP (if any) +func (msp *bccspmsp) GetDefaultSigningIdentity() (SigningIdentity, error) { + mspLogger.Debugf("Obtaining default signing identity") + + if msp.signer == nil { + return nil, errors.New("this MSP does not possess a valid default signing identity") + } + + return msp.signer, nil +} + +// GetSigningIdentity returns a specific signing +// identity identified by the supplied identifier +func (msp *bccspmsp) GetSigningIdentity(identifier *IdentityIdentifier) (SigningIdentity, error) { + // TODO + return nil, errors.Errorf("no signing identity for %#v", identifier) +} + +// Validate attempts to determine whether +// the supplied identity is valid according +// to this MSP's roots of trust; it returns +// nil in case the identity is valid or an +// error otherwise +func (msp *bccspmsp) Validate(id Identity) error { + mspLogger.Debugf("MSP %s validating identity", msp.name) + + switch id := id.(type) { + // If this identity is of this specific type, + // this is how I can validate it given the + // root of trust this MSP has + case *identity: + return msp.validateIdentity(id) + default: + return errors.New("identity type not recognized") + } +} + +// hasOURole checks that the identity belongs to the organizational unit +// associated to the specified MSPRole. +// This function does not check the certifiers identifier. +// Appropriate validation needs to be enforced before. +func (msp *bccspmsp) hasOURole(id Identity, mspRole m.MSPRole_MSPRoleType) error { + // Check NodeOUs + if !msp.ouEnforcement { + return errors.New("NodeOUs not activated. Cannot tell apart identities.") + } + + mspLogger.Debugf("MSP %s checking if the identity is a client", msp.name) + + switch id := id.(type) { + // If this identity is of this specific type, + // this is how I can validate it given the + // root of trust this MSP has + case *identity: + return msp.hasOURoleInternal(id, mspRole) + default: + return errors.New("Identity type not recognized") + } +} + +func (msp *bccspmsp) hasOURoleInternal(id *identity, mspRole m.MSPRole_MSPRoleType) error { + var nodeOU *OUIdentifier + switch mspRole { + case m.MSPRole_CLIENT: + nodeOU = msp.clientOU + case m.MSPRole_PEER: + nodeOU = msp.peerOU + case m.MSPRole_ADMIN: + nodeOU = msp.adminOU + case m.MSPRole_ORDERER: + nodeOU = msp.ordererOU + default: + return errors.New("Invalid MSPRoleType. It must be CLIENT, PEER, ADMIN or ORDERER") + } + + if nodeOU == nil { + return errors.Errorf("cannot test for classification, node ou for type [%s], not defined, msp: [%s]", mspRole, msp.name) + } + + for _, OU := range id.GetOrganizationalUnits() { + if OU.OrganizationalUnitIdentifier == nodeOU.OrganizationalUnitIdentifier { + return nil + } + } + + return errors.Errorf("The identity does not contain OU [%s], MSP: [%s]", mspRole, msp.name) +} + +// DeserializeIdentity returns an Identity given the byte-level +// representation of a SerializedIdentity struct +func (msp *bccspmsp) DeserializeIdentity(serializedID []byte) (Identity, error) { + mspLogger.Debug("Obtaining identity") + + // We first deserialize to a SerializedIdentity to get the MSP ID + sId := &m.SerializedIdentity{} + err := proto.Unmarshal(serializedID, sId) + if err != nil { + return nil, errors.Wrap(err, "could not deserialize a SerializedIdentity") + } + + if sId.Mspid != msp.name { + return nil, errors.Errorf("expected MSP ID %s, received %s", msp.name, sId.Mspid) + } + + return msp.deserializeIdentityInternal(sId.IdBytes) +} + +// deserializeIdentityInternal returns an identity given its byte-level representation +func (msp *bccspmsp) deserializeIdentityInternal(serializedIdentity []byte) (Identity, error) { + // This MSP will always deserialize certs this way + bl, _ := pem.Decode(serializedIdentity) + if bl == nil { + return nil, errors.New("could not decode the PEM structure") + } + cert, err := x509.ParseCertificate(bl.Bytes) + if err != nil { + return nil, errors.Wrap(err, "parseCertificate failed") + } + + // Now we have the certificate; make sure that its fields + // (e.g. the Issuer.OU or the Subject.OU) match with the + // MSP id that this MSP has; otherwise it might be an attack + // TODO! + // We can't do it yet because there is no standardized way + // (yet) to encode the MSP ID into the x.509 body of a cert + + pub, err := msp.bccsp.KeyImport(cert, factory.GetX509PublicKeyImportOpts(true)) + if err != nil { + return nil, errors.WithMessage(err, "failed to import certificate's public key") + } + + return newIdentity(cert, pub, msp) +} + +// SatisfiesPrincipal returns nil if the identity matches the principal or an error otherwise +func (msp *bccspmsp) SatisfiesPrincipal(id Identity, principal *m.MSPPrincipal) error { + principals, err := collectPrincipals(principal, msp.GetVersion()) + if err != nil { + return err + } + for _, principal := range principals { + err = msp.internalSatisfiesPrincipalInternalFunc(id, principal) + if err != nil { + return err + } + } + return nil +} + +// collectPrincipals collects principals from combined principals into a single MSPPrincipal slice. +func collectPrincipals(principal *m.MSPPrincipal, mspVersion MSPVersion) ([]*m.MSPPrincipal, error) { + switch principal.PrincipalClassification { + case m.MSPPrincipal_COMBINED: + // Combined principals are not supported in MSP v1.0 or v1.1 + if mspVersion <= MSPv1_1 { + return nil, errors.Errorf("invalid principal type %d", int32(principal.PrincipalClassification)) + } + // Principal is a combination of multiple principals. + principals := &m.CombinedPrincipal{} + err := proto.Unmarshal(principal.Principal, principals) + if err != nil { + return nil, errors.Wrap(err, "could not unmarshal CombinedPrincipal from principal") + } + // Return an error if there are no principals in the combined principal. + if len(principals.Principals) == 0 { + return nil, errors.New("No principals in CombinedPrincipal") + } + // Recursively call msp.collectPrincipals for all combined principals. + // There is no limit for the levels of nesting for the combined principals. + var principalsSlice []*m.MSPPrincipal + for _, cp := range principals.Principals { + internalSlice, err := collectPrincipals(cp, mspVersion) + if err != nil { + return nil, err + } + principalsSlice = append(principalsSlice, internalSlice...) + } + // All the combined principals have been collected into principalsSlice + return principalsSlice, nil + default: + return []*m.MSPPrincipal{principal}, nil + } +} + +// satisfiesPrincipalInternalPreV13 takes as arguments the identity and the principal. +// The function returns an error if one occurred. +// The function implements the behavior of an MSP up to and including v1.1. +func (msp *bccspmsp) satisfiesPrincipalInternalPreV13(id Identity, principal *m.MSPPrincipal) error { + switch principal.PrincipalClassification { + // in this case, we have to check whether the + // identity has a role in the msp - member or admin + case m.MSPPrincipal_ROLE: + // Principal contains the msp role + mspRole := &m.MSPRole{} + err := proto.Unmarshal(principal.Principal, mspRole) + if err != nil { + return errors.Wrap(err, "could not unmarshal MSPRole from principal") + } + + // at first, we check whether the MSP + // identifier is the same as that of the identity + if mspRole.MspIdentifier != msp.name { + return errors.Errorf("the identity is a member of a different MSP (expected %s, got %s)", mspRole.MspIdentifier, id.GetMSPIdentifier()) + } + + // now we validate the different msp roles + switch mspRole.Role { + case m.MSPRole_MEMBER: + // in the case of member, we simply check + // whether this identity is valid for the MSP + mspLogger.Debugf("Checking if identity satisfies MEMBER role for %s", msp.name) + return msp.Validate(id) + case m.MSPRole_ADMIN: + mspLogger.Debugf("Checking if identity satisfies ADMIN role for %s", msp.name) + // in the case of admin, we check that the + // id is exactly one of our admins + if msp.isInAdmins(id.(*identity)) { + return nil + } + return errors.New("This identity is not an admin") + case m.MSPRole_CLIENT: + fallthrough + case m.MSPRole_PEER: + mspLogger.Debugf("Checking if identity satisfies role [%s] for %s", m.MSPRole_MSPRoleType_name[int32(mspRole.Role)], msp.name) + if err := msp.Validate(id); err != nil { + return errors.Wrapf(err, "The identity is not valid under this MSP [%s]", msp.name) + } + + if err := msp.hasOURole(id, mspRole.Role); err != nil { + return errors.Wrapf(err, "The identity is not a [%s] under this MSP [%s]", m.MSPRole_MSPRoleType_name[int32(mspRole.Role)], msp.name) + } + return nil + default: + return errors.Errorf("invalid MSP role type %d", int32(mspRole.Role)) + } + case m.MSPPrincipal_IDENTITY: + // in this case we have to deserialize the principal's identity + // and compare it byte-by-byte with our cert + principalId, err := msp.DeserializeIdentity(principal.Principal) + if err != nil { + return errors.WithMessage(err, "invalid identity principal, not a certificate") + } + + if bytes.Equal(id.(*identity).cert.Raw, principalId.(*identity).cert.Raw) { + return principalId.Validate() + } + + return errors.New("The identities do not match") + case m.MSPPrincipal_ORGANIZATION_UNIT: + // Principal contains the OrganizationUnit + OU := &m.OrganizationUnit{} + err := proto.Unmarshal(principal.Principal, OU) + if err != nil { + return errors.Wrap(err, "could not unmarshal OrganizationUnit from principal") + } + + // at first, we check whether the MSP + // identifier is the same as that of the identity + if OU.MspIdentifier != msp.name { + return errors.Errorf("the identity is a member of a different MSP (expected %s, got %s)", OU.MspIdentifier, id.GetMSPIdentifier()) + } + + // we then check if the identity is valid with this MSP + // and fail if it is not + err = msp.Validate(id) + if err != nil { + return err + } + + // now we check whether any of this identity's OUs match the requested one + for _, ou := range id.GetOrganizationalUnits() { + if ou.OrganizationalUnitIdentifier == OU.OrganizationalUnitIdentifier && + bytes.Equal(ou.CertifiersIdentifier, OU.CertifiersIdentifier) { + return nil + } + } + + // if we are here, no match was found, return an error + return errors.New("The identities do not match") + default: + return errors.Errorf("invalid principal type %d", int32(principal.PrincipalClassification)) + } +} + +// satisfiesPrincipalInternalV13 takes as arguments the identity and the principal. +// The function returns an error if one occurred. +// The function implements the additional behavior expected of an MSP starting from v1.3. +// For pre-v1.3 functionality, the function calls the satisfiesPrincipalInternalPreV13. +func (msp *bccspmsp) satisfiesPrincipalInternalV13(id Identity, principal *m.MSPPrincipal) error { + switch principal.PrincipalClassification { + case m.MSPPrincipal_COMBINED: + return errors.New("SatisfiesPrincipalInternal shall not be called with a CombinedPrincipal") + case m.MSPPrincipal_ANONYMITY: + anon := &m.MSPIdentityAnonymity{} + err := proto.Unmarshal(principal.Principal, anon) + if err != nil { + return errors.Wrap(err, "could not unmarshal MSPIdentityAnonymity from principal") + } + switch anon.AnonymityType { + case m.MSPIdentityAnonymity_ANONYMOUS: + return errors.New("Principal is anonymous, but X.509 MSP does not support anonymous identities") + case m.MSPIdentityAnonymity_NOMINAL: + return nil + default: + return errors.Errorf("Unknown principal anonymity type: %d", anon.AnonymityType) + } + + default: + // Use the pre-v1.3 function to check other principal types + return msp.satisfiesPrincipalInternalPreV13(id, principal) + } +} + +// satisfiesPrincipalInternalV142 takes as arguments the identity and the principal. +// The function returns an error if one occurred. +// The function implements the additional behavior expected of an MSP starting from v2.0. +// For v1.3 functionality, the function calls the satisfiesPrincipalInternalPreV13. +func (msp *bccspmsp) satisfiesPrincipalInternalV142(id Identity, principal *m.MSPPrincipal) error { + _, okay := id.(*identity) + if !okay { + return errors.New("invalid identity type, expected *identity") + } + + switch principal.PrincipalClassification { + case m.MSPPrincipal_ROLE: + if !msp.ouEnforcement { + break + } + + // Principal contains the msp role + mspRole := &m.MSPRole{} + err := proto.Unmarshal(principal.Principal, mspRole) + if err != nil { + return errors.Wrap(err, "could not unmarshal MSPRole from principal") + } + + // at first, we check whether the MSP + // identifier is the same as that of the identity + if mspRole.MspIdentifier != msp.name { + return errors.Errorf("the identity is a member of a different MSP (expected %s, got %s)", mspRole.MspIdentifier, id.GetMSPIdentifier()) + } + + // now we validate the admin role only, the other roles are left to the v1.3 function + switch mspRole.Role { + case m.MSPRole_ADMIN: + mspLogger.Debugf("Checking if identity has been named explicitly as an admin for %s", msp.name) + // in the case of admin, we check that the + // id is exactly one of our admins + if msp.isInAdmins(id.(*identity)) { + return nil + } + + // or it carries the Admin OU, in this case check that the identity is valid as well. + mspLogger.Debugf("Checking if identity carries the admin ou for %s", msp.name) + if err := msp.Validate(id); err != nil { + return errors.Wrapf(err, "The identity is not valid under this MSP [%s]", msp.name) + } + + if err := msp.hasOURole(id, m.MSPRole_ADMIN); err != nil { + return errors.Wrapf(err, "The identity is not an admin under this MSP [%s]", msp.name) + } + + return nil + case m.MSPRole_ORDERER: + mspLogger.Debugf("Checking if identity satisfies role [%s] for %s", m.MSPRole_MSPRoleType_name[int32(mspRole.Role)], msp.name) + if err := msp.Validate(id); err != nil { + return errors.Wrapf(err, "The identity is not valid under this MSP [%s]", msp.name) + } + + if err := msp.hasOURole(id, mspRole.Role); err != nil { + return errors.Wrapf(err, "The identity is not a [%s] under this MSP [%s]", m.MSPRole_MSPRoleType_name[int32(mspRole.Role)], msp.name) + } + return nil + } + } + + // Use the v1.3 function to check other principal types + return msp.satisfiesPrincipalInternalV13(id, principal) +} + +func (msp *bccspmsp) isInAdmins(id *identity) bool { + for _, admincert := range msp.admins { + if bytes.Equal(id.cert.Raw, admincert.(*identity).cert.Raw) { + // we do not need to check whether the admin is a valid identity + // according to this MSP, since we already check this at Setup time + // if there is a match, we can just return + return true + } + } + return false +} + +// getCertificationChain returns the certification chain of the passed identity within this msp +func (msp *bccspmsp) getCertificationChain(id Identity) ([]*x509.Certificate, error) { + mspLogger.Debugf("MSP %s getting certification chain", msp.name) + + switch id := id.(type) { + // If this identity is of this specific type, + // this is how I can validate it given the + // root of trust this MSP has + case *identity: + return msp.getCertificationChainForBCCSPIdentity(id) + default: + return nil, errors.New("identity type not recognized") + } +} + +// getCertificationChainForBCCSPIdentity returns the certification chain of the passed bccsp identity within this msp +func (msp *bccspmsp) getCertificationChainForBCCSPIdentity(id *identity) ([]*x509.Certificate, error) { + if id == nil { + return nil, errors.New("Invalid bccsp identity. Must be different from nil.") + } + + // we expect to have a valid VerifyOptions instance + if msp.opts == nil { + return nil, errors.New("Invalid msp instance") + } + + // CAs cannot be directly used as identities.. + if id.cert.IsCA { + return nil, errors.New("An X509 certificate with Basic Constraint: " + + "Certificate Authority equals true cannot be used as an identity") + } + + return msp.getValidationChain(id.cert, false) +} + +func (msp *bccspmsp) getUniqueValidationChain(cert *x509.Certificate, opts x509.VerifyOptions) ([]*x509.Certificate, error) { + // ask golang to validate the cert for us based on the options that we've built at setup time + if msp.opts == nil { + return nil, errors.New("the supplied identity has no verify options") + } + validationChains, err := cert.Verify(opts) + if err != nil { + return nil, errors.WithMessage(err, "the supplied identity is not valid") + } + + // we only support a single validation chain; + // if there's more than one then there might + // be unclarity about who owns the identity + if len(validationChains) != 1 { + return nil, errors.Errorf("this MSP only supports a single validation chain, got %d", len(validationChains)) + } + + return validationChains[0], nil +} + +func (msp *bccspmsp) getValidationChain(cert *x509.Certificate, isIntermediateChain bool) ([]*x509.Certificate, error) { + validationChain, err := msp.getUniqueValidationChain(cert, msp.getValidityOptsForCert(cert)) + if err != nil { + return nil, errors.WithMessage(err, "failed getting validation chain") + } + + // we expect a chain of length at least 2 + if len(validationChain) < 2 { + return nil, errors.Errorf("expected a chain of length at least 2, got %d", len(validationChain)) + } + + // check that the parent is a leaf of the certification tree + // if validating an intermediate chain, the first certificate will the parent + parentPosition := 1 + if isIntermediateChain { + parentPosition = 0 + } + if msp.certificationTreeInternalNodesMap[string(validationChain[parentPosition].Raw)] { + return nil, errors.Errorf("invalid validation chain. Parent certificate should be a leaf of the certification tree [%v]", cert.Raw) + } + return validationChain, nil +} + +// getCertificationChainIdentifier returns the certification chain identifier of the passed identity within this msp. +// The identifier is computes as the SHA256 of the concatenation of the certificates in the chain. +func (msp *bccspmsp) getCertificationChainIdentifier(id Identity) ([]byte, error) { + chain, err := msp.getCertificationChain(id) + if err != nil { + return nil, errors.WithMessagef(err, "failed getting certification chain for [%v]", id) + } + + // chain[0] is the certificate representing the identity. + // It will be discarded + return msp.getCertificationChainIdentifierFromChain(chain[1:]) +} + +func (msp *bccspmsp) getCertificationChainIdentifierFromChain(chain []*x509.Certificate) ([]byte, error) { + // Hash the chain + // Use the hash of the identity's certificate as id in the IdentityIdentifier + hashOpt, err := factory.GetHashOpt(msp.cryptoConfig.IdentityIdentifierHashFunction) + if err != nil { + return nil, errors.WithMessage(err, "failed getting hash function options") + } + + hf, err := msp.bccsp.GetHash(hashOpt) + if err != nil { + return nil, errors.WithMessage(err, "failed getting hash function when computing certification chain identifier") + } + for i := 0; i < len(chain); i++ { + hf.Write(chain[i].Raw) + } + return hf.Sum(nil), nil +} + +// sanitizeCert ensures that x509 certificates signed using ECDSA +// do have signatures in Low-S. If this is not the case, the certificate +// is regenerated to have a Low-S signature. +func (msp *bccspmsp) sanitizeCert(cert *x509.Certificate) (*x509.Certificate, error) { + if isECDSASignedCert(cert) { + // Lookup for a parent certificate to perform the sanitization + var parentCert *x509.Certificate + chain, err := msp.getUniqueValidationChain(cert, msp.getValidityOptsForCert(cert)) + if err != nil { + return nil, err + } + + // at this point, cert might be a root CA certificate + // or an intermediate CA certificate + if cert.IsCA && len(chain) == 1 { + // cert is a root CA certificate + parentCert = cert + } else { + parentCert = chain[1] + } + + // Sanitize + cert, err = sanitizeECDSASignedCert(cert, parentCert) + if err != nil { + return nil, err + } + } + return cert, nil +} + +// IsWellFormed checks if the given identity can be deserialized into its provider-specific form. +// In this MSP implementation, well formed means that the PEM has a Type which is either +// the string 'CERTIFICATE' or the Type is missing altogether. +func (msp *bccspmsp) IsWellFormed(identity *m.SerializedIdentity) error { + bl, rest := pem.Decode(identity.IdBytes) + if bl == nil { + return errors.New("PEM decoding resulted in an empty block") + } + if len(rest) > 0 { + return errors.Errorf("identity %s for MSP %s has trailing bytes", string(identity.IdBytes), identity.Mspid) + } + + // Important: This method looks very similar to getCertFromPem(idBytes []byte) (*x509.Certificate, error) + // But we: + // 1) Must ensure PEM block is of type CERTIFICATE or is empty + // 2) Must not replace getCertFromPem with this method otherwise we will introduce + // a change in validation logic which will result in a chain fork. + if bl.Type != "CERTIFICATE" && bl.Type != "" { + return errors.Errorf("pem type is %s, should be 'CERTIFICATE' or missing", bl.Type) + } + cert, err := x509.ParseCertificate(bl.Bytes) + if err != nil { + return err + } + + if !isECDSASignedCert(cert) { + return nil + } + + return isIdentitySignedInCanonicalForm(cert.Signature, identity.Mspid, identity.IdBytes) + +} + +func isIdentitySignedInCanonicalForm(sig []byte, mspID string, pemEncodedIdentity []byte) error { + r, s, err := utils.UnmarshalECDSASignature(sig) + if err != nil { + return err + } + + expectedSig, err := utils.MarshalECDSASignature(r, s) + if err != nil { + return err + } + + if !bytes.Equal(expectedSig, sig) { + return errors.Errorf("identity %s for MSP %s has a non canonical signature", + string(pemEncodedIdentity), mspID) + } + + return nil +} diff --git a/internal/github.com/hyperledger/fabric/msp/mspimplsetup.go b/internal/github.com/hyperledger/fabric/msp/mspimplsetup.go new file mode 100644 index 00000000..7c4f1605 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/msp/mspimplsetup.go @@ -0,0 +1,674 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package msp + +import ( + "bytes" + "crypto/x509" + "crypto/x509/pkix" + "fmt" + "time" + + "github.com/golang/protobuf/proto" + m "github.com/hyperledger/fabric-protos-go/msp" + bccsp "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/cryptosuitebridge" + errors "github.com/pkg/errors" +) + +func (msp *bccspmsp) getCertifiersIdentifier(certRaw []byte) ([]byte, error) { + // 1. check that certificate is registered in msp.rootCerts or msp.intermediateCerts + cert, err := msp.getCertFromPem(certRaw) + if err != nil { + return nil, fmt.Errorf("Failed getting certificate for [%v]: [%s]", certRaw, err) + } + + // 2. Sanitize it to ensure like for like comparison + cert, err = msp.sanitizeCert(cert) + if err != nil { + return nil, fmt.Errorf("sanitizeCert failed %s", err) + } + + found := false + root := false + // Search among root certificates + for _, v := range msp.rootCerts { + if v.(*identity).cert.Equal(cert) { + found = true + root = true + break + } + } + if !found { + // Search among root intermediate certificates + for _, v := range msp.intermediateCerts { + if v.(*identity).cert.Equal(cert) { + found = true + break + } + } + } + if !found { + // Certificate not valid, reject configuration + return nil, fmt.Errorf("Failed adding OU. Certificate [%v] not in root or intermediate certs.", cert) + } + + // 3. get the certification path for it + var certifiersIdentifier []byte + var chain []*x509.Certificate + if root { + chain = []*x509.Certificate{cert} + } else { + chain, err = msp.getValidationChain(cert, true) + if err != nil { + return nil, fmt.Errorf("Failed computing validation chain for [%v]. [%s]", cert, err) + } + } + + // 4. compute the hash of the certification path + certifiersIdentifier, err = msp.getCertificationChainIdentifierFromChain(chain) + if err != nil { + return nil, fmt.Errorf("Failed computing Certifiers Identifier for [%v]. [%s]", certRaw, err) + } + + return certifiersIdentifier, nil + +} + +func (msp *bccspmsp) setupCrypto(conf *m.FabricMSPConfig) error { + msp.cryptoConfig = conf.CryptoConfig + if msp.cryptoConfig == nil { + // Move to defaults + msp.cryptoConfig = &m.FabricCryptoConfig{ + SignatureHashFamily: bccsp.SHA2, + IdentityIdentifierHashFunction: bccsp.SHA256, + } + mspLogger.Debugf("CryptoConfig was nil. Move to defaults.") + } + if msp.cryptoConfig.SignatureHashFamily == "" { + msp.cryptoConfig.SignatureHashFamily = bccsp.SHA2 + mspLogger.Debugf("CryptoConfig.SignatureHashFamily was nil. Move to defaults.") + } + if msp.cryptoConfig.IdentityIdentifierHashFunction == "" { + msp.cryptoConfig.IdentityIdentifierHashFunction = bccsp.SHA256 + mspLogger.Debugf("CryptoConfig.IdentityIdentifierHashFunction was nil. Move to defaults.") + } + + return nil +} + +func (msp *bccspmsp) setupCAs(conf *m.FabricMSPConfig) error { + // make and fill the set of CA certs - we expect them to be there + if len(conf.RootCerts) == 0 { + return errors.New("expected at least one CA certificate") + } + + // pre-create the verify options with roots and intermediates. + // This is needed to make certificate sanitation working. + // Recall that sanitization is applied also to root CA and intermediate + // CA certificates. After their sanitization is done, the opts + // will be recreated using the sanitized certs. + msp.opts = &x509.VerifyOptions{Roots: x509.NewCertPool(), Intermediates: x509.NewCertPool()} + for _, v := range conf.RootCerts { + cert, err := msp.getCertFromPem(v) + if err != nil { + return err + } + msp.opts.Roots.AddCert(cert) + } + for _, v := range conf.IntermediateCerts { + cert, err := msp.getCertFromPem(v) + if err != nil { + return err + } + msp.opts.Intermediates.AddCert(cert) + } + + // Load root and intermediate CA identities + // Recall that when an identity is created, its certificate gets sanitized + msp.rootCerts = make([]Identity, len(conf.RootCerts)) + for i, trustedCert := range conf.RootCerts { + id, _, err := msp.getIdentityFromConf(trustedCert) + if err != nil { + return err + } + + msp.rootCerts[i] = id + } + + // make and fill the set of intermediate certs (if present) + msp.intermediateCerts = make([]Identity, len(conf.IntermediateCerts)) + for i, trustedCert := range conf.IntermediateCerts { + id, _, err := msp.getIdentityFromConf(trustedCert) + if err != nil { + return err + } + + msp.intermediateCerts[i] = id + } + + // root CA and intermediate CA certificates are sanitized, they can be re-imported + msp.opts = &x509.VerifyOptions{Roots: x509.NewCertPool(), Intermediates: x509.NewCertPool()} + for _, id := range msp.rootCerts { + msp.opts.Roots.AddCert(id.(*identity).cert) + } + for _, id := range msp.intermediateCerts { + msp.opts.Intermediates.AddCert(id.(*identity).cert) + } + + return nil +} + +func (msp *bccspmsp) setupAdmins(conf *m.FabricMSPConfig) error { + return msp.internalSetupAdmin(conf) +} + +func (msp *bccspmsp) setupAdminsPreV142(conf *m.FabricMSPConfig) error { + // make and fill the set of admin certs (if present) + msp.admins = make([]Identity, len(conf.Admins)) + for i, admCert := range conf.Admins { + id, _, err := msp.getIdentityFromConf(admCert) + if err != nil { + return err + } + + msp.admins[i] = id + } + + return nil +} + +func (msp *bccspmsp) setupAdminsV142(conf *m.FabricMSPConfig) error { + // make and fill the set of admin certs (if present) + if err := msp.setupAdminsPreV142(conf); err != nil { + return err + } + + if len(msp.admins) == 0 && (!msp.ouEnforcement || msp.adminOU == nil) { + return errors.New("administrators must be declared when no admin ou classification is set") + } + + return nil +} + +func (msp *bccspmsp) setupCRLs(conf *m.FabricMSPConfig) error { + // setup the CRL (if present) + msp.CRL = make([]*pkix.CertificateList, len(conf.RevocationList)) + for i, crlbytes := range conf.RevocationList { + crl, err := x509.ParseCRL(crlbytes) + if err != nil { + return errors.Wrap(err, "could not parse RevocationList") + } + + // TODO: pre-verify the signature on the CRL and create a map + // of CA certs to respective CRLs so that later upon + // validation we can already look up the CRL given the + // chain of the certificate to be validated + + msp.CRL[i] = crl + } + + return nil +} + +func (msp *bccspmsp) finalizeSetupCAs() error { + // ensure that our CAs are properly formed and that they are valid + for _, id := range append(append([]Identity{}, msp.rootCerts...), msp.intermediateCerts...) { + if !id.(*identity).cert.IsCA { + return errors.Errorf("CA Certificate did not have the CA attribute, (SN: %x)", id.(*identity).cert.SerialNumber) + } + if _, err := getSubjectKeyIdentifierFromCert(id.(*identity).cert); err != nil { + return errors.WithMessagef(err, "CA Certificate problem with Subject Key Identifier extension, (SN: %x)", id.(*identity).cert.SerialNumber) + } + + if err := msp.validateCAIdentity(id.(*identity)); err != nil { + return errors.WithMessagef(err, "CA Certificate is not valid, (SN: %s)", id.(*identity).cert.SerialNumber) + } + } + + // populate certificationTreeInternalNodesMap to mark the internal nodes of the + // certification tree + msp.certificationTreeInternalNodesMap = make(map[string]bool) + for _, id := range append([]Identity{}, msp.intermediateCerts...) { + chain, err := msp.getUniqueValidationChain(id.(*identity).cert, msp.getValidityOptsForCert(id.(*identity).cert)) + if err != nil { + return errors.WithMessagef(err, "failed getting validation chain, (SN: %s)", id.(*identity).cert.SerialNumber) + } + + // Recall chain[0] is id.(*identity).id so it does not count as a parent + for i := 1; i < len(chain); i++ { + msp.certificationTreeInternalNodesMap[string(chain[i].Raw)] = true + } + } + + return nil +} + +func (msp *bccspmsp) setupNodeOUs(config *m.FabricMSPConfig) error { + if config.FabricNodeOus != nil { + + msp.ouEnforcement = config.FabricNodeOus.Enable + + if config.FabricNodeOus.ClientOuIdentifier == nil || len(config.FabricNodeOus.ClientOuIdentifier.OrganizationalUnitIdentifier) == 0 { + return errors.New("Failed setting up NodeOUs. ClientOU must be different from nil.") + } + + if config.FabricNodeOus.PeerOuIdentifier == nil || len(config.FabricNodeOus.PeerOuIdentifier.OrganizationalUnitIdentifier) == 0 { + return errors.New("Failed setting up NodeOUs. PeerOU must be different from nil.") + } + + // ClientOU + msp.clientOU = &OUIdentifier{OrganizationalUnitIdentifier: config.FabricNodeOus.ClientOuIdentifier.OrganizationalUnitIdentifier} + if len(config.FabricNodeOus.ClientOuIdentifier.Certificate) != 0 { + certifiersIdentifier, err := msp.getCertifiersIdentifier(config.FabricNodeOus.ClientOuIdentifier.Certificate) + if err != nil { + return err + } + msp.clientOU.CertifiersIdentifier = certifiersIdentifier + } + + // PeerOU + msp.peerOU = &OUIdentifier{OrganizationalUnitIdentifier: config.FabricNodeOus.PeerOuIdentifier.OrganizationalUnitIdentifier} + if len(config.FabricNodeOus.PeerOuIdentifier.Certificate) != 0 { + certifiersIdentifier, err := msp.getCertifiersIdentifier(config.FabricNodeOus.PeerOuIdentifier.Certificate) + if err != nil { + return err + } + msp.peerOU.CertifiersIdentifier = certifiersIdentifier + } + + } else { + msp.ouEnforcement = false + } + + return nil +} + +func (msp *bccspmsp) setupNodeOUsV142(config *m.FabricMSPConfig) error { + if config.FabricNodeOus == nil { + msp.ouEnforcement = false + return nil + } + + msp.ouEnforcement = config.FabricNodeOus.Enable + + counter := 0 + // ClientOU + if config.FabricNodeOus.ClientOuIdentifier != nil { + msp.clientOU = &OUIdentifier{OrganizationalUnitIdentifier: config.FabricNodeOus.ClientOuIdentifier.OrganizationalUnitIdentifier} + if len(config.FabricNodeOus.ClientOuIdentifier.Certificate) != 0 { + certifiersIdentifier, err := msp.getCertifiersIdentifier(config.FabricNodeOus.ClientOuIdentifier.Certificate) + if err != nil { + return err + } + msp.clientOU.CertifiersIdentifier = certifiersIdentifier + } + counter++ + } else { + msp.clientOU = nil + } + + // PeerOU + if config.FabricNodeOus.PeerOuIdentifier != nil { + msp.peerOU = &OUIdentifier{OrganizationalUnitIdentifier: config.FabricNodeOus.PeerOuIdentifier.OrganizationalUnitIdentifier} + if len(config.FabricNodeOus.PeerOuIdentifier.Certificate) != 0 { + certifiersIdentifier, err := msp.getCertifiersIdentifier(config.FabricNodeOus.PeerOuIdentifier.Certificate) + if err != nil { + return err + } + msp.peerOU.CertifiersIdentifier = certifiersIdentifier + } + counter++ + } else { + msp.peerOU = nil + } + + // AdminOU + if config.FabricNodeOus.AdminOuIdentifier != nil { + msp.adminOU = &OUIdentifier{OrganizationalUnitIdentifier: config.FabricNodeOus.AdminOuIdentifier.OrganizationalUnitIdentifier} + if len(config.FabricNodeOus.AdminOuIdentifier.Certificate) != 0 { + certifiersIdentifier, err := msp.getCertifiersIdentifier(config.FabricNodeOus.AdminOuIdentifier.Certificate) + if err != nil { + return err + } + msp.adminOU.CertifiersIdentifier = certifiersIdentifier + } + counter++ + } else { + msp.adminOU = nil + } + + // OrdererOU + if config.FabricNodeOus.OrdererOuIdentifier != nil { + msp.ordererOU = &OUIdentifier{OrganizationalUnitIdentifier: config.FabricNodeOus.OrdererOuIdentifier.OrganizationalUnitIdentifier} + if len(config.FabricNodeOus.OrdererOuIdentifier.Certificate) != 0 { + certifiersIdentifier, err := msp.getCertifiersIdentifier(config.FabricNodeOus.OrdererOuIdentifier.Certificate) + if err != nil { + return err + } + msp.ordererOU.CertifiersIdentifier = certifiersIdentifier + } + counter++ + } else { + msp.ordererOU = nil + } + + if counter == 0 { + // Disable NodeOU + msp.ouEnforcement = false + } + + return nil +} + +func (msp *bccspmsp) setupSigningIdentity(conf *m.FabricMSPConfig) error { + if conf.SigningIdentity != nil { + sid, err := msp.getSigningIdentityFromConf(conf.SigningIdentity) + if err != nil { + return err + } + + expirationTime := sid.ExpiresAt() + now := time.Now() + if expirationTime.After(now) { + mspLogger.Debug("Signing identity expires at", expirationTime) + } else if expirationTime.IsZero() { + mspLogger.Debug("Signing identity has no known expiration time") + } else { + return errors.Errorf("signing identity expired %v ago", now.Sub(expirationTime)) + } + + msp.signer = sid + } + + return nil +} + +func (msp *bccspmsp) setupOUs(conf *m.FabricMSPConfig) error { + msp.ouIdentifiers = make(map[string][][]byte) + for _, ou := range conf.OrganizationalUnitIdentifiers { + + certifiersIdentifier, err := msp.getCertifiersIdentifier(ou.Certificate) + if err != nil { + return errors.WithMessagef(err, "failed getting certificate for [%v]", ou) + } + + // Check for duplicates + found := false + for _, id := range msp.ouIdentifiers[ou.OrganizationalUnitIdentifier] { + if bytes.Equal(id, certifiersIdentifier) { + mspLogger.Warningf("Duplicate found in ou identifiers [%s, %v]", ou.OrganizationalUnitIdentifier, id) + found = true + break + } + } + + if !found { + // No duplicates found, add it + msp.ouIdentifiers[ou.OrganizationalUnitIdentifier] = append( + msp.ouIdentifiers[ou.OrganizationalUnitIdentifier], + certifiersIdentifier, + ) + } + } + + return nil +} + +func (msp *bccspmsp) setupTLSCAs(conf *m.FabricMSPConfig) error { + + opts := &x509.VerifyOptions{Roots: x509.NewCertPool(), Intermediates: x509.NewCertPool()} + + // Load TLS root and intermediate CA identities + msp.tlsRootCerts = make([][]byte, len(conf.TlsRootCerts)) + rootCerts := make([]*x509.Certificate, len(conf.TlsRootCerts)) + for i, trustedCert := range conf.TlsRootCerts { + cert, err := msp.getCertFromPem(trustedCert) + if err != nil { + return err + } + + rootCerts[i] = cert + msp.tlsRootCerts[i] = trustedCert + opts.Roots.AddCert(cert) + } + + // make and fill the set of intermediate certs (if present) + msp.tlsIntermediateCerts = make([][]byte, len(conf.TlsIntermediateCerts)) + intermediateCerts := make([]*x509.Certificate, len(conf.TlsIntermediateCerts)) + for i, trustedCert := range conf.TlsIntermediateCerts { + cert, err := msp.getCertFromPem(trustedCert) + if err != nil { + return err + } + + intermediateCerts[i] = cert + msp.tlsIntermediateCerts[i] = trustedCert + opts.Intermediates.AddCert(cert) + } + + // ensure that our CAs are properly formed and that they are valid + for _, cert := range append(append([]*x509.Certificate{}, rootCerts...), intermediateCerts...) { + if cert == nil { + continue + } + + if !cert.IsCA { + return errors.Errorf("CA Certificate did not have the CA attribute, (SN: %x)", cert.SerialNumber) + } + if _, err := getSubjectKeyIdentifierFromCert(cert); err != nil { + return errors.WithMessagef(err, "CA Certificate problem with Subject Key Identifier extension, (SN: %x)", cert.SerialNumber) + } + + if err := msp.validateTLSCAIdentity(cert, opts); err != nil { + return errors.WithMessagef(err, "CA Certificate is not valid, (SN: %s)", cert.SerialNumber) + } + } + + return nil +} + +func (msp *bccspmsp) setupV1(conf1 *m.FabricMSPConfig) error { + err := msp.preSetupV1(conf1) + if err != nil { + return err + } + + err = msp.postSetupV1(conf1) + if err != nil { + return err + } + + return nil +} + +func (msp *bccspmsp) preSetupV1(conf *m.FabricMSPConfig) error { + // setup crypto config + if err := msp.setupCrypto(conf); err != nil { + return err + } + + // Setup CAs + if err := msp.setupCAs(conf); err != nil { + return err + } + + // Setup Admins + if err := msp.setupAdmins(conf); err != nil { + return err + } + + // Setup CRLs + if err := msp.setupCRLs(conf); err != nil { + return err + } + + // Finalize setup of the CAs + if err := msp.finalizeSetupCAs(); err != nil { + return err + } + + // setup the signer (if present) + if err := msp.setupSigningIdentity(conf); err != nil { + return err + } + + // setup TLS CAs + if err := msp.setupTLSCAs(conf); err != nil { + return err + } + + // setup the OUs + if err := msp.setupOUs(conf); err != nil { + return err + } + + return nil +} + +func (msp *bccspmsp) preSetupV142(conf *m.FabricMSPConfig) error { + // setup crypto config + if err := msp.setupCrypto(conf); err != nil { + return err + } + + // Setup CAs + if err := msp.setupCAs(conf); err != nil { + return err + } + + // Setup CRLs + if err := msp.setupCRLs(conf); err != nil { + return err + } + + // Finalize setup of the CAs + if err := msp.finalizeSetupCAs(); err != nil { + return err + } + + // setup the signer (if present) + if err := msp.setupSigningIdentity(conf); err != nil { + return err + } + + // setup TLS CAs + if err := msp.setupTLSCAs(conf); err != nil { + return err + } + + // setup the OUs + if err := msp.setupOUs(conf); err != nil { + return err + } + + // setup NodeOUs + if err := msp.setupNodeOUsV142(conf); err != nil { + return err + } + + // Setup Admins + if err := msp.setupAdmins(conf); err != nil { + return err + } + + return nil +} + +func (msp *bccspmsp) postSetupV1(conf *m.FabricMSPConfig) error { + // make sure that admins are valid members as well + // this way, when we validate an admin MSP principal + // we can simply check for exact match of certs + for i, admin := range msp.admins { + err := admin.Validate() + if err != nil { + return errors.WithMessagef(err, "admin %d is invalid", i) + } + } + + return nil +} + +func (msp *bccspmsp) setupV11(conf *m.FabricMSPConfig) error { + err := msp.preSetupV1(conf) + if err != nil { + return err + } + + // setup NodeOUs + if err := msp.setupNodeOUs(conf); err != nil { + return err + } + + err = msp.postSetupV11(conf) + if err != nil { + return err + } + + return nil +} + +func (msp *bccspmsp) setupV142(conf *m.FabricMSPConfig) error { + err := msp.preSetupV142(conf) + if err != nil { + return err + } + + err = msp.postSetupV142(conf) + if err != nil { + return err + } + + return nil +} + +func (msp *bccspmsp) postSetupV11(conf *m.FabricMSPConfig) error { + // Check for OU enforcement + if !msp.ouEnforcement { + // No enforcement required. Call post setup as per V1 + return msp.postSetupV1(conf) + } + + // Check that admins are clients + principalBytes, err := proto.Marshal(&m.MSPRole{Role: m.MSPRole_CLIENT, MspIdentifier: msp.name}) + if err != nil { + return errors.Wrapf(err, "failed creating MSPRole_CLIENT") + } + principal := &m.MSPPrincipal{ + PrincipalClassification: m.MSPPrincipal_ROLE, + Principal: principalBytes} + for i, admin := range msp.admins { + err = admin.SatisfiesPrincipal(principal) + if err != nil { + return errors.WithMessagef(err, "admin %d is invalid", i) + } + } + + return nil +} + +func (msp *bccspmsp) postSetupV142(conf *m.FabricMSPConfig) error { + // Check for OU enforcement + if !msp.ouEnforcement { + // No enforcement required. Call post setup as per V1 + return msp.postSetupV1(conf) + } + + // Check that admins are clients or admins + for i, admin := range msp.admins { + err1 := msp.hasOURole(admin, m.MSPRole_CLIENT) + err2 := msp.hasOURole(admin, m.MSPRole_ADMIN) + if err1 != nil && err2 != nil { + return errors.Errorf("admin %d is invalid [%s,%s]", i, err1, err2) + } + } + + return nil +} diff --git a/internal/github.com/hyperledger/fabric/msp/mspimplvalidate.go b/internal/github.com/hyperledger/fabric/msp/mspimplvalidate.go new file mode 100644 index 00000000..c3c889eb --- /dev/null +++ b/internal/github.com/hyperledger/fabric/msp/mspimplvalidate.go @@ -0,0 +1,355 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package msp + +import ( + "bytes" + "crypto/x509" + "crypto/x509/pkix" + "encoding/asn1" + "math/big" + "reflect" + "time" + + "github.com/pkg/errors" +) + +func (msp *bccspmsp) validateIdentity(id *identity) error { + id.validationMutex.Lock() + defer id.validationMutex.Unlock() + + // return cached validation value if already validated + if id.validated { + return id.validationErr + } + + id.validated = true + + validationChain, err := msp.getCertificationChainForBCCSPIdentity(id) + if err != nil { + id.validationErr = errors.WithMessage(err, "could not obtain certification chain") + return id.validationErr + } + + err = msp.validateIdentityAgainstChain(id, validationChain) + if err != nil { + id.validationErr = errors.WithMessage(err, "could not validate identity against certification chain") + return id.validationErr + } + + err = msp.internalValidateIdentityOusFunc(id) + if err != nil { + id.validationErr = errors.WithMessage(err, "could not validate identity's OUs") + return id.validationErr + } + + return nil +} + +func (msp *bccspmsp) validateCAIdentity(id *identity) error { + if !id.cert.IsCA { + return errors.New("Only CA identities can be validated") + } + + validationChain, err := msp.getUniqueValidationChain(id.cert, msp.getValidityOptsForCert(id.cert)) + if err != nil { + return errors.WithMessage(err, "could not obtain certification chain") + } + if len(validationChain) == 1 { + // validationChain[0] is the root CA certificate + return nil + } + + return msp.validateIdentityAgainstChain(id, validationChain) +} + +func (msp *bccspmsp) validateTLSCAIdentity(cert *x509.Certificate, opts *x509.VerifyOptions) error { + if !cert.IsCA { + return errors.New("Only CA identities can be validated") + } + + validationChain, err := msp.getUniqueValidationChain(cert, *opts) + if err != nil { + return errors.WithMessage(err, "could not obtain certification chain") + } + if len(validationChain) == 1 { + // validationChain[0] is the root CA certificate + return nil + } + + return msp.validateCertAgainstChain(cert, validationChain) +} + +func (msp *bccspmsp) validateIdentityAgainstChain(id *identity, validationChain []*x509.Certificate) error { + return msp.validateCertAgainstChain(id.cert, validationChain) +} + +func (msp *bccspmsp) validateCertAgainstChain(cert *x509.Certificate, validationChain []*x509.Certificate) error { + // here we know that the identity is valid; now we have to check whether it has been revoked + + // identify the SKI of the CA that signed this cert + SKI, err := getSubjectKeyIdentifierFromCert(validationChain[1]) + if err != nil { + return errors.WithMessage(err, "could not obtain Subject Key Identifier for signer cert") + } + + // check whether one of the CRLs we have has this cert's + // SKI as its AuthorityKeyIdentifier + for _, crl := range msp.CRL { + aki, err := getAuthorityKeyIdentifierFromCrl(crl) + if err != nil { + return errors.WithMessage(err, "could not obtain Authority Key Identifier for crl") + } + + // check if the SKI of the cert that signed us matches the AKI of any of the CRLs + if bytes.Equal(aki, SKI) { + // we have a CRL, check whether the serial number is revoked + for _, rc := range crl.TBSCertList.RevokedCertificates { + if rc.SerialNumber.Cmp(cert.SerialNumber) == 0 { + // We have found a CRL whose AKI matches the SKI of + // the CA (root or intermediate) that signed the + // certificate that is under validation. As a + // precaution, we verify that said CA is also the + // signer of this CRL. + err = validationChain[1].CheckCRLSignature(crl) + if err != nil { + // the CA cert that signed the certificate + // that is under validation did not sign the + // candidate CRL - skip + mspLogger.Warningf("Invalid signature over the identified CRL, error %+v", err) + continue + } + + // A CRL also includes a time of revocation so that + // the CA can say "this cert is to be revoked starting + // from this time"; however here we just assume that + // revocation applies instantaneously from the time + // the MSP config is committed and used so we will not + // make use of that field + return errors.New("The certificate has been revoked") + } + } + } + } + + return nil +} + +func (msp *bccspmsp) validateIdentityOUsV1(id *identity) error { + // Check that the identity's OUs are compatible with those recognized by this MSP, + // meaning that the intersection is not empty. + if len(msp.ouIdentifiers) > 0 { + found := false + + for _, OU := range id.GetOrganizationalUnits() { + certificationIDs, exists := msp.ouIdentifiers[OU.OrganizationalUnitIdentifier] + + if exists { + for _, certificationID := range certificationIDs { + if bytes.Equal(certificationID, OU.CertifiersIdentifier) { + found = true + break + } + } + } + } + + if !found { + if len(id.GetOrganizationalUnits()) == 0 { + return errors.New("the identity certificate does not contain an Organizational Unit (OU)") + } + return errors.Errorf("none of the identity's organizational units %s are in MSP %s", OUIDs(id.GetOrganizationalUnits()), msp.name) + } + } + + return nil +} + +func (msp *bccspmsp) validateIdentityOUsV11(id *identity) error { + // Run the same checks as per V1 + err := msp.validateIdentityOUsV1(id) + if err != nil { + return err + } + + // Perform V1_1 additional checks: + // + // -- Check for OU enforcement + if !msp.ouEnforcement { + // No enforcement required + return nil + } + + // Make sure that the identity has only one of the special OUs + // used to tell apart clients or peers. + counter := 0 + for _, OU := range id.GetOrganizationalUnits() { + // Is OU.OrganizationalUnitIdentifier one of the special OUs? + var nodeOU *OUIdentifier + switch OU.OrganizationalUnitIdentifier { + case msp.clientOU.OrganizationalUnitIdentifier: + nodeOU = msp.clientOU + case msp.peerOU.OrganizationalUnitIdentifier: + nodeOU = msp.peerOU + default: + continue + } + + // Yes. Then, enforce the certifiers identifier is this is specified. + // It is not specified, it means that any certification path is fine. + if len(nodeOU.CertifiersIdentifier) != 0 && !bytes.Equal(nodeOU.CertifiersIdentifier, OU.CertifiersIdentifier) { + return errors.Errorf("certifiersIdentifier does not match: %v, MSP: [%s]", OUIDs(id.GetOrganizationalUnits()), msp.name) + } + counter++ + if counter > 1 { + break + } + } + if counter != 1 { + return errors.Errorf("the identity must be a client or a peer identity to be valid, not a combination of them. OUs: %s, MSP: [%s]", OUIDs(id.GetOrganizationalUnits()), msp.name) + } + + return nil +} + +func (msp *bccspmsp) validateIdentityOUsV142(id *identity) error { + // Run the same checks as per V1 + err := msp.validateIdentityOUsV1(id) + if err != nil { + return err + } + + // -- Check for OU enforcement + if !msp.ouEnforcement { + // No enforcement required + return nil + } + + // Make sure that the identity has only one of the special OUs + // used to tell apart clients, peers and admins. + counter := 0 + validOUs := make(map[string]*OUIdentifier) + if msp.clientOU != nil { + validOUs[msp.clientOU.OrganizationalUnitIdentifier] = msp.clientOU + } + if msp.peerOU != nil { + validOUs[msp.peerOU.OrganizationalUnitIdentifier] = msp.peerOU + } + if msp.adminOU != nil { + validOUs[msp.adminOU.OrganizationalUnitIdentifier] = msp.adminOU + } + if msp.ordererOU != nil { + validOUs[msp.ordererOU.OrganizationalUnitIdentifier] = msp.ordererOU + } + + for _, OU := range id.GetOrganizationalUnits() { + // Is OU.OrganizationalUnitIdentifier one of the special OUs? + nodeOU := validOUs[OU.OrganizationalUnitIdentifier] + if nodeOU == nil { + continue + } + + // Yes. Then, enforce the certifiers identifier in this is specified. + // If is not specified, it means that any certification path is fine. + if len(nodeOU.CertifiersIdentifier) != 0 && !bytes.Equal(nodeOU.CertifiersIdentifier, OU.CertifiersIdentifier) { + return errors.Errorf("certifiersIdentifier does not match: %s, MSP: [%s]", OUIDs(id.GetOrganizationalUnits()), msp.name) + } + counter++ + if counter > 1 { + break + } + } + if counter != 1 { + return errors.Errorf("the identity must be a client, a peer, an orderer or an admin identity to be valid, not a combination of them. OUs: %s, MSP: [%s]", OUIDs(id.GetOrganizationalUnits()), msp.name) + } + + return nil +} + +func (msp *bccspmsp) getValidityOptsForCert(cert *x509.Certificate) x509.VerifyOptions { + // First copy the opts to override the CurrentTime field + // in order to make the certificate passing the expiration test + // independently from the real local current time. + // This is a temporary workaround for FAB-3678 + + var tempOpts x509.VerifyOptions + tempOpts.Roots = msp.opts.Roots + tempOpts.DNSName = msp.opts.DNSName + tempOpts.Intermediates = msp.opts.Intermediates + tempOpts.KeyUsages = msp.opts.KeyUsages + tempOpts.CurrentTime = cert.NotBefore.Add(time.Second) + + return tempOpts +} + +/* + This is the definition of the ASN.1 marshalling of AuthorityKeyIdentifier + from https://www.ietf.org/rfc/rfc5280.txt + + AuthorityKeyIdentifier ::= SEQUENCE { + keyIdentifier [0] KeyIdentifier OPTIONAL, + authorityCertIssuer [1] GeneralNames OPTIONAL, + authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL } + + KeyIdentifier ::= OCTET STRING + + CertificateSerialNumber ::= INTEGER + +*/ + +type authorityKeyIdentifier struct { + KeyIdentifier []byte `asn1:"optional,tag:0"` + AuthorityCertIssuer []byte `asn1:"optional,tag:1"` + AuthorityCertSerialNumber big.Int `asn1:"optional,tag:2"` +} + +// getAuthorityKeyIdentifierFromCrl returns the Authority Key Identifier +// for the supplied CRL. The authority key identifier can be used to identify +// the public key corresponding to the private key which was used to sign the CRL. +func getAuthorityKeyIdentifierFromCrl(crl *pkix.CertificateList) ([]byte, error) { + aki := authorityKeyIdentifier{} + + for _, ext := range crl.TBSCertList.Extensions { + // Authority Key Identifier is identified by the following ASN.1 tag + // authorityKeyIdentifier (2 5 29 35) (see https://tools.ietf.org/html/rfc3280.html) + if reflect.DeepEqual(ext.Id, asn1.ObjectIdentifier{2, 5, 29, 35}) { + _, err := asn1.Unmarshal(ext.Value, &aki) + if err != nil { + return nil, errors.Wrap(err, "failed to unmarshal AKI") + } + + return aki.KeyIdentifier, nil + } + } + + return nil, errors.New("authorityKeyIdentifier not found in certificate") +} + +// getSubjectKeyIdentifierFromCert returns the Subject Key Identifier for the supplied certificate +// Subject Key Identifier is an identifier of the public key of this certificate +func getSubjectKeyIdentifierFromCert(cert *x509.Certificate) ([]byte, error) { + var SKI []byte + + for _, ext := range cert.Extensions { + // Subject Key Identifier is identified by the following ASN.1 tag + // subjectKeyIdentifier (2 5 29 14) (see https://tools.ietf.org/html/rfc3280.html) + if reflect.DeepEqual(ext.Id, asn1.ObjectIdentifier{2, 5, 29, 14}) { + _, err := asn1.Unmarshal(ext.Value, &SKI) + if err != nil { + return nil, errors.Wrap(err, "failed to unmarshal Subject Key Identifier") + } + + return SKI, nil + } + } + + return nil, errors.New("subjectKeyIdentifier not found in certificate") +} diff --git a/internal/github.com/hyperledger/fabric/msp/mspmgrimpl.go b/internal/github.com/hyperledger/fabric/msp/mspmgrimpl.go new file mode 100644 index 00000000..65d65b71 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/msp/mspmgrimpl.go @@ -0,0 +1,112 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package msp + +import ( + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-protos-go/msp" + flogging "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/logbridge" + "github.com/pkg/errors" +) + +var mspLogger = flogging.MustGetLogger("msp") + +type mspManagerImpl struct { + // map that contains all MSPs that we have setup or otherwise added + mspsMap map[string]MSP + + // map that maps MSPs by their provider types + mspsByProviders map[ProviderType][]MSP + + // error that might have occurred at startup + up bool +} + +// NewMSPManager returns a new MSP manager instance; +// note that this instance is not initialized until +// the Setup method is called +func NewMSPManager() MSPManager { + return &mspManagerImpl{} +} + +// Setup initializes the internal data structures of this manager and creates MSPs +func (mgr *mspManagerImpl) Setup(msps []MSP) error { + if mgr.up { + mspLogger.Infof("MSP manager already up") + return nil + } + + mspLogger.Debugf("Setting up the MSP manager (%d msps)", len(msps)) + + // create the map that assigns MSP IDs to their manager instance - once + mgr.mspsMap = make(map[string]MSP) + + // create the map that sorts MSPs by their provider types + mgr.mspsByProviders = make(map[ProviderType][]MSP) + + for _, msp := range msps { + // add the MSP to the map of active MSPs + mspID, err := msp.GetIdentifier() + if err != nil { + return errors.WithMessage(err, "could not extract msp identifier") + } + mgr.mspsMap[mspID] = msp + providerType := msp.GetType() + mgr.mspsByProviders[providerType] = append(mgr.mspsByProviders[providerType], msp) + } + + mgr.up = true + + mspLogger.Debugf("MSP manager setup complete, setup %d msps", len(msps)) + + return nil +} + +// GetMSPs returns the MSPs that are managed by this manager +func (mgr *mspManagerImpl) GetMSPs() (map[string]MSP, error) { + return mgr.mspsMap, nil +} + +// DeserializeIdentity returns an identity given its serialized version supplied as argument +func (mgr *mspManagerImpl) DeserializeIdentity(serializedID []byte) (Identity, error) { + // We first deserialize to a SerializedIdentity to get the MSP ID + sId := &msp.SerializedIdentity{} + err := proto.Unmarshal(serializedID, sId) + if err != nil { + return nil, errors.Wrap(err, "could not deserialize a SerializedIdentity") + } + + // we can now attempt to obtain the MSP + msp := mgr.mspsMap[sId.Mspid] + if msp == nil { + return nil, errors.Errorf("MSP %s is not defined on channel", sId.Mspid) + } + + switch t := msp.(type) { + case *bccspmsp: + return t.deserializeIdentityInternal(sId.IdBytes) + default: + return t.DeserializeIdentity(serializedID) + } +} + +func (mgr *mspManagerImpl) IsWellFormed(identity *msp.SerializedIdentity) error { + // Iterate over all the MSPs by their providers, and find at least 1 MSP that can attest + // that this identity is well formed + for _, mspList := range mgr.mspsByProviders { + // We are guaranteed to have at least 1 MSP in each list from the initialization at Setup() + msp := mspList[0] + if err := msp.IsWellFormed(identity); err == nil { + return nil + } + } + return errors.New("no MSP provider recognizes the identity") +} diff --git a/internal/github.com/hyperledger/fabric/protoutil/blockutils.go b/internal/github.com/hyperledger/fabric/protoutil/blockutils.go new file mode 100644 index 00000000..941e3ca9 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/protoutil/blockutils.go @@ -0,0 +1,224 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package protoutil + +import ( + "bytes" + "crypto/sha256" + "encoding/asn1" + "math/big" + + "github.com/golang/protobuf/proto" + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/pkg/errors" +) + +// NewBlock constructs a block with no data and no metadata. +func NewBlock(seqNum uint64, previousHash []byte) *cb.Block { + block := &cb.Block{} + block.Header = &cb.BlockHeader{} + block.Header.Number = seqNum + block.Header.PreviousHash = previousHash + block.Header.DataHash = []byte{} + block.Data = &cb.BlockData{} + + var metadataContents [][]byte + for i := 0; i < len(cb.BlockMetadataIndex_name); i++ { + metadataContents = append(metadataContents, []byte{}) + } + block.Metadata = &cb.BlockMetadata{Metadata: metadataContents} + + return block +} + +type asn1Header struct { + Number *big.Int + PreviousHash []byte + DataHash []byte +} + +func BlockHeaderBytes(b *cb.BlockHeader) []byte { + asn1Header := asn1Header{ + PreviousHash: b.PreviousHash, + DataHash: b.DataHash, + Number: new(big.Int).SetUint64(b.Number), + } + result, err := asn1.Marshal(asn1Header) + if err != nil { + // Errors should only arise for types which cannot be encoded, since the + // BlockHeader type is known a-priori to contain only encodable types, an + // error here is fatal and should not be propagated + panic(err) + } + return result +} + +func BlockHeaderHash(b *cb.BlockHeader) []byte { + sum := sha256.Sum256(BlockHeaderBytes(b)) + return sum[:] +} + +func BlockDataHash(b *cb.BlockData) []byte { + sum := sha256.Sum256(bytes.Join(b.Data, nil)) + return sum[:] +} + +// GetChannelIDFromBlockBytes returns channel ID given byte array which represents +// the block +func GetChannelIDFromBlockBytes(bytes []byte) (string, error) { + block, err := UnmarshalBlock(bytes) + if err != nil { + return "", err + } + + return GetChannelIDFromBlock(block) +} + +// GetChannelIDFromBlock returns channel ID in the block +func GetChannelIDFromBlock(block *cb.Block) (string, error) { + if block == nil || block.Data == nil || block.Data.Data == nil || len(block.Data.Data) == 0 { + return "", errors.New("failed to retrieve channel id - block is empty") + } + var err error + envelope, err := GetEnvelopeFromBlock(block.Data.Data[0]) + if err != nil { + return "", err + } + payload, err := UnmarshalPayload(envelope.Payload) + if err != nil { + return "", err + } + + if payload.Header == nil { + return "", errors.New("failed to retrieve channel id - payload header is empty") + } + chdr, err := UnmarshalChannelHeader(payload.Header.ChannelHeader) + if err != nil { + return "", err + } + + return chdr.ChannelId, nil +} + +// GetMetadataFromBlock retrieves metadata at the specified index. +func GetMetadataFromBlock(block *cb.Block, index cb.BlockMetadataIndex) (*cb.Metadata, error) { + if block.Metadata == nil { + return nil, errors.New("no metadata in block") + } + + if len(block.Metadata.Metadata) <= int(index) { + return nil, errors.Errorf("no metadata at index [%s]", index) + } + + md := &cb.Metadata{} + err := proto.Unmarshal(block.Metadata.Metadata[index], md) + if err != nil { + return nil, errors.Wrapf(err, "error unmarshaling metadata at index [%s]", index) + } + return md, nil +} + +// GetMetadataFromBlockOrPanic retrieves metadata at the specified index, or +// panics on error +func GetMetadataFromBlockOrPanic(block *cb.Block, index cb.BlockMetadataIndex) *cb.Metadata { + md, err := GetMetadataFromBlock(block, index) + if err != nil { + panic(err) + } + return md +} + +// GetConsenterMetadataFromBlock attempts to retrieve consenter metadata from the value +// stored in block metadata at index SIGNATURES (first field). If no consenter metadata +// is found there, it falls back to index ORDERER (third field). +func GetConsenterMetadataFromBlock(block *cb.Block) (*cb.Metadata, error) { + m, err := GetMetadataFromBlock(block, cb.BlockMetadataIndex_SIGNATURES) + if err != nil { + return nil, errors.WithMessage(err, "failed to retrieve metadata") + } + + // TODO FAB-15864 Remove this fallback when we can stop supporting upgrade from pre-1.4.1 orderer + if len(m.Value) == 0 { + return GetMetadataFromBlock(block, cb.BlockMetadataIndex_ORDERER) + } + + obm := &cb.OrdererBlockMetadata{} + err = proto.Unmarshal(m.Value, obm) + if err != nil { + return nil, errors.Wrap(err, "failed to unmarshal orderer block metadata") + } + + res := &cb.Metadata{} + err = proto.Unmarshal(obm.ConsenterMetadata, res) + if err != nil { + return nil, errors.Wrap(err, "failed to unmarshal consenter metadata") + } + + return res, nil +} + +// GetLastConfigIndexFromBlock retrieves the index of the last config block as +// encoded in the block metadata +func GetLastConfigIndexFromBlock(block *cb.Block) (uint64, error) { + m, err := GetMetadataFromBlock(block, cb.BlockMetadataIndex_SIGNATURES) + if err != nil { + return 0, errors.WithMessage(err, "failed to retrieve metadata") + } + // TODO FAB-15864 Remove this fallback when we can stop supporting upgrade from pre-1.4.1 orderer + if len(m.Value) == 0 { + m, err := GetMetadataFromBlock(block, cb.BlockMetadataIndex_LAST_CONFIG) + if err != nil { + return 0, errors.WithMessage(err, "failed to retrieve metadata") + } + lc := &cb.LastConfig{} + err = proto.Unmarshal(m.Value, lc) + if err != nil { + return 0, errors.Wrap(err, "error unmarshaling LastConfig") + } + return lc.Index, nil + } + + obm := &cb.OrdererBlockMetadata{} + err = proto.Unmarshal(m.Value, obm) + if err != nil { + return 0, errors.Wrap(err, "failed to unmarshal orderer block metadata") + } + return obm.LastConfig.Index, nil +} + +// GetLastConfigIndexFromBlockOrPanic retrieves the index of the last config +// block as encoded in the block metadata, or panics on error +func GetLastConfigIndexFromBlockOrPanic(block *cb.Block) uint64 { + index, err := GetLastConfigIndexFromBlock(block) + if err != nil { + panic(err) + } + return index +} + +// CopyBlockMetadata copies metadata from one block into another +func CopyBlockMetadata(src *cb.Block, dst *cb.Block) { + dst.Metadata = src.Metadata + // Once copied initialize with rest of the + // required metadata positions. + InitBlockMetadata(dst) +} + +// InitBlockMetadata initializes metadata structure +func InitBlockMetadata(block *cb.Block) { + if block.Metadata == nil { + block.Metadata = &cb.BlockMetadata{Metadata: [][]byte{{}, {}, {}, {}, {}}} + } else if len(block.Metadata.Metadata) < int(cb.BlockMetadataIndex_COMMIT_HASH+1) { + for i := int(len(block.Metadata.Metadata)); i <= int(cb.BlockMetadataIndex_COMMIT_HASH); i++ { + block.Metadata.Metadata = append(block.Metadata.Metadata, []byte{}) + } + } +} diff --git a/internal/github.com/hyperledger/fabric/protoutil/commonutils.go b/internal/github.com/hyperledger/fabric/protoutil/commonutils.go new file mode 100644 index 00000000..156b506e --- /dev/null +++ b/internal/github.com/hyperledger/fabric/protoutil/commonutils.go @@ -0,0 +1,269 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package protoutil + +import ( + "crypto/rand" + "fmt" + "time" + + "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes/timestamp" + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkinternal/pkg/identity" + "github.com/pkg/errors" +) + +// MarshalOrPanic serializes a protobuf message and panics if this +// operation fails +func MarshalOrPanic(pb proto.Message) []byte { + data, err := proto.Marshal(pb) + if err != nil { + panic(err) + } + return data +} + +// Marshal serializes a protobuf message. +func Marshal(pb proto.Message) ([]byte, error) { + return proto.Marshal(pb) +} + +// CreateNonceOrPanic generates a nonce using the common/crypto package +// and panics if this operation fails. +func CreateNonceOrPanic() []byte { + nonce, err := CreateNonce() + if err != nil { + panic(err) + } + return nonce +} + +// CreateNonce generates a nonce using the common/crypto package. +func CreateNonce() ([]byte, error) { + nonce, err := getRandomNonce() + return nonce, errors.WithMessage(err, "error generating random nonce") +} + +// UnmarshalEnvelopeOfType unmarshals an envelope of the specified type, +// including unmarshaling the payload data +func UnmarshalEnvelopeOfType(envelope *cb.Envelope, headerType cb.HeaderType, message proto.Message) (*cb.ChannelHeader, error) { + payload, err := UnmarshalPayload(envelope.Payload) + if err != nil { + return nil, err + } + + if payload.Header == nil { + return nil, errors.New("envelope must have a Header") + } + + chdr, err := UnmarshalChannelHeader(payload.Header.ChannelHeader) + if err != nil { + return nil, err + } + + if chdr.Type != int32(headerType) { + return nil, errors.Errorf("invalid type %s, expected %s", cb.HeaderType(chdr.Type), headerType) + } + + err = proto.Unmarshal(payload.Data, message) + err = errors.Wrapf(err, "error unmarshaling message for type %s", headerType) + return chdr, err +} + +// ExtractEnvelopeOrPanic retrieves the requested envelope from a given block +// and unmarshals it -- it panics if either of these operations fail +func ExtractEnvelopeOrPanic(block *cb.Block, index int) *cb.Envelope { + envelope, err := ExtractEnvelope(block, index) + if err != nil { + panic(err) + } + return envelope +} + +// ExtractEnvelope retrieves the requested envelope from a given block and +// unmarshals it +func ExtractEnvelope(block *cb.Block, index int) (*cb.Envelope, error) { + if block.Data == nil { + return nil, errors.New("block data is nil") + } + + envelopeCount := len(block.Data.Data) + if index < 0 || index >= envelopeCount { + return nil, errors.New("envelope index out of bounds") + } + marshaledEnvelope := block.Data.Data[index] + envelope, err := GetEnvelopeFromBlock(marshaledEnvelope) + err = errors.WithMessagef(err, "block data does not carry an envelope at index %d", index) + return envelope, err +} + +// MakeChannelHeader creates a ChannelHeader. +func MakeChannelHeader(headerType cb.HeaderType, version int32, chainID string, epoch uint64) *cb.ChannelHeader { + return &cb.ChannelHeader{ + Type: int32(headerType), + Version: version, + Timestamp: ×tamp.Timestamp{ + Seconds: time.Now().Unix(), + Nanos: 0, + }, + ChannelId: chainID, + Epoch: epoch, + } +} + +// MakeSignatureHeader creates a SignatureHeader. +func MakeSignatureHeader(serializedCreatorCertChain []byte, nonce []byte) *cb.SignatureHeader { + return &cb.SignatureHeader{ + Creator: serializedCreatorCertChain, + Nonce: nonce, + } +} + +// SetTxID generates a transaction id based on the provided signature header +// and sets the TxId field in the channel header +func SetTxID(channelHeader *cb.ChannelHeader, signatureHeader *cb.SignatureHeader) { + channelHeader.TxId = ComputeTxID( + signatureHeader.Nonce, + signatureHeader.Creator, + ) +} + +// MakePayloadHeader creates a Payload Header. +func MakePayloadHeader(ch *cb.ChannelHeader, sh *cb.SignatureHeader) *cb.Header { + return &cb.Header{ + ChannelHeader: MarshalOrPanic(ch), + SignatureHeader: MarshalOrPanic(sh), + } +} + +// NewSignatureHeader returns a SignatureHeader with a valid nonce. +func NewSignatureHeader(id identity.Serializer) (*cb.SignatureHeader, error) { + creator, err := id.Serialize() + if err != nil { + return nil, err + } + nonce, err := CreateNonce() + if err != nil { + return nil, err + } + + return &cb.SignatureHeader{ + Creator: creator, + Nonce: nonce, + }, nil +} + +// NewSignatureHeaderOrPanic returns a signature header and panics on error. +func NewSignatureHeaderOrPanic(id identity.Serializer) *cb.SignatureHeader { + if id == nil { + panic(errors.New("invalid signer. cannot be nil")) + } + + signatureHeader, err := NewSignatureHeader(id) + if err != nil { + panic(fmt.Errorf("failed generating a new SignatureHeader: %s", err)) + } + + return signatureHeader +} + +// SignOrPanic signs a message and panics on error. +func SignOrPanic(signer identity.Signer, msg []byte) []byte { + if signer == nil { + panic(errors.New("invalid signer. cannot be nil")) + } + + sigma, err := signer.Sign(msg) + if err != nil { + panic(fmt.Errorf("failed generating signature: %s", err)) + } + return sigma +} + +// IsConfigBlock validates whenever given block contains configuration +// update transaction +func IsConfigBlock(block *cb.Block) bool { + envelope, err := ExtractEnvelope(block, 0) + if err != nil { + return false + } + + payload, err := UnmarshalPayload(envelope.Payload) + if err != nil { + return false + } + + if payload.Header == nil { + return false + } + + hdr, err := UnmarshalChannelHeader(payload.Header.ChannelHeader) + if err != nil { + return false + } + + return cb.HeaderType(hdr.Type) == cb.HeaderType_CONFIG || cb.HeaderType(hdr.Type) == cb.HeaderType_ORDERER_TRANSACTION +} + +// ChannelHeader returns the *cb.ChannelHeader for a given *cb.Envelope. +func ChannelHeader(env *cb.Envelope) (*cb.ChannelHeader, error) { + envPayload, err := UnmarshalPayload(env.Payload) + if err != nil { + return nil, err + } + + if envPayload.Header == nil { + return nil, errors.New("header not set") + } + + if envPayload.Header.ChannelHeader == nil { + return nil, errors.New("channel header not set") + } + + chdr, err := UnmarshalChannelHeader(envPayload.Header.ChannelHeader) + if err != nil { + return nil, errors.WithMessage(err, "error unmarshaling channel header") + } + + return chdr, nil +} + +// ChannelID returns the Channel ID for a given *cb.Envelope. +func ChannelID(env *cb.Envelope) (string, error) { + chdr, err := ChannelHeader(env) + if err != nil { + return "", errors.WithMessage(err, "error retrieving channel header") + } + + return chdr.ChannelId, nil +} + +// EnvelopeToConfigUpdate is used to extract a ConfigUpdateEnvelope from an envelope of +// type CONFIG_UPDATE +func EnvelopeToConfigUpdate(configtx *cb.Envelope) (*cb.ConfigUpdateEnvelope, error) { + configUpdateEnv := &cb.ConfigUpdateEnvelope{} + _, err := UnmarshalEnvelopeOfType(configtx, cb.HeaderType_CONFIG_UPDATE, configUpdateEnv) + if err != nil { + return nil, err + } + return configUpdateEnv, nil +} + +func getRandomNonce() ([]byte, error) { + key := make([]byte, 24) + + _, err := rand.Read(key) + if err != nil { + return nil, errors.Wrap(err, "error getting random bytes") + } + return key, nil +} diff --git a/internal/github.com/hyperledger/fabric/protoutil/configtxutils.go b/internal/github.com/hyperledger/fabric/protoutil/configtxutils.go new file mode 100644 index 00000000..5ee4e66f --- /dev/null +++ b/internal/github.com/hyperledger/fabric/protoutil/configtxutils.go @@ -0,0 +1,25 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package protoutil + +import "github.com/hyperledger/fabric-protos-go/common" + +func NewConfigGroup() *common.ConfigGroup { + return &common.ConfigGroup{ + Groups: make(map[string]*common.ConfigGroup), + Values: make(map[string]*common.ConfigValue), + Policies: make(map[string]*common.ConfigPolicy), + } +} diff --git a/internal/github.com/hyperledger/fabric/protoutil/proputils.go b/internal/github.com/hyperledger/fabric/protoutil/proputils.go new file mode 100644 index 00000000..99108524 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/protoutil/proputils.go @@ -0,0 +1,414 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package protoutil + +import ( + "crypto/sha256" + "encoding/hex" + "time" + + "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes" + "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-protos-go/peer" + "github.com/pkg/errors" +) + +// CreateChaincodeProposal creates a proposal from given input. +// It returns the proposal and the transaction id associated to the proposal +func CreateChaincodeProposal(typ common.HeaderType, channelID string, cis *peer.ChaincodeInvocationSpec, creator []byte) (*peer.Proposal, string, error) { + return CreateChaincodeProposalWithTransient(typ, channelID, cis, creator, nil) +} + +// CreateChaincodeProposalWithTransient creates a proposal from given input +// It returns the proposal and the transaction id associated to the proposal +func CreateChaincodeProposalWithTransient(typ common.HeaderType, channelID string, cis *peer.ChaincodeInvocationSpec, creator []byte, transientMap map[string][]byte) (*peer.Proposal, string, error) { + // generate a random nonce + nonce, err := getRandomNonce() + if err != nil { + return nil, "", err + } + + // compute txid + txid := ComputeTxID(nonce, creator) + + return CreateChaincodeProposalWithTxIDNonceAndTransient(txid, typ, channelID, cis, nonce, creator, transientMap) +} + +// CreateChaincodeProposalWithTxIDAndTransient creates a proposal from given +// input. It returns the proposal and the transaction id associated with the +// proposal +func CreateChaincodeProposalWithTxIDAndTransient(typ common.HeaderType, channelID string, cis *peer.ChaincodeInvocationSpec, creator []byte, txid string, transientMap map[string][]byte) (*peer.Proposal, string, error) { + // generate a random nonce + nonce, err := getRandomNonce() + if err != nil { + return nil, "", err + } + + // compute txid unless provided by tests + if txid == "" { + txid = ComputeTxID(nonce, creator) + } + + return CreateChaincodeProposalWithTxIDNonceAndTransient(txid, typ, channelID, cis, nonce, creator, transientMap) +} + +// CreateChaincodeProposalWithTxIDNonceAndTransient creates a proposal from +// given input +func CreateChaincodeProposalWithTxIDNonceAndTransient(txid string, typ common.HeaderType, channelID string, cis *peer.ChaincodeInvocationSpec, nonce, creator []byte, transientMap map[string][]byte) (*peer.Proposal, string, error) { + ccHdrExt := &peer.ChaincodeHeaderExtension{ChaincodeId: cis.ChaincodeSpec.ChaincodeId} + ccHdrExtBytes, err := proto.Marshal(ccHdrExt) + if err != nil { + return nil, "", errors.Wrap(err, "error marshaling ChaincodeHeaderExtension") + } + + cisBytes, err := proto.Marshal(cis) + if err != nil { + return nil, "", errors.Wrap(err, "error marshaling ChaincodeInvocationSpec") + } + + ccPropPayload := &peer.ChaincodeProposalPayload{Input: cisBytes, TransientMap: transientMap} + ccPropPayloadBytes, err := proto.Marshal(ccPropPayload) + if err != nil { + return nil, "", errors.Wrap(err, "error marshaling ChaincodeProposalPayload") + } + + // TODO: epoch is now set to zero. This must be changed once we + // get a more appropriate mechanism to handle it in. + var epoch uint64 + + timestamp, err := ptypes.TimestampProto(time.Now().UTC()) + if err != nil { + return nil, "", errors.Wrap(err, "error validating Timestamp") + } + + hdr := &common.Header{ + ChannelHeader: MarshalOrPanic( + &common.ChannelHeader{ + Type: int32(typ), + TxId: txid, + Timestamp: timestamp, + ChannelId: channelID, + Extension: ccHdrExtBytes, + Epoch: epoch, + }, + ), + SignatureHeader: MarshalOrPanic( + &common.SignatureHeader{ + Nonce: nonce, + Creator: creator, + }, + ), + } + + hdrBytes, err := proto.Marshal(hdr) + if err != nil { + return nil, "", err + } + + prop := &peer.Proposal{ + Header: hdrBytes, + Payload: ccPropPayloadBytes, + } + return prop, txid, nil +} + +// GetBytesProposalResponsePayload gets proposal response payload +func GetBytesProposalResponsePayload(hash []byte, response *peer.Response, result []byte, event []byte, ccid *peer.ChaincodeID) ([]byte, error) { + cAct := &peer.ChaincodeAction{ + Events: event, Results: result, + Response: response, + ChaincodeId: ccid, + } + cActBytes, err := proto.Marshal(cAct) + if err != nil { + return nil, errors.Wrap(err, "error marshaling ChaincodeAction") + } + + prp := &peer.ProposalResponsePayload{ + Extension: cActBytes, + ProposalHash: hash, + } + prpBytes, err := proto.Marshal(prp) + return prpBytes, errors.Wrap(err, "error marshaling ProposalResponsePayload") +} + +// GetBytesChaincodeProposalPayload gets the chaincode proposal payload +func GetBytesChaincodeProposalPayload(cpp *peer.ChaincodeProposalPayload) ([]byte, error) { + cppBytes, err := proto.Marshal(cpp) + return cppBytes, errors.Wrap(err, "error marshaling ChaincodeProposalPayload") +} + +// GetBytesResponse gets the bytes of Response +func GetBytesResponse(res *peer.Response) ([]byte, error) { + resBytes, err := proto.Marshal(res) + return resBytes, errors.Wrap(err, "error marshaling Response") +} + +// GetBytesChaincodeEvent gets the bytes of ChaincodeEvent +func GetBytesChaincodeEvent(event *peer.ChaincodeEvent) ([]byte, error) { + eventBytes, err := proto.Marshal(event) + return eventBytes, errors.Wrap(err, "error marshaling ChaincodeEvent") +} + +// GetBytesChaincodeActionPayload get the bytes of ChaincodeActionPayload from +// the message +func GetBytesChaincodeActionPayload(cap *peer.ChaincodeActionPayload) ([]byte, error) { + capBytes, err := proto.Marshal(cap) + return capBytes, errors.Wrap(err, "error marshaling ChaincodeActionPayload") +} + +// GetBytesProposalResponse gets proposal bytes response +func GetBytesProposalResponse(pr *peer.ProposalResponse) ([]byte, error) { + respBytes, err := proto.Marshal(pr) + return respBytes, errors.Wrap(err, "error marshaling ProposalResponse") +} + +// GetBytesHeader get the bytes of Header from the message +func GetBytesHeader(hdr *common.Header) ([]byte, error) { + bytes, err := proto.Marshal(hdr) + return bytes, errors.Wrap(err, "error marshaling Header") +} + +// GetBytesSignatureHeader get the bytes of SignatureHeader from the message +func GetBytesSignatureHeader(hdr *common.SignatureHeader) ([]byte, error) { + bytes, err := proto.Marshal(hdr) + return bytes, errors.Wrap(err, "error marshaling SignatureHeader") +} + +// GetBytesTransaction get the bytes of Transaction from the message +func GetBytesTransaction(tx *peer.Transaction) ([]byte, error) { + bytes, err := proto.Marshal(tx) + return bytes, errors.Wrap(err, "error unmarshaling Transaction") +} + +// GetBytesPayload get the bytes of Payload from the message +func GetBytesPayload(payl *common.Payload) ([]byte, error) { + bytes, err := proto.Marshal(payl) + return bytes, errors.Wrap(err, "error marshaling Payload") +} + +// GetBytesEnvelope get the bytes of Envelope from the message +func GetBytesEnvelope(env *common.Envelope) ([]byte, error) { + bytes, err := proto.Marshal(env) + return bytes, errors.Wrap(err, "error marshaling Envelope") +} + +// GetActionFromEnvelope extracts a ChaincodeAction message from a +// serialized Envelope +// TODO: fix function name as per FAB-11831 +func GetActionFromEnvelope(envBytes []byte) (*peer.ChaincodeAction, error) { + env, err := GetEnvelopeFromBlock(envBytes) + if err != nil { + return nil, err + } + return GetActionFromEnvelopeMsg(env) +} + +func GetActionFromEnvelopeMsg(env *common.Envelope) (*peer.ChaincodeAction, error) { + payl, err := UnmarshalPayload(env.Payload) + if err != nil { + return nil, err + } + + tx, err := UnmarshalTransaction(payl.Data) + if err != nil { + return nil, err + } + + if len(tx.Actions) == 0 { + return nil, errors.New("at least one TransactionAction required") + } + + _, respPayload, err := GetPayloads(tx.Actions[0]) + return respPayload, err +} + +// CreateProposalFromCISAndTxid returns a proposal given a serialized identity +// and a ChaincodeInvocationSpec +func CreateProposalFromCISAndTxid(txid string, typ common.HeaderType, channelID string, cis *peer.ChaincodeInvocationSpec, creator []byte) (*peer.Proposal, string, error) { + nonce, err := getRandomNonce() + if err != nil { + return nil, "", err + } + return CreateChaincodeProposalWithTxIDNonceAndTransient(txid, typ, channelID, cis, nonce, creator, nil) +} + +// CreateProposalFromCIS returns a proposal given a serialized identity and a +// ChaincodeInvocationSpec +func CreateProposalFromCIS(typ common.HeaderType, channelID string, cis *peer.ChaincodeInvocationSpec, creator []byte) (*peer.Proposal, string, error) { + return CreateChaincodeProposal(typ, channelID, cis, creator) +} + +// CreateGetChaincodesProposal returns a GETCHAINCODES proposal given a +// serialized identity +func CreateGetChaincodesProposal(channelID string, creator []byte) (*peer.Proposal, string, error) { + ccinp := &peer.ChaincodeInput{Args: [][]byte{[]byte("getchaincodes")}} + lsccSpec := &peer.ChaincodeInvocationSpec{ + ChaincodeSpec: &peer.ChaincodeSpec{ + Type: peer.ChaincodeSpec_GOLANG, + ChaincodeId: &peer.ChaincodeID{Name: "lscc"}, + Input: ccinp, + }, + } + return CreateProposalFromCIS(common.HeaderType_ENDORSER_TRANSACTION, channelID, lsccSpec, creator) +} + +// CreateGetInstalledChaincodesProposal returns a GETINSTALLEDCHAINCODES +// proposal given a serialized identity +func CreateGetInstalledChaincodesProposal(creator []byte) (*peer.Proposal, string, error) { + ccinp := &peer.ChaincodeInput{Args: [][]byte{[]byte("getinstalledchaincodes")}} + lsccSpec := &peer.ChaincodeInvocationSpec{ + ChaincodeSpec: &peer.ChaincodeSpec{ + Type: peer.ChaincodeSpec_GOLANG, + ChaincodeId: &peer.ChaincodeID{Name: "lscc"}, + Input: ccinp, + }, + } + return CreateProposalFromCIS(common.HeaderType_ENDORSER_TRANSACTION, "", lsccSpec, creator) +} + +// CreateInstallProposalFromCDS returns a install proposal given a serialized +// identity and a ChaincodeDeploymentSpec +func CreateInstallProposalFromCDS(ccpack proto.Message, creator []byte) (*peer.Proposal, string, error) { + return createProposalFromCDS("", ccpack, creator, "install") +} + +// CreateDeployProposalFromCDS returns a deploy proposal given a serialized +// identity and a ChaincodeDeploymentSpec +func CreateDeployProposalFromCDS( + channelID string, + cds *peer.ChaincodeDeploymentSpec, + creator []byte, + policy []byte, + escc []byte, + vscc []byte, + collectionConfig []byte) (*peer.Proposal, string, error) { + if collectionConfig == nil { + return createProposalFromCDS(channelID, cds, creator, "deploy", policy, escc, vscc) + } + return createProposalFromCDS(channelID, cds, creator, "deploy", policy, escc, vscc, collectionConfig) +} + +// CreateUpgradeProposalFromCDS returns a upgrade proposal given a serialized +// identity and a ChaincodeDeploymentSpec +func CreateUpgradeProposalFromCDS( + channelID string, + cds *peer.ChaincodeDeploymentSpec, + creator []byte, + policy []byte, + escc []byte, + vscc []byte, + collectionConfig []byte) (*peer.Proposal, string, error) { + if collectionConfig == nil { + return createProposalFromCDS(channelID, cds, creator, "upgrade", policy, escc, vscc) + } + return createProposalFromCDS(channelID, cds, creator, "upgrade", policy, escc, vscc, collectionConfig) +} + +// createProposalFromCDS returns a deploy or upgrade proposal given a +// serialized identity and a ChaincodeDeploymentSpec +func createProposalFromCDS(channelID string, msg proto.Message, creator []byte, propType string, args ...[]byte) (*peer.Proposal, string, error) { + // in the new mode, cds will be nil, "deploy" and "upgrade" are instantiates. + var ccinp *peer.ChaincodeInput + var b []byte + var err error + if msg != nil { + b, err = proto.Marshal(msg) + if err != nil { + return nil, "", err + } + } + switch propType { + case "deploy": + fallthrough + case "upgrade": + cds, ok := msg.(*peer.ChaincodeDeploymentSpec) + if !ok || cds == nil { + return nil, "", errors.New("invalid message for creating lifecycle chaincode proposal") + } + Args := [][]byte{[]byte(propType), []byte(channelID), b} + Args = append(Args, args...) + + ccinp = &peer.ChaincodeInput{Args: Args} + case "install": + ccinp = &peer.ChaincodeInput{Args: [][]byte{[]byte(propType), b}} + } + + // wrap the deployment in an invocation spec to lscc... + lsccSpec := &peer.ChaincodeInvocationSpec{ + ChaincodeSpec: &peer.ChaincodeSpec{ + Type: peer.ChaincodeSpec_GOLANG, + ChaincodeId: &peer.ChaincodeID{Name: "lscc"}, + Input: ccinp, + }, + } + + // ...and get the proposal for it + return CreateProposalFromCIS(common.HeaderType_ENDORSER_TRANSACTION, channelID, lsccSpec, creator) +} + +// ComputeTxID computes TxID as the Hash computed +// over the concatenation of nonce and creator. +func ComputeTxID(nonce, creator []byte) string { + // TODO: Get the Hash function to be used from + // channel configuration + hasher := sha256.New() + hasher.Write(nonce) + hasher.Write(creator) + return hex.EncodeToString(hasher.Sum(nil)) +} + +// CheckTxID checks that txid is equal to the Hash computed +// over the concatenation of nonce and creator. +func CheckTxID(txid string, nonce, creator []byte) error { + computedTxID := ComputeTxID(nonce, creator) + + if txid != computedTxID { + return errors.Errorf("invalid txid. got [%s], expected [%s]", txid, computedTxID) + } + + return nil +} + +// InvokedChaincodeName takes the proposal bytes of a SignedProposal, and unpacks it all the way down, +// until either an error is encountered, or the chaincode name is found. This is useful primarily +// for chaincodes which wish to know the chaincode name originally invoked, in order to deny cc2cc +// invocations (or, perhaps to deny direct invocations and require cc2cc). +func InvokedChaincodeName(proposalBytes []byte) (string, error) { + proposal := &peer.Proposal{} + err := proto.Unmarshal(proposalBytes, proposal) + if err != nil { + return "", errors.WithMessage(err, "could not unmarshal proposal") + } + + proposalPayload := &peer.ChaincodeProposalPayload{} + err = proto.Unmarshal(proposal.Payload, proposalPayload) + if err != nil { + return "", errors.WithMessage(err, "could not unmarshal chaincode proposal payload") + } + + cis := &peer.ChaincodeInvocationSpec{} + err = proto.Unmarshal(proposalPayload.Input, cis) + if err != nil { + return "", errors.WithMessage(err, "could not unmarshal chaincode invocation spec") + } + + if cis.ChaincodeSpec == nil { + return "", errors.Errorf("chaincode spec is nil") + } + + if cis.ChaincodeSpec.ChaincodeId == nil { + return "", errors.Errorf("chaincode id is nil") + } + + return cis.ChaincodeSpec.ChaincodeId.Name, nil +} diff --git a/internal/github.com/hyperledger/fabric/protoutil/signeddata.go b/internal/github.com/hyperledger/fabric/protoutil/signeddata.go new file mode 100644 index 00000000..ec52bce0 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/protoutil/signeddata.go @@ -0,0 +1,86 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package protoutil + +import ( + "bytes" + "fmt" + + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-protos-go/common" +) + +// SignedData is used to represent the general triplet required to verify a signature +// This is intended to be generic across crypto schemes, while most crypto schemes will +// include the signing identity and a nonce within the Data, this is left to the crypto +// implementation. +type SignedData struct { + Data []byte + Identity []byte + Signature []byte +} + +// ConfigUpdateEnvelopeAsSignedData returns the set of signatures for the +// ConfigUpdateEnvelope as SignedData or an error indicating why this was not +// possible. +func ConfigUpdateEnvelopeAsSignedData(ce *common.ConfigUpdateEnvelope) ([]*SignedData, error) { + if ce == nil { + return nil, fmt.Errorf("No signatures for nil SignedConfigItem") + } + + result := make([]*SignedData, len(ce.Signatures)) + for i, configSig := range ce.Signatures { + sigHeader := &common.SignatureHeader{} + err := proto.Unmarshal(configSig.SignatureHeader, sigHeader) + if err != nil { + return nil, err + } + + result[i] = &SignedData{ + Data: bytes.Join([][]byte{configSig.SignatureHeader, ce.ConfigUpdate}, nil), + Identity: sigHeader.Creator, + Signature: configSig.Signature, + } + + } + + return result, nil +} + +// EnvelopeAsSignedData returns the signatures for the Envelope as SignedData +// slice of length 1 or an error indicating why this was not possible. +func EnvelopeAsSignedData(env *common.Envelope) ([]*SignedData, error) { + if env == nil { + return nil, fmt.Errorf("No signatures for nil Envelope") + } + + payload := &common.Payload{} + err := proto.Unmarshal(env.Payload, payload) + if err != nil { + return nil, err + } + + if payload.Header == nil /* || payload.Header.SignatureHeader == nil */ { + return nil, fmt.Errorf("Missing Header") + } + + shdr := &common.SignatureHeader{} + err = proto.Unmarshal(payload.Header.SignatureHeader, shdr) + if err != nil { + return nil, fmt.Errorf("GetSignatureHeaderFromBytes failed, err %s", err) + } + + return []*SignedData{{ + Data: env.Payload, + Identity: shdr.Creator, + Signature: env.Signature, + }}, nil +} diff --git a/internal/github.com/hyperledger/fabric/protoutil/txutils.go b/internal/github.com/hyperledger/fabric/protoutil/txutils.go new file mode 100644 index 00000000..e3ea63e5 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/protoutil/txutils.go @@ -0,0 +1,520 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package protoutil + +import ( + "bytes" + "crypto/sha256" + + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-protos-go/peer" + "github.com/pkg/errors" +) + +// GetPayloads gets the underlying payload objects in a TransactionAction +func GetPayloads(txActions *peer.TransactionAction) (*peer.ChaincodeActionPayload, *peer.ChaincodeAction, error) { + // TODO: pass in the tx type (in what follows we're assuming the + // type is ENDORSER_TRANSACTION) + ccPayload, err := UnmarshalChaincodeActionPayload(txActions.Payload) + if err != nil { + return nil, nil, err + } + + if ccPayload.Action == nil || ccPayload.Action.ProposalResponsePayload == nil { + return nil, nil, errors.New("no payload in ChaincodeActionPayload") + } + pRespPayload, err := UnmarshalProposalResponsePayload(ccPayload.Action.ProposalResponsePayload) + if err != nil { + return nil, nil, err + } + + if pRespPayload.Extension == nil { + return nil, nil, errors.New("response payload is missing extension") + } + + respPayload, err := UnmarshalChaincodeAction(pRespPayload.Extension) + if err != nil { + return ccPayload, nil, err + } + return ccPayload, respPayload, nil +} + +// GetEnvelopeFromBlock gets an envelope from a block's Data field. +func GetEnvelopeFromBlock(data []byte) (*common.Envelope, error) { + // Block always begins with an envelope + var err error + env := &common.Envelope{} + if err = proto.Unmarshal(data, env); err != nil { + return nil, errors.Wrap(err, "error unmarshaling Envelope") + } + + return env, nil +} + +// CreateSignedEnvelope creates a signed envelope of the desired type, with +// marshaled dataMsg and signs it +func CreateSignedEnvelope( + txType common.HeaderType, + channelID string, + signer Signer, + dataMsg proto.Message, + msgVersion int32, + epoch uint64, +) (*common.Envelope, error) { + return CreateSignedEnvelopeWithTLSBinding(txType, channelID, signer, dataMsg, msgVersion, epoch, nil) +} + +// CreateSignedEnvelopeWithTLSBinding creates a signed envelope of the desired +// type, with marshaled dataMsg and signs it. It also includes a TLS cert hash +// into the channel header +func CreateSignedEnvelopeWithTLSBinding( + txType common.HeaderType, + channelID string, + signer Signer, + dataMsg proto.Message, + msgVersion int32, + epoch uint64, + tlsCertHash []byte, +) (*common.Envelope, error) { + payloadChannelHeader := MakeChannelHeader(txType, msgVersion, channelID, epoch) + payloadChannelHeader.TlsCertHash = tlsCertHash + var err error + payloadSignatureHeader := &common.SignatureHeader{} + + if signer != nil { + payloadSignatureHeader, err = NewSignatureHeader(signer) + if err != nil { + return nil, err + } + } + + data, err := proto.Marshal(dataMsg) + if err != nil { + return nil, errors.Wrap(err, "error marshaling") + } + + paylBytes := MarshalOrPanic( + &common.Payload{ + Header: MakePayloadHeader(payloadChannelHeader, payloadSignatureHeader), + Data: data, + }, + ) + + var sig []byte + if signer != nil { + sig, err = signer.Sign(paylBytes) + if err != nil { + return nil, err + } + } + + env := &common.Envelope{ + Payload: paylBytes, + Signature: sig, + } + + return env, nil +} + +// Signer is the interface needed to sign a transaction +type Signer interface { + Sign(msg []byte) ([]byte, error) + Serialize() ([]byte, error) +} + +// CreateSignedTx assembles an Envelope message from proposal, endorsements, +// and a signer. This function should be called by a client when it has +// collected enough endorsements for a proposal to create a transaction and +// submit it to peers for ordering +func CreateSignedTx( + proposal *peer.Proposal, + signer Signer, + resps ...*peer.ProposalResponse, +) (*common.Envelope, error) { + if len(resps) == 0 { + return nil, errors.New("at least one proposal response is required") + } + + // the original header + hdr, err := UnmarshalHeader(proposal.Header) + if err != nil { + return nil, err + } + + // the original payload + pPayl, err := UnmarshalChaincodeProposalPayload(proposal.Payload) + if err != nil { + return nil, err + } + + // check that the signer is the same that is referenced in the header + // TODO: maybe worth removing? + signerBytes, err := signer.Serialize() + if err != nil { + return nil, err + } + + shdr, err := UnmarshalSignatureHeader(hdr.SignatureHeader) + if err != nil { + return nil, err + } + + if !bytes.Equal(signerBytes, shdr.Creator) { + return nil, errors.New("signer must be the same as the one referenced in the header") + } + + // ensure that all actions are bitwise equal and that they are successful + var a1 []byte + for n, r := range resps { + if r.Response.Status < 200 || r.Response.Status >= 400 { + return nil, errors.Errorf("proposal response was not successful, error code %d, msg %s", r.Response.Status, r.Response.Message) + } + + if n == 0 { + a1 = r.Payload + continue + } + + if !bytes.Equal(a1, r.Payload) { + return nil, errors.New("ProposalResponsePayloads do not match") + } + } + + // fill endorsements + endorsements := make([]*peer.Endorsement, len(resps)) + for n, r := range resps { + endorsements[n] = r.Endorsement + } + + // create ChaincodeEndorsedAction + cea := &peer.ChaincodeEndorsedAction{ProposalResponsePayload: resps[0].Payload, Endorsements: endorsements} + + // obtain the bytes of the proposal payload that will go to the transaction + propPayloadBytes, err := GetBytesProposalPayloadForTx(pPayl) + if err != nil { + return nil, err + } + + // serialize the chaincode action payload + cap := &peer.ChaincodeActionPayload{ChaincodeProposalPayload: propPayloadBytes, Action: cea} + capBytes, err := GetBytesChaincodeActionPayload(cap) + if err != nil { + return nil, err + } + + // create a transaction + taa := &peer.TransactionAction{Header: hdr.SignatureHeader, Payload: capBytes} + taas := make([]*peer.TransactionAction, 1) + taas[0] = taa + tx := &peer.Transaction{Actions: taas} + + // serialize the tx + txBytes, err := GetBytesTransaction(tx) + if err != nil { + return nil, err + } + + // create the payload + payl := &common.Payload{Header: hdr, Data: txBytes} + paylBytes, err := GetBytesPayload(payl) + if err != nil { + return nil, err + } + + // sign the payload + sig, err := signer.Sign(paylBytes) + if err != nil { + return nil, err + } + + // here's the envelope + return &common.Envelope{Payload: paylBytes, Signature: sig}, nil +} + +// CreateProposalResponse creates a proposal response. +func CreateProposalResponse( + hdrbytes []byte, + payl []byte, + response *peer.Response, + results []byte, + events []byte, + ccid *peer.ChaincodeID, + signingEndorser Signer, +) (*peer.ProposalResponse, error) { + hdr, err := UnmarshalHeader(hdrbytes) + if err != nil { + return nil, err + } + + // obtain the proposal hash given proposal header, payload and the + // requested visibility + pHashBytes, err := GetProposalHash1(hdr, payl) + if err != nil { + return nil, errors.WithMessage(err, "error computing proposal hash") + } + + // get the bytes of the proposal response payload - we need to sign them + prpBytes, err := GetBytesProposalResponsePayload(pHashBytes, response, results, events, ccid) + if err != nil { + return nil, err + } + + // serialize the signing identity + endorser, err := signingEndorser.Serialize() + if err != nil { + return nil, errors.WithMessage(err, "error serializing signing identity") + } + + // sign the concatenation of the proposal response and the serialized + // endorser identity with this endorser's key + signature, err := signingEndorser.Sign(append(prpBytes, endorser...)) + if err != nil { + return nil, errors.WithMessage(err, "could not sign the proposal response payload") + } + + resp := &peer.ProposalResponse{ + // Timestamp: TODO! + Version: 1, // TODO: pick right version number + Endorsement: &peer.Endorsement{ + Signature: signature, + Endorser: endorser, + }, + Payload: prpBytes, + Response: &peer.Response{ + Status: 200, + Message: "OK", + }, + } + + return resp, nil +} + +// CreateProposalResponseFailure creates a proposal response for cases where +// endorsement proposal fails either due to a endorsement failure or a +// chaincode failure (chaincode response status >= shim.ERRORTHRESHOLD) +func CreateProposalResponseFailure( + hdrbytes []byte, + payl []byte, + response *peer.Response, + results []byte, + events []byte, + chaincodeName string, +) (*peer.ProposalResponse, error) { + hdr, err := UnmarshalHeader(hdrbytes) + if err != nil { + return nil, err + } + + // obtain the proposal hash given proposal header, payload and the requested visibility + pHashBytes, err := GetProposalHash1(hdr, payl) + if err != nil { + return nil, errors.WithMessage(err, "error computing proposal hash") + } + + // get the bytes of the proposal response payload + prpBytes, err := GetBytesProposalResponsePayload(pHashBytes, response, results, events, &peer.ChaincodeID{Name: chaincodeName}) + if err != nil { + return nil, err + } + + resp := &peer.ProposalResponse{ + // Timestamp: TODO! + Payload: prpBytes, + Response: response, + } + + return resp, nil +} + +// GetSignedProposal returns a signed proposal given a Proposal message and a +// signing identity +func GetSignedProposal(prop *peer.Proposal, signer Signer) (*peer.SignedProposal, error) { + // check for nil argument + if prop == nil || signer == nil { + return nil, errors.New("nil arguments") + } + + propBytes, err := proto.Marshal(prop) + if err != nil { + return nil, err + } + + signature, err := signer.Sign(propBytes) + if err != nil { + return nil, err + } + + return &peer.SignedProposal{ProposalBytes: propBytes, Signature: signature}, nil +} + +// MockSignedEndorserProposalOrPanic creates a SignedProposal with the +// passed arguments +func MockSignedEndorserProposalOrPanic( + channelID string, + cs *peer.ChaincodeSpec, + creator, + signature []byte, +) (*peer.SignedProposal, *peer.Proposal) { + prop, _, err := CreateChaincodeProposal( + common.HeaderType_ENDORSER_TRANSACTION, + channelID, + &peer.ChaincodeInvocationSpec{ChaincodeSpec: cs}, + creator) + if err != nil { + panic(err) + } + + propBytes, err := proto.Marshal(prop) + if err != nil { + panic(err) + } + + return &peer.SignedProposal{ProposalBytes: propBytes, Signature: signature}, prop +} + +func MockSignedEndorserProposal2OrPanic( + channelID string, + cs *peer.ChaincodeSpec, + signer Signer, +) (*peer.SignedProposal, *peer.Proposal) { + serializedSigner, err := signer.Serialize() + if err != nil { + panic(err) + } + + prop, _, err := CreateChaincodeProposal( + common.HeaderType_ENDORSER_TRANSACTION, + channelID, + &peer.ChaincodeInvocationSpec{ChaincodeSpec: &peer.ChaincodeSpec{}}, + serializedSigner) + if err != nil { + panic(err) + } + + sProp, err := GetSignedProposal(prop, signer) + if err != nil { + panic(err) + } + + return sProp, prop +} + +// GetBytesProposalPayloadForTx takes a ChaincodeProposalPayload and returns +// its serialized version according to the visibility field +func GetBytesProposalPayloadForTx( + payload *peer.ChaincodeProposalPayload, +) ([]byte, error) { + // check for nil argument + if payload == nil { + return nil, errors.New("nil arguments") + } + + // strip the transient bytes off the payload + cppNoTransient := &peer.ChaincodeProposalPayload{Input: payload.Input, TransientMap: nil} + cppBytes, err := GetBytesChaincodeProposalPayload(cppNoTransient) + if err != nil { + return nil, err + } + + return cppBytes, nil +} + +// GetProposalHash2 gets the proposal hash - this version +// is called by the committer where the visibility policy +// has already been enforced and so we already get what +// we have to get in ccPropPayl +func GetProposalHash2(header *common.Header, ccPropPayl []byte) ([]byte, error) { + // check for nil argument + if header == nil || + header.ChannelHeader == nil || + header.SignatureHeader == nil || + ccPropPayl == nil { + return nil, errors.New("nil arguments") + } + + hash := sha256.New() + // hash the serialized Channel Header object + hash.Write(header.ChannelHeader) + // hash the serialized Signature Header object + hash.Write(header.SignatureHeader) + // hash the bytes of the chaincode proposal payload that we are given + hash.Write(ccPropPayl) + return hash.Sum(nil), nil +} + +// GetProposalHash1 gets the proposal hash bytes after sanitizing the +// chaincode proposal payload according to the rules of visibility +func GetProposalHash1(header *common.Header, ccPropPayl []byte) ([]byte, error) { + // check for nil argument + if header == nil || + header.ChannelHeader == nil || + header.SignatureHeader == nil || + ccPropPayl == nil { + return nil, errors.New("nil arguments") + } + + // unmarshal the chaincode proposal payload + cpp, err := UnmarshalChaincodeProposalPayload(ccPropPayl) + if err != nil { + return nil, err + } + + ppBytes, err := GetBytesProposalPayloadForTx(cpp) + if err != nil { + return nil, err + } + + hash2 := sha256.New() + // hash the serialized Channel Header object + hash2.Write(header.ChannelHeader) + // hash the serialized Signature Header object + hash2.Write(header.SignatureHeader) + // hash of the part of the chaincode proposal payload that will go to the tx + hash2.Write(ppBytes) + return hash2.Sum(nil), nil +} + +// GetOrComputeTxIDFromEnvelope gets the txID present in a given transaction +// envelope. If the txID is empty, it constructs the txID from nonce and +// creator fields in the envelope. +func GetOrComputeTxIDFromEnvelope(txEnvelopBytes []byte) (string, error) { + txEnvelope, err := UnmarshalEnvelope(txEnvelopBytes) + if err != nil { + return "", errors.WithMessage(err, "error getting txID from envelope") + } + + txPayload, err := UnmarshalPayload(txEnvelope.Payload) + if err != nil { + return "", errors.WithMessage(err, "error getting txID from payload") + } + + if txPayload.Header == nil { + return "", errors.New("error getting txID from header: payload header is nil") + } + + chdr, err := UnmarshalChannelHeader(txPayload.Header.ChannelHeader) + if err != nil { + return "", errors.WithMessage(err, "error getting txID from channel header") + } + + if chdr.TxId != "" { + return chdr.TxId, nil + } + + sighdr, err := UnmarshalSignatureHeader(txPayload.Header.SignatureHeader) + if err != nil { + return "", errors.WithMessage(err, "error getting nonce and creator for computing txID") + } + + txid := ComputeTxID(sighdr.Nonce, sighdr.Creator) + return txid, nil +} diff --git a/internal/github.com/hyperledger/fabric/protoutil/unmarshalers.go b/internal/github.com/hyperledger/fabric/protoutil/unmarshalers.go new file mode 100644 index 00000000..8822885f --- /dev/null +++ b/internal/github.com/hyperledger/fabric/protoutil/unmarshalers.go @@ -0,0 +1,213 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package protoutil + +import ( + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-protos-go/common" + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-protos-go/msp" + "github.com/hyperledger/fabric-protos-go/peer" + pb "github.com/hyperledger/fabric-protos-go/peer" + "github.com/pkg/errors" +) + +// the implicit contract of all these unmarshalers is that they +// will return a non-nil pointer whenever the error is nil + +// UnmarshalBlock unmarshals bytes to a Block +func UnmarshalBlock(encoded []byte) (*cb.Block, error) { + block := &cb.Block{} + err := proto.Unmarshal(encoded, block) + return block, errors.Wrap(err, "error unmarshaling Block") +} + +// UnmarshalChaincodeDeploymentSpec unmarshals bytes to a ChaincodeDeploymentSpec +func UnmarshalChaincodeDeploymentSpec(code []byte) (*peer.ChaincodeDeploymentSpec, error) { + cds := &peer.ChaincodeDeploymentSpec{} + err := proto.Unmarshal(code, cds) + return cds, errors.Wrap(err, "error unmarshaling ChaincodeDeploymentSpec") +} + +// UnmarshalChaincodeInvocationSpec unmarshals bytes to a ChaincodeInvocationSpec +func UnmarshalChaincodeInvocationSpec(encoded []byte) (*peer.ChaincodeInvocationSpec, error) { + cis := &peer.ChaincodeInvocationSpec{} + err := proto.Unmarshal(encoded, cis) + return cis, errors.Wrap(err, "error unmarshaling ChaincodeInvocationSpec") +} + +// UnmarshalPayload unmarshals bytes to a Payload +func UnmarshalPayload(encoded []byte) (*cb.Payload, error) { + payload := &cb.Payload{} + err := proto.Unmarshal(encoded, payload) + return payload, errors.Wrap(err, "error unmarshaling Payload") +} + +// UnmarshalEnvelope unmarshals bytes to a Envelope +func UnmarshalEnvelope(encoded []byte) (*cb.Envelope, error) { + envelope := &cb.Envelope{} + err := proto.Unmarshal(encoded, envelope) + return envelope, errors.Wrap(err, "error unmarshaling Envelope") +} + +// UnmarshalChannelHeader unmarshals bytes to a ChannelHeader +func UnmarshalChannelHeader(bytes []byte) (*cb.ChannelHeader, error) { + chdr := &cb.ChannelHeader{} + err := proto.Unmarshal(bytes, chdr) + return chdr, errors.Wrap(err, "error unmarshaling ChannelHeader") +} + +// UnmarshalChaincodeID unmarshals bytes to a ChaincodeID +func UnmarshalChaincodeID(bytes []byte) (*peer.ChaincodeID, error) { + ccid := &pb.ChaincodeID{} + err := proto.Unmarshal(bytes, ccid) + return ccid, errors.Wrap(err, "error unmarshaling ChaincodeID") +} + +// UnmarshalSignatureHeader unmarshals bytes to a SignatureHeader +func UnmarshalSignatureHeader(bytes []byte) (*cb.SignatureHeader, error) { + sh := &common.SignatureHeader{} + err := proto.Unmarshal(bytes, sh) + return sh, errors.Wrap(err, "error unmarshaling SignatureHeader") +} + +func UnmarshalSerializedIdentity(bytes []byte) (*msp.SerializedIdentity, error) { + sid := &msp.SerializedIdentity{} + err := proto.Unmarshal(bytes, sid) + return sid, errors.Wrap(err, "error unmarshaling SerializedIdentity") +} + +// UnmarshalHeader unmarshals bytes to a Header +func UnmarshalHeader(bytes []byte) (*common.Header, error) { + hdr := &common.Header{} + err := proto.Unmarshal(bytes, hdr) + return hdr, errors.Wrap(err, "error unmarshaling Header") +} + +// UnmarshalChaincodeHeaderExtension unmarshals bytes to a ChaincodeHeaderExtension +func UnmarshalChaincodeHeaderExtension(hdrExtension []byte) (*peer.ChaincodeHeaderExtension, error) { + chaincodeHdrExt := &peer.ChaincodeHeaderExtension{} + err := proto.Unmarshal(hdrExtension, chaincodeHdrExt) + return chaincodeHdrExt, errors.Wrap(err, "error unmarshaling ChaincodeHeaderExtension") +} + +// UnmarshalProposalResponse unmarshals bytes to a ProposalResponse +func UnmarshalProposalResponse(prBytes []byte) (*peer.ProposalResponse, error) { + proposalResponse := &peer.ProposalResponse{} + err := proto.Unmarshal(prBytes, proposalResponse) + return proposalResponse, errors.Wrap(err, "error unmarshaling ProposalResponse") +} + +// UnmarshalChaincodeAction unmarshals bytes to a ChaincodeAction +func UnmarshalChaincodeAction(caBytes []byte) (*peer.ChaincodeAction, error) { + chaincodeAction := &peer.ChaincodeAction{} + err := proto.Unmarshal(caBytes, chaincodeAction) + return chaincodeAction, errors.Wrap(err, "error unmarshaling ChaincodeAction") +} + +// UnmarshalResponse unmarshals bytes to a Response +func UnmarshalResponse(resBytes []byte) (*peer.Response, error) { + response := &peer.Response{} + err := proto.Unmarshal(resBytes, response) + return response, errors.Wrap(err, "error unmarshaling Response") +} + +// UnmarshalChaincodeEvents unmarshals bytes to a ChaincodeEvent +func UnmarshalChaincodeEvents(eBytes []byte) (*peer.ChaincodeEvent, error) { + chaincodeEvent := &peer.ChaincodeEvent{} + err := proto.Unmarshal(eBytes, chaincodeEvent) + return chaincodeEvent, errors.Wrap(err, "error unmarshaling ChaicnodeEvent") +} + +// UnmarshalProposalResponsePayload unmarshals bytes to a ProposalResponsePayload +func UnmarshalProposalResponsePayload(prpBytes []byte) (*peer.ProposalResponsePayload, error) { + prp := &peer.ProposalResponsePayload{} + err := proto.Unmarshal(prpBytes, prp) + return prp, errors.Wrap(err, "error unmarshaling ProposalResponsePayload") +} + +// UnmarshalProposal unmarshals bytes to a Proposal +func UnmarshalProposal(propBytes []byte) (*peer.Proposal, error) { + prop := &peer.Proposal{} + err := proto.Unmarshal(propBytes, prop) + return prop, errors.Wrap(err, "error unmarshaling Proposal") +} + +// UnmarshalTransaction unmarshals bytes to a Transaction +func UnmarshalTransaction(txBytes []byte) (*peer.Transaction, error) { + tx := &peer.Transaction{} + err := proto.Unmarshal(txBytes, tx) + return tx, errors.Wrap(err, "error unmarshaling Transaction") +} + +// UnmarshalChaincodeActionPayload unmarshals bytes to a ChaincodeActionPayload +func UnmarshalChaincodeActionPayload(capBytes []byte) (*peer.ChaincodeActionPayload, error) { + cap := &peer.ChaincodeActionPayload{} + err := proto.Unmarshal(capBytes, cap) + return cap, errors.Wrap(err, "error unmarshaling ChaincodeActionPayload") +} + +// UnmarshalChaincodeProposalPayload unmarshals bytes to a ChaincodeProposalPayload +func UnmarshalChaincodeProposalPayload(bytes []byte) (*peer.ChaincodeProposalPayload, error) { + cpp := &peer.ChaincodeProposalPayload{} + err := proto.Unmarshal(bytes, cpp) + return cpp, errors.Wrap(err, "error unmarshaling ChaincodeProposalPayload") +} + +// UnmarshalPayloadOrPanic unmarshals bytes to a Payload structure or panics +// on error +func UnmarshalPayloadOrPanic(encoded []byte) *cb.Payload { + payload, err := UnmarshalPayload(encoded) + if err != nil { + panic(err) + } + return payload +} + +// UnmarshalEnvelopeOrPanic unmarshals bytes to an Envelope structure or panics +// on error +func UnmarshalEnvelopeOrPanic(encoded []byte) *cb.Envelope { + envelope, err := UnmarshalEnvelope(encoded) + if err != nil { + panic(err) + } + return envelope +} + +// UnmarshalBlockOrPanic unmarshals bytes to an Block or panics +// on error +func UnmarshalBlockOrPanic(encoded []byte) *cb.Block { + block, err := UnmarshalBlock(encoded) + if err != nil { + panic(err) + } + return block +} + +// UnmarshalChannelHeaderOrPanic unmarshals bytes to a ChannelHeader or panics +// on error +func UnmarshalChannelHeaderOrPanic(bytes []byte) *cb.ChannelHeader { + chdr, err := UnmarshalChannelHeader(bytes) + if err != nil { + panic(err) + } + return chdr +} + +// UnmarshalSignatureHeaderOrPanic unmarshals bytes to a SignatureHeader or panics +// on error +func UnmarshalSignatureHeaderOrPanic(bytes []byte) *cb.SignatureHeader { + sighdr, err := UnmarshalSignatureHeader(bytes) + if err != nil { + panic(err) + } + return sighdr +} diff --git a/internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/encoder/encoder.go b/internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/encoder/encoder.go new file mode 100644 index 00000000..d6e73cd8 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/encoder/encoder.go @@ -0,0 +1,627 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package encoder + +import ( + "github.com/golang/protobuf/proto" + cb "github.com/hyperledger/fabric-protos-go/common" + pb "github.com/hyperledger/fabric-protos-go/peer" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/channelconfig" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/genesis" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/policies" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/policydsl" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/util" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/msp" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/protoutil" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/genesisconfig" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkinternal/configtxlator/update" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkinternal/pkg/identity" + flogging "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/logbridge" + "github.com/pkg/errors" +) + +const ( + ordererAdminsPolicyName = "/Channel/Orderer/Admins" + + msgVersion = int32(0) + epoch = 0 +) + +var logger = flogging.MustGetLogger("common.tools.configtxgen.encoder") + +const ( + // ConsensusTypeSolo identifies the solo consensus implementation. + ConsensusTypeSolo = "solo" + // ConsensusTypeKafka identifies the Kafka-based consensus implementation. + ConsensusTypeKafka = "kafka" + // ConsensusTypeKafka identifies the Kafka-based consensus implementation. + ConsensusTypeEtcdRaft = "etcdraft" + + // BlockValidationPolicyKey TODO + BlockValidationPolicyKey = "BlockValidation" + + // OrdererAdminsPolicy is the absolute path to the orderer admins policy + OrdererAdminsPolicy = "/Channel/Orderer/Admins" + + // SignaturePolicyType is the 'Type' string for signature policies + SignaturePolicyType = "Signature" + + // ImplicitMetaPolicyType is the 'Type' string for implicit meta policies + ImplicitMetaPolicyType = "ImplicitMeta" +) + +func addValue(cg *cb.ConfigGroup, value channelconfig.ConfigValue, modPolicy string) { + cg.Values[value.Key()] = &cb.ConfigValue{ + Value: protoutil.MarshalOrPanic(value.Value()), + ModPolicy: modPolicy, + } +} + +func addPolicy(cg *cb.ConfigGroup, policy policies.ConfigPolicy, modPolicy string) { + cg.Policies[policy.Key()] = &cb.ConfigPolicy{ + Policy: policy.Value(), + ModPolicy: modPolicy, + } +} + +func AddOrdererPolicies(cg *cb.ConfigGroup, policyMap map[string]*genesisconfig.Policy, modPolicy string) error { + switch { + case policyMap == nil: + return errors.Errorf("no policies defined") + case policyMap[BlockValidationPolicyKey] == nil: + return errors.Errorf("no BlockValidation policy defined") + } + + return AddPolicies(cg, policyMap, modPolicy) +} + +func AddPolicies(cg *cb.ConfigGroup, policyMap map[string]*genesisconfig.Policy, modPolicy string) error { + switch { + case policyMap == nil: + return errors.Errorf("no policies defined") + case policyMap[channelconfig.AdminsPolicyKey] == nil: + return errors.Errorf("no Admins policy defined") + case policyMap[channelconfig.ReadersPolicyKey] == nil: + return errors.Errorf("no Readers policy defined") + case policyMap[channelconfig.WritersPolicyKey] == nil: + return errors.Errorf("no Writers policy defined") + } + + for policyName, policy := range policyMap { + switch policy.Type { + case ImplicitMetaPolicyType: + imp, err := policies.ImplicitMetaFromString(policy.Rule) + if err != nil { + return errors.Wrapf(err, "invalid implicit meta policy rule '%s'", policy.Rule) + } + cg.Policies[policyName] = &cb.ConfigPolicy{ + ModPolicy: modPolicy, + Policy: &cb.Policy{ + Type: int32(cb.Policy_IMPLICIT_META), + Value: protoutil.MarshalOrPanic(imp), + }, + } + case SignaturePolicyType: + sp, err := policydsl.FromString(policy.Rule) + if err != nil { + return errors.Wrapf(err, "invalid signature policy rule '%s'", policy.Rule) + } + cg.Policies[policyName] = &cb.ConfigPolicy{ + ModPolicy: modPolicy, + Policy: &cb.Policy{ + Type: int32(cb.Policy_SIGNATURE), + Value: protoutil.MarshalOrPanic(sp), + }, + } + default: + return errors.Errorf("unknown policy type: %s", policy.Type) + } + } + return nil +} + +// NewChannelGroup defines the root of the channel configuration. It defines basic operating principles like the hashing +// algorithm used for the blocks, as well as the location of the ordering service. It will recursively call into the +// NewOrdererGroup, NewConsortiumsGroup, and NewApplicationGroup depending on whether these sub-elements are set in the +// configuration. All mod_policy values are set to "Admins" for this group, with the exception of the OrdererAddresses +// value which is set to "/Channel/Orderer/Admins". +func NewChannelGroup(conf *genesisconfig.Profile) (*cb.ConfigGroup, error) { + channelGroup := protoutil.NewConfigGroup() + if err := AddPolicies(channelGroup, conf.Policies, channelconfig.AdminsPolicyKey); err != nil { + return nil, errors.Wrapf(err, "error adding policies to channel group") + } + + addValue(channelGroup, channelconfig.HashingAlgorithmValue(), channelconfig.AdminsPolicyKey) + addValue(channelGroup, channelconfig.BlockDataHashingStructureValue(), channelconfig.AdminsPolicyKey) + if conf.Orderer != nil && len(conf.Orderer.Addresses) > 0 { + addValue(channelGroup, channelconfig.OrdererAddressesValue(conf.Orderer.Addresses), ordererAdminsPolicyName) + } + + if conf.Consortium != "" { + addValue(channelGroup, channelconfig.ConsortiumValue(conf.Consortium), channelconfig.AdminsPolicyKey) + } + + if len(conf.Capabilities) > 0 { + addValue(channelGroup, channelconfig.CapabilitiesValue(conf.Capabilities), channelconfig.AdminsPolicyKey) + } + + var err error + if conf.Orderer != nil { + channelGroup.Groups[channelconfig.OrdererGroupKey], err = NewOrdererGroup(conf.Orderer) + if err != nil { + return nil, errors.Wrap(err, "could not create orderer group") + } + } + + if conf.Application != nil { + channelGroup.Groups[channelconfig.ApplicationGroupKey], err = NewApplicationGroup(conf.Application) + if err != nil { + return nil, errors.Wrap(err, "could not create application group") + } + } + + if conf.Consortiums != nil { + channelGroup.Groups[channelconfig.ConsortiumsGroupKey], err = NewConsortiumsGroup(conf.Consortiums) + if err != nil { + return nil, errors.Wrap(err, "could not create consortiums group") + } + } + + channelGroup.ModPolicy = channelconfig.AdminsPolicyKey + return channelGroup, nil +} + +// NewOrdererGroup returns the orderer component of the channel configuration. It defines parameters of the ordering service +// about how large blocks should be, how frequently they should be emitted, etc. as well as the organizations of the ordering network. +// It sets the mod_policy of all elements to "Admins". This group is always present in any channel configuration. +func NewOrdererGroup(conf *genesisconfig.Orderer) (*cb.ConfigGroup, error) { + ordererGroup := protoutil.NewConfigGroup() + if err := AddOrdererPolicies(ordererGroup, conf.Policies, channelconfig.AdminsPolicyKey); err != nil { + return nil, errors.Wrapf(err, "error adding policies to orderer group") + } + addValue(ordererGroup, channelconfig.BatchSizeValue( + conf.BatchSize.MaxMessageCount, + conf.BatchSize.AbsoluteMaxBytes, + conf.BatchSize.PreferredMaxBytes, + ), channelconfig.AdminsPolicyKey) + addValue(ordererGroup, channelconfig.BatchTimeoutValue(conf.BatchTimeout.String()), channelconfig.AdminsPolicyKey) + addValue(ordererGroup, channelconfig.ChannelRestrictionsValue(conf.MaxChannels), channelconfig.AdminsPolicyKey) + + if len(conf.Capabilities) > 0 { + addValue(ordererGroup, channelconfig.CapabilitiesValue(conf.Capabilities), channelconfig.AdminsPolicyKey) + } + + var consensusMetadata []byte + var err error + + switch conf.OrdererType { + case ConsensusTypeSolo: + case ConsensusTypeKafka: + addValue(ordererGroup, channelconfig.KafkaBrokersValue(conf.Kafka.Brokers), channelconfig.AdminsPolicyKey) + case ConsensusTypeEtcdRaft: + if consensusMetadata, err = channelconfig.MarshalEtcdRaftMetadata(conf.EtcdRaft); err != nil { + return nil, errors.Errorf("cannot marshal metadata for orderer type %s: %s", ConsensusTypeEtcdRaft, err) + } + default: + return nil, errors.Errorf("unknown orderer type: %s", conf.OrdererType) + } + + addValue(ordererGroup, channelconfig.ConsensusTypeValue(conf.OrdererType, consensusMetadata), channelconfig.AdminsPolicyKey) + + for _, org := range conf.Organizations { + var err error + ordererGroup.Groups[org.Name], err = NewOrdererOrgGroup(org) + if err != nil { + return nil, errors.Wrap(err, "failed to create orderer org") + } + } + + ordererGroup.ModPolicy = channelconfig.AdminsPolicyKey + return ordererGroup, nil +} + +// NewConsortiumsGroup returns an org component of the channel configuration. It defines the crypto material for the +// organization (its MSP). It sets the mod_policy of all elements to "Admins". +func NewConsortiumOrgGroup(conf *genesisconfig.Organization) (*cb.ConfigGroup, error) { + consortiumsOrgGroup := protoutil.NewConfigGroup() + consortiumsOrgGroup.ModPolicy = channelconfig.AdminsPolicyKey + + if conf.SkipAsForeign { + return consortiumsOrgGroup, nil + } + + mspConfig, err := msp.GetVerifyingMspConfig(conf.MSPDir, conf.ID, conf.MSPType) + if err != nil { + return nil, errors.Wrapf(err, "1 - Error loading MSP configuration for org: %s", conf.Name) + } + + if err := AddPolicies(consortiumsOrgGroup, conf.Policies, channelconfig.AdminsPolicyKey); err != nil { + return nil, errors.Wrapf(err, "error adding policies to consortiums org group '%s'", conf.Name) + } + + addValue(consortiumsOrgGroup, channelconfig.MSPValue(mspConfig), channelconfig.AdminsPolicyKey) + + return consortiumsOrgGroup, nil +} + +// NewOrdererOrgGroup returns an orderer org component of the channel configuration. It defines the crypto material for the +// organization (its MSP). It sets the mod_policy of all elements to "Admins". +func NewOrdererOrgGroup(conf *genesisconfig.Organization) (*cb.ConfigGroup, error) { + ordererOrgGroup := protoutil.NewConfigGroup() + ordererOrgGroup.ModPolicy = channelconfig.AdminsPolicyKey + + if conf.SkipAsForeign { + return ordererOrgGroup, nil + } + + mspConfig, err := msp.GetVerifyingMspConfig(conf.MSPDir, conf.ID, conf.MSPType) + if err != nil { + return nil, errors.Wrapf(err, "1 - Error loading MSP configuration for org: %s", conf.Name) + } + + if err := AddPolicies(ordererOrgGroup, conf.Policies, channelconfig.AdminsPolicyKey); err != nil { + return nil, errors.Wrapf(err, "error adding policies to orderer org group '%s'", conf.Name) + } + + addValue(ordererOrgGroup, channelconfig.MSPValue(mspConfig), channelconfig.AdminsPolicyKey) + + if len(conf.OrdererEndpoints) > 0 { + addValue(ordererOrgGroup, channelconfig.EndpointsValue(conf.OrdererEndpoints), channelconfig.AdminsPolicyKey) + } + + return ordererOrgGroup, nil +} + +// NewApplicationGroup returns the application component of the channel configuration. It defines the organizations which are involved +// in application logic like chaincodes, and how these members may interact with the orderer. It sets the mod_policy of all elements to "Admins". +func NewApplicationGroup(conf *genesisconfig.Application) (*cb.ConfigGroup, error) { + applicationGroup := protoutil.NewConfigGroup() + if err := AddPolicies(applicationGroup, conf.Policies, channelconfig.AdminsPolicyKey); err != nil { + return nil, errors.Wrapf(err, "error adding policies to application group") + } + + if len(conf.ACLs) > 0 { + addValue(applicationGroup, channelconfig.ACLValues(conf.ACLs), channelconfig.AdminsPolicyKey) + } + + if len(conf.Capabilities) > 0 { + addValue(applicationGroup, channelconfig.CapabilitiesValue(conf.Capabilities), channelconfig.AdminsPolicyKey) + } + + for _, org := range conf.Organizations { + var err error + applicationGroup.Groups[org.Name], err = NewApplicationOrgGroup(org) + if err != nil { + return nil, errors.Wrap(err, "failed to create application org") + } + } + + applicationGroup.ModPolicy = channelconfig.AdminsPolicyKey + return applicationGroup, nil +} + +// NewApplicationOrgGroup returns an application org component of the channel configuration. It defines the crypto material for the organization +// (its MSP) as well as its anchor peers for use by the gossip network. It sets the mod_policy of all elements to "Admins". +func NewApplicationOrgGroup(conf *genesisconfig.Organization) (*cb.ConfigGroup, error) { + applicationOrgGroup := protoutil.NewConfigGroup() + applicationOrgGroup.ModPolicy = channelconfig.AdminsPolicyKey + + if conf.SkipAsForeign { + return applicationOrgGroup, nil + } + + mspConfig, err := msp.GetVerifyingMspConfig(conf.MSPDir, conf.ID, conf.MSPType) + if err != nil { + return nil, errors.Wrapf(err, "1 - Error loading MSP configuration for org %s", conf.Name) + } + + if err := AddPolicies(applicationOrgGroup, conf.Policies, channelconfig.AdminsPolicyKey); err != nil { + return nil, errors.Wrapf(err, "error adding policies to application org group %s", conf.Name) + } + addValue(applicationOrgGroup, channelconfig.MSPValue(mspConfig), channelconfig.AdminsPolicyKey) + + var anchorProtos []*pb.AnchorPeer + for _, anchorPeer := range conf.AnchorPeers { + anchorProtos = append(anchorProtos, &pb.AnchorPeer{ + Host: anchorPeer.Host, + Port: int32(anchorPeer.Port), + }) + } + + // Avoid adding an unnecessary anchor peers element when one is not required. This helps + // prevent a delta from the orderer system channel when computing more complex channel + // creation transactions + if len(anchorProtos) > 0 { + addValue(applicationOrgGroup, channelconfig.AnchorPeersValue(anchorProtos), channelconfig.AdminsPolicyKey) + } + + return applicationOrgGroup, nil +} + +// NewConsortiumsGroup returns the consortiums component of the channel configuration. This element is only defined for the ordering system channel. +// It sets the mod_policy for all elements to "/Channel/Orderer/Admins". +func NewConsortiumsGroup(conf map[string]*genesisconfig.Consortium) (*cb.ConfigGroup, error) { + consortiumsGroup := protoutil.NewConfigGroup() + // This policy is not referenced anywhere, it is only used as part of the implicit meta policy rule at the channel level, so this setting + // effectively degrades control of the ordering system channel to the ordering admins + addPolicy(consortiumsGroup, policies.SignaturePolicy(channelconfig.AdminsPolicyKey, policydsl.AcceptAllPolicy), ordererAdminsPolicyName) + + for consortiumName, consortium := range conf { + var err error + consortiumsGroup.Groups[consortiumName], err = NewConsortiumGroup(consortium) + if err != nil { + return nil, errors.Wrapf(err, "failed to create consortium %s", consortiumName) + } + } + + consortiumsGroup.ModPolicy = ordererAdminsPolicyName + return consortiumsGroup, nil +} + +// NewConsortiums returns a consortiums component of the channel configuration. Each consortium defines the organizations which may be involved in channel +// creation, as well as the channel creation policy the orderer checks at channel creation time to authorize the action. It sets the mod_policy of all +// elements to "/Channel/Orderer/Admins". +func NewConsortiumGroup(conf *genesisconfig.Consortium) (*cb.ConfigGroup, error) { + consortiumGroup := protoutil.NewConfigGroup() + + for _, org := range conf.Organizations { + var err error + consortiumGroup.Groups[org.Name], err = NewConsortiumOrgGroup(org) + if err != nil { + return nil, errors.Wrap(err, "failed to create consortium org") + } + } + + addValue(consortiumGroup, channelconfig.ChannelCreationPolicyValue(policies.ImplicitMetaAnyPolicy(channelconfig.AdminsPolicyKey).Value()), ordererAdminsPolicyName) + + consortiumGroup.ModPolicy = ordererAdminsPolicyName + return consortiumGroup, nil +} + +// NewChannelCreateConfigUpdate generates a ConfigUpdate which can be sent to the orderer to create a new channel. Optionally, the channel group of the +// ordering system channel may be passed in, and the resulting ConfigUpdate will extract the appropriate versions from this file. +func NewChannelCreateConfigUpdate(channelID string, conf *genesisconfig.Profile, templateConfig *cb.ConfigGroup) (*cb.ConfigUpdate, error) { + if conf.Application == nil { + return nil, errors.New("cannot define a new channel with no Application section") + } + + if conf.Consortium == "" { + return nil, errors.New("cannot define a new channel with no Consortium value") + } + + newChannelGroup, err := NewChannelGroup(conf) + if err != nil { + return nil, errors.Wrapf(err, "could not turn parse profile into channel group") + } + + updt, err := update.Compute(&cb.Config{ChannelGroup: templateConfig}, &cb.Config{ChannelGroup: newChannelGroup}) + if err != nil { + return nil, errors.Wrapf(err, "could not compute update") + } + + // Add the consortium name to create the channel for into the write set as required. + updt.ChannelId = channelID + updt.ReadSet.Values[channelconfig.ConsortiumKey] = &cb.ConfigValue{Version: 0} + updt.WriteSet.Values[channelconfig.ConsortiumKey] = &cb.ConfigValue{ + Version: 0, + Value: protoutil.MarshalOrPanic(&cb.Consortium{ + Name: conf.Consortium, + }), + } + + return updt, nil +} + +// DefaultConfigTemplate generates a config template based on the assumption that +// the input profile is a channel creation template and no system channel context +// is available. +func DefaultConfigTemplate(conf *genesisconfig.Profile) (*cb.ConfigGroup, error) { + channelGroup, err := NewChannelGroup(conf) + if err != nil { + return nil, errors.WithMessage(err, "error parsing configuration") + } + + if _, ok := channelGroup.Groups[channelconfig.ApplicationGroupKey]; !ok { + return nil, errors.New("channel template configs must contain an application section") + } + + channelGroup.Groups[channelconfig.ApplicationGroupKey].Values = nil + channelGroup.Groups[channelconfig.ApplicationGroupKey].Policies = nil + + return channelGroup, nil +} + +func ConfigTemplateFromGroup(conf *genesisconfig.Profile, cg *cb.ConfigGroup) (*cb.ConfigGroup, error) { + template := proto.Clone(cg).(*cb.ConfigGroup) + if template.Groups == nil { + return nil, errors.Errorf("supplied system channel group has no sub-groups") + } + + template.Groups[channelconfig.ApplicationGroupKey] = &cb.ConfigGroup{ + Groups: map[string]*cb.ConfigGroup{}, + Policies: map[string]*cb.ConfigPolicy{ + channelconfig.AdminsPolicyKey: {}, + }, + } + + consortiums, ok := template.Groups[channelconfig.ConsortiumsGroupKey] + if !ok { + return nil, errors.Errorf("supplied system channel group does not appear to be system channel (missing consortiums group)") + } + + if consortiums.Groups == nil { + return nil, errors.Errorf("system channel consortiums group appears to have no consortiums defined") + } + + consortium, ok := consortiums.Groups[conf.Consortium] + if !ok { + return nil, errors.Errorf("supplied system channel group is missing '%s' consortium", conf.Consortium) + } + + if conf.Application == nil { + return nil, errors.Errorf("supplied channel creation profile does not contain an application section") + } + + for _, organization := range conf.Application.Organizations { + var ok bool + template.Groups[channelconfig.ApplicationGroupKey].Groups[organization.Name], ok = consortium.Groups[organization.Name] + if !ok { + return nil, errors.Errorf("consortium %s does not contain member org %s", conf.Consortium, organization.Name) + } + } + delete(template.Groups, channelconfig.ConsortiumsGroupKey) + + addValue(template, channelconfig.ConsortiumValue(conf.Consortium), channelconfig.AdminsPolicyKey) + + return template, nil +} + +// MakeChannelCreationTransaction is a handy utility function for creating transactions for channel creation. +// It assumes the invoker has no system channel context so ignores all but the application section. +func MakeChannelCreationTransaction( + channelID string, + signer identity.SignerSerializer, + conf *genesisconfig.Profile, +) (*cb.Envelope, error) { + template, err := DefaultConfigTemplate(conf) + if err != nil { + return nil, errors.WithMessage(err, "could not generate default config template") + } + return MakeChannelCreationTransactionFromTemplate(channelID, signer, conf, template) +} + +// MakeChannelCreationTransactionWithSystemChannelContext is a utility function for creating channel creation txes. +// It requires a configuration representing the orderer system channel to allow more sophisticated channel creation +// transactions modifying pieces of the configuration like the orderer set. +func MakeChannelCreationTransactionWithSystemChannelContext( + channelID string, + signer identity.SignerSerializer, + conf, + systemChannelConf *genesisconfig.Profile, +) (*cb.Envelope, error) { + cg, err := NewChannelGroup(systemChannelConf) + if err != nil { + return nil, errors.WithMessage(err, "could not parse system channel config") + } + + template, err := ConfigTemplateFromGroup(conf, cg) + if err != nil { + return nil, errors.WithMessage(err, "could not create config template") + } + + return MakeChannelCreationTransactionFromTemplate(channelID, signer, conf, template) +} + +// MakeChannelCreationTransactionFromTemplate creates a transaction for creating a channel. It uses +// the given template to produce the config update set. Usually, the caller will want to invoke +// MakeChannelCreationTransaction or MakeChannelCreationTransactionWithSystemChannelContext. +func MakeChannelCreationTransactionFromTemplate( + channelID string, + signer identity.SignerSerializer, + conf *genesisconfig.Profile, + template *cb.ConfigGroup, +) (*cb.Envelope, error) { + newChannelConfigUpdate, err := NewChannelCreateConfigUpdate(channelID, conf, template) + if err != nil { + return nil, errors.Wrap(err, "config update generation failure") + } + + newConfigUpdateEnv := &cb.ConfigUpdateEnvelope{ + ConfigUpdate: protoutil.MarshalOrPanic(newChannelConfigUpdate), + } + + if signer != nil { + sigHeader, err := protoutil.NewSignatureHeader(signer) + if err != nil { + return nil, errors.Wrap(err, "creating signature header failed") + } + + newConfigUpdateEnv.Signatures = []*cb.ConfigSignature{{ + SignatureHeader: protoutil.MarshalOrPanic(sigHeader), + }} + + newConfigUpdateEnv.Signatures[0].Signature, err = signer.Sign(util.ConcatenateBytes(newConfigUpdateEnv.Signatures[0].SignatureHeader, newConfigUpdateEnv.ConfigUpdate)) + if err != nil { + return nil, errors.Wrap(err, "signature failure over config update") + } + + } + + return protoutil.CreateSignedEnvelope(cb.HeaderType_CONFIG_UPDATE, channelID, signer, newConfigUpdateEnv, msgVersion, epoch) +} + +// HasSkippedForeignOrgs is used to detect whether a configuration includes +// org definitions which should not be parsed because this tool is being +// run in a context where the user does not have access to that org's info +func HasSkippedForeignOrgs(conf *genesisconfig.Profile) error { + var organizations []*genesisconfig.Organization + + if conf.Orderer != nil { + organizations = append(organizations, conf.Orderer.Organizations...) + } + + if conf.Application != nil { + organizations = append(organizations, conf.Application.Organizations...) + } + + for _, consortium := range conf.Consortiums { + organizations = append(organizations, consortium.Organizations...) + } + + for _, org := range organizations { + if org.SkipAsForeign { + return errors.Errorf("organization '%s' is marked to be skipped as foreign", org.Name) + } + } + + return nil +} + +// Bootstrapper is a wrapper around NewChannelConfigGroup which can produce genesis blocks +type Bootstrapper struct { + channelGroup *cb.ConfigGroup +} + +// NewBootstrapper creates a bootstrapper but returns an error instead of panic-ing +func NewBootstrapper(config *genesisconfig.Profile) (*Bootstrapper, error) { + if err := HasSkippedForeignOrgs(config); err != nil { + return nil, errors.WithMessage(err, "all org definitions must be local during bootstrapping") + } + + channelGroup, err := NewChannelGroup(config) + if err != nil { + return nil, errors.WithMessage(err, "could not create channel group") + } + + return &Bootstrapper{ + channelGroup: channelGroup, + }, nil +} + +// New creates a new Bootstrapper for generating genesis blocks +func New(config *genesisconfig.Profile) *Bootstrapper { + bs, err := NewBootstrapper(config) + if err != nil { + logger.Panicf("Error creating bootsrapper: %s", err) + } + return bs +} + +// GenesisBlock produces a genesis block for the default test channel id +func (bs *Bootstrapper) GenesisBlock() *cb.Block { + // TODO(mjs): remove + return genesis.NewFactoryImpl(bs.channelGroup).Block("testchannelid") +} + +// GenesisBlockForChannel produces a genesis block for a given channel ID +func (bs *Bootstrapper) GenesisBlockForChannel(channelID string) *cb.Block { + return genesis.NewFactoryImpl(bs.channelGroup).Block(channelID) +} diff --git a/internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/genesisconfig/config.go b/internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/genesisconfig/config.go new file mode 100644 index 00000000..cadba3f7 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/genesisconfig/config.go @@ -0,0 +1,164 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package genesisconfig + +import ( + "time" + + "github.com/hyperledger/fabric-protos-go/orderer/etcdraft" +) + +const ( + // Prefix identifies the prefix for the configtxgen-related ENV vars. + Prefix string = "CONFIGTX" + + // The type key for etcd based RAFT consensus. + EtcdRaft = "etcdraft" +) + +const ( + // SampleInsecureSoloProfile references the sample profile which does not + // include any MSPs and uses solo for ordering. + SampleInsecureSoloProfile = "SampleInsecureSolo" + // SampleDevModeSoloProfile references the sample profile which requires + // only basic membership for admin privileges and uses solo for ordering. + SampleDevModeSoloProfile = "SampleDevModeSolo" + // SampleSingleMSPSoloProfile references the sample profile which includes + // only the sample MSP and uses solo for ordering. + SampleSingleMSPSoloProfile = "SampleSingleMSPSolo" + + // SampleInsecureKafkaProfile references the sample profile which does not + // include any MSPs and uses Kafka for ordering. + SampleInsecureKafkaProfile = "SampleInsecureKafka" + // SampleDevModeKafkaProfile references the sample profile which requires only + // basic membership for admin privileges and uses Kafka for ordering. + SampleDevModeKafkaProfile = "SampleDevModeKafka" + // SampleSingleMSPKafkaProfile references the sample profile which includes + // only the sample MSP and uses Kafka for ordering. + SampleSingleMSPKafkaProfile = "SampleSingleMSPKafka" + + // SampleDevModeEtcdRaftProfile references the sample profile used for testing + // the etcd/raft-based ordering service. + SampleDevModeEtcdRaftProfile = "SampleDevModeEtcdRaft" + + // SampleSingleMSPChannelProfile references the sample profile which + // includes only the sample MSP and is used to create a channel + SampleSingleMSPChannelProfile = "SampleSingleMSPChannel" + + // SampleConsortiumName is the sample consortium from the + // sample configtx.yaml + SampleConsortiumName = "SampleConsortium" + // SampleOrgName is the name of the sample org in the sample profiles + SampleOrgName = "SampleOrg" + + // AdminRoleAdminPrincipal is set as AdminRole to cause the MSP role of + // type Admin to be used as the admin principal default + AdminRoleAdminPrincipal = "Role.ADMIN" +) + +// TopLevel consists of the structs used by the configtxgen tool. +type TopLevel struct { + Profiles map[string]*Profile `yaml:"Profiles"` + Organizations []*Organization `yaml:"Organizations"` + Channel *Profile `yaml:"Channel"` + Application *Application `yaml:"Application"` + Orderer *Orderer `yaml:"Orderer"` + Capabilities map[string]map[string]bool `yaml:"Capabilities"` +} + +// Profile encodes orderer/application configuration combinations for the +// configtxgen tool. +type Profile struct { + Consortium string `yaml:"Consortium"` + Application *Application `yaml:"Application"` + Orderer *Orderer `yaml:"Orderer"` + Consortiums map[string]*Consortium `yaml:"Consortiums"` + Capabilities map[string]bool `yaml:"Capabilities"` + Policies map[string]*Policy `yaml:"Policies"` +} + +// Policy encodes a channel config policy +type Policy struct { + Type string `yaml:"Type"` + Rule string `yaml:"Rule"` +} + +// Consortium represents a group of organizations which may create channels +// with each other +type Consortium struct { + Organizations []*Organization `yaml:"Organizations"` +} + +// Application encodes the application-level configuration needed in config +// transactions. +type Application struct { + Organizations []*Organization `yaml:"Organizations"` + Capabilities map[string]bool `yaml:"Capabilities"` + Policies map[string]*Policy `yaml:"Policies"` + ACLs map[string]string `yaml:"ACLs"` +} + +// Organization encodes the organization-level configuration needed in +// config transactions. +type Organization struct { + Name string `yaml:"Name"` + ID string `yaml:"ID"` + MSPDir string `yaml:"MSPDir"` + MSPType string `yaml:"MSPType"` + Policies map[string]*Policy `yaml:"Policies"` + + // Note: Viper deserialization does not seem to care for + // embedding of types, so we use one organization struct + // for both orderers and applications. + AnchorPeers []*AnchorPeer `yaml:"AnchorPeers"` + OrdererEndpoints []string `yaml:"OrdererEndpoints"` + + // AdminPrincipal is deprecated and may be removed in a future release + // it was used for modifying the default policy generation, but policies + // may now be specified explicitly so it is redundant and unnecessary + AdminPrincipal string `yaml:"AdminPrincipal"` + + // SkipAsForeign indicates that this org definition is actually unknown to this + // instance of the tool, so, parsing of this org's parameters should be ignored. + SkipAsForeign bool +} + +// AnchorPeer encodes the necessary fields to identify an anchor peer. +type AnchorPeer struct { + Host string `yaml:"Host"` + Port int `yaml:"Port"` +} + +// Orderer contains configuration associated to a channel. +type Orderer struct { + OrdererType string `yaml:"OrdererType"` + Addresses []string `yaml:"Addresses"` + BatchTimeout time.Duration `yaml:"BatchTimeout"` + BatchSize BatchSize `yaml:"BatchSize"` + Kafka Kafka `yaml:"Kafka"` + EtcdRaft *etcdraft.ConfigMetadata `yaml:"EtcdRaft"` + Organizations []*Organization `yaml:"Organizations"` + MaxChannels uint64 `yaml:"MaxChannels"` + Capabilities map[string]bool `yaml:"Capabilities"` + Policies map[string]*Policy `yaml:"Policies"` +} + +// BatchSize contains configuration affecting the size of batches. +type BatchSize struct { + MaxMessageCount uint32 `yaml:"MaxMessageCount"` + AbsoluteMaxBytes uint32 `yaml:"AbsoluteMaxBytes"` + PreferredMaxBytes uint32 `yaml:"PreferredMaxBytes"` +} + +// Kafka contains configuration for the Kafka-based orderer. +type Kafka struct { + Brokers []string `yaml:"Brokers"` +} diff --git a/internal/github.com/hyperledger/fabric/sdkinternal/configtxlator/update/update.go b/internal/github.com/hyperledger/fabric/sdkinternal/configtxlator/update/update.go new file mode 100644 index 00000000..85db3cd1 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/sdkinternal/configtxlator/update/update.go @@ -0,0 +1,242 @@ +/* +Copyright IBM Corp. 2017 All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package update + +import ( + "bytes" + "fmt" + + "github.com/golang/protobuf/proto" + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/protoutil" +) + +func computePoliciesMapUpdate(original, updated map[string]*cb.ConfigPolicy) (readSet, writeSet, sameSet map[string]*cb.ConfigPolicy, updatedMembers bool) { + readSet = make(map[string]*cb.ConfigPolicy) + writeSet = make(map[string]*cb.ConfigPolicy) + + // All modified config goes into the read/write sets, but in case the map membership changes, we retain the + // config which was the same to add to the read/write sets + sameSet = make(map[string]*cb.ConfigPolicy) + + for policyName, originalPolicy := range original { + updatedPolicy, ok := updated[policyName] + if !ok { + updatedMembers = true + continue + } + + if originalPolicy.ModPolicy == updatedPolicy.ModPolicy && proto.Equal(originalPolicy.Policy, updatedPolicy.Policy) { + sameSet[policyName] = &cb.ConfigPolicy{ + Version: originalPolicy.Version, + } + continue + } + + writeSet[policyName] = &cb.ConfigPolicy{ + Version: originalPolicy.Version + 1, + ModPolicy: updatedPolicy.ModPolicy, + Policy: updatedPolicy.Policy, + } + } + + for policyName, updatedPolicy := range updated { + if _, ok := original[policyName]; ok { + // If the updatedPolicy is in the original set of policies, it was already handled + continue + } + updatedMembers = true + writeSet[policyName] = &cb.ConfigPolicy{ + Version: 0, + ModPolicy: updatedPolicy.ModPolicy, + Policy: updatedPolicy.Policy, + } + } + + return +} + +func computeValuesMapUpdate(original, updated map[string]*cb.ConfigValue) (readSet, writeSet, sameSet map[string]*cb.ConfigValue, updatedMembers bool) { + readSet = make(map[string]*cb.ConfigValue) + writeSet = make(map[string]*cb.ConfigValue) + + // All modified config goes into the read/write sets, but in case the map membership changes, we retain the + // config which was the same to add to the read/write sets + sameSet = make(map[string]*cb.ConfigValue) + + for valueName, originalValue := range original { + updatedValue, ok := updated[valueName] + if !ok { + updatedMembers = true + continue + } + + if originalValue.ModPolicy == updatedValue.ModPolicy && bytes.Equal(originalValue.Value, updatedValue.Value) { + sameSet[valueName] = &cb.ConfigValue{ + Version: originalValue.Version, + } + continue + } + + writeSet[valueName] = &cb.ConfigValue{ + Version: originalValue.Version + 1, + ModPolicy: updatedValue.ModPolicy, + Value: updatedValue.Value, + } + } + + for valueName, updatedValue := range updated { + if _, ok := original[valueName]; ok { + // If the updatedValue is in the original set of values, it was already handled + continue + } + updatedMembers = true + writeSet[valueName] = &cb.ConfigValue{ + Version: 0, + ModPolicy: updatedValue.ModPolicy, + Value: updatedValue.Value, + } + } + + return +} + +func computeGroupsMapUpdate(original, updated map[string]*cb.ConfigGroup) (readSet, writeSet, sameSet map[string]*cb.ConfigGroup, updatedMembers bool) { + readSet = make(map[string]*cb.ConfigGroup) + writeSet = make(map[string]*cb.ConfigGroup) + + // All modified config goes into the read/write sets, but in case the map membership changes, we retain the + // config which was the same to add to the read/write sets + sameSet = make(map[string]*cb.ConfigGroup) + + for groupName, originalGroup := range original { + updatedGroup, ok := updated[groupName] + if !ok { + updatedMembers = true + continue + } + + groupReadSet, groupWriteSet, groupUpdated := computeGroupUpdate(originalGroup, updatedGroup) + if !groupUpdated { + sameSet[groupName] = groupReadSet + continue + } + + readSet[groupName] = groupReadSet + writeSet[groupName] = groupWriteSet + + } + + for groupName, updatedGroup := range updated { + if _, ok := original[groupName]; ok { + // If the updatedGroup is in the original set of groups, it was already handled + continue + } + updatedMembers = true + _, groupWriteSet, _ := computeGroupUpdate(protoutil.NewConfigGroup(), updatedGroup) + writeSet[groupName] = &cb.ConfigGroup{ + Version: 0, + ModPolicy: updatedGroup.ModPolicy, + Policies: groupWriteSet.Policies, + Values: groupWriteSet.Values, + Groups: groupWriteSet.Groups, + } + } + + return +} + +func computeGroupUpdate(original, updated *cb.ConfigGroup) (readSet, writeSet *cb.ConfigGroup, updatedGroup bool) { + readSetPolicies, writeSetPolicies, sameSetPolicies, policiesMembersUpdated := computePoliciesMapUpdate(original.Policies, updated.Policies) + readSetValues, writeSetValues, sameSetValues, valuesMembersUpdated := computeValuesMapUpdate(original.Values, updated.Values) + readSetGroups, writeSetGroups, sameSetGroups, groupsMembersUpdated := computeGroupsMapUpdate(original.Groups, updated.Groups) + + // If the updated group is 'Equal' to the updated group (none of the members nor the mod policy changed) + if !(policiesMembersUpdated || valuesMembersUpdated || groupsMembersUpdated || original.ModPolicy != updated.ModPolicy) { + + // If there were no modified entries in any of the policies/values/groups maps + if len(readSetPolicies) == 0 && + len(writeSetPolicies) == 0 && + len(readSetValues) == 0 && + len(writeSetValues) == 0 && + len(readSetGroups) == 0 && + len(writeSetGroups) == 0 { + return &cb.ConfigGroup{ + Version: original.Version, + }, &cb.ConfigGroup{ + Version: original.Version, + }, false + } + + return &cb.ConfigGroup{ + Version: original.Version, + Policies: readSetPolicies, + Values: readSetValues, + Groups: readSetGroups, + }, &cb.ConfigGroup{ + Version: original.Version, + Policies: writeSetPolicies, + Values: writeSetValues, + Groups: writeSetGroups, + }, true + } + + for k, samePolicy := range sameSetPolicies { + readSetPolicies[k] = samePolicy + writeSetPolicies[k] = samePolicy + } + + for k, sameValue := range sameSetValues { + readSetValues[k] = sameValue + writeSetValues[k] = sameValue + } + + for k, sameGroup := range sameSetGroups { + readSetGroups[k] = sameGroup + writeSetGroups[k] = sameGroup + } + + return &cb.ConfigGroup{ + Version: original.Version, + Policies: readSetPolicies, + Values: readSetValues, + Groups: readSetGroups, + }, &cb.ConfigGroup{ + Version: original.Version + 1, + Policies: writeSetPolicies, + Values: writeSetValues, + Groups: writeSetGroups, + ModPolicy: updated.ModPolicy, + }, true +} + +func Compute(original, updated *cb.Config) (*cb.ConfigUpdate, error) { + if original.ChannelGroup == nil { + return nil, fmt.Errorf("no channel group included for original config") + } + + if updated.ChannelGroup == nil { + return nil, fmt.Errorf("no channel group included for updated config") + } + + readSet, writeSet, groupUpdated := computeGroupUpdate(original.ChannelGroup, updated.ChannelGroup) + if !groupUpdated { + return nil, fmt.Errorf("no differences detected between original and updated config") + } + return &cb.ConfigUpdate{ + ReadSet: readSet, + WriteSet: writeSet, + }, nil +} diff --git a/internal/github.com/hyperledger/fabric/sdkinternal/pkg/comm/config.go b/internal/github.com/hyperledger/fabric/sdkinternal/pkg/comm/config.go new file mode 100644 index 00000000..b82afd12 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/sdkinternal/pkg/comm/config.go @@ -0,0 +1,173 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package comm + +import ( + "crypto/tls" + "crypto/x509" + "time" + + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/metrics" + flogging "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/logbridge" + "google.golang.org/grpc" + "google.golang.org/grpc/keepalive" +) + +// Configuration defaults +var ( + // Max send and receive bytes for grpc clients and servers + MaxRecvMsgSize = 100 * 1024 * 1024 + MaxSendMsgSize = 100 * 1024 * 1024 + // Default peer keepalive options + DefaultKeepaliveOptions = KeepaliveOptions{ + ClientInterval: time.Duration(1) * time.Minute, // 1 min + ClientTimeout: time.Duration(20) * time.Second, // 20 sec - gRPC default + ServerInterval: time.Duration(2) * time.Hour, // 2 hours - gRPC default + ServerTimeout: time.Duration(20) * time.Second, // 20 sec - gRPC default + ServerMinInterval: time.Duration(1) * time.Minute, // match ClientInterval + } + // strong TLS cipher suites + DefaultTLSCipherSuites = []uint16{ + tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, + tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + tls.TLS_RSA_WITH_AES_128_GCM_SHA256, + tls.TLS_RSA_WITH_AES_256_GCM_SHA384, + } + // default connection timeout + DefaultConnectionTimeout = 5 * time.Second +) + +// ServerConfig defines the parameters for configuring a GRPCServer instance +type ServerConfig struct { + // ConnectionTimeout specifies the timeout for connection establishment + // for all new connections + ConnectionTimeout time.Duration + // SecOpts defines the security parameters + SecOpts SecureOptions + // KaOpts defines the keepalive parameters + KaOpts KeepaliveOptions + // StreamInterceptors specifies a list of interceptors to apply to + // streaming RPCs. They are executed in order. + StreamInterceptors []grpc.StreamServerInterceptor + // UnaryInterceptors specifies a list of interceptors to apply to unary + // RPCs. They are executed in order. + UnaryInterceptors []grpc.UnaryServerInterceptor + // Logger specifies the logger the server will use + Logger *flogging.Logger + // Metrics Provider + MetricsProvider metrics.Provider + // HealthCheckEnabled enables the gRPC Health Checking Protocol for the server + HealthCheckEnabled bool +} + +// ClientConfig defines the parameters for configuring a GRPCClient instance +type ClientConfig struct { + // SecOpts defines the security parameters + SecOpts SecureOptions + // KaOpts defines the keepalive parameters + KaOpts KeepaliveOptions + // Timeout specifies how long the client will block when attempting to + // establish a connection + Timeout time.Duration + // AsyncConnect makes connection creation non blocking + AsyncConnect bool +} + +// Clone clones this ClientConfig +func (cc ClientConfig) Clone() ClientConfig { + shallowClone := cc + return shallowClone +} + +// SecureOptions defines the security parameters (e.g. TLS) for a +// GRPCServer or GRPCClient instance +type SecureOptions struct { + // VerifyCertificate, if not nil, is called after normal + // certificate verification by either a TLS client or server. + // If it returns a non-nil error, the handshake is aborted and that error results. + VerifyCertificate func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error + // PEM-encoded X509 public key to be used for TLS communication + Certificate []byte + // PEM-encoded private key to be used for TLS communication + Key []byte + // Set of PEM-encoded X509 certificate authorities used by clients to + // verify server certificates + ServerRootCAs [][]byte + // Set of PEM-encoded X509 certificate authorities used by servers to + // verify client certificates + ClientRootCAs [][]byte + // Whether or not to use TLS for communication + UseTLS bool + // Whether or not TLS client must present certificates for authentication + RequireClientCert bool + // CipherSuites is a list of supported cipher suites for TLS + CipherSuites []uint16 + // TimeShift makes TLS handshakes time sampling shift to the past by a given duration + TimeShift time.Duration +} + +// KeepaliveOptions is used to set the gRPC keepalive settings for both +// clients and servers +type KeepaliveOptions struct { + // ClientInterval is the duration after which if the client does not see + // any activity from the server it pings the server to see if it is alive + ClientInterval time.Duration + // ClientTimeout is the duration the client waits for a response + // from the server after sending a ping before closing the connection + ClientTimeout time.Duration + // ServerInterval is the duration after which if the server does not see + // any activity from the client it pings the client to see if it is alive + ServerInterval time.Duration + // ServerTimeout is the duration the server waits for a response + // from the client after sending a ping before closing the connection + ServerTimeout time.Duration + // ServerMinInterval is the minimum permitted time between client pings. + // If clients send pings more frequently, the server will disconnect them + ServerMinInterval time.Duration +} + +type Metrics struct { + // OpenConnCounter keeps track of number of open connections + OpenConnCounter metrics.Counter + // ClosedConnCounter keeps track of number connections closed + ClosedConnCounter metrics.Counter +} + +// ServerKeepaliveOptions returns gRPC keepalive options for server. +func ServerKeepaliveOptions(ka KeepaliveOptions) []grpc.ServerOption { + var serverOpts []grpc.ServerOption + kap := keepalive.ServerParameters{ + Time: ka.ServerInterval, + Timeout: ka.ServerTimeout, + } + serverOpts = append(serverOpts, grpc.KeepaliveParams(kap)) + kep := keepalive.EnforcementPolicy{ + MinTime: ka.ServerMinInterval, + // allow keepalive w/o rpc + PermitWithoutStream: true, + } + serverOpts = append(serverOpts, grpc.KeepaliveEnforcementPolicy(kep)) + return serverOpts +} + +// ClientKeepaliveOptions returns gRPC keepalive options for clients. +func ClientKeepaliveOptions(ka KeepaliveOptions) []grpc.DialOption { + var dialOpts []grpc.DialOption + kap := keepalive.ClientParameters{ + Time: ka.ClientInterval, + Timeout: ka.ClientTimeout, + PermitWithoutStream: true, + } + dialOpts = append(dialOpts, grpc.WithKeepaliveParams(kap)) + return dialOpts +} diff --git a/internal/github.com/hyperledger/fabric/sdkinternal/pkg/identity/identity.go b/internal/github.com/hyperledger/fabric/sdkinternal/pkg/identity/identity.go new file mode 100644 index 00000000..458512e5 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/sdkinternal/pkg/identity/identity.go @@ -0,0 +1,33 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +// Package identity provides a set of interfaces for identity-related operations. + +package identity + +// Signer is an interface which wraps the Sign method. +// +// Sign signs message bytes and returns the signature or an error on failure. +type Signer interface { + Sign(message []byte) ([]byte, error) +} + +// Serializer is an interface which wraps the Serialize function. +// +// Serialize converts an identity to bytes. It returns an error on failure. +type Serializer interface { + Serialize() ([]byte, error) +} + +// SignerSerializer groups the Sign and Serialize methods. +type SignerSerializer interface { + Signer + Serializer +} diff --git a/internal/github.com/hyperledger/fabric/sdkinternal/pkg/txflags/validation_flags.go b/internal/github.com/hyperledger/fabric/sdkinternal/pkg/txflags/validation_flags.go new file mode 100644 index 00000000..4e20a42d --- /dev/null +++ b/internal/github.com/hyperledger/fabric/sdkinternal/pkg/txflags/validation_flags.go @@ -0,0 +1,64 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package txflags + +import ( + "github.com/hyperledger/fabric-protos-go/peer" +) + +// ValidationFlags is array of transaction validation codes. It is used when committer validates block. +type ValidationFlags []uint8 + +// New create new object-array of validation codes with target size. +// Default values: TxValidationCode_NOT_VALIDATED +func New(size int) ValidationFlags { + return newWithValues(size, peer.TxValidationCode_NOT_VALIDATED) +} + +// NewWithValues creates new object-array of validation codes with target size +// and the supplied value +func NewWithValues(size int, value peer.TxValidationCode) ValidationFlags { + return newWithValues(size, value) +} + +func newWithValues(size int, value peer.TxValidationCode) ValidationFlags { + inst := make(ValidationFlags, size) + for i := range inst { + inst[i] = uint8(value) + } + + return inst +} + +// SetFlag assigns validation code to specified transaction +func (obj ValidationFlags) SetFlag(txIndex int, flag peer.TxValidationCode) { + obj[txIndex] = uint8(flag) +} + +// Flag returns validation code at specified transaction +func (obj ValidationFlags) Flag(txIndex int) peer.TxValidationCode { + return peer.TxValidationCode(obj[txIndex]) +} + +// IsValid checks if specified transaction is valid +func (obj ValidationFlags) IsValid(txIndex int) bool { + return obj.IsSetTo(txIndex, peer.TxValidationCode_VALID) +} + +// IsInvalid checks if specified transaction is invalid +func (obj ValidationFlags) IsInvalid(txIndex int) bool { + return !obj.IsValid(txIndex) +} + +// IsSetTo returns true if the specified transaction equals flag; false otherwise. +func (obj ValidationFlags) IsSetTo(txIndex int, flag peer.TxValidationCode) bool { + return obj.Flag(txIndex) == flag +} diff --git a/internal/github.com/hyperledger/fabric/sdkpatch/cachebridge/cache.go b/internal/github.com/hyperledger/fabric/sdkpatch/cachebridge/cache.go new file mode 100644 index 00000000..3b1d3c6f --- /dev/null +++ b/internal/github.com/hyperledger/fabric/sdkpatch/cachebridge/cache.go @@ -0,0 +1,125 @@ +/* +Copyright SecureKey Technologies Inc. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package cachebridge + +import ( + "fmt" + "time" + + "encoding/hex" + + "github.com/hyperledger/fabric-sdk-go/pkg/util/concurrent/lazycache" + flogging "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/logbridge" + "github.com/miekg/pkcs11" +) + +var logger = flogging.MustGetLogger("bccsp_p11_sessioncache") + +var sessionCache = newSessionCache() + +const ( + privateKeyFlag = true +) + +// keyPairCacheKey +type KeyPairCacheKey struct { + Mod *pkcs11.Ctx + Session pkcs11.SessionHandle + SKI []byte + KeyType bool +} + +//String return string value for keyPairCacheKey +func (keyPairCacheKey *KeyPairCacheKey) String() string { + return fmt.Sprintf("%x_%t", keyPairCacheKey.SKI, keyPairCacheKey.KeyType) +} + +// SessionCacheKey +type SessionCacheKey struct { + SessionID string +} + +//String return string value for SessionCacheKey +func (SessionCacheKey *SessionCacheKey) String() string { + return SessionCacheKey.SessionID +} + +func newSessionCache() *lazycache.Cache { + return lazycache.New( + "Session_Resolver_Cache", + func(key lazycache.Key) (interface{}, error) { + return lazycache.New( + "KeyPair_Resolver_Cache", + func(key lazycache.Key) (interface{}, error) { + return getKeyPairFromSKI(key.(*KeyPairCacheKey)) + }), nil + }) +} + +func timeTrack(start time.Time, msg string) { + elapsed := time.Since(start) + logger.Debugf("%s took %s", msg, elapsed) +} + +func ClearAllSession() { + sessionCache.DeleteAll() +} + +func ClearSession(key string) { + sessionCache.Delete(&SessionCacheKey{SessionID: key}) +} + +func GetKeyPairFromSessionSKI(keyPairCacheKey *KeyPairCacheKey) (*pkcs11.ObjectHandle, error) { + keyPairCache, err := sessionCache.Get(&SessionCacheKey{SessionID: fmt.Sprintf("%d", keyPairCacheKey.Session)}) + if err != nil { + return nil, err + } + if keyPairCache != nil { + val := keyPairCache.(*lazycache.Cache) + defer timeTrack(time.Now(), fmt.Sprintf("finding key [session: %d] [ski: %x]", keyPairCacheKey.Session, keyPairCacheKey.SKI)) + value, err := val.Get(keyPairCacheKey) + if err != nil { + return nil, err + } + return value.(*pkcs11.ObjectHandle), nil + } + return nil, fmt.Errorf("cannot find session in sessionCache") +} + +func getKeyPairFromSKI(keyPairCacheKey *KeyPairCacheKey) (*pkcs11.ObjectHandle, error) { + ktype := pkcs11.CKO_PUBLIC_KEY + if keyPairCacheKey.KeyType == privateKeyFlag { + ktype = pkcs11.CKO_PRIVATE_KEY + } + + template := []*pkcs11.Attribute{ + pkcs11.NewAttribute(pkcs11.CKA_CLASS, ktype), + pkcs11.NewAttribute(pkcs11.CKA_ID, keyPairCacheKey.SKI), + } + if err := keyPairCacheKey.Mod.FindObjectsInit(keyPairCacheKey.Session, template); err != nil { + return nil, err + } + + // single session instance, assume one hit only + objs, _, err := keyPairCacheKey.Mod.FindObjects(keyPairCacheKey.Session, 1) + if err != nil { + return nil, err + } + if err = keyPairCacheKey.Mod.FindObjectsFinal(keyPairCacheKey.Session); err != nil { + return nil, err + } + + if len(objs) == 0 { + return nil, fmt.Errorf("Key not found [%s]", hex.Dump(keyPairCacheKey.SKI)) + } + + return &objs[0], nil +} diff --git a/internal/github.com/hyperledger/fabric/sdkpatch/cryptosuitebridge/cryptosuitebridge.go b/internal/github.com/hyperledger/fabric/sdkpatch/cryptosuitebridge/cryptosuitebridge.go new file mode 100644 index 00000000..a6391d97 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/sdkpatch/cryptosuitebridge/cryptosuitebridge.go @@ -0,0 +1,104 @@ +/* +Copyright SecureKey Technologies Inc. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package cryptosuitebridge + +import ( + "crypto" + "crypto/ecdsa" + + "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core" + "github.com/hyperledger/fabric-sdk-go/pkg/core/cryptosuite" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/bccsp" + cspsigner "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/bccsp/signer" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/bccsp/utils" +) + +const ( + ECDSA = bccsp.ECDSA + ECDSAP256 = bccsp.ECDSAP256 + ECDSAP384 = bccsp.ECDSAP384 + ECDSAReRand = bccsp.ECDSAReRand + AES = bccsp.AES + AES128 = bccsp.AES128 + AES192 = bccsp.AES192 + AES256 = bccsp.AES256 + HMAC = bccsp.HMAC + HMACTruncated256 = bccsp.HMACTruncated256 + SHA = bccsp.SHA + SHA2 = bccsp.SHA2 + SHA3 = bccsp.SHA3 + SHA256 = bccsp.SHA256 + SHA384 = bccsp.SHA384 + SHA3_256 = bccsp.SHA3_256 + SHA3_384 = bccsp.SHA3_384 + X509Certificate = bccsp.X509Certificate +) + +// NewCspSigner is a bridge for bccsp signer.New call +func NewCspSigner(csp core.CryptoSuite, key core.Key) (crypto.Signer, error) { + return cspsigner.New(csp, key) +} + +//GetDefault creates new cryptosuite from bccsp factory default +func GetDefault() core.CryptoSuite { + return cryptosuite.GetDefault() +} + +//SignatureToLowS is a bridge for bccsp utils.SignatureToLowS() +func SignatureToLowS(k *ecdsa.PublicKey, signature []byte) ([]byte, error) { + return utils.SignatureToLowS(k, signature) +} + +//GetHashOpt is a bridge for bccsp util GetHashOpt +func GetHashOpt(hashFunction string) (core.HashOpts, error) { + return bccsp.GetHashOpt(hashFunction) +} + +//GetSHAOpts returns options for computing SHA. +func GetSHAOpts() core.HashOpts { + return &bccsp.SHAOpts{} +} + +//GetSHA256Opts returns options relating to SHA-256. +func GetSHA256Opts() core.HashOpts { + return &bccsp.SHA256Opts{} +} + +//GetSHA3256Opts returns options relating to SHA-256. +func GetSHA3256Opts() core.HashOpts { + return &bccsp.SHA3_256Opts{} +} + +// GetECDSAKeyGenOpts returns options for ECDSA key generation. +func GetECDSAKeyGenOpts(ephemeral bool) core.KeyGenOpts { + return &bccsp.ECDSAKeyGenOpts{Temporary: ephemeral} +} + +//GetECDSAP256KeyGenOpts returns options for ECDSA key generation with curve P-256. +func GetECDSAP256KeyGenOpts(ephemeral bool) core.KeyGenOpts { + return &bccsp.ECDSAP256KeyGenOpts{Temporary: ephemeral} +} + +//GetECDSAP384KeyGenOpts options for ECDSA key generation with curve P-384. +func GetECDSAP384KeyGenOpts(ephemeral bool) core.KeyGenOpts { + return &bccsp.ECDSAP384KeyGenOpts{Temporary: ephemeral} +} + +//GetX509PublicKeyImportOpts options for importing public keys from an x509 certificate +func GetX509PublicKeyImportOpts(ephemeral bool) core.KeyImportOpts { + return &bccsp.X509PublicKeyImportOpts{Temporary: ephemeral} +} + +//GetECDSAPrivateKeyImportOpts options for ECDSA secret key importation in DER format +// or PKCS#8 format. +func GetECDSAPrivateKeyImportOpts(ephemeral bool) core.KeyImportOpts { + return &bccsp.ECDSAPrivateKeyImportOpts{Temporary: ephemeral} +} diff --git a/internal/github.com/hyperledger/fabric/sdkpatch/keyutil/keys.go b/internal/github.com/hyperledger/fabric/sdkpatch/keyutil/keys.go new file mode 100644 index 00000000..0594c679 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/sdkpatch/keyutil/keys.go @@ -0,0 +1,73 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package keyutil + +import ( + "crypto/ecdsa" + "crypto/x509" + "encoding/pem" + "errors" + "fmt" +) + +func derToPrivateKey(der []byte) (key interface{}, err error) { + + if key, err = x509.ParsePKCS1PrivateKey(der); err == nil { + return key, nil + } + + if key, err = x509.ParsePKCS8PrivateKey(der); err == nil { + switch key.(type) { + case *ecdsa.PrivateKey: + return + default: + return nil, errors.New("found unknown private key type in PKCS#8 wrapping") + } + } + + if key, err = x509.ParseECPrivateKey(der); err == nil { + return + } + + return nil, errors.New("invalid key type. The DER must contain an ecdsa.PrivateKey") +} + +func PEMToPrivateKey(raw []byte, pwd []byte) (interface{}, error) { + block, _ := pem.Decode(raw) + if block == nil { + return nil, fmt.Errorf("failed decoding PEM. Block must be different from nil [% x]", raw) + } + + // TODO: derive from header the type of the key + + if x509.IsEncryptedPEMBlock(block) { + if len(pwd) == 0 { + return nil, errors.New("encrypted Key. Need a password") + } + + decrypted, err := x509.DecryptPEMBlock(block, pwd) + if err != nil { + return nil, fmt.Errorf("failed PEM decryption: [%s]", err) + } + + key, err := derToPrivateKey(decrypted) + if err != nil { + return nil, err + } + return key, err + } + + cert, err := derToPrivateKey(block.Bytes) + if err != nil { + return nil, err + } + return cert, err +} diff --git a/internal/github.com/hyperledger/fabric/sdkpatch/logbridge/httpadmin/spec.go b/internal/github.com/hyperledger/fabric/sdkpatch/logbridge/httpadmin/spec.go new file mode 100644 index 00000000..4a8e9983 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/sdkpatch/logbridge/httpadmin/spec.go @@ -0,0 +1,85 @@ +/* +Copyright IBM Corp. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package httpadmin + +import ( + "encoding/json" + "fmt" + "net/http" + + flogging "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkpatch/logbridge" +) + +//go:generate counterfeiter -o fakes/logging.go -fake-name Logging . Logging + +type Logging interface { + ActivateSpec(spec string) error + Spec() string +} + +type LogSpec struct { + Spec string `json:"spec,omitempty"` +} + +type ErrorResponse struct { + Error string `json:"error"` +} + +func NewSpecHandler() *SpecHandler { + return &SpecHandler{ + Logger: flogging.MustGetLogger("flogging.httpadmin"), + } +} + +type SpecHandler struct { + Logging Logging + Logger *flogging.Logger +} + +func (h *SpecHandler) ServeHTTP(resp http.ResponseWriter, req *http.Request) { + switch req.Method { + case http.MethodPut: + var logSpec LogSpec + decoder := json.NewDecoder(req.Body) + if err := decoder.Decode(&logSpec); err != nil { + h.sendResponse(resp, http.StatusBadRequest, err) + return + } + req.Body.Close() + + if err := h.Logging.ActivateSpec(logSpec.Spec); err != nil { + h.sendResponse(resp, http.StatusBadRequest, err) + return + } + resp.WriteHeader(http.StatusNoContent) + + case http.MethodGet: + h.sendResponse(resp, http.StatusOK, &LogSpec{Spec: h.Logging.Spec()}) + + default: + err := fmt.Errorf("invalid request method: %s", req.Method) + h.sendResponse(resp, http.StatusBadRequest, err) + } +} + +func (h *SpecHandler) sendResponse(resp http.ResponseWriter, code int, payload interface{}) { + encoder := json.NewEncoder(resp) + if err, ok := payload.(error); ok { + payload = &ErrorResponse{Error: err.Error()} + } + + resp.WriteHeader(code) + + resp.Header().Set("Content-Type", "application/json") + if err := encoder.Encode(payload); err != nil { + h.Logger.Errorf("[error] failed to encode payload", err) + } +} diff --git a/internal/github.com/hyperledger/fabric/sdkpatch/logbridge/logbridge.go b/internal/github.com/hyperledger/fabric/sdkpatch/logbridge/logbridge.go new file mode 100644 index 00000000..e01096e1 --- /dev/null +++ b/internal/github.com/hyperledger/fabric/sdkpatch/logbridge/logbridge.go @@ -0,0 +1,55 @@ +/* +Copyright SecureKey Technologies Inc. All Rights Reserved. + +SPDX-License-Identifier: Apache-2.0 +*/ +/* +Notice: This file has been modified for Hyperledger Fabric SDK Go usage. +Please review third_party pinning scripts and patches for more details. +*/ + +package logbridge + +import ( + "github.com/hyperledger/fabric-sdk-go/pkg/common/logging" +) + +// Log levels (from fabric-sdk-go/pkg/logging/level.go). +const ( + CRITICAL logging.Level = iota + ERROR + WARNING + INFO + DEBUG +) + +// Logger bridges the SDK's logger struct +type Logger struct { + *logging.Logger + module string +} + +// MustGetLogger bridges calls the Go SDK NewLogger +func MustGetLogger(module string) *Logger { + fabModule := "fabsdk/fab" + logger := logging.NewLogger(fabModule) + return &Logger{ + Logger: logger, + module: fabModule, + } +} + +// Warningf bridges calls to the Go SDK logger's Warnf. +func (l *Logger) Warningf(format string, args ...interface{}) { + l.Warnf(format, args...) +} + +// Warning bridges calls to the Go SDK logger's Warn. +func (l *Logger) Warning(args ...interface{}) { + l.Warn(args...) +} + +// IsEnabledFor bridges calls to the Go SDK logger's IsEnabledFor. +func (l *Logger) IsEnabledFor(level logging.Level) bool { + return logging.IsEnabledFor(l.module, level) +} diff --git a/kubectl-hlf/cmd/channel/addanchorpeer.go b/kubectl-hlf/cmd/channel/addanchorpeer.go new file mode 100644 index 00000000..8120034f --- /dev/null +++ b/kubectl-hlf/cmd/channel/addanchorpeer.go @@ -0,0 +1,162 @@ +package channel + +import ( + "bytes" + "fmt" + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-config/configtx" + "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-protos-go/peer" + "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt" + "github.com/hyperledger/fabric-sdk-go/pkg/core/config" + "github.com/hyperledger/fabric-sdk-go/pkg/fab/resource" + "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk" + "github.com/hyperledger/fabric/protoutil" + "github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "io" +) + +type addAnchorPeerCmd struct { + configPath string + peer string + channelName string + userName string +} + +func (c *addAnchorPeerCmd) validate() error { + return nil +} + +func uniqueAnchorPeers(anchorPeers []*peer.AnchorPeer) []*peer.AnchorPeer { + keys := make(map[string]bool) + var list []*peer.AnchorPeer + for _, entry := range anchorPeers { + key := fmt.Sprintf("%s:%d", entry.Host, entry.Port) + if _, value := keys[key]; !value { + keys[key] = true + list = append(list, entry) + } + } + return list +} +func (c *addAnchorPeerCmd) run() error { + oclient, err := helpers.GetKubeOperatorClient() + if err != nil { + return err + } + configBackend := config.FromFile(c.configPath) + sdk, err := fabsdk.New(configBackend) + if err != nil { + return err + } + clientSet, err := helpers.GetKubeClient() + if err != nil { + return err + } + adminPeer, err := helpers.GetPeerByFullName(clientSet, oclient, c.peer) + if err != nil { + return err + } + mspID := adminPeer.Spec.MspID + org1AdminClientContext := sdk.Context( + fabsdk.WithUser(c.userName), + fabsdk.WithOrg(mspID), + ) + resClient, err := resmgmt.New(org1AdminClientContext) + if err != nil { + return err + } + block, err := resClient.QueryConfigBlockFromOrderer(c.channelName) + if err != nil { + return err + } + cfgBlock, err := resource.ExtractConfigFromBlock(block) + if err != nil { + return err + } + cftxGen := configtx.New(cfgBlock) + app := cftxGen.Application().Organization(mspID) + peerHostName, peerPort, err := helpers.GetPeerHostAndPort(clientSet, adminPeer.Spec, adminPeer.Status) + if err != nil { + return err + } + anchorPeers, err := app.AnchorPeers() + if err != nil { + return err + } + log.Printf("Anchor peers %v", anchorPeers) + anchorPeers = []configtx.Address{} + err = app.AddAnchorPeer(configtx.Address{ + Host: peerHostName, + Port: peerPort, + }) + if err != nil { + return err + } + configUpdateBytes, err := cftxGen.ComputeMarshaledUpdate(c.channelName) + if err != nil { + return err + } + configUpdate := &common.ConfigUpdate{} + err = proto.Unmarshal(configUpdateBytes, configUpdate) + if err != nil { + return err + } + channelConfigBytes, err := CreateConfigUpdateEnvelope(c.channelName, configUpdate) + if err != nil { + return err + } + configUpdateReader := bytes.NewReader(channelConfigBytes) + chResponse, err := resClient.SaveChannel(resmgmt.SaveChannelRequest{ + ChannelID: c.channelName, + ChannelConfig: configUpdateReader, + }) + if err != nil { + return err + } + log.Infof("anchor anchorPeers added: %s", chResponse.TransactionID) + return nil +} +func newAddAnchorPeerCMD(io.Writer, io.Writer) *cobra.Command { + c := &addAnchorPeerCmd{} + cmd := &cobra.Command{ + Use: "addanchorpeer", + RunE: func(cmd *cobra.Command, args []string) error { + if err := c.validate(); err != nil { + return err + } + return c.run() + }, + } + persistentFlags := cmd.PersistentFlags() + persistentFlags.StringVarP(&c.peer, "peer", "", "", "Name of the peer to invoke the updates") + persistentFlags.StringVarP(&c.channelName, "channel", "", "", "Channel name") + persistentFlags.StringVarP(&c.configPath, "config", "", "", "Configuration file for the SDK") + persistentFlags.StringVarP(&c.userName, "user", "", "", "User name for the transaction") + cmd.MarkPersistentFlagRequired("channel") + cmd.MarkPersistentFlagRequired("config") + cmd.MarkPersistentFlagRequired("user") + cmd.MarkPersistentFlagRequired("peer") + return cmd +} + +func CreateConfigUpdateEnvelope(channelID string, configUpdate *common.ConfigUpdate) ([]byte, error) { + configUpdate.ChannelId = channelID + configUpdateData, err := proto.Marshal(configUpdate) + if err != nil { + return nil, err + } + configUpdateEnvelope := &common.ConfigUpdateEnvelope{} + configUpdateEnvelope.ConfigUpdate = configUpdateData + envelope, err := protoutil.CreateSignedEnvelope(common.HeaderType_CONFIG_UPDATE, channelID, nil, configUpdateEnvelope, 0, 0) + if err != nil { + return nil, err + } + envelopeData, err := proto.Marshal(envelope) + if err != nil { + return nil, err + } + return envelopeData, nil +} diff --git a/kubectl-hlf/cmd/channel/addorg.go b/kubectl-hlf/cmd/channel/addorg.go new file mode 100644 index 00000000..d8a63080 --- /dev/null +++ b/kubectl-hlf/cmd/channel/addorg.go @@ -0,0 +1,153 @@ +package channel + +import ( + "bytes" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/channelconfig" + "io" + "io/ioutil" + + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-config/protolator" + "github.com/hyperledger/fabric-protos-go/common" + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt" + "github.com/hyperledger/fabric-sdk-go/pkg/core/config" + "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/encoder" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/genesisconfig" + "github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers" + "github.com/pkg/errors" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "gopkg.in/yaml.v2" +) + +type addOrgCmd struct { + configPath string + orgPath string + peer string + channelName string + userName string + mspID string + dryRun bool +} + +func (c *addOrgCmd) validate() error { + return nil +} +func (c *addOrgCmd) run(out io.Writer) error { + oclient, err := helpers.GetKubeOperatorClient() + if err != nil { + return err + } + clientSet, err := helpers.GetKubeClient() + if err != nil { + return err + } + peer, err := helpers.GetPeerByFullName(clientSet, oclient, c.peer) + if err != nil { + return err + } + mspID := peer.Spec.MspID + configBackend := config.FromFile(c.configPath) + sdk, err := fabsdk.New(configBackend) + if err != nil { + return err + } + org1AdminClientContext := sdk.Context( + fabsdk.WithUser(c.userName), + fabsdk.WithOrg(mspID), + ) + resClient, err := resmgmt.New(org1AdminClientContext) + if err != nil { + return err + } + channelID := c.channelName + channelConfig, err := helpers.GetCurrentConfigFromPeer(resClient, channelID) + if err != nil { + return err + } + modifiedConfig := &common.Config{} + modifiedConfigBytes, err := proto.Marshal(channelConfig) + if err != nil { + return err + } + err = proto.Unmarshal(modifiedConfigBytes, modifiedConfig) + if err != nil { + return err + } + orgBytes, err := ioutil.ReadFile(c.orgPath) + if err != nil { + return err + } + topLevel := &genesisconfig.TopLevel{} + err = yaml.Unmarshal(orgBytes, topLevel) + if err != nil { + return err + } + var orgConfig *cb.ConfigGroup + for _, org := range topLevel.Organizations { + if org.Name == c.mspID { + orgConfig, err = encoder.NewApplicationOrgGroup(org) + if err != nil { + return err + } + } + } + if orgConfig == nil { + return errors.Errorf("msp ID %s not found", c.mspID) + } + modifiedConfig.ChannelGroup.Groups[channelconfig.ApplicationGroupKey].Groups[c.mspID] = orgConfig + confUpdate, err := resmgmt.CalculateConfigUpdate(channelID, channelConfig, modifiedConfig) + if err != nil { + return err + } + if c.dryRun { + err = protolator.DeepMarshalJSON(out, confUpdate) + if err != nil { + return err + } + } else { + configEnvelopeBytes, err := helpers.GetConfigEnvelopeBytes(confUpdate) + if err != nil { + return err + } + configReader := bytes.NewReader(configEnvelopeBytes) + txID, err := resClient.SaveChannel(resmgmt.SaveChannelRequest{ + ChannelID: channelID, + ChannelConfig: configReader, + }) + if err != nil { + return err + } + log.Infof("Channel updated, txID=%s", string(txID.TransactionID)) + } + return nil +} +func newAddOrgToChannelCMD(out io.Writer, errOut io.Writer) *cobra.Command { + c := &addOrgCmd{} + cmd := &cobra.Command{ + Use: "addorg", + RunE: func(cmd *cobra.Command, args []string) error { + if err := c.validate(); err != nil { + return err + } + return c.run(out) + }, + } + persistentFlags := cmd.PersistentFlags() + persistentFlags.StringVarP(&c.peer, "peer", "", "", "Name of the peer to invoke the updates") + persistentFlags.StringVarP(&c.channelName, "name", "", "", "Channel name") + persistentFlags.StringVarP(&c.configPath, "config", "", "", "Configuration file for the SDK") + persistentFlags.StringVarP(&c.userName, "user", "", "", "User name for the transaction") + persistentFlags.StringVarP(&c.mspID, "msp-id", "", "", "MSP ID for the new organization") + persistentFlags.StringVarP(&c.orgPath, "org-config", "", "", "JSON with the crypto material for the new org") + persistentFlags.BoolVarP(&c.dryRun, "dry-run", "", false, "Output configuration as JSON and not update") + cmd.MarkPersistentFlagRequired("name") + cmd.MarkPersistentFlagRequired("config") + cmd.MarkPersistentFlagRequired("peer") + cmd.MarkPersistentFlagRequired("org-config") + cmd.MarkPersistentFlagRequired("msp-id") + cmd.MarkPersistentFlagRequired("user") + return cmd +} diff --git a/kubectl-hlf/cmd/channel/channel.go b/kubectl-hlf/cmd/channel/channel.go index 43a432b9..bd4826b5 100644 --- a/kubectl-hlf/cmd/channel/channel.go +++ b/kubectl-hlf/cmd/channel/channel.go @@ -1,6 +1,8 @@ package channel import ( + "github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/channel/consenter" + "github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/channel/ordorg" "io" "github.com/spf13/cobra" @@ -11,9 +13,18 @@ func NewChannelCmd(stdOut io.Writer, stdErr io.Writer) *cobra.Command { Use: "channel", } channelCmd.AddCommand( + newCreateChannelCMD(stdOut, stdErr), + newJoinChannelCMD(stdOut, stdErr), + newSignUpdateChannelCMD(stdOut, stdErr), + newAddAnchorPeerCMD(stdOut, stdErr), newUpdateChannelCMD(stdOut, stdErr), + newGenerateChannelCMD(stdOut, stdErr), newInspectChannelCMD(stdOut, stdErr), newTopChannelCMD(stdOut, stdErr), + newAddOrgToChannelCMD(stdOut, stdErr), + ordorg.NewOrdOrgCmd(stdOut, stdErr), + consenter.NewConsenterCmd(stdOut, stdErr), + newDelAnchorPeerCMD(stdOut, stdErr), ) return channelCmd } diff --git a/kubectl-hlf/cmd/channel/consenter/add.go b/kubectl-hlf/cmd/channel/consenter/add.go new file mode 100644 index 00000000..e4863ba7 --- /dev/null +++ b/kubectl-hlf/cmd/channel/consenter/add.go @@ -0,0 +1,138 @@ +package consenter + +import ( + "github.com/gogo/protobuf/proto" + "github.com/hyperledger/fabric-config/configtx" + "github.com/hyperledger/fabric-config/configtx/orderer" + "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt" + "github.com/hyperledger/fabric-sdk-go/pkg/core/config" + "github.com/hyperledger/fabric-sdk-go/pkg/fab/resource" + "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk" + "github.com/kfsoftware/hlf-operator/controllers/utils" + "github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "io" + "io/ioutil" +) + +type addConsenterCmd struct { + configPath string + channelName string + userName string + ordNodeNames []string + mspID string + output string +} + +func (c *addConsenterCmd) validate() error { + return nil +} + +func (c *addConsenterCmd) run() error { + oClient, err := helpers.GetKubeOperatorClient() + if err != nil { + return err + } + clientSet, err := helpers.GetKubeClient() + if err != nil { + return err + } + configBackend := config.FromFile(c.configPath) + sdk, err := fabsdk.New(configBackend) + if err != nil { + return err + } + mspID := c.mspID + org1AdminClientContext := sdk.Context( + fabsdk.WithUser(c.userName), + fabsdk.WithOrg(mspID), + ) + resClient, err := resmgmt.New(org1AdminClientContext) + if err != nil { + return err + } + block, err := resClient.QueryConfigBlockFromOrderer(c.channelName) + if err != nil { + return err + } + cfgBlock, err := resource.ExtractConfigFromBlock(block) + if err != nil { + return err + } + cftxGen := configtx.New(cfgBlock) + cfgOrd := cftxGen.Orderer() + for _, ordNodeName := range c.ordNodeNames { + ordNode, err := helpers.GetOrdererNodeByFullName(clientSet, oClient, ordNodeName) + if err != nil { + return err + } + tlsCert, err := utils.ParseX509Certificate([]byte(ordNode.Status.TlsCert)) + if err != nil { + return err + } + ordererHostPort, err := helpers.GetOrdererHostPort(clientSet, ordNode.Item) + if err != nil { + return err + } + log.Infof("Orderer host=%s port=%d", ordererHostPort.Host, ordererHostPort.Port) + err = cfgOrd.AddConsenter(orderer.Consenter{ + Address: orderer.EtcdAddress{ + Host: ordererHostPort.Host, + Port: ordererHostPort.Port, + }, + ClientTLSCert: tlsCert, + ServerTLSCert: tlsCert, + }) + if err != nil { + return err + } + } + + configUpdateBytes, err := cftxGen.ComputeMarshaledUpdate(c.channelName) + if err != nil { + return err + } + configUpdate := &common.ConfigUpdate{} + err = proto.Unmarshal(configUpdateBytes, configUpdate) + if err != nil { + return err + } + channelConfigBytes, err := helpers.CreateConfigUpdateEnvelope(c.channelName, configUpdate) + if err != nil { + return err + } + err = ioutil.WriteFile(c.output, channelConfigBytes, 0755) + if err != nil { + return err + } + log.Infof("output file: %s", c.output) + return nil +} +func newAddConsenterCMD(io.Writer, io.Writer) *cobra.Command { + c := &addConsenterCmd{} + cmd := &cobra.Command{ + Use: "add", + RunE: func(cmd *cobra.Command, args []string) error { + if err := c.validate(); err != nil { + return err + } + return c.run() + }, + } + persistentFlags := cmd.PersistentFlags() + persistentFlags.StringVarP(&c.channelName, "channel", "", "", "Channel name") + persistentFlags.StringVarP(&c.configPath, "config", "", "", "Configuration file for the SDK") + persistentFlags.StringVarP(&c.mspID, "mspid", "", "", "MSP ID of the organization") + persistentFlags.StringSliceVarP(&c.ordNodeNames, "orderers", "", []string{}, "Orderer name") + persistentFlags.StringVarP(&c.userName, "user", "", "", "User name for the transaction") + persistentFlags.StringVarP(&c.output, "output", "o", "", "Output block") + cmd.MarkPersistentFlagRequired("channel") + cmd.MarkPersistentFlagRequired("config") + cmd.MarkPersistentFlagRequired("user") + cmd.MarkPersistentFlagRequired("orderers") + cmd.MarkPersistentFlagRequired("mspid") + cmd.MarkPersistentFlagRequired("output") + return cmd +} diff --git a/kubectl-hlf/cmd/channel/consenter/consenter.go b/kubectl-hlf/cmd/channel/consenter/consenter.go new file mode 100644 index 00000000..c3b54b8b --- /dev/null +++ b/kubectl-hlf/cmd/channel/consenter/consenter.go @@ -0,0 +1,19 @@ +package consenter + +import ( + "io" + + "github.com/spf13/cobra" +) + +func NewConsenterCmd(stdOut io.Writer, stdErr io.Writer) *cobra.Command { + consenterCmd := &cobra.Command{ + Use: "consenter", + } + consenterCmd.AddCommand( + newAddConsenterCMD(stdOut, stdErr), + newDelConsenterCMD(stdOut, stdErr), + newReplaceConsenterCMD(stdOut, stdErr), + ) + return consenterCmd +} diff --git a/kubectl-hlf/cmd/channel/consenter/remove.go b/kubectl-hlf/cmd/channel/consenter/remove.go new file mode 100644 index 00000000..cdd0f346 --- /dev/null +++ b/kubectl-hlf/cmd/channel/consenter/remove.go @@ -0,0 +1,132 @@ +package consenter + +import ( + "github.com/gogo/protobuf/proto" + "github.com/hyperledger/fabric-config/configtx" + "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt" + "github.com/hyperledger/fabric-sdk-go/pkg/core/config" + "github.com/hyperledger/fabric-sdk-go/pkg/fab/resource" + "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk" + "github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "io" + "io/ioutil" +) + +type delConsenterCmd struct { + configPath string + channelName string + userName string + ordNodeName string + mspID string + output string +} + +func (c *delConsenterCmd) validate() error { + return nil +} + +func (c *delConsenterCmd) run() error { + oClient, err := helpers.GetKubeOperatorClient() + if err != nil { + return err + } + clientSet, err := helpers.GetKubeClient() + if err != nil { + return err + } + configBackend := config.FromFile(c.configPath) + sdk, err := fabsdk.New(configBackend) + if err != nil { + return err + } + mspID := c.mspID + org1AdminClientContext := sdk.Context( + fabsdk.WithUser(c.userName), + fabsdk.WithOrg(mspID), + ) + resClient, err := resmgmt.New(org1AdminClientContext) + if err != nil { + return err + } + block, err := resClient.QueryConfigBlockFromOrderer(c.channelName) + if err != nil { + return err + } + cfgBlock, err := resource.ExtractConfigFromBlock(block) + if err != nil { + return err + } + cftxGen := configtx.New(cfgBlock) + cfgOrd := cftxGen.Orderer() + ordNode, err := helpers.GetOrdererNodeByFullName(clientSet, oClient, c.ordNodeName) + if err != nil { + return err + } + ordererHostPort, err := helpers.GetOrdererHostPort(clientSet, ordNode.Item) + if err != nil { + return err + } + ordererConf, err := cftxGen.Orderer().Configuration() + if err != nil { + return err + } + log.Infof("Consenters=%v", ordererConf.EtcdRaft.Consenters) + for _, consenter := range ordererConf.EtcdRaft.Consenters { + if consenter.Address.Host == ordererHostPort.Host && consenter.Address.Port == ordererHostPort.Port { + log.Infof("removing consenter %v", consenter) + err = cfgOrd.RemoveConsenter(consenter) + if err != nil { + return err + } + break + } + } + configUpdateBytes, err := cftxGen.ComputeMarshaledUpdate(c.channelName) + if err != nil { + return err + } + configUpdate := &common.ConfigUpdate{} + err = proto.Unmarshal(configUpdateBytes, configUpdate) + if err != nil { + return err + } + channelConfigBytes, err := helpers.CreateConfigUpdateEnvelope(c.channelName, configUpdate) + if err != nil { + return err + } + err = ioutil.WriteFile(c.output, channelConfigBytes, 0755) + if err != nil { + return err + } + log.Infof("output file: %s", c.output) + return nil +} +func newDelConsenterCMD(io.Writer, io.Writer) *cobra.Command { + c := &delConsenterCmd{} + cmd := &cobra.Command{ + Use: "del", + RunE: func(cmd *cobra.Command, args []string) error { + if err := c.validate(); err != nil { + return err + } + return c.run() + }, + } + persistentFlags := cmd.PersistentFlags() + persistentFlags.StringVarP(&c.channelName, "channel", "", "", "Channel name") + persistentFlags.StringVarP(&c.configPath, "config", "", "", "Configuration file for the SDK") + persistentFlags.StringVarP(&c.mspID, "mspid", "", "", "MSP ID of the organization") + persistentFlags.StringVarP(&c.ordNodeName, "orderer", "", "", "Orderer name") + persistentFlags.StringVarP(&c.userName, "user", "", "", "User name for the transaction") + persistentFlags.StringVarP(&c.output, "output", "o", "", "Output block") + cmd.MarkPersistentFlagRequired("channel") + cmd.MarkPersistentFlagRequired("config") + cmd.MarkPersistentFlagRequired("user") + cmd.MarkPersistentFlagRequired("orderer") + cmd.MarkPersistentFlagRequired("mspid") + cmd.MarkPersistentFlagRequired("output") + return cmd +} diff --git a/kubectl-hlf/cmd/channel/consenter/replace.go b/kubectl-hlf/cmd/channel/consenter/replace.go new file mode 100644 index 00000000..496d48e5 --- /dev/null +++ b/kubectl-hlf/cmd/channel/consenter/replace.go @@ -0,0 +1,145 @@ +package consenter + +import ( + "github.com/gogo/protobuf/proto" + "github.com/hyperledger/fabric-config/configtx" + "github.com/hyperledger/fabric-config/configtx/orderer" + "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt" + "github.com/hyperledger/fabric-sdk-go/pkg/core/config" + "github.com/hyperledger/fabric-sdk-go/pkg/fab/resource" + "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk" + "github.com/kfsoftware/hlf-operator/controllers/utils" + "github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "io" + "io/ioutil" +) + +type replaceonsenterCmd struct { + configPath string + channelName string + userName string + ordNodeName string + mspID string + output string +} + +func (c *replaceonsenterCmd) validate() error { + return nil +} + +func (c *replaceonsenterCmd) run() error { + oClient, err := helpers.GetKubeOperatorClient() + if err != nil { + return err + } + clientSet, err := helpers.GetKubeClient() + if err != nil { + return err + } + configBackend := config.FromFile(c.configPath) + sdk, err := fabsdk.New(configBackend) + if err != nil { + return err + } + mspID := c.mspID + org1AdminClientContext := sdk.Context( + fabsdk.WithUser(c.userName), + fabsdk.WithOrg(mspID), + ) + resClient, err := resmgmt.New(org1AdminClientContext) + if err != nil { + return err + } + block, err := resClient.QueryConfigBlockFromOrderer(c.channelName) + if err != nil { + return err + } + cfgBlock, err := resource.ExtractConfigFromBlock(block) + if err != nil { + return err + } + cftxGen := configtx.New(cfgBlock) + cfgOrd := cftxGen.Orderer() + ordConf, err := cftxGen.Orderer().Configuration() + ordNode, err := helpers.GetOrdererNodeByFullName(clientSet, oClient, c.ordNodeName) + if err != nil { + return err + } + tlsCert, err := utils.ParseX509Certificate([]byte(ordNode.Status.TlsCert)) + if err != nil { + return err + } + ordererHostPort, err := helpers.GetOrdererHostPort(clientSet, ordNode.Item) + if err != nil { + return err + } + log.Infof("Orderer host=%s port=%d", ordererHostPort.Host, ordererHostPort.Port) + for _, consenter := range ordConf.EtcdRaft.Consenters { + if consenter.Address.Host == ordererHostPort.Host && consenter.Address.Port == ordererHostPort.Port { + err = cftxGen.Orderer().RemoveConsenter(consenter) + if err != nil { + return err + } + err = cfgOrd.AddConsenter(orderer.Consenter{ + Address: orderer.EtcdAddress{ + Host: ordererHostPort.Host, + Port: ordererHostPort.Port, + }, + ClientTLSCert: tlsCert, + ServerTLSCert: tlsCert, + }) + if err != nil { + return err + } + break + } + } + configUpdateBytes, err := cftxGen.ComputeMarshaledUpdate(c.channelName) + if err != nil { + return err + } + configUpdate := &common.ConfigUpdate{} + err = proto.Unmarshal(configUpdateBytes, configUpdate) + if err != nil { + return err + } + channelConfigBytes, err := helpers.CreateConfigUpdateEnvelope(c.channelName, configUpdate) + if err != nil { + return err + } + err = ioutil.WriteFile(c.output, channelConfigBytes, 0755) + if err != nil { + return err + } + log.Infof("output file: %s", c.output) + return nil +} +func newReplaceConsenterCMD(io.Writer, io.Writer) *cobra.Command { + c := &replaceonsenterCmd{} + cmd := &cobra.Command{ + Use: "replace", + RunE: func(cmd *cobra.Command, args []string) error { + if err := c.validate(); err != nil { + return err + } + return c.run() + }, + } + persistentFlags := cmd.PersistentFlags() + persistentFlags.StringVarP(&c.channelName, "channel", "", "", "Channel name") + persistentFlags.StringVarP(&c.configPath, "config", "", "", "Configuration file for the SDK") + persistentFlags.StringVarP(&c.mspID, "mspid", "", "", "MSP ID of the organization") + persistentFlags.StringVarP(&c.ordNodeName, "orderer", "", "", "Orderer name") + persistentFlags.StringVarP(&c.userName, "user", "", "", "User name for the transaction") + persistentFlags.StringVarP(&c.output, "output", "o", "", "Output block") + cmd.MarkPersistentFlagRequired("channel") + cmd.MarkPersistentFlagRequired("config") + cmd.MarkPersistentFlagRequired("user") + cmd.MarkPersistentFlagRequired("orderer") + cmd.MarkPersistentFlagRequired("mspid") + cmd.MarkPersistentFlagRequired("output") + return cmd +} diff --git a/kubectl-hlf/cmd/channel/create.go b/kubectl-hlf/cmd/channel/create.go new file mode 100644 index 00000000..35c02b2d --- /dev/null +++ b/kubectl-hlf/cmd/channel/create.go @@ -0,0 +1,167 @@ +package channel + +import ( + "bytes" + "fmt" + "io" + + "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt" + "github.com/hyperledger/fabric-sdk-go/pkg/core/config" + "github.com/hyperledger/fabric-sdk-go/pkg/fab/resource" + "github.com/hyperledger/fabric-sdk-go/pkg/fab/resource/genesisconfig" + "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk" + "github.com/kfsoftware/hlf-operator/controllers/testutils" + "github.com/kfsoftware/hlf-operator/controllers/utils" + "github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers" + "github.com/pkg/errors" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" +) + +type createChannelCmd struct { + configPath string + organizations []string + adminOrg string + ordererOrg string + channelName string + consortiumName string + userName string + ordererNodes []string +} + +func (c *createChannelCmd) validate() error { + return nil +} +func (c *createChannelCmd) run() error { + oclient, err := helpers.GetKubeOperatorClient() + if err != nil { + return err + } + clientSet, err := helpers.GetKubeClient() + if err != nil { + return err + } + configBackend := config.FromFile(c.configPath) + sdk, err := fabsdk.New(configBackend) + if err != nil { + return err + } + ordService, err := helpers.GetOrderingServiceByFullName(clientSet, oclient, c.ordererOrg) + if err != nil { + return err + } + adminPeer, err := helpers.GetPeerByFullName(clientSet, oclient, c.adminOrg) + if err != nil { + return err + } + org1AdminClientContext := sdk.Context( + fabsdk.WithUser(c.userName), + fabsdk.WithOrg(adminPeer.Spec.MspID), + ) + resClient, err := resmgmt.New(org1AdminClientContext) + if err != nil { + return err + } + ns := "" + _, peers, err := helpers.GetClusterPeers(clientSet, oclient, ns) + if err != nil { + return err + } + var peerOrgs []testutils.PeerOrganization + for _, peer := range peers { + if !utils.Contains(c.organizations, peer.Name) { + continue + } + certAuth, err := helpers.GetCertAuthByURL( + clientSet, + oclient, + peer.Spec.Secret.Enrollment.Component.Cahost, + peer.Spec.Secret.Enrollment.Component.Caport, + ) + if err != nil { + return err + } + var nodes []testutils.PeerNode + peerOrgs = append(peerOrgs, testutils.PeerOrganization{ + RootCert: certAuth.Status.CACert, + TLSRootCert: certAuth.Status.TLSCACert, + MspID: peer.Spec.MspID, + Peers: nodes, + }) + } + if len(peerOrgs) == 0 { + return errors.Errorf("No peer orgs specified") + } + certAuth, err := helpers.GetCertAuthByURL( + clientSet, + oclient, + ordService.Spec.Enrollment.Component.Cahost, + ordService.Spec.Enrollment.Component.Caport, + ) + if err != nil { + return err + } + ordOrganization := testutils.OrdererOrganization{ + Nodes: []testutils.OrdererNode{}, + RootTLSCert: certAuth.Status.TLSCACert, + RootSignCert: certAuth.Status.CACert, + MspID: c.ordererOrg, + } + + profileConfig, err := testutils.GetChannelProfileConfig( + ordOrganization, + peerOrgs, + c.consortiumName, + fmt.Sprintf(`OR('%s.admin')`, adminPeer.Spec.MspID), + ) + if err != nil { + return err + } + var baseProfile *genesisconfig.Profile + channelTx, err := resource.CreateChannelCreateTx( + profileConfig, + baseProfile, + c.channelName, + ) + if err != nil { + return err + } + channelConfig := bytes.NewReader(channelTx) + saveResponse, err := resClient.SaveChannel(resmgmt.SaveChannelRequest{ + ChannelID: c.channelName, + ChannelConfig: channelConfig, + }) + if err != nil { + return err + } + log.Infof("Channel created, txID=%s", saveResponse.TransactionID) + return nil +} +func newCreateChannelCMD(io.Writer, io.Writer) *cobra.Command { + c := &createChannelCmd{} + cmd := &cobra.Command{ + Use: "create", + RunE: func(cmd *cobra.Command, args []string) error { + if err := c.validate(); err != nil { + return err + } + return c.run() + }, + } + persistentFlags := cmd.PersistentFlags() + persistentFlags.StringVarP(&c.adminOrg, "admin-org", "", "", "Admin org to invoke the updates") + persistentFlags.StringVarP(&c.ordererOrg, "ordering-service", "", "", "Orderer Service name") + persistentFlags.StringVarP(&c.channelName, "name", "", "", "Channel name") + persistentFlags.StringVarP(&c.configPath, "config", "", "", "Configuration file for the SDK") + persistentFlags.StringVarP(&c.userName, "user", "", "", "User name for the transaction") + persistentFlags.StringVarP(&c.consortiumName, "consortium", "", "", "Consortium name") + persistentFlags.StringSliceVarP(&c.organizations, "organizations", "p", []string{}, "Organizations belonging to the consortium") + persistentFlags.StringSliceVarP(&c.ordererNodes, "orderer-nodes", "o", []string{}, "Consenter orderer nodes") + cmd.MarkPersistentFlagRequired("channel-id") + cmd.MarkPersistentFlagRequired("organizations") + cmd.MarkPersistentFlagRequired("config") + cmd.MarkPersistentFlagRequired("peer-org") + cmd.MarkPersistentFlagRequired("consortium") + cmd.MarkPersistentFlagRequired("orderer-org") + return cmd +} diff --git a/kubectl-hlf/cmd/channel/delanchorpeer.go b/kubectl-hlf/cmd/channel/delanchorpeer.go new file mode 100644 index 00000000..0d33e49c --- /dev/null +++ b/kubectl-hlf/cmd/channel/delanchorpeer.go @@ -0,0 +1,108 @@ +package channel + +import ( + "bytes" + "github.com/gogo/protobuf/proto" + "github.com/hyperledger/fabric-config/configtx" + "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt" + "github.com/hyperledger/fabric-sdk-go/pkg/core/config" + "github.com/hyperledger/fabric-sdk-go/pkg/fab/resource" + "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "io" +) + +type delAnchorPeerCmd struct { + configPath string + channelName string + userName string + peerHost string + peerPort int + mspID string +} + +func (c *delAnchorPeerCmd) validate() error { + return nil +} + +func (c *delAnchorPeerCmd) run() error { + configBackend := config.FromFile(c.configPath) + sdk, err := fabsdk.New(configBackend) + if err != nil { + return err + } + mspID := c.mspID + org1AdminClientContext := sdk.Context( + fabsdk.WithUser(c.userName), + fabsdk.WithOrg(mspID), + ) + resClient, err := resmgmt.New(org1AdminClientContext) + if err != nil { + return err + } + block, err := resClient.QueryConfigBlockFromOrderer(c.channelName) + if err != nil { + return err + } + cfgBlock, err := resource.ExtractConfigFromBlock(block) + if err != nil { + return err + } + cftxGen := configtx.New(cfgBlock) + app := cftxGen.Application().Organization(mspID) + err = app.RemoveAnchorPeer(configtx.Address{Host: c.peerHost, Port: c.peerPort}) + if err != nil { + return err + } + configUpdateBytes, err := cftxGen.ComputeMarshaledUpdate(c.channelName) + if err != nil { + return err + } + configUpdate := &common.ConfigUpdate{} + err = proto.Unmarshal(configUpdateBytes, configUpdate) + if err != nil { + return err + } + channelConfigBytes, err := CreateConfigUpdateEnvelope(c.channelName, configUpdate) + if err != nil { + return err + } + configUpdateReader := bytes.NewReader(channelConfigBytes) + chResponse, err := resClient.SaveChannel(resmgmt.SaveChannelRequest{ + ChannelID: c.channelName, + ChannelConfig: configUpdateReader, + }) + if err != nil { + return err + } + log.Infof("anchor anchorPeers removed: %s", chResponse.TransactionID) + return nil +} +func newDelAnchorPeerCMD(io.Writer, io.Writer) *cobra.Command { + c := &delAnchorPeerCmd{} + cmd := &cobra.Command{ + Use: "delanchorpeer", + RunE: func(cmd *cobra.Command, args []string) error { + if err := c.validate(); err != nil { + return err + } + return c.run() + }, + } + persistentFlags := cmd.PersistentFlags() + persistentFlags.StringVarP(&c.peerHost, "peer-host", "", "", "Peer host") + persistentFlags.IntVarP(&c.peerPort, "peer-port", "", 0, "Peer port") + persistentFlags.StringVarP(&c.channelName, "channel", "", "", "Channel name") + persistentFlags.StringVarP(&c.configPath, "config", "", "", "Configuration file for the SDK") + persistentFlags.StringVarP(&c.userName, "user", "", "", "User name for the transaction") + persistentFlags.StringVarP(&c.mspID, "msp-id", "", "", "MSP ID of organization to remove the anchor peers from") + + cmd.MarkPersistentFlagRequired("channel") + cmd.MarkPersistentFlagRequired("config") + cmd.MarkPersistentFlagRequired("user") + cmd.MarkPersistentFlagRequired("peer-host") + cmd.MarkPersistentFlagRequired("peer-port") + return cmd +} diff --git a/kubectl-hlf/cmd/channel/generate.go b/kubectl-hlf/cmd/channel/generate.go new file mode 100644 index 00000000..85a6a294 --- /dev/null +++ b/kubectl-hlf/cmd/channel/generate.go @@ -0,0 +1,231 @@ +package channel + +import ( + "context" + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-config/configtx/orderer" + "github.com/kfsoftware/hlf-operator/controllers/testutils" + "github.com/kfsoftware/hlf-operator/controllers/utils" + "github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers" + "github.com/pkg/errors" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "io" + "io/ioutil" + "strings" +) + +type generateChannelCmd struct { + channelName string + organizations []string + ordererOrganizations []string + consenterNodes []string + output string + maxMessageCount int + absoluteMaxBytes int + preferredMaxBytes int +} + +func (c generateChannelCmd) validate() error { + if c.channelName == "" { + return errors.Errorf("--channelName is required") + } + if len(c.ordererOrganizations) == 0 { + return errors.Errorf("--ordererOrganizations is required") + } + if len(c.organizations) == 0 { + return errors.Errorf("--organizations is required") + } + if c.output == "" { + return errors.Errorf("--output is required") + } + return nil +} + +func (c generateChannelCmd) run() error { + oclient, err := helpers.GetKubeOperatorClient() + if err != nil { + return err + } + clientSet, err := helpers.GetKubeClient() + if err != nil { + return err + } + ns := "" + chStore := testutils.NewChannelStore() + ctx := context.Background() + var consenters []testutils.Consenter + orderers, err := helpers.GetClusterOrdererNodes(clientSet, oclient, ns) + if err != nil { + return err + } + ordererMap := map[string][]*helpers.ClusterOrdererNode{} + log.Debugf("orderers: %v", orderers) + for _, consenter := range orderers { + log.Debugf("orderer: %v", consenter.Spec.MspID) + if !utils.Contains(c.ordererOrganizations, consenter.Spec.MspID) { + continue + } + if len(c.consenterNodes) > 0 { + // check if the orderer is in the list of consenter nodes specified + found := false + for _, consenterNode := range c.consenterNodes { + if consenterNode == consenter.Item.Name { + found = true + } + } + if !found { + continue + } + } + tlsCert, err := utils.ParseX509Certificate([]byte(consenter.Status.TlsCert)) + if err != nil { + return err + } + consenterHost, consenterPort, err := helpers.GetOrdererHostAndPort( + clientSet, + consenter.Spec, + consenter.Status, + ) + if err != nil { + return err + } + createConsenter := testutils.CreateConsenter( + consenterHost, + consenterPort, + tlsCert, + ) + consenters = append(consenters, createConsenter) + _, ok := ordererMap[consenter.Spec.MspID] + if !ok { + ordererMap[consenter.Spec.MspID] = []*helpers.ClusterOrdererNode{} + } + ordererMap[consenter.Spec.MspID] = append(ordererMap[consenter.Spec.MspID], consenter) + + } + var ordererOrgs []testutils.OrdererOrg + for mspID, orderers := range ordererMap { + orderer := orderers[0] + cahost := orderer.Spec.Secret.Enrollment.Component.Cahost + certAuth, err := helpers.GetCertAuthByURL( + clientSet, + oclient, + cahost, + orderer.Spec.Secret.Enrollment.Component.Caport, + ) + if err != nil { + return err + } + tlsCert, err := utils.ParseX509Certificate([]byte(certAuth.Status.TLSCACert)) + if err != nil { + return err + } + signCert, err := utils.ParseX509Certificate([]byte(certAuth.Status.CACert)) + if err != nil { + return err + } + var ordererUrls []string + for _, node := range orderers { + ordererURL, err := helpers.GetOrdererPublicURL(clientSet, node.Item) + if err != nil { + return err + } + ordererUrls = append( + ordererUrls, + ordererURL, + ) + } + ordererOrgs = append(ordererOrgs, testutils.CreateOrdererOrg( + mspID, + tlsCert, + signCert, + ordererUrls, + )) + } + var peerOrgs []testutils.PeerOrg + _, peers, err := helpers.GetClusterPeers(clientSet, oclient, ns) + if err != nil { + return err + } + for _, peer := range peers { + if !utils.Contains(c.organizations, peer.Spec.MspID) { + continue + } + caHost := strings.Split(peer.Spec.Secret.Enrollment.Component.Cahost, ".")[0] + certAuth, err := helpers.GetCertAuthByURL( + clientSet, + oclient, + caHost, + peer.Spec.Secret.Enrollment.Component.Caport, + ) + if err != nil { + return err + } + rootCert, err := utils.ParseX509Certificate([]byte(certAuth.Status.CACert)) + if err != nil { + return err + } + tlsRootCert, err := utils.ParseX509Certificate([]byte(certAuth.Status.TLSCACert)) + if err != nil { + return err + } + peerOrgs = append(peerOrgs, testutils.CreatePeerOrg( + peer.Spec.MspID, + tlsRootCert, + rootCert, + )) + } + log.Infof("Peer organizations=%v", peerOrgs) + log.Infof("Orderer organizations=%v", ordererOrgs) + + block, err := chStore.GetApplicationChannelBlock( + ctx, + testutils.WithName(c.channelName), + testutils.WithOrdererOrgs(ordererOrgs...), + testutils.WithPeerOrgs(peerOrgs...), + testutils.WithConsenters(consenters...), + testutils.WithBatchSize(&orderer.BatchSize{ + MaxMessageCount: uint32(c.maxMessageCount), + AbsoluteMaxBytes: uint32(c.absoluteMaxBytes), + PreferredMaxBytes: uint32(c.preferredMaxBytes), + }), + ) + if err != nil { + return err + } + blockBytes, err := proto.Marshal(block) + if err != nil { + return err + } + err = ioutil.WriteFile(c.output, blockBytes, 0755) + if err != nil { + return err + } + return nil +} +func newGenerateChannelCMD(io.Writer, io.Writer) *cobra.Command { + c := &generateChannelCmd{} + cmd := &cobra.Command{ + Use: "generate", + RunE: func(cmd *cobra.Command, args []string) error { + if err := c.validate(); err != nil { + return err + } + return c.run() + }, + } + persistentFlags := cmd.PersistentFlags() + persistentFlags.StringVarP(&c.channelName, "name", "", "", "Channel name") + persistentFlags.StringVarP(&c.output, "output", "o", "", "Output block") + persistentFlags.StringSliceVarP(&c.organizations, "organizations", "p", nil, "Organizations belonging to the channel") + persistentFlags.StringSliceVarP(&c.ordererOrganizations, "ordererOrganizations", "", nil, "Orderer organizations belonging to the channel") + persistentFlags.StringSliceVarP(&c.consenterNodes, "consenterNodes", "c", []string{}, "Consenter nodes belonging to the channel") + persistentFlags.IntVarP(&c.maxMessageCount, "maxMessageCount", "", 100, "Max transactions per block") + persistentFlags.IntVarP(&c.absoluteMaxBytes, "absoluteMaxBytes", "", 1024*1024, "Max size per block") + persistentFlags.IntVarP(&c.preferredMaxBytes, "preferredMaxBytes", "", 512*1024, "Max size per block") + cmd.MarkPersistentFlagRequired("name") + cmd.MarkPersistentFlagRequired("organizations") + cmd.MarkPersistentFlagRequired("ordererOrganizations") + cmd.MarkPersistentFlagRequired("output") + return cmd +} diff --git a/kubectl-hlf/cmd/channel/join.go b/kubectl-hlf/cmd/channel/join.go new file mode 100644 index 00000000..d146ade8 --- /dev/null +++ b/kubectl-hlf/cmd/channel/join.go @@ -0,0 +1,79 @@ +package channel + +import ( + "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt" + "github.com/hyperledger/fabric-sdk-go/pkg/core/config" + "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk" + "github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "io" +) + +type joinChannelCmd struct { + configPath string + peer string + channelName string + userName string +} + +func (c *joinChannelCmd) validate() error { + return nil +} +func (c *joinChannelCmd) run() error { + oclient, err := helpers.GetKubeOperatorClient() + if err != nil { + return err + } + clientSet, err := helpers.GetKubeClient() + if err != nil { + return err + } + peer, err := helpers.GetPeerByFullName(clientSet, oclient, c.peer) + if err != nil { + return err + } + mspID := peer.Spec.MspID + peerName := peer.Name + configBackend := config.FromFile(c.configPath) + sdk, err := fabsdk.New(configBackend) + if err != nil { + return err + } + org1AdminClientContext := sdk.Context( + fabsdk.WithUser(c.userName), + fabsdk.WithOrg(mspID), + ) + resClient, err := resmgmt.New(org1AdminClientContext) + if err != nil { + return err + } + err = resClient.JoinChannel(c.channelName, resmgmt.WithTargetEndpoints(peerName)) + if err != nil { + return err + } + log.Infof("Channel joined") + return nil +} +func newJoinChannelCMD(io.Writer, io.Writer) *cobra.Command { + c := &joinChannelCmd{} + cmd := &cobra.Command{ + Use: "join", + RunE: func(cmd *cobra.Command, args []string) error { + if err := c.validate(); err != nil { + return err + } + return c.run() + }, + } + persistentFlags := cmd.PersistentFlags() + persistentFlags.StringVarP(&c.peer, "peer", "p", "", "Name of the peer to invoke the updates") + persistentFlags.StringVarP(&c.userName, "user", "", "", "User name for the transaction") + persistentFlags.StringVarP(&c.channelName, "name", "", "", "Channel name") + persistentFlags.StringVarP(&c.configPath, "config", "", "", "Configuration file for the SDK") + cmd.MarkPersistentFlagRequired("name") + cmd.MarkPersistentFlagRequired("user") + cmd.MarkPersistentFlagRequired("peer") + cmd.MarkPersistentFlagRequired("config") + return cmd +} diff --git a/kubectl-hlf/cmd/channel/ordorg/add.go b/kubectl-hlf/cmd/channel/ordorg/add.go new file mode 100644 index 00000000..105180b5 --- /dev/null +++ b/kubectl-hlf/cmd/channel/ordorg/add.go @@ -0,0 +1,129 @@ +package ordorg + +import ( + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/common/channelconfig" + "io" + "io/ioutil" + + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-protos-go/common" + cb "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt" + "github.com/hyperledger/fabric-sdk-go/pkg/core/config" + "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/encoder" + "github.com/kfsoftware/hlf-operator/internal/github.com/hyperledger/fabric/sdkinternal/configtxgen/genesisconfig" + "github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers" + "github.com/pkg/errors" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "gopkg.in/yaml.v2" +) + +type addOrgCmd struct { + configPath string + orgPath string + channelName string + userName string + mspID string + dryRun bool + signMSPID string + output string +} + +func (c *addOrgCmd) validate() error { + return nil +} +func (c *addOrgCmd) run(out io.Writer) error { + mspID := c.signMSPID + configBackend := config.FromFile(c.configPath) + sdk, err := fabsdk.New(configBackend) + if err != nil { + return err + } + org1AdminClientContext := sdk.Context( + fabsdk.WithUser(c.userName), + fabsdk.WithOrg(mspID), + ) + resClient, err := resmgmt.New(org1AdminClientContext) + if err != nil { + return err + } + channelID := c.channelName + channelConfig, err := helpers.GetCurrentConfigFromPeer(resClient, channelID) + if err != nil { + return err + } + modifiedConfig := &common.Config{} + modifiedConfigBytes, err := proto.Marshal(channelConfig) + if err != nil { + return err + } + err = proto.Unmarshal(modifiedConfigBytes, modifiedConfig) + if err != nil { + return err + } + orgBytes, err := ioutil.ReadFile(c.orgPath) + if err != nil { + return err + } + topLevel := &genesisconfig.TopLevel{} + err = yaml.Unmarshal(orgBytes, topLevel) + if err != nil { + return err + } + var orgConfig *cb.ConfigGroup + for _, org := range topLevel.Organizations { + if org.Name == c.mspID { + orgConfig, err = encoder.NewOrdererOrgGroup(org) + if err != nil { + return err + } + } + } + if orgConfig == nil { + return errors.Errorf("msp ID %s not found", c.mspID) + } + modifiedConfig.ChannelGroup.Groups[channelconfig.OrdererGroupKey].Groups[c.mspID] = orgConfig + confUpdate, err := resmgmt.CalculateConfigUpdate(channelID, channelConfig, modifiedConfig) + if err != nil { + return err + } + configEnvelopeBytes, err := helpers.GetConfigEnvelopeBytes(confUpdate) + if err != nil { + return err + } + err = ioutil.WriteFile(c.output, configEnvelopeBytes, 0755) + if err != nil { + return err + } + log.Infof("output file: %s", c.output) + return nil +} +func newAddOrgToChannelCMD(out io.Writer, errOut io.Writer) *cobra.Command { + c := &addOrgCmd{} + cmd := &cobra.Command{ + Use: "addorg", + RunE: func(cmd *cobra.Command, args []string) error { + if err := c.validate(); err != nil { + return err + } + return c.run(out) + }, + } + persistentFlags := cmd.PersistentFlags() + persistentFlags.StringVarP(&c.channelName, "name", "", "", "Channel name") + persistentFlags.StringVarP(&c.configPath, "config", "", "", "Configuration file for the SDK") + persistentFlags.StringVarP(&c.userName, "user", "", "", "User name for the transaction") + persistentFlags.StringVarP(&c.signMSPID, "config-msp-id", "", "", "MSP ID for the transaction") + persistentFlags.StringVarP(&c.mspID, "msp-id", "", "", "MSP ID for the new organization") + persistentFlags.StringVarP(&c.orgPath, "org-config", "", "", "JSON with the crypto material for the new org") + persistentFlags.StringVarP(&c.output, "output", "", "", "Output file") + cmd.MarkPersistentFlagRequired("name") + cmd.MarkPersistentFlagRequired("config") + cmd.MarkPersistentFlagRequired("config-msp-id") + cmd.MarkPersistentFlagRequired("org-config") + cmd.MarkPersistentFlagRequired("msp-id") + cmd.MarkPersistentFlagRequired("user") + return cmd +} diff --git a/kubectl-hlf/cmd/channel/ordorg/ordorg.go b/kubectl-hlf/cmd/channel/ordorg/ordorg.go new file mode 100644 index 00000000..2e29883d --- /dev/null +++ b/kubectl-hlf/cmd/channel/ordorg/ordorg.go @@ -0,0 +1,18 @@ +package ordorg + +import ( + "io" + + "github.com/spf13/cobra" +) + +func NewOrdOrgCmd(stdOut io.Writer, stdErr io.Writer) *cobra.Command { + ordOrgCmd := &cobra.Command{ + Use: "ordorg", + } + ordOrgCmd.AddCommand( + newAddOrgToChannelCMD(stdOut, stdErr), + newRemoveOrgToChannelCMD(stdOut, stdErr), + ) + return ordOrgCmd +} diff --git a/kubectl-hlf/cmd/channel/ordorg/remove.go b/kubectl-hlf/cmd/channel/ordorg/remove.go new file mode 100644 index 00000000..af7e3aa8 --- /dev/null +++ b/kubectl-hlf/cmd/channel/ordorg/remove.go @@ -0,0 +1,100 @@ +package ordorg + +import ( + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-config/configtx" + "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt" + "github.com/hyperledger/fabric-sdk-go/pkg/core/config" + "github.com/hyperledger/fabric-sdk-go/pkg/fab/resource" + "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk" + "github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "io" + "io/ioutil" +) + +type removeOrgCmd struct { + configPath string + channelName string + userName string + mspID string + signMSPID string + output string +} + +func (c *removeOrgCmd) validate() error { + return nil +} +func (c *removeOrgCmd) run(out io.Writer) error { + mspID := c.signMSPID + configBackend := config.FromFile(c.configPath) + sdk, err := fabsdk.New(configBackend) + if err != nil { + return err + } + org1AdminClientContext := sdk.Context( + fabsdk.WithUser(c.userName), + fabsdk.WithOrg(mspID), + ) + resClient, err := resmgmt.New(org1AdminClientContext) + if err != nil { + return err + } + block, err := resClient.QueryConfigBlockFromOrderer(c.channelName) + if err != nil { + return err + } + cfgBlock, err := resource.ExtractConfigFromBlock(block) + if err != nil { + return err + } + cftxGen := configtx.New(cfgBlock) + cftxGen.Orderer().RemoveOrganization(c.mspID) + configUpdateBytes, err := cftxGen.ComputeMarshaledUpdate(c.channelName) + if err != nil { + return err + } + configUpdate := &common.ConfigUpdate{} + err = proto.Unmarshal(configUpdateBytes, configUpdate) + if err != nil { + return err + } + channelConfigBytes, err := helpers.CreateConfigUpdateEnvelope(c.channelName, configUpdate) + if err != nil { + return err + } + err = ioutil.WriteFile(c.output, channelConfigBytes, 0755) + if err != nil { + return err + } + log.Infof("output file: %s", c.output) + return nil +} +func newRemoveOrgToChannelCMD(out io.Writer, errOut io.Writer) *cobra.Command { + c := &removeOrgCmd{} + cmd := &cobra.Command{ + Use: "del", + RunE: func(cmd *cobra.Command, args []string) error { + if err := c.validate(); err != nil { + return err + } + return c.run(out) + }, + } + persistentFlags := cmd.PersistentFlags() + persistentFlags.StringVarP(&c.channelName, "name", "", "", "Channel name") + persistentFlags.StringVarP(&c.configPath, "config", "", "", "Configuration file for the SDK") + persistentFlags.StringVarP(&c.userName, "user", "", "", "User name for the transaction") + persistentFlags.StringVarP(&c.signMSPID, "config-msp-id", "", "", "MSP ID for the transaction") + persistentFlags.StringVarP(&c.mspID, "msp-id", "", "", "MSP ID of the organization to remove") + persistentFlags.StringVarP(&c.output, "output", "", "", "Output file") + cmd.MarkPersistentFlagRequired("name") + cmd.MarkPersistentFlagRequired("config") + cmd.MarkPersistentFlagRequired("config-msp-id") + cmd.MarkPersistentFlagRequired("msp-id") + cmd.MarkPersistentFlagRequired("user") + cmd.MarkPersistentFlagRequired("output") + return cmd +} diff --git a/kubectl-hlf/cmd/channel/signupdate.go b/kubectl-hlf/cmd/channel/signupdate.go new file mode 100644 index 00000000..39cb5112 --- /dev/null +++ b/kubectl-hlf/cmd/channel/signupdate.go @@ -0,0 +1,103 @@ +package channel + +import ( + "bytes" + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-protos-go/common" + mspclient "github.com/hyperledger/fabric-sdk-go/pkg/client/msp" + "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt" + "github.com/hyperledger/fabric-sdk-go/pkg/core/config" + + "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "io" + "io/ioutil" +) + +type signUpdateChannelCmd struct { + configPath string + channelName string + userName string + file string + output string + mspID string +} + +func (c *signUpdateChannelCmd) validate() error { + return nil +} + +func (c *signUpdateChannelCmd) run() error { + configBackend := config.FromFile(c.configPath) + sdk, err := fabsdk.New(configBackend) + if err != nil { + return err + } + org1AdminClientContext := sdk.Context( + fabsdk.WithUser(c.userName), + fabsdk.WithOrg(c.mspID), + ) + resClient, err := resmgmt.New(org1AdminClientContext) + if err != nil { + return err + } + updateEnvelopeBytes, err := ioutil.ReadFile(c.file) + if err != nil { + return err + } + envelope := &common.Envelope{} + err = proto.Unmarshal(updateEnvelopeBytes, envelope) + if err != nil { + return err + } + configUpdateReader := bytes.NewReader(updateEnvelopeBytes) + mspClient, err := mspclient.New(org1AdminClientContext, mspclient.WithOrg(c.mspID)) + if err != nil { + return err + } + usr, err := mspClient.GetSigningIdentity(c.userName) + if err != nil { + return err + } + signature, err := resClient.CreateConfigSignatureFromReader(usr, configUpdateReader) + if err != nil { + return err + } + signatureBytes, err := proto.Marshal(signature) + if err != nil { + return err + } + err = ioutil.WriteFile(c.output, signatureBytes, 0777) + if err != nil { + return err + } + log.Infof("channel signed output: %s", c.output) + return nil +} +func newSignUpdateChannelCMD(io.Writer, io.Writer) *cobra.Command { + c := &signUpdateChannelCmd{} + cmd := &cobra.Command{ + Use: "signupdate", + RunE: func(cmd *cobra.Command, args []string) error { + if err := c.validate(); err != nil { + return err + } + return c.run() + }, + } + persistentFlags := cmd.PersistentFlags() + persistentFlags.StringVarP(&c.mspID, "mspid", "", "", "MSP ID of the organization") + persistentFlags.StringVarP(&c.channelName, "channel", "", "", "Channel name") + persistentFlags.StringVarP(&c.configPath, "config", "", "", "Configuration file for the SDK") + persistentFlags.StringVarP(&c.userName, "user", "", "", "User name for the transaction") + persistentFlags.StringVarP(&c.file, "file", "f", "", "Config update file") + persistentFlags.StringVarP(&c.output, "output", "o", "", "Output signature file") + cmd.MarkPersistentFlagRequired("mspid") + cmd.MarkPersistentFlagRequired("channel") + cmd.MarkPersistentFlagRequired("config") + cmd.MarkPersistentFlagRequired("user") + cmd.MarkPersistentFlagRequired("file") + cmd.MarkPersistentFlagRequired("output") + return cmd +} diff --git a/kubectl-hlf/cmd/helpers/channel.go b/kubectl-hlf/cmd/helpers/channel.go new file mode 100644 index 00000000..89485a39 --- /dev/null +++ b/kubectl-hlf/cmd/helpers/channel.go @@ -0,0 +1,74 @@ +package helpers + +import ( + "bytes" + "github.com/golang/protobuf/proto" + "github.com/hyperledger/fabric-config/protolator" + "github.com/hyperledger/fabric-protos-go/common" + "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt" + "github.com/hyperledger/fabric-sdk-go/pkg/fab/resource" + "github.com/hyperledger/fabric/protoutil" +) + +func CreateConfigUpdateEnvelope(channelID string, configUpdate *common.ConfigUpdate) ([]byte, error) { + configUpdate.ChannelId = channelID + configUpdateData, err := proto.Marshal(configUpdate) + if err != nil { + return nil, err + } + configUpdateEnvelope := &common.ConfigUpdateEnvelope{} + configUpdateEnvelope.ConfigUpdate = configUpdateData + envelope, err := protoutil.CreateSignedEnvelope(common.HeaderType_CONFIG_UPDATE, channelID, nil, configUpdateEnvelope, 0, 0) + if err != nil { + return nil, err + } + envelopeData, err := proto.Marshal(envelope) + if err != nil { + return nil, err + } + return envelopeData, nil +} + +func GetCurrentConfigFromPeer(resClient *resmgmt.Client, channelID string) (*common.Config, error) { + block, err := resClient.QueryConfigBlockFromOrderer(channelID) + if err != nil { + return nil, err + } + channelConfig, err := resource.ExtractConfigFromBlock(block) + if err != nil { + return nil, err + } + return channelConfig, nil +} + +func GetConfigEnvelopeBytes(configUpdate *common.ConfigUpdate) ([]byte, error) { + var buf bytes.Buffer + if err := protolator.DeepMarshalJSON(&buf, configUpdate); err != nil { + return nil, err + } + + channelConfigBytes, err := proto.Marshal(configUpdate) + if err != nil { + return nil, err + } + configUpdateEnvelope := &common.ConfigUpdateEnvelope{ + ConfigUpdate: channelConfigBytes, + Signatures: nil, + } + configUpdateEnvelopeBytes, err := proto.Marshal(configUpdateEnvelope) + if err != nil { + return nil, err + } + payload := &common.Payload{ + Data: configUpdateEnvelopeBytes, + } + payloadBytes, err := proto.Marshal(payload) + if err != nil { + return nil, err + } + configEnvelope := &common.Envelope{ + Payload: payloadBytes, + } + + return proto.Marshal(configEnvelope) +} diff --git a/kubectl-hlf/cmd/helpers/hlf.go b/kubectl-hlf/cmd/helpers/hlf.go index 64ff2167..ba75eca0 100644 --- a/kubectl-hlf/cmd/helpers/hlf.go +++ b/kubectl-hlf/cmd/helpers/hlf.go @@ -318,11 +318,11 @@ func GetURLForCA(certAuth *ClusterCA) (string, error) { if len(certAuth.Spec.Istio.Hosts) > 0 { host = certAuth.Spec.Istio.Hosts[0] port = certAuth.Spec.Istio.Port - }else if len(certAuth.Spec.GatewayApi.Hosts) > 0{ + } else if len(certAuth.Spec.GatewayApi.Hosts) > 0 { host = certAuth.Spec.GatewayApi.Hosts[0] port = certAuth.Spec.GatewayApi.Port - }else { + } else { client, err := GetKubeClient() if err != nil { return "", err From 5c19558953e05efd1effd95fe47801f542ff7e25 Mon Sep 17 00:00:00 2001 From: "Roy,Sownak" Date: Wed, 23 Aug 2023 08:14:37 +0000 Subject: [PATCH 2/7] chore: update license to Apache 2.0 Signed-off-by: Roy,Sownak --- k8s/.gitkeep | 1 + k8s/boilerplate.go.txt | 12 ------------ .../v1alpha1/applicationcapabilities.go | 19 +++++-------------- .../hlf.kungfusoftware.es/v1alpha1/catls.go | 19 +++++-------------- .../v1alpha1/channelcapabilities.go | 19 +++++-------------- .../v1alpha1/channelconfig.go | 19 +++++-------------- .../v1alpha1/component.go | 19 +++++-------------- .../hlf.kungfusoftware.es/v1alpha1/cors.go | 19 +++++-------------- .../hlf.kungfusoftware.es/v1alpha1/csr.go | 19 +++++-------------- .../v1alpha1/enrollment.go | 19 +++++-------------- .../v1alpha1/externalbuilder.go | 19 +++++-------------- .../v1alpha1/externalcertificate.go | 19 +++++-------------- .../v1alpha1/fabricca.go | 19 +++++-------------- .../v1alpha1/fabriccaaffiliation.go | 19 +++++-------------- .../v1alpha1/fabriccabccsp.go | 19 +++++-------------- .../v1alpha1/fabriccabccspsw.go | 19 +++++-------------- .../v1alpha1/fabriccacfg.go | 19 +++++-------------- .../v1alpha1/fabriccacfgaffilitions.go | 19 +++++-------------- .../v1alpha1/fabriccacfgidentities.go | 19 +++++-------------- .../v1alpha1/fabriccaclientauth.go | 19 +++++-------------- .../v1alpha1/fabriccacrl.go | 19 +++++-------------- .../v1alpha1/fabriccacrypto.go | 19 +++++-------------- .../v1alpha1/fabriccacsr.go | 19 +++++-------------- .../v1alpha1/fabriccacsrca.go | 19 +++++-------------- .../v1alpha1/fabriccadatabase.go | 19 +++++-------------- .../v1alpha1/fabriccaidentity.go | 19 +++++-------------- .../v1alpha1/fabriccaidentityattrs.go | 19 +++++-------------- .../v1alpha1/fabriccaintermediate.go | 19 +++++-------------- .../fabriccaintermediateparentserver.go | 19 +++++-------------- .../v1alpha1/fabriccaitemconf.go | 19 +++++-------------- .../v1alpha1/fabriccametrics.go | 19 +++++-------------- .../v1alpha1/fabriccametricsstatsd.go | 19 +++++-------------- .../v1alpha1/fabriccanames.go | 19 +++++-------------- .../v1alpha1/fabriccaregistry.go | 19 +++++-------------- .../v1alpha1/fabriccasigning.go | 19 +++++-------------- .../v1alpha1/fabriccasigningdefault.go | 19 +++++-------------- .../v1alpha1/fabriccasigningprofiles.go | 19 +++++-------------- .../v1alpha1/fabriccasigningsignprofile.go | 19 +++++-------------- .../fabriccasigningsignprofileconstraint.go | 19 +++++-------------- .../v1alpha1/fabriccasigningtlsprofile.go | 19 +++++-------------- .../v1alpha1/fabriccaspec.go | 19 +++++-------------- .../v1alpha1/fabriccaspecservice.go | 19 +++++-------------- .../v1alpha1/fabriccastatus.go | 19 +++++-------------- .../v1alpha1/fabriccasubject.go | 19 +++++-------------- .../v1alpha1/fabriccatlsconf.go | 19 +++++-------------- .../v1alpha1/fabricchaincode.go | 19 +++++-------------- .../v1alpha1/fabricchaincodespec.go | 19 +++++-------------- .../v1alpha1/fabricchaincodestatus.go | 19 +++++-------------- .../v1alpha1/fabricexplorer.go | 19 +++++-------------- .../v1alpha1/fabricexplorerspec.go | 19 +++++-------------- .../v1alpha1/fabricexplorerstatus.go | 19 +++++-------------- .../v1alpha1/fabricfollowerchannel.go | 19 +++++-------------- .../fabricfollowerchannelanchorpeer.go | 19 +++++-------------- .../fabricfollowerchannelexternalpeer.go | 19 +++++-------------- .../v1alpha1/fabricfollowerchannelorderer.go | 19 +++++-------------- .../v1alpha1/fabricfollowerchannelpeer.go | 19 +++++-------------- .../v1alpha1/fabricfollowerchannelspec.go | 19 +++++-------------- .../v1alpha1/fabricfollowerchannelstatus.go | 19 +++++-------------- .../v1alpha1/fabricfsserver.go | 19 +++++-------------- .../v1alpha1/fabricidentity.go | 19 +++++-------------- .../v1alpha1/fabricidentityregister.go | 19 +++++-------------- .../v1alpha1/fabricidentityspec.go | 19 +++++-------------- .../v1alpha1/fabricidentitystatus.go | 19 +++++-------------- .../v1alpha1/fabricistio.go | 19 +++++-------------- .../v1alpha1/fabricmainchannel.go | 19 +++++-------------- ...mainchanneladminordererorganizationspec.go | 19 +++++-------------- ...ricmainchanneladminpeerorganizationspec.go | 19 +++++-------------- .../fabricmainchannelapplicationconfig.go | 19 +++++-------------- .../v1alpha1/fabricmainchannelconfig.go | 19 +++++-------------- .../v1alpha1/fabricmainchannelconsenter.go | 19 +++++-------------- .../v1alpha1/fabricmainchanneletcdraft.go | 19 +++++-------------- .../fabricmainchanneletcdraftoptions.go | 19 +++++-------------- .../fabricmainchannelexternalorderernode.go | 19 +++++-------------- ...cmainchannelexternalordererorganization.go | 19 +++++-------------- ...bricmainchannelexternalpeerorganization.go | 19 +++++-------------- .../v1alpha1/fabricmainchannelidentity.go | 19 +++++-------------- .../fabricmainchannelordererbatchsize.go | 19 +++++-------------- .../fabricmainchannelordererconfig.go | 19 +++++-------------- .../v1alpha1/fabricmainchannelorderernode.go | 19 +++++-------------- .../fabricmainchannelordererorganization.go | 19 +++++-------------- .../fabricmainchannelpeerorganization.go | 19 +++++-------------- .../fabricmainchannelpoliciesconfig.go | 19 +++++-------------- .../v1alpha1/fabricmainchannelspec.go | 19 +++++-------------- .../v1alpha1/fabricmainchannelstatus.go | 19 +++++-------------- .../v1alpha1/fabricnetworkconfig.go | 19 +++++-------------- .../v1alpha1/fabricnetworkconfigidentity.go | 19 +++++-------------- .../v1alpha1/fabricnetworkconfigspec.go | 19 +++++-------------- .../v1alpha1/fabricnetworkconfigstatus.go | 19 +++++-------------- .../v1alpha1/fabricoperationsconsole.go | 19 +++++-------------- .../v1alpha1/fabricoperationsconsoleauth.go | 19 +++++-------------- .../fabricoperationsconsolecouchdb.go | 19 +++++-------------- .../v1alpha1/fabricoperationsconsolespec.go | 19 +++++-------------- .../v1alpha1/fabricoperationsconsolestatus.go | 19 +++++-------------- .../v1alpha1/fabricoperatorapi.go | 19 +++++-------------- .../v1alpha1/fabricoperatorapiauth.go | 19 +++++-------------- .../v1alpha1/fabricoperatorapihlfconfig.go | 19 +++++-------------- .../fabricoperatorapinetworkconfig.go | 19 +++++-------------- .../v1alpha1/fabricoperatorapispec.go | 19 +++++-------------- .../v1alpha1/fabricoperatorapistatus.go | 19 +++++-------------- .../v1alpha1/fabricoperatorui.go | 19 +++++-------------- .../v1alpha1/fabricoperatoruiauth.go | 19 +++++-------------- .../v1alpha1/fabricoperatoruispec.go | 19 +++++-------------- .../v1alpha1/fabricoperatoruistatus.go | 19 +++++-------------- .../v1alpha1/fabricorderernode.go | 19 +++++-------------- .../v1alpha1/fabricorderernodespec.go | 19 +++++-------------- .../v1alpha1/fabricorderernodestatus.go | 19 +++++-------------- .../v1alpha1/fabricorderingservice.go | 19 +++++-------------- .../v1alpha1/fabricorderingservicespec.go | 19 +++++-------------- .../v1alpha1/fabricorderingservicestatus.go | 19 +++++-------------- .../v1alpha1/fabricpeer.go | 19 +++++-------------- .../v1alpha1/fabricpeercouchdb.go | 19 +++++-------------- .../v1alpha1/fabricpeercouchdbexporter.go | 19 +++++-------------- .../v1alpha1/fabricpeerdiscovery.go | 19 +++++-------------- .../v1alpha1/fabricpeerexternalcouchdb.go | 19 +++++-------------- .../v1alpha1/fabricpeerlogging.go | 19 +++++-------------- .../v1alpha1/fabricpeerresources.go | 19 +++++-------------- .../v1alpha1/fabricpeerspec.go | 19 +++++-------------- .../v1alpha1/fabricpeerspecgossip.go | 19 +++++-------------- .../v1alpha1/fabricpeerstatus.go | 19 +++++-------------- .../v1alpha1/fabricpeerstorage.go | 19 +++++-------------- .../v1alpha1/fabrictlscacrypto.go | 19 +++++-------------- .../v1alpha1/grpcproxy.go | 19 +++++-------------- .../v1alpha1/hlfidentity.go | 19 +++++-------------- .../hlf.kungfusoftware.es/v1alpha1/ingress.go | 19 +++++-------------- .../v1alpha1/ingresshost.go | 19 +++++-------------- .../v1alpha1/ingresspath.go | 19 +++++-------------- .../v1alpha1/orderercapabilities.go | 19 +++++-------------- .../v1alpha1/ordererenrollment.go | 19 +++++-------------- .../v1alpha1/orderernode.go | 19 +++++-------------- .../v1alpha1/orderernodeenrollment.go | 19 +++++-------------- .../v1alpha1/orderernodeenrollmenttls.go | 19 +++++-------------- .../v1alpha1/orderernodeservice.go | 19 +++++-------------- .../v1alpha1/ordererservice.go | 19 +++++-------------- .../v1alpha1/orderersystemchannel.go | 19 +++++-------------- .../v1alpha1/peerservice.go | 19 +++++-------------- .../hlf.kungfusoftware.es/v1alpha1/secret.go | 19 +++++-------------- .../v1alpha1/servicemonitor.go | 19 +++++-------------- .../hlf.kungfusoftware.es/v1alpha1/storage.go | 19 +++++-------------- .../hlf.kungfusoftware.es/v1alpha1/tls.go | 19 +++++-------------- .../applyconfiguration/internal/internal.go | 19 +++++-------------- pkg/client/applyconfiguration/utils.go | 19 +++++-------------- pkg/client/clientset/versioned/clientset.go | 19 +++++-------------- .../versioned/fake/clientset_generated.go | 19 +++++-------------- pkg/client/clientset/versioned/fake/doc.go | 19 +++++-------------- .../clientset/versioned/fake/register.go | 19 +++++-------------- pkg/client/clientset/versioned/scheme/doc.go | 19 +++++-------------- .../clientset/versioned/scheme/register.go | 19 +++++-------------- .../hlf.kungfusoftware.es/v1alpha1/doc.go | 19 +++++-------------- .../v1alpha1/fabricca.go | 19 +++++-------------- .../v1alpha1/fabricchaincode.go | 19 +++++-------------- .../v1alpha1/fabricexplorer.go | 19 +++++-------------- .../v1alpha1/fabricfollowerchannel.go | 19 +++++-------------- .../v1alpha1/fabricidentity.go | 19 +++++-------------- .../v1alpha1/fabricmainchannel.go | 19 +++++-------------- .../v1alpha1/fabricnetworkconfig.go | 19 +++++-------------- .../v1alpha1/fabricoperationsconsole.go | 19 +++++-------------- .../v1alpha1/fabricoperatorapi.go | 19 +++++-------------- .../v1alpha1/fabricoperatorui.go | 19 +++++-------------- .../v1alpha1/fabricorderernode.go | 19 +++++-------------- .../v1alpha1/fabricorderingservice.go | 19 +++++-------------- .../v1alpha1/fabricpeer.go | 19 +++++-------------- .../v1alpha1/fake/doc.go | 19 +++++-------------- .../v1alpha1/fake/fake_fabricca.go | 19 +++++-------------- .../v1alpha1/fake/fake_fabricchaincode.go | 19 +++++-------------- .../v1alpha1/fake/fake_fabricexplorer.go | 19 +++++-------------- .../fake/fake_fabricfollowerchannel.go | 19 +++++-------------- .../v1alpha1/fake/fake_fabricidentity.go | 19 +++++-------------- .../v1alpha1/fake/fake_fabricmainchannel.go | 19 +++++-------------- .../v1alpha1/fake/fake_fabricnetworkconfig.go | 19 +++++-------------- .../fake/fake_fabricoperationsconsole.go | 19 +++++-------------- .../v1alpha1/fake/fake_fabricoperatorapi.go | 19 +++++-------------- .../v1alpha1/fake/fake_fabricoperatorui.go | 19 +++++-------------- .../v1alpha1/fake/fake_fabricorderernode.go | 19 +++++-------------- .../fake/fake_fabricorderingservice.go | 19 +++++-------------- .../v1alpha1/fake/fake_fabricpeer.go | 19 +++++-------------- .../fake/fake_hlf.kungfusoftware.es_client.go | 19 +++++-------------- .../v1alpha1/generated_expansion.go | 19 +++++-------------- .../v1alpha1/hlf.kungfusoftware.es_client.go | 19 +++++-------------- .../informers/externalversions/factory.go | 19 +++++-------------- .../informers/externalversions/generic.go | 19 +++++-------------- .../hlf.kungfusoftware.es/interface.go | 19 +++++-------------- .../v1alpha1/fabricca.go | 19 +++++-------------- .../v1alpha1/fabricchaincode.go | 19 +++++-------------- .../v1alpha1/fabricexplorer.go | 19 +++++-------------- .../v1alpha1/fabricfollowerchannel.go | 19 +++++-------------- .../v1alpha1/fabricidentity.go | 19 +++++-------------- .../v1alpha1/fabricmainchannel.go | 19 +++++-------------- .../v1alpha1/fabricnetworkconfig.go | 19 +++++-------------- .../v1alpha1/fabricoperationsconsole.go | 19 +++++-------------- .../v1alpha1/fabricoperatorapi.go | 19 +++++-------------- .../v1alpha1/fabricoperatorui.go | 19 +++++-------------- .../v1alpha1/fabricorderernode.go | 19 +++++-------------- .../v1alpha1/fabricorderingservice.go | 19 +++++-------------- .../v1alpha1/fabricpeer.go | 19 +++++-------------- .../v1alpha1/interface.go | 19 +++++-------------- .../internalinterfaces/factory_interfaces.go | 19 +++++-------------- .../v1alpha1/expansion_generated.go | 19 +++++-------------- .../v1alpha1/fabricca.go | 19 +++++-------------- .../v1alpha1/fabricchaincode.go | 19 +++++-------------- .../v1alpha1/fabricexplorer.go | 19 +++++-------------- .../v1alpha1/fabricfollowerchannel.go | 19 +++++-------------- .../v1alpha1/fabricidentity.go | 19 +++++-------------- .../v1alpha1/fabricmainchannel.go | 19 +++++-------------- .../v1alpha1/fabricnetworkconfig.go | 19 +++++-------------- .../v1alpha1/fabricoperationsconsole.go | 19 +++++-------------- .../v1alpha1/fabricoperatorapi.go | 19 +++++-------------- .../v1alpha1/fabricoperatorui.go | 19 +++++-------------- .../v1alpha1/fabricorderernode.go | 19 +++++-------------- .../v1alpha1/fabricorderingservice.go | 19 +++++-------------- .../v1alpha1/fabricpeer.go | 19 +++++-------------- 210 files changed, 1041 insertions(+), 2924 deletions(-) create mode 100644 k8s/.gitkeep delete mode 100644 k8s/boilerplate.go.txt diff --git a/k8s/.gitkeep b/k8s/.gitkeep new file mode 100644 index 00000000..77a70a29 --- /dev/null +++ b/k8s/.gitkeep @@ -0,0 +1 @@ +//keep this folder diff --git a/k8s/boilerplate.go.txt b/k8s/boilerplate.go.txt deleted file mode 100644 index 52fbdef1..00000000 --- a/k8s/boilerplate.go.txt +++ /dev/null @@ -1,12 +0,0 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/applicationcapabilities.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/applicationcapabilities.go index 351bac22..6ee2b071 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/applicationcapabilities.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/applicationcapabilities.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/catls.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/catls.go index 0e8f8472..18d3536a 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/catls.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/catls.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/channelcapabilities.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/channelcapabilities.go index ac2ca4d5..d121c6e9 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/channelcapabilities.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/channelcapabilities.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/channelconfig.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/channelconfig.go index 49e52e6a..7de48e03 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/channelconfig.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/channelconfig.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/component.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/component.go index 00fd3b9a..8e664bfc 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/component.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/component.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/cors.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/cors.go index 4a21807c..c8837835 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/cors.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/cors.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/csr.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/csr.go index 1bc1cbdb..f6d3fe81 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/csr.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/csr.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/enrollment.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/enrollment.go index 629c6f5b..2089f76c 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/enrollment.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/enrollment.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/externalbuilder.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/externalbuilder.go index 70273158..12ae9803 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/externalbuilder.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/externalbuilder.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/externalcertificate.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/externalcertificate.go index 27e25c40..09a0bdd1 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/externalcertificate.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/externalcertificate.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricca.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricca.go index d5c76d8d..97f13e24 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricca.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricca.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaaffiliation.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaaffiliation.go index 2da31e40..4f58f4e7 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaaffiliation.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaaffiliation.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccabccsp.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccabccsp.go index 166baca1..3285bd2f 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccabccsp.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccabccsp.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccabccspsw.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccabccspsw.go index a2860f9a..89799b97 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccabccspsw.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccabccspsw.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacfg.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacfg.go index b34723a0..bdada19a 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacfg.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacfg.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacfgaffilitions.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacfgaffilitions.go index 007c7ebe..08cc485e 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacfgaffilitions.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacfgaffilitions.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacfgidentities.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacfgidentities.go index 3afada64..f1414605 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacfgidentities.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacfgidentities.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaclientauth.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaclientauth.go index 2bb7690f..748cd9f1 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaclientauth.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaclientauth.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacrl.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacrl.go index c6835564..a5039735 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacrl.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacrl.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacrypto.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacrypto.go index eb8f016e..ce01d3d4 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacrypto.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacrypto.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacsr.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacsr.go index 3afe8391..36ef0ba0 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacsr.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacsr.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacsrca.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacsrca.go index 68591790..afa0af76 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacsrca.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccacsrca.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccadatabase.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccadatabase.go index 56315a4d..2285642a 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccadatabase.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccadatabase.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaidentity.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaidentity.go index 77827a96..937d7c61 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaidentity.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaidentity.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaidentityattrs.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaidentityattrs.go index e52c31a6..42003364 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaidentityattrs.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaidentityattrs.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaintermediate.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaintermediate.go index e6f8beb4..4dd5a7ff 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaintermediate.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaintermediate.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaintermediateparentserver.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaintermediateparentserver.go index 387a9670..d71a75e5 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaintermediateparentserver.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaintermediateparentserver.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaitemconf.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaitemconf.go index 60e97d35..d6e01168 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaitemconf.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaitemconf.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccametrics.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccametrics.go index 9a1e226e..06c0d9bf 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccametrics.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccametrics.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccametricsstatsd.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccametricsstatsd.go index 4106e80c..d5a76161 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccametricsstatsd.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccametricsstatsd.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccanames.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccanames.go index 8c7d3983..cf296b73 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccanames.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccanames.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaregistry.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaregistry.go index e01497a9..855ed22a 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaregistry.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaregistry.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigning.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigning.go index 75a2065a..79c3daf6 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigning.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigning.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningdefault.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningdefault.go index 37192339..edec84b8 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningdefault.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningdefault.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningprofiles.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningprofiles.go index caef638c..59d28128 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningprofiles.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningprofiles.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningsignprofile.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningsignprofile.go index a59173d0..db05da10 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningsignprofile.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningsignprofile.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningsignprofileconstraint.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningsignprofileconstraint.go index 682a4bf4..dff6f609 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningsignprofileconstraint.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningsignprofileconstraint.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningtlsprofile.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningtlsprofile.go index e3da4b23..8b77ff27 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningtlsprofile.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasigningtlsprofile.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaspec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaspec.go index b42a8e93..491b691e 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaspec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaspec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaspecservice.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaspecservice.go index a998efcf..6f51b31e 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaspecservice.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccaspecservice.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccastatus.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccastatus.go index c097bea7..d360a125 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccastatus.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccastatus.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasubject.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasubject.go index 8f6e9a5f..a808b67f 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasubject.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccasubject.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccatlsconf.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccatlsconf.go index baa118b4..33a8f492 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccatlsconf.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabriccatlsconf.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go index a22702de..75980be9 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricchaincodespec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricchaincodespec.go index 1759a2cc..26302aab 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricchaincodespec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricchaincodespec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricchaincodestatus.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricchaincodestatus.go index 27adc64e..19dea8d3 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricchaincodestatus.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricchaincodestatus.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go index b8d7b5bb..5f9ebf12 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricexplorerspec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricexplorerspec.go index 72029302..f4b820b0 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricexplorerspec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricexplorerspec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricexplorerstatus.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricexplorerstatus.go index c8bbada9..5ca19d56 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricexplorerstatus.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricexplorerstatus.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go index 61f17257..92ddad70 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelanchorpeer.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelanchorpeer.go index 5367ff2f..d3cb6533 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelanchorpeer.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelanchorpeer.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelexternalpeer.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelexternalpeer.go index 4633d39b..2f6130a7 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelexternalpeer.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelexternalpeer.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelorderer.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelorderer.go index c0ac52dd..3a39301b 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelorderer.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelorderer.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelpeer.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelpeer.go index 50fbf356..b5264f9e 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelpeer.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelpeer.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelspec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelspec.go index 5941d23d..63c5211b 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelspec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelspec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelstatus.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelstatus.go index 3a715b1b..aee47044 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelstatus.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannelstatus.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfsserver.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfsserver.go index 1f1eda05..69e67c11 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfsserver.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricfsserver.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go index 3e616620..4c14ccd5 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentityregister.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentityregister.go index 91cccfc9..198eff50 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentityregister.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentityregister.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentityspec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentityspec.go index ff4acde4..31dc99cc 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentityspec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentityspec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentitystatus.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentitystatus.go index 2b5cc212..64b624c2 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentitystatus.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricidentitystatus.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricistio.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricistio.go index 44bd8b27..efb790d4 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricistio.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricistio.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go index 54e467b2..f9be4689 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneladminordererorganizationspec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneladminordererorganizationspec.go index 4b4e7346..3d933bd2 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneladminordererorganizationspec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneladminordererorganizationspec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneladminpeerorganizationspec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneladminpeerorganizationspec.go index 8f59453f..0847b3cd 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneladminpeerorganizationspec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneladminpeerorganizationspec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelapplicationconfig.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelapplicationconfig.go index 224e5df8..f188ae59 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelapplicationconfig.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelapplicationconfig.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelconfig.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelconfig.go index d363b601..a8d31d2d 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelconfig.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelconfig.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelconsenter.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelconsenter.go index f4d35387..3691311f 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelconsenter.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelconsenter.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneletcdraft.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneletcdraft.go index eddb560c..c791807a 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneletcdraft.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneletcdraft.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneletcdraftoptions.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneletcdraftoptions.go index 6b45b4e0..4e1ba180 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneletcdraftoptions.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchanneletcdraftoptions.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelexternalorderernode.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelexternalorderernode.go index 7d0392e0..d97c4a06 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelexternalorderernode.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelexternalorderernode.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelexternalordererorganization.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelexternalordererorganization.go index d440bbb0..93640ec9 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelexternalordererorganization.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelexternalordererorganization.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelexternalpeerorganization.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelexternalpeerorganization.go index acfaa91f..26de2cdc 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelexternalpeerorganization.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelexternalpeerorganization.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelidentity.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelidentity.go index fb1b2d3f..e21b16c1 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelidentity.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelidentity.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelordererbatchsize.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelordererbatchsize.go index 0b6d14cb..ffd4ff0b 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelordererbatchsize.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelordererbatchsize.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelordererconfig.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelordererconfig.go index fb02b960..869500fc 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelordererconfig.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelordererconfig.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelorderernode.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelorderernode.go index 0773cfa9..34f23247 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelorderernode.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelorderernode.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelordererorganization.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelordererorganization.go index afb4348d..96339003 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelordererorganization.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelordererorganization.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelpeerorganization.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelpeerorganization.go index 34da0aee..b05b785e 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelpeerorganization.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelpeerorganization.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelpoliciesconfig.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelpoliciesconfig.go index 47f6ac56..bfe6dfa6 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelpoliciesconfig.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelpoliciesconfig.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelspec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelspec.go index 914fd8f1..a43d384b 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelspec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelspec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelstatus.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelstatus.go index 5131bb7e..f83a0b6e 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelstatus.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricmainchannelstatus.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go index 638822a0..de02e6ae 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfigidentity.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfigidentity.go index 57d029e2..97bdfa67 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfigidentity.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfigidentity.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfigspec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfigspec.go index 97191082..e5de3a28 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfigspec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfigspec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfigstatus.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfigstatus.go index 6183ff8d..6c850a33 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfigstatus.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfigstatus.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go index c6a278d3..228dfc36 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsoleauth.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsoleauth.go index 6216afa6..1628f70f 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsoleauth.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsoleauth.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsolecouchdb.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsolecouchdb.go index 863b5ace..7afd0a07 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsolecouchdb.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsolecouchdb.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsolespec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsolespec.go index fac5a254..aeede66d 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsolespec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsolespec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsolestatus.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsolestatus.go index efac26e5..0d2e9e54 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsolestatus.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsolestatus.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go index e359596d..e41c78f4 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapiauth.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapiauth.go index a243dcfc..ad3108fe 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapiauth.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapiauth.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapihlfconfig.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapihlfconfig.go index effbf5c4..c15e16d6 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapihlfconfig.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapihlfconfig.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapinetworkconfig.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapinetworkconfig.go index d4c5b546..2fceff3e 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapinetworkconfig.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapinetworkconfig.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapispec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapispec.go index 1ab02803..287d4967 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapispec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapispec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapistatus.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapistatus.go index fd19a383..c6d162f8 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapistatus.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapistatus.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go index 54dfa525..782ba5e0 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatoruiauth.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatoruiauth.go index 221a878f..fc7d4226 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatoruiauth.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatoruiauth.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatoruispec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatoruispec.go index 004683ef..b91ebedf 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatoruispec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatoruispec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatoruistatus.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatoruistatus.go index 1a5c5f3a..5e4f5b73 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatoruistatus.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricoperatoruistatus.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go index 4f2b6053..8a6a4961 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderernodespec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderernodespec.go index 8781f1fb..0af14a30 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderernodespec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderernodespec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderernodestatus.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderernodestatus.go index 1b4b4e4c..c83ac415 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderernodestatus.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderernodestatus.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go index 1e4fa93e..69173506 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderingservicespec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderingservicespec.go index 064d6f6f..a11ffcc4 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderingservicespec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderingservicespec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderingservicestatus.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderingservicestatus.go index 79564a31..4e088046 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderingservicestatus.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricorderingservicestatus.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go index 9ec7a8b8..34c0c83b 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeercouchdb.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeercouchdb.go index f3a60302..7fa90d5e 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeercouchdb.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeercouchdb.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeercouchdbexporter.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeercouchdbexporter.go index 122e6621..9e6fc9c3 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeercouchdbexporter.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeercouchdbexporter.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerdiscovery.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerdiscovery.go index ec5467d6..e0452580 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerdiscovery.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerdiscovery.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerexternalcouchdb.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerexternalcouchdb.go index f8f60d26..ddb32b33 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerexternalcouchdb.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerexternalcouchdb.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerlogging.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerlogging.go index 961c2dad..362dedde 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerlogging.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerlogging.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerresources.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerresources.go index 8ea7b653..3b1a4782 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerresources.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerresources.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerspec.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerspec.go index a8703441..c22a5ce0 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerspec.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerspec.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerspecgossip.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerspecgossip.go index 803654ea..1c0ef382 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerspecgossip.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerspecgossip.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerstatus.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerstatus.go index 7bbfa661..09c0c8fb 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerstatus.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerstatus.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerstorage.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerstorage.go index baf35847..7f6e2c64 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerstorage.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabricpeerstorage.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabrictlscacrypto.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabrictlscacrypto.go index fe7ffbb9..9d210a2e 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabrictlscacrypto.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/fabrictlscacrypto.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/grpcproxy.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/grpcproxy.go index e42c503c..e334d596 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/grpcproxy.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/grpcproxy.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/hlfidentity.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/hlfidentity.go index e196455b..e6dd2dcb 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/hlfidentity.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/hlfidentity.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ingress.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ingress.go index 3279dd4c..4557330d 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ingress.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ingress.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ingresshost.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ingresshost.go index 37293c75..8e492ed2 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ingresshost.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ingresshost.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ingresspath.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ingresspath.go index f492537d..5ca11219 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ingresspath.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ingresspath.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderercapabilities.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderercapabilities.go index 7baa2048..b021a5ee 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderercapabilities.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderercapabilities.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ordererenrollment.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ordererenrollment.go index 1f9cff96..8db07908 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ordererenrollment.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ordererenrollment.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernode.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernode.go index 8dfe9946..1bafddd4 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernode.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernode.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernodeenrollment.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernodeenrollment.go index 322cf1ac..34886409 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernodeenrollment.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernodeenrollment.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernodeenrollmenttls.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernodeenrollmenttls.go index 15b4fdd4..377b5989 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernodeenrollmenttls.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernodeenrollmenttls.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernodeservice.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernodeservice.go index 979173b4..da5f0cd2 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernodeservice.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderernodeservice.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ordererservice.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ordererservice.go index 46eae2da..8aa4e498 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ordererservice.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/ordererservice.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderersystemchannel.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderersystemchannel.go index b54fee0c..8001c7cf 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderersystemchannel.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/orderersystemchannel.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/peerservice.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/peerservice.go index 2d251f97..1461aa36 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/peerservice.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/peerservice.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/secret.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/secret.go index c0b6ff25..3d8733ec 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/secret.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/secret.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/servicemonitor.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/servicemonitor.go index 66eb1c52..f4fe6952 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/servicemonitor.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/servicemonitor.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/storage.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/storage.go index c185f40a..e23def92 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/storage.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/storage.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/tls.go b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/tls.go index 22fbbe46..fe7038b7 100644 --- a/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/tls.go +++ b/pkg/client/applyconfiguration/hlf.kungfusoftware.es/v1alpha1/tls.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/applyconfiguration/internal/internal.go b/pkg/client/applyconfiguration/internal/internal.go index 995895e0..883bd618 100644 --- a/pkg/client/applyconfiguration/internal/internal.go +++ b/pkg/client/applyconfiguration/internal/internal.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package internal diff --git a/pkg/client/applyconfiguration/utils.go b/pkg/client/applyconfiguration/utils.go index 4f730f82..255968f3 100644 --- a/pkg/client/applyconfiguration/utils.go +++ b/pkg/client/applyconfiguration/utils.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by applyconfiguration-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package applyconfiguration diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 909f099f..b1a3839e 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package versioned diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 31921825..671453d1 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/fake/doc.go b/pkg/client/clientset/versioned/fake/doc.go index a2af5ec0..0b557c37 100644 --- a/pkg/client/clientset/versioned/fake/doc.go +++ b/pkg/client/clientset/versioned/fake/doc.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ // This package has the automatically generated fake clientset. package fake diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 4a9236c0..4c1d3af1 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/scheme/doc.go b/pkg/client/clientset/versioned/scheme/doc.go index 78f7119d..08313f93 100644 --- a/pkg/client/clientset/versioned/scheme/doc.go +++ b/pkg/client/clientset/versioned/scheme/doc.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ // This package contains the scheme of the automatically generated clientset. package scheme diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 0aa83894..37e028ec 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package scheme diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/doc.go index 5b2cd590..4615b9f8 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/doc.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/doc.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ // This package has the automatically generated typed clients. package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricca.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricca.go index d7babb8a..bfb55c8b 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricca.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricca.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go index 86923320..3d05236c 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go index 36b49308..2a6be011 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go index eb4e4e00..5ac183df 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go index b6ecad5b..cb8b4549 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go index 04abd0d2..501d961f 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go index 304bbc54..8c7db391 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go index a3a0ccdb..9638137d 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go index e1d44096..4cdd37b3 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go index 02c79bd0..1e6ca847 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go index 6d4ef872..7fa8cad8 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go index 2e439a03..04d95a1b 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go index aad8701e..5ad01025 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/doc.go index 7644981c..60760a09 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/doc.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/doc.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ // Package fake has the automatically generated clients. package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricca.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricca.go index 972ce3a6..d025b028 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricca.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricca.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricchaincode.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricchaincode.go index d642b68d..05039dd4 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricchaincode.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricchaincode.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricexplorer.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricexplorer.go index 41f34bf6..e54a77b5 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricexplorer.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricexplorer.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricfollowerchannel.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricfollowerchannel.go index 46d72624..55f8aab8 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricfollowerchannel.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricfollowerchannel.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricidentity.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricidentity.go index cdfc995f..7fdfb4f0 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricidentity.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricidentity.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricmainchannel.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricmainchannel.go index 948fecaa..b47a2802 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricmainchannel.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricmainchannel.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricnetworkconfig.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricnetworkconfig.go index 97bf1858..a0cacb29 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricnetworkconfig.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricnetworkconfig.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricoperationsconsole.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricoperationsconsole.go index a67cd27a..947b3be2 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricoperationsconsole.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricoperationsconsole.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricoperatorapi.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricoperatorapi.go index 6dddbca1..815a8ca1 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricoperatorapi.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricoperatorapi.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricoperatorui.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricoperatorui.go index 1c8c9639..b6fa7196 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricoperatorui.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricoperatorui.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricorderernode.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricorderernode.go index 312ccf70..f534424f 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricorderernode.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricorderernode.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricorderingservice.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricorderingservice.go index 6e965ec0..e5e90309 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricorderingservice.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricorderingservice.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricpeer.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricpeer.go index b513bf0a..5ad79011 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricpeer.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_fabricpeer.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_hlf.kungfusoftware.es_client.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_hlf.kungfusoftware.es_client.go index e9c02cce..decb09d5 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_hlf.kungfusoftware.es_client.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/fake/fake_hlf.kungfusoftware.es_client.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package fake diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/generated_expansion.go index c339e7aa..663e937f 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/generated_expansion.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/hlf.kungfusoftware.es_client.go b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/hlf.kungfusoftware.es_client.go index 4a364978..7fea47fa 100644 --- a/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/hlf.kungfusoftware.es_client.go +++ b/pkg/client/clientset/versioned/typed/hlf.kungfusoftware.es/v1alpha1/hlf.kungfusoftware.es_client.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by client-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go index d301d852..ab1e01c9 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package externalversions diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index ecd33af9..c53d4b5d 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package externalversions diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/interface.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/interface.go index 09fa7719..91ad453c 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/interface.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/interface.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package hlf diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricca.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricca.go index bd3f3c08..b9f7c97c 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricca.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricca.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go index d0e685e5..8699515a 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go index 581989a7..537ee397 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go index 057877eb..597a13f0 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go index 8888eee6..30f9a617 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go index a0d66472..7e8c279b 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go index 4a29aa7f..a58f281e 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go index 59e3261a..652f01bc 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go index c4ca44ee..731b6aae 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go index 4e9f5a1e..a8dc606a 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go index 8cacf2d9..e13ccc79 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go index f71a3db2..09681635 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go index 20a4622e..08c5c5bf 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/interface.go b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/interface.go index d243827e..84cb3c08 100644 --- a/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/hlf.kungfusoftware.es/v1alpha1/interface.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go index dbbdad3d..de5cc79a 100644 --- a/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go +++ b/pkg/client/informers/externalversions/internalinterfaces/factory_interfaces.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by informer-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package internalinterfaces diff --git a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/expansion_generated.go b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/expansion_generated.go index 6af147ef..a3cc3b80 100644 --- a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/expansion_generated.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by lister-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricca.go b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricca.go index f4e0975c..838993b7 100644 --- a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricca.go +++ b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricca.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by lister-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go index f4b21ea2..afb9acb4 100644 --- a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go +++ b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricchaincode.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by lister-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go index 509be78e..0bf52c33 100644 --- a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go +++ b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricexplorer.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by lister-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go index 2a15e4c1..7b116dca 100644 --- a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go +++ b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricfollowerchannel.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by lister-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go index f5f49870..949ec808 100644 --- a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go +++ b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricidentity.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by lister-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go index 4a287ae7..73610ee8 100644 --- a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go +++ b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricmainchannel.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by lister-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go index d51399af..adb54291 100644 --- a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go +++ b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricnetworkconfig.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by lister-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go index 9ab7f737..25d15361 100644 --- a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go +++ b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricoperationsconsole.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by lister-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go index 59f23255..918529b4 100644 --- a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go +++ b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricoperatorapi.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by lister-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go index 9b3b7a1f..2956983d 100644 --- a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go +++ b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricoperatorui.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by lister-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go index eb7fc7c7..e4f0edcc 100644 --- a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go +++ b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricorderernode.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by lister-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go index 31217ae8..bb3d3fdd 100644 --- a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go +++ b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricorderingservice.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by lister-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 diff --git a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go index b717c907..936036b4 100644 --- a/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go +++ b/pkg/client/listers/hlf.kungfusoftware.es/v1alpha1/fabricpeer.go @@ -1,17 +1,8 @@ -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// Code generated by lister-gen. DO NOT EDIT. +/* + * Copyright Kungfusoftware.es. All Rights Reserved. + * + * SPDX-License-Identifier: Apache-2.0 + */ package v1alpha1 From e85fe6a46337279aec40593aecd3e08f9877f877 Mon Sep 17 00:00:00 2001 From: fthrslntgy Date: Thu, 5 Oct 2023 17:11:16 +0300 Subject: [PATCH 3/7] Add transient map arg to chaincode invoke&query Signed-off-by: fthrslntgy --- kubectl-hlf/cmd/chaincode/invoke.go | 13 +++++++++++-- kubectl-hlf/cmd/chaincode/query.go | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/kubectl-hlf/cmd/chaincode/invoke.go b/kubectl-hlf/cmd/chaincode/invoke.go index 096d609c..b34e2217 100644 --- a/kubectl-hlf/cmd/chaincode/invoke.go +++ b/kubectl-hlf/cmd/chaincode/invoke.go @@ -1,14 +1,16 @@ package chaincode import ( + "encoding/json" "fmt" + "io" + "github.com/hyperledger/fabric-sdk-go/pkg/client/channel" "github.com/hyperledger/fabric-sdk-go/pkg/core/config" "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk" "github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" - "io" ) type invokeChaincodeCmd struct { @@ -19,6 +21,7 @@ type invokeChaincodeCmd struct { chaincode string fcn string args []string + transient string } func (c *invokeChaincodeCmd) validate() error { @@ -56,13 +59,18 @@ func (c *invokeChaincodeCmd) run(out io.Writer) error { for _, arg := range c.args { args = append(args, []byte(arg)) } + var transientMap map[string][]byte + err = json.Unmarshal([]byte(c.transient), &transientMap) + if err != nil { + return err + } response, err := ch.Execute( channel.Request{ ChaincodeID: c.chaincode, Fcn: c.fcn, Args: args, - TransientMap: nil, + TransientMap: transientMap, InvocationChain: nil, IsInit: false, }, @@ -96,6 +104,7 @@ func newInvokeChaincodeCMD(out io.Writer, errOut io.Writer) *cobra.Command { persistentFlags.StringVarP(&c.chaincode, "chaincode", "", "", "Chaincode label") persistentFlags.StringVarP(&c.fcn, "fcn", "", "", "Function name") persistentFlags.StringArrayVarP(&c.args, "args", "a", []string{}, "Function arguments") + persistentFlags.StringVarP(&c.transient, "transient", "t", "", "Transient map") cmd.MarkPersistentFlagRequired("user") cmd.MarkPersistentFlagRequired("peer") cmd.MarkPersistentFlagRequired("config") diff --git a/kubectl-hlf/cmd/chaincode/query.go b/kubectl-hlf/cmd/chaincode/query.go index e4363ad7..4ada4e5d 100644 --- a/kubectl-hlf/cmd/chaincode/query.go +++ b/kubectl-hlf/cmd/chaincode/query.go @@ -1,13 +1,15 @@ package chaincode import ( + "encoding/json" "fmt" + "io" + "github.com/hyperledger/fabric-sdk-go/pkg/client/channel" "github.com/hyperledger/fabric-sdk-go/pkg/core/config" "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk" "github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers" "github.com/spf13/cobra" - "io" ) type queryChaincodeCmd struct { @@ -18,6 +20,7 @@ type queryChaincodeCmd struct { chaincode string fcn string args []string + transient string } func (c *queryChaincodeCmd) validate() error { @@ -56,12 +59,18 @@ func (c *queryChaincodeCmd) run(out io.Writer) error { for _, arg := range c.args { args = append(args, []byte(arg)) } + var transientMap map[string][]byte + err = json.Unmarshal([]byte(c.transient), &transientMap) + if err != nil { + return err + } + response, err := ch.Query( channel.Request{ ChaincodeID: c.chaincode, Fcn: c.fcn, Args: args, - TransientMap: nil, + TransientMap: transientMap, InvocationChain: nil, IsInit: false, }, @@ -95,6 +104,7 @@ func newQueryChaincodeCMD(out io.Writer, errOut io.Writer) *cobra.Command { persistentFlags.StringVarP(&c.chaincode, "chaincode", "", "", "Chaincode label") persistentFlags.StringVarP(&c.fcn, "fcn", "", "", "Function name") persistentFlags.StringArrayVarP(&c.args, "args", "a", []string{}, "Function arguments") + persistentFlags.StringVarP(&c.transient, "transient", "t", "", "Transient map") cmd.MarkPersistentFlagRequired("user") cmd.MarkPersistentFlagRequired("peer") cmd.MarkPersistentFlagRequired("config") From fc8aa2af3851547343fb1c5707e988269505b6f5 Mon Sep 17 00:00:00 2001 From: adityajoshi12 Date: Mon, 25 Sep 2023 11:28:32 +0530 Subject: [PATCH 4/7] custom port for chaincodeserver Signed-off-by: adityajoshi12 --- .../v1alpha1/hlf_types.go | 7 +++++ ...lf.kungfusoftware.es_fabricchaincodes.yaml | 6 ++++ controllers/chaincode/chaincode_controller.go | 6 ++-- kubectl-hlf/cmd/externalchaincode/create.go | 23 +++++++-------- kubectl-hlf/cmd/externalchaincode/sync.go | 29 ++++++++++--------- 5 files changed, 42 insertions(+), 29 deletions(-) diff --git a/api/hlf.kungfusoftware.es/v1alpha1/hlf_types.go b/api/hlf.kungfusoftware.es/v1alpha1/hlf_types.go index 016e3d3a..71db9969 100644 --- a/api/hlf.kungfusoftware.es/v1alpha1/hlf_types.go +++ b/api/hlf.kungfusoftware.es/v1alpha1/hlf_types.go @@ -1576,6 +1576,13 @@ type FabricChaincodeSpec struct { // +optional // +kubebuilder:validation:Default={} Env []corev1.EnvVar `json:"env"` + + // +kubebuilder:default=7052 + ChaincodeServerPort int `json:"chaincodeServerPort"` + + // +optional + // +kubebuilder:validation:Optional + MspID string `json:"mspID"` } // FabricChaincodeStatus defines the observed state of FabricChaincode diff --git a/config/crd/bases/hlf.kungfusoftware.es_fabricchaincodes.yaml b/config/crd/bases/hlf.kungfusoftware.es_fabricchaincodes.yaml index bca721d8..5f47fde0 100644 --- a/config/crd/bases/hlf.kungfusoftware.es_fabricchaincodes.yaml +++ b/config/crd/bases/hlf.kungfusoftware.es_fabricchaincodes.yaml @@ -869,6 +869,9 @@ spec: items: type: string type: array + chaincodeServerPort: + default: 7052 + type: integer command: description: Entrypoint array. Not executed within a shell. The container image's ENTRYPOINT is used if this is not provided. @@ -1056,6 +1059,8 @@ spec: type: object nullable: true type: array + mspID: + type: string packageId: minLength: 1 type: string @@ -1129,6 +1134,7 @@ spec: nullable: true type: array required: + - chaincodeServerPort - image - imagePullPolicy - packageId diff --git a/controllers/chaincode/chaincode_controller.go b/controllers/chaincode/chaincode_controller.go index 25f69479..20d639ac 100644 --- a/controllers/chaincode/chaincode_controller.go +++ b/controllers/chaincode/chaincode_controller.go @@ -50,11 +50,11 @@ func CreateChaincodeCryptoMaterial(conf *hlfv1alpha1.FabricChaincode, caName str TLSCert: tlsCertString, URL: caurl, Name: caName, - MSPID: "Org1MSP", + MSPID: conf.Spec.MspID, User: enrollID, Secret: enrollSecret, Hosts: hosts, - CN: "", + CN: conf.Name, Profile: "tls", Attributes: nil, }) @@ -312,7 +312,7 @@ func (r *FabricChaincodeReconciler) Reconcile(ctx context.Context, req ctrl.Requ } deploymentName := fmt.Sprintf("%s", fabricChaincode.Name) serviceName := fmt.Sprintf("%s", fabricChaincode.Name) - chaincodePort := 7052 + chaincodePort := fabricChaincode.Spec.ChaincodeServerPort chaincodeAddress := fmt.Sprintf("0.0.0.0:%d", chaincodePort) envVars := []corev1.EnvVar{ { diff --git a/kubectl-hlf/cmd/externalchaincode/create.go b/kubectl-hlf/cmd/externalchaincode/create.go index c12ffffe..da38415d 100644 --- a/kubectl-hlf/cmd/externalchaincode/create.go +++ b/kubectl-hlf/cmd/externalchaincode/create.go @@ -12,19 +12,16 @@ import ( ) type createExternalChaincodeCmd struct { - name string - namespace string - image string - packageID string - caName string - caNamespace string - imagePullPolicy string - - enrollId string - enrollSecret string - - replicas int - + name string + namespace string + image string + packageID string + caName string + caNamespace string + imagePullPolicy string + enrollId string + enrollSecret string + replicas int tlsRequired bool ImagePullSecrets []string } diff --git a/kubectl-hlf/cmd/externalchaincode/sync.go b/kubectl-hlf/cmd/externalchaincode/sync.go index 99eb0f58..fe2f6a14 100644 --- a/kubectl-hlf/cmd/externalchaincode/sync.go +++ b/kubectl-hlf/cmd/externalchaincode/sync.go @@ -26,9 +26,10 @@ type syncExternalChaincodeCmd struct { replicas int - tlsRequired bool - ImagePullSecret []string - Env []string + tlsRequired bool + ImagePullSecret []string + Env []string + chaincodeServerPort int } func (c *syncExternalChaincodeCmd) validate() error { @@ -62,16 +63,17 @@ func (c *syncExternalChaincodeCmd) validate() error { } func (c syncExternalChaincodeCmd) getFabricChaincodeSpec(ctx context.Context) (v1alpha1.FabricChaincodeSpec, error) { fabricChaincodeSpec := v1alpha1.FabricChaincodeSpec{ - Image: c.image, - ImagePullPolicy: corev1.PullAlways, - PackageID: c.packageID, - ImagePullSecrets: []corev1.LocalObjectReference{}, - Affinity: nil, - Tolerations: []corev1.Toleration{}, - Resources: nil, - Credentials: nil, - Replicas: c.replicas, - Env: []corev1.EnvVar{}, + Image: c.image, + ImagePullPolicy: corev1.PullAlways, + PackageID: c.packageID, + ImagePullSecrets: []corev1.LocalObjectReference{}, + Affinity: nil, + Tolerations: []corev1.Toleration{}, + Resources: nil, + Credentials: nil, + Replicas: c.replicas, + Env: []corev1.EnvVar{}, + ChaincodeServerPort: c.chaincodeServerPort, } if len(c.ImagePullSecret) > 0 { @@ -274,5 +276,6 @@ func newExternalChaincodeSyncCmd() *cobra.Command { f.IntVarP(&c.replicas, "replicas", "", 1, "Number of replicas of the chaincode") f.StringArrayVarP(&c.ImagePullSecret, "image-pull-secret", "s", []string{}, "Image Pull Secret for the Chaincode Image") f.StringArrayVarP(&c.Env, "env", "", []string{}, "Environment variable for the Chaincode (key=value)") + f.IntVar(&c.chaincodeServerPort, "port", 7052, "Chaincode Server Port") return cmd } From a5050dec53f4f54a3528ea57afff1e2eb5335042 Mon Sep 17 00:00:00 2001 From: adityajoshi12 Date: Mon, 23 Oct 2023 14:47:36 +0530 Subject: [PATCH 5/7] updated CRD in helm-chart Signed-off-by: adityajoshi12 --- .../crds/hlf.kungfusoftware.es_fabricchaincodes.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chart/hlf-operator/templates/crds/hlf.kungfusoftware.es_fabricchaincodes.yaml b/chart/hlf-operator/templates/crds/hlf.kungfusoftware.es_fabricchaincodes.yaml index bca721d8..5f47fde0 100644 --- a/chart/hlf-operator/templates/crds/hlf.kungfusoftware.es_fabricchaincodes.yaml +++ b/chart/hlf-operator/templates/crds/hlf.kungfusoftware.es_fabricchaincodes.yaml @@ -869,6 +869,9 @@ spec: items: type: string type: array + chaincodeServerPort: + default: 7052 + type: integer command: description: Entrypoint array. Not executed within a shell. The container image's ENTRYPOINT is used if this is not provided. @@ -1056,6 +1059,8 @@ spec: type: object nullable: true type: array + mspID: + type: string packageId: minLength: 1 type: string @@ -1129,6 +1134,7 @@ spec: nullable: true type: array required: + - chaincodeServerPort - image - imagePullPolicy - packageId From a855d4ab60de6a5ea74f4d983d5254eaf2949390 Mon Sep 17 00:00:00 2001 From: fthrslntgy Date: Sat, 4 Nov 2023 19:46:47 +0300 Subject: [PATCH 6/7] Check transient parameter exists Signed-off-by: fthrslntgy --- kubectl-hlf/cmd/chaincode/invoke.go | 8 +++++--- kubectl-hlf/cmd/chaincode/query.go | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/kubectl-hlf/cmd/chaincode/invoke.go b/kubectl-hlf/cmd/chaincode/invoke.go index b34e2217..5b42cd0d 100644 --- a/kubectl-hlf/cmd/chaincode/invoke.go +++ b/kubectl-hlf/cmd/chaincode/invoke.go @@ -60,9 +60,11 @@ func (c *invokeChaincodeCmd) run(out io.Writer) error { args = append(args, []byte(arg)) } var transientMap map[string][]byte - err = json.Unmarshal([]byte(c.transient), &transientMap) - if err != nil { - return err + if c.transient != "" { + err = json.Unmarshal([]byte(c.transient), &transientMap) + if err != nil { + return err + } } response, err := ch.Execute( diff --git a/kubectl-hlf/cmd/chaincode/query.go b/kubectl-hlf/cmd/chaincode/query.go index 4ada4e5d..cf0e05af 100644 --- a/kubectl-hlf/cmd/chaincode/query.go +++ b/kubectl-hlf/cmd/chaincode/query.go @@ -60,9 +60,11 @@ func (c *queryChaincodeCmd) run(out io.Writer) error { args = append(args, []byte(arg)) } var transientMap map[string][]byte - err = json.Unmarshal([]byte(c.transient), &transientMap) - if err != nil { - return err + if c.transient != "" { + err = json.Unmarshal([]byte(c.transient), &transientMap) + if err != nil { + return err + } } response, err := ch.Query( From 62d002839d8873fb4fd930af8bada62024bae701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Torres?= Date: Mon, 20 Nov 2023 19:57:52 +0100 Subject: [PATCH 7/7] doc: Add June workshop video to the Readme (#183) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: AndrĂ©s Torres --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6cbf29a4..2a74ed79 100644 --- a/README.md +++ b/README.md @@ -32,19 +32,26 @@ For discussions and questions, please join the Hyperledger Foundation Discord: The channel is located under `BEVEL`, named [`bevel-operator-fabric`](https://discordapp.com/channels/905194001349627914/967823782712594442). - ## Tutorial Videos -Step by step video tutorials to setup hlf-operator in kubernetes +Step-by-step video tutorials to setup hlf-operator in Kubernetes [![Hyperledger Fabric on Kubernetes](https://img.youtube.com/vi/e04TcJHUI5M/0.jpg)](https://www.youtube.com/playlist?list=PLuAZTZDgj0csRQuNMY8wbYqOCpzggAuMo "Hyperledger Fabric on Kubernetes") +This workshop provides an in-depth hands on discussion and demonstration of using Bevel and the new Bevel-Operator-Fabric to deploy Hyperledger Fabric on Kubernetes. + ## Hyperledger Meetup -You can watch this video in order to see how to use it to deploy your own network: +You can watch this video to see how to use it to deploy your own network: [![Hyperledger Fabric on Kubernetes](http://img.youtube.com/vi/namKDeJf5QI/0.jpg)](http://www.youtube.com/watch?v=namKDeJf5QI "Hyperledger Fabric on Kubernetes") +## Hyperledger Workshops + +This workshop provides an in-depth, hands-on discussion and demonstration of using Bevel and the new Bevel-Operator-Fabric to deploy Hyperledger Fabric on Kubernetes. + +[![How to Deploy Hyperledger Fabric on Kubernetes with Hyperledger Bevel](https://img.youtube.com/vi/YUC12ahY5_k/0.jpg)](https://www.youtube.com/live/YUC12ahY5_k?feature=share&t=4430) + ## Sponsor | | |