common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WalletHomeDir  = ".bestchains/wallet"      // directory for wallet files
	ConnProfileDir = ".bestchains/connProfile" // directory for connection profile files
)

Constants for file paths

View Source
const (
	// Endpoint to create a depository
	CreateDepository = "/basic/putValue"
	// Endpoint to create an untrusted depository
	CreateUntrustedDepository = "/basic/putUntrustValue"
	// Endpoint to get a specific depository
	GetDepository = "/basic/depositories/%s"
	// Endpoint to list all depositories
	ListDepository = "/basic/depositories"
	// Endpoint to get the current nonce
	DepositoryCurrentNonce = "/basic/currentNonce"

	// Endpoint to create a repository
	CreateRepository = "/market/repo"
	// Endpoint to list all repositories
	ListRepositories = "/market/repos"
	// Endpoint to get the current market nonce
	MarketCurrentNonce = "/market/nonce"
)

Constants for API endpoints

View Source
const (
	// LocalBindPort is the local bind port,
	// If you want to change it, you have to change the configuration in the oidc-server configmap at the same time.
	LocalBindPort = "127.0.0.1:26666"
	// ConfigFilePath is the config file path and file name
	ConfigFilePath = "$HOME/.bestchains/config"
	// ConfigFileType is the config file type
	ConfigFileType = "yaml"
)
View Source
const (
	IBPGroup             = "ibp.com"
	IBPVersion           = "v1beta1"
	IAMGroup             = "iam.tenxcloud.com"
	IAMVersion           = "v1alpha1"
	CoreVersion          = "v1"
	OrganizationResource = "organizations"
	FederationResource   = "federations"
	UserResource         = "users"
	NetworkResource      = "networks"
	Channel              = "channels"
	Configmap            = "configmaps"
	Proposal             = "proposals"
	Vote                 = "votes"
	Network              = "networks"
	EndorsePolicy        = "endorsepolicies"
	ChaincodeBuild       = "chaincodebuilds"
	Chaincode            = "chaincodes"
)

Variables

View Source
var (
	DefaultWalletConfigDir = filepath.Join(os.Getenv("HOME"), WalletHomeDir)
	DefaultConnProfileDir  = filepath.Join(os.Getenv("HOME"), ConnProfileDir)
)

Variables for default directory paths

Functions

func GetDynamicClient

func GetDynamicClient() (dynamic.Interface, error)

func InKubeGetter

func InKubeGetter() (*clientcmdapi.Config, error)

func ListToObj

func ListToObj(list corev1.List) (runtime.Object, error)

Types

type AdminCredential

type AdminCredential struct {
	ID       string `yaml:"id,omitempty" json:"id,omitempty"`
	Password string `yaml:"password,omitempty" json:"password" default:"passw0rd"`
}

+k8s:deepcopy-gen=true

type AuthConfig

type AuthConfig struct {
	// Enable is the enable flag
	Enable bool `mapstructure:"enable"`
	// IssuerURL is the URL of the OIDC issuer.
	IssuerURL string `mapstructure:"issuerurl"`
	// IDToken is the id-token
	IDToken string `mapstructure:"idtoken"`
	// RefreshToken is the refresh-token
	RefreshToken string `mapstructure:"refreshtoken"`
	// Expiry is the expiry time of the access token
	Expiry int64 `mapstructure:"expiry"`
	// Username is the preferred_username(user.spec.name, not user.metadata.name)
	Username string `mapstructure:"username"`

	ClientID     string `mapstructure:"clientid"`
	ClientSecret string `mapstructure:"clientsecret"`
}

type ChannelInfo

type ChannelInfo struct {
	// Peers which can be used to connect to this channel
	Peers map[string]PeerInfo `yaml:"peers" json:"peers"`
}

ChannelInfo defines configurations when connect to this channel +k8s:deepcopy-gen=true

type Client

type Client struct {
	Organization string `yaml:"organization,omitempty" json:"organization,omitempty"`
	Logging      `yaml:"logging,omitempty" json:"logging,omitempty"`
	// For blockchain explorer
	AdminCredential `yaml:"adminCredential,omitempty" json:"adminCredential,omitempty"`
	CredentialStore `yaml:"credentialStore,omitempty" json:"credentialStore,omitempty"`
	TLSEnable       bool `yaml:"tlsEnable,omitempty" json:"tlsEnable,omitempty"`
}

Client defines who is trying to connect with networks

type ClusterConfig

type ClusterConfig struct {
	// LocationOfOrigin indicates where this object came from.  It is used for round tripping config post-merge, but never serialized.
	// +k8s:conversion-gen=false
	LocationOfOrigin string
	// Server is the address of the kubernetes cluster (https://hostname:port).
	Server string `mapstructure:"server"`
	// TLSServerName is used to check server certificate. If TLSServerName is empty, the hostname used to contact the server is used.
	// +optional
	TLSServerName string `mapstructure:"tls-server-name,omitempty"`
	// InsecureSkipTLSVerify skips the validity check for the server's certificate. This will make your HTTPS connections insecure.
	// +optional
	InsecureSkipTLSVerify bool `mapstructure:"insecure-skip-tls-verify,omitempty"`
	// CertificateAuthority is the path to a cert file for the certificate authority.
	// +optional
	CertificateAuthority string `mapstructure:"certificate-authority,omitempty"`
	// CertificateAuthorityData contains PEM-encoded certificate authority certificates. Overrides CertificateAuthority
	// +optional
	CertificateAuthorityData []byte `mapstructure:"certificate-authority-data,omitempty"`
	// ProxyURL is the URL to the proxy to be used for all requests made by this
	// client. URLs with "http", "https", and "socks5" schemes are supported.  If
	// this configuration is not provided or the empty string, the client
	// attempts to construct a proxy configuration from http_proxy and
	// https_proxy environment variables. If these environment variables are not
	// set, the client does not attempt to proxy requests.
	//
	// socks5 proxying does not currently support spdy streaming endpoints (exec,
	// attach, port forward).
	// +optional
	ProxyURL string `mapstructure:"proxy-url,omitempty"`
	// DisableCompression allows client to opt-out of response compression for all requests to the server. This is useful
	// to speed up requests (specifically lists) when client-server network bandwidth is ample, by saving time on
	// compression (server-side) and decompression (client-side): https://github.com/kubernetes/kubernetes/issues/112296.
	// +optional
	DisableCompression bool `mapstructure:"disable-compression,omitempty"`
	// Extensions holds additional information. This is useful for extenders so that reads and writes don't clobber unknown fields
	// +optional
	Extensions map[string]runtime.Object `mapstructure:"extensions,omitempty"`
}

copy from "k8s.io/client-go/tools/clientcmd/api" Cluster contains information about how to communicate with a kubernetes cluster

type Config

type Config struct {
	Auth    AuthConfig    `mapstructure:"auth"`
	Saas    SaasConfig    `mapstructure:"saas"`
	Cluster ClusterConfig `mapstructure:"cluster"`
}

type CredentialStore

type CredentialStore struct {
	Path        string `yaml:"path,omitempty" json:"path,omitempty"`
	CryptoStore `yaml:"cryptoStore,omitempty" json:"cryptoStore,omitempty"`
}

+k8s:deepcopy-gen=true

type CryptoConfig

type CryptoConfig struct {
	Path string `yaml:"path,omitempty" json:"path,omitempty"`
}

+k8s:deepcopy-gen=true

type CryptoStore

type CryptoStore struct {
	Path string `yaml:"path,omitempty" json:"path,omitempty"`
}

+k8s:deepcopy-gen=true

type Depository

type Depository struct {
	// Server represents the URL of the depository server.
	Server string `mapstructure:"server"`
}

Depository represents the configuration for the depository server.

type FabProfile

type FabProfile struct {
	Channel      string       `yaml:"channel" json:"channel" validate:"required"`
	Organization string       `yaml:"organization" json:"organization" validate:"required"`
	User         User         `yaml:"user" json:"user" validate:"required"`
	Enpoint      NodeEndpoint `yaml:"endpoint" json:"endpoint" validate:"required"`
}

FabProfile channal

type Logging

type Logging struct {
	Level string `yaml:"level,omitempty" json:"level,omitempty"`
}

+k8s:deepcopy-gen=true

type Market

type Market struct {
	// Server represents the URL of the market server.
	Server string `mapstructure:"server"`
}

Market represents the configuration for the market server.

type NodeEndpoint

type NodeEndpoint struct {
	URL        string `yaml:"url,omitempty" json:"url,omitempty"`
	TLSCACerts `yaml:"tlsCACerts,omitempty" json:"tlsCACerts,omitempty"`
}

+k8s:deepcopy-gen=true

type Options

type Options struct {
	genericclioptions.IOStreams
}

Options represents the command line options for the application

type OrganizationInfo

type OrganizationInfo struct {
	MSPID string          `yaml:"mspid,omitempty" json:"mspid,omitempty"`
	Users map[string]User `yaml:"users,omitempty" json:"users,omitempty"`
	Peers []string        `yaml:"peers,omitempty" json:"peers,omitempty"`

	// For blockchain explorer
	AdminPrivateKey Pem `yaml:"adminPrivateKey,omitempty" json:"adminPrivateKey,omitempty"`
	SignedCert      Pem `yaml:"signedCert,omitempty" json:"signedCert,omitempty"`
}

OrganizationInfo defines a organization along with its users and peers +k8s:deepcopy-gen=true

type PeerInfo

type PeerInfo struct {
	EndorsingPeer  *bool `yaml:"endorsingPeer,omitempty" json:"endorsingPeer,omitempty"`
	ChaincodeQuery *bool `yaml:"chaincodeQuery,omitempty" json:"chaincodeQuery,omitempty"`
	LedgerQuery    *bool `yaml:"ledgerQuery,omitempty" json:"ledgerQuery,omitempty"`
	EventSource    *bool `yaml:"eventSource,omitempty" json:"eventSource,omitempty"`
}

+k8s:deepcopy-gen=true

type Pem

type Pem struct {
	Pem string `yaml:"pem,omitempty" json:"pem,omitempty"`
}

+k8s:deepcopy-gen=true

type Profile

type Profile struct {
	Version       string `yaml:"version,omitempty" json:"version,omitempty"`
	Client        `yaml:"client,omitempty" json:"client,omitempty"`
	Channels      map[string]ChannelInfo      `yaml:"channels" json:"channels"`
	Organizations map[string]OrganizationInfo `yaml:"organizations,omitempty" json:"organizations,omitempty"`
	// Orderers defines all orderer endpoints which can be used
	Orderers map[string]NodeEndpoint `yaml:"orderers,omitempty" json:"orderers,omitempty"`
	// Peers defines all peer endpoints which can be used
	Peers map[string]NodeEndpoint `yaml:"peers,omitempty" json:"peers,omitempty"`
}

Profile contasins all we need to connect with a blockchain network. Currently we use embeded pem by default +k8s:deepcopy-gen=true

type SaasConfig

type SaasConfig struct {
	// Depository represents the configuration for the depository server.
	Depository Depository `mapstructure:"depository"`
	// Market represents the configuration for the market server.
	Market Market `mapstructure:"market"`
}

SaasConfig represents the configuration for a SaaS application.

type TLSCACerts

type TLSCACerts struct {
	Path string `yaml:"path,omitempty" json:"path,omitempty"`
	Pem  string `yaml:"pem,omitempty" json:"pem,omitempty"`
}

+k8s:deepcopy-gen=true

type User

type User struct {
	Name string `yaml:"name,omitempty" json:"name,omitempty"`
	Key  Pem    `yaml:"key,omitempty" json:"key,omitempty"`
	Cert Pem    `yaml:"cert,omitempty" json:"cert,omitempty"`
}

User is the ca identity which has a private key(embeded pem) and signed certificate(embeded pem) +k8s:deepcopy-gen=true

Jump to

Keyboard shortcuts

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