util

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChaincodeNamespaceVariable      = builderVariablePrefix + "NAMESPACE"
	ChaincodeServiceAccountVariable = builderVariablePrefix + "SERVICE_ACCOUNT"
	DebugVariable                   = builderVariablePrefix + "DEBUG"
	KubeconfigPathVariable          = "KUBECONFIG_PATH"
	PeerIDVariable                  = "CORE_PEER_ID"
)
View Source
const (
	ChaincodeFile = "chaincode.json"
	ImageFile     = "image.json"
	MetadataDir   = "META-INF"
)
View Source
const (

	// Mutual TLS auth client key and cert paths in the chaincode container.
	TLSClientKeyPath      string = "/etc/hyperledger/fabric/client.key"
	TLSClientCertPath     string = "/etc/hyperledger/fabric/client.crt"
	TLSClientKeyFile      string = "/etc/hyperledger/fabric/client_pem.key"
	TLSClientCertFile     string = "/etc/hyperledger/fabric/client_pem.crt"
	TLSClientRootCertFile string = "/etc/hyperledger/fabric/peer.crt"
)

Variables

This section is empty.

Functions

func ApplyChaincodeSecrets

func ApplyChaincodeSecrets(
	ctx context.Context,
	logger *log.CmdLogger,
	secretsClient v1.SecretInterface,
	namespace, peerID string,
	chaincodeData *ChaincodeJSON,
) error

func CopyImageJSON

func CopyImageJSON(logger *log.CmdLogger, src, dest string) error

CopyImageJSON validates and copies the chaincode image file.

func CopyIndexFiles

func CopyIndexFiles(logger *log.CmdLogger, src, dest string) error

CopyIndexFiles copies CouchDB index definitions from source to destination directories.

func CopyMetadataDir

func CopyMetadataDir(logger *log.CmdLogger, src, dest string) error

CopyMetadataDir copies all chaincode metadata from source to destination directories.

func CreateChaincodePod

func CreateChaincodePod(
	ctx context.Context,
	logger *log.CmdLogger,
	podsClient v1.PodInterface,
	namespace, serviceAccount, peerID string,
	chaincodeData *ChaincodeJSON,
	imageData *ImageJSON,
) (*apiv1.Pod, error)

func GetKubeClientset

func GetKubeClientset(logger *log.CmdLogger, kubeconfigPath string) (*kubernetes.Clientset, error)

GetKubeClientset returns a client object for a provided kubeconfig filepath if one is provided, or which uses the service account kubernetes gives to pods otherwise.

func GetKubeNamespace

func GetKubeNamespace() (string, error)

func GetOptionalEnv

func GetOptionalEnv(key, defaultValue string) string

func GetRequiredEnv

func GetRequiredEnv(key string) (string, error)

func GetValidName added in v0.10.0

func GetValidName(mspID, peerID, chaincodeID string) string

GetValidName returns a valid RFC 1035 label name.

func WaitForChaincodePod

func WaitForChaincodePod(
	ctx context.Context,
	logger *log.CmdLogger,
	podsClient v1.PodInterface,
	pod *apiv1.Pod,
	chaincodeID string,
) error

Types

type ChaincodeJSON

type ChaincodeJSON struct {
	ChaincodeID string `json:"chaincode_id"`
	PeerAddress string `json:"peer_address"`
	ClientCert  string `json:"client_cert"`
	ClientKey   string `json:"client_key"`
	RootCert    string `json:"root_cert"`
	MspID       string `json:"mspid"`
}

ChaincodeJSON represents the chaincode.json file that is supplied by Fabric in the RUN_METADATA_DIR.

func ReadChaincodeJSON

func ReadChaincodeJSON(logger *log.CmdLogger, dir string) (*ChaincodeJSON, error)

ReadChaincodeJSON reads and parses the chaincode.json file in the provided directory.

type ImageJSON

type ImageJSON struct {
	Name   string `json:"name"`
	Digest string `json:"digest"`
}

ImageJSON represents the image.json file in the k8s chaincode package.

func ReadImageJSON

func ReadImageJSON(logger *log.CmdLogger, dir string) (*ImageJSON, error)

ReadImageJSON reads and parses the image.json file in the provided directory.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL