Git Product home page Git Product logo

controller-sdk-go's Introduction

Deis Workflow is no longer maintained.
Please read the announcement for more detail.
09/07/2017 Deis Workflow v2.18 final release before entering maintenance mode
03/01/2018 End of Workflow maintenance: critical patches no longer merged
Hephy is a fork of Workflow that is actively developed and accepts code contributions.

Controller Go SDK

Build Status codecov Go Report Card codebeat badge GoDoc

This is the Go SDK for interacting with the Deis Controller.

Usage

import deis "github.com/deis/controller-sdk-go"
import "github.com/deis/controller-sdk-go/apps"

Construct a deis client to interact with the controller API. Then, get the first 100 apps the user has access to.

//                    Verify SSL, Controller URL, API Token
client, err := deis.New(true, "deis.test.io", "abc123")
if err != nil {
    log.Fatal(err)
}
apps, _, err := apps.List(client, 100)
if err != nil {
    log.Fatal(err)
}

Authentication

import deis "github.com/deis/controller-sdk-go"
import "github.com/deis/controller-sdk-go/auth"

If you don't already have a token for a user, you can retrieve one with a username and password.

// Create a client with a blank token to pass to login.
client, err := deis.New(true, "deis.test.io", "")
if err != nil {
    log.Fatal(err)
}
token, err := auth.Login(client, "user", "password")
if err != nil {
    log.Fatal(err)
}
// Set the client to use the retrieved token
client.Token = token

For a complete usage guide to the SDK, see full package documentation.

controller-sdk-go's People

Contributors

aledbf avatar arschles avatar babarinde avatar benwilber avatar carmstrong avatar clayzermk1 avatar developerinlondon avatar fabiob avatar helgi avatar jgmize avatar johanneswuerbach avatar joshua-anderson avatar kmala avatar krancour avatar laurrentt avatar mboersma avatar nathansamson avatar ngpestelos avatar phspagiari avatar pmelmon avatar public avatar rochacon avatar romansergey avatar shanejonas avatar smothiki avatar softr8 avatar technosophos avatar xe avatar zinuzoid avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

controller-sdk-go's Issues

Better error handling

Right now don't return any constant error type for SDK problems, making it very hard for libraries to check what type of error we are returning.

For example, this code from the CLI shows just how hard and ugly checking error types currently is:

err = auth.Delete(c, username)
cleanup := fmt.Errorf("\n%s %s\n\n", "409", "Conflict")
if reflect.DeepEqual(err, cleanup) {
    fmt.Printf("%s still has application associated with it. Transfer ownership or delete them first\n", username)
    return nil
}

Setup Travis CI

We already have test and a .travis.yml file setup, so a repo admin needs to flip the switch in the Travis CI interface to enable it.

Jenkinsfile: best way to derive actual PR commit

As https://ci.deis.io/job/Deis/pipeline-syntax/globals doesn't appear to expose the actual PR commit sha, we run an incantation along the lines of git rev-parse HEAD | git log --pretty=%P -n 1 | cut -c1-40 to derive it. (fwiw, we also have to use that first git rev-parse HEAD command to grab the merge commit)

We should either find the best practice git command fu to derive the PR commit or see about filing an issue upstream to the Jenkins Pipeline project about exposing it. (Also, the GitHub Pull Request Plugin gives us this info when used with the jobs defined in DSL in the https://github.com/deis/jenkins-jobs repo -- we also might consider seeing if this plugin can be used in a Jenkinsfile)

Enable requiring a particular workflow-cli version/commit

Currently for testing PRs in this repo, we check out the master branch of the workflow-cli repo and build it from scratch with the controller-sdk-go changes.

We should create a mechanism for checking out a forked workflow-cli repo at a certain commit if it is required by, for instance, Requires workflow-cli#<issue_number>.

sdk e2e pipeline

deis/workflow#359 describes the need and approach for a pipeline to test commits in this repo. Current thought is the pipeline will consist of the following 3 jobs:

  1. pr commit to sdk triggers sdk job which only really passes down relevant info (commit sha, repo name) to
  2. cli job which looks like it does now but with added functionality to:
    • update glide.yaml with sha and repo name received from 1
    • glide up
    • make build upload-gcs
      then kicking off
  3. e2e job which is already set up to look for binary deployed to gcs from 2 here

deis auth:regenerate panic after v2.3.0 -> v2.4.0 upgrade

Steps to reproduce:

  • Install Workflow v2.3.0
  • Upgrade to v2.4.0
  • deis apps returns: Error: Unauthorized: Missing or Invalid Token
  • Run deis auth:regenerate
○ → deis auth:regenerate
panic: runtime error: invalid memory address or nil pointer dereference
    panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x160881]

goroutine 1 [running]:
panic(0x4e12a0, 0xc82000e100)
    /usr/local/go/src/runtime/panic.go:481 +0x3e6
github.com/deis/workflow-cli/vendor/github.com/deis/controller-sdk-go/auth.Regenerate.func1(0x0)
    /go/src/github.com/deis/workflow-cli/vendor/github.com/deis/controller-sdk-go/auth/auth.go:110 +0xb1
panic(0x4e12a0, 0xc82000e100)
    /usr/local/go/src/runtime/panic.go:443 +0x4e9
github.com/deis/workflow-cli/vendor/github.com/deis/controller-sdk-go/auth.Regenerate(0xc8202100e0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /go/src/github.com/deis/workflow-cli/vendor/github.com/deis/controller-sdk-go/auth/auth.go:119 +0x4a1
github.com/deis/workflow-cli/cmd.Regenerate(0x0, 0x0, 0xc82011dc00, 0x0, 0x0)
    /go/src/github.com/deis/workflow-cli/cmd/auth.go:279 +0xa4
github.com/deis/workflow-cli/parser.authRegenerate(0xc82006e090, 0x1, 0x1, 0x0, 0x0)
    /go/src/github.com/deis/workflow-cli/parser/auth.go:238 +0x290
github.com/deis/workflow-cli/parser.Auth(0xc82006e090, 0x1, 0x1, 0x0, 0x0)
    /go/src/github.com/deis/workflow-cli/parser/auth.go:40 +0x686
main.Command(0xc82006e090, 0x1, 0x1, 0x1a20b5)
    /go/src/github.com/deis/workflow-cli/deis.go:93 +0xe47
main.main()
    /go/src/github.com/deis/workflow-cli/deis.go:18 +0x60
cat ~/.deis/client.json
{"username":"admin","ssl_verify":false,"controller":"http://deis.example.com","token":"eb648a2fb4d5b9b8dccffd88ae585b84f4b5c475","response_limit":0}

Remove dependency on github.com/deis/pkg/time

I believe github.com/deis/pkg/time is only used in one place - for time formatting between the server and the client. However, this package comes with dependencies on k8s.io/kubernetes/pkg/..., which is huge. This issue is for removing the dependency altogether, so that we don't have to pull in a 100MB+ (iirc) dependency to get 1 constant

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.