// validates the resources specified in the template config.
validates the resources specified in the template config.
// validates the resources specified in the template config .
func validateResources(c parser.TemplateConfig) {
	resources := command.Resources
	clogger.SetPrefix("validate-config | ")
	if len(c.RawResources) == 0 {
		clogger.Fatal("NoResourceFound: 'resources' list is empty")
	}
	for index, rawResource := range c.RawResources {
		if validator.IsZero(rawResource) {
			clogger.Fatalf("Empty resource found in list 'resources' at index: [%v]", index+1)
		}
		cs := validator.CustomStruct{Struct: rawResource}
		if errs := validator.CheckRequiredFieldsInStruct(cs); len(errs) != 0 {
			if validator.IsZero(rawResource.Name) {
				clogger.Errorf("Missing/Empty key(s) in the resource number: [%v]", index+1)
			} else {
				clogger.Errorf("Missing/Empty key(s) in the resource: [%v]", rawResource.Name)
			}
			clogger.Fatal(errs)
		}
		resource, ok := resources[rawResource.Type]
		if !ok {
			clogger.Fatalf("Invalid resource type [%s] found in Resource: [%s]", rawResource.Type, rawResource.Name)
		}
		if err := resource.Validate(rawResource); err != nil {
			clogger.Fatal(err)
		}
	}
	clogger.Success("Template config is valid.")
}
func validateResources ( c parser . TemplateConfig ) { resources := command . Resources clogger . SetPrefix ( " " ) if len ( c . RawResources ) == 0 { clogger . Fatal ( " " ) } for index , rawResource := range c . RawResources { if validator . IsZero ( rawResource ) { clogger . Fatalf ( " " , index + 1 ) } cs := validator . CustomStruct { Struct : rawResource } if errs := validator . CheckRequiredFieldsInStruct ( cs ) ; len ( errs ) != 0 { if validator . IsZero ( rawResource . Name ) { clogger . Errorf ( " " , index + 1 ) } else { clogger . Errorf ( " " , rawResource . Name ) } clogger . Fatal ( errs ) } resource , ok := resources [ rawResource . Type ] if ! ok { clogger . Fatalf ( " " , rawResource . Type , rawResource . Name ) } if err := resource . Validate ( rawResource ) ; err != nil { clogger . Fatal ( err ) } } clogger . Success ( " " ) }
validates the resources specified in the template config.
validates the resources specified in the template config .
// check if the resource list is empty // check if the resource name is empty // check if the given resource is valid resource type