GithubHelp home page GithubHelp logo

fredericalix / go-rundeck Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lusis/go-rundeck

0.0 2.0 0.0 99 KB

Library and Utilities for interacting with Rundeck from Go

License: Other

Makefile 1.40% Go 98.60%

go-rundeck's Introduction

go-rundeck

Build Status Go library and utilities for interacting with Rundeck. It currently supports configuration via environment variables only and supports either token authentication or username/password authentication. (v13 only)

Configuration

  • set RUNDECK_URL to the base url of your rundeck installation (i.e. http://localhost:4000 or https://my.rundeck.domain.com)

  • set EITHER RUNDECK_TOKEN or RUNDECK_USERNAME and RUNDECK_PASSWORD (only if using v13 api)

  • if all three are set RUNDECK_TOKEN takes precendence

Again, username/password authentication are ONLY supported in rundeck.v13 and higher. The original rundeck.v12 only supports token authentication.

Usage

There are two ways to use this:

  • as a library
  • just for the unmarshal
  • via the bundled utilities

as a library

package main

import (
	"fmt"

	rundeck "github.com/lusis/go-rundeck/src/rundeck.v17"
)

func main() {
	/*
		NewClientFromEnv requires two (or three) environement variables:
		- RUNDECK_URL
		- RUNDECK_TOKEN
		if RUNDECK_TOKEN is empty, RUNDECK_USERNAME/RUNDECK_PASSWORD are required
	*/
	client := rundeck.NewClientFromEnv()
	data, err := client.ListProjects()
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("%+v\n", data)
	}
}

for unmarshalling existing data into structs

This is what the test cases do with the mock data

package main

import (
        "encoding/xml"
        "io/ioutil"
        "os"
)

	xmlfile, err := os.Open("assets/test/user_token.xml")
	if err != nil {
		t.Fatal(err.Error())
	}
	defer xmlfile.Close()
	xmlData, _ := ioutil.ReadAll(xmlfile)
	var s Tokens
	xml.Unmarshal(xmlData, &s)

	fmt.Printf("%+v", s)

bundled utilities

git clone https://github.com/lusis/go-rundeck.git
cd go-rundeck
make all
RUNDECK_URL=http://rundeck.local:4440 RUNDECK_TOKEN=XXXXXXX bin/rundeck-list-projects
+---------+-------------+-----------------------------------------------------------+
|  NAME   | DESCRIPTION |                            URL                            |
+---------+-------------+-----------------------------------------------------------+
| FOOPROJ | A project   | http://rundeck.local:4440/api/12/project/FOOPROJ          |
+---------+-------------+-----------------------------------------------------------+

Note on versioning

The initial release of this repo was built for rundeck API v12. Each rundeck release adds new or changed functionality. I'm now using a v17 install of Rundeck. The v13 API is the last before several changes in the v14 api.

For now I plan on keeping a different directory for EACH version on the master branch even though there will be quite a bit of code duplication. I reserve the right to make changes to the internals of the library as well in each versioned directory. Some of this is happening with v13 as I ended up shooting myself in the foot with the initial implementation and didn't leave room to change with the rundeck API.

The question becomes how to handle the bundled utilities. I'm likely going to break those out into separate repos and version them separately.

TODO

  • Flesh out more tests
  • More utilities
  • Wrapper cli for sub-utilities

go-rundeck's People

Contributors

lusis avatar fredericalix avatar jbguerraz avatar

Watchers

James Cloos avatar  avatar

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.