/
profile.go
127 lines (107 loc) · 4.81 KB
/
profile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
Copyright 2023 The Bestchains Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package common
// Profile contasins all we need to connect with a blockchain network. Currently we use embeded pem by default
// +k8s:deepcopy-gen=true
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"`
}
// Client defines who is trying to connect with networks
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"`
}
// +k8s:deepcopy-gen=true
type Logging struct {
Level string `yaml:"level,omitempty" json:"level,omitempty"`
}
// +k8s:deepcopy-gen=true
type CryptoConfig struct {
Path string `yaml:"path,omitempty" json:"path,omitempty"`
}
// +k8s:deepcopy-gen=true
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 CredentialStore struct {
Path string `yaml:"path,omitempty" json:"path,omitempty"`
CryptoStore `yaml:"cryptoStore,omitempty" json:"cryptoStore,omitempty"`
}
// +k8s:deepcopy-gen=true
type CryptoStore struct {
Path string `yaml:"path,omitempty" json:"path,omitempty"`
}
// ChannelInfo defines configurations when connect to this channel
// +k8s:deepcopy-gen=true
type ChannelInfo struct {
// Peers which can be used to connect to this channel
Peers map[string]PeerInfo `yaml:"peers" json:"peers"`
}
// +k8s:deepcopy-gen=true
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"`
}
// OrganizationInfo defines a organization along with its users and peers
// +k8s:deepcopy-gen=true
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"`
}
// User is the ca identity which has a private key(embeded pem) and signed certificate(embeded pem)
// +k8s:deepcopy-gen=true
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"`
}
// +k8s:deepcopy-gen=true
type Pem struct {
Pem string `yaml:"pem,omitempty" json:"pem,omitempty"`
}
// +k8s:deepcopy-gen=true
type NodeEndpoint struct {
URL string `yaml:"url,omitempty" json:"url,omitempty"`
TLSCACerts `yaml:"tlsCACerts,omitempty" json:"tlsCACerts,omitempty"`
}
// +k8s:deepcopy-gen=true
type TLSCACerts struct {
Path string `yaml:"path,omitempty" json:"path,omitempty"`
Pem string `yaml:"pem,omitempty" json:"pem,omitempty"`
}
// FabProfile channal
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"`
}