Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is `<<` and `&` in yaml mean?

Tags:

When I review the cryptogen(a fabric command) config file . I saw there symbol.

Profiles:      SampleInsecureSolo:         Orderer:             <<: *OrdererDefaults  ## what is the `<<`             Organizations:                 - *ExampleCom     ## what is the `*`         Consortiums:             SampleConsortium:                 Organizations:                     - *Org1ExampleCom                     - *Org2ExampleCom 

Above there a two symbol << and *.

Application: &ApplicationDefaults  # what is the `&` mean      Organizations: 

As you can see there is another symbol &. I don't know what are there mean. I didn't get any information even by reviewing the source code (fabric/common/configtx/tool/configtxgen/main.go)

like image 626
blackdog Avatar asked Oct 09 '17 07:10

blackdog


People also ask

Is and and or a conjunction?

Coordinating conjunctions allow you to join words, phrases, and clauses of equal grammatical rank in a sentence. The most common coordinating conjunctions are for, and, nor, but, or, yet, and so; you can remember them by using the mnemonic device FANBOYS. I'd like pizza or a salad for lunch.

What is the and in grammar?

And is a coordinating conjunction. We use and to connect two words, phrases, clauses or prefixes together: Televisions and computers are dominating our daily life. ( noun + noun)

What type of word is &?

As detailed above, 'and' is a conjunction. Conjunction usage: Boys and girls come out to play.

What are and in English?

\ ˈand \ Definition of AND (Entry 2 of 2) : a logical operator that requires both of two inputs to be present or two conditions to be met for an output to be made or a statement to be executed.


1 Answers

Well, those are elements of the YAML file format, which is used here to provide a configuration file for configtxgen. The "&" sign mean anchor and "*" reference to the anchor, this is basically used to avoid duplication, for example:

person: &person     name: "John Doe"  employee: &employee     << : *person     salary : 5000 

will reuse fields of person and has similar meaning as:

employee: &employee     name   : "John Doe"     salary : 5000 

another example is simply reusing value:

key1: &key some very common value  key2: *key 

equivalent to:

key1: some very common value  key2: some very common value 

Since abric/common/configtx/tool/configtxgen/main.go uses of the shelf YAML parser you won't find any reference to these symbols in configtxgen related code. I would suggest to read a bit more about YAML file format.

like image 130
Artem Barger Avatar answered Oct 10 '22 21:10

Artem Barger