Skip to content

Commit

Permalink
[FAB-7874] refactoring api package
Browse files Browse the repository at this point in the history
This change is just to refactor packages
with minimal changes to logic.

- renamed pkg/fabric-txn to pkg/client
- refactored and moved apiconfig to pkg/context/core
- refactored and moved apicryptosuite to pkg/context/core
- refactored and moved apifabca to pkg/context/fab
- refactored and moved apifabclient to pkg/context/fab
- refactored and moved apitxn to pkg/client
- refactored and moved apilogging to pkg/logging/api
- deleted api package
- merged pkg/client/chclient and pkg/client/txnhandler

incoming changes from next code push
- rename pkg/client/chclient to pkg/client/channel
- rename pkg/client/resmgmtclient to pkg/client/resmgmt
- moving pkg/client/txnhandler to pkg/client/chclient/txnhandler
- updating thirdparty pinning scripts- moved api/kvstore to
    fabsdk/api/core


Change-Id: Ic7afa225626ff0ec1ce57516f537c9e109670352
Signed-off-by: Sudesh Shetty <sudesh.shetty@securekey.com>
  • Loading branch information
sudeshrshetty committed Feb 23, 2018
1 parent fc7d324 commit 350f593
Show file tree
Hide file tree
Showing 219 changed files with 2,031 additions and 2,153 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ dockerenv-latest-up: clean

.PHONY: mock-gen
mock-gen:
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/api/apifabclient ProposalProcessor | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > api/apifabclient/mocks/mockfabclient.gen.go
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/api/apiconfig Config | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > api/apiconfig/mocks/mockconfig.gen.go
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/api/apifabca FabricCAClient | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > api/apifabca/mocks/mockfabriccaclient.gen.go
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/api CoreProviders,SvcProviders,Providers,CoreProviderFactory,ServiceProviderFactory,OrgClientFactory,SessionClientFactory | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > pkg/fabsdk/api/mocks/mocksdkapi.gen.go
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/pkg/context/api/core Config | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > pkg/context/api/core/mocks/mockconfig.gen.go
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/pkg/context/api/fab ProposalProcessor,FabricCAClient | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > pkg/context/api/fab/mocks/mockcontextapi.gen.go
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/api CoreProviders,SvcProviders,Providers,CoreProviderFactory,ServiceProviderFactory,OrgClientFactory,SessionClientFactory | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > pkg/fabsdk/mocks/mockfabsdkapi.gen.go


# TODO - Add cryptogen
.PHONY: channel-config-gen
Expand Down
35 changes: 0 additions & 35 deletions api/apifabclient/chconfig.go

This file was deleted.

48 changes: 0 additions & 48 deletions api/apifabclient/mocks/mockfabclient.gen.go

This file was deleted.

88 changes: 0 additions & 88 deletions api/apitxn/chclient/chclient.go

This file was deleted.

38 changes: 0 additions & 38 deletions api/apitxn/chclient/opts.go

This file was deleted.

37 changes: 0 additions & 37 deletions api/apitxn/chclient/txnhandler.go

This file was deleted.

20 changes: 10 additions & 10 deletions def/fabapi/deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ SPDX-License-Identifier: Apache-2.0
package fabapi

import (
"github.com/hyperledger/fabric-sdk-go/api/apiconfig"
"github.com/hyperledger/fabric-sdk-go/api/apilogging"
"github.com/hyperledger/fabric-sdk-go/pkg/config"
"github.com/hyperledger/fabric-sdk-go/pkg/context/api/core"
"github.com/hyperledger/fabric-sdk-go/pkg/fabsdk"
apisdk "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/api"
"github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/factory/defcore"
"github.com/hyperledger/fabric-sdk-go/pkg/logging"
"github.com/hyperledger/fabric-sdk-go/pkg/logging/api"

sdkApi "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/api"
"github.com/pkg/errors"
)

Expand All @@ -33,19 +33,19 @@ type Options struct {
StateStoreOpts StateStoreOpts

// Factories to create clients and providers
CoreFactory apisdk.CoreProviderFactory
ServiceFactory apisdk.ServiceProviderFactory
ContextFactory apisdk.OrgClientFactory
SessionFactory apisdk.SessionClientFactory
LoggerFactory apilogging.LoggerProvider
CoreFactory sdkApi.CoreProviderFactory
ServiceFactory sdkApi.ServiceProviderFactory
ContextFactory sdkApi.OrgClientFactory
SessionFactory sdkApi.SessionClientFactory
LoggerFactory api.LoggerProvider
}

// StateStoreOpts provides setup parameters for KeyValueStore
type StateStoreOpts struct {
Path string
}

func configFromOptions(options *Options) apiconfig.ConfigProvider {
func configFromOptions(options *Options) core.ConfigProvider {
if options.ConfigByte != nil {
return config.FromRaw(options.ConfigByte, options.ConfigType)
}
Expand All @@ -54,7 +54,7 @@ func configFromOptions(options *Options) apiconfig.ConfigProvider {
return config.FromFile(options.ConfigFile)
}

return func() (apiconfig.Config, error) {
return func() (core.Config, error) {
return nil, errors.New("No configuration provided")
}
}
Expand Down
10 changes: 5 additions & 5 deletions internal/github.com/hyperledger/fabric-ca/lib/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ import (

cfsslapi "github.com/cloudflare/cfssl/api"
"github.com/cloudflare/cfssl/csr"
"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/api"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/tls"
log "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkpatch/logbridge"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
"github.com/hyperledger/fabric-sdk-go/pkg/context/api/core"
"github.com/mitchellh/mapstructure"
)

Expand All @@ -56,7 +56,7 @@ type Client struct {
// File and directory paths
keyFile, certFile, caCertsDir string
// The crypto service provider (BCCSP)
csp apicryptosuite.CryptoSuite
csp core.CryptoSuite
// HTTP client associated with this Fabric CA client
httpClient *http.Client
}
Expand Down Expand Up @@ -209,7 +209,7 @@ func (c *Client) Enroll(req *api.EnrollmentRequest) (*EnrollmentResponse, error)
// @param result The result from server
// @param id Name of identity being enrolled or reenrolled
// @param key The private key which was used to sign the request
func (c *Client) newEnrollmentResponse(result *enrollmentResponseNet, id string, key apicryptosuite.Key) (*EnrollmentResponse, error) {
func (c *Client) newEnrollmentResponse(result *enrollmentResponseNet, id string, key core.Key) (*EnrollmentResponse, error) {
log.Debugf("newEnrollmentResponse %s", id)
certByte, err := util.B64Decode(result.Cert)
if err != nil {
Expand All @@ -226,7 +226,7 @@ func (c *Client) newEnrollmentResponse(result *enrollmentResponseNet, id string,
}

// GenCSR generates a CSR (Certificate Signing Request)
func (c *Client) GenCSR(req *api.CSRInfo, id string) ([]byte, apicryptosuite.Key, error) {
func (c *Client) GenCSR(req *api.CSRInfo, id string) ([]byte, core.Key, error) {
log.Debugf("GenCSR %+v", req)

err := c.Init()
Expand Down Expand Up @@ -284,7 +284,7 @@ func (c *Client) newCertificateRequest(req *api.CSRInfo) *csr.CertificateRequest
}

// NewIdentity creates a new identity
func (c *Client) NewIdentity(key apicryptosuite.Key, cert []byte) (*Identity, error) {
func (c *Client) NewIdentity(key core.Key, cert []byte) (*Identity, error) {
name, err := util.GetEnrollmentIDFromPEM(cert)
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions internal/github.com/hyperledger/fabric-ca/lib/clientconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Please review third_party pinning scripts and patches for more details.
package lib

import (
"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/api"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/tls"
"github.com/hyperledger/fabric-sdk-go/pkg/context/api/core"
)

// ClientConfig is the fabric-ca client's config
Expand All @@ -37,6 +37,6 @@ type ClientConfig struct {
ID api.RegistrationRequest
Revoke api.RevocationRequest
CAInfo api.GetCAInfoRequest
CAName string `help:"Name of CA"`
CSP apicryptosuite.CryptoSuite `mapstructure:"bccsp"`
CAName string `help:"Name of CA"`
CSP core.CryptoSuite `mapstructure:"bccsp"`
}
Loading

0 comments on commit 350f593

Please sign in to comment.