Skip to content

kentik/community_sdk_golang

Repository files navigation

community_sdk_golang

Go Reference

This repository is the Kentik Go SDK for the community.

kentikapi package contains Go client library for Kentik APIs.

Requirements

  • Go >= 1.15

Installation

Install the library:

go get github.com/kentik/community_sdk_golang/kentikapi

Usage

To use the SDK, import packages of github.com/kentik/community_sdk_golang Go module.

Library documentation: https://pkg.go.dev/github.com/kentik/community_sdk_golang

Usage examples: examples Note that examples are placed in Go test files (e.g. users_example_test.go) to be easily runnable.

Running examples

Run an example:

export KTAPI_AUTH_EMAIL=<Kentik API authentication email>
export KTAPI_AUTH_TOKEN=<Kentik API authentication token>

# Run from a Go module, e.g. the root of this repository
# Adjust -run parameter to filter example names
go test -tags examples -count 1 -v -run Users github.com/kentik/community_sdk_golang/examples

To configure timeout for a client call for Cloud Export or Synthetics use context.WithTimeout() and pass it to the request function. See an example.

Development

Anybody who wants to contribute to development is welcome to provide pull requests. To work on the SDK, install tools listed in requirements section.

Optional tools:

Development steps:

  • Compile the code: go build ./...
  • Run tests: go test ./...
  • Run all tests, including usage examples: go test -tags examples ./...
  • Run golangci-lint: golangci-lint run ./...
  • Format the code: ./tools/fmt.sh
  • Generate code for Synthetics and Cloud Export:
    • Generate the client: ./generate_client.sh
    • Generate the fake server: ./generate_server.sh
    • Generate documentation: ./generate_docs.sh

Subset of the code is generated from API specification available at:

The OpenAPI Generator is used for code generation: https://openapi-generator.tech/. Generated code is checked-in to the repository, so that the user can go get the library.

Note that the generated code scaffolding needs to be complemented with actual logic implementation. Here are the lists of generated files of the fake server that need to be filled manually:

Release

Release process for the SDK is based on Git repository tags that follow semantic versioning.

To release the SDK:

  1. Make sure that all code that you want to release is in master branch.
  2. Navigate to repository releases page, click Draft a new release button and put tag version (in v[0-9].[0-9].[0-9] format), name and description.