| 51 | } |
| 52 | |
| 53 | func NewProjectDeploy(projectDirectory string, opts ...ProjectDeployOption) (*ProjectDeploy, error) { |
| 54 | var op errors.Op = "deploy.NewProjectDeploy" |
| 55 | ec := cli.NewExecutionContext() |
| 56 | ec.ExecutionDirectory = projectDirectory |
| 57 | ec.Viper = viper.New() |
| 58 | ec.IsTerminal = false |
| 59 | ec.Stdout = io.Discard |
| 60 | ec.Stderr = io.Discard |
| 61 | |
| 62 | if err := ec.Prepare(); err != nil { |
| 63 | return nil, errors.E(op, err) |
| 64 | } |
| 65 | d := &ProjectDeploy{ec} |
| 66 | for _, opt := range opts { |
| 67 | opt(d) |
| 68 | } |
| 69 | |
| 70 | if err := ec.Validate(); err != nil { |
| 71 | return nil, errors.E(op, err) |
| 72 | } |
| 73 | if ec.Config.Version <= cli.V1 { |
| 74 | return nil, errors.E(op, fmt.Errorf("config %v is not supported", ec.Config.Version)) |
| 75 | } |
| 76 | return d, nil |
| 77 | } |