github.com/IBM-Blockchain/fabric-operator@v1.0.4/pkg/initializer/ca/sw.go (about) 1 /* 2 * Copyright contributors to the Hyperledger Fabric Operator project 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at: 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 package initializer 20 21 import ( 22 current "github.com/IBM-Blockchain/fabric-operator/api/v1beta1" 23 v1 "github.com/IBM-Blockchain/fabric-operator/pkg/apis/ca/v1" 24 "github.com/IBM-Blockchain/fabric-operator/pkg/util" 25 ) 26 27 type SW struct{} 28 29 func (sw *SW) Create(instance *current.IBPCA, overrides *v1.ServerConfig, ca IBPCA) (*Response, error) { 30 var err error 31 32 err = ca.RemoveHomeDir() 33 if err != nil { 34 return nil, err 35 } 36 37 err = ca.OverrideServerConfig(overrides) 38 if err != nil { 39 return nil, err 40 } 41 42 crypto, err := ca.ParseCrypto() 43 if err != nil { 44 return nil, err 45 } 46 47 err = ca.WriteConfig() 48 if err != nil { 49 return nil, err 50 } 51 52 err = ca.Init() 53 if err != nil { 54 return nil, err 55 } 56 57 caBlock, err := ca.ParseCABlock() 58 if err != nil { 59 return nil, err 60 } 61 crypto = util.JoinMaps(crypto, caBlock) 62 63 ca.SetMountPaths() 64 65 err = ca.RemoveHomeDir() 66 if err != nil { 67 return nil, err 68 } 69 70 return &Response{ 71 Config: ca.GetServerConfig(), 72 CryptoMap: crypto, 73 }, nil 74 }