Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

irregular symbols happens when translate docker yaml file #463

Closed
tyhtao1990 opened this issue Feb 1, 2019 · 1 comment
Closed

irregular symbols happens when translate docker yaml file #463

tyhtao1990 opened this issue Feb 1, 2019 · 1 comment

Comments

@tyhtao1990
Copy link

I tried to read a docker file as a template in my program, and replace the detail when new condition happens.but it failed when I use dump function.
My code is like:

let yaml  = require('js-yaml');
let filePath = **/docker-compos-template.yaml';
let savePath = '**/docker-compose-save.yaml';
try{
        let doc = yaml.safeLoad(fs.readFileSync(filePath),'utf8');
        console.log(doc);
        fs.writeFileSync(savePath, yaml.dump(doc), 'utf8');
 }catch(e) {
        console.log(e);
    }

My part of my template file is :

 environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-santai
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=chembean_default
      - FABRIC_CA_SERVER_TLS_ENABLED=true
      - FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.santai.chembean.io-cert.pem

and the translated file is:

    environment:
      - FABRIC_CA_HOME=/etc/hyperledger/fabric-ca-server
      - FABRIC_CA_SERVER_CA_NAME=ca-santai
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=chembean_default
      - FABRIC_CA_SERVER_TLS_ENABLED=true
      - >-
        FABRIC_CA_SERVER_TLS_CERTFILE=/etc/hyperledger/fabric-ca-server-config/ca.santai.chembean.io-cert.pem

the symbol >- is not defined in the template.
and then will be '' in translate files.
e.g my template file is:

environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb-santai:5984
    
      - CORE_PEER_ID=peer0.santai.chembean.io
      - CORE_PEER_NETWORKID=chembean
      - CORE_PEER_ADDRESS=peer0.santai.chembean.io:7051
      - CORE_PEER_GOSSIP_BOOTSTRAP=peer0.santai.chembean.io:7051
      - CORE_PEER_ADDRESSAUTODETECT=true
      - CORE_PEER_CHAINCODEADDRESS=peer0.santai.chembean.io:7052
      - CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052
      - CORE_CHAINCODE_STARTUPTIMEOUT=1200s
      - CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.santai.chembean.io:7051
      - CORE_PEER_LOCALMSPID=SantaiMSP
      - CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
      # the following setting starts chaincode containers on the same
      # bridge network as the peers
      # https://docs.docker.com/compose/networking/
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=chembean_default
      - CORE_LOGGING_LEVEL=INFO
      #- CORE_LOGGING_LEVEL=DEBUG
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_GOSSIP_USELEADERELECTION=true
      - CORE_PEER_GOSSIP_ORGLEADER=false
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt

but the translate file is:

    environment:
      - CORE_LEDGER_STATE_STATEDATABASE=CouchDB
      - 'CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb-santai:5984'
      - CORE_PEER_ID=peer0.santai.chembean.io
      - CORE_PEER_NETWORKID=chembean
      - 'CORE_PEER_ADDRESS=peer0.santai.chembean.io:7051'
      - 'CORE_PEER_GOSSIP_BOOTSTRAP=peer0.santai.chembean.io:7051'
      - CORE_PEER_ADDRESSAUTODETECT=true
      - 'CORE_PEER_CHAINCODEADDRESS=peer0.santai.chembean.io:7052'
      - 'CORE_PEER_CHAINCODELISTENADDRESS=0.0.0.0:7052'
      - CORE_CHAINCODE_STARTUPTIMEOUT=1200s
      - 'CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.santai.chembean.io:7051'
      - CORE_PEER_LOCALMSPID=SantaiMSP
      - 'CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock'
      - CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=chembean_default
      - CORE_LOGGING_LEVEL=INFO
      - CORE_PEER_TLS_ENABLED=true
      - CORE_PEER_GOSSIP_USELEADERELECTION=true
      - CORE_PEER_GOSSIP_ORGLEADER=false
      - CORE_PEER_PROFILE_ENABLED=true
      - CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/fabric/tls/server.crt
      - CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/fabric/tls/server.key
      - CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/fabric/tls/ca.crt

it seems that the symbol '' appears randomly.
Is there any good idea to help me solve these problems?

@puzrin
Copy link
Member

puzrin commented Feb 1, 2019

Quoting appears only when required. Result is correct and have no mistales.

There was attempt #454 to add option to force quatin, but implementation was far from perfect to accept.

@puzrin puzrin closed this as completed Feb 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants