go-cosmosdb

module
v0.0.0-...-88298ca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2024 License: Apache-2.0

README

go-cosmosdb

Minimal go cosmosdb rest client generator. Repository helps to generate go clients for cosmosdb based on the go structs.

https://docs.microsoft.com/en-gb/rest/api/cosmos-db

Tests

Tests expects CosmosDB database to to be present.

  1. Create cosmosdb for our example:
# create resource group
az group create --name  go-cosmosdb-test-rg --location eastus
# create cosmosdb
az cosmosdb create --name go-cosmosdb-test --resource-group go-cosmosdb-test-rg
  1. Create env file from env.example example
export RESOURCEGROUP=go-cosmosdb-test-rg
export COSMOSDB_ACCOUNT=go-cosmosdb-test
export COSMOSDB_KEY=$(az cosmosdb keys list -g $RESOURCEGROUP -n $COSMOSDB_ACCOUNT --query primaryMasterKey -o tsv)
  1. Run test
source ./env
make test

Example

See example/hello-world folder for code example.

Clients are generated by executing make generate. Generators are defined in example/cosmosdb/generate.go where we tell library to generate us clients for Person and People structures/documents.

//go:generate go run github.com/jewzaam/go-cosmosdb/cmd/gencosmosdb github.com/jewzaam/go-cosmosdb/example/types,Person,People
//go:generate gofmt -s -w .

Run example:

source ./env
go run ./example/hello-world

Directories

Path Synopsis
cmd
example
pkg
gencosmosdb
Code generated for package gencosmosdb by go-bindata DO NOT EDIT.
Code generated for package gencosmosdb by go-bindata DO NOT EDIT.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL