Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/dev/preview/previewctl/cmd/report.go
2500 views
1
// Copyright (c) 2022 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
"os"
9
"strings"
10
11
"github.com/spf13/cobra"
12
13
"github.com/gitpod-io/gitpod/previewctl/pkg/preview"
14
15
"text/template"
16
)
17
18
var tmplString = `
19
<p>Gitpod was successfully deployed to your preview environment.</p>
20
<ul>
21
<li><b>🏷️ Name</b> - {{ .Name }}</li>
22
<li><b>🔗 URL</b> - <a href="https://{{ .Name }}.preview.gitpod-dev.com/workspaces" target="_blank">{{ .Name }}.preview.gitpod-dev.com/workspaces</a>.</li>
23
<li><b>📚 Documentation</b> - See our <a href="https://www.notion.so/gitpod/6debd359591b43688b52f76329d04010#7c1ce80ab31a41e29eff2735e38eec39" target="_blank">internal documentation</a> for information on how to interact with your preview environment.</li>
24
<li><b>📦 Version</b> - {{ .Version }}</li>
25
<li><b>🗒️ Logs</b> - <a href="https://console.cloud.google.com/logs/query;query=jsonPayload.kubernetes.host%3D%22preview-{{ .Name }}%22%0A%0A--%20Filter%20on%20service:%0A--%20jsonPayload.serviceContext.service%3D%22ws-manager-mk2%22%0A;duration=P1D?project=gitpod-dev-preview" target="_blank">GCP Logs Explorer</a></li>
26
</ul>
27
`
28
29
func newReportNameCmd() *cobra.Command {
30
var version string
31
cmd := &cobra.Command{
32
Use: "report",
33
Short: "Writes an HTML report to stdout with information about the current preview environment.",
34
RunE: func(cmd *cobra.Command, args []string) error {
35
previewName, err := preview.GetName(branch)
36
if err != nil {
37
return err
38
}
39
40
tmpl, _ := template.New("Report").Parse(strings.TrimSpace(strings.ReplaceAll(tmplString, "'", "`")))
41
42
vars := make(map[string]interface{})
43
vars["Name"] = previewName
44
vars["Url"] = previewName
45
vars["Version"] = version
46
47
err = tmpl.Execute(os.Stdout, vars)
48
if err != nil {
49
return err
50
}
51
52
return nil
53
},
54
}
55
56
cmd.Flags().StringVar(&version, "installer-version", os.Getenv("VERSION"), "Deployed installer version")
57
58
return cmd
59
}
60
61