graphql-engine/cli/pkg/deploy/deploy.go
Rikin Kachhia c256dcef7b cli: add option to apply seeds with the hasura deploy command
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7231
Co-authored-by: Aravind K P <8335904+scriptonist@users.noreply.github.com>
GitOrigin-RevId: 3cc7510bb16e8bceeb6cd2a678881a3459b6721f
2022-12-22 07:56:56 +00:00

41 lines
916 B
Go

package deploy
import (
"github.com/hasura/graphql-engine/cli/v2"
"github.com/hasura/graphql-engine/cli/v2/commands"
"github.com/hasura/graphql-engine/cli/v2/internal/errors"
)
type projectDeployExecutor struct {
ec *cli.ExecutionContext
opts commands.DeployOptions
}
func newProjectDeployExecutor(ec *cli.ExecutionContext) *projectDeployExecutor {
d := &projectDeployExecutor{
ec: ec,
opts: commands.DeployOptions{EC: ec},
}
return d
}
type ProjectDeployExecutorOptions func(executor *projectDeployExecutor)
func WithSeeds() ProjectDeployExecutorOptions {
return func(p *projectDeployExecutor) {
p.opts.WithSeeds = true
}
}
func (d *projectDeployExecutor) deploy(opts ...ProjectDeployExecutorOptions) error {
var op errors.Op = "deploy.projectDeployExecutor.deploy"
for _, opt := range opts {
opt(d)
}
err := d.opts.Run()
if err != nil {
return errors.E(op, err)
}
return nil
}