// executeResources applies the given resources in given configuration.
executeResources applies the given resources in given configuration.
// executeResources applies the given resources in given configuration .
func executeResources(dsc string) {
	c, err := parseConfig(dsc)
	if err != nil {
		clogger.Fatal("Unable to parse configuration file: \n", err)
	}
	resources := command.Resources
	inventory := make([]byte, 0)
	header := []byte("---\n")
	inventory = append(inventory, header...)
	for _, rawResource := range c.RawResources {
		resource, ok := resources[rawResource.Type]
		if !ok {
			clogger.Fatalf("InvalidResourceType: Resource Type '%s' Not Found", rawResource.Type)
		}
		clogger.SetPrefix(rawResource.Type + " | ")
		clogger.Successf("Resource : %s  Status: Started", rawResource.Name)
		clogger.Info("")
		if err := resource.Prepare(rawResource.Config); err != nil {
			clogger.Error(err)
			clogger.Fatalf("Resource : %s  Status: Failed", rawResource.Name)
		}
		if err := resource.Run(); err != nil {
			clogger.Error(err)
			clogger.Fatalf("Resource : %s  Status: Failed", rawResource.Name)
		}
		bs, err := resource.GenerateInventory()
		if err != nil {
			clogger.Fatal(err)
		}
		inventory = append(inventory, bs...)
		clogger.Info("")
		clogger.Successf("Resource : %s  Status: Succeeded", rawResource.Name)
		fmt.Println("")
	}
	file, err := os.Create(inventoryPath)
	if err != nil {
		clogger.Fatal(err)
	}
	_, err = file.Write(inventory)
	if err != nil {
		clogger.Fatal(err)
	}
}
func executeResources ( dsc string ) { c , err := parseConfig ( dsc ) if err != nil { clogger . Fatal ( " \n " , err ) } resources := command . Resources inventory := make ( [ ] byte , 0 ) header := [ ] byte ( " \n " ) inventory = append ( inventory , header ... ) for _ , rawResource := range c . RawResources { resource , ok := resources [ rawResource . Type ] if ! ok { clogger . Fatalf ( " " , rawResource . Type ) } clogger . SetPrefix ( rawResource . Type + " " ) clogger . Successf ( " " , rawResource . Name ) clogger . Info ( " " ) if err := resource . Prepare ( rawResource . Config ) ; err != nil { clogger . Error ( err ) clogger . Fatalf ( " " , rawResource . Name ) } if err := resource . Run ( ) ; err != nil { clogger . Error ( err ) clogger . Fatalf ( " " , rawResource . Name ) } bs , err := resource . GenerateInventory ( ) if err != nil { clogger . Fatal ( err ) } inventory = append ( inventory , bs ... ) clogger . Info ( " " ) clogger . Successf ( " " , rawResource . Name ) fmt . Println ( " " ) } file , err := os . Create ( inventoryPath ) if err != nil { clogger . Fatal ( err ) } _ , err = file . Write ( inventory ) if err != nil { clogger . Fatal ( err ) } }
executeResources applies the given resources in given configuration.
executeResources applies the given resources in given configuration .
// apply resources defined in template one by one // Generate inventory report