@@ -88,7 +88,7 @@ type ExternalBuilder struct {
88
88
PropagateEnvironment []string `json:"propagateEnvironment"`
89
89
}
90
90
91
- const DefaultImagePullPolicy = corev1 .PullAlways
91
+ const DefaultImagePullPolicy = corev1 .PullIfNotPresent
92
92
93
93
type ServiceMonitor struct {
94
94
// +kubebuilder:default:=false
@@ -1581,15 +1581,36 @@ type FabricOperatorAPISpec struct {
1581
1581
Resources * corev1.ResourceRequirements `json:"resources"`
1582
1582
}
1583
1583
1584
+ type FabricNetworkConfigOrgPeer struct {
1585
+ Name string `json:"name"`
1586
+ Namespace string `json:"namespace"`
1587
+ }
1588
+ type FabricNetworkConfigOrganization struct {
1589
+ Peers []FabricNetworkConfigOrgPeer `json:"peers"`
1590
+ }
1591
+ type FabricNetworkConfigCA struct {
1592
+ Name string `json:"name"`
1593
+ Namespace string `json:"namespace"`
1594
+ }
1595
+
1584
1596
// FabricNetworkConfigSpec defines the desired state of FabricNetworkConfig
1585
1597
type FabricNetworkConfigSpec struct {
1586
1598
Organization string `json:"organization"`
1587
1599
1588
1600
Internal bool `json:"internal"`
1589
1601
1590
1602
Organizations []string `json:"organizations"`
1591
-
1592
- Namespaces []string `json:"namespaces"`
1603
+ // +kubebuilder:validation:Default={}
1604
+ // +optional
1605
+ // +kubebuilder:validation:Optional
1606
+ // +nullable
1607
+ OrganizationConfig map [string ]FabricNetworkConfigOrganization `json:"organizationConfig"`
1608
+ Namespaces []string `json:"namespaces"`
1609
+ // +nullable
1610
+ // +kubebuilder:validation:Optional
1611
+ // +optional
1612
+ // +kubebuilder:validation:Default={}
1613
+ CertificateAuthorities []FabricNetworkConfigCA `json:"certificateAuthorities"`
1593
1614
1594
1615
Channels []string `json:"channels"`
1595
1616
// HLF Identities to be included in the network config
@@ -1662,8 +1683,18 @@ type FabricNetworkConfigList struct {
1662
1683
Items []FabricNetworkConfig `json:"items"`
1663
1684
}
1664
1685
1686
+ type FabricChaincodeTemplateRef struct {
1687
+ Name string `json:"name"`
1688
+ Namespace string `json:"namespace"`
1689
+ }
1690
+
1665
1691
// FabricChaincodeSpec defines the desired state of FabricChaincode
1666
1692
type FabricChaincodeSpec struct {
1693
+ // +nullable
1694
+ // +optional
1695
+ // +kubebuilder:validation:Optional
1696
+ Template * FabricChaincodeTemplateRef `json:"template"`
1697
+
1667
1698
// +nullable
1668
1699
// +optional
1669
1700
// +kubebuilder:validation:Optional
@@ -1746,6 +1777,56 @@ type FabricChaincodeSpec struct {
1746
1777
MspID string `json:"mspID"`
1747
1778
}
1748
1779
1780
+ func (in * FabricChaincodeSpec ) ApplyDefaultValuesFromTemplate (template * FabricChaincodeTemplate ) {
1781
+ if in .ImagePullPolicy == "" {
1782
+ in .ImagePullPolicy = template .Spec .ImagePullPolicy
1783
+ }
1784
+ if in .ImagePullSecrets == nil || len (in .ImagePullSecrets ) == 0 {
1785
+ in .ImagePullSecrets = template .Spec .ImagePullSecrets
1786
+ }
1787
+ if in .Command == nil || len (in .Command ) == 0 {
1788
+ in .Command = template .Spec .Command
1789
+ }
1790
+ if in .Args == nil || len (in .Args ) == 0 {
1791
+ in .Args = template .Spec .Args
1792
+ }
1793
+ if in .Affinity == nil {
1794
+ in .Affinity = template .Spec .Affinity
1795
+ }
1796
+ if in .Tolerations == nil || len (in .Tolerations ) == 0 {
1797
+ in .Tolerations = template .Spec .Tolerations
1798
+ }
1799
+ if in .Resources == nil {
1800
+ in .Resources = template .Spec .Resources
1801
+ }
1802
+ if in .Replicas == 0 {
1803
+ in .Replicas = template .Spec .Replicas
1804
+ }
1805
+ if in .Env == nil || len (in .Env ) == 0 {
1806
+ in .Env = template .Spec .Env
1807
+ } else {
1808
+ for _ , env := range template .Spec .Env {
1809
+ found := false
1810
+ for _ , e := range in .Env {
1811
+ if e .Name == env .Name {
1812
+ found = true
1813
+ break
1814
+ }
1815
+ }
1816
+ if ! found {
1817
+ in .Env = append (in .Env , env )
1818
+ }
1819
+
1820
+ }
1821
+ }
1822
+ if in .ChaincodeServerPort == 0 {
1823
+ in .ChaincodeServerPort = template .Spec .ChaincodeServerPort
1824
+ }
1825
+ if in .MspID == "" {
1826
+ in .MspID = template .Spec .MspID
1827
+ }
1828
+ }
1829
+
1749
1830
// FabricChaincodeStatus defines the observed state of FabricChaincode
1750
1831
type FabricChaincodeStatus struct {
1751
1832
Conditions status.Conditions `json:"conditions"`
@@ -2229,8 +2310,119 @@ type FabricFollowerChannelOrderer struct {
2229
2310
Certificate string `json:"certificate"`
2230
2311
}
2231
2312
2313
+ // FabricChaincodeTemplateStatus defines the observed state of FabricChaincodeTemplate
2314
+ type FabricChaincodeTemplateStatus struct {
2315
+ Conditions status.Conditions `json:"conditions"`
2316
+ Message string `json:"message"`
2317
+ // Status of the FabricCA
2318
+ Status DeploymentStatus `json:"status"`
2319
+ }
2320
+
2321
+ // +genclient
2322
+ // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
2323
+ // +k8s:defaulter-gen=true
2324
+ // +kubebuilder:subresource:status
2325
+ // +kubebuilder:resource:scope=Namespaced,shortName=fabricchaincodetemplate,singular=fabricchaincodetemplate
2326
+ // +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.status"
2327
+ // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
2328
+
2329
+ // FabricChaincodeTemplate is the Schema for the hlfs API
2330
+ type FabricChaincodeTemplate struct {
2331
+ metav1.TypeMeta `json:",inline"`
2332
+ metav1.ObjectMeta `json:"metadata,omitempty"`
2333
+ Spec FabricChaincodeTemplateSpec `json:"spec,omitempty"`
2334
+ Status FabricChaincodeTemplateStatus `json:"status,omitempty"`
2335
+ }
2336
+
2337
+ // +kubebuilder:object:root=true
2338
+
2339
+ // FabricChaincodeTemplateList contains a list of FabricChaincodeTemplate
2340
+ type FabricChaincodeTemplateList struct {
2341
+ metav1.TypeMeta `json:",inline"`
2342
+ metav1.ListMeta `json:"metadata,omitempty"`
2343
+ Items []FabricChaincodeTemplate `json:"items"`
2344
+ }
2345
+
2346
+ // FabricChaincodeTemplateSpec defines the desired state of FabricChaincodeTemplate
2347
+ type FabricChaincodeTemplateSpec struct {
2348
+ // +nullable
2349
+ // +optional
2350
+ // +kubebuilder:validation:Optional
2351
+ // +kubebuilder:default:={}
2352
+ Annotations map [string ]string `json:"annotations"`
2353
+ // +nullable
2354
+ // +optional
2355
+ // +kubebuilder:validation:Optional
2356
+ // +kubebuilder:default:={}
2357
+ Labels map [string ]string `json:"labels"`
2358
+
2359
+ // +nullable
2360
+ // +optional
2361
+ // +kubebuilder:validation:Optional
2362
+ // +kubebuilder:default:={}
2363
+ PodAnnotations map [string ]string `json:"podAnnotations"`
2364
+
2365
+ // +nullable
2366
+ // +optional
2367
+ // +kubebuilder:validation:Optional
2368
+ // +kubebuilder:default:={}
2369
+ PodLabels map [string ]string `json:"podLabels"`
2370
+
2371
+ // +kubebuilder:default:="IfNotPresent"
2372
+ ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy"`
2373
+
2374
+ // +kubebuilder:validation:Default={}
2375
+ // +optional
2376
+ // +kubebuilder:validation:Optional
2377
+ // +nullable
2378
+ ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets"`
2379
+
2380
+ // Entrypoint array. Not executed within a shell.
2381
+ // The container image's ENTRYPOINT is used if this is not provided.
2382
+ // +optional
2383
+ Command []string `json:"command,omitempty" protobuf:"bytes,3,rep,name=command"`
2384
+
2385
+ // Arguments to the entrypoint.
2386
+ // The container image's CMD is used if this is not provided.
2387
+ // +optional
2388
+ Args []string `json:"args,omitempty" protobuf:"bytes,4,rep,name=args"`
2389
+
2390
+ // +nullable
2391
+ // +kubebuilder:validation:Optional
2392
+ // +optional
2393
+ Affinity * corev1.Affinity `json:"affinity"`
2394
+
2395
+ // +nullable
2396
+ // +kubebuilder:validation:Optional
2397
+ // +optional
2398
+ // +kubebuilder:validation:Default={}
2399
+ Tolerations []corev1.Toleration `json:"tolerations"`
2400
+
2401
+ // +nullable
2402
+ // +kubebuilder:validation:Optional
2403
+ // +optional
2404
+ Resources * corev1.ResourceRequirements `json:"resources"`
2405
+
2406
+ // +kubebuilder:validation:Default=1
2407
+ Replicas int `json:"replicas"`
2408
+
2409
+ // +nullable
2410
+ // +kubebuilder:validation:Optional
2411
+ // +optional
2412
+ // +kubebuilder:validation:Default={}
2413
+ Env []corev1.EnvVar `json:"env"`
2414
+
2415
+ // +kubebuilder:default=7052
2416
+ ChaincodeServerPort int `json:"chaincodeServerPort"`
2417
+
2418
+ // +optional
2419
+ // +kubebuilder:validation:Optional
2420
+ MspID string `json:"mspID"`
2421
+ }
2422
+
2232
2423
func init () {
2233
2424
SchemeBuilder .Register (& FabricPeer {}, & FabricPeerList {})
2425
+ SchemeBuilder .Register (& FabricChaincodeTemplate {}, & FabricChaincodeTemplateList {})
2234
2426
SchemeBuilder .Register (& FabricOrderingService {}, & FabricOrderingServiceList {})
2235
2427
SchemeBuilder .Register (& FabricCA {}, & FabricCAList {})
2236
2428
SchemeBuilder .Register (& FabricOrdererNode {}, & FabricOrdererNodeList {})
0 commit comments