diff --git a/compose/project.go b/compose/project.go index 837ec893a..53d3fb0b4 100644 --- a/compose/project.go +++ b/compose/project.go @@ -40,7 +40,7 @@ var DefaultFileNames = []string{ // NewProjectFromComposeFile loads a compose file and returns a project. If no // compose file is specified, it will look for one in the current directory. -func NewProjectFromComposeFile(ctx context.Context, workdir, composefile string) (*Project, error) { +func NewProjectFromComposeFile(ctx context.Context, workdir, composefile string, opts ...cli.ProjectOptionsFn) (*Project, error) { if composefile == "" { for _, file := range DefaultFileNames { fullpath := filepath.Join(workdir, file) @@ -62,6 +62,7 @@ func NewProjectFromComposeFile(ctx context.Context, workdir, composefile string) options, err := cli.NewProjectOptions( []string{fullpath}, + opts..., ) if err != nil { return nil, err diff --git a/internal/cli/kraft/cloud/compose/build/build.go b/internal/cli/kraft/cloud/compose/build/build.go index 3d4cbacf4..be352ca05 100644 --- a/internal/cli/kraft/cloud/compose/build/build.go +++ b/internal/cli/kraft/cloud/compose/build/build.go @@ -14,6 +14,7 @@ import ( "strings" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/spf13/cobra" kraftcloud "sdk.kraft.cloud" @@ -33,8 +34,9 @@ import ( type BuildOptions struct { Auth *config.AuthConfig `noattribute:"true"` - Composefile string `noattribute:"true"` Client kraftcloud.KraftCloud `noattribute:"true"` + Composefile string `noattribute:"true"` + EnvFile string `noattribute:"true"` Metro string `noattribute:"true"` Project *compose.Project `noattribute:"true"` Push bool `long:"push" usage:"Push the built service images"` @@ -102,7 +104,11 @@ func Build(ctx context.Context, opts *BuildOptions, args ...string) error { return err } - opts.Project, err = compose.NewProjectFromComposeFile(ctx, workdir, opts.Composefile) + opts.Project, err = compose.NewProjectFromComposeFile(ctx, + workdir, + opts.Composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/cloud/compose/compose.go b/internal/cli/kraft/cloud/compose/compose.go index 43222dad8..0bbca6907 100644 --- a/internal/cli/kraft/cloud/compose/compose.go +++ b/internal/cli/kraft/cloud/compose/compose.go @@ -28,6 +28,7 @@ import ( type ComposeOptions struct { Composefile string `long:"file" usage:"Set the Compose file."` + EnvFile string `long:"env-file" usage:"Set the environment file."` } func NewCmd() *cobra.Command { diff --git a/internal/cli/kraft/cloud/compose/down/down.go b/internal/cli/kraft/cloud/compose/down/down.go index dc18916b5..4269faedb 100644 --- a/internal/cli/kraft/cloud/compose/down/down.go +++ b/internal/cli/kraft/cloud/compose/down/down.go @@ -13,6 +13,7 @@ import ( "strings" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/spf13/cobra" kraftcloud "sdk.kraft.cloud" @@ -28,6 +29,7 @@ type DownOptions struct { Auth *config.AuthConfig `noattribute:"true"` Client kraftcloud.KraftCloud `noattribute:"true"` Composefile string `noattribute:"true"` + EnvFile string `noattribute:"true"` Metro string `noattribute:"true"` Project *compose.Project `noattribute:"true"` Token string `noattribute:"true"` @@ -88,7 +90,11 @@ func (opts *DownOptions) Run(ctx context.Context, args []string) error { return err } - opts.Project, err = compose.NewProjectFromComposeFile(ctx, workdir, opts.Composefile) + opts.Project, err = compose.NewProjectFromComposeFile(ctx, + workdir, + opts.Composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/cloud/compose/list/list.go b/internal/cli/kraft/cloud/compose/list/list.go index 7dff4e8cd..1fb9d5943 100644 --- a/internal/cli/kraft/cloud/compose/list/list.go +++ b/internal/cli/kraft/cloud/compose/list/list.go @@ -12,6 +12,7 @@ import ( "strings" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/spf13/cobra" "kraftkit.sh/cmdfactory" @@ -23,6 +24,7 @@ import ( type ListOptions struct { Composefile string `noattribute:"true"` + EnvFile string `noattribute:"true"` Output string `long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list,raw" default:"table"` Token string `noattribute:"true"` } @@ -64,7 +66,11 @@ func (opts *ListOptions) Run(ctx context.Context, args []string) error { workdir = args[0] } - project, err := compose.NewProjectFromComposeFile(ctx, workdir, opts.Composefile) + project, err := compose.NewProjectFromComposeFile(ctx, + workdir, + opts.Composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/cloud/compose/logs/logs.go b/internal/cli/kraft/cloud/compose/logs/logs.go index 20b95770f..728771060 100644 --- a/internal/cli/kraft/cloud/compose/logs/logs.go +++ b/internal/cli/kraft/cloud/compose/logs/logs.go @@ -12,6 +12,7 @@ import ( "strings" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/spf13/cobra" kraftcloud "sdk.kraft.cloud" @@ -27,6 +28,7 @@ type LogsOptions struct { Auth *config.AuthConfig `noattribute:"true"` Client kraftcloud.KraftCloud `noattribute:"true"` Composefile string `noattribute:"true"` + EnvFile string `noattribute:"true"` Follow bool `long:"follow" short:"f" usage:"Follow log output"` Metro string `noattribute:"true"` Output string `long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list,raw" default:"table"` @@ -99,7 +101,11 @@ func Logs(ctx context.Context, opts *LogsOptions, args ...string) error { } if opts.Project == nil { - opts.Project, err = compose.NewProjectFromComposeFile(ctx, workdir, opts.Composefile) + opts.Project, err = compose.NewProjectFromComposeFile(ctx, + workdir, + opts.Composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/cloud/compose/ps/ps.go b/internal/cli/kraft/cloud/compose/ps/ps.go index 600b732e6..d634423d2 100644 --- a/internal/cli/kraft/cloud/compose/ps/ps.go +++ b/internal/cli/kraft/cloud/compose/ps/ps.go @@ -12,6 +12,7 @@ import ( "strings" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/spf13/cobra" kraftcloud "sdk.kraft.cloud" @@ -27,6 +28,7 @@ type PsOptions struct { Auth *config.AuthConfig `noattribute:"true"` Client kraftcloud.KraftCloud `noattribute:"true"` Composefile string `noattribute:"true"` + EnvFile string `noattribute:"true"` Metro string `noattribute:"true"` Output string `long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list,raw" default:"table"` Project *compose.Project `noattribute:"true"` @@ -84,7 +86,11 @@ func (opts *PsOptions) Run(ctx context.Context, args []string) error { return err } - opts.Project, err = compose.NewProjectFromComposeFile(ctx, workdir, opts.Composefile) + opts.Project, err = compose.NewProjectFromComposeFile(ctx, + workdir, + opts.Composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/cloud/compose/push/push.go b/internal/cli/kraft/cloud/compose/push/push.go index c5eb70094..45b7dbdbf 100644 --- a/internal/cli/kraft/cloud/compose/push/push.go +++ b/internal/cli/kraft/cloud/compose/push/push.go @@ -12,6 +12,7 @@ import ( "strings" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/dustin/go-humanize" "github.com/spf13/cobra" @@ -31,6 +32,7 @@ type PushOptions struct { Auth *config.AuthConfig `noattribute:"true"` Client kcinstances.InstancesService `noattribute:"true"` Composefile string `noattribute:"true"` + EnvFile string `noattribute:"true"` Metro string `noattribute:"true"` Project *compose.Project `noattribute:"true"` Token string `noattribute:"true"` @@ -79,7 +81,11 @@ func Push(ctx context.Context, opts *PushOptions, args ...string) error { } if opts.Project == nil { - opts.Project, err = compose.NewProjectFromComposeFile(ctx, workdir, opts.Composefile) + opts.Project, err = compose.NewProjectFromComposeFile(ctx, + workdir, + opts.Composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/cloud/compose/start/start.go b/internal/cli/kraft/cloud/compose/start/start.go index 9c998c484..346d56403 100644 --- a/internal/cli/kraft/cloud/compose/start/start.go +++ b/internal/cli/kraft/cloud/compose/start/start.go @@ -13,6 +13,7 @@ import ( "time" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/spf13/cobra" kraftcloud "sdk.kraft.cloud" @@ -28,6 +29,7 @@ type StartOptions struct { Auth *config.AuthConfig `noattribute:"true"` Client kraftcloud.KraftCloud `noattribute:"true"` Composefile string `noattribute:"true"` + EnvFile string `noattribute:"true"` Metro string `noattribute:"true"` Project *compose.Project `noattribute:"true"` Token string `noattribute:"true"` @@ -93,7 +95,11 @@ func (opts *StartOptions) Run(ctx context.Context, args []string) error { return err } - opts.Project, err = compose.NewProjectFromComposeFile(ctx, workdir, opts.Composefile) + opts.Project, err = compose.NewProjectFromComposeFile(ctx, + workdir, + opts.Composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/cloud/compose/stop/stop.go b/internal/cli/kraft/cloud/compose/stop/stop.go index 1c1d90a06..33cd61961 100644 --- a/internal/cli/kraft/cloud/compose/stop/stop.go +++ b/internal/cli/kraft/cloud/compose/stop/stop.go @@ -13,6 +13,7 @@ import ( "time" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/spf13/cobra" kraftcloud "sdk.kraft.cloud" @@ -30,6 +31,7 @@ type StopOptions struct { Client kraftcloud.KraftCloud `noattribute:"true"` Composefile string `noattribute:"true"` DrainTimeout time.Duration `long:"drain-timeout" short:"d" usage:"Timeout for the instance to stop (ms/s/m/h)"` + EnvFile string `noattribute:"true"` Force bool `long:"force" short:"f" usage:"Force stop the instance(s)"` Metro string `noattribute:"true"` Project *compose.Project `noattribute:"true"` @@ -103,7 +105,11 @@ func (opts *StopOptions) Run(ctx context.Context, args []string) error { return err } - opts.Project, err = compose.NewProjectFromComposeFile(ctx, workdir, opts.Composefile) + opts.Project, err = compose.NewProjectFromComposeFile(ctx, + workdir, + opts.Composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/cloud/compose/up/up.go b/internal/cli/kraft/cloud/compose/up/up.go index 22fac26fd..feaf41fb8 100644 --- a/internal/cli/kraft/cloud/compose/up/up.go +++ b/internal/cli/kraft/cloud/compose/up/up.go @@ -14,6 +14,7 @@ import ( "time" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/dustin/go-humanize" "github.com/spf13/cobra" @@ -41,6 +42,7 @@ type UpOptions struct { Client kraftcloud.KraftCloud `noattribute:"true"` Composefile string `noattribute:"true"` Detach bool `local:"true" long:"detach" short:"d" usage:"Run the services in the background"` + EnvFile string `noattribute:"true"` Metro string `noattribute:"true"` NoStart bool `noattribute:"true"` NoBuild bool `local:"true" long:"no-build" usage:"Do not build the services before starting them"` @@ -136,7 +138,11 @@ func Up(ctx context.Context, opts *UpOptions, args ...string) error { return err } - opts.Project, err = compose.NewProjectFromComposeFile(ctx, workdir, opts.Composefile) + opts.Project, err = compose.NewProjectFromComposeFile(ctx, + workdir, + opts.Composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/compose/build/build.go b/internal/cli/kraft/compose/build/build.go index f6ccfad02..7165b372d 100644 --- a/internal/cli/kraft/compose/build/build.go +++ b/internal/cli/kraft/compose/build/build.go @@ -10,6 +10,7 @@ import ( "fmt" "os" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/compose-spec/compose-go/v2/types" "github.com/spf13/cobra" @@ -24,6 +25,7 @@ import ( type BuildOptions struct { composefile string + EnvFile string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -63,7 +65,11 @@ func (opts *BuildOptions) Run(ctx context.Context, args []string) error { return err } - project, err := compose.NewProjectFromComposeFile(ctx, workdir, opts.composefile) + project, err := compose.NewProjectFromComposeFile(ctx, + workdir, + opts.composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/compose/compose.go b/internal/cli/kraft/compose/compose.go index b6b2b21bd..80b8e491c 100644 --- a/internal/cli/kraft/compose/compose.go +++ b/internal/cli/kraft/compose/compose.go @@ -30,6 +30,7 @@ import ( type ComposeOptions struct { Composefile string `long:"file" short:"f" usage:"Set the Compose file."` + EnvFile string `long:"env-file" usage:"Set the environment file."` } func NewCmd() *cobra.Command { diff --git a/internal/cli/kraft/compose/create/create.go b/internal/cli/kraft/compose/create/create.go index 65a3b7e61..6b17ca986 100644 --- a/internal/cli/kraft/compose/create/create.go +++ b/internal/cli/kraft/compose/create/create.go @@ -12,6 +12,7 @@ import ( "strings" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/compose-spec/compose-go/v2/types" "github.com/spf13/cobra" @@ -42,6 +43,7 @@ import ( type CreateOptions struct { Composefile string `noattribute:"true"` + EnvFile string `noattribute:"true"` RemoveOrphans bool `long:"remove-orphans" usage:"Remove machines for services not defined in the Compose file"` } @@ -88,7 +90,11 @@ func (opts *CreateOptions) Run(ctx context.Context, args []string) error { return err } - project, err := compose.NewProjectFromComposeFile(ctx, workdir, opts.Composefile) + project, err := compose.NewProjectFromComposeFile(ctx, + workdir, + opts.Composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/compose/down/down.go b/internal/cli/kraft/compose/down/down.go index edaaae41d..c4000b10c 100644 --- a/internal/cli/kraft/compose/down/down.go +++ b/internal/cli/kraft/compose/down/down.go @@ -10,6 +10,7 @@ import ( "os" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/compose-spec/compose-go/v2/types" "github.com/spf13/cobra" @@ -29,7 +30,8 @@ import ( type DownOptions struct { composefile string - RemoveOrphans bool `long:"remove-orphans" usage:"Remove machines for services not defined in the Compose file."` + EnvFile string `noattribute:"true"` + RemoveOrphans bool `long:"remove-orphans" usage:"Remove machines for services not defined in the Compose file."` } func NewCmd() *cobra.Command { @@ -74,7 +76,11 @@ func (opts *DownOptions) Run(ctx context.Context, args []string) error { if err != nil { return err } - project, err := compose.NewProjectFromComposeFile(ctx, workdir, opts.composefile) + project, err := compose.NewProjectFromComposeFile(ctx, + workdir, + opts.composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/compose/logs/logs.go b/internal/cli/kraft/compose/logs/logs.go index a579444b3..2b782c2bf 100644 --- a/internal/cli/kraft/compose/logs/logs.go +++ b/internal/cli/kraft/compose/logs/logs.go @@ -9,26 +9,23 @@ import ( "context" "os" + composespec "github.com/compose-spec/compose-go/v2/cli" + "github.com/spf13/cobra" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - machineapi "kraftkit.sh/api/machine/v1alpha1" - "github.com/spf13/cobra" - "kraftkit.sh/cmdfactory" "kraftkit.sh/compose" kernellogs "kraftkit.sh/internal/cli/kraft/logs" "kraftkit.sh/log" - mplatform "kraftkit.sh/machine/platform" - "kraftkit.sh/packmanager" ) type LogsOptions struct { - Follow bool `long:"follow" usage:"Follow log output"` - Composefile string `noattribute:"true"` + EnvFile string `noattribute:"true"` + Follow bool `long:"follow" usage:"Follow log output"` } func NewCmd() *cobra.Command { @@ -69,7 +66,11 @@ func (opts *LogsOptions) Run(ctx context.Context, args []string) error { return err } - project, err := compose.NewProjectFromComposeFile(ctx, workdir, opts.Composefile) + project, err := compose.NewProjectFromComposeFile(ctx, + workdir, + opts.Composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/compose/pause/pause.go b/internal/cli/kraft/compose/pause/pause.go index 42d885c02..90c8b1275 100644 --- a/internal/cli/kraft/compose/pause/pause.go +++ b/internal/cli/kraft/compose/pause/pause.go @@ -9,6 +9,7 @@ import ( "os" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/spf13/cobra" "kraftkit.sh/cmdfactory" @@ -23,6 +24,7 @@ import ( type PauseOptions struct { composefile string + EnvFile string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -67,7 +69,11 @@ func (opts *PauseOptions) Run(ctx context.Context, args []string) error { return err } - project, err := compose.NewProjectFromComposeFile(ctx, workdir, opts.composefile) + project, err := compose.NewProjectFromComposeFile(ctx, + workdir, + opts.composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/compose/ps/ps.go b/internal/cli/kraft/compose/ps/ps.go index 9eeeb93ac..29abebbd3 100644 --- a/internal/cli/kraft/compose/ps/ps.go +++ b/internal/cli/kraft/compose/ps/ps.go @@ -10,18 +10,20 @@ import ( "os" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/spf13/cobra" - "kraftkit.sh/cmdfactory" - "kraftkit.sh/compose" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + composeapi "kraftkit.sh/api/compose/v1" + "kraftkit.sh/cmdfactory" + "kraftkit.sh/compose" pslist "kraftkit.sh/internal/cli/kraft/ps" "kraftkit.sh/log" "kraftkit.sh/packmanager" ) type PsOptions struct { + EnvFile string `noattribute:"true"` Long bool `long:"long" short:"l" usage:"Show more information"` Orphans bool `long:"orphans" usage:"Include orphaned services (default: true)" default:"true"` Output string `long:"output" short:"o" usage:"Set output format. Options: table,yaml,json,list" default:"table"` @@ -74,7 +76,11 @@ func (opts *PsOptions) Run(ctx context.Context, args []string) error { if err != nil { return err } - project, err := compose.NewProjectFromComposeFile(ctx, workdir, opts.composefile) + project, err := compose.NewProjectFromComposeFile(ctx, + workdir, + opts.composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/compose/pull/pull.go b/internal/cli/kraft/compose/pull/pull.go index ecac05897..e271c4509 100644 --- a/internal/cli/kraft/compose/pull/pull.go +++ b/internal/cli/kraft/compose/pull/pull.go @@ -10,11 +10,12 @@ import ( "os" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/spf13/cobra" + "kraftkit.sh/cmdfactory" "kraftkit.sh/compose" "kraftkit.sh/internal/cli/kraft/compose/utils" - pkgpull "kraftkit.sh/internal/cli/kraft/pkg/pull" "kraftkit.sh/log" "kraftkit.sh/packmanager" @@ -22,6 +23,7 @@ import ( type PullOptions struct { composefile string + EnvFile string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -67,7 +69,11 @@ func (opts *PullOptions) Run(ctx context.Context, args []string) error { return err } - project, err := compose.NewProjectFromComposeFile(ctx, workdir, opts.composefile) + project, err := compose.NewProjectFromComposeFile(ctx, + workdir, + opts.composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/compose/push/push.go b/internal/cli/kraft/compose/push/push.go index 59c09eb67..a9fa75ed9 100644 --- a/internal/cli/kraft/compose/push/push.go +++ b/internal/cli/kraft/compose/push/push.go @@ -10,10 +10,11 @@ import ( "os" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/spf13/cobra" + "kraftkit.sh/cmdfactory" "kraftkit.sh/compose" - pkgpush "kraftkit.sh/internal/cli/kraft/pkg/push" "kraftkit.sh/log" "kraftkit.sh/packmanager" @@ -21,6 +22,7 @@ import ( type PushOptions struct { composefile string + EnvFile string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -66,7 +68,11 @@ func (opts *PushOptions) Run(ctx context.Context, args []string) error { return err } - project, err := compose.NewProjectFromComposeFile(ctx, workdir, opts.composefile) + project, err := compose.NewProjectFromComposeFile(ctx, + workdir, + opts.composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/compose/start/start.go b/internal/cli/kraft/compose/start/start.go index da16432f5..5f8e5968b 100644 --- a/internal/cli/kraft/compose/start/start.go +++ b/internal/cli/kraft/compose/start/start.go @@ -9,6 +9,7 @@ import ( "os" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/spf13/cobra" "kraftkit.sh/cmdfactory" @@ -23,6 +24,7 @@ import ( type StartOptions struct { Composefile string `noattribute:"true"` + EnvFile string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -67,7 +69,11 @@ func (opts *StartOptions) Run(ctx context.Context, args []string) error { return err } - project, err := compose.NewProjectFromComposeFile(ctx, workdir, opts.Composefile) + project, err := compose.NewProjectFromComposeFile(ctx, + workdir, + opts.Composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/compose/stop/stop.go b/internal/cli/kraft/compose/stop/stop.go index 97ece8131..7093953ef 100644 --- a/internal/cli/kraft/compose/stop/stop.go +++ b/internal/cli/kraft/compose/stop/stop.go @@ -9,6 +9,7 @@ import ( "os" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/spf13/cobra" "kraftkit.sh/cmdfactory" @@ -23,6 +24,7 @@ import ( type StopOptions struct { Composefile string + EnvFile string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -67,7 +69,11 @@ func (opts *StopOptions) Run(ctx context.Context, args []string) error { return err } - project, err := compose.NewProjectFromComposeFile(ctx, workdir, opts.Composefile) + project, err := compose.NewProjectFromComposeFile(ctx, + workdir, + opts.Composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err } diff --git a/internal/cli/kraft/compose/unpause/unpause.go b/internal/cli/kraft/compose/unpause/unpause.go index 511ba9189..082dfa931 100644 --- a/internal/cli/kraft/compose/unpause/unpause.go +++ b/internal/cli/kraft/compose/unpause/unpause.go @@ -9,6 +9,7 @@ import ( "os" "github.com/MakeNowJust/heredoc" + composespec "github.com/compose-spec/compose-go/v2/cli" "github.com/spf13/cobra" "kraftkit.sh/cmdfactory" @@ -23,6 +24,7 @@ import ( type UnpauseOptions struct { Composefile string `noattribute:"true"` + EnvFile string `noattribute:"true"` } func NewCmd() *cobra.Command { @@ -67,7 +69,11 @@ func (opts *UnpauseOptions) Run(ctx context.Context, args []string) error { return err } - project, err := compose.NewProjectFromComposeFile(ctx, workdir, opts.Composefile) + project, err := compose.NewProjectFromComposeFile(ctx, + workdir, + opts.Composefile, + composespec.WithEnvFiles(opts.EnvFile), + ) if err != nil { return err }