package addons

import (
	"fmt"

	"zlh-agent/internal/state"
	"zlh-agent/internal/provision/addons/codeserver"
)

/*
   Provision installs requested addons.

   IMPORTANT:
   - Addons are role-agnostic (dev/game/etc)
   - This function ONLY installs
   - Verification happens later (ensureProvisioned)
*/
func Provision(cfg state.Config) error {

	for _, addon := range cfg.Addons {

		switch addon {

		case "codeserver":
			if err := codeserver.Install(cfg); err != nil {
				return err
			}

		default:
			return fmt.Errorf("unsupported addon: %s", addon)
		}
	}

	return nil
}
