From 178db2df7e1e6c959d45f0ebccaf14ada35355dc Mon Sep 17 00:00:00 2001 From: Toby Lorne Date: Fri, 25 Oct 2019 17:14:59 +0100 Subject: [PATCH 01/17] Move into code to pkg/provider so tests are easier Also allow us to use username and password Signed-off-by: Toby Lorne --- config.go | 32 -------------- go.mod | 3 ++ go.sum | 11 +++++ main.go | 4 +- pkg/client/client.go | 48 ++++++++++++++++++++ pkg/client/transport.go | 22 +++++++++ pkg/provider/config.go | 59 +++++++++++++++++++++++++ pipeline.go => pkg/provider/pipeline.go | 2 +- pkg/provider/provider.go | 54 ++++++++++++++++++++++ team.go => pkg/provider/team.go | 2 +- util.go => pkg/provider/util.go | 2 +- provider.go | 29 ------------ 12 files changed, 203 insertions(+), 65 deletions(-) delete mode 100644 config.go create mode 100644 pkg/client/client.go create mode 100644 pkg/client/transport.go create mode 100644 pkg/provider/config.go rename pipeline.go => pkg/provider/pipeline.go (99%) create mode 100644 pkg/provider/provider.go rename team.go => pkg/provider/team.go (99%) rename util.go => pkg/provider/util.go (98%) delete mode 100644 provider.go diff --git a/config.go b/config.go deleted file mode 100644 index 824893c..0000000 --- a/config.go +++ /dev/null @@ -1,32 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/concourse/concourse/fly/rc" - "github.com/concourse/concourse/go-concourse/concourse" - "github.com/hashicorp/terraform/helper/schema" -) - -type ProviderConfig struct { - Client concourse.Client -} - -func ProviderConfigurationBuilder( - d *schema.ResourceData, -) (interface{}, error) { - - targetName := rc.TargetName(d.Get("target").(string)) - - target, err := rc.LoadTarget(targetName, false) - - if err != nil { - return nil, fmt.Errorf("Error loading target: %s", err) - } - - client := target.Client() - - return &ProviderConfig{ - Client: interface{}(client).(concourse.Client), - }, nil -} diff --git a/go.mod b/go.mod index 5d2a13a..85607ac 100644 --- a/go.mod +++ b/go.mod @@ -6,4 +6,7 @@ require ( github.com/concourse/concourse v5.5.1+incompatible github.com/ghodss/yaml v1.0.0 github.com/hashicorp/terraform v0.12.9 + github.com/onsi/ginkgo v1.9.0 + github.com/onsi/gomega v1.7.0 + golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 ) diff --git a/go.sum b/go.sum index 8397dd3..7675b5f 100644 --- a/go.sum +++ b/go.sum @@ -143,6 +143,7 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do github.com/dancannon/gorethink v4.0.0+incompatible/go.mod h1:BLvkat9KmZc1efyYwhz3WnybhRZtgF1K929FD8z1avU= github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/denisenkom/go-mssqldb v0.0.0-20180901172138-1eb28afdf9b6/go.mod h1:xN/JuLBIz4bjkxNmByTiV1IbhfnYb6oo99phBn4Eqhc= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= @@ -184,6 +185,7 @@ github.com/go-sql-driver/mysql v0.0.0-20160802113842-0b58b37b664c/go.mod h1:zAC/ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stomp/stomp v2.0.2+incompatible/go.mod h1:VqCtqNZv1226A1/79yh+rMiFUcfY3R109np+7ke4n0c= github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gobuffalo/packr v1.13.7/go.mod h1:KkinLIn/n6+3tVXMwg6KkNvWwVsrRAz4ph+jgpk3Z24= github.com/gocql/gocql v0.0.0-20180920092337-799fb0373110/go.mod h1:4Fw1eo5iaEhDUs8XyuhSVCVy52Jq3L+/3GJgYkwc+/0= @@ -302,6 +304,7 @@ github.com/hashicorp/hcl2 v0.0.0-20190821123243-0c888d1241f6 h1:JImQpEeUQ+0DPFMa github.com/hashicorp/hcl2 v0.0.0-20190821123243-0c888d1241f6/go.mod h1:Cxv+IJLuBiEhQ7pBYGEuORa0nr4U994pE8mYLuFd7v0= github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590 h1:2yzhWGdgQUWZUCNK+AoO35V+HTsgEmcM4J9IkArh7PI= github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590/go.mod h1:n2TSygSNwsLJ76m8qFXTSc7beTb+auJxYdqrnoqwZWE= +github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/memberlist v0.1.0/go.mod h1:ncdBp14cuox2iFOq3kDiquKU6fqsTBc3W6JvZwjxxsE= github.com/hashicorp/nomad v0.8.6/go.mod h1:WRaKjdO1G2iqi86TvTjIYtKTyxg4pl7NLr9InxtWaI0= @@ -310,6 +313,8 @@ github.com/hashicorp/serf v0.0.0-20160124182025-e4ec8cc423bb/go.mod h1:h/Ru6tmZa github.com/hashicorp/serf v0.8.1/go.mod h1:h/Ru6tmZazX7WO/GDmwdpS975F019L4t5ng5IgwbNrE= github.com/hashicorp/terraform v0.12.9 h1:ClfUndj2L94SWUiBRNikWBHu5+U/KmvaUKbLTbuo5mM= github.com/hashicorp/terraform v0.12.9/go.mod h1:qqvw7OZzW6mePSM0k2+rOzOD4U8YgHJF6T1qUCR7aAU= +github.com/hashicorp/terraform v0.12.12 h1:c71+dDT8TbiVDCaQPvkEhdvTqyrP55s7POa6D5aUBSM= +github.com/hashicorp/terraform-config-inspect v0.0.0-20190821133035-82a99dc22ef4 h1:fTkL0YwjohGyN7AqsDhz6bwcGBpT+xBqi3Qhpw58Juw= github.com/hashicorp/terraform-config-inspect v0.0.0-20190821133035-82a99dc22ef4/go.mod h1:JDmizlhaP5P0rYTTZB0reDMefAiJyfWPEtugV4in1oI= github.com/hashicorp/vault v0.10.4/go.mod h1:KfSyffbKxoVyspOdlaGVjIuwLobi07qD1bAbosPMpP0= github.com/hashicorp/vault v1.0.1/go.mod h1:KfSyffbKxoVyspOdlaGVjIuwLobi07qD1bAbosPMpP0= @@ -329,6 +334,7 @@ github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20180917205041-7221087c3d28 h1:gACvD6C1jev87LpraglGaxsDUGA8qg7Uz+Xh6dWKtIQ= github.com/hashicorp/yamux v0.0.0-20180917205041-7221087c3d28/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf/go.mod h1:hyb9oH7vZsitZCiBt0ZvifOrB+qc8PS5IiilCIb87rg= @@ -397,6 +403,7 @@ github.com/miekg/dns v1.0.8/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nr github.com/miekg/dns v1.1.6/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mitchellh/cli v1.0.0 h1:iGBIsUe3+HZ/AD/Vd7DErOt5sU9fa8Uj7A2s1aggv1Y= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= @@ -433,10 +440,12 @@ github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.9.0 h1:SZjF721BByVj8QH636/8S2DnX4n0Re3SteMmw3N+tzc= github.com/onsi/ginkgo v1.9.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= @@ -700,6 +709,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/fatih/pool.v2 v2.0.0/go.mod h1:8xVGeu1/2jr2wm5V9SPuMht2H5AEmf5aFMGSQixtjTY= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gorethink/gorethink.v4 v4.1.0/go.mod h1:M7JgwrUAmshJ3iUbEK0Pt049MPyPK+CYDGGaEjdZb/c= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= @@ -710,6 +720,7 @@ gopkg.in/ory-am/dockertest.v2 v2.2.3/go.mod h1:kDHEsan1UcKFYH1c28sDmqnmeqIpB4Nj6 gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/square/go-jose.v2 v2.1.8/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/square/go-jose.v2 v2.3.0/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.0.0-20160301204022-a83829b6f129/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= diff --git a/main.go b/main.go index 5ecf31e..26a9253 100644 --- a/main.go +++ b/main.go @@ -3,12 +3,14 @@ package main import ( "github.com/hashicorp/terraform/plugin" "github.com/hashicorp/terraform/terraform" + + "github.com/alphagov/terraform-provider-concourse/pkg/provider" ) func main() { plugin.Serve(&plugin.ServeOpts{ ProviderFunc: func() terraform.ResourceProvider { - return Provider() + return provider.Provider() }, }) } diff --git a/pkg/client/client.go b/pkg/client/client.go new file mode 100644 index 0000000..4b53ba7 --- /dev/null +++ b/pkg/client/client.go @@ -0,0 +1,48 @@ +package client + +import ( + "context" + "net/http" + + "github.com/concourse/concourse/go-concourse/concourse" + "golang.org/x/oauth2" +) + +// NewConcourseClient gives you an authenticated Concourse client using +// local user username and password authentication. Separate from Basic Auth. +func NewConcourseClient( + url string, + team string, + username string, password string, +) (concourse.Client, error) { + + client := concourse.NewClient(url, &http.Client{}, false) + + o2cfg := oauth2.Config{ + ClientID: "fly", + ClientSecret: "Zmx5", + + Endpoint: oauth2.Endpoint{TokenURL: client.URL() + "/sky/token"}, + Scopes: []string{"email", "federated:id", "groups", "openid", "profile"}, + } + + ctx := context.WithValue( + context.Background(), + oauth2.HTTPClient, client.HTTPClient(), + ) + + tok, err := o2cfg.PasswordCredentialsToken(ctx, username, password) + + if err != nil { + return nil, err + } + + return concourse.NewClient( + url, + &http.Client{ + Transport: AuthenticatedTransport{ + AccessToken: tok.AccessToken, + TokenType: tok.TokenType, + }, + }, false), nil +} diff --git a/pkg/client/transport.go b/pkg/client/transport.go new file mode 100644 index 0000000..45541ab --- /dev/null +++ b/pkg/client/transport.go @@ -0,0 +1,22 @@ +package client + +import ( + "net/http" + "strings" +) + +// AuthenticatedTransport is a transport which adds the Authorization header +type AuthenticatedTransport struct { + AccessToken string + TokenType string +} + +// RoundTrip represents a single authorized request/response cycle +func (t AuthenticatedTransport) RoundTrip(r *http.Request) (*http.Response, error) { + r.Header.Add( + "Authorization", + strings.Join([]string{t.TokenType, t.AccessToken}, " "), + ) + + return http.DefaultTransport.RoundTrip(r) +} diff --git a/pkg/provider/config.go b/pkg/provider/config.go new file mode 100644 index 0000000..f64fe4b --- /dev/null +++ b/pkg/provider/config.go @@ -0,0 +1,59 @@ +package provider + +import ( + "fmt" + + "github.com/concourse/concourse/fly/rc" + "github.com/concourse/concourse/go-concourse/concourse" + "github.com/hashicorp/terraform/helper/schema" + + "github.com/alphagov/terraform-provider-concourse/pkg/client" +) + +type ProviderConfig struct { + Client concourse.Client +} + +func ProviderConfigurationBuilder( + d *schema.ResourceData, +) (interface{}, error) { + + targetName := rc.TargetName(d.Get("target").(string)) + + if targetName != "" { + target, err := rc.LoadTarget(targetName, false) + + if err != nil { + return nil, fmt.Errorf("Error loading target: %s", err) + } + + return &ProviderConfig{ + Client: target.Client(), + }, nil + } + + url := d.Get("url").(string) + team := d.Get("team").(string) + username := d.Get("username").(string) + password := d.Get("password").(string) + + if url != "" && team != "" && username != "" && password != "" { + c, err := client.NewConcourseClient( + url, + team, + username, password, + ) + + if err != nil { + return nil, fmt.Errorf("Error creating client: %s", err) + } + + return &ProviderConfig{ + Client: c, + }, nil + } + + return nil, fmt.Errorf( + `Please specify "target" or "username", "password", "team", and "url"`, + ) +} diff --git a/pipeline.go b/pkg/provider/pipeline.go similarity index 99% rename from pipeline.go rename to pkg/provider/pipeline.go index 2054856..e7805d0 100644 --- a/pipeline.go +++ b/pkg/provider/pipeline.go @@ -1,4 +1,4 @@ -package main +package provider import ( "encoding/json" diff --git a/pkg/provider/provider.go b/pkg/provider/provider.go new file mode 100644 index 0000000..7786ccc --- /dev/null +++ b/pkg/provider/provider.go @@ -0,0 +1,54 @@ +package provider + +import ( + "github.com/hashicorp/terraform/helper/schema" +) + +func Provider() *schema.Provider { + return &schema.Provider{ + Schema: map[string]*schema.Schema{ + "target": { + Type: schema.TypeString, + DefaultFunc: schema.EnvDefaultFunc("FLY_TARGET", nil), + Description: "Target as in 'fly --target', do not use if using team/username/password", + Optional: true, + }, + "url": { + Type: schema.TypeString, + DefaultFunc: schema.EnvDefaultFunc("FLY_URL", nil), + Description: "URL, do not use if using target ", + Optional: true, + }, + "team": { + Type: schema.TypeString, + DefaultFunc: schema.EnvDefaultFunc("FLY_TEAM", nil), + Description: "Team name, do not use if using target ", + Optional: true, + }, + "username": { + Type: schema.TypeString, + DefaultFunc: schema.EnvDefaultFunc("FLY_USERNAME", nil), + Description: "Username, do not use if using target", + Optional: true, + }, + "password": { + Type: schema.TypeString, + DefaultFunc: schema.EnvDefaultFunc("FLY_PASSWORD", nil), + Description: "Password, do not use if using target ", + Optional: true, + }, + }, + + ConfigureFunc: ProviderConfigurationBuilder, + + DataSourcesMap: map[string]*schema.Resource{ + "concourse_pipeline": dataPipeline(), + "concourse_team": dataTeam(), + }, + + ResourcesMap: map[string]*schema.Resource{ + "concourse_pipeline": resourcePipeline(), + "concourse_team": resourceTeam(), + }, + } +} diff --git a/team.go b/pkg/provider/team.go similarity index 99% rename from team.go rename to pkg/provider/team.go index c095e14..c643c34 100644 --- a/team.go +++ b/pkg/provider/team.go @@ -1,4 +1,4 @@ -package main +package provider import ( "fmt" diff --git a/util.go b/pkg/provider/util.go similarity index 98% rename from util.go rename to pkg/provider/util.go index c17a71e..175dacc 100644 --- a/util.go +++ b/pkg/provider/util.go @@ -1,4 +1,4 @@ -package main +package provider import ( "fmt" diff --git a/provider.go b/provider.go deleted file mode 100644 index f5d3a90..0000000 --- a/provider.go +++ /dev/null @@ -1,29 +0,0 @@ -package main - -import ( - "github.com/hashicorp/terraform/helper/schema" -) - -func Provider() *schema.Provider { - return &schema.Provider{ - Schema: map[string]*schema.Schema{ - "target": { - Type: schema.TypeString, - Required: true, - DefaultFunc: schema.EnvDefaultFunc("FLY_TARGET", nil), - Description: "Target as in 'fly --target'", - }, - }, - ConfigureFunc: ProviderConfigurationBuilder, - - DataSourcesMap: map[string]*schema.Resource{ - "concourse_pipeline": dataPipeline(), - "concourse_team": dataTeam(), - }, - - ResourcesMap: map[string]*schema.Resource{ - "concourse_pipeline": resourcePipeline(), - "concourse_team": resourceTeam(), - }, - } -} From cf7617cbdb2819a0a0228a132919b93980033690 Mon Sep 17 00:00:00 2001 From: Toby Lorne Date: Sat, 26 Oct 2019 14:26:36 +0100 Subject: [PATCH 02/17] Add simple acceptance test using docker-compose Signed-off-by: Toby Lorne --- docker-compose.yml | 26 ++++ integration-tests/setup_test.go | 107 ++++++++++++++ integration-tests/suite_test.go | 13 ++ integration-tests/user_mgmt.go | 248 ++++++++++++++++++++++++++++++++ 4 files changed, 394 insertions(+) create mode 100644 docker-compose.yml create mode 100644 integration-tests/setup_test.go create mode 100644 integration-tests/suite_test.go create mode 100644 integration-tests/user_mgmt.go diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5967bdf --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,26 @@ +version: '3' + +services: + concourse-db: + image: postgres + environment: + POSTGRES_DB: concourse + POSTGRES_PASSWORD: concourse_pass + POSTGRES_USER: concourse_user + PGDATA: /database + + concourse: + image: concourse/concourse + command: quickstart + privileged: true + depends_on: [concourse-db] + ports: ["8080:8080"] + environment: + CONCOURSE_POSTGRES_HOST: concourse-db + CONCOURSE_POSTGRES_USER: concourse_user + CONCOURSE_POSTGRES_PASSWORD: concourse_pass + CONCOURSE_POSTGRES_DATABASE: concourse + CONCOURSE_EXTERNAL_URL: http://localhost:8080 + CONCOURSE_ADD_LOCAL_USER: admin:password + CONCOURSE_MAIN_TEAM_LOCAL_USER: admin + CONCOURSE_WORKER_BAGGAGECLAIM_DRIVER: overlay diff --git a/integration-tests/setup_test.go b/integration-tests/setup_test.go new file mode 100644 index 0000000..5aa12ac --- /dev/null +++ b/integration-tests/setup_test.go @@ -0,0 +1,107 @@ +package integration_tests + +import ( + "fmt" + "os" + "os/exec" + + "github.com/concourse/concourse/go-concourse/concourse" + + "github.com/alphagov/terraform-provider-concourse/pkg/client" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + "github.com/onsi/gomega/gexec" +) + +const ( + concourseURL = "http://localhost:8080" + concourseTeam = "main" + concourseUsername = "admin" + concoursePassword = "password" +) + +func NewConcourseClient() (concourse.Client, error) { + c, err := client.NewConcourseClient( + concourseURL, + concourseTeam, + concourseUsername, concoursePassword, + ) + + if err != nil { + return nil, err + } + + return c, nil +} + +func SetupSuite() { + Expect(os.Setenv("TF_ACC", "true")).NotTo(HaveOccurred()) + + Expect(os.Setenv("FLY_URL", concourseURL)).NotTo(HaveOccurred()) + Expect(os.Setenv("FLY_TEAM", concourseTeam)).NotTo(HaveOccurred()) + Expect(os.Setenv("FLY_USERNAME", concourseUsername)).NotTo(HaveOccurred()) + Expect(os.Setenv("FLY_PASSWORD", concoursePassword)).NotTo(HaveOccurred()) + + buildCmd := exec.Command("docker-compose", "build") + session, err := gexec.Start(buildCmd, GinkgoWriter, GinkgoWriter) + Expect(err).ShouldNot(HaveOccurred()) + Eventually(session, 300).Should(gexec.Exit(0)) +} + +func SetupTest() { + upCmd := exec.Command("docker-compose", "up", "-d", "--force-recreate") + session, err := gexec.Start(upCmd, GinkgoWriter, GinkgoWriter) + Expect(err).ShouldNot(HaveOccurred()) + Eventually(session, 120).Should(gexec.Exit(0)) + + Eventually(func() error { + fmt.Println("Waiting for Concourse to be ready") + + client, err := NewConcourseClient() + + if err != nil { + return err + } + + _, err = client.ListWorkers() + + if err != nil { + return err + } + + fmt.Println("Concourse is ready") + return nil + }, "15s", "3s").ShouldNot(HaveOccurred()) +} + +func TeardownTest() { + downCmd := exec.Command("docker-compose", "down") + session, err := gexec.Start(downCmd, GinkgoWriter, GinkgoWriter) + Expect(err).ShouldNot(HaveOccurred()) + Eventually(session, 60).Should(gexec.Exit(0)) +} + +func TeardownSuite() { + gexec.KillAndWait() +} + +type GinkgoTerraformTestingT struct { + GinkgoTInterface + + CurrentDescription GinkgoTestDescription +} + +func NewGinkoTerraformTestingT() GinkgoTerraformTestingT { + return GinkgoTerraformTestingT{GinkgoT(), CurrentGinkgoTestDescription()} +} + +func (t GinkgoTerraformTestingT) Helper() {} + +func (t GinkgoTerraformTestingT) Name() string { + return t.CurrentDescription.FullTestText +} + +func (t GinkgoTerraformTestingT) Verbose() bool { + return true +} diff --git a/integration-tests/suite_test.go b/integration-tests/suite_test.go new file mode 100644 index 0000000..5f86295 --- /dev/null +++ b/integration-tests/suite_test.go @@ -0,0 +1,13 @@ +package integration_tests + +import ( + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +func TestIntegrationTests(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Integration tests") +} diff --git a/integration-tests/user_mgmt.go b/integration-tests/user_mgmt.go new file mode 100644 index 0000000..f7916bc --- /dev/null +++ b/integration-tests/user_mgmt.go @@ -0,0 +1,248 @@ +package integration_tests + +import ( + "fmt" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/alphagov/terraform-provider-concourse/pkg/provider" + + "github.com/hashicorp/terraform/helper/resource" + // "github.com/hashicorp/terraform/helper/schema" + "github.com/concourse/concourse/atc" + "github.com/hashicorp/terraform/terraform" +) + +var _ = Describe("User management", func() { + BeforeSuite(SetupSuite) + BeforeEach(SetupTest) + AfterEach(TeardownTest) + AfterSuite(TeardownSuite) + + It("should create, update, and destroy users", func() { + providers := map[string]terraform.ResourceProvider{ + "concourse": provider.Provider(), + } + + client, err := NewConcourseClient() + + Expect(err).NotTo(HaveOccurred()) + + resource.Test(NewGinkoTerraformTestingT(), resource.TestCase{ + IsUnitTest: false, + + Providers: providers, + + Steps: []resource.TestStep{ + resource.TestStep{ + // Add a team without any users + + Config: `resource "concourse_team" "a_team" { + team_name = "team-a" + }`, + + Check: resource.ComposeTestCheckFunc( + func(s *terraform.State) error { + By("Creating an empty team") + + fmt.Printf("%+v\n", s) + return nil + }, + + resource.TestCheckResourceAttr("concourse_team.a_team", "team_name", "team-a"), + + resource.TestCheckResourceAttr("concourse_team.a_team", "owners.#", "0"), + resource.TestCheckResourceAttr("concourse_team.a_team", "members.#", "0"), + resource.TestCheckResourceAttr("concourse_team.a_team", "pipeline_operators.#", "0"), + resource.TestCheckResourceAttr("concourse_team.a_team", "viewers.#", "0"), + + func(s *terraform.State) error { + teams, err := client.ListTeams() + + if err != nil { + return nil + } + + Expect(teams).To(HaveLen(2)) + + Expect(teams[0].Name).To(Equal("main")) + Expect(teams[1].Name).To(Equal("team-a")) + + expectedTeamAuth := atc.TeamAuth{ + "owner": {"groups": nil, "users": nil}, + "member": {"groups": nil, "users": nil}, + "pipeline-operator": {"groups": nil, "users": nil}, + "viewer": {"groups": nil, "users": nil}, + } + + Expect(teams[1].Auth).To(Equal(expectedTeamAuth)) + + return nil + }, + ), + }, + + resource.TestStep{ + // Add a user as an owner + + Config: `resource "concourse_team" "a_team" { + team_name = "team-a" + + owners = ["user:github:tlwr"] + }`, + + Check: resource.ComposeTestCheckFunc( + func(s *terraform.State) error { + By("Adding a user as an owner") + + fmt.Printf("%+v\n", s) + return nil + }, + + resource.TestCheckResourceAttr("concourse_team.a_team", "team_name", "team-a"), + + resource.TestCheckResourceAttr("concourse_team.a_team", "owners.#", "1"), + resource.TestCheckResourceAttr("concourse_team.a_team", "owners.0", "user:github:tlwr"), + resource.TestCheckResourceAttr("concourse_team.a_team", "members.#", "0"), + resource.TestCheckResourceAttr("concourse_team.a_team", "pipeline_operators.#", "0"), + resource.TestCheckResourceAttr("concourse_team.a_team", "viewers.#", "0"), + + func(s *terraform.State) error { + teams, err := client.ListTeams() + + if err != nil { + return nil + } + + Expect(teams).To(HaveLen(2)) + + Expect(teams[0].Name).To(Equal("main")) + Expect(teams[1].Name).To(Equal("team-a")) + + expectedTeamAuth := atc.TeamAuth{ + "member": {"groups": nil, "users": nil}, + "pipeline-operator": {"groups": nil, "users": nil}, + "viewer": {"groups": nil, "users": nil}, + + "owner": { + "groups": nil, + "users": {"github:tlwr"}, + }, + } + + Expect(teams[1].Auth).To(Equal(expectedTeamAuth)) + + return nil + }, + ), + }, + + resource.TestStep{ + // Change a user from an owner to a pipeline-operator + + Config: `resource "concourse_team" "a_team" { + team_name = "team-a" + + pipeline_operators = ["user:github:tlwr"] + }`, + + Check: resource.ComposeTestCheckFunc( + func(s *terraform.State) error { + By("Changing a user from an owner to a pipeline-operator") + + fmt.Printf("%+v\n", s) + return nil + }, + + resource.TestCheckResourceAttr("concourse_team.a_team", "team_name", "team-a"), + + resource.TestCheckResourceAttr("concourse_team.a_team", "owners.#", "0"), + resource.TestCheckResourceAttr("concourse_team.a_team", "members.#", "0"), + resource.TestCheckResourceAttr("concourse_team.a_team", "pipeline_operators.#", "1"), + resource.TestCheckResourceAttr("concourse_team.a_team", "pipeline_operators.0", "user:github:tlwr"), + resource.TestCheckResourceAttr("concourse_team.a_team", "viewers.#", "0"), + + func(s *terraform.State) error { + teams, err := client.ListTeams() + + if err != nil { + return nil + } + + Expect(teams).To(HaveLen(2)) + + Expect(teams[0].Name).To(Equal("main")) + Expect(teams[1].Name).To(Equal("team-a")) + + expectedTeamAuth := atc.TeamAuth{ + "member": {"groups": nil, "users": nil}, + "owner": {"groups": nil, "users": nil}, + "viewer": {"groups": nil, "users": nil}, + + "pipeline-operator": { + "groups": nil, + "users": {"github:tlwr"}, + }, + } + + Expect(teams[1].Auth).To(Equal(expectedTeamAuth)) + + return nil + }, + ), + }, + + resource.TestStep{ + // Delete the team + + Config: `# Cannot be empty`, + + Check: resource.ComposeTestCheckFunc( + func(s *terraform.State) error { + By("Deleting the team") + + fmt.Printf("%+v\n", s) + return nil + }, + + func(s *terraform.State) error { + Expect(s.RootModule().Resources).To(HaveLen(0)) + return nil + }, + + func(s *terraform.State) error { + teams, err := client.ListTeams() + + if err != nil { + return nil + } + + Expect(teams).To(HaveLen(1)) + + Expect(teams[0].Name).To(Equal("main")) + + return nil + }, + ), + }, + }, + + CheckDestroy: resource.ComposeTestCheckFunc( + func(s *terraform.State) error { + teams, err := client.ListTeams() + + if err != nil { + return nil + } + + Expect(teams).To(HaveLen(1)) + + Expect(teams[0].Name).To(Equal("main")) + + return nil + }, + ), + }) + }) +}) From 2d8b34508e2ec6dfeec14491174d4ac27b25bf8a Mon Sep 17 00:00:00 2001 From: Toby Lorne Date: Sat, 26 Oct 2019 14:29:02 +0100 Subject: [PATCH 03/17] Add failing test for renaming teams There is a bug where renaming a team just creates a new one with the new config. Add a failing test for this Signed-off-by: Toby Lorne --- integration-tests/user_mgmt.go | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/integration-tests/user_mgmt.go b/integration-tests/user_mgmt.go index f7916bc..64559ab 100644 --- a/integration-tests/user_mgmt.go +++ b/integration-tests/user_mgmt.go @@ -193,6 +193,61 @@ var _ = Describe("User management", func() { ), }, + resource.TestStep{ + // Rename the team + + Config: `resource "concourse_team" "a_team" { + team_name = "team-a-renamed" + + pipeline_operators = ["user:github:tlwr"] + }`, + + Check: resource.ComposeTestCheckFunc( + func(s *terraform.State) error { + By("Renaming the team") + + fmt.Printf("%+v\n", s) + return nil + }, + + resource.TestCheckResourceAttr("concourse_team.a_team", "team_name", "team-a-renamed"), + + resource.TestCheckResourceAttr("concourse_team.a_team", "owners.#", "0"), + resource.TestCheckResourceAttr("concourse_team.a_team", "members.#", "0"), + resource.TestCheckResourceAttr("concourse_team.a_team", "pipeline_operators.#", "1"), + resource.TestCheckResourceAttr("concourse_team.a_team", "pipeline_operators.0", "user:github:tlwr"), + resource.TestCheckResourceAttr("concourse_team.a_team", "viewers.#", "0"), + + func(s *terraform.State) error { + teams, err := client.ListTeams() + + if err != nil { + return nil + } + + Expect(teams).To(HaveLen(2)) + + Expect(teams[0].Name).To(Equal("main")) + Expect(teams[1].Name).To(Equal("team-a-renamed")) + + expectedTeamAuth := atc.TeamAuth{ + "member": {"groups": nil, "users": nil}, + "owner": {"groups": nil, "users": nil}, + "viewer": {"groups": nil, "users": nil}, + + "pipeline-operator": { + "groups": nil, + "users": {"github:tlwr"}, + }, + } + + Expect(teams[1].Auth).To(Equal(expectedTeamAuth)) + + return nil + }, + ), + }, + resource.TestStep{ // Delete the team From c0c9c482801bfdde367b00d8bb3dd1e8a1770532 Mon Sep 17 00:00:00 2001 From: Toby Lorne Date: Sat, 26 Oct 2019 14:44:55 +0100 Subject: [PATCH 04/17] Fix bug where renaming a team created a new team Signed-off-by: Toby Lorne --- integration-tests/{user_mgmt.go => team_mgmt.go} | 2 +- pkg/provider/team.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) rename integration-tests/{user_mgmt.go => team_mgmt.go} (99%) diff --git a/integration-tests/user_mgmt.go b/integration-tests/team_mgmt.go similarity index 99% rename from integration-tests/user_mgmt.go rename to integration-tests/team_mgmt.go index 64559ab..3bc277d 100644 --- a/integration-tests/user_mgmt.go +++ b/integration-tests/team_mgmt.go @@ -20,7 +20,7 @@ var _ = Describe("User management", func() { AfterEach(TeardownTest) AfterSuite(TeardownSuite) - It("should create, update, and destroy users", func() { + It("should create, update, rename, and delete a team", func() { providers := map[string]terraform.ResourceProvider{ "concourse": provider.Provider(), } diff --git a/pkg/provider/team.go b/pkg/provider/team.go index c643c34..cbaa135 100644 --- a/pkg/provider/team.go +++ b/pkg/provider/team.go @@ -335,6 +335,14 @@ func resourceTeamUpdate(d *schema.ResourceData, m interface{}) error { team := client.Team(teamName) + if d.HasChange("team_name") { + _, err := team.RenameTeam(d.Id(), d.Get("team_name").(string)) + + if err != nil { + return fmt.Errorf("Could not rename team %s", teamName) + } + } + _, created, updated, err := team.CreateOrUpdate(teamDetails) if err != nil { From 4852d087e266048d67d63a420897649fa4431422 Mon Sep 17 00:00:00 2001 From: Toby Lorne Date: Sat, 26 Oct 2019 14:58:05 +0100 Subject: [PATCH 05/17] Add test for adding groups Signed-off-by: Toby Lorne --- integration-tests/team_mgmt.go | 83 +++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 22 deletions(-) diff --git a/integration-tests/team_mgmt.go b/integration-tests/team_mgmt.go index 3bc277d..3fe17d9 100644 --- a/integration-tests/team_mgmt.go +++ b/integration-tests/team_mgmt.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform/terraform" ) -var _ = Describe("User management", func() { +var _ = Describe("Team management", func() { BeforeSuite(SetupSuite) BeforeEach(SetupTest) AfterEach(TeardownTest) @@ -121,14 +121,10 @@ var _ = Describe("User management", func() { Expect(teams[1].Name).To(Equal("team-a")) expectedTeamAuth := atc.TeamAuth{ + "owner": {"groups": nil, "users": {"github:tlwr"}}, "member": {"groups": nil, "users": nil}, "pipeline-operator": {"groups": nil, "users": nil}, "viewer": {"groups": nil, "users": nil}, - - "owner": { - "groups": nil, - "users": {"github:tlwr"}, - }, } Expect(teams[1].Auth).To(Equal(expectedTeamAuth)) @@ -176,14 +172,61 @@ var _ = Describe("User management", func() { Expect(teams[1].Name).To(Equal("team-a")) expectedTeamAuth := atc.TeamAuth{ - "member": {"groups": nil, "users": nil}, - "owner": {"groups": nil, "users": nil}, - "viewer": {"groups": nil, "users": nil}, - - "pipeline-operator": { - "groups": nil, - "users": {"github:tlwr"}, - }, + "owner": {"groups": nil, "users": nil}, + "member": {"groups": nil, "users": nil}, + "pipeline-operator": {"groups": nil, "users": {"github:tlwr"}}, + "viewer": {"groups": nil, "users": nil}, + } + + Expect(teams[1].Auth).To(Equal(expectedTeamAuth)) + + return nil + }, + ), + }, + + resource.TestStep{ + // Removing a user, adding a group + + Config: `resource "concourse_team" "a_team" { + team_name = "team-a" + + owners = ["group:github:alphagov:paas-team"] + }`, + + Check: resource.ComposeTestCheckFunc( + func(s *terraform.State) error { + By("Removing a user, adding a group") + + fmt.Printf("%+v\n", s) + return nil + }, + + resource.TestCheckResourceAttr("concourse_team.a_team", "team_name", "team-a"), + + resource.TestCheckResourceAttr("concourse_team.a_team", "owners.#", "1"), + resource.TestCheckResourceAttr("concourse_team.a_team", "owners.0", "group:github:alphagov:paas-team"), + resource.TestCheckResourceAttr("concourse_team.a_team", "members.#", "0"), + resource.TestCheckResourceAttr("concourse_team.a_team", "pipeline_operators.#", "0"), + resource.TestCheckResourceAttr("concourse_team.a_team", "viewers.#", "0"), + + func(s *terraform.State) error { + teams, err := client.ListTeams() + + if err != nil { + return nil + } + + Expect(teams).To(HaveLen(2)) + + Expect(teams[0].Name).To(Equal("main")) + Expect(teams[1].Name).To(Equal("team-a")) + + expectedTeamAuth := atc.TeamAuth{ + "owner": {"groups": {"github:alphagov:paas-team"}, "users": nil}, + "member": {"groups": nil, "users": nil}, + "pipeline-operator": {"groups": nil, "users": nil}, + "viewer": {"groups": nil, "users": nil}, } Expect(teams[1].Auth).To(Equal(expectedTeamAuth)) @@ -231,14 +274,10 @@ var _ = Describe("User management", func() { Expect(teams[1].Name).To(Equal("team-a-renamed")) expectedTeamAuth := atc.TeamAuth{ - "member": {"groups": nil, "users": nil}, - "owner": {"groups": nil, "users": nil}, - "viewer": {"groups": nil, "users": nil}, - - "pipeline-operator": { - "groups": nil, - "users": {"github:tlwr"}, - }, + "owner": {"groups": nil, "users": nil}, + "member": {"groups": nil, "users": nil}, + "pipeline-operator": {"groups": nil, "users": {"github:tlwr"}}, + "viewer": {"groups": nil, "users": nil}, } Expect(teams[1].Auth).To(Equal(expectedTeamAuth)) From 6f88b4e32c62b0b2b4072058cefcd9d273d12961 Mon Sep 17 00:00:00 2001 From: Toby Lorne Date: Sat, 26 Oct 2019 16:11:24 +0100 Subject: [PATCH 06/17] Add integration test for pipeline mgmt Signed-off-by: Toby Lorne --- integration-tests/pipeline_mgmt.go | 405 +++++++++++++++++++++++++++++ integration-tests/suite_test.go | 3 + integration-tests/team_mgmt.go | 4 +- 3 files changed, 409 insertions(+), 3 deletions(-) create mode 100644 integration-tests/pipeline_mgmt.go diff --git a/integration-tests/pipeline_mgmt.go b/integration-tests/pipeline_mgmt.go new file mode 100644 index 0000000..41c1ae2 --- /dev/null +++ b/integration-tests/pipeline_mgmt.go @@ -0,0 +1,405 @@ +package integration_tests + +import ( + "fmt" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/alphagov/terraform-provider-concourse/pkg/provider" + + "github.com/hashicorp/terraform/helper/resource" + // "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/terraform" +) + +var _ = Describe("Pipeline management", func() { + BeforeEach(SetupTest) + AfterEach(TeardownTest) + + const ( + pipelineConfig = `# +resources: + - name: every-midnight + type: time + source: + location: Europe/London + start: 12:00AM + stop: 12:15AM + +jobs: + - name: check-the-time + serial: true + plan: + - get: every-midnight + trigger: true +` + + pipelineConfigJSON = `{"jobs":[{"name":"check-the-time","plan":[{"get":"every-midnight","trigger":true}],"serial":true}],"resources":[{"name":"every-midnight","source":{"location":"Europe/London","start":"12:00AM","stop":"12:15AM"},"type":"time"}]}` + + updatedPipelineConfig = `# +resources: + - name: every-midnight + type: time + source: + location: Europe/London + start: 12:00AM + stop: 12:15AM + +jobs: + - name: check-the-time-on-demand + serial: true + plan: + - get: every-midnight +` + updatedPipelineConfigJSON = `{"jobs":[{"name":"check-the-time-on-demand","plan":[{"get":"every-midnight"}],"serial":true}],"resources":[{"name":"every-midnight","source":{"location":"Europe/London","start":"12:00AM","stop":"12:15AM"},"type":"time"}]}` + ) + + It("should manage the lifecycle of a pipeline", func() { + providers := map[string]terraform.ResourceProvider{ + "concourse": provider.Provider(), + } + + client, err := NewConcourseClient() + + Expect(err).NotTo(HaveOccurred()) + + resource.Test(NewGinkoTerraformTestingT(), resource.TestCase{ + IsUnitTest: false, + + Providers: providers, + + Steps: []resource.TestStep{ + resource.TestStep{ + // Add a pipeline + + Config: fmt.Sprintf(`data "concourse_team" "main_team" { + team_name = "main" + } + + resource "concourse_team" "other_team" { + team_name = "other" + } + + resource "concourse_pipeline" "a_pipeline" { + team_name = "${data.concourse_team.main_team.team_name}" + pipeline_name = "pipeline-a" + + is_exposed = false + is_paused = false + + pipeline_config_format = "yaml" + pipeline_config = < Date: Sat, 26 Oct 2019 16:15:48 +0100 Subject: [PATCH 07/17] Add failing test for moving pipeline between teams There is a bug where moving a pipeline between teams just creates a new one with the new config. Add a failing test for this Signed-off-by: Toby Lorne --- integration-tests/pipeline_mgmt.go | 64 ++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/integration-tests/pipeline_mgmt.go b/integration-tests/pipeline_mgmt.go index 41c1ae2..a68d93d 100644 --- a/integration-tests/pipeline_mgmt.go +++ b/integration-tests/pipeline_mgmt.go @@ -326,6 +326,70 @@ jobs: ), }, + resource.TestStep{ + // Move a pipeline from one team to another + + Config: fmt.Sprintf(`data "concourse_team" "main_team" { + team_name = "main" + } + + resource "concourse_team" "other_team" { + team_name = "other" + } + + resource "concourse_pipeline" "a_pipeline" { + team_name = "${concourse_team.other_team.team_name}" + pipeline_name = "pipeline-a" + + is_exposed = false + is_paused = false + + pipeline_config_format = "yaml" + pipeline_config = < Date: Sat, 26 Oct 2019 16:35:09 +0100 Subject: [PATCH 08/17] Fix bug: moving pipeline between teams duplicated Signed-off-by: Toby Lorne --- pkg/provider/pipeline.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/provider/pipeline.go b/pkg/provider/pipeline.go index e7805d0..82b19eb 100644 --- a/pkg/provider/pipeline.go +++ b/pkg/provider/pipeline.go @@ -3,6 +3,7 @@ package provider import ( "encoding/json" "fmt" + "strings" "github.com/concourse/concourse/go-concourse/concourse" "github.com/hashicorp/terraform/helper/schema" @@ -245,6 +246,25 @@ func resourcePipelineRead(d *schema.ResourceData, m interface{}) error { func resourcePipelineUpdate(d *schema.ResourceData, m interface{}) error { client := m.(*ProviderConfig).Client + + if d.HasChange("team_name") && d.Id() != "" { + // Concourse does not yet have support for moving pipeline, so we should + // delete the pipeline from the old team + + oldTeamName := strings.SplitN(d.Id(), ":", 2)[0] + oldPipelineName := strings.SplitN(d.Id(), ":", 2)[1] + + team := client.Team(oldTeamName) + _, err := team.DeletePipeline(oldPipelineName) + + if err != nil { + return fmt.Errorf( + "Error deleting old pipeline %s in team %s: %s", + oldPipelineName, oldTeamName, err, + ) + } + } + pipelineName := d.Get("pipeline_name").(string) teamName := d.Get("team_name").(string) d.SetId(pipelineID(teamName, pipelineName)) From f232875a8b8f31184a2b89592b7a97e6307f20d2 Mon Sep 17 00:00:00 2001 From: Toby Lorne Date: Sat, 26 Oct 2019 16:39:44 +0100 Subject: [PATCH 09/17] Add failing test for renaming pipelines There is a bug where renaming a pipeline just creates a new one with the new config. Add a failing test for this Signed-off-by: Toby Lorne --- integration-tests/pipeline_mgmt.go | 64 ++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/integration-tests/pipeline_mgmt.go b/integration-tests/pipeline_mgmt.go index a68d93d..5971e47 100644 --- a/integration-tests/pipeline_mgmt.go +++ b/integration-tests/pipeline_mgmt.go @@ -390,6 +390,70 @@ jobs: ), }, + resource.TestStep{ + // Rename the pipeline + + Config: fmt.Sprintf(`data "concourse_team" "main_team" { + team_name = "main" + } + + resource "concourse_team" "other_team" { + team_name = "other" + } + + resource "concourse_pipeline" "a_pipeline" { + team_name = "${concourse_team.other_team.team_name}" + pipeline_name = "pipeline-a-renamed" + + is_exposed = false + is_paused = false + + pipeline_config_format = "yaml" + pipeline_config = < Date: Sat, 26 Oct 2019 16:45:16 +0100 Subject: [PATCH 10/17] Fix bug: renaming pipeline teams duplicated it Signed-off-by: Toby Lorne --- pkg/provider/pipeline.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/provider/pipeline.go b/pkg/provider/pipeline.go index 82b19eb..88937f6 100644 --- a/pkg/provider/pipeline.go +++ b/pkg/provider/pipeline.go @@ -265,6 +265,23 @@ func resourcePipelineUpdate(d *schema.ResourceData, m interface{}) error { } } + if d.HasChange("pipeline_name") && !d.HasChange("team_name") && d.Id() != "" { + teamName := strings.SplitN(d.Id(), ":", 2)[0] + oldPipelineName := strings.SplitN(d.Id(), ":", 2)[1] + newPipelineName := d.Get("pipeline_name").(string) + + team := client.Team(teamName) + + _, err := team.RenamePipeline(oldPipelineName, newPipelineName) + + if err != nil { + return fmt.Errorf( + "Error renaming pipeline %s to %s in team %s: %s", + oldPipelineName, newPipelineName, teamName, err, + ) + } + } + pipelineName := d.Get("pipeline_name").(string) teamName := d.Get("team_name").(string) d.SetId(pipelineID(teamName, pipelineName)) From ac0385576e8c005258eab1c473fee09123a99fd1 Mon Sep 17 00:00:00 2001 From: Toby Lorne Date: Sat, 26 Oct 2019 17:00:09 +0100 Subject: [PATCH 11/17] Add Makefile for running tests Signed-off-by: Toby Lorne --- Makefile | 7 +++++++ go.sum | 11 +++++++++++ {integration-tests => integration}/pipeline_mgmt.go | 2 +- {integration-tests => integration}/setup_test.go | 2 +- {integration-tests => integration}/suite_test.go | 2 +- {integration-tests => integration}/team_mgmt.go | 2 +- 6 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 Makefile rename {integration-tests => integration}/pipeline_mgmt.go (99%) rename {integration-tests => integration}/setup_test.go (98%) rename {integration-tests => integration}/suite_test.go (90%) rename {integration-tests => integration}/team_mgmt.go (99%) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..84c255a --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: build +build: + go build -o terraform-provider-concourse + +.PHONY: integration-tests +integration-tests: + go test -count 1 -v ./integration diff --git a/go.sum b/go.sum index 7675b5f..3a157c0 100644 --- a/go.sum +++ b/go.sum @@ -12,6 +12,7 @@ code.cloudfoundry.org/clock v0.0.0-20180518195852-02e53af36e6c/go.mod h1:QD9Lzhd code.cloudfoundry.org/credhub-cli v0.0.0-20190415201820-e3951663d25c/go.mod h1:oZAAU/4R7ssJ+kighWL4VLyyyY+Utm8H9r721AE3edQ= code.cloudfoundry.org/garden v0.0.0-20181108172608-62470dc86365/go.mod h1:9edl55ou1627lC7chvtltZ561+iITkNTzkZsLgohU8s= code.cloudfoundry.org/lager v1.1.0/go.mod h1:O2sS7gKP3HM2iemG+EnwvyNQK7pTSC6Foi4QiMp9sSk= +code.cloudfoundry.org/lager v2.0.0+incompatible h1:WZwDKDB2PLd/oL+USK4b4aEjUymIej9My2nUQ9oWEwQ= code.cloudfoundry.org/lager v2.0.0+incompatible/go.mod h1:O2sS7gKP3HM2iemG+EnwvyNQK7pTSC6Foi4QiMp9sSk= code.cloudfoundry.org/localip v0.0.0-20170223024724-b88ad0dea95c/go.mod h1:q9OZPRxTlJybLg3Qb0b3R+hYgJBk5/Gi05gKB8O/lSU= code.cloudfoundry.org/urljoiner v0.0.0-20170223060717-5cabba6c0a50/go.mod h1:GyubIUn2eHGSlpIqJhGKBKicAe6CUV/pQJosfNEHdo4= @@ -28,6 +29,7 @@ github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022/go.mod h1:nu github.com/DataDog/datadog-go v0.0.0-20180702141236-ef3a9daf849d/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.4.0/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/Jeffail/gabs v1.1.0/go.mod h1:6xMvQMK4k33lb7GUUpaAPh6nKMmemQeg5d4gn7/bOXc= +github.com/Masterminds/squirrel v0.0.0-20190107164353-fa735ea14f09 h1:enWVS77aJkLWVIUExiqF6A8eWTVzCXUKUvkST3/wyKI= github.com/Masterminds/squirrel v0.0.0-20190107164353-fa735ea14f09/go.mod h1:yaPeOnPG5ZRwL9oKdTsO/prlkPbXWZlRVMQ/gGlzIuA= github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= @@ -94,6 +96,7 @@ github.com/briankassouf/jose v0.9.1/go.mod h1:HQhVmdUf7dBNwIIdBTivnCDxcf6IZY3/zr github.com/bsm/go-vlq v0.0.0-20150828105119-ec6e8d4f5f4e/go.mod h1:N+BjUcTjSxc2mtRGSCPsat1kze3CUtvJN3/jTXlp29k= github.com/caarlos0/env v3.5.0+incompatible/go.mod h1:tdCsowwCzMLdkqRYDlHpZCp2UooDD3MspDBjZ2AD02Y= github.com/cenkalti/backoff v2.0.0+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/cenkalti/backoff v2.1.1+incompatible h1:tKJnvO2kl0zmb/jA5UKAt4VoEVw1qxKWjE/Bpp46npY= github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -122,6 +125,7 @@ github.com/concourse/go-archive v0.0.0-20180803203406-784931698f4f/go.mod h1:Xfo github.com/concourse/go-archive v1.0.0/go.mod h1:Xfo080IPQBmVz3I5ehjCddW3phA2mwv0NFwlpjf5CO8= github.com/concourse/go-archive v1.0.1/go.mod h1:Xfo080IPQBmVz3I5ehjCddW3phA2mwv0NFwlpjf5CO8= github.com/concourse/retryhttp v0.0.0-20170802173037-937335fd9545/go.mod h1:4+V9YCkKuoV7rg+/No+ZM9FsO3BK4tIJNUiYMI7nki0= +github.com/concourse/retryhttp v1.0.2 h1:Qlag8vPBvXN79XyuM+XSf0/+jIYWnnivPwaa3ijbgdk= github.com/concourse/retryhttp v1.0.2/go.mod h1:t/8nUqzPriXrWczdqI7tHoEvFe+tJplQHS/fO3BzdlA= github.com/containerd/continuity v0.0.0-20180919190352-508d86ade3c2/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/coreos/bbolt v1.3.0/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= @@ -187,6 +191,7 @@ github.com/go-stomp/stomp v2.0.2+incompatible/go.mod h1:VqCtqNZv1226A1/79yh+rMiF github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/gobuffalo/packr v1.13.7 h1:2uZgLd6b/W4yRBZV/ScaORxZLNGMHO0VCvqQNkKukNA= github.com/gobuffalo/packr v1.13.7/go.mod h1:KkinLIn/n6+3tVXMwg6KkNvWwVsrRAz4ph+jgpk3Z24= github.com/gocql/gocql v0.0.0-20180920092337-799fb0373110/go.mod h1:4Fw1eo5iaEhDUs8XyuhSVCVy52Jq3L+/3GJgYkwc+/0= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -371,9 +376,12 @@ github.com/krishicks/yaml-patch v0.0.10/go.mod h1:Sm5TchwZS6sm7RJoyg87tzxm2ZcKzd github.com/kylelemons/godebug v0.0.0-20160406211939-eadb3ce320cb/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw= github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o= +github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk= github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw= github.com/lib/pq v0.0.0-20181016162627-9eb73efc1fcc/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lusis/go-artifactory v0.0.0-20160115162124-7e4ce345df82/go.mod h1:y54tfGmO3NKssKveTEFFzH8C/akrSOy/iW9qEAUDV84= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -433,6 +441,7 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= @@ -455,6 +464,7 @@ github.com/ory-am/common v0.4.0/go.mod h1:oCYGuwwM8FyYMKqh9vrhBaeUoyz/edx0bgJN6u github.com/ory/dockertest v3.3.2+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/packer-community/winrmcp v0.0.0-20180102160824-81144009af58/go.mod h1:f6Izs6JvFTdnRbziASagjZ2vmf55NSIkC/weStxCHqk= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/peterhellberg/link v1.0.0 h1:mUWkiegowUXEcmlb+ybF75Q/8D2Y0BjZtR8cxoKhaQo= @@ -462,6 +472,7 @@ github.com/peterhellberg/link v1.0.0/go.mod h1:gtSlOT4jmkY8P47hbTc8PTgiDDWpdPbFY github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ= github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/integration-tests/pipeline_mgmt.go b/integration/pipeline_mgmt.go similarity index 99% rename from integration-tests/pipeline_mgmt.go rename to integration/pipeline_mgmt.go index 5971e47..d6f08d6 100644 --- a/integration-tests/pipeline_mgmt.go +++ b/integration/pipeline_mgmt.go @@ -1,4 +1,4 @@ -package integration_tests +package integration import ( "fmt" diff --git a/integration-tests/setup_test.go b/integration/setup_test.go similarity index 98% rename from integration-tests/setup_test.go rename to integration/setup_test.go index 5aa12ac..0c6dd29 100644 --- a/integration-tests/setup_test.go +++ b/integration/setup_test.go @@ -1,4 +1,4 @@ -package integration_tests +package integration import ( "fmt" diff --git a/integration-tests/suite_test.go b/integration/suite_test.go similarity index 90% rename from integration-tests/suite_test.go rename to integration/suite_test.go index 360ee8a..5f9be77 100644 --- a/integration-tests/suite_test.go +++ b/integration/suite_test.go @@ -1,4 +1,4 @@ -package integration_tests +package integration import ( "testing" diff --git a/integration-tests/team_mgmt.go b/integration/team_mgmt.go similarity index 99% rename from integration-tests/team_mgmt.go rename to integration/team_mgmt.go index 8be2796..ef0cfe6 100644 --- a/integration-tests/team_mgmt.go +++ b/integration/team_mgmt.go @@ -1,4 +1,4 @@ -package integration_tests +package integration import ( "fmt" From 1d70c3541ba6873a66b308ae23419a7283d93149 Mon Sep 17 00:00:00 2001 From: Toby Lorne Date: Sat, 26 Oct 2019 17:09:34 +0100 Subject: [PATCH 12/17] Remove disclaimer We've used this a bunch now and it has tests Signed-off-by: Toby Lorne --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 4e6bf1c..9b29c84 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,6 @@ A terraform provider for concourse `fly` is an amazing tool, but configuration using scripts running fly is not ideal. -## Disclaimer - -This is an incredibly early piece of software and should not be relied upon for production use. - ## Prerequisites Install `go`, `glide`, and `terraform`. From 8454514868875d889abd2c4dc9f00cf174710504 Mon Sep 17 00:00:00 2001 From: Toby Lorne Date: Sat, 26 Oct 2019 17:12:21 +0100 Subject: [PATCH 13/17] Add local user docs to README Signed-off-by: Toby Lorne --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 9b29c84..4052354 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,20 @@ provider "concourse" { } ``` +## Create a provider (using a local username and password) + +Note: this is not basic authentication + +``` +provider "concourse" { + url = "https://wings.pivotal.io" + team = "main" + + username = "localuser" + password = "very-secure-password" +} +``` + ## Look up a team ``` From 384f84b2352988b01d18f6b0143c583abcfcb09c Mon Sep 17 00:00:00 2001 From: Toby Lorne Date: Sat, 26 Oct 2019 17:12:30 +0100 Subject: [PATCH 14/17] Tweak docs about users/groups Signed-off-by: Toby Lorne --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4052354..a518ea3 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,10 @@ output "my_pipeline_yaml" { Supports `owners`, `members`, `pipeline_operators`, and `viewers`. -User and groups are adopted by prefixing the strings with `user:` or `group:`. +Specify users and groups by prefixing the strings: + +* `user:` +* `group:` ``` resource "concourse_team" "my_team" { From a5b7a07a59fcb03769cee8c23a68dbda2c07df3f Mon Sep 17 00:00:00 2001 From: Toby Lorne Date: Sat, 26 Oct 2019 17:13:31 +0100 Subject: [PATCH 15/17] Add github action for CI Signed-off-by: Toby Lorne --- .github/workflows/ci.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c47277e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,21 @@ +name: ci + +on: [push] + +jobs: + + build: + name: build + runs-on: ubuntu-latest + steps: + - name: setup + uses: actions/setup-go@v1 + with: + go-version: 1.12 + id: go + + - name: checkout + uses: actions/checkout@v1 + + - name: integration-tests + run: make integration-tests From b86fd6b6b01f7c4ee5bf727e669f81e3e8375934 Mon Sep 17 00:00:00 2001 From: Toby Lorne Date: Sat, 26 Oct 2019 17:14:01 +0100 Subject: [PATCH 16/17] Update go to 1.13 Signed-off-by: Toby Lorne --- .github/workflows/ci.yml | 2 +- go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c47277e..ab885a5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: - name: setup uses: actions/setup-go@v1 with: - go-version: 1.12 + go-version: 1.13 id: go - name: checkout diff --git a/go.mod b/go.mod index 85607ac..debfc21 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/alphagov/terraform-provider-concourse -go 1.12 +go 1.13 require ( github.com/concourse/concourse v5.5.1+incompatible From fc81998d6d4dc54773d93ebf71a6c164be8b600c Mon Sep 17 00:00:00 2001 From: Toby Lorne Date: Sat, 26 Oct 2019 17:21:13 +0100 Subject: [PATCH 17/17] Increase Concourse wait time GitHub actions is slow to boot Concourse Signed-off-by: Toby Lorne --- integration/setup_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/setup_test.go b/integration/setup_test.go index 0c6dd29..441080f 100644 --- a/integration/setup_test.go +++ b/integration/setup_test.go @@ -72,7 +72,7 @@ func SetupTest() { fmt.Println("Concourse is ready") return nil - }, "15s", "3s").ShouldNot(HaveOccurred()) + }, "60s", "3s").ShouldNot(HaveOccurred()) } func TeardownTest() {