зеркало из https://github.com/Azure/ARO-RP.git
Коммит
6694293f8d
|
@ -1,18 +1,28 @@
|
||||||
|
name: push-test
|
||||||
on: push
|
on: push
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
GOPATH: /home/runner/work/rp/go
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/setup-go@v1
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v1
|
||||||
with:
|
with:
|
||||||
go-version: 1.12
|
go-version: 1.12
|
||||||
- uses: actions/checkout@v1
|
- name: Check out source
|
||||||
- run: |
|
uses: actions/checkout@v1
|
||||||
|
with:
|
||||||
|
path: go/src/github.com/jim-minter/rp
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
set -x
|
||||||
|
|
||||||
go get github.com/alvaroloes/enumer
|
go get github.com/alvaroloes/enumer
|
||||||
go get github.com/jim-minter/go-cosmosdb/cmd/gencosmosdb
|
go get github.com/jim-minter/go-cosmosdb/cmd/gencosmosdb
|
||||||
|
|
||||||
go generate ./...
|
go generate ./...
|
||||||
go build ./...
|
go build ./...
|
||||||
go test ./...
|
go test ./...
|
||||||
|
|
||||||
[[ -z $(git status -s) ]]
|
[[ -z $(git status -s) ]]
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
|
|
||||||
// Options represents API options
|
// Options represents API options
|
||||||
type Options struct {
|
type Options struct {
|
||||||
|
NoETag bool
|
||||||
PreTriggers []string
|
PreTriggers []string
|
||||||
PostTriggers []string
|
PostTriggers []string
|
||||||
}
|
}
|
||||||
|
@ -137,12 +138,3 @@ func (c *databaseClient) do(method, path, resourceType, resourceLink string, exp
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setOptions(options *Options, headers http.Header) {
|
|
||||||
if len(options.PreTriggers) > 0 {
|
|
||||||
headers.Set("X-Ms-Documentdb-Pre-Trigger-Include", strings.Join(options.PreTriggers, ","))
|
|
||||||
}
|
|
||||||
if len(options.PostTriggers) > 0 {
|
|
||||||
headers.Set("X-Ms-Documentdb-Post-Trigger-Include", strings.Join(options.PostTriggers, ","))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ package cosmosdb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
pkg "github.com/jim-minter/rp/pkg/api"
|
pkg "github.com/jim-minter/rp/pkg/api"
|
||||||
)
|
)
|
||||||
|
@ -75,9 +76,17 @@ func (c *openShiftClusterDocumentClient) all(i OpenShiftClusterDocumentIterator)
|
||||||
func (c *openShiftClusterDocumentClient) Create(partitionkey string, newopenShiftClusterDocument *pkg.OpenShiftClusterDocument, options *Options) (openShiftClusterDocument *pkg.OpenShiftClusterDocument, err error) {
|
func (c *openShiftClusterDocumentClient) Create(partitionkey string, newopenShiftClusterDocument *pkg.OpenShiftClusterDocument, options *Options) (openShiftClusterDocument *pkg.OpenShiftClusterDocument, err error) {
|
||||||
headers := http.Header{}
|
headers := http.Header{}
|
||||||
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
|
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
|
||||||
if options != nil {
|
|
||||||
setOptions(options, headers)
|
if options == nil {
|
||||||
|
options = &Options{}
|
||||||
}
|
}
|
||||||
|
options.NoETag = true
|
||||||
|
|
||||||
|
err = c.setOptions(options, newopenShiftClusterDocument, headers)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err = c.do(http.MethodPost, c.path+"/docs", "docs", c.path, http.StatusCreated, &newopenShiftClusterDocument, &openShiftClusterDocument, headers)
|
err = c.do(http.MethodPost, c.path+"/docs", "docs", c.path, http.StatusCreated, &newopenShiftClusterDocument, &openShiftClusterDocument, headers)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -98,30 +107,29 @@ func (c *openShiftClusterDocumentClient) Get(partitionkey, openShiftClusterDocum
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *openShiftClusterDocumentClient) Replace(partitionkey string, newopenShiftClusterDocument *pkg.OpenShiftClusterDocument, options *Options) (openShiftClusterDocument *pkg.OpenShiftClusterDocument, err error) {
|
func (c *openShiftClusterDocumentClient) Replace(partitionkey string, newopenShiftClusterDocument *pkg.OpenShiftClusterDocument, options *Options) (openShiftClusterDocument *pkg.OpenShiftClusterDocument, err error) {
|
||||||
if newopenShiftClusterDocument.ETag == "" {
|
|
||||||
return nil, ErrETagRequired
|
|
||||||
}
|
|
||||||
headers := http.Header{}
|
headers := http.Header{}
|
||||||
headers.Set("If-Match", newopenShiftClusterDocument.ETag)
|
|
||||||
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
|
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
|
||||||
if options != nil {
|
|
||||||
setOptions(options, headers)
|
err = c.setOptions(options, openShiftClusterDocument, headers)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = c.do(http.MethodPut, c.path+"/docs/"+newopenShiftClusterDocument.ID, "docs", c.path+"/docs/"+newopenShiftClusterDocument.ID, http.StatusOK, &newopenShiftClusterDocument, &openShiftClusterDocument, headers)
|
err = c.do(http.MethodPut, c.path+"/docs/"+newopenShiftClusterDocument.ID, "docs", c.path+"/docs/"+newopenShiftClusterDocument.ID, http.StatusOK, &newopenShiftClusterDocument, &openShiftClusterDocument, headers)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *openShiftClusterDocumentClient) Delete(partitionkey string, openShiftClusterDocument *pkg.OpenShiftClusterDocument, options *Options) error {
|
func (c *openShiftClusterDocumentClient) Delete(partitionkey string, openShiftClusterDocument *pkg.OpenShiftClusterDocument, options *Options) (err error) {
|
||||||
if openShiftClusterDocument.ETag == "" {
|
|
||||||
return ErrETagRequired
|
|
||||||
}
|
|
||||||
headers := http.Header{}
|
headers := http.Header{}
|
||||||
headers.Set("If-Match", openShiftClusterDocument.ETag)
|
|
||||||
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
|
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
|
||||||
if options != nil {
|
|
||||||
setOptions(options, headers)
|
err = c.setOptions(options, openShiftClusterDocument, headers)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return c.do(http.MethodDelete, c.path+"/docs/"+openShiftClusterDocument.ID, "docs", c.path+"/docs/"+openShiftClusterDocument.ID, http.StatusNoContent, nil, nil, headers)
|
|
||||||
|
err = c.do(http.MethodDelete, c.path+"/docs/"+openShiftClusterDocument.ID, "docs", c.path+"/docs/"+openShiftClusterDocument.ID, http.StatusNoContent, nil, nil, headers)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *openShiftClusterDocumentClient) Query(partitionkey string, query *Query) OpenShiftClusterDocumentIterator {
|
func (c *openShiftClusterDocumentClient) Query(partitionkey string, query *Query) OpenShiftClusterDocumentIterator {
|
||||||
|
@ -132,6 +140,27 @@ func (c *openShiftClusterDocumentClient) QueryAll(partitionkey string, query *Qu
|
||||||
return c.all(c.Query(partitionkey, query))
|
return c.all(c.Query(partitionkey, query))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusterDocumentClient) setOptions(options *Options, openShiftClusterDocument *pkg.OpenShiftClusterDocument, headers http.Header) error {
|
||||||
|
if options == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if !options.NoETag {
|
||||||
|
if openShiftClusterDocument.ETag == "" {
|
||||||
|
return ErrETagRequired
|
||||||
|
}
|
||||||
|
headers.Set("If-Match", openShiftClusterDocument.ETag)
|
||||||
|
}
|
||||||
|
if len(options.PreTriggers) > 0 {
|
||||||
|
headers.Set("X-Ms-Documentdb-Pre-Trigger-Include", strings.Join(options.PreTriggers, ","))
|
||||||
|
}
|
||||||
|
if len(options.PostTriggers) > 0 {
|
||||||
|
headers.Set("X-Ms-Documentdb-Post-Trigger-Include", strings.Join(options.PostTriggers, ","))
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (i *openShiftClusterDocumentListIterator) Next() (openShiftClusterDocuments *pkg.OpenShiftClusterDocuments, err error) {
|
func (i *openShiftClusterDocumentListIterator) Next() (openShiftClusterDocuments *pkg.OpenShiftClusterDocuments, err error) {
|
||||||
if i.done {
|
if i.done {
|
||||||
return
|
return
|
||||||
|
|
Загрузка…
Ссылка в новой задаче