From 1200919d3a0efe82c0ba1dfe0d006248a82b48ea Mon Sep 17 00:00:00 2001 From: Ringo De Smet Date: Wed, 1 Apr 2020 16:58:24 +0200 Subject: [PATCH 1/9] Lower the time out to end before GH Actions times out --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 19f0b7683..f3f8394e0 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -14,7 +14,7 @@ test: fmtcheck xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4 testacc: fmtcheck - TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m + TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 40m vet: @echo "go vet ." From 122ba85d78bd0b0bd5c614b5aef445404116c985 Mon Sep 17 00:00:00 2001 From: Ringo De Smet Date: Wed, 1 Apr 2020 18:06:14 +0200 Subject: [PATCH 2/9] Run the EE acceptance tests with DEBUG logging --- .github/workflows/acceptance-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/acceptance-tests.yml b/.github/workflows/acceptance-tests.yml index d0c87a692..3709d6629 100644 --- a/.github/workflows/acceptance-tests.yml +++ b/.github/workflows/acceptance-tests.yml @@ -59,6 +59,7 @@ jobs: echo "::set-env name=GO111MODULE::on" echo "::set-env name=GITLAB_TOKEN::20char-testing-token" echo "::set-env name=GITLAB_BASE_URL::http://127.0.0.1:8080/api/v4" + echo "::set-env name=TF_LOG::DEBUG" - name: Start Gitlab and run acceptance tests run: | From e8641687e4975951f274aa14d03c925873bbce14 Mon Sep 17 00:00:00 2001 From: Ringo De Smet Date: Wed, 1 Apr 2020 18:46:20 +0200 Subject: [PATCH 3/9] Benefit from Go 1.14 streaming test output --- .github/workflows/acceptance-tests.yml | 4 ++-- .github/workflows/unit-tests.yml | 2 +- .github/workflows/website.yml | 2 +- GNUmakefile | 4 ++-- go.mod | 2 +- vendor/modules.txt | 14 ++++++++++++++ 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/acceptance-tests.yml b/.github/workflows/acceptance-tests.yml index 3709d6629..2bcbfd9ec 100644 --- a/.github/workflows/acceptance-tests.yml +++ b/.github/workflows/acceptance-tests.yml @@ -9,7 +9,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v1 with: - go-version: 1.12 + go-version: 1.14 id: go - name: Check out code repository source code @@ -36,7 +36,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v1 with: - go-version: 1.12 + go-version: 1.14 id: go - name: Check out code repository source code diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 6685173ba..0b3f47abe 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - go: [1.12, 1.13, 1.14] + go: [1.13, 1.14] os: [ubuntu-latest, macos-latest, windows-latest] make_target: [test, vet] diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index cc7bc66c2..1a992f12e 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -9,7 +9,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v1 with: - go-version: 1.12 + go-version: 1.14 id: go # https://help.github.com/en/actions/reference/workflow-commands-for-github-actions diff --git a/GNUmakefile b/GNUmakefile index f3f8394e0..af823a17b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,4 +1,4 @@ -TEST?=$$(go list ./... |grep -v 'vendor') +TEST?=./gitlab GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor) WEBSITE_REPO=github.com/hashicorp/terraform-website PKG_NAME=gitlab @@ -14,7 +14,7 @@ test: fmtcheck xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4 testacc: fmtcheck - TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 40m + TF_ACC=1 go test -v $(TEST) $(TESTARGS) -timeout 40m vet: @echo "go vet ." diff --git a/go.mod b/go.mod index 5e42f0bc0..82924e813 100644 --- a/go.mod +++ b/go.mod @@ -17,4 +17,4 @@ require ( golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 // indirect ) -go 1.13 +go 1.14 diff --git a/vendor/modules.txt b/vendor/modules.txt index 711804a2e..86a5c9d97 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -7,6 +7,7 @@ cloud.google.com/go/internal/optional cloud.google.com/go/internal/trace cloud.google.com/go/internal/version # cloud.google.com/go/storage v1.6.0 +## explicit cloud.google.com/go/storage # github.com/BurntSushi/toml v0.3.1 github.com/BurntSushi/toml @@ -19,6 +20,7 @@ github.com/apparentlymart/go-textseg/textseg # github.com/armon/go-radix v1.0.0 github.com/armon/go-radix # github.com/aws/aws-sdk-go v1.29.30 +## explicit github.com/aws/aws-sdk-go/aws github.com/aws/aws-sdk-go/aws/arn github.com/aws/aws-sdk-go/aws/awserr @@ -103,6 +105,7 @@ github.com/hashicorp/go-cleanhttp github.com/hashicorp/go-getter github.com/hashicorp/go-getter/helper/url # github.com/hashicorp/go-hclog v0.12.1 +## explicit github.com/hashicorp/go-hclog # github.com/hashicorp/go-multierror v1.0.0 github.com/hashicorp/go-multierror @@ -118,6 +121,7 @@ github.com/hashicorp/go-uuid # github.com/hashicorp/go-version v1.2.0 github.com/hashicorp/go-version # github.com/hashicorp/hcl v1.0.0 +## explicit github.com/hashicorp/hcl github.com/hashicorp/hcl/hcl/ast github.com/hashicorp/hcl/hcl/parser @@ -128,6 +132,7 @@ github.com/hashicorp/hcl/json/parser github.com/hashicorp/hcl/json/scanner github.com/hashicorp/hcl/json/token # github.com/hashicorp/hcl/v2 v2.3.0 +## explicit github.com/hashicorp/hcl/v2 github.com/hashicorp/hcl/v2/ext/customdecode github.com/hashicorp/hcl/v2/ext/dynblock @@ -142,10 +147,12 @@ github.com/hashicorp/hcl/v2/json # github.com/hashicorp/logutils v1.0.0 github.com/hashicorp/logutils # github.com/hashicorp/terraform-config-inspect v0.0.0-20200210163047-f7d8399e1194 +## explicit github.com/hashicorp/terraform-config-inspect/tfconfig # github.com/hashicorp/terraform-json v0.4.0 github.com/hashicorp/terraform-json # github.com/hashicorp/terraform-plugin-sdk v1.8.0 +## explicit github.com/hashicorp/terraform-plugin-sdk/acctest github.com/hashicorp/terraform-plugin-sdk/helper/acctest github.com/hashicorp/terraform-plugin-sdk/helper/hashcode @@ -194,10 +201,12 @@ github.com/hashicorp/terraform-plugin-sdk/terraform # github.com/hashicorp/terraform-plugin-test v1.2.0 github.com/hashicorp/terraform-plugin-test # github.com/hashicorp/terraform-svchost v0.0.0-20191119180714-d2e4933b9136 +## explicit github.com/hashicorp/terraform-svchost github.com/hashicorp/terraform-svchost/auth github.com/hashicorp/terraform-svchost/disco # github.com/hashicorp/yamux v0.0.0-20190923154419-df201c70410d +## explicit github.com/hashicorp/yamux # github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af github.com/jmespath/go-jmespath @@ -228,6 +237,7 @@ github.com/mitchellh/reflectwalk # github.com/oklog/run v1.0.0 github.com/oklog/run # github.com/posener/complete v1.2.3 +## explicit github.com/posener/complete github.com/posener/complete/cmd github.com/posener/complete/cmd/install @@ -235,14 +245,17 @@ github.com/posener/complete/cmd/install github.com/spf13/afero github.com/spf13/afero/mem # github.com/ulikunitz/xz v0.5.7 +## explicit github.com/ulikunitz/xz github.com/ulikunitz/xz/internal/hash github.com/ulikunitz/xz/internal/xlog github.com/ulikunitz/xz/lzma # github.com/vmihailenco/msgpack v4.0.4+incompatible +## explicit github.com/vmihailenco/msgpack github.com/vmihailenco/msgpack/codes # github.com/xanzy/go-gitlab v0.29.0 +## explicit github.com/xanzy/go-gitlab # github.com/zclconf/go-cty v1.2.1 github.com/zclconf/go-cty/cty @@ -273,6 +286,7 @@ go.opencensus.io/trace/internal go.opencensus.io/trace/propagation go.opencensus.io/trace/tracestate # golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 +## explicit golang.org/x/crypto/bcrypt golang.org/x/crypto/blowfish golang.org/x/crypto/cast5 From 11f3c43351c2716700014ffc774ab590b810ff1d Mon Sep 17 00:00:00 2001 From: Ringo De Smet Date: Fri, 3 Apr 2020 20:28:20 +0200 Subject: [PATCH 4/9] Update go-gitlab to v0.30.1 --- go.mod | 2 +- go.sum | 13 +- vendor/github.com/xanzy/go-gitlab/README.md | 3 +- .../xanzy/go-gitlab/applications.go | 100 +++++++++++++ .../xanzy/go-gitlab/event_webhook_types.go | 1 + vendor/github.com/xanzy/go-gitlab/gitlab.go | 2 + .../xanzy/go-gitlab/group_clusters.go | 23 +-- .../github.com/xanzy/go-gitlab/group_hooks.go | 136 +++++++++++++++++- vendor/github.com/xanzy/go-gitlab/groups.go | 116 ++++++++++++++- vendor/github.com/xanzy/go-gitlab/issues.go | 62 ++++---- .../xanzy/go-gitlab/project_clusters.go | 34 +++-- vendor/github.com/xanzy/go-gitlab/projects.go | 39 ++--- .../xanzy/go-gitlab/protected_branches.go | 43 +++++- vendor/github.com/xanzy/go-gitlab/services.go | 6 +- .../xanzy/go-gitlab/system_hooks.go | 8 +- vendor/modules.txt | 2 +- 16 files changed, 502 insertions(+), 88 deletions(-) create mode 100644 vendor/github.com/xanzy/go-gitlab/applications.go diff --git a/go.mod b/go.mod index 82924e813..113aa4bc8 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/posener/complete v1.2.3 // indirect github.com/ulikunitz/xz v0.5.7 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect - github.com/xanzy/go-gitlab v0.29.0 + github.com/xanzy/go-gitlab v0.30.1 golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 // indirect ) diff --git a/go.sum b/go.sum index 85d5f9c6e..1547e825a 100644 --- a/go.sum +++ b/go.sum @@ -147,16 +147,12 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl/v2 v2.0.0 h1:efQznTz+ydmQXq3BOnRa3AXzvCeTq1P4dKj/z5GLlY8= github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90= -github.com/hashicorp/hcl/v2 v2.1.0 h1:GNoCF4TJPJ/ZNAAOylHmSc/gECnMStnGacR9j3hIQw8= -github.com/hashicorp/hcl/v2 v2.1.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90= github.com/hashicorp/hcl/v2 v2.3.0 h1:iRly8YaMwTBAKhn1Ybk7VSdzbnopghktCD031P8ggUE= github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8= 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/terraform-config-inspect v0.0.0-20191115094559-17f92b0546e8 h1:+RyjwU+Gnd/aTJBPZVDNm903eXVjjqhbaR4Ypx3xYyY= github.com/hashicorp/terraform-config-inspect v0.0.0-20191115094559-17f92b0546e8/go.mod h1:p+ivJws3dpqbp1iP84+npOyAmTTOLMgCzrXd3GSdn/A= -github.com/hashicorp/terraform-config-inspect v0.0.0-20191121111010-e9629612a215 h1:H50GDgzwwTZzPkX8eTvkkkEbMRhUyMl8YUcT7nkeIhk= -github.com/hashicorp/terraform-config-inspect v0.0.0-20191121111010-e9629612a215/go.mod h1:p+ivJws3dpqbp1iP84+npOyAmTTOLMgCzrXd3GSdn/A= github.com/hashicorp/terraform-config-inspect v0.0.0-20200210163047-f7d8399e1194 h1:Zn54YFKlZ0tVcR4HCfmVUP9kTTIK1c7G5mW7JKMsaak= github.com/hashicorp/terraform-config-inspect v0.0.0-20200210163047-f7d8399e1194/go.mod h1:p+ivJws3dpqbp1iP84+npOyAmTTOLMgCzrXd3GSdn/A= github.com/hashicorp/terraform-json v0.4.0 h1:KNh29iNxozP5adfUFBJ4/fWd0Cu3taGgjHB38JYqOF4= @@ -248,16 +244,14 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= -github.com/ulikunitz/xz v0.5.6 h1:jGHAfXawEGZQ3blwU5wnWKQJvAraT7Ftq9EXjnXYgt8= -github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= github.com/ulikunitz/xz v0.5.7 h1:YvTNdFzX6+W5m9msiYg/zpkSURPPtOlzbqYjrFn7Yt4= github.com/ulikunitz/xz v0.5.7/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/xanzy/go-gitlab v0.29.0 h1:9tMvAkG746eIlzcdpnRgpcKPA1woUDmldMIjR/E5OWM= -github.com/xanzy/go-gitlab v0.29.0/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug= +github.com/xanzy/go-gitlab v0.30.1 h1:FXmtPTFT8YGa2uaxPSsY3Mar/x9gyqakbWHytpnGy4E= +github.com/xanzy/go-gitlab v0.30.1/go.mod h1:sPLojNBn68fMUWSxIJtdVVIP8uSBYqesTfDUseX11Ug= github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= @@ -340,6 +334,7 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -453,9 +448,11 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.27.1 h1:zvIju4sqAGvwKspUQOhwnpcqSbzi7/H6QomNNjTL4sk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= 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/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/vendor/github.com/xanzy/go-gitlab/README.md b/vendor/github.com/xanzy/go-gitlab/README.md index 48fb4882b..47dc46dbc 100644 --- a/vendor/github.com/xanzy/go-gitlab/README.md +++ b/vendor/github.com/xanzy/go-gitlab/README.md @@ -20,6 +20,7 @@ incompatible changes that were needed to fully support the V4 Gitlab API. This API client package covers most of the existing Gitlab API calls and is updated regularly to add new and/or missing endpoints. Currently the following services are supported: +- [x] Applications - [x] Award Emojis - [x] Branches - [x] Broadcast Messages @@ -166,7 +167,7 @@ For complete usage of go-gitlab, see the full [package docs](https://godoc.org/g ## Author -Sander van Harmelen () +Sander van Harmelen () ## License diff --git a/vendor/github.com/xanzy/go-gitlab/applications.go b/vendor/github.com/xanzy/go-gitlab/applications.go new file mode 100644 index 000000000..30ff8dce0 --- /dev/null +++ b/vendor/github.com/xanzy/go-gitlab/applications.go @@ -0,0 +1,100 @@ +// +// Copyright 2017, Sander van Harmelen +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package gitlab + +import "fmt" + +// ApplicationsService handles communication with administrables applications +// of the Gitlab API. +// +// Gitlab API docs : https://docs.gitlab.com/ee/api/applications.html +type ApplicationsService struct { + client *Client +} + +type Application struct { + ID int `json:"id"` + ApplicationID string `json:"application_id"` + ApplicationName string `json:"application_name"` + Secret string `json:"secret"` + CallbackURL string `json:"callback_url"` + Confidential bool `json:"confidential"` +} + +// CreateApplicationOptions represents the available CreateApplication() options. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/applications.html#create-an-application +type CreateApplicationOptions struct { + Name *string `url:"name,omitempty" json:"name,omitempty"` + RedirectURI *string `url:"redirect_uri,omitempty" json:"redirect_uri,omitempty"` + Scopes *string `url:"scopes,omitempty" json:"scopes,omitempty"` + Confidential *bool `url:"confidential,omitempty" json:"confidential,omitempty"` +} + +// CreateApplication creates a new application owned by the authenticated user. +// +// Gitlab API docs : https://docs.gitlab.com/ce/api/applications.html#create-an-application +func (s *ApplicationsService) CreateApplication(opt *CreateApplicationOptions, options ...OptionFunc) (*Application, *Response, error) { + req, err := s.client.NewRequest("POST", "applications", opt, options) + if err != nil { + return nil, nil, err + } + + a := new(Application) + resp, err := s.client.Do(req, a) + if err != nil { + return nil, resp, err + } + + return a, resp, err +} + +type ListApplicationsOptions ListOptions + +// ListApplications get a list of administrables applications by the authenticated user +// +// Gitlab API docs : https://docs.gitlab.com/ce/api/applications.html#list-all-applications +func (s *ApplicationsService) ListApplications(opt *ListApplicationsOptions, options ...OptionFunc) ([]*Application, *Response, error) { + req, err := s.client.NewRequest("GET", "applications", opt, options) + if err != nil { + return nil, nil, err + } + + var as []*Application + resp, err := s.client.Do(req, &as) + if err != nil { + return nil, resp, err + } + + return as, resp, err +} + +// DeleteApplication removes a specific application. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/applications.html#delete-an-application +func (s *ApplicationsService) DeleteApplication(application int, options ...OptionFunc) (*Response, error) { + u := fmt.Sprintf("applications/%d", application) + + req, err := s.client.NewRequest("DELETE", u, nil, options) + if err != nil { + return nil, err + } + + return s.client.Do(req, nil) +} diff --git a/vendor/github.com/xanzy/go-gitlab/event_webhook_types.go b/vendor/github.com/xanzy/go-gitlab/event_webhook_types.go index ed1a7b8a0..108c191b8 100644 --- a/vendor/github.com/xanzy/go-gitlab/event_webhook_types.go +++ b/vendor/github.com/xanzy/go-gitlab/event_webhook_types.go @@ -128,6 +128,7 @@ type IssueEvent struct { ObjectKind string `json:"object_kind"` User *User `json:"user"` Project struct { + ID int `json:"id"` Name string `json:"name"` Description string `json:"description"` AvatarURL string `json:"avatar_url"` diff --git a/vendor/github.com/xanzy/go-gitlab/gitlab.go b/vendor/github.com/xanzy/go-gitlab/gitlab.go index c8d0eaff4..e782e8229 100644 --- a/vendor/github.com/xanzy/go-gitlab/gitlab.go +++ b/vendor/github.com/xanzy/go-gitlab/gitlab.go @@ -352,6 +352,7 @@ type Client struct { // Services used for talking to different parts of the GitLab API. AccessRequests *AccessRequestsService + Applications *ApplicationsService AwardEmoji *AwardEmojiService Boards *IssueBoardsService Branches *BranchesService @@ -513,6 +514,7 @@ func newClient(httpClient *http.Client) *Client { // Create all the public services. c.AccessRequests = &AccessRequestsService{client: c} + c.Applications = &ApplicationsService{client: c} c.AwardEmoji = &AwardEmojiService{client: c} c.Boards = &IssueBoardsService{client: c} c.Branches = &BranchesService{client: c} diff --git a/vendor/github.com/xanzy/go-gitlab/group_clusters.go b/vendor/github.com/xanzy/go-gitlab/group_clusters.go index 9f38bc0b0..2b2e4d717 100644 --- a/vendor/github.com/xanzy/go-gitlab/group_clusters.go +++ b/vendor/github.com/xanzy/go-gitlab/group_clusters.go @@ -44,6 +44,7 @@ type GroupCluster struct { ClusterType string `json:"cluster_type"` User *User `json:"user"` PlatformKubernetes *PlatformKubernetes `json:"platform_kubernetes"` + ManagementProject *ManagementProject `json:"management_project"` Group *Group `json:"group"` } @@ -106,12 +107,13 @@ func (s *GroupClustersService) GetCluster(pid interface{}, cluster int, options // GitLab API docs: // https://docs.gitlab.com/ee/api/group_clusters.html#add-existing-cluster-to-group type AddGroupClusterOptions struct { - Name *string `url:"name,omitempty" json:"name,omitempty"` - Domain *string `url:"domain,omitempty" json:"domain,omitempty"` - Enabled *bool `url:"enabled,omitempty" json:"enabled,omitempty"` - Managed *bool `url:"managed,omitempty" json:"managed,omitempty"` - EnvironmentScope *string `url:"environment_scope,omitempty" json:"environment_scope,omitempty"` - PlatformKubernetes *AddGroupPlatformKubernetesOptions `url:"platform_kubernetes_attributes,omitempty" json:"platform_kubernetes_attributes,omitempty"` + Name *string `url:"name,omitempty" json:"name,omitempty"` + Domain *string `url:"domain,omitempty" json:"domain,omitempty"` + ManagementProjectID *string `url:"management_project_id,omitempty" json:"management_project_id,omitempty"` + Enabled *bool `url:"enabled,omitempty" json:"enabled,omitempty"` + Managed *bool `url:"managed,omitempty" json:"managed,omitempty"` + EnvironmentScope *string `url:"environment_scope,omitempty" json:"environment_scope,omitempty"` + PlatformKubernetes *AddGroupPlatformKubernetesOptions `url:"platform_kubernetes_attributes,omitempty" json:"platform_kubernetes_attributes,omitempty"` } // AddGroupPlatformKubernetesOptions represents the available PlatformKubernetes options for adding. @@ -153,10 +155,11 @@ func (s *GroupClustersService) AddCluster(pid interface{}, opt *AddGroupClusterO // GitLab API docs: // https://docs.gitlab.com/ee/api/group_clusters.html#edit-group-cluster type EditGroupClusterOptions struct { - Name *string `url:"name,omitempty" json:"name,omitempty"` - Domain *string `url:"domain,omitempty" json:"domain,omitempty"` - EnvironmentScope *string `url:"environment_scope,omitempty" json:"environment_scope,omitempty"` - PlatformKubernetes *EditGroupPlatformKubernetesOptions `url:"platform_kubernetes_attributes,omitempty" json:"platform_kubernetes_attributes,omitempty"` + Name *string `url:"name,omitempty" json:"name,omitempty"` + Domain *string `url:"domain,omitempty" json:"domain,omitempty"` + EnvironmentScope *string `url:"environment_scope,omitempty" json:"environment_scope,omitempty"` + PlatformKubernetes *EditGroupPlatformKubernetesOptions `url:"platform_kubernetes_attributes,omitempty" json:"platform_kubernetes_attributes,omitempty"` + ManagementProjectID *string `url:"management_project_id,omitempty" json:"management_project_id,omitempty"` } // EditGroupPlatformKubernetesOptions represents the available PlatformKubernetes options for editing. diff --git a/vendor/github.com/xanzy/go-gitlab/group_hooks.go b/vendor/github.com/xanzy/go-gitlab/group_hooks.go index 6c92517ec..de409b2e0 100644 --- a/vendor/github.com/xanzy/go-gitlab/group_hooks.go +++ b/vendor/github.com/xanzy/go-gitlab/group_hooks.go @@ -31,13 +31,14 @@ type GroupHook struct { PushEvents bool `json:"push_events"` IssuesEvents bool `json:"issues_events"` ConfidentialIssuesEvents bool `json:"confidential_issues_events"` + ConfidentialNoteEvents bool `json:"confidential_note_events"` MergeRequestsEvents bool `json:"merge_requests_events"` TagPushEvents bool `json:"tag_push_events"` NoteEvents bool `json:"note_events"` JobEvents bool `json:"job_events"` PipelineEvents bool `json:"pipeline_events"` WikiPageEvents bool `json:"wiki_page_events"` - EnableSslVerification bool `json:"enable_ssl_verification"` + EnableSSLVerification bool `json:"enable_ssl_verification"` CreatedAt *time.Time `json:"created_at"` } @@ -63,3 +64,136 @@ func (s *GroupsService) ListGroupHooks(gid interface{}) ([]*GroupHook, *Response return gh, resp, err } + +// GetGroupHook gets a specific hook for a group. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/groups.html#get-group-hook +func (s *GroupsService) GetGroupHook(pid interface{}, hook int, options ...OptionFunc) (*GroupHook, *Response, error) { + group, err := parseID(pid) + if err != nil { + return nil, nil, err + } + u := fmt.Sprintf("groups/%s/hooks/%d", pathEscape(group), hook) + + req, err := s.client.NewRequest("GET", u, nil, options) + if err != nil { + return nil, nil, err + } + + gh := new(GroupHook) + resp, err := s.client.Do(req, gh) + if err != nil { + return nil, resp, err + } + + return gh, resp, err +} + +// AddGroupHookOptions represents the available AddGroupHook() options. +// +// GitLab API docs: https://docs.gitlab.com/ee/api/groups.html#add-group-hook +type AddGroupHookOptions struct { + URL *string `url:"url,omitempty" json:"url,omitempty"` + PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` + IssuesEvents *bool `url:"issues_events,omitempty" json:"issues_events,omitempty"` + ConfidentialIssuesEvents *bool `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"` + ConfidentialNoteEvents *bool `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"` + MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"` + TagPushEvents *bool `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"` + NoteEvents *bool `url:"note_events,omitempty" json:"note_events,omitempty"` + JobEvents *bool `url:"job_events,omitempty" json:"job_events,omitempty"` + PipelineEvents *bool `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"` + WikiPageEvents *bool `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"` + EnableSSLVerification *bool `url:"enable_ssl_verification,omitempty" json:"enable_ssl_verification,omitempty"` + Token *string `url:"token,omitempty" json:"token,omitempty"` +} + +// AddGroupHook create a new group scoped webhook. +// +// GitLab API docs: https://docs.gitlab.com/ee/api/groups.html#add-group-hook +func (s *GroupsService) AddGroupHook(gid interface{}, opt *AddGroupHookOptions, options ...OptionFunc) (*GroupHook, *Response, error) { + group, err := parseID(gid) + if err != nil { + return nil, nil, err + } + u := fmt.Sprintf("groups/%s/hooks", pathEscape(group)) + + req, err := s.client.NewRequest("POST", u, opt, options) + if err != nil { + return nil, nil, err + } + + gh := new(GroupHook) + resp, err := s.client.Do(req, gh) + if err != nil { + return nil, resp, err + } + + return gh, resp, err +} + +// EditGroupHookOptions represents the available EditGroupHook() options. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/groups.html#edit-group-hook +type EditGroupHookOptions struct { + URL *string `url:"url,omitempty" json:"url,omitempty"` + PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` + IssuesEvents *bool `url:"issues_events,omitempty" json:"issues_events,omitempty"` + ConfidentialIssuesEvents *bool `url:"confidential_issues_events,omitempty" json:"confidential_issues_events,omitempty"` + ConfidentialNoteEvents *bool `url:"confidential_note_events,omitempty" json:"confidential_note_events,omitempty"` + MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"` + TagPushEvents *bool `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"` + NoteEvents *bool `url:"note_events,omitempty" json:"note_events,omitempty"` + JobEvents *bool `url:"job_events,omitempty" json:"job_events,omitempty"` + PipelineEvents *bool `url:"pipeline_events,omitempty" json:"pipeline_events,omitempty"` + WikiPageEvents *bool `url:"wiki_page_events,omitempty" json:"wiki_page_events,omitempty"` + EnableSSLVerification *bool `url:"enable_ssl_verification,omitempty" json:"enable_ssl_verification,omitempty"` + Token *string `url:"token,omitempty" json:"token,omitempty"` +} + +// EditGroupHook edits a hook for a specified group. +// +// Gitlab API docs: +// https://docs.gitlab.com/ce/api/groups.html#edit-group-hook +func (s *GroupsService) EditGroupHook(pid interface{}, hook int, opt *EditGroupHookOptions, options ...OptionFunc) (*GroupHook, *Response, error) { + group, err := parseID(pid) + if err != nil { + return nil, nil, err + } + u := fmt.Sprintf("groups/%s/hooks/%d", pathEscape(group), hook) + + req, err := s.client.NewRequest("PUT", u, opt, options) + if err != nil { + return nil, nil, err + } + + gh := new(GroupHook) + resp, err := s.client.Do(req, gh) + if err != nil { + return nil, resp, err + } + + return gh, resp, err +} + +// DeleteGroupHook removes a hook from a group. This is an idempotent +// method and can be called multiple times. +// +// GitLab API docs: +// https://docs.gitlab.com/ce/api/groups.html#delete-group-hook +func (s *GroupsService) DeleteGroupHook(pid interface{}, hook int, options ...OptionFunc) (*Response, error) { + group, err := parseID(pid) + if err != nil { + return nil, err + } + u := fmt.Sprintf("groups/%s/hooks/%d", pathEscape(group), hook) + + req, err := s.client.NewRequest("DELETE", u, nil, options) + if err != nil { + return nil, err + } + + return s.client.Do(req, nil) +} diff --git a/vendor/github.com/xanzy/go-gitlab/groups.go b/vendor/github.com/xanzy/go-gitlab/groups.go index 79256780b..9f7a19137 100644 --- a/vendor/github.com/xanzy/go-gitlab/groups.go +++ b/vendor/github.com/xanzy/go-gitlab/groups.go @@ -60,9 +60,16 @@ type Group struct { SharedProjects []*Project `json:"shared_projects"` LDAPCN string `json:"ldap_cn"` LDAPAccess AccessLevelValue `json:"ldap_access"` + LDAPGroupLinks []*LDAPGroupLink `json:"ldap_group_links"` SharedRunnersMinutesLimit int `json:"shared_runners_minutes_limit"` ExtraSharedRunnersMinutesLimit int `json:"extra_shared_runners_minutes_limit"` - PendingDelete bool `json:"pending_delete"` + MarkedForDeletionOn *ISOTime `json:"marked_for_deletion_on"` +} + +type LDAPGroupLink struct { + CN string `json:"cn"` + GroupAccess AccessLevelValue `json:"group_access"` + Provider string `json:"provider"` } // ListGroupsOptions represents the available ListGroups() options. @@ -347,3 +354,110 @@ func (s *GroupsService) ListSubgroups(gid interface{}, opt *ListSubgroupsOptions return g, resp, err } + +// ListGroupLDAPLinks lists the group's LDAP links. Available only for users who +// can edit groups. +// +// GitLab API docs: +// https://docs.gitlab.com/ee/api/groups.html#list-ldap-group-links-starter +func (s *GroupsService) ListGroupLDAPLinks(gid interface{}, options ...OptionFunc) ([]*LDAPGroupLink, *Response, error) { + group, err := parseID(gid) + if err != nil { + return nil, nil, err + } + u := fmt.Sprintf("groups/%s/ldap_group_links", pathEscape(group)) + + req, err := s.client.NewRequest("GET", u, nil, options) + if err != nil { + return nil, nil, err + } + + var gl []*LDAPGroupLink + resp, err := s.client.Do(req, &gl) + if err != nil { + return nil, resp, err + } + + return gl, resp, nil +} + +// AddGroupLDAPLinkOptions represents the available AddGroupLDAPLink() options. +// +// GitLab API docs: +// https://docs.gitlab.com/ee/api/groups.html#add-ldap-group-link-starter +type AddGroupLDAPLinkOptions struct { + CN *string `url:"cn,omitempty" json:"cn,omitempty"` + GroupAccess *int `url:"group_access,omitempty" json:"group_access,omitempty"` + Provider *string `url:"provider,omitempty" json:"provider,ommitempty"` +} + +// AddGroupLDAPLink creates a new group LDAP link. Available only for users who +// can edit groups. +// +// GitLab API docs: +// https://docs.gitlab.com/ee/api/groups.html#add-ldap-group-link-starter +func (s *GroupsService) AddGroupLDAPLink(gid interface{}, opt *AddGroupLDAPLinkOptions, options ...OptionFunc) (*LDAPGroupLink, *Response, error) { + group, err := parseID(gid) + if err != nil { + return nil, nil, err + } + u := fmt.Sprintf("groups/%s/ldap_group_links", pathEscape(group)) + + req, err := s.client.NewRequest("POST", u, opt, options) + if err != nil { + return nil, nil, err + } + + gl := new(LDAPGroupLink) + resp, err := s.client.Do(req, gl) + if err != nil { + return nil, resp, err + } + + return gl, resp, err +} + +// DeleteGroupLDAPLink deletes a group LDAP link. Available only for users who +// can edit groups. +// +// GitLab API docs: +// https://docs.gitlab.com/ee/api/groups.html#delete-ldap-group-link-starter +func (s *GroupsService) DeleteGroupLDAPLink(gid interface{}, cn string, options ...OptionFunc) (*Response, error) { + group, err := parseID(gid) + if err != nil { + return nil, err + } + u := fmt.Sprintf("groups/%s/ldap_group_links/%s", pathEscape(group), pathEscape(cn)) + + req, err := s.client.NewRequest("DELETE", u, nil, options) + if err != nil { + return nil, err + } + + return s.client.Do(req, nil) +} + +// DeleteGroupLDAPLinkForProvider deletes a group LDAP link from a specific +// provider. Available only for users who can edit groups. +// +// GitLab API docs: +// https://docs.gitlab.com/ee/api/groups.html#delete-ldap-group-link-starter +func (s *GroupsService) DeleteGroupLDAPLinkForProvider(gid interface{}, provider, cn string, options ...OptionFunc) (*Response, error) { + group, err := parseID(gid) + if err != nil { + return nil, err + } + u := fmt.Sprintf( + "groups/%s/ldap_group_links/%s/%s", + pathEscape(group), + pathEscape(provider), + pathEscape(cn), + ) + + req, err := s.client.NewRequest("DELETE", u, nil, options) + if err != nil { + return nil, err + } + + return s.client.Do(req, nil) +} diff --git a/vendor/github.com/xanzy/go-gitlab/issues.go b/vendor/github.com/xanzy/go-gitlab/issues.go index 3aa1a3bc8..75a5bfca6 100644 --- a/vendor/github.com/xanzy/go-gitlab/issues.go +++ b/vendor/github.com/xanzy/go-gitlab/issues.go @@ -53,6 +53,13 @@ type IssueAssignee struct { Username string `json:"username"` } +// IssueReferences represents references of the issue. +type IssueReferences struct { + Short string `json:"short"` + Relative string `json:"relative"` + Full string `json:"full"` +} + // IssueLinks represents links of the issue. type IssueLinks struct { Self string `json:"self"` @@ -65,33 +72,34 @@ type IssueLinks struct { // // GitLab API docs: https://docs.gitlab.com/ce/api/issues.html type Issue struct { - ID int `json:"id"` - IID int `json:"iid"` - ProjectID int `json:"project_id"` - Milestone *Milestone `json:"milestone"` - Author *IssueAuthor `json:"author"` - Description string `json:"description"` - State string `json:"state"` - Assignees []*IssueAssignee `json:"assignees"` - Assignee *IssueAssignee `json:"assignee"` - Upvotes int `json:"upvotes"` - Downvotes int `json:"downvotes"` - Labels Labels `json:"labels"` - Title string `json:"title"` - UpdatedAt *time.Time `json:"updated_at"` - CreatedAt *time.Time `json:"created_at"` - ClosedAt *time.Time `json:"closed_at"` - Subscribed bool `json:"subscribed"` - UserNotesCount int `json:"user_notes_count"` - DueDate *ISOTime `json:"due_date"` - WebURL string `json:"web_url"` - TimeStats *TimeStats `json:"time_stats"` - Confidential bool `json:"confidential"` - Weight int `json:"weight"` - DiscussionLocked bool `json:"discussion_locked"` - Links *IssueLinks `json:"_links"` - IssueLinkID int `json:"issue_link_id"` - MergeRequestCount int `json:"merge_requests_count"` + ID int `json:"id"` + IID int `json:"iid"` + State string `json:"state"` + Description string `json:"description"` + Author *IssueAuthor `json:"author"` + Milestone *Milestone `json:"milestone"` + ProjectID int `json:"project_id"` + Assignees []*IssueAssignee `json:"assignees"` + Assignee *IssueAssignee `json:"assignee"` + UpdatedAt *time.Time `json:"updated_at"` + ClosedAt *time.Time `json:"closed_at"` + Title string `json:"title"` + CreatedAt *time.Time `json:"created_at"` + Labels Labels `json:"labels"` + Upvotes int `json:"upvotes"` + Downvotes int `json:"downvotes"` + DueDate *ISOTime `json:"due_date"` + WebURL string `json:"web_url"` + References *IssueReferences `json:"references"` + TimeStats *TimeStats `json:"time_stats"` + Confidential bool `json:"confidential"` + Weight int `json:"weight"` + DiscussionLocked bool `json:"discussion_locked"` + Subscribed bool `json:"subscribed"` + UserNotesCount int `json:"user_notes_count"` + Links *IssueLinks `json:"_links"` + IssueLinkID int `json:"issue_link_id"` + MergeRequestCount int `json:"merge_requests_count"` TaskCompletionStatus struct { Count int `json:"count"` CompletedCount int `json:"completed_count"` diff --git a/vendor/github.com/xanzy/go-gitlab/project_clusters.go b/vendor/github.com/xanzy/go-gitlab/project_clusters.go index d2be60e2e..e50c5728f 100644 --- a/vendor/github.com/xanzy/go-gitlab/project_clusters.go +++ b/vendor/github.com/xanzy/go-gitlab/project_clusters.go @@ -44,6 +44,7 @@ type ProjectCluster struct { ClusterType string `json:"cluster_type"` User *User `json:"user"` PlatformKubernetes *PlatformKubernetes `json:"platform_kubernetes"` + ManagementProject *ManagementProject `json:"management_project"` Project *Project `json:"project"` } @@ -60,6 +61,17 @@ type PlatformKubernetes struct { AuthorizationType string `json:"authorization_type"` } +// ManagementProject represents a GitLab Project Cluster management_project. +type ManagementProject struct { + ID int `json:"id"` + Description string `json:"description"` + Name string `json:"name"` + NameWithNamespace string `json:"name_with_namespace"` + Path string `json:"path"` + PathWithNamespace string `json:"path_with_namespace"` + CreatedAt *time.Time `json:"created_at"` +} + // ListClusters gets a list of all clusters in a project. // // GitLab API docs: @@ -115,12 +127,13 @@ func (s *ProjectClustersService) GetCluster(pid interface{}, cluster int, option // GitLab API docs: // https://docs.gitlab.com/ee/api/project_clusters.html#add-existing-cluster-to-project type AddClusterOptions struct { - Name *string `url:"name,omitempty" json:"name,omitempty"` - Domain *string `url:"domain,omitempty" json:"domain,omitempty"` - Enabled *bool `url:"enabled,omitempty" json:"enabled,omitempty"` - Managed *bool `url:"managed,omitempty" json:"managed,omitempty"` - EnvironmentScope *string `url:"environment_scope,omitempty" json:"environment_scope,omitempty"` - PlatformKubernetes *AddPlatformKubernetesOptions `url:"platform_kubernetes_attributes,omitempty" json:"platform_kubernetes_attributes,omitempty"` + Name *string `url:"name,omitempty" json:"name,omitempty"` + Domain *string `url:"domain,omitempty" json:"domain,omitempty"` + Enabled *bool `url:"enabled,omitempty" json:"enabled,omitempty"` + Managed *bool `url:"managed,omitempty" json:"managed,omitempty"` + EnvironmentScope *string `url:"environment_scope,omitempty" json:"environment_scope,omitempty"` + PlatformKubernetes *AddPlatformKubernetesOptions `url:"platform_kubernetes_attributes,omitempty" json:"platform_kubernetes_attributes,omitempty"` + ManagementProjectID *string `url:"management_project_id,omitempty" json:"management_project_id,omitempty"` } // AddPlatformKubernetesOptions represents the available PlatformKubernetes options for adding. @@ -162,10 +175,11 @@ func (s *ProjectClustersService) AddCluster(pid interface{}, opt *AddClusterOpti // GitLab API docs: // https://docs.gitlab.com/ee/api/project_clusters.html#edit-project-cluster type EditClusterOptions struct { - Name *string `url:"name,omitempty" json:"name,omitempty"` - Domain *string `url:"domain,omitempty" json:"domain,omitempty"` - EnvironmentScope *string `url:"environment_scope,omitempty" json:"environment_scope,omitempty"` - PlatformKubernetes *EditPlatformKubernetesOptions `url:"platform_kubernetes_attributes,omitempty" json:"platform_kubernetes_attributes,omitempty"` + Name *string `url:"name,omitempty" json:"name,omitempty"` + Domain *string `url:"domain,omitempty" json:"domain,omitempty"` + EnvironmentScope *string `url:"environment_scope,omitempty" json:"environment_scope,omitempty"` + ManagementProjectID *string `url:"management_project_id,omitempty" json:"management_project_id,omitempty"` + PlatformKubernetes *EditPlatformKubernetesOptions `url:"platform_kubernetes_attributes,omitempty" json:"platform_kubernetes_attributes,omitempty"` } // EditPlatformKubernetesOptions represents the available PlatformKubernetes options for editing. diff --git a/vendor/github.com/xanzy/go-gitlab/projects.go b/vendor/github.com/xanzy/go-gitlab/projects.go index 7df17f3ef..b03ebd488 100644 --- a/vendor/github.com/xanzy/go-gitlab/projects.go +++ b/vendor/github.com/xanzy/go-gitlab/projects.go @@ -69,7 +69,7 @@ type Project struct { ImportStatus string `json:"import_status"` ImportError string `json:"import_error"` Permissions *Permissions `json:"permissions"` - MarkedForDeletionAt *time.Time `json:"marked_for_deletion_at"` + MarkedForDeletionAt *ISOTime `json:"marked_for_deletion_at"` Archived bool `json:"archived"` AvatarURL string `json:"avatar_url"` SharedRunnersEnabled bool `json:"shared_runners_enabled"` @@ -79,6 +79,7 @@ type Project struct { PublicBuilds bool `json:"public_builds"` OnlyAllowMergeIfPipelineSucceeds bool `json:"only_allow_merge_if_pipeline_succeeds"` OnlyAllowMergeIfAllDiscussionsAreResolved bool `json:"only_allow_merge_if_all_discussions_are_resolved"` + RemoveSourceBranchAfterMerge bool `json:"remove_source_branch_after_merge"` LFSEnabled bool `json:"lfs_enabled"` RequestAccessEnabled bool `json:"request_access_enabled"` MergeMethod MergeMethodValue `json:"merge_method"` @@ -98,7 +99,6 @@ type Project struct { CIConfigPath string `json:"ci_config_path"` CIDefaultGitDepth int `json:"ci_default_git_depth"` CustomAttributes []*CustomAttribute `json:"custom_attributes"` - PendingDelete bool `json:"pending_delete"` } // Repository represents a repository. @@ -192,14 +192,15 @@ func (s Project) String() string { // GitLab API docs: // https://docs.gitlab.com/ee/api/merge_request_approvals.html#get-project-level-rules type ProjectApprovalRule struct { - ID int `json:"id"` - Name string `json:"name"` - RuleType string `json:"rule_type"` - EligibleApprovers []*BasicUser `json:"eligible_approvers"` - ApprovalsRequired int `json:"approvals_required"` - Users []*BasicUser `json:"users"` - Groups []*Group `json:"groups"` - ContainsHiddenGroups bool `json:"contains_hidden_groups"` + ID int `json:"id"` + Name string `json:"name"` + RuleType string `json:"rule_type"` + EligibleApprovers []*BasicUser `json:"eligible_approvers"` + ApprovalsRequired int `json:"approvals_required"` + Users []*BasicUser `json:"users"` + Groups []*Group `json:"groups"` + ContainsHiddenGroups bool `json:"contains_hidden_groups"` + ProtectedBranches []*ProtectedBranch `json:"protected_branches"` } func (s ProjectApprovalRule) String() string { @@ -1382,10 +1383,11 @@ func (s *ProjectsService) GetProjectApprovalRules(pid interface{}, options ...Op // GitLab API docs: // https://docs.gitlab.com/ee/api/merge_request_approvals.html#create-project-level-rules type CreateProjectLevelRuleOptions struct { - Name *string `url:"name,omitempty" json:"name,omitempty"` - ApprovalsRequired *int `url:"approvals_required,omitempty" json:"approvals_required,omitempty"` - UserIDs []int `url:"user_ids,omitempty" json:"user_ids,omitempty"` - GroupIDs []int `url:"group_ids,omitempty" json:"group_ids,omitempty"` + Name *string `url:"name,omitempty" json:"name,omitempty"` + ApprovalsRequired *int `url:"approvals_required,omitempty" json:"approvals_required,omitempty"` + UserIDs []int `url:"user_ids,omitempty" json:"user_ids,omitempty"` + GroupIDs []int `url:"group_ids,omitempty" json:"group_ids,omitempty"` + ProtectedBranchIDs []int `url:"protected_branch_ids,omitempty" json:"protected_branch_ids,omitempty"` } // CreateProjectApprovalRule creates a new project-level approval rule. @@ -1419,10 +1421,11 @@ func (s *ProjectsService) CreateProjectApprovalRule(pid interface{}, opt *Create // GitLab API docs: // https://docs.gitlab.com/ee/api/merge_request_approvals.html#update-project-level-rules type UpdateProjectLevelRuleOptions struct { - Name *string `url:"name,omitempty" json:"name,omitempty"` - ApprovalsRequired *int `url:"approvals_required,omitempty" json:"approvals_required,omitempty"` - UserIDs []int `url:"user_ids,omitempty" json:"user_ids,omitempty"` - GroupIDs []int `url:"group_ids,omitempty" json:"group_ids,omitempty"` + Name *string `url:"name,omitempty" json:"name,omitempty"` + ApprovalsRequired *int `url:"approvals_required,omitempty" json:"approvals_required,omitempty"` + UserIDs []int `url:"user_ids,omitempty" json:"user_ids,omitempty"` + GroupIDs []int `url:"group_ids,omitempty" json:"group_ids,omitempty"` + ProtectedBranchIDs []int `url:"protected_branch_ids,omitempty" json:"protected_branch_ids,omitempty"` } // UpdateProjectApprovalRule updates an existing approval rule with new options. diff --git a/vendor/github.com/xanzy/go-gitlab/protected_branches.go b/vendor/github.com/xanzy/go-gitlab/protected_branches.go index 3567f6ebd..069bb7f8d 100644 --- a/vendor/github.com/xanzy/go-gitlab/protected_branches.go +++ b/vendor/github.com/xanzy/go-gitlab/protected_branches.go @@ -45,9 +45,11 @@ type BranchAccessDescription struct { // GitLab API docs: // https://docs.gitlab.com/ce/api/protected_branches.html#list-protected-branches type ProtectedBranch struct { - Name string `json:"name"` - PushAccessLevels []*BranchAccessDescription `json:"push_access_levels"` - MergeAccessLevels []*BranchAccessDescription `json:"merge_access_levels"` + ID int `json:"id"` + Name string `json:"name"` + PushAccessLevels []*BranchAccessDescription `json:"push_access_levels"` + MergeAccessLevels []*BranchAccessDescription `json:"merge_access_levels"` + CodeOwnerApprovalRequired bool `json:"code_owner_approval_required"` } // ListProtectedBranchesOptions represents the available ListProtectedBranches() @@ -113,9 +115,10 @@ func (s *ProtectedBranchesService) GetProtectedBranch(pid interface{}, branch st // GitLab API docs: // https://docs.gitlab.com/ce/api/protected_branches.html#protect-repository-branches type ProtectRepositoryBranchesOptions struct { - Name *string `url:"name,omitempty" json:"name,omitempty"` - PushAccessLevel *AccessLevelValue `url:"push_access_level,omitempty" json:"push_access_level,omitempty"` - MergeAccessLevel *AccessLevelValue `url:"merge_access_level,omitempty" json:"merge_access_level,omitempty"` + Name *string `url:"name,omitempty" json:"name,omitempty"` + PushAccessLevel *AccessLevelValue `url:"push_access_level,omitempty" json:"push_access_level,omitempty"` + MergeAccessLevel *AccessLevelValue `url:"merge_access_level,omitempty" json:"merge_access_level,omitempty"` + CodeOwnerApprovalRequired *bool `url:"code_owner_approval_required,omitempty" json:"code_owner_approval_required,omitempty"` } // ProtectRepositoryBranches protects a single repository branch or several @@ -163,3 +166,31 @@ func (s *ProtectedBranchesService) UnprotectRepositoryBranches(pid interface{}, return s.client.Do(req, nil) } + +// RequireCodeOwnerApprovalsOptions represents the available +// RequireCodeOwnerApprovals() options. +// +// GitLab API docs: +// https://docs.gitlab.com/ee/api/protected_branches.html#require-code-owner-approvals-for-a-single-branch +type RequireCodeOwnerApprovalsOptions struct { + CodeOwnerApprovalRequired *bool `url:"code_owner_approval_required,omitempty" json:"code_owner_approval_required,omitempty"` +} + +// RequireCodeOwnerApprovals updates the code owner approval. +// +// Gitlab API docs: +// https://docs.gitlab.com/ee/api/protected_branches.html#require-code-owner-approvals-for-a-single-branch +func (s *ProtectedBranchesService) RequireCodeOwnerApprovals(pid interface{}, branch string, opt *RequireCodeOwnerApprovalsOptions, options ...OptionFunc) (*Response, error) { + project, err := parseID(pid) + if err != nil { + return nil, err + } + u := fmt.Sprintf("projects/%s/protected_branches/%s", pathEscape(project), url.PathEscape(branch)) + + req, err := s.client.NewRequest("PATCH", u, opt, options) + if err != nil { + return nil, err + } + + return s.client.Do(req, nil) +} diff --git a/vendor/github.com/xanzy/go-gitlab/services.go b/vendor/github.com/xanzy/go-gitlab/services.go index 0dd441cef..1931153bf 100644 --- a/vendor/github.com/xanzy/go-gitlab/services.go +++ b/vendor/github.com/xanzy/go-gitlab/services.go @@ -43,7 +43,9 @@ type Service struct { PushEvents bool `json:"push_events"` IssuesEvents bool `json:"issues_events"` ConfidentialIssuesEvents bool `json:"confidential_issues_events"` + CommitEvents bool `json:"commit_events"` MergeRequestsEvents bool `json:"merge_requests_events"` + CommentOnEventEnabled bool `json:"comment_on_event_enabled"` TagPushEvents bool `json:"tag_push_events"` NoteEvents bool `json:"note_events"` ConfidentialNoteEvents bool `json:"confidential_note_events"` @@ -536,9 +538,6 @@ type JiraServiceProperties struct { Username string `json:"username,omitempty" ` Password string `json:"password,omitempty" ` JiraIssueTransitionID string `json:"jira_issue_transition_id,omitempty"` - CommitEvents bool `json:"commit_events,omitempty" ` - MergeRequestsEvents bool `json:"merge_requests_events,omitempty" ` - CommentOnEventEnabled bool `json:"comment_on_event_enabled,omitempty" ` } // UnmarshalJSON decodes the Jira Service Properties. @@ -607,6 +606,7 @@ type SetJiraServiceOptions struct { ProjectKey *string `url:"project_key,omitempty" json:"project_key,omitempty" ` Username *string `url:"username,omitempty" json:"username,omitempty" ` Password *string `url:"password,omitempty" json:"password,omitempty" ` + Active *bool `url:"active,omitempty" json:"active,omitempty"` JiraIssueTransitionID *string `url:"jira_issue_transition_id,omitempty" json:"jira_issue_transition_id,omitempty"` CommitEvents *bool `url:"commit_events,omitempty" json:"commit_events,omitempty"` MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"` diff --git a/vendor/github.com/xanzy/go-gitlab/system_hooks.go b/vendor/github.com/xanzy/go-gitlab/system_hooks.go index d5209d4f7..cd6c8bd0a 100644 --- a/vendor/github.com/xanzy/go-gitlab/system_hooks.go +++ b/vendor/github.com/xanzy/go-gitlab/system_hooks.go @@ -66,7 +66,13 @@ func (s *SystemHooksService) ListHooks(options ...OptionFunc) ([]*Hook, *Respons // GitLab API docs: // https://docs.gitlab.com/ce/api/system_hooks.html#add-new-system-hook-hook type AddHookOptions struct { - URL *string `url:"url,omitempty" json:"url,omitempty"` + URL *string `url:"url,omitempty" json:"url,omitempty"` + Token *string `url:"token,omitempty" json:"token,omitempty"` + PushEvents *bool `url:"push_events,omitempty" json:"push_events,omitempty"` + TagPushEvents *bool `url:"tag_push_events,omitempty" json:"tag_push_events,omitempty"` + MergeRequestsEvents *bool `url:"merge_requests_events,omitempty" json:"merge_requests_events,omitempty"` + RepositoryUpdateEvents *bool `url:"repository_update_events,omitempty" json:"repository_update_events,omitempty"` + EnableSSLVerification *bool `url:"enable_ssl_verification,omitempty" json:"enable_ssl_verification,omitempty"` } // AddHook adds a new system hook hook. diff --git a/vendor/modules.txt b/vendor/modules.txt index 86a5c9d97..ea1216aaf 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -254,7 +254,7 @@ github.com/ulikunitz/xz/lzma ## explicit github.com/vmihailenco/msgpack github.com/vmihailenco/msgpack/codes -# github.com/xanzy/go-gitlab v0.29.0 +# github.com/xanzy/go-gitlab v0.30.1 ## explicit github.com/xanzy/go-gitlab # github.com/zclconf/go-cty v1.2.1 From 82a7226774fd2e338eafdd0e397a4b66940ddf63 Mon Sep 17 00:00:00 2001 From: Ringo De Smet Date: Sat, 4 Apr 2020 14:11:16 +0200 Subject: [PATCH 5/9] Check for soft-delete on EE in tests --- gitlab/resource_gitlab_group_label_test.go | 4 +++- gitlab/resource_gitlab_group_test.go | 4 +++- gitlab/resource_gitlab_group_variable_test.go | 4 +++- gitlab/resource_gitlab_label_test.go | 4 +++- gitlab/resource_gitlab_pipeline_schedule_test.go | 4 +++- gitlab/resource_gitlab_pipeline_trigger_test.go | 4 +++- gitlab/resource_gitlab_project_hook_test.go | 4 +++- gitlab/resource_gitlab_project_push_rules_test.go | 4 +++- gitlab/resource_gitlab_project_test.go | 4 +++- gitlab/resource_gitlab_project_variable_test.go | 4 +++- gitlab/resource_gitlab_service_jira_test.go | 4 +++- gitlab/resource_gitlab_service_slack_test.go | 4 +++- 12 files changed, 36 insertions(+), 12 deletions(-) diff --git a/gitlab/resource_gitlab_group_label_test.go b/gitlab/resource_gitlab_group_label_test.go index 5c2a7539e..5a89fa11a 100644 --- a/gitlab/resource_gitlab_group_label_test.go +++ b/gitlab/resource_gitlab_group_label_test.go @@ -119,7 +119,9 @@ func testAccCheckGitlabGroupLabelDestroy(s *terraform.State) error { group, resp, err := conn.Groups.GetGroup(rs.Primary.ID) if err == nil { if group != nil && fmt.Sprintf("%d", group.ID) == rs.Primary.ID { - return fmt.Errorf("Group still exists") + if group.MarkedForDeletionOn == nil { + return fmt.Errorf("Group still exists") + } } } if resp.StatusCode != 404 { diff --git a/gitlab/resource_gitlab_group_test.go b/gitlab/resource_gitlab_group_test.go index 18dcd60e0..d20085f0b 100644 --- a/gitlab/resource_gitlab_group_test.go +++ b/gitlab/resource_gitlab_group_test.go @@ -264,7 +264,9 @@ func testAccCheckGitlabGroupDestroy(s *terraform.State) error { group, resp, err := conn.Groups.GetGroup(rs.Primary.ID) if err == nil { if group != nil && fmt.Sprintf("%d", group.ID) == rs.Primary.ID { - return fmt.Errorf("Group still exists") + if group.MarkedForDeletionOn == nil { + return fmt.Errorf("Group still exists") + } } } if resp.StatusCode != 404 { diff --git a/gitlab/resource_gitlab_group_variable_test.go b/gitlab/resource_gitlab_group_variable_test.go index 2973b5ce8..7cdb96263 100644 --- a/gitlab/resource_gitlab_group_variable_test.go +++ b/gitlab/resource_gitlab_group_variable_test.go @@ -119,7 +119,9 @@ func testAccCheckGitlabGroupVariableDestroy(s *terraform.State) error { _, resp, err := conn.Groups.GetGroup(rs.Primary.ID) if err == nil { //if gotRepo != nil && fmt.Sprintf("%d", gotRepo.ID) == rs.Primary.ID { - // return fmt.Errorf("Repository still exists") + // if gotRepo.MarkedForDeletionAt == nil { + // return fmt.Errorf("Repository still exists") + // } //} } if resp.StatusCode != 404 { diff --git a/gitlab/resource_gitlab_label_test.go b/gitlab/resource_gitlab_label_test.go index 7375b55db..68ad9fe95 100644 --- a/gitlab/resource_gitlab_label_test.go +++ b/gitlab/resource_gitlab_label_test.go @@ -152,7 +152,9 @@ func testAccCheckGitlabLabelDestroy(s *terraform.State) error { gotRepo, resp, err := conn.Projects.GetProject(rs.Primary.ID, nil) if err == nil { if gotRepo != nil && fmt.Sprintf("%d", gotRepo.ID) == rs.Primary.ID { - return fmt.Errorf("Repository still exists") + if gotRepo.MarkedForDeletionAt == nil { + return fmt.Errorf("Repository still exists") + } } } if resp.StatusCode != 404 { diff --git a/gitlab/resource_gitlab_pipeline_schedule_test.go b/gitlab/resource_gitlab_pipeline_schedule_test.go index 4166fc706..44e1b9b90 100644 --- a/gitlab/resource_gitlab_pipeline_schedule_test.go +++ b/gitlab/resource_gitlab_pipeline_schedule_test.go @@ -138,7 +138,9 @@ func testAccCheckGitlabPipelineScheduleDestroy(s *terraform.State) error { gotRepo, resp, err := conn.Projects.GetProject(rs.Primary.ID, nil) if err == nil { if gotRepo != nil && fmt.Sprintf("%d", gotRepo.ID) == rs.Primary.ID { - return fmt.Errorf("Repository still exists") + if gotRepo.MarkedForDeletionAt == nil { + return fmt.Errorf("Repository still exists") + } } } if resp.StatusCode != 404 { diff --git a/gitlab/resource_gitlab_pipeline_trigger_test.go b/gitlab/resource_gitlab_pipeline_trigger_test.go index 9e4ff1eef..cb6e99365 100644 --- a/gitlab/resource_gitlab_pipeline_trigger_test.go +++ b/gitlab/resource_gitlab_pipeline_trigger_test.go @@ -107,7 +107,9 @@ func testAccCheckGitlabPipelineTriggerDestroy(s *terraform.State) error { gotRepo, resp, err := conn.Projects.GetProject(rs.Primary.ID, nil) if err == nil { if gotRepo != nil && fmt.Sprintf("%d", gotRepo.ID) == rs.Primary.ID { - return fmt.Errorf("Repository still exists") + if gotRepo.MarkedForDeletionAt == nil { + return fmt.Errorf("Repository still exists") + } } } if resp.StatusCode != 404 { diff --git a/gitlab/resource_gitlab_project_hook_test.go b/gitlab/resource_gitlab_project_hook_test.go index f9601ad5e..92d2c5f34 100644 --- a/gitlab/resource_gitlab_project_hook_test.go +++ b/gitlab/resource_gitlab_project_hook_test.go @@ -163,7 +163,9 @@ func testAccCheckGitlabProjectHookDestroy(s *terraform.State) error { gotRepo, resp, err := conn.Projects.GetProject(rs.Primary.ID, nil) if err == nil { if gotRepo != nil && fmt.Sprintf("%d", gotRepo.ID) == rs.Primary.ID { - return fmt.Errorf("Repository still exists") + if gotRepo.MarkedForDeletionAt == nil { + return fmt.Errorf("Repository still exists") + } } } if resp.StatusCode != 404 { diff --git a/gitlab/resource_gitlab_project_push_rules_test.go b/gitlab/resource_gitlab_project_push_rules_test.go index 131784f45..f37874856 100644 --- a/gitlab/resource_gitlab_project_push_rules_test.go +++ b/gitlab/resource_gitlab_project_push_rules_test.go @@ -173,7 +173,9 @@ func testAccCheckGitlabProjectPushRulesDestroy(s *terraform.State) error { gotRepo, resp, err := conn.Projects.GetProject(rs.Primary.ID, nil) if err == nil { if gotRepo != nil && fmt.Sprintf("%d", gotRepo.ID) == rs.Primary.ID { - return fmt.Errorf("Repository still exists") + if gotRepo.MarkedForDeletionAt == nil { + return fmt.Errorf("Repository still exists") + } } } if resp.StatusCode != 404 { diff --git a/gitlab/resource_gitlab_project_test.go b/gitlab/resource_gitlab_project_test.go index 088c79e87..c80e173c9 100644 --- a/gitlab/resource_gitlab_project_test.go +++ b/gitlab/resource_gitlab_project_test.go @@ -380,7 +380,9 @@ func testAccCheckGitlabProjectDestroy(s *terraform.State) error { gotRepo, resp, err := conn.Projects.GetProject(rs.Primary.ID, nil) if err == nil { if gotRepo != nil && fmt.Sprintf("%d", gotRepo.ID) == rs.Primary.ID { - return fmt.Errorf("Repository still exists") + if gotRepo.MarkedForDeletionAt == nil { + return fmt.Errorf("Repository still exists") + } } } if resp.StatusCode != 404 { diff --git a/gitlab/resource_gitlab_project_variable_test.go b/gitlab/resource_gitlab_project_variable_test.go index fa526651a..b02227e31 100644 --- a/gitlab/resource_gitlab_project_variable_test.go +++ b/gitlab/resource_gitlab_project_variable_test.go @@ -119,7 +119,9 @@ func testAccCheckGitlabProjectVariableDestroy(s *terraform.State) error { gotRepo, resp, err := conn.Projects.GetProject(rs.Primary.ID, nil) if err == nil { if gotRepo != nil && fmt.Sprintf("%d", gotRepo.ID) == rs.Primary.ID { - return fmt.Errorf("Repository still exists") + if gotRepo.MarkedForDeletionAt == nil { + return fmt.Errorf("Repository still exists") + } } } if resp.StatusCode != 404 { diff --git a/gitlab/resource_gitlab_service_jira_test.go b/gitlab/resource_gitlab_service_jira_test.go index 1343ff0df..c4df399ec 100644 --- a/gitlab/resource_gitlab_service_jira_test.go +++ b/gitlab/resource_gitlab_service_jira_test.go @@ -114,7 +114,9 @@ func testAccCheckGitlabServiceJiraDestroy(s *terraform.State) error { gotRepo, resp, err := conn.Projects.GetProject(rs.Primary.ID, nil) if err == nil { if gotRepo != nil && fmt.Sprintf("%d", gotRepo.ID) == rs.Primary.ID { - return fmt.Errorf("Repository still exists") + if gotRepo.MarkedForDeletionAt == nil { + return fmt.Errorf("Repository still exists") + } } } if resp.StatusCode != 404 { diff --git a/gitlab/resource_gitlab_service_slack_test.go b/gitlab/resource_gitlab_service_slack_test.go index d03e0dc28..0eacdcfd3 100644 --- a/gitlab/resource_gitlab_service_slack_test.go +++ b/gitlab/resource_gitlab_service_slack_test.go @@ -134,7 +134,9 @@ func testAccCheckGitlabServiceSlackDestroy(s *terraform.State) error { gotRepo, resp, err := conn.Projects.GetProject(rs.Primary.ID, nil) if err == nil { if gotRepo != nil && fmt.Sprintf("%d", gotRepo.ID) == rs.Primary.ID { - return fmt.Errorf("Repository still exists") + if gotRepo.MarkedForDeletionAt == nil { + return fmt.Errorf("Repository still exists") + } } } if resp.StatusCode != 404 { From d428640f4ed6835749234e2a3b73facfacdb3fe1 Mon Sep 17 00:00:00 2001 From: Ringo De Smet Date: Wed, 1 Apr 2020 16:59:07 +0200 Subject: [PATCH 6/9] Support Github EE soft delete of groups & projects --- gitlab/resource_gitlab_group.go | 12 +++++++++++- gitlab/resource_gitlab_project.go | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gitlab/resource_gitlab_group.go b/gitlab/resource_gitlab_group.go index 4d4e20d57..4763f5288 100644 --- a/gitlab/resource_gitlab_group.go +++ b/gitlab/resource_gitlab_group.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "net/http" + "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" @@ -127,6 +128,11 @@ func resourceGitlabGroupRead(d *schema.ResourceData, meta interface{}) error { } return err } + if group.MarkedForDeletionOn != nil { + log.Printf("[DEBUG] gitlab group %s is marked for deletion", d.Id()) + d.SetId("") + return nil + } d.SetId(fmt.Sprintf("%d", group.ID)) d.Set("name", group.Name) @@ -190,7 +196,7 @@ func resourceGitlabGroupDelete(d *schema.ResourceData, meta interface{}) error { log.Printf("[DEBUG] Delete gitlab group %s", d.Id()) _, err := client.Groups.DeleteGroup(d.Id()) - if err != nil { + if err != nil && !strings.Contains(err.Error(), "Group has been already marked for deletion") { return fmt.Errorf("error deleting group %s: %s", d.Id(), err) } @@ -208,6 +214,10 @@ func resourceGitlabGroupDelete(d *schema.ResourceData, meta interface{}) error { log.Printf("[ERROR] Received error: %#v", err) return out, "Error", err } + if out.MarkedForDeletionOn != nil { + // Represents a Gitlab EE soft-delete + return out, "Deleted", nil + } return out, "Deleting", nil }, diff --git a/gitlab/resource_gitlab_project.go b/gitlab/resource_gitlab_project.go index 8b2863917..feb438be9 100644 --- a/gitlab/resource_gitlab_project.go +++ b/gitlab/resource_gitlab_project.go @@ -352,6 +352,11 @@ func resourceGitlabProjectRead(d *schema.ResourceData, meta interface{}) error { if err != nil { return err } + if project.MarkedForDeletionAt != nil { + log.Printf("[DEBUG] gitlab project %s is marked for deletion", d.Id()) + d.SetId("") + return nil + } resourceGitlabProjectSetToState(d, project) return nil @@ -544,6 +549,10 @@ func resourceGitlabProjectDelete(d *schema.ResourceData, meta interface{}) error log.Printf("[ERROR] Received error: %#v", err) return out, "Error", err } + if out.MarkedForDeletionAt != nil { + // Represents a Gitlab EE soft-delete + return out, "Deleted", nil + } return out, "Deleting", nil }, From ffee1ea1f5ce6bef3f87d37dead1bd9fe441e291 Mon Sep 17 00:00:00 2001 From: Ringo De Smet Date: Sat, 4 Apr 2020 16:28:28 +0200 Subject: [PATCH 7/9] Disable a code path which will never work in EE --- gitlab/resource_gitlab_group_test.go | 31 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/gitlab/resource_gitlab_group_test.go b/gitlab/resource_gitlab_group_test.go index d20085f0b..413d230a0 100644 --- a/gitlab/resource_gitlab_group_test.go +++ b/gitlab/resource_gitlab_group_test.go @@ -137,21 +137,22 @@ func TestAccGitlabGroup_nested(t *testing.T) { }), ), }, - { - Config: testAccGitlabNestedGroupConfig(rInt), - Check: resource.ComposeTestCheckFunc( - testAccCheckGitlabGroupExists("gitlab_group.foo", &group), - testAccCheckGitlabGroupExists("gitlab_group.foo2", &group2), - testAccCheckGitlabGroupExists("gitlab_group.nested_foo", &nestedGroup), - testAccCheckGitlabGroupAttributes(&nestedGroup, &testAccGitlabGroupExpectedAttributes{ - Name: fmt.Sprintf("nfoo-name-%d", rInt), - Path: fmt.Sprintf("nfoo-path-%d", rInt), - Description: "Terraform acceptance tests", - LFSEnabled: true, - Parent: &group, - }), - ), - }, + // TODO In EE version, re-creating on the same path where a previous group was soft-deleted doesn't work. + // { + // Config: testAccGitlabNestedGroupConfig(rInt), + // Check: resource.ComposeTestCheckFunc( + // testAccCheckGitlabGroupExists("gitlab_group.foo", &group), + // testAccCheckGitlabGroupExists("gitlab_group.foo2", &group2), + // testAccCheckGitlabGroupExists("gitlab_group.nested_foo", &nestedGroup), + // testAccCheckGitlabGroupAttributes(&nestedGroup, &testAccGitlabGroupExpectedAttributes{ + // Name: fmt.Sprintf("nfoo-name-%d", rInt), + // Path: fmt.Sprintf("nfoo-path-%d", rInt), + // Description: "Terraform acceptance tests", + // LFSEnabled: true, + // Parent: &group, + // }), + // ), + // }, }, }) } From 95277f2909814c62e4bdebbe92d051a67dcc79e4 Mon Sep 17 00:00:00 2001 From: Ringo De Smet Date: Sat, 4 Apr 2020 16:44:33 +0200 Subject: [PATCH 8/9] Deactivate Travis CI --- .travis.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 87c27272a..000000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -language: go -matrix: - fast_finish: false - include: - - name: acceptance tests EE - env: MAKE_TARGET=testacc GITLAB_LICENSE_FILE=JulienPivotto.gitlab-license GOFLAGS=-mod=vendor GO111MODULE=on GITLAB_BASE_URL=http://127.0.0.1:8080/api/v4 GITLAB_TOKEN=ACCTEST - go: "1.12.x" - - name: acceptance tests CE - env: MAKE_TARGET=testacc GOFLAGS=-mod=vendor GO111MODULE=on GITLAB_BASE_URL=http://127.0.0.1:8080/api/v4 GITLAB_TOKEN=ACCTEST - go: "1.12.x" - allow_failures: - - name: acceptance tests EE - env: MAKE_TARGET=testacc GITLAB_LICENSE_FILE=JulienPivotto.gitlab-license GOFLAGS=-mod=vendor GO111MODULE=on GITLAB_BASE_URL=http://127.0.0.1:8080/api/v4 GITLAB_TOKEN=ACCTEST - go: "1.12.x" - -install: -# This script is used by the Travis build to install a cookie for -# go.googlesource.com so rate limits are higher when using `go get` to fetch -# packages that live there. -# See: https://github.com/golang/go/issues/12933 -- bash scripts/gogetcookie.sh -- bash scripts/license.sh -- bash scripts/start-gitlab.sh - -script: -- make $MAKE_TARGET - -branches: - only: - - master From 49b79d47a88acc9a5c50597bbb4f85e8e0e3d683 Mon Sep 17 00:00:00 2001 From: Ringo De Smet Date: Sat, 4 Apr 2020 17:01:26 +0200 Subject: [PATCH 9/9] Updating Changelog for v2.5.1 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89d4d0ee5..deba90436 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ ## 2.5.1 (Unreleased) + +BUGFIXES: +* Support for soft-delete of groups and projects in Gitlab Enterprise Edition ([GH-282][GH-283][GH-285][GH-291]) + +ENHANCEMENTS: +* Switched from Travis CI to Github Actions ([GH-216]) + ## 2.5.0 (December 05, 2019) ENHANCEMENTS: