mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
* Initial implementation for service create interactive mode. * Remove unneeded (and troublesome) raw extension unmarshalling. * Update vendor. * Isolate interactive mode implementation from command code. * Unexport functions that don't need to be. * Rename SelectServiceNameInteractively to EnterServiceNameInteractively. Add documentation. * Remove dependency on occlient in ui package. * Format documentation according to conventions. * Make todo more specific. * If title doesn't exist use name instead. * Actually, always use name and show title as additional info. * Properly handle interrupts (ctrl-c). * Improve handling of properties: - Deal with optional properties - Check (and ignore) extra provided properties * Introduce Validator type. * Improve UI. * Add basic validation of input. * Use init function and validators map. * Initial implementation using survey instead of promptui. * Update vendor. * Address code style issues. * Update glide and vendor. * Fix improper pointer assignment. * Proof of concept of promptui-like detail panel. * Updated for new code organization. Needs lots of improvements. * Extract ServicePlans creation into NewServicePlans function. Simplify unmarshalling code. * Use ServicePlans instead of dealing with info extraction here and remove option to pass values to EnterServicePropertiesInteractively. * Rename catalogUI to simply ui. * Move ui package to where it's used and makes more sense. * Make service plan parameters sortable by name. * Make EnterServicePropertiesInteractively more easily testable. * Extract fake plan details creation functions so that they can be reused. * Add ui tests but it is currently failing… Update vendor dependencies. * Disable color output to simplify testing. * Duplicate survey test infrastructure and adapt ui_test accordingly. * Remove now unneeded stdio function. * Make providing value required. * Only attempt to unmarshal extension if it exists. * Fix crash if filtered entries resulted in empty pageEntries. * Restore original template once we're done with the selection. * Use a more explicit template function name and improve template changes. * Use defer to restore template and template functions once done. * Use survey.ComposeValidators and remove chainedValidator. * Skip the test until we can figure out what is wrong with it. * Fix improper imports. * Fix style errors. * Add documentation to exported functions. * Rename ServicePlans to ServicePlan (no reason for it to be plural). * Should error out if the service class is not found. * Fix link. * Add documentation. * Fix missing display and potential panic. * Service name was improperly validated. * Remove additional information display as it's causing display issues. * Update survey to latest version. * Re-add service class detail since it is now fixed and improve output. * Work around issue with repeated question when lines wrap in terminal. * Update to survey 1.8.0. * Use 1 error code. * Create a constant for the default number of columns before text wraps. * Add comments. * Add comment for golint to pick up. * Add comment. * Add documentation to ServiceCreateOptions struct. * Fix potentially invalid logic. * Fix improper output (expected vs actual were reversed). * Extract more common functions to services and add more tests. * Delete unused function. * Default to default column number if detected width is 0. Add tests. * Update vendor information. * Add more tests. * Add documentation.
92 lines
2.1 KiB
Go
Generated
92 lines
2.1 KiB
Go
Generated
// Copyright 2018 Netflix, Inc.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package expect
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// NewTestConsole returns a new Console that multiplexes the application's
|
|
// stdout to go's testing logger. Primarily so that outputs from parallel tests
|
|
// using t.Parallel() is not interleaved.
|
|
func NewTestConsole(t *testing.T, opts ...ConsoleOpt) (*Console, error) {
|
|
tf, err := NewTestWriter(t)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return NewConsole(append(opts, WithStdout(tf))...)
|
|
}
|
|
|
|
// NewTestWriter returns an io.Writer where bytes written to the file are
|
|
// logged by go's testing logger. Bytes are flushed to the logger on line end.
|
|
func NewTestWriter(t *testing.T) (io.Writer, error) {
|
|
r, w := io.Pipe()
|
|
tw := testWriter{t}
|
|
|
|
go func() {
|
|
defer r.Close()
|
|
|
|
br := bufio.NewReader(r)
|
|
|
|
for {
|
|
line, _, err := br.ReadLine()
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
_, err = tw.Write(line)
|
|
if err != nil {
|
|
return
|
|
}
|
|
}
|
|
}()
|
|
|
|
return w, nil
|
|
}
|
|
|
|
// testWriter provides a io.Writer interface to go's testing logger.
|
|
type testWriter struct {
|
|
t *testing.T
|
|
}
|
|
|
|
func (tw testWriter) Write(p []byte) (n int, err error) {
|
|
tw.t.Log(string(p))
|
|
return len(p), nil
|
|
}
|
|
|
|
// StripTrailingEmptyLines returns a copy of s stripped of trailing lines that
|
|
// consist of only space characters.
|
|
func StripTrailingEmptyLines(out string) string {
|
|
lines := strings.Split(out, "\n")
|
|
if len(lines) < 2 {
|
|
return out
|
|
}
|
|
|
|
for i := len(lines) - 1; i >= 0; i-- {
|
|
stripped := strings.Replace(lines[i], " ", "", -1)
|
|
if len(stripped) == 0 {
|
|
lines = lines[:len(lines)-1]
|
|
} else {
|
|
break
|
|
}
|
|
}
|
|
|
|
return strings.Join(lines, "\n")
|
|
}
|