Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/dev/preview/previewctl/cmd/create.go
2500 views
1
// Copyright (c) 2023 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package cmd
6
7
import (
8
"fmt"
9
"os"
10
"os/exec"
11
12
"github.com/sirupsen/logrus"
13
"github.com/spf13/cobra"
14
)
15
16
func newCreateCmd(logger *logrus.Logger) *cobra.Command {
17
cmd := &cobra.Command{
18
Use: "create",
19
Aliases: []string{"start"},
20
Short: "Create a new preview environment. Alias to `leeway run dev:preview`",
21
RunE: func(cmd *cobra.Command, args []string) error {
22
if err := create(); err != nil {
23
logger.WithError(err).Fatal("Failed to create preview.")
24
}
25
26
return nil
27
},
28
}
29
30
return cmd
31
}
32
33
func create() error {
34
cmd := exec.Command("leeway", "run", "dev:preview")
35
cmd.Stdin = os.Stdin
36
cmd.Stdout = os.Stdout
37
cmd.Stderr = os.Stderr
38
cmd.Env = os.Environ()
39
40
err := cmd.Run()
41
if err != nil {
42
return fmt.Errorf("failed to run command: %s", cmd.String())
43
}
44
45
return nil
46
}
47
48