github.com/docker/libcompose@v0.4.1-0.20210616120443-2a046c0bdbf2/hack/inline_schema.go (about)

     1  package main
     2  
     3  import (
     4  	"io/ioutil"
     5  	"os"
     6  	"text/template"
     7  )
     8  
     9  func main() {
    10  	t, err := template.New("schema_template.go").ParseFiles("./hack/schema_template.go")
    11  	if err != nil {
    12  		panic(err)
    13  	}
    14  
    15  	schemaV1, err := ioutil.ReadFile("./hack/config_schema_v1.json")
    16  	if err != nil {
    17  		panic(err)
    18  	}
    19  	schemaV2, err := ioutil.ReadFile("./hack/config_schema_v2.0.json")
    20  	if err != nil {
    21  		panic(err)
    22  	}
    23  
    24  	inlinedFile, err := os.Create("config/schema.go")
    25  	if err != nil {
    26  		panic(err)
    27  	}
    28  
    29  	err = t.Execute(inlinedFile, map[string]string{
    30  		"schemaV1": string(schemaV1),
    31  		"schemaV2": string(schemaV2),
    32  	})
    33  
    34  	if err != nil {
    35  		panic(err)
    36  	}
    37  }