github.com/mineiros-io/terradoc@v0.0.9-0.20220711062319-018bd4ae81f5/internal/schemas/docschema/docschema.go (about)

     1  package docschema
     2  
     3  import "github.com/hashicorp/hcl/v2"
     4  
     5  func RootSchema() *hcl.BodySchema {
     6  	return &hcl.BodySchema{
     7  		Blocks: []hcl.BlockHeaderSchema{
     8  			{
     9  				Type:       "header",
    10  				LabelNames: []string{},
    11  			},
    12  			{
    13  				Type:       "section",
    14  				LabelNames: []string{},
    15  			},
    16  			{
    17  				Type:       "references",
    18  				LabelNames: []string{},
    19  			},
    20  		},
    21  	}
    22  }
    23  
    24  func HeaderSchema() *hcl.BodySchema {
    25  	return &hcl.BodySchema{
    26  		Attributes: []hcl.AttributeSchema{
    27  			{
    28  				Name:     "image",
    29  				Required: false,
    30  			},
    31  			{
    32  				Name:     "url",
    33  				Required: false,
    34  			},
    35  		},
    36  		Blocks: []hcl.BlockHeaderSchema{
    37  			{
    38  				Type:       "badge",
    39  				LabelNames: []string{"name"},
    40  			},
    41  		},
    42  	}
    43  }
    44  
    45  func BadgeSchema() *hcl.BodySchema {
    46  	return &hcl.BodySchema{
    47  		Attributes: []hcl.AttributeSchema{
    48  			{
    49  				Name:     "image",
    50  				Required: true,
    51  			},
    52  			{
    53  				Name:     "url",
    54  				Required: true,
    55  			},
    56  			{
    57  				Name:     "text",
    58  				Required: true,
    59  			},
    60  		},
    61  	}
    62  }
    63  
    64  func ReferencesSchema() *hcl.BodySchema {
    65  	return &hcl.BodySchema{
    66  		Blocks: []hcl.BlockHeaderSchema{
    67  			{
    68  				Type:       "ref",
    69  				LabelNames: []string{"name"},
    70  			},
    71  		},
    72  	}
    73  }
    74  
    75  func RefSchema() *hcl.BodySchema {
    76  	return &hcl.BodySchema{
    77  		Attributes: []hcl.AttributeSchema{
    78  			{
    79  				Name:     "value",
    80  				Required: true,
    81  			},
    82  		},
    83  	}
    84  }
    85  
    86  func SectionSchema() *hcl.BodySchema {
    87  	return &hcl.BodySchema{
    88  		Attributes: []hcl.AttributeSchema{
    89  			{
    90  				Name:     "title",
    91  				Required: false,
    92  			},
    93  			{
    94  				Name:     "content",
    95  				Required: false,
    96  			},
    97  			{
    98  				Name:     "toc",
    99  				Required: false,
   100  			},
   101  		},
   102  		Blocks: []hcl.BlockHeaderSchema{
   103  			{
   104  				Type:       "section",
   105  				LabelNames: []string{},
   106  			},
   107  			{
   108  				Type:       "variable",
   109  				LabelNames: []string{"name"},
   110  			},
   111  			{
   112  				Type:       "output",
   113  				LabelNames: []string{"name"},
   114  			},
   115  		},
   116  	}
   117  }
   118  
   119  func VariableSchema() *hcl.BodySchema {
   120  	return &hcl.BodySchema{
   121  		Attributes: []hcl.AttributeSchema{
   122  			{
   123  				Name:     "type",
   124  				Required: true,
   125  			},
   126  			{
   127  				Name:     "description",
   128  				Required: false,
   129  			},
   130  			{
   131  				Name:     "default",
   132  				Required: false,
   133  			},
   134  			{
   135  				Name:     "required",
   136  				Required: false,
   137  			},
   138  			{
   139  				Name:     "forces_recreation",
   140  				Required: false,
   141  			},
   142  			{
   143  				Name:     "readme_example",
   144  				Required: false,
   145  			},
   146  			{
   147  				Name:     "readme_type",
   148  				Required: false,
   149  			},
   150  		},
   151  		Blocks: []hcl.BlockHeaderSchema{
   152  			{
   153  				Type:       "attribute",
   154  				LabelNames: []string{"name"},
   155  			},
   156  		},
   157  	}
   158  }
   159  
   160  func OutputSchema() *hcl.BodySchema {
   161  	return &hcl.BodySchema{
   162  		Attributes: []hcl.AttributeSchema{
   163  			{
   164  				Name:     "type",
   165  				Required: true,
   166  			},
   167  			{
   168  				Name:     "description",
   169  				Required: false,
   170  			},
   171  		},
   172  	}
   173  }
   174  
   175  func AttributeSchema() *hcl.BodySchema {
   176  	return &hcl.BodySchema{
   177  		Attributes: []hcl.AttributeSchema{
   178  			{
   179  				Name:     "type",
   180  				Required: true,
   181  			},
   182  			{
   183  				Name:     "description",
   184  				Required: false,
   185  			},
   186  			{
   187  				Name:     "required",
   188  				Required: false,
   189  			},
   190  			{
   191  				Name:     "forces_recreation",
   192  				Required: false,
   193  			},
   194  			{
   195  				Name:     "default",
   196  				Required: false,
   197  			},
   198  			{
   199  				Name:     "readme_example",
   200  				Required: false,
   201  			},
   202  			{
   203  				Name:     "readme_type",
   204  				Required: false,
   205  			},
   206  		},
   207  		Blocks: []hcl.BlockHeaderSchema{
   208  			{
   209  				Type:       "attribute",
   210  				LabelNames: []string{"name"},
   211  			},
   212  		},
   213  	}
   214  }