package steps

import (
	"context"
	"os"

	"github.com/joho/godotenv"
	"github.com/pingcap/errors"
)

type loadEnv struct {
}

func NewLoadEnv() Step {
	return &loadEnv{}
}

func (s *loadEnv) Execute(ctx context.Context) error {
	if err := godotenv.Load(); err != nil && !os.IsNotExist(err) {
		return errors.Trace(err)
	}
	return nil
}

func (s *loadEnv) String() string {
	return "loadEnv: .env"
}
