Beispiel #1
0
package main

import (
	"fmt"
	"os"

	"github.com/olekukonko/tablewriter"
	kingpin "gopkg.in/alecthomas/kingpin.v2"

	rundeck "rundeck.v13"
)

var (
	projectid = kingpin.Arg("projectid", "").Required().String()
)

func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	top, err := client.GetHistory(*projectid)
	if err != nil {
		fmt.Printf("%s\n", err)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		for _, data := range top.Events {
			var job string
			if data.Job != nil {
				job = data.Job.ID
			} else {
				job = "<adhoc>"
			}
Beispiel #2
0
	"os"
	"syscall"
	"time"

	"github.com/jollheef/tin_foil_hat/checker"
	"github.com/jollheef/tin_foil_hat/config"
	"github.com/jollheef/tin_foil_hat/pulse"
	"github.com/jollheef/tin_foil_hat/receiver"
	"github.com/jollheef/tin_foil_hat/scoreboard"
	"github.com/jollheef/tin_foil_hat/steward"
	"github.com/jollheef/tin_foil_hat/vexillary"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
)

var (
	configPath = kingpin.Arg("config",
		"Path to configuration file.").String()

	dbReinit = kingpin.Flag("reinit", "Reinit database.").Bool()
)

var (
	commitID  string
	buildDate string
	buildTime string
)

func buildInfo() (str string) {

	if len(commitID) > 7 {
		commitID = commitID[:7] // abbreviated commit hash
	}
Beispiel #3
0
package main

import (
	artifactory "artifactory.v491"
	"fmt"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
	"os"
)

var (
	username = kingpin.Arg("username", "Username to delete").Required().String()
)

func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()
	err := client.DeleteUser(*username)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		fmt.Printf("User %s deleted\n", *username)
		os.Exit(0)
	}
}
Beispiel #4
0
package main

import (
	"fmt"
	"os"
	"strings"

	kingpin "gopkg.in/alecthomas/kingpin.v2"
	rundeck "rundeck.v13"
)

var (
	runAs      = kingpin.Flag("runas", "user to run as").String()
	nodeFilter = kingpin.Flag("nodeFilter", "node filter to use").String()
	logLevel   = kingpin.Flag("logLevel", "log level to run the job").Enum("DEBUG", "VERBOSE", "INFO", "WARN", "ERROR")
	jobId      = kingpin.Arg("jobId", "Job ID to run").Required().String()
	argString  = kingpin.Arg("argString", "arguments to pass to job").Strings()
)

func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	jobopts := rundeck.RunOptions{
		RunAs:     *runAs,
		LogLevel:  *logLevel,
		Filter:    *nodeFilter,
		Arguments: strings.Join(*argString, " "),
	}
	res, err := client.RunJob(*jobId, jobopts)
	if err != nil {
		fmt.Printf("%s\n", err)
Beispiel #5
0
package main

import (
	"fmt"
	"os"

	"github.com/olekukonko/tablewriter"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
	rundeck "rundeck.v13"
)

var (
	id = kingpin.Arg("execution_id", "the id of the execution").Required().String()
)

func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	data, err := client.GetExecution(*id)
	if err != nil {
		fmt.Printf("%s\n", err)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		headers := []string{
			"ID",
			"User",
			"Status",
			"Start Date",
			"End Date",
		}
		table.SetHeader(headers)
Beispiel #6
0
package main

import (
	"fmt"
	"os"
	"strings"

	"github.com/olekukonko/tablewriter"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
	rundeck "rundeck.v13"
)

var (
	jobid     = kingpin.Arg("jobname", "").Required().String()
	projectid = kingpin.Arg("projectname", "").Required().String()
)

func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	data, err := client.FindJobByName(*jobid, *projectid)
	if err != nil {
		fmt.Printf("%s\n", err)
	} else {
		scope := *data
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"ID", "Name", "Description", "Group", "Steps", "Node Filters"})
		var steps []string
		var nodefilters []string
		for _, d := range scope.Sequence.Steps {
			var stepDescription string
Beispiel #7
0
package main

import (
	"fmt"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
	"os"

	artifactory "artifactory.v491"
)

var (
	repo     = kingpin.Arg("repo", "repository key for upload").Required().String()
	file     = kingpin.Arg("filename", "file to upload").Required().ExistingFile()
	path     = kingpin.Arg("path", "path for deployed file").String()
	property = kingpin.Flag("property", "properties for the upload").StringMap()
	silent   = kingpin.Flag("silent", "supress output").Bool()
)

func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()

	i, err := client.DeployArtifact(*repo, *file, *path, *property)
	if err != nil {
		if *silent != true {
			fmt.Printf("%s\n", err)
		}
		os.Exit(1)
	} else {
		if *silent != true {
			fmt.Printf("%s\n", i.URI)
Beispiel #8
0
package main

import (
	"fmt"
	"os"

	kingpin "gopkg.in/alecthomas/kingpin.v2"
	rundeck "rundeck.v13"
)

var (
	ids = kingpin.Arg("ids", "ids to delete").Required().Strings()
)

func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	res, err := client.DeleteExecutions(*ids)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		fmt.Printf("Successful: %d\n", res.Successful.Count)
		if res.Failed.Count != 0 {
			fmt.Printf("Failed: %d\n", res.Failed.Count)
			for _, f := range res.Failed.Failures {
				fmt.Printf("%d - %s\n", f.ID, f.Message)
			}
		}
		os.Exit(0)
	}
Beispiel #9
0
package main

import (
	"fmt"
	"os"

	kingpin "gopkg.in/alecthomas/kingpin.v2"
	rundeck "rundeck.v13"
)

var (
	jobid  = kingpin.Arg("jobid", "The id of the job to export").Required().String()
	format = kingpin.Flag("format", "Format to export").Default("xml").Enum("xml", "yaml")
)

func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	res, err := client.ExportJob(*jobid, *format)
	if err != nil {
		fmt.Printf(err.Error())
		os.Exit(1)
	} else {
		fmt.Printf(res)
		os.Exit(0)
	}
}
Beispiel #10
0
package main

import (
	"crypto/rand"
	"encoding/base64"
	"fmt"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
	"os"

	artifactory "artifactory.v491"
)

var (
	username  = kingpin.Arg("username", "username to create").Required().String()
	email     = kingpin.Flag("email", "email address for new user").Required().String()
	showpass  = kingpin.Flag("showpass", "show randomly generated password for new user").Default("false").Bool()
	updatable = kingpin.Flag("updatable", "can user update profile?").Bool()
	group     = kingpin.Flag("group", "optional group for user. specify multiple times for multiple groups").Strings()
)

func randPass() string {
	b := make([]byte, 16)
	rand.Read(b)
	encode := base64.StdEncoding
	d := make([]byte, encode.EncodedLen(len(b)))
	encode.Encode(d, b)
	return string(d)
}

func main() {
	kingpin.Parse()
Beispiel #11
0
	"github.com/agonzalezro/md2slides/presentation"
	"github.com/gorilla/mux"

	kingpin "gopkg.in/alecthomas/kingpin.v2"
)

var (
	availableThemes = []string{"reveal", "shower", "remark"}
	theme           *string

	outputFile  = kingpin.Flag("output", "output file where to write the HTML.").Default("/dev/stdout").Short('o').OpenFile(os.O_CREATE|os.O_WRONLY, 0644)
	startDaemon = kingpin.Flag("daemon", "start a simple HTTP serving your slides.").Short('d').Bool()
	port        = kingpin.Flag("port", "port where to run the server.").Default("8080").Int()
	config      = kingpin.Flag("theme-config", "configuration for the theme (JS file)").Short('c').File()

	source = kingpin.Arg("source", "Markdown source file.").Required().File()
)

func init() {
	themesHelp := fmt.Sprintf("Choose one: [%s].", strings.Join(availableThemes, ", "))
	theme = kingpin.Flag("theme", themesHelp).Default("reveal").String()

	kingpin.CommandLine.HelpFlag.Short('h')
}

func main() {
	kingpin.Parse()
	if !contains(availableThemes, *theme) {
		kingpin.Fatalf("theme: %s not found", *theme)
	}
Beispiel #12
0
package main

import (
	"fmt"
	"os"
	"strconv"

	artifactory "artifactory.v401"
	"github.com/olekukonko/tablewriter"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
)

var (
	group = kingpin.Arg("group", "group name to show").Required().String()
)

func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()
	u, err := client.GetGroupDetails(*group)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"Name", "Description", "AutoJoin?", "Realm", "Realm Attributes"})
		table.SetAutoWrapText(false)
		table.Append([]string{
			u.Name,
			u.Description,
			strconv.FormatBool(u.AutoJoin),
Beispiel #13
0
package main

import (
	"fmt"
	"os"
	"strings"

	artifactory "artifactory.v491"
	"github.com/olekukonko/tablewriter"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
)

var (
	target = kingpin.Arg("target", "permission target to show").Required().String()
)

func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()
	u, err := client.GetPermissionTargetDetails(*target)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"Name", "Includes", "Excludes", "Repositories", "Users", "Groups"})
		row := []string{
			u.Name,
			u.IncludesPattern,
			u.ExcludesPattern,
			strings.Join(u.Repositories, "\n"),
Beispiel #14
0
package main

import (
	"fmt"
	"os"
	"strings"

	"github.com/olekukonko/tablewriter"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
	rundeck "rundeck.v13"
)

var (
	jobid = kingpin.Arg("jobid", "").Required().String()
)

func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	data, err := client.GetJob(*jobid)
	if err != nil {
		fmt.Printf("%s\n", err)
	} else {
		scope := data.Job
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{"ID", "Name", "Description", "Group", "Steps", "Node Filters"})
		var steps []string
		var nodefilters []string
		for _, d := range scope.Sequence.Steps {
			var stepDescription string
			if d.Description == "" {
Beispiel #15
0
package main

import (
	"fmt"
	"os"
	"strconv"
	"strings"

	artifactory "artifactory.v491"
	"github.com/olekukonko/tablewriter"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
)

var (
	formatUsage = fmt.Sprintf("Format to show results [table]")
	user        = kingpin.Arg("user", "User name to show").Required().String()
	format      = kingpin.Flag("format", formatUsage).Short('F').Default("table").Enum("table")
	attrs       = kingpin.Flag("attrs", "Columns to display. Cumulative last argument (i.e. -A name email)").Short('A').Strings()
)

/*
type selectiveCol struct {
	Header string
	Data   string
}

type selectiveResults struct {
	Name                     selectiveCol
	Email                    selectiveCol
	Password                 selectiveCol
	Updatable                selectiveCol
Beispiel #16
0
package main

import (
	"fmt"
	"os"

	kingpin "gopkg.in/alecthomas/kingpin.v2"
	rundeck "rundeck.v13"
)

var (
	project = kingpin.Arg("project", "project to delete all executions for").Required().String()
)

func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	res, err := client.DeleteAllExecutionsForProject(*project, 200)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		fmt.Printf("Successful: %d\n", res.Successful.Count)
		if res.Failed.Count != 0 {
			fmt.Printf("Failed: %d\n", res.Failed.Count)
			for _, f := range res.Failed.Failures {
				fmt.Printf("%d - %s\n", f.ID, f.Message)
			}
		}
		os.Exit(0)
	}
Beispiel #17
0
package main

import (
	"fmt"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
	"os"
	"reflect"
	"strconv"
	"strings"

	artifactory "artifactory.v491"
	"github.com/olekukonko/tablewriter"
)

var (
	repo = kingpin.Arg("repo", "Repo to show").Required().String()
)

func makeBaseRow(b artifactory.RepoConfig) []string {
	s := reflect.ValueOf(b)
	baseRow := []string{
		s.FieldByName("Key").String(),
		s.FieldByName("RClass").String(),
		s.FieldByName("PackageType").String(),
		s.FieldByName("Description").String(),
		s.FieldByName("Notes").String(),
		strconv.FormatBool((s.FieldByName("BlackedOut").Bool())),
		strconv.FormatBool((s.FieldByName("HandleReleases").Bool())),
		strconv.FormatBool((s.FieldByName("HandleSnapshots").Bool())),
		s.FieldByName("ExcludesPattern").String(),
		s.FieldByName("IncludesPattern").String(),
Beispiel #18
0
package main

import (
	"fmt"
	"os"

	kingpin "gopkg.in/alecthomas/kingpin.v2"
	rundeck "rundeck.v13"
)

var (
	id = kingpin.Arg("id", "id to delete").Required().String()
)

func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	err := client.DeleteExecution(*id)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		os.Exit(0)
	}
}