---
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: hyperledger/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",
          "x-commitTimeout": 300,
          "version": "1.0.0",
          "client": {
              "organization": "Org1",
              "connection": {
                  "timeout": {
                      "peer": {
                          "endorser": "300",
                          "eventHub": "300",
                          "eventReg": "300"
                      },
                      "orderer": "300"
                  }
              }
          },
          "channels": {
              "channel1": {
                  "orderers": [
                      "orderer.example.com"
                  ],
                  "peers": {
                      "blockchain-org1peer1": {
                          "endorsingPeer": true,
                          "chaincodeQuery": true,
                          "ledgerQuery": true,
                          "eventSource": true
                      }
                  }
              }
          },
          "organizations": {
              "Org1": {
                  "mspid": "Org1MSP",
                  "peers": [
                      "blockchain-org1peer1"
                  ],
                  "certificateAuthorities": [
                      "blockchain-ca"
                  ]
              }
          },
          "orderers": {
              "orderer.example.com": {
                  "url": "grpc://blockchain-orderer:31010"
              }
          },
          "peers": {
              "blockchain-org1peer1": {
                  "url": "grpc://blockchain-org1peer1:30110",
                  "eventUrl": "grpc://blockchain-org1peer1:30111"
              }
          },
          "certificateAuthorities": {
              "blockchain-ca": {
                  "url": "http://blockchain-ca:30054",
                  "caName": "CA1"
              }
          }
        }
    volumeMounts:
    - name: composer-card-store
      mountPath: /home/composer/.composer
    - name: shared
      mountPath: /shared

