This repository has been archived by the owner on Apr 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
59 lines (42 loc) · 1.44 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"fmt"
"net/http"
"os"
"github.com/MattHodge/go-octopusdeploy/octopusdeploy"
)
var octopusURL = os.Getenv("OCTOPUS_URL")
var octopusAPIKey = os.Getenv("OCTOPUS_APIKEY")
func main() {
httpClient := http.Client{}
client := octopusdeploy.NewClient(&httpClient, octopusURL, octopusAPIKey)
p := octopusdeploy.NewProject("Test Project GoLang2", "Lifecycles-1", "ProjectGroups-1")
createdProject, err := client.Project.Add(p)
if err != nil {
fmt.Println(err.Error())
} else { //This isn't idomatic go, but it allows the demo to continue if the create fails
fmt.Printf("Created Project ID %s", createdProject.ID)
project, err := client.Project.Get(createdProject.ID)
if err != nil {
fmt.Println(err.Error())
} else { //This isn't idomatic go, but it allows the demo to continue if the create fails
fmt.Println(project.Name)
}
}
e := octopusdeploy.NewEnvironment("Test Environment GoLang", "Test environment created by go-octopusdeploy", false)
err = e.Validate()
if err != nil {
fmt.Println(err.Error())
}
createdEnvironment, err := client.Environment.Add(e)
if err != nil {
fmt.Println(err.Error())
}
fmt.Printf("Created Project ID %s", createdEnvironment.ID)
environment, err := client.Environment.Get(createdEnvironment.ID)
if err != nil {
fmt.Println(err.Error())
} else { //This isn't idomatic go, but it allows the demo to continue if the create fails
fmt.Println(environment.Name)
}
}