2026-05-19 14:40:54 +05:30
|
|
|
package sandbox
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/safedep/pmg/config"
|
|
|
|
|
pmgsandbox "github.com/safedep/pmg/sandbox"
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// registryFactory builds a ProfileRegistry. Tests inject a stub.
|
|
|
|
|
type registryFactory func() (pmgsandbox.ProfileRegistry, error)
|
|
|
|
|
|
|
|
|
|
func defaultRegistryFactory() (pmgsandbox.ProfileRegistry, error) {
|
2026-07-21 15:14:07 +05:30
|
|
|
// Include user presets so profile inspection agrees with runtime
|
|
|
|
|
// resolution of custom profiles referencing presets.
|
|
|
|
|
presets, err := defaultPresetRegistryFactory()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-19 14:40:54 +05:30
|
|
|
return pmgsandbox.NewProfileRegistry(
|
|
|
|
|
pmgsandbox.WithUserProfileDir(config.Get().SandboxProfileDir()),
|
2026-07-21 15:14:07 +05:30
|
|
|
pmgsandbox.WithPresetRegistry(presets),
|
2026-05-19 14:40:54 +05:30
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewProfileCommand returns the `pmg sandbox profile` parent command.
|
|
|
|
|
func NewProfileCommand() *cobra.Command {
|
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
|
Use: "profile",
|
|
|
|
|
Short: "Inspect sandbox profiles",
|
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
|
return cmd.Help()
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cmd.AddCommand(newProfileListCommand(defaultRegistryFactory))
|
|
|
|
|
cmd.AddCommand(newProfileShowCommand(defaultRegistryFactory))
|
|
|
|
|
cmd.AddCommand(newProfileInitCommand(defaultRegistryFactory))
|
2026-07-18 22:53:39 +05:30
|
|
|
cmd.AddCommand(newProfileEditCommand(defaultRegistryFactory))
|
2026-05-19 14:40:54 +05:30
|
|
|
cmd.AddCommand(newProfileLintCommand(defaultRegistryFactory))
|
|
|
|
|
cmd.AddCommand(newProfileDiffCommand(defaultRegistryFactory))
|
|
|
|
|
return cmd
|
|
|
|
|
}
|