---
apiVersion: v1
kind: Pod
metadata:
  name: composer-card-import
spec:
  restartPolicy: "Never"
  volumes:
  - name: composer-card-store
    persistentVolumeClaim:
      claimName: composer-pvc
  - name: shared
    persistentVolumeClaim:
      claimName: shared-pvc
  containers:
  - name: composer-card-import
    image: ibmblockchain/composer-cli:0.19.5
    imagePullPolicy: Always
    command: ["sh", "-c", "echo $K8S_PROFILE > connection.json && composer card create -f PeerAdmin.card -p connection.json -u PeerAdmin -r PeerAdmin -r ChannelAdmin -c /shared/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem -k /shared/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/key.pem && composer card import -f PeerAdmin.card"]
    env:
    - name: K8S_PROFILE
      value: >
        {
          "name": "hlfv1",
          "x-type": "hlfv1",
          "version": "1.0.0",
          "peers": {
            "peer0.org1.example.com": {
                "url": "grpc://localhost:7051",
                "eventUrl": "grpc://localhost:7053"
              }
            },
            "ca.org1.example.com": {
              "url": "http://localhost:7054",
              "certificateAuthorities": {
              "caName": "ca.org1.example.com"
            }
          },
          "orderers": {
            "orderer.example.com": {
              "url": "grpc://localhost:7050"
            }
          },
          "organizations": {
            "Org1": {
              "mspid": "Org1MSP",
              "peers": [
                "peer0.org1.example.com"
              ],
              "certificateAuthorities": [
                "ca.org1.example.com"
              ]
            }
          },
          "channels": {
            "composerchannel": {
              "orderers": [
                "orderer.example.com"
              ],
              "peers": {
                "peer0.org1.example.com": {
                  "endorsingPeer": true,
                  "chaincodeQuery": true,
                  "eventSource": true
                }
              }
            }
          },
          "client": {
            "organization": "Org1",
            "connection": {
              "timeout": {
                "peer": {
                  "endorser": "300",
                  "eventHub": "300",
                  "eventReg": "300"
                },
                "orderer": "300"
              }
            }
          }
        }
    volumeMounts:
    - name: composer-card-store
      mountPath: /home/composer/.composer
    - name: shared
      mountPath: /shared
