예제 #1
0
package main

import (
	"fmt"
	"github.com/olekukonko/tablewriter"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
	"os"

	artifactory "artifactory.v401"
)

var (
	kind = kingpin.Flag("kind", "Types of repos to show").Default("all").Enum("local", "remote", "virtual", "all")
)

func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()
	data, err := client.GetRepos(*kind)
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{
			"Key",
			"Type",
			"Description",
			"Url",
		})
		for _, r := range data {
예제 #2
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)
예제 #3
0
파일: main.go 프로젝트: artpar/greconcile
package main

import (
	"encoding/json"
	"errors"
	logger "github.com/op/go-logging"
	config "github.com/spf13/viper"
	flag "gopkg.in/alecthomas/kingpin.v2"
	"io/ioutil"
	"os"
	"path/filepath"
	"time"
)

var (
	configFileName    = flag.Flag("config", "Config file name").Short('c').Required().String()
	taskDirectoryName = flag.Flag("tasks", "Task Directory name").Short('t').Required().String()
	moduleName        = "greconcile"
	mainLogger        = logger.MustGetLogger(moduleName)
)

func initLog(logConfig map[string]interface{}) {

	mainLogger.Info("LogConfig: %v", logConfig)
	_, ok := logConfig["level"]
	if ok {
		switch logConfig["level"].(string) {
		case "debug":
			logger.SetLevel(logger.NOTICE, moduleName)
		case "error":
			logger.SetLevel(logger.ERROR, moduleName)
예제 #4
0
import (
	"database/sql"
	"fmt"
	"log"
	"os"

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

	"github.com/jollheef/tin_foil_hat/config"
	"github.com/jollheef/tin_foil_hat/scoreboard"
	"github.com/jollheef/tin_foil_hat/steward"
)

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

	score = kingpin.Command("scoreboard", "View scoreboard.")

	adv = kingpin.Command("advisory", "Work with advisories.")

	advList        = adv.Command("list", "List advisories.")
	advNotReviewed = adv.Flag("not-reviewed",
		"List only not reviewed advisory.").Bool()

	advReview   = adv.Command("review", "Review advisory.")
	advReviewID = advReview.Arg("id", "advisory id").Required().Int()
	advScore    = advReview.Arg("score", "advisory id").Required().Int()

	advHide   = adv.Command("hide", "Hide advisory.")
	advHideID = advHide.Arg("id", "advisory id").Required().Int()
예제 #5
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)
예제 #6
0
파일: main.go 프로젝트: digibib/gosmtpd
	"bufio"
	"log"
	"net"
	"sync"

	"time"

	"github.com/pborman/uuid"
	"github.com/zenazn/goji"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
)

const timeout time.Duration = time.Duration(10)
const mailMaxSize = 1024 * 1024 * 2 // 2 MB

var webport = kingpin.Flag("webport", "Port the web server should run on").Default("8000").OverrideDefaultFromEnvar("WEBPORT").String()
var hostname = kingpin.Flag("hostname", "Hostname for the smtp server to listen to").Default("localhost").String()
var port = kingpin.Flag("port", "Port for the smtp server to listen to").Default("2525").String()

var forwardsmtp = kingpin.Flag("forwardsmtp", "SMTP server to relay the mail to (host:port)").Default("").OverrideDefaultFromEnvar("FORWARD_SMTP").String()
var forwardhost = kingpin.Flag("forwardhost", "The hostname after the @ that we should forward i.e. gmail.com").Default("").OverrideDefaultFromEnvar("FORWARD_HOST").String()
var forwardport = kingpin.Flag("forwardport", "The port on which email should be forwarded").Default("25").OverrideDefaultFromEnvar("FORWARD_PORT").String()
var forwarduser = kingpin.Flag("forwarduser", "The username for the forward host").Default("").OverrideDefaultFromEnvar("FORWARD_USER").String()
var forwardpassword = kingpin.Flag("forwardpassword", "Password for the user").Default("").OverrideDefaultFromEnvar("FORWARD_PASSWORD").String()

var cleanupInterval = kingpin.Flag("mailexpiration", "Time in seconds for a mail to expire, and be removed from database").Default("300").Int()

func createListener(server *MailServer) net.Listener {
	addr := "0.0.0.0:" + server.port
	listener, err := net.Listen("tcp", addr)
	if err != nil {
예제 #7
0
package main

import (
	"fmt"
	"os"

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

var (
	formatUsage = fmt.Sprintf("Format to show results [table, csv, list (usernames only - useful for piping)]")
	format      = kingpin.Flag("format", formatUsage).Short('F').Default("table").Enum("table", "list", "csv")
	sep         = kingpin.Flag("separator", "separator for csv output").Default(",").String()
)

func main() {
	kingpin.UsageTemplate(kingpin.CompactUsageTemplate).Version("1.0").Author("John E. Vincent")
	kingpin.CommandLine.Help = "List all users in Artifactory"
	kingpin.Parse()

	client := artifactory.NewClientFromEnv()
	data, err := client.GetUsers()
	if err != nil {
		fmt.Printf("%s\n", err)
		os.Exit(1)
	} else {
		if *format == "table" {
			table := tablewriter.NewWriter(os.Stdout)
			table.SetHeader([]string{"Name", "Uri"})
예제 #8
0
파일: main.go 프로젝트: strogo/md2slides
	"net/http"
	"os"
	"strconv"
	"strings"

	"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() {
예제 #9
0
파일: main.go 프로젝트: strogo/md2slides
func init() {
	themesHelp := fmt.Sprintf("Choose one: [%s].", strings.Join(availableThemes, ", "))
	theme = kingpin.Flag("theme", themesHelp).Default("reveal").String()

	kingpin.CommandLine.HelpFlag.Short('h')
}
예제 #10
0
		lines = append(lines, "FROM not valid")
	}

	if v.isRootUser() {
		if !v.Rules.AllowRootUser {
			valid = false
			lines = append(lines, "Running as root")
		}
	}

	return valid, strings.Join(lines, "\n")

}

var (
	startDaemon = kingpin.Flag("daemon", "start a simple HTTP serving your slides.").Short('d').Bool()
	port        = kingpin.Flag("port", "port where to run the server.").Short('p').Default("8080").Int()

	dockerfile = kingpin.Flag("dockerfile", "dockerfile to be analysed").Short('f').Default("Dockerfile").String()
	rulesFile  = kingpin.Flag("rules", "Rules file").Short('r').String()
)

func main() {
	kingpin.Parse()

	if *startDaemon {
		debug, _ = strconv.ParseBool(os.Getenv("DEBUG"))
		rules, _ = loadRulesFromFile("rules.yaml")
		log.Println("Daemon is listening in port", strconv.Itoa(*port))
		http.HandleFunc("/validate", validateHandler)
		http.HandleFunc("/setup", uploadHandler)
예제 #11
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()
예제 #12
0
package main

import (
	"fmt"
	"os"
	"strconv"

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

var (
	projectid = kingpin.Arg("projectid", "").Required().String()
	max       = kingpin.Flag("max", "max number of results to return").Default("200").String()
)

func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	options := make(map[string]string)
	options["max"] = *max
	data, err := client.ListProjectExecutions(*projectid, options)
	if err != nil {
		fmt.Printf("%s\n", err)
	} else {
		table := tablewriter.NewWriter(os.Stdout)
		table.SetHeader([]string{
			"ID",
			"Job Name",
			"Job Description",
예제 #13
0
package main

import (
	"bytes"
	"fmt"
	"github.com/olekukonko/tablewriter"
	kingpin "gopkg.in/alecthomas/kingpin.v2"
	"os"
	"strings"

	artifactory "artifactory.v491"
)

var (
	groupid    = kingpin.Flag("groupid", "groupid coordinate").String()
	artifactid = kingpin.Flag("artifactid", "artifactid coordinate").String()
	version    = kingpin.Flag("version", "version coordinate").String()
	classifier = kingpin.Flag("classifier", "classifier coordinate").String()
	repo       = kingpin.Flag("repo", "repo to search against. can be specified multiple times").Strings()
)

func main() {
	kingpin.Parse()
	client := artifactory.NewClientFromEnv()
	var coords artifactory.Gavc
	if groupid != nil {
		coords.GroupID = *groupid
	}
	if artifactid != nil {
		coords.ArtifactID = *artifactid
	}
예제 #14
0
package main

import (
	"fmt"
	"os"

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

var (
	filename = kingpin.Flag("file", "Full /path/to/file to import").Required().ExistingFile()
	format   = kingpin.Flag("format", "Format to import").Default("xml").Enum("xml", "yaml")
	dupe     = kingpin.Flag("dupe", "How to handle existing jobs with same name").Default("create").Enum("create", "update", "skip")
	uuid     = kingpin.Flag("uuid", "Preserve or strip uuids").Default("preserve").Enum("preserve", "remove")
	project  = kingpin.Flag("project", "Project name for imported job").Required().String()
)

func main() {
	kingpin.Parse()
	client := rundeck.NewClientFromEnv()
	importParams := rundeck.ImportParams{
		Filename: *filename,
		Format:   *format,
		Dupe:     *dupe,
		Uuid:     *uuid,
		Project:  *project,
	}
	jobid, err := client.ImportJob(importParams)
	if err != nil {
		fmt.Printf("%s\n", err)
예제 #15
0
	"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
	}

	str = fmt.Sprintf("Version: tin_foil_hat %s %s %s\n",
예제 #16
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)
	}
}
예제 #17
0
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
	LastLoggedIn             selectiveCol
예제 #18
0
파일: sacloud.go 프로젝트: dopin/go-jj
package sacloud

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

var ExitCode = 0

var (
	cli  = kingpin.New("jj", "Yet another unofficial Sacloud CLI")
	json = kingpin.Flag("json", "Output the raw json response body of the API").Bool()
	tsv  = kingpin.Flag("tsv", "Output as tsv format(default)").Bool()

	servers = cli.Command("servers", "List servers")

	api       = cli.Command("api", "Support sending a request to API")
	apiMethod = api.Arg("method", "HTTP Verb: get, put, post, delete").Required().String()
	apiPath   = api.Arg("path", "Path: /server").Required().String()
)

type OuputFormat struct {
	JSON, TSV bool
}

const VERSION = "0.0.1"

func Run(args []string) {
	kingpin.CommandLine.HelpFlag.Short('h')
	kingpin.Version(VERSION)

	opFmt := &OuputFormat{JSON: *json, TSV: *tsv}