Beispiel #1
0
// Simple wrapper to add multiple resources
func AddResources(fileName, resourceName string, keys []string, c *cli.Context) error {
	setStoreFormatFromFileName(fileName)
	config := util.Config{
		IgnoreList:        c.GlobalStringSlice("exclude-attr"),
		Timeout:           int(c.Duration("timeout") / time.Millisecond),
		AllowInsecure:     c.Bool("insecure"),
		NoFollowRedirects: c.Bool("no-follow-redirects"),
	}

	var gossConfig GossConfig
	if _, err := os.Stat(fileName); err == nil {
		gossConfig = ReadJSON(fileName)
	} else {
		gossConfig = *NewGossConfig()
	}

	sys := system.New(c)

	for _, key := range keys {
		if err := AddResource(fileName, gossConfig, resourceName, key, c, config, sys); err != nil {
			return err
		}
	}
	WriteJSON(fileName, gossConfig)

	return nil
}
Beispiel #2
0
// AddCommand adds a Note
func AddCommand(c *cli.Context, i storage.Impl) (n storage.Note, err error) {
	nName, err := NoteName(c)
	if err != nil {
		return n, err
	}

	if exists := i.NoteExists(nName); exists == true {
		return n, fmt.Errorf("Note already exists")
	}

	n.Name = nName
	n.Temporary = c.Bool("t")

	// Only open editor if -p (read from clipboard) isnt set
	if c.IsSet("p") {
		nText, err := clipboard.ReadAll()
		if err != nil {
			return n, err
		}
		n.Text = nText
	} else {
		if err := writer.WriteNote(&n); err != nil {
			return n, err
		}
	}

	if err := i.SaveNote(&n); err != nil {
		return n, err
	}

	return n, nil
}
Beispiel #3
0
// ProjectPull pulls images for services.
func ProjectPull(p project.APIProject, c *cli.Context) error {
	err := p.Pull(context.Background(), c.Args()...)
	if err != nil && !c.Bool("ignore-pull-failures") {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
Beispiel #4
0
func startContainer(context *cli.Context, spec *specs.Spec, create bool) (int, error) {
	id := context.Args().First()
	if id == "" {
		return -1, errEmptyID
	}
	container, err := createContainer(context, id, spec)
	if err != nil {
		return -1, err
	}
	// Support on-demand socket activation by passing file descriptors into the container init process.
	listenFDs := []*os.File{}
	if os.Getenv("LISTEN_FDS") != "" {
		listenFDs = activation.Files(false)
	}
	r := &runner{
		enableSubreaper: !context.Bool("no-subreaper"),
		shouldDestroy:   true,
		container:       container,
		listenFDs:       listenFDs,
		console:         context.String("console"),
		detach:          context.Bool("detach"),
		pidFile:         context.String("pid-file"),
		create:          create,
	}
	return r.run(&spec.Process)
}
Beispiel #5
0
// ProjectDelete deletes services.
func ProjectDelete(p project.APIProject, c *cli.Context) error {
	options := options.Delete{
		RemoveVolume: c.Bool("v"),
	}
	if !c.Bool("force") {
		stoppedContainers, err := p.Containers(context.Background(), project.Filter{
			State: project.Stopped,
		}, c.Args()...)
		if err != nil {
			return cli.NewExitError(err.Error(), 1)
		}
		if len(stoppedContainers) == 0 {
			fmt.Println("No stopped containers")
			return nil
		}
		fmt.Printf("Going to remove %v\nAre you sure? [yN]\n", strings.Join(stoppedContainers, ", "))
		var answer string
		_, err = fmt.Scanln(&answer)
		if err != nil {
			return cli.NewExitError(err.Error(), 1)
		}
		if answer != "y" && answer != "Y" {
			return nil
		}
	}
	err := p.Delete(context.Background(), options, c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
Beispiel #6
0
// ProjectLog gets services logs.
func ProjectLog(p project.APIProject, c *cli.Context) error {
	err := p.Log(context.Background(), c.Bool("follow"), c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
Beispiel #7
0
// Executes the "apply" command
func execApplyCommand(c *cli.Context) error {
	if len(c.Args()) < 1 {
		return cli.NewExitError(errNoModuleName.Error(), 64)
	}

	L := lua.NewState()
	defer L.Close()
	config := &catalog.Config{
		Module:   c.Args()[0],
		DryRun:   c.Bool("dry-run"),
		Logger:   resource.DefaultLogger,
		SiteRepo: c.String("siterepo"),
		L:        L,
	}

	katalog := catalog.New(config)
	if err := katalog.Load(); err != nil {
		if err != nil {
			return cli.NewExitError(err.Error(), 1)
		}
	}

	if err := katalog.Run(); err != nil {
		return cli.NewExitError(err.Error(), 1)
	}

	return nil
}
func run(c *cli.Context) error {
	if c.String("env-file") != "" {
		_ = godotenv.Load(c.String("env-file"))
	}

	plugin := Plugin{
		Repo: Repo{
			Owner: c.String("repo.owner"),
			Name:  c.String("repo.name"),
		},
		Build: Build{
			Event: c.String("build.event"),
		},
		Commit: Commit{
			Ref: c.String("commit.ref"),
		},
		Config: Config{
			APIKey:     c.String("api-key"),
			Files:      c.StringSlice("files"),
			FileExists: c.String("file-exists"),
			Checksum:   c.StringSlice("checksum"),
			Draft:      c.Bool("draft"),
			BaseURL:    c.String("base-url"),
			UploadURL:  c.String("upload-url"),
		},
	}

	return plugin.Exec()
}
Beispiel #9
0
func printVersionCmd(c *cli.Context) error {
	fullVersion := c.Bool("full")

	if err := output.ConfigureOutputFormat(c); err != nil {
		log.Fatalf("Failed to configure output format, error: %s", err)
	}

	versionOutput := VersionOutputModel{
		Version: version.VERSION,
	}

	if fullVersion {
		versionOutput.FormatVersion = models.Version
		versionOutput.BuildNumber = version.BuildNumber
		versionOutput.Commit = version.Commit
	}

	if output.Format == output.FormatRaw {
		if fullVersion {
			fmt.Fprintf(c.App.Writer, "version: %v\nformat version: %v\nbuild number: %v\ncommit: %v\n", versionOutput.Version, versionOutput.FormatVersion, versionOutput.BuildNumber, versionOutput.Commit)
		} else {
			fmt.Fprintf(c.App.Writer, "%v\n", versionOutput.Version)
		}
	} else {
		output.Print(versionOutput, output.Format)
	}

	return nil
}
Beispiel #10
0
func before(c *cli.Context) error {
	// Log level
	if logLevel, err := log.ParseLevel(c.String(LogLevelKey)); err != nil {
		log.Fatal("Failed to parse log level:", err)
	} else {
		log.SetLevel(logLevel)
	}

	if len(c.Args()) != 0 && c.Args().First() != "version" && !c.Bool(HelpKey) && !c.Bool(VersionKey) {
		if err := MachineWorkdir.Set(c.String(WorkdirKey)); err != nil {
			log.Fatalf("Failed to set MachineWorkdir: %s", err)
		}
		if MachineWorkdir.String() == "" {
			log.Fatalln("No Workdir specified!")
		}
	}
	MachineWorkdir.Freeze()

	if err := MachineConfigTypeID.Set(c.String(ConfigTypeIDParamKey)); err != nil {
		log.Fatalf("Failed to set MachineConfigTypeID: %s", err)
	}
	log.Debugf("MachineConfigTypeID: %s", MachineConfigTypeID)

	if err := MachineParamsAdditionalEnvs.Set(c.StringSlice(EnvironmentParamKey)); err != nil {
		log.Fatalf("Failed to set MachineParamsAdditionalEnvs: %s", err)
	}
	log.Debugf("MachineParamsAdditionalEnvs: %s", MachineParamsAdditionalEnvs)
	MachineParamsAdditionalEnvs.Freeze()

	return nil
}
Beispiel #11
0
func run(c *cli.Context) error {
	if c.String("env-file") != "" {
		_ = godotenv.Load(c.String("env-file"))
	}

	plugin := Plugin{
		Key:                    c.String("access-key"),
		Secret:                 c.String("secret-key"),
		Bucket:                 c.String("bucket"),
		Region:                 c.String("region"),
		Source:                 c.String("source"),
		Target:                 c.String("target"),
		Delete:                 c.Bool("delete"),
		Access:                 c.Generic("access").(*StringMapFlag).Get(),
		CacheControl:           c.Generic("cache-control").(*StringMapFlag).Get(),
		ContentType:            c.Generic("content-type").(*StringMapFlag).Get(),
		ContentEncoding:        c.Generic("content-encoding").(*StringMapFlag).Get(),
		Metadata:               c.Generic("metadata").(*DeepStringMapFlag).Get(),
		Redirects:              c.Generic("redirects").(*MapFlag).Get(),
		CloudFrontDistribution: c.String("cloudfront-distribution"),
		DryRun:                 c.Bool("dry-run"),
	}

	return plugin.Exec()
}
func initialize(c *cli.Context, terraformCommand string) TerraformOperation {
	if len(c.Args()) < 1 {
		fmt.Printf("Incorrect usage\n")
		fmt.Printf("%s <environment>\n", terraformCommand)
		os.Exit(1)
	}

	fmt.Println(c.Args())
	environment := c.Args()[0]

	security.Apply(c.String("security"), c)

	fmt.Println()
	fmt.Println("Execute Terraform command")
	fmt.Println("Command:    ", command.Bold(terraformCommand))
	fmt.Println("Environment:", command.Bold(environment))
	fmt.Println()

	configLocation := c.String("config-location")
	config := terraform_config.LoadConfig(configLocation, environment)

	getState(c.Bool("no-sync"), config, environment)

	return TerraformOperation{
		command:     terraformCommand,
		environment: environment,
		config:      config,
		args:        os.Args[2:],
	}
}
Beispiel #13
0
func runCreateUser(c *cli.Context) error {
	if !c.IsSet("name") {
		return fmt.Errorf("Username is not specified")
	} else if !c.IsSet("password") {
		return fmt.Errorf("Password is not specified")
	} else if !c.IsSet("email") {
		return fmt.Errorf("Email is not specified")
	}

	if c.IsSet("config") {
		setting.CustomConf = c.String("config")
	}

	setting.NewContext()
	models.LoadConfigs()
	models.SetEngine()

	if err := models.CreateUser(&models.User{
		Name:     c.String("name"),
		Email:    c.String("email"),
		Passwd:   c.String("password"),
		IsActive: true,
		IsAdmin:  c.Bool("admin"),
	}); err != nil {
		return fmt.Errorf("CreateUser: %v", err)
	}

	fmt.Printf("New user '%s' has been successfully created!\n", c.String("name"))
	return nil
}
Beispiel #14
0
func statusCommand(c *cli.Context) {
	url := Config.Get(c.String("name"))
	fmt.Println(c.String("name"), "-", url)
	printJobQueue(url, c.Bool("dump"))
	fmt.Println("")
	printServerInfo(url)
}
Beispiel #15
0
func createContainer(context *cli.Context, id string, spec *specs.Spec) (libcontainer.Container, error) {
	config, err := specconv.CreateLibcontainerConfig(&specconv.CreateOpts{
		CgroupName:       id,
		UseSystemdCgroup: context.GlobalBool("systemd-cgroup"),
		NoPivotRoot:      context.Bool("no-pivot"),
		NoNewKeyring:     context.Bool("no-new-keyring"),
		Spec:             spec,
	})
	if err != nil {
		return nil, err
	}

	if _, err := os.Stat(config.Rootfs); err != nil {
		if os.IsNotExist(err) {
			return nil, fmt.Errorf("rootfs (%q) does not exist", config.Rootfs)
		}
		return nil, err
	}

	factory, err := loadFactory(context)
	if err != nil {
		return nil, err
	}
	return factory.Create(id, config)
}
Beispiel #16
0
// Version prints the libcompose version number and additionnal informations.
func Version(c *cli.Context) error {
	if c.Bool("short") {
		fmt.Println(version.VERSION)
		return nil
	}

	tmpl, err := template.New("").Parse(versionTemplate)
	if err != nil {
		logrus.Fatal(err)
	}

	v := struct {
		Version   string
		GitCommit string
		GoVersion string
		BuildTime string
		Os        string
		Arch      string
	}{
		Version:   version.VERSION,
		GitCommit: version.GITCOMMIT,
		GoVersion: runtime.Version(),
		BuildTime: version.BUILDTIME,
		Os:        runtime.GOOS,
		Arch:      runtime.GOARCH,
	}

	if err := tmpl.Execute(os.Stdout, v); err != nil {
		logrus.Fatal(err)
	}
	fmt.Printf("\n")
	return nil
}
Beispiel #17
0
// mkCommandFunc executes the "mk" command.
func mkCommandFunc(c *cli.Context, ki client.KeysAPI) {
	if len(c.Args()) == 0 {
		handleError(c, ExitBadArgs, errors.New("key required"))
	}
	key := c.Args()[0]
	value, err := argOrStdin(c.Args(), os.Stdin, 1)
	if err != nil {
		handleError(c, ExitBadArgs, errors.New("value required"))
	}

	ttl := c.Int("ttl")
	inorder := c.Bool("in-order")

	var resp *client.Response
	ctx, cancel := contextWithTotalTimeout(c)
	if !inorder {
		// Since PrevNoExist means that the Node must not exist previously,
		// this Set method always creates a new key. Therefore, mk command
		// succeeds only if the key did not previously exist, and the command
		// prevents one from overwriting values accidentally.
		resp, err = ki.Set(ctx, key, value, &client.SetOptions{TTL: time.Duration(ttl) * time.Second, PrevExist: client.PrevNoExist})
	} else {
		// If in-order flag is specified then create an inorder key under
		// the directory identified by the key argument.
		resp, err = ki.CreateInOrder(ctx, key, value, &client.CreateInOrderOptions{TTL: time.Duration(ttl) * time.Second})
	}
	cancel()
	if err != nil {
		handleError(c, ExitServerError, err)
	}

	printResponseKey(resp, c.GlobalString("output"))
}
// createCloudConfig creates a config object that supports cloud and (optionally) local mode.
func createCloudConfig(context *cli.Context, xmppJID, robotRefreshToken, userRefreshToken, shareScope, proxyName string, localEnable bool) *lib.Config {
	return &lib.Config{
		LocalPrintingEnable: localEnable,
		CloudPrintingEnable: true,

		XMPPJID:                   xmppJID,
		RobotRefreshToken:         robotRefreshToken,
		UserRefreshToken:          userRefreshToken,
		ShareScope:                shareScope,
		ProxyName:                 proxyName,
		XMPPServer:                lib.DefaultConfig.XMPPServer,
		XMPPPort:                  uint16(context.Int("xmpp-port")),
		XMPPPingTimeout:           context.String("xmpp-ping-timeout"),
		XMPPPingInterval:          context.String("xmpp-ping-interval"),
		GCPBaseURL:                lib.DefaultConfig.GCPBaseURL,
		GCPOAuthClientID:          context.String("gcp-oauth-client-id"),
		GCPOAuthClientSecret:      context.String("gcp-oauth-client-secret"),
		GCPOAuthAuthURL:           lib.DefaultConfig.GCPOAuthAuthURL,
		GCPOAuthTokenURL:          lib.DefaultConfig.GCPOAuthTokenURL,
		GCPMaxConcurrentDownloads: uint(context.Int("gcp-max-concurrent-downloads")),

		NativeJobQueueSize:        uint(context.Int("native-job-queue-size")),
		NativePrinterPollInterval: context.String("native-printer-poll-interval"),
		CUPSJobFullUsername:       lib.PointerToBool(context.Bool("cups-job-full-username")),
		PrefixJobIDToJobTitle:     lib.PointerToBool(context.Bool("prefix-job-id-to-job-title")),
		DisplayNamePrefix:         context.String("display-name-prefix"),
		PrinterBlacklist:          lib.DefaultConfig.PrinterBlacklist,
		PrinterWhitelist:          lib.DefaultConfig.PrinterWhitelist,
		LogLevel:                  context.String("log-level"),

		LocalPortLow:  uint16(context.Int("local-port-low")),
		LocalPortHigh: uint16(context.Int("local-port-high")),
	}
}
// updateGCPPrinter updates settings for a GCP printer.
func updateGCPPrinter(context *cli.Context) {
	config := getConfig(context)
	gcpConn := getGCP(config)

	var diff lib.PrinterDiff
	diff.Printer = lib.Printer{GCPID: context.String("printer-id")}

	if context.Bool("enable-quota") {
		diff.Printer.QuotaEnabled = true
		diff.QuotaEnabledChanged = true
	} else if context.Bool("disable-quota") {
		diff.Printer.QuotaEnabled = false
		diff.QuotaEnabledChanged = true
	}
	if context.Int("daily-quota") > 0 {
		diff.Printer.DailyQuota = context.Int("daily-quota")
		diff.DailyQuotaChanged = true
	}
	err := gcpConn.Update(&diff)
	if err != nil {
		fmt.Printf("Failed to update GCP printer %s: %s", context.String("printer-id"), err)
	} else {
		fmt.Printf("Updated GCP printer %s", context.String("printer-id"))
	}
}
Beispiel #20
0
func execProcess(context *cli.Context) (int, error) {
	container, err := getContainer(context)
	if err != nil {
		return -1, err
	}
	path := context.String("process")
	if path == "" && len(context.Args()) == 1 {
		return -1, fmt.Errorf("process args cannot be empty")
	}
	detach := context.Bool("detach")
	state, err := container.State()
	if err != nil {
		return -1, err
	}
	bundle := utils.SearchLabels(state.Config.Labels, "bundle")
	p, err := getProcess(context, bundle)
	if err != nil {
		return -1, err
	}
	r := &runner{
		enableSubreaper: false,
		shouldDestroy:   false,
		container:       container,
		console:         context.String("console"),
		detach:          detach,
		pidFile:         context.String("pid-file"),
	}
	return r.run(p)
}
Beispiel #21
0
func heimdallBefore(c *cli.Context) error {
	if c.Bool("verbose") {
		log.SetLevel(log.DebugLevel)
	}

	redisPool = newPool(c.String("redis"), c.String("redis-password"))
	return nil
}
func CmdPlan(c *cli.Context) error {
	operation := initialize(c, "plan")
	if c.Bool("destroy") {
		operation.extraArgs = "-destroy"
	}
	run(operation)
	return nil
}
Beispiel #23
0
// Before set before handler when start run cli.App
func Before(ctx *cli.Context) error {
	lv := log15.LvlInfo
	if ctx.Bool("debug") {
		lv = log15.LvlDebug
	}
	log15.Root().SetHandler(log15.LvlFilterHandler(lv, ext.FatalHandler(log15.StreamHandler(os.Stderr, helper.LogfmtFormat()))))
	return nil
}
Beispiel #24
0
func cmdWrapper(c *cli.Context) error {
	if len(c.Args()) < 1 {
		Logger.Fatalf("Missing <target> argument. See usage with 'assh wrapper %s -h'.", c.Command.Name)
	}

	// prepare variables
	target := c.Args()[0]
	command := c.Args()[1:]
	options := []string{}
	for _, flag := range config.SSHBoolFlags {
		if c.Bool(flag) {
			options = append(options, fmt.Sprintf("-%s", flag))
		}
	}
	for _, flag := range config.SSHStringFlags {
		if val := c.String(flag); val != "" {
			options = append(options, fmt.Sprintf("-%s", flag))
			options = append(options, val)
		}
	}
	args := []string{c.Command.Name}
	args = append(args, options...)
	args = append(args, target)
	args = append(args, command...)
	bin, err := exec.LookPath(c.Command.Name)
	if err != nil {
		Logger.Fatalf("Cannot find %q in $PATH", c.Command.Name)
	}

	Logger.Debugf("Wrapper called with bin=%v target=%v command=%v options=%v, args=%v", bin, target, command, options, args)

	// check if config is up-to-date
	conf, err := config.Open(c.GlobalString("config"))
	if err != nil {
		Logger.Fatalf("Cannot open configuration file: %v", err)
	}

	if err = conf.LoadKnownHosts(); err != nil {
		Logger.Debugf("Failed to load assh known_hosts: %v", err)
	}

	// check if .ssh/config is outdated
	isOutdated, err := conf.IsConfigOutdated(target)
	if err != nil {
		Logger.Error(err)
	}
	if isOutdated {
		Logger.Debugf("The configuration file is outdated, rebuilding it before calling %s", c.Command.Name)
		if err = conf.SaveSSHConfig(); err != nil {
			Logger.Error(err)
		}
	}

	// Execute Binary
	syscall.Exec(bin, args, os.Environ())

	return nil
}
Beispiel #25
0
func download(c *cli.Context) error {
	// Input validation
	collectionURI := c.String(CollectionKey)
	if collectionURI == "" {
		log.Fatalln("[STEPMAN] - No step collection specified")
	}
	route, found := stepman.ReadRoute(collectionURI)
	if !found {
		log.Fatal("No route found for lib: " + collectionURI)
	}

	id := c.String(IDKey)
	if id == "" {
		log.Fatal("[STEPMAN] - Missing step id")
	}

	collection, err := stepman.ReadStepSpec(collectionURI)
	if err != nil {
		log.Fatal("[STEPMAN] - Failed to read step spec:", err)
	}

	version := c.String(VersionKey)
	if version == "" {
		log.Debug("[STEPMAN] - Missing step version -- Use latest version")

		latest, err := collection.GetLatestStepVersion(id)
		if err != nil {
			log.Fatal("[STEPMAN] - Failed to get step latest version: ", err)
		}
		log.Debug("[STEPMAN] - Latest version of step: ", latest)
		version = latest
	}

	update := c.Bool(UpdateKey)

	// Check step exist in collection
	step, found := collection.GetStep(id, version)
	if !found {
		if update {
			log.Infof("[STEPMAN] - Collection doesn't contain step (id:%s) (version:%s) -- Updating collection", id, version)
			if err := stepman.ReGenerateStepSpec(route); err != nil {
				log.Fatalf("[STEPMAN] - Failed to update collection:%s error:%v", collectionURI, err)
			}

			if _, found := collection.GetStep(id, version); !found {
				log.Fatalf("[STEPMAN] - Even the updated collection doesn't contain step (id:%s) (version:%s)", id, version)
			}
		} else {
			log.Fatalf("[STEPMAN] - Collection doesn't contain step (id:%s) (version:%s)", id, version)
		}
	}

	if err := stepman.DownloadStep(collectionURI, collection, id, version, step.Source.Commit); err != nil {
		log.Fatal("[STEPMAN] - Failed to download step")
	}

	return nil
}
Beispiel #26
0
//
// putFiles uploads a selection of files into the bucket
//
func putFiles(o *formatter, cx *cli.Context, cmd *cliCommand) error {
	bucket := cx.String("bucket")
	kms := cx.String("kms")
	flatten := cx.Bool("flatten")
	path := cx.String("path")

	if flatten && path != "" {
		return fmt.Errorf("invalid option, you cannot flatten *and* specify a path")
	}

	// step: ensure the bucket exists
	if found, err := cmd.hasBucket(bucket); err != nil {
		return err
	} else if !found {
		return fmt.Errorf("the bucket: %s does not exist", bucket)
	}

	// check: we need any least one argument
	if len(cx.Args()) <= 0 {
		return fmt.Errorf("you have not specified any files to upload")
	}

	// step: iterate the paths and upload the files
	for _, p := range getPaths(cx) {
		// step: get a list of files under this path
		files, err := expandFiles(p)
		if err != nil {
			return fmt.Errorf("failed to process path: %s, error: %s", p, err)
		}
		// step: iterate the files in the path
		for _, filename := range files {
			// step: construct the key for this file
			keyName := filename
			if flatten {
				keyName = filepath.Base(keyName)
			}
			if path != "" {
				keyName = fmt.Sprintf("%s/%s", strings.TrimRight(path, "/"), filepath.Base(keyName))
			}

			// step: upload the file to the bucket
			if err := cmd.putFile(bucket, keyName, filename, kms); err != nil {
				return fmt.Errorf("failed to put the file: %s, error: %s", filename, err)
			}

			// step: add the log
			o.fields(map[string]interface{}{
				"action": "put",
				"path":   filename,
				"bucket": bucket,
				"key":    keyName,
			}).log("successfully pushed the file: %s to s3://%s/%s\n", filename, bucket, keyName)
		}
	}

	return nil
}
Beispiel #27
0
// ProjectPs lists the containers.
func ProjectPs(p project.APIProject, c *cli.Context) error {
	qFlag := c.Bool("q")
	allInfo, err := p.Ps(context.Background(), qFlag, c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	os.Stdout.WriteString(allInfo.String(!qFlag))
	return nil
}
func version(c *cli.Context) {
	fmt.Println(c.App.Version)

	if c.Bool(FullFlagKey) {
		fmt.Println()
		fmt.Println("go: " + runtime.Version())
		fmt.Println("arch: " + runtime.GOARCH)
		fmt.Println("os: " + runtime.GOOS)
	}
}
Beispiel #29
0
// ProjectDelete deletes services.
func ProjectDelete(p project.APIProject, c *cli.Context) error {
	options := options.Delete{
		RemoveVolume: c.Bool("v"),
	}
	err := p.Delete(context.Background(), options, c.Args()...)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	return nil
}
Beispiel #30
0
// ProjectConfig validates and print the compose file.
func ProjectConfig(p project.APIProject, c *cli.Context) error {
	yaml, err := p.Config()
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}
	if !c.Bool("quiet") {
		fmt.Println(yaml)
	}
	return nil
}