-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathadd.go
48 lines (39 loc) · 1.08 KB
/
add.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
46
47
48
package dns
import (
"fmt"
"github.com/spf13/cobra"
"github.com/nanobox-io/nanobox/helpers"
"github.com/nanobox-io/nanobox/models"
app_dns "github.com/nanobox-io/nanobox/processors/app/dns"
"github.com/nanobox-io/nanobox/util/config"
"github.com/nanobox-io/nanobox/util/display"
)
// AddCmd ...
var AddCmd = &cobra.Command{
Use: "add [local|dry-run] <hostname>",
Short: "Adds dns entries",
Long: ``,
// PreRun: steps.Run("login"),
Run: addFn,
}
// addFn ...
func addFn(ccmd *cobra.Command, args []string) {
// parse the dnss excluding the context
env, _ := models.FindEnvByID(config.EnvID())
args, location, name := helpers.Endpoint(env, args, 2)
if len(args) != 1 {
fmt.Println("i need a dns")
}
switch location {
case "local":
app, _ := models.FindAppBySlug(config.EnvID(), name)
app.Generate(env, name)
display.CommandErr(app_dns.Add(env, app, args[0]))
case "production":
fmt.Printf(`
--------------------------------------------------------
Production dns aliasing is not yet implemented.
--------------------------------------------------------
`)
}
}