From 2955306f8df6b6c8fb1f79c9ef42847df699a439 Mon Sep 17 00:00:00 2001 From: Don Date: Mon, 9 Sep 2019 18:04:09 -0700 Subject: [PATCH] Add Transport to urfave --- pkg/urfave/types.go | 39 +++++++++++++++++++++++++++++++++++++++ pkg/urfave/urfave.go | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 pkg/urfave/types.go diff --git a/pkg/urfave/types.go b/pkg/urfave/types.go new file mode 100644 index 0000000..bf964c9 --- /dev/null +++ b/pkg/urfave/types.go @@ -0,0 +1,39 @@ +// Copyright (c) 2019, the Drone Plugins project authors. +// Please see the AUTHORS file for details. All rights reserved. +// Use of this source code is governed by an Apache 2.0 license that can be +// found in the LICENSE file. + +package urfave + +import "github.com/urfave/cli" + +//--------------------------------------------------------------------- +// Transport Flags +//--------------------------------------------------------------------- + +// Transport contains options for the underlying http client. +type Transport struct { + // SSLVerify certificate information. + SSLVerify bool +} + +const transportSSLVerifyFlag = "transport.ssl-verify" + +// TransportFlags has the cli.Flags for the Transport. +func TransportFlags() []cli.Flag { + return []cli.Flag{ + cli.BoolFlag{ + Name: transportSSLVerifyFlag, + Usage: "transport ssl verify", + EnvVar: "PLUGIN_SSL_VERIFY", + Hidden: true, + }, + } +} + +// TransportFromContext creates a Transport from the cli.Context. +func TransportFromContext(ctx cli.Context) Transport { + return Transport{ + SSLVerify: ctx.Bool(transportSSLVerifyFlag), + } +} diff --git a/pkg/urfave/urfave.go b/pkg/urfave/urfave.go index b6b0a86..bea96e8 100644 --- a/pkg/urfave/urfave.go +++ b/pkg/urfave/urfave.go @@ -648,7 +648,7 @@ func SemVerFlags() []cli.Flag { } } -// SemVerFromContext creates a plugin.Step from the cli.SemVer. +// SemVerFromContext creates a plugin.Step from the cli.Context. func SemVerFromContext(ctx *cli.Context) plugin.SemVer { return plugin.SemVer{ Build: ctx.String(SemVerBuildFlag),