| 
									
										
										
										
											2022-09-14 22:15:09 +08:00
										 |  |  | package codegen | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"embed" | 
					
						
							| 
									
										
										
										
											2023-04-28 04:32:38 +08:00
										 |  |  | 	"strings" | 
					
						
							| 
									
										
										
										
											2022-09-14 22:15:09 +08:00
										 |  |  | 	"text/template" | 
					
						
							|  |  |  | 	"time" | 
					
						
							| 
									
										
										
										
											2022-11-22 22:00:29 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/grafana/codejen" | 
					
						
							| 
									
										
										
										
											2022-09-14 22:15:09 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // All the parsed templates in the tmpl subdirectory
 | 
					
						
							|  |  |  | var tmpls *template.Template | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func init() { | 
					
						
							|  |  |  | 	base := template.New("codegen").Funcs(template.FuncMap{ | 
					
						
							| 
									
										
										
										
											2023-04-28 04:32:38 +08:00
										 |  |  | 		"now":     time.Now, | 
					
						
							|  |  |  | 		"ToLower": strings.ToLower, | 
					
						
							| 
									
										
										
										
											2022-09-14 22:15:09 +08:00
										 |  |  | 	}) | 
					
						
							|  |  |  | 	tmpls = template.Must(base.ParseFS(tmplFS, "tmpl/*.tmpl")) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //go:embed tmpl/*.tmpl
 | 
					
						
							|  |  |  | var tmplFS embed.FS | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // The following group of types, beginning with tvars_*, all contain the set
 | 
					
						
							|  |  |  | // of variables expected by the corresponding named template file under tmpl/
 | 
					
						
							|  |  |  | type ( | 
					
						
							| 
									
										
										
										
											2022-11-22 22:00:29 +08:00
										 |  |  | 	tvars_gen_header struct { | 
					
						
							|  |  |  | 		MainGenerator string | 
					
						
							|  |  |  | 		Using         []codejen.NamedJenny | 
					
						
							|  |  |  | 		From          string | 
					
						
							| 
									
										
										
										
											2023-02-02 01:08:26 +08:00
										 |  |  | 		Leader        string | 
					
						
							| 
									
										
										
										
											2022-11-22 22:00:29 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2024-03-14 00:05:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-28 04:32:38 +08:00
										 |  |  | 	tvars_resource struct { | 
					
						
							| 
									
										
										
										
											2024-02-26 17:18:19 +08:00
										 |  |  | 		PackageName string | 
					
						
							|  |  |  | 		KindName    string | 
					
						
							|  |  |  | 		Version     string | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tvars_metadata struct { | 
					
						
							|  |  |  | 		PackageName string | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tvars_status struct { | 
					
						
							|  |  |  | 		PackageName string | 
					
						
							| 
									
										
										
										
											2023-04-28 04:32:38 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2024-03-14 00:05:21 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	tvars_registry struct { | 
					
						
							|  |  |  | 		Schemas []Schema | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Schema struct { | 
					
						
							|  |  |  | 		Name     string | 
					
						
							|  |  |  | 		FilePath string | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-09-14 22:15:09 +08:00
										 |  |  | ) |