mirror of https://github.com/knative/func.git
src: promote verbosity to constructor arg (#869)
* update root and version structure and help text * fix: limit openshift int test with tag * src: verbosity to constructor param * fix misspelling * fix merge error
This commit is contained in:
parent
1e4d52be33
commit
5a122c31e6
|
|
@ -24,12 +24,12 @@ import (
|
||||||
//Builder holds the configuration that will be passed to
|
//Builder holds the configuration that will be passed to
|
||||||
//Buildpack builder
|
//Buildpack builder
|
||||||
type Builder struct {
|
type Builder struct {
|
||||||
Verbose bool
|
verbose bool
|
||||||
}
|
}
|
||||||
|
|
||||||
//NewBuilder builds the new Builder configuration
|
//NewBuilder builds the new Builder configuration
|
||||||
func NewBuilder() *Builder {
|
func NewBuilder(verbose bool) *Builder {
|
||||||
return &Builder{}
|
return &Builder{verbose: verbose}
|
||||||
}
|
}
|
||||||
|
|
||||||
var v330 = semver.MustParse("v3.3.0")
|
var v330 = semver.MustParse("v3.3.0")
|
||||||
|
|
@ -57,7 +57,7 @@ func (builder *Builder) Build(ctx context.Context, f fn.Function) (err error) {
|
||||||
|
|
||||||
// log output is either STDOUt or kept in a buffer to be printed on error.
|
// log output is either STDOUt or kept in a buffer to be printed on error.
|
||||||
var logWriter io.Writer
|
var logWriter io.Writer
|
||||||
if builder.Verbose {
|
if builder.verbose {
|
||||||
// pass stdout as non-closeable writer
|
// pass stdout as non-closeable writer
|
||||||
// otherwise pack client would close it which is bad
|
// otherwise pack client would close it which is bad
|
||||||
logWriter = stdoutWrapper{os.Stdout}
|
logWriter = stdoutWrapper{os.Stdout}
|
||||||
|
|
@ -130,7 +130,7 @@ func (builder *Builder) Build(ctx context.Context, f fn.Function) (err error) {
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
// received SIGINT
|
// received SIGINT
|
||||||
return
|
return
|
||||||
} else if !builder.Verbose {
|
} else if !builder.verbose {
|
||||||
// If the builder was not showing logs, embed the full logs in the error.
|
// If the builder was not showing logs, embed the full logs in the error.
|
||||||
err = fmt.Errorf("%v\noutput: %s\n", err, logWriter.(*bytes.Buffer).String())
|
err = fmt.Errorf("%v\noutput: %s\n", err, logWriter.(*bytes.Buffer).String())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ func TestList(t *testing.T) {
|
||||||
verbose := true
|
verbose := true
|
||||||
|
|
||||||
// Assemble
|
// Assemble
|
||||||
lister := knative.NewLister(DefaultNamespace)
|
lister := knative.NewLister(DefaultNamespace, verbose)
|
||||||
|
|
||||||
client := fn.New(
|
client := fn.New(
|
||||||
fn.WithLister(lister),
|
fn.WithLister(lister),
|
||||||
|
|
@ -203,20 +203,11 @@ func TestRemoteRepositories(t *testing.T) {
|
||||||
// newClient creates an instance of the func client whose concrete impls
|
// newClient creates an instance of the func client whose concrete impls
|
||||||
// match those created by the kn func plugin CLI.
|
// match those created by the kn func plugin CLI.
|
||||||
func newClient(verbose bool) *fn.Client {
|
func newClient(verbose bool) *fn.Client {
|
||||||
builder := buildpacks.NewBuilder()
|
builder := buildpacks.NewBuilder(verbose)
|
||||||
builder.Verbose = verbose
|
pusher := docker.NewPusher(verbose)
|
||||||
|
deployer := knative.NewDeployer(DefaultNamespace, verbose)
|
||||||
pusher := docker.NewPusher()
|
remover := knative.NewRemover(DefaultNamespace, verbose)
|
||||||
pusher.Verbose = verbose
|
lister := knative.NewLister(DefaultNamespace, verbose)
|
||||||
|
|
||||||
deployer := knative.NewDeployer(DefaultNamespace)
|
|
||||||
deployer.Verbose = verbose
|
|
||||||
|
|
||||||
remover := knative.NewRemover(DefaultNamespace)
|
|
||||||
remover.Verbose = verbose
|
|
||||||
|
|
||||||
lister := knative.NewLister(DefaultNamespace)
|
|
||||||
lister.Verbose = verbose
|
|
||||||
|
|
||||||
return fn.New(
|
return fn.New(
|
||||||
fn.WithRegistry(DefaultRegistry),
|
fn.WithRegistry(DefaultRegistry),
|
||||||
|
|
|
||||||
|
|
@ -52,11 +52,10 @@ func NewDefaultClientFactory() (newClient ClientFactory, cleanUp func() error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
newClient = func(clientOptions ClientOptions) *fn.Client {
|
newClient = func(clientOptions ClientOptions) *fn.Client {
|
||||||
builder := buildpacks.NewBuilder()
|
verbose := clientOptions.Verbose
|
||||||
builder.Verbose = clientOptions.Verbose
|
builder := buildpacks.NewBuilder(verbose)
|
||||||
|
|
||||||
progressListener := progress.New()
|
progressListener := progress.New(verbose)
|
||||||
progressListener.Verbose = clientOptions.Verbose
|
|
||||||
|
|
||||||
credentialsProvider := creds.NewCredentialsProvider(
|
credentialsProvider := creds.NewCredentialsProvider(
|
||||||
creds.WithPromptForCredentials(newPromptForCredentials()),
|
creds.WithPromptForCredentials(newPromptForCredentials()),
|
||||||
|
|
@ -64,37 +63,30 @@ func NewDefaultClientFactory() (newClient ClientFactory, cleanUp func() error) {
|
||||||
creds.WithTransport(transport),
|
creds.WithTransport(transport),
|
||||||
creds.WithAdditionalCredentialLoaders(additionalCredLoaders...))
|
creds.WithAdditionalCredentialLoaders(additionalCredLoaders...))
|
||||||
|
|
||||||
pusher := docker.NewPusher(
|
pusher := docker.NewPusher(verbose,
|
||||||
docker.WithCredentialsProvider(credentialsProvider),
|
docker.WithCredentialsProvider(credentialsProvider),
|
||||||
docker.WithProgressListener(progressListener),
|
docker.WithProgressListener(progressListener),
|
||||||
docker.WithTransport(transport))
|
docker.WithTransport(transport))
|
||||||
pusher.Verbose = clientOptions.Verbose
|
|
||||||
|
|
||||||
deployer := knative.NewDeployer(clientOptions.Namespace)
|
deployer := knative.NewDeployer(clientOptions.Namespace, verbose)
|
||||||
deployer.Verbose = clientOptions.Verbose
|
|
||||||
|
|
||||||
pipelinesProvider := tekton.NewPipelinesProvider(
|
pipelinesProvider := tekton.NewPipelinesProvider(verbose,
|
||||||
tekton.WithNamespace(clientOptions.Namespace),
|
tekton.WithNamespace(clientOptions.Namespace),
|
||||||
tekton.WithProgressListener(progressListener),
|
tekton.WithProgressListener(progressListener),
|
||||||
tekton.WithCredentialsProvider(credentialsProvider))
|
tekton.WithCredentialsProvider(credentialsProvider))
|
||||||
pipelinesProvider.Verbose = clientOptions.Verbose
|
|
||||||
|
|
||||||
remover := knative.NewRemover(clientOptions.Namespace)
|
remover := knative.NewRemover(clientOptions.Namespace, verbose)
|
||||||
remover.Verbose = clientOptions.Verbose
|
|
||||||
|
|
||||||
describer := knative.NewDescriber(clientOptions.Namespace)
|
describer := knative.NewDescriber(clientOptions.Namespace, verbose)
|
||||||
describer.Verbose = clientOptions.Verbose
|
|
||||||
|
|
||||||
lister := knative.NewLister(clientOptions.Namespace)
|
lister := knative.NewLister(clientOptions.Namespace, verbose)
|
||||||
lister.Verbose = clientOptions.Verbose
|
|
||||||
|
|
||||||
runner := docker.NewRunner()
|
runner := docker.NewRunner(verbose)
|
||||||
runner.Verbose = clientOptions.Verbose
|
|
||||||
|
|
||||||
opts := []fn.Option{
|
opts := []fn.Option{
|
||||||
fn.WithRepository(clientOptions.Repository), // URI of repository override
|
fn.WithRepository(clientOptions.Repository), // URI of repository override
|
||||||
fn.WithRegistry(clientOptions.Registry),
|
fn.WithRegistry(clientOptions.Registry),
|
||||||
fn.WithVerbose(clientOptions.Verbose),
|
fn.WithVerbose(verbose),
|
||||||
fn.WithTransport(transport),
|
fn.WithTransport(transport),
|
||||||
fn.WithProgressListener(progressListener),
|
fn.WithProgressListener(progressListener),
|
||||||
fn.WithBuilder(builder),
|
fn.WithBuilder(builder),
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func CompleteFunctionList(cmd *cobra.Command, args []string, toComplete string) (strings []string, directive cobra.ShellCompDirective) {
|
func CompleteFunctionList(cmd *cobra.Command, args []string, toComplete string) (strings []string, directive cobra.ShellCompDirective) {
|
||||||
lister := knative.NewLister("")
|
lister := knative.NewLister("", false)
|
||||||
|
|
||||||
list, err := lister.List(cmd.Context())
|
list, err := lister.List(cmd.Context())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ EXAMPLES
|
||||||
// Environment Variables
|
// Environment Variables
|
||||||
// Evaluated first after static defaults, set all flags to be associated with
|
// Evaluated first after static defaults, set all flags to be associated with
|
||||||
// a version prefixed by "FUNC_"
|
// a version prefixed by "FUNC_"
|
||||||
viper.AutomaticEnv() // read in environment variables that match
|
viper.AutomaticEnv() // read in environment variables for FUNC_<flag>
|
||||||
viper.SetEnvPrefix("func") // ensure thay all have the prefix
|
viper.SetEnvPrefix("func") // ensure thay all have the prefix
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
|
|
@ -366,7 +366,7 @@ func (v Version) String() string {
|
||||||
// value v0.0.0 as the default indicating there is no version information
|
// value v0.0.0 as the default indicating there is no version information
|
||||||
// available.
|
// available.
|
||||||
if strings.HasPrefix(v.Vers, "v") {
|
if strings.HasPrefix(v.Vers, "v") {
|
||||||
// TODO: this is the naieve approach, perhaps consider actually parse it
|
// TODO: this is the naive approach, perhaps consider actually parse it
|
||||||
// using the semver lib
|
// using the semver lib
|
||||||
return v.Vers
|
return v.Vers
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,11 @@ import (
|
||||||
|
|
||||||
func newRunClient(cfg runConfig) *fn.Client {
|
func newRunClient(cfg runConfig) *fn.Client {
|
||||||
bc := newBuildConfig()
|
bc := newBuildConfig()
|
||||||
runner := docker.NewRunner()
|
runner := docker.NewRunner(cfg.Verbose)
|
||||||
runner.Verbose = cfg.Verbose
|
|
||||||
|
|
||||||
// builder fields
|
// builder fields
|
||||||
builder := buildpacks.NewBuilder()
|
builder := buildpacks.NewBuilder(cfg.Verbose)
|
||||||
listener := progress.New()
|
listener := progress.New(cfg.Verbose)
|
||||||
builder.Verbose = cfg.Verbose
|
|
||||||
listener.Verbose = cfg.Verbose
|
|
||||||
return fn.New(
|
return fn.New(
|
||||||
fn.WithBuilder(builder),
|
fn.WithBuilder(builder),
|
||||||
fn.WithProgressListener(listener),
|
fn.WithProgressListener(listener),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"text/template"
|
|
||||||
|
|
||||||
"github.com/ory/viper"
|
"github.com/ory/viper"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
@ -35,13 +34,12 @@ DESCRIPTION
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help Action
|
// Help Action
|
||||||
cmd.SetHelpFunc(runVersionHelp)
|
cmd.SetHelpFunc(defaultTemplatedHelp)
|
||||||
|
|
||||||
// Run Action
|
// Run Action
|
||||||
cmd.Run = func(cmd *cobra.Command, args []string) {
|
cmd.Run = func(cmd *cobra.Command, args []string) {
|
||||||
runVersion(cmd, args, version)
|
runVersion(cmd, args, version)
|
||||||
}
|
}
|
||||||
cmd.SetHelpFunc(defaultTemplatedHelp)
|
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
@ -51,22 +49,3 @@ func runVersion(cmd *cobra.Command, args []string, version Version) {
|
||||||
version.Verbose = viper.GetBool("verbose")
|
version.Verbose = viper.GetBool("verbose")
|
||||||
fmt.Fprintf(cmd.OutOrStdout(), "%v\n", version)
|
fmt.Fprintf(cmd.OutOrStdout(), "%v\n", version)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help
|
|
||||||
func runVersionHelp(cmd *cobra.Command, args []string) {
|
|
||||||
var (
|
|
||||||
body = cmd.Long + "\n\n" + cmd.UsageString()
|
|
||||||
t = template.New("version")
|
|
||||||
tpl = template.Must(t.Parse(body))
|
|
||||||
)
|
|
||||||
|
|
||||||
var data = struct {
|
|
||||||
Name string
|
|
||||||
}{
|
|
||||||
Name: cmd.Root().Name(),
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := tpl.Execute(cmd.OutOrStdout(), data); err != nil {
|
|
||||||
fmt.Fprintf(cmd.ErrOrStderr(), "unable to display help text: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,7 @@ type PusherDockerClientFactory func() (PusherDockerClient, error)
|
||||||
|
|
||||||
// Pusher of images from local to remote registry.
|
// Pusher of images from local to remote registry.
|
||||||
type Pusher struct {
|
type Pusher struct {
|
||||||
// Verbose logging.
|
verbose bool // verbose logging.
|
||||||
Verbose bool
|
|
||||||
credentialsProvider CredentialsProvider
|
credentialsProvider CredentialsProvider
|
||||||
progressListener fn.ProgressListener
|
progressListener fn.ProgressListener
|
||||||
transport http.RoundTripper
|
transport http.RoundTripper
|
||||||
|
|
@ -84,9 +83,8 @@ func EmptyCredentialsProvider(ctx context.Context, registry string) (Credentials
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPusher creates an instance of a docker-based image pusher.
|
// NewPusher creates an instance of a docker-based image pusher.
|
||||||
func NewPusher(opts ...Opt) *Pusher {
|
func NewPusher(verbose bool, opts ...Opt) *Pusher {
|
||||||
result := &Pusher{
|
result := &Pusher{
|
||||||
Verbose: false,
|
|
||||||
credentialsProvider: EmptyCredentialsProvider,
|
credentialsProvider: EmptyCredentialsProvider,
|
||||||
progressListener: &fn.NoopProgressListener{},
|
progressListener: &fn.NoopProgressListener{},
|
||||||
transport: http.DefaultTransport,
|
transport: http.DefaultTransport,
|
||||||
|
|
@ -94,6 +92,7 @@ func NewPusher(opts ...Opt) *Pusher {
|
||||||
c, _, err := NewClient(client.DefaultDockerHost)
|
c, _, err := NewClient(client.DefaultDockerHost)
|
||||||
return c, err
|
return c, err
|
||||||
},
|
},
|
||||||
|
verbose: verbose,
|
||||||
}
|
}
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(result)
|
opt(result)
|
||||||
|
|
@ -116,7 +115,7 @@ func (n *Pusher) Push(ctx context.Context, f fn.Function) (digest string, err er
|
||||||
|
|
||||||
var output io.Writer
|
var output io.Writer
|
||||||
|
|
||||||
if n.Verbose {
|
if n.verbose {
|
||||||
output = os.Stderr
|
output = os.Stderr
|
||||||
} else {
|
} else {
|
||||||
output = io.Discard
|
output = io.Discard
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ func TestDaemonPush(t *testing.T) {
|
||||||
dockerClientFactory := func() (docker.PusherDockerClient, error) {
|
dockerClientFactory := func() (docker.PusherDockerClient, error) {
|
||||||
return dockerClient, nil
|
return dockerClient, nil
|
||||||
}
|
}
|
||||||
pusher := docker.NewPusher(
|
pusher := docker.NewPusher(false,
|
||||||
docker.WithCredentialsProvider(testCredProvider),
|
docker.WithCredentialsProvider(testCredProvider),
|
||||||
docker.WithPusherDockerClientFactory(dockerClientFactory))
|
docker.WithPusherDockerClientFactory(dockerClientFactory))
|
||||||
|
|
||||||
|
|
@ -182,7 +182,7 @@ func TestNonDaemonPush(t *testing.T) {
|
||||||
return dockerClient, nil
|
return dockerClient, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
pusher := docker.NewPusher(
|
pusher := docker.NewPusher(false,
|
||||||
docker.WithTransport(transport),
|
docker.WithTransport(transport),
|
||||||
docker.WithCredentialsProvider(testCredProvider),
|
docker.WithCredentialsProvider(testCredProvider),
|
||||||
docker.WithPusherDockerClientFactory(dockerClientFactory))
|
docker.WithPusherDockerClientFactory(dockerClientFactory))
|
||||||
|
|
|
||||||
|
|
@ -36,13 +36,12 @@ const (
|
||||||
|
|
||||||
// Runner starts and stops Functions as local contaieners.
|
// Runner starts and stops Functions as local contaieners.
|
||||||
type Runner struct {
|
type Runner struct {
|
||||||
// Verbose logging
|
verbose bool // Verbose logging
|
||||||
Verbose bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRunner creates an instance of a docker-backed runner.
|
// NewRunner creates an instance of a docker-backed runner.
|
||||||
func NewRunner() *Runner {
|
func NewRunner(verbose bool) *Runner {
|
||||||
return &Runner{}
|
return &Runner{verbose: verbose}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the Function.
|
// Run the Function.
|
||||||
|
|
@ -69,7 +68,7 @@ func (n *Runner) Run(ctx context.Context, f fn.Function) (job *fn.Job, err error
|
||||||
if c, _, err = NewClient(client.DefaultDockerHost); err != nil {
|
if c, _, err = NewClient(client.DefaultDockerHost); err != nil {
|
||||||
return job, errors.Wrap(err, "failed to create Docker API client")
|
return job, errors.Wrap(err, "failed to create Docker API client")
|
||||||
}
|
}
|
||||||
if id, err = newContainer(ctx, c, f, port, n.Verbose); err != nil {
|
if id, err = newContainer(ctx, c, f, port, n.verbose); err != nil {
|
||||||
return job, errors.Wrap(err, "runner unable to create container")
|
return job, errors.Wrap(err, "runner unable to create container")
|
||||||
}
|
}
|
||||||
if conn, err = copyStdio(ctx, c, id, copyErrCh); err != nil {
|
if conn, err = copyStdio(ctx, c, id, copyErrCh); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,7 @@ func TestDockerRun(t *testing.T) {
|
||||||
|
|
||||||
// NOTE: test requires that the image be built already.
|
// NOTE: test requires that the image be built already.
|
||||||
|
|
||||||
runner := docker.NewRunner()
|
runner := docker.NewRunner(true)
|
||||||
runner.Verbose = true
|
|
||||||
if _, err = runner.Run(context.Background(), f); err != nil {
|
if _, err = runner.Run(context.Background(), f); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +47,7 @@ func TestDockerRun(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDockerRunImagelessError(t *testing.T) {
|
func TestDockerRunImagelessError(t *testing.T) {
|
||||||
runner := docker.NewRunner()
|
runner := docker.NewRunner(true)
|
||||||
f := fn.NewFunctionWith(fn.Function{})
|
f := fn.NewFunctionWith(fn.Function{})
|
||||||
|
|
||||||
_, err := runner.Run(context.Background(), f)
|
_, err := runner.Run(context.Background(), f)
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,14 @@ type Deployer struct {
|
||||||
// Namespace with which to override that set on the default configuration (such as the ~/.kube/config).
|
// Namespace with which to override that set on the default configuration (such as the ~/.kube/config).
|
||||||
// If left blank, deployment will commence to the configured namespace.
|
// If left blank, deployment will commence to the configured namespace.
|
||||||
Namespace string
|
Namespace string
|
||||||
// Verbose logging enablement flag.
|
// verbose logging enablement flag.
|
||||||
Verbose bool
|
verbose bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDeployer(namespaceOverride string) *Deployer {
|
func NewDeployer(namespaceOverride string, verbose bool) *Deployer {
|
||||||
return &Deployer{
|
return &Deployer{
|
||||||
Namespace: namespaceOverride,
|
Namespace: namespaceOverride,
|
||||||
|
verbose: verbose,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,7 +111,7 @@ func (d *Deployer) Deploy(ctx context.Context, f fn.Function) (result fn.Deploym
|
||||||
return fn.DeploymentResult{}, err
|
return fn.DeploymentResult{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.Verbose {
|
if d.verbose {
|
||||||
fmt.Println("Waiting for Knative Service to become ready")
|
fmt.Println("Waiting for Knative Service to become ready")
|
||||||
}
|
}
|
||||||
chprivate := make(chan bool)
|
chprivate := make(chan bool)
|
||||||
|
|
@ -159,7 +160,7 @@ func (d *Deployer) Deploy(ctx context.Context, f fn.Function) (result fn.Deploym
|
||||||
return fn.DeploymentResult{}, err
|
return fn.DeploymentResult{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if d.Verbose {
|
if d.verbose {
|
||||||
fmt.Println("Function deployed at URL: " + route.Status.URL.String())
|
fmt.Println("Function deployed at URL: " + route.Status.URL.String())
|
||||||
}
|
}
|
||||||
return fn.DeploymentResult{
|
return fn.DeploymentResult{
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Describer struct {
|
type Describer struct {
|
||||||
Verbose bool
|
|
||||||
namespace string
|
namespace string
|
||||||
|
verbose bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDescriber(namespaceOverride string) *Describer {
|
func NewDescriber(namespaceOverride string, verbose bool) *Describer {
|
||||||
return &Describer{
|
return &Describer{
|
||||||
namespace: namespaceOverride,
|
namespace: namespaceOverride,
|
||||||
|
verbose: verbose,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Lister struct {
|
type Lister struct {
|
||||||
Verbose bool
|
|
||||||
Namespace string
|
Namespace string
|
||||||
|
verbose bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLister(namespaceOverride string) *Lister {
|
func NewLister(namespaceOverride string, verbose bool) *Lister {
|
||||||
return &Lister{
|
return &Lister{
|
||||||
Namespace: namespaceOverride,
|
Namespace: namespaceOverride,
|
||||||
|
verbose: verbose,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,15 +10,16 @@ import (
|
||||||
|
|
||||||
const RemoveTimeout = 120 * time.Second
|
const RemoveTimeout = 120 * time.Second
|
||||||
|
|
||||||
func NewRemover(namespaceOverride string) *Remover {
|
func NewRemover(namespaceOverride string, verbose bool) *Remover {
|
||||||
return &Remover{
|
return &Remover{
|
||||||
Namespace: namespaceOverride,
|
Namespace: namespaceOverride,
|
||||||
|
verbose: verbose,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Remover struct {
|
type Remover struct {
|
||||||
Namespace string
|
Namespace string
|
||||||
Verbose bool
|
verbose bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (remover *Remover) Remove(ctx context.Context, name string) (err error) {
|
func (remover *Remover) Remove(ctx context.Context, name string) (err error) {
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ type PipelinesProvider struct {
|
||||||
// namespace with which to override that set on the default configuration (such as the ~/.kube/config).
|
// namespace with which to override that set on the default configuration (such as the ~/.kube/config).
|
||||||
// If left blank, pipeline creation/run will commence to the configured namespace.
|
// If left blank, pipeline creation/run will commence to the configured namespace.
|
||||||
namespace string
|
namespace string
|
||||||
Verbose bool
|
verbose bool
|
||||||
progressListener fn.ProgressListener
|
progressListener fn.ProgressListener
|
||||||
credentialsProvider docker.CredentialsProvider
|
credentialsProvider docker.CredentialsProvider
|
||||||
}
|
}
|
||||||
|
|
@ -53,8 +53,8 @@ func WithCredentialsProvider(credentialsProvider docker.CredentialsProvider) Opt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPipelinesProvider(opts ...Opt) *PipelinesProvider {
|
func NewPipelinesProvider(verbose bool, opts ...Opt) *PipelinesProvider {
|
||||||
pp := &PipelinesProvider{}
|
pp := &PipelinesProvider{verbose: verbose}
|
||||||
|
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(pp)
|
opt(pp)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ type Bar struct {
|
||||||
|
|
||||||
// verbose mode disables progress spinner and line overwrites, instead
|
// verbose mode disables progress spinner and line overwrites, instead
|
||||||
// printing single, full line updates.
|
// printing single, full line updates.
|
||||||
Verbose bool
|
verbose bool
|
||||||
|
|
||||||
// print verbose-style updates even when not attached to an interactive terminal.
|
// print verbose-style updates even when not attached to an interactive terminal.
|
||||||
printWhileHeadless bool
|
printWhileHeadless bool
|
||||||
|
|
@ -78,9 +78,10 @@ func WithPrintStepCounter(s bool) Option {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(options ...Option) *Bar {
|
func New(verbose bool, options ...Option) *Bar {
|
||||||
b := &Bar{
|
b := &Bar{
|
||||||
out: os.Stdout,
|
out: os.Stdout,
|
||||||
|
verbose: verbose,
|
||||||
}
|
}
|
||||||
for _, o := range options {
|
for _, o := range options {
|
||||||
o(b)
|
o(b)
|
||||||
|
|
@ -110,7 +111,7 @@ func (b *Bar) Increment(text string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're in verbose mode, do a simple write
|
// If we're in verbose mode, do a simple write
|
||||||
if b.Verbose {
|
if b.verbose {
|
||||||
b.write()
|
b.write()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -144,7 +145,7 @@ func (b *Bar) Complete(text string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're interactive, but in verbose mode do a simple write
|
// If we're interactive, but in verbose mode do a simple write
|
||||||
if b.Verbose {
|
if b.verbose {
|
||||||
b.write()
|
b.write()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -213,7 +214,7 @@ func (b *Bar) String() string {
|
||||||
|
|
||||||
// Write a spinner at the beginning of the previous line.
|
// Write a spinner at the beginning of the previous line.
|
||||||
func (b *Bar) spin(ch <-chan time.Time) {
|
func (b *Bar) spin(ch <-chan time.Time) {
|
||||||
if b.Verbose {
|
if b.verbose {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Various options for spinners.
|
// Various options for spinners.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue