Run executes the full skills-init sequence: docker config merge → git auth setup → git clones → OCI pulls. It returns the first error encountered; successful operations before the failure are left in place on disk (the container restarts and re-runs from scratch). homeDir is the binary's $HOME — ex
(cfg Config, homeDir string)
| 16 | // homeDir is the binary's $HOME — exposed for tests. In production callers |
| 17 | // should pass os.UserHomeDir() or "/root". |
| 18 | func Run(cfg Config, homeDir string) error { |
| 19 | if len(cfg.ImagePullSecrets) > 0 { |
| 20 | dockerCfgPath := filepath.Join(os.TempDir(), "kagent-docker-config", "config.json") |
| 21 | dockerCfgDir, err := MergeDockerConfigs(DockerSecretsDir, cfg.ImagePullSecrets, dockerCfgPath) |
| 22 | if err != nil { |
| 23 | return fmt.Errorf("merge docker configs: %w", err) |
| 24 | } |
| 25 | if err := os.Setenv("DOCKER_CONFIG", dockerCfgDir); err != nil { |
| 26 | return err |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | if err := SetupGitAuth(homeDir, cfg.AuthMountPath, cfg.SSHHosts); err != nil { |
| 31 | return fmt.Errorf("setup git auth: %w", err) |
| 32 | } |
| 33 | |
| 34 | for _, ref := range cfg.GitRefs { |
| 35 | log.Printf("cloning %s (ref=%s) into %s", ref.URL, ref.Ref, ref.Dest) |
| 36 | if err := CloneGit(ref); err != nil { |
| 37 | return fmt.Errorf("clone %s: %w", ref.URL, err) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | for _, ref := range cfg.OCIRefs { |
| 42 | log.Printf("exporting OCI image %s into %s", ref.Image, ref.Dest) |
| 43 | if err := FetchOCI(ref, cfg.InsecureOCI); err != nil { |
| 44 | return fmt.Errorf("oci %s: %w", ref.Image, err) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | return nil |
| 49 | } |
| 50 | |
| 51 | // LoadConfig reads and parses the config JSON from the conventional mount. |
| 52 | func LoadConfig() (Config, error) { |
nothing calls this directly
no test coverage detected