generated from mattermost/mattermost-plugin-starter-template
/
terraform.go
45 lines (36 loc) · 997 Bytes
/
terraform.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved.
// See License for license information.
package main
import (
"encoding/json"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/mattermost/mattermost-plugin-apps/upstream/upaws"
)
func init() {
rootCmd.AddCommand(
terraformCmd,
)
terraformCmd.AddCommand(terraformGenerateCmd)
}
var terraformCmd = &cobra.Command{
Use: "terraform",
Short: "Generate Terraform data for Mattermost Cloud",
}
var terraformGenerateCmd = &cobra.Command{
Use: "generate-data",
Short: "Generate Terraform data for Mattermost Cloud",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
data, err := upaws.GetDeployDataFromFile(args[0], log)
if err != nil {
return errors.Wrap(err, "can't get deploy data")
}
bytes, err := json.MarshalIndent(data, "", "\t")
if err != nil {
return errors.Wrap(err, "can't marshal data")
}
cmd.Println(string(bytes))
return nil
},
}