mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
Move registry to preference (#5428)
<!-- Thank you for opening a PR! Here are some things you need to know before submitting: 1. Please read our developer guideline: https://github.com/redhat-developer/odo/wiki/Developer-Guidelines 2. Label this PR accordingly with the '/kind' line 3. Ensure you have written and ran the appropriate tests: https://github.com/redhat-developer/odo/wiki/Writing-and-running-tests 4. Read how we approve and LGTM each PR: https://github.com/redhat-developer/odo/wiki/PR-Review Documentation: If you are pushing a change to documentation, please read: https://github.com/redhat-developer/odo/wiki/Contributing-to-Docs --> **What type of PR is this:** <!-- Add one of the following kinds: /kind bug /kind cleanup /kind tests /kind documentation Feel free to use other [labels](https://github.com/redhat-developer/odo/labels) as needed. However one of the above labels must be present or the PR will not be reviewed. This instruction is for reviewers as well. --> /kind feature **What does this PR do / why we need it:** This PR does the following: - Moves "registry" to preference - Gets rid of unused preference configuration options - Reorders the parameters for preference for the usage in --help **Which issue(s) this PR fixes:** <!-- Specifying the issue will automatically close it when this PR is merged --> https://github.com/redhat-developer/odo/issues/5402 **PR acceptance criteria:** - [X] Unit test - [X] Integration test - [X] Documentation **How to test changes / Special notes to the reviewer:**
This commit is contained in:
@@ -32,6 +32,6 @@ The following table describes the additional information collected by odo comman
|
||||
| | **Cluster Type** | Openshift 4 / Kubernetes |
|
||||
|**Project Create**| Cluster Type |Openshift 4 / Kubernetes |
|
||||
|**Project Set**| Cluster Type |Openshift 4 / Kubernetes |
|
||||
|**Preference Change** | Preference Key| UpdateNotification/NamePrefix/Timeout/BuildTimeout/PushTimeout/Ephemeral/ConsentTelemetry |
|
||||
|**Preference Change** | Preference Key| UpdateNotification/Timeout/PushTimeout/RegistryCacheTime/Ephemeral/ConsentTelemetry |
|
||||
|
||||
|
||||
|
||||
@@ -59,10 +59,9 @@ Example:
|
||||
$ odo preference view
|
||||
PARAMETER CURRENT_VALUE
|
||||
UpdateNotification
|
||||
NamePrefix
|
||||
Timeout
|
||||
BuildTimeout
|
||||
PushTimeout
|
||||
RegistryCacheTime
|
||||
Ephemeral
|
||||
ConsentTelemetry
|
||||
```
|
||||
@@ -95,11 +94,11 @@ Unsetting a preference key sets it to an empty value in the preference file. odo
|
||||
### Preference Key Table
|
||||
|
||||
| Preference | Description | Default |
|
||||
| --------------------- | ------------------------------------------------------------------------- | ------------------------- |
|
||||
|--------------------|--------------------------------------------------------------------------------|------------------------|
|
||||
| UpdateNotification | Control whether a notification to update odo is shown | True |
|
||||
| NamePrefix | Set a default name prefix for an odo resource (component, storage, etc) | Current directory name |
|
||||
| Timeout | Timeout for OpenShift server connection check | 1 second |
|
||||
| BuildTimeout | Timeout for waiting for a build of the git component to complete | 300 seconds |
|
||||
| Timeout | Timeout for Kubernetes server connection check | 1 second |
|
||||
| PushTimeout | Timeout for waiting for a component to start | 240 seconds |
|
||||
| RegistryCacheTime | For how long (in minutes) odo will cache information from the Devfile registry | 4 Minutes |
|
||||
| Ephemeral | Control whether odo should create a emptyDir volume to store source code | True |
|
||||
| ConsentTelemetry | Control whether odo can collect telemetry for the user's odo usage | False |
|
||||
|
||||
@@ -91,29 +91,6 @@ In this example we will use odo to manage a sample [Java JPA MicroService applic
|
||||
```shell
|
||||
odo push --show-log
|
||||
```
|
||||
**Troubleshooting**:
|
||||
The Open Liberty image used by this application is relatively large(~850 MB), and depending on your internet connection, it might fail to download within the BuildTimeout set by odo; default timeout is 300 seconds.
|
||||
```shell
|
||||
$ odo push
|
||||
Validation
|
||||
✓ Validating the devfile [45508ns]
|
||||
|
||||
Updating services
|
||||
✓ Services and Links are in sync with the cluster, no changes are required
|
||||
|
||||
Creating Kubernetes resources for component mysboproj
|
||||
✗ Waiting for component to start [5m]
|
||||
✗ Failed to start component with name "mysboproj". Error: Failed to create the component: error while waiting for deployment rollout: timeout while waiting for mysboproj-app deployment roll out
|
||||
```
|
||||
|
||||
In case this step fails due to a timeout, consider increasing the Build Timeout:
|
||||
```shell
|
||||
odo preference set BuildTimeout 600
|
||||
```
|
||||
Deploy the application to the cluster again:
|
||||
```shell
|
||||
odo push --show-log -f
|
||||
```
|
||||
5. The application is now deployed to the cluster - you can view the status of the cluster, and the application test results by streaming the cluster logs of the component that we pushed to the cluster in the previous step.
|
||||
```shell
|
||||
odo log --follow
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"github.com/redhat-developer/odo/pkg/devfile"
|
||||
"github.com/redhat-developer/odo/pkg/kclient"
|
||||
"github.com/redhat-developer/odo/pkg/log"
|
||||
registryUtil "github.com/redhat-developer/odo/pkg/odo/cli/registry/util"
|
||||
registryUtil "github.com/redhat-developer/odo/pkg/odo/cli/preference/registry/util"
|
||||
"github.com/redhat-developer/odo/pkg/preference"
|
||||
"github.com/redhat-developer/odo/pkg/segment"
|
||||
"github.com/redhat-developer/odo/pkg/testingutil/filesystem"
|
||||
|
||||
@@ -70,17 +70,12 @@ func GetDefaultComponentName(cfg preference.Client, componentPath string, compon
|
||||
existingComponentNames = append(existingComponentNames, component.Name)
|
||||
}
|
||||
|
||||
// If there's no prefix in config file, or its value is empty string use safe default - the current directory along with component type
|
||||
if cfg.NamePrefix() == nil || *cfg.NamePrefix() == "" {
|
||||
// Create a random generated name for the component to use within Kubernetes
|
||||
prefix, err = GetComponentDir(componentPath)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "unable to generate random component name")
|
||||
}
|
||||
prefix = util.TruncateString(prefix, componentRandomNamePartsMaxLen)
|
||||
} else {
|
||||
// Set the required prefix into componentName
|
||||
prefix = *cfg.NamePrefix()
|
||||
}
|
||||
|
||||
// Generate unique name for the component using prefix and unique random suffix
|
||||
componentName, err := util.GetRandomName(
|
||||
|
||||
@@ -255,7 +255,6 @@ func TestGetDefaultComponentName(t *testing.T) {
|
||||
t.Run(tt.testName, func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
cfg := preference.NewMockClient(ctrl)
|
||||
cfg.EXPECT().NamePrefix().Return(nil)
|
||||
|
||||
name, err := GetDefaultComponentName(cfg, tt.componentPath, tt.componentType, tt.existingComponents)
|
||||
if (err != nil) != tt.wantErr {
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||
"github.com/redhat-developer/odo/pkg/devfile/location"
|
||||
"github.com/redhat-developer/odo/pkg/log"
|
||||
registryUtil "github.com/redhat-developer/odo/pkg/odo/cli/registry/util"
|
||||
registryUtil "github.com/redhat-developer/odo/pkg/odo/cli/preference/registry/util"
|
||||
"github.com/redhat-developer/odo/pkg/util"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
@@ -15,8 +15,8 @@ import (
|
||||
"github.com/redhat-developer/odo/pkg/odo/cli/logout"
|
||||
"github.com/redhat-developer/odo/pkg/odo/cli/plugins"
|
||||
"github.com/redhat-developer/odo/pkg/odo/cli/preference"
|
||||
"github.com/redhat-developer/odo/pkg/odo/cli/preference/registry"
|
||||
"github.com/redhat-developer/odo/pkg/odo/cli/project"
|
||||
"github.com/redhat-developer/odo/pkg/odo/cli/registry"
|
||||
"github.com/redhat-developer/odo/pkg/odo/cli/telemetry"
|
||||
"github.com/redhat-developer/odo/pkg/odo/cli/url"
|
||||
"github.com/redhat-developer/odo/pkg/odo/cli/utils"
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
registryUtil "github.com/redhat-developer/odo/pkg/odo/cli/registry/util"
|
||||
registryUtil "github.com/redhat-developer/odo/pkg/odo/cli/preference/registry/util"
|
||||
"github.com/redhat-developer/odo/pkg/odo/cmdline"
|
||||
"github.com/redhat-developer/odo/pkg/odo/genericclioptions/clientset"
|
||||
"github.com/zalando/go-keyring"
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"github.com/redhat-developer/odo/pkg/catalog"
|
||||
"github.com/redhat-developer/odo/pkg/component"
|
||||
"github.com/redhat-developer/odo/pkg/log"
|
||||
registryUtil "github.com/redhat-developer/odo/pkg/odo/cli/registry/util"
|
||||
registryUtil "github.com/redhat-developer/odo/pkg/odo/cli/preference/registry/util"
|
||||
"github.com/redhat-developer/odo/pkg/preference"
|
||||
"github.com/redhat-developer/odo/pkg/util"
|
||||
"github.com/zalando/go-keyring"
|
||||
|
||||
@@ -3,6 +3,7 @@ package preference
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/redhat-developer/odo/pkg/odo/cli/preference/registry"
|
||||
"github.com/redhat-developer/odo/pkg/odo/util"
|
||||
"github.com/redhat-developer/odo/pkg/preference"
|
||||
|
||||
@@ -19,9 +20,16 @@ var preferenceLongDesc = ktemplates.LongDesc(`Modifies odo specific configuratio
|
||||
|
||||
// NewCmdPreference implements the utils config odo command
|
||||
func NewCmdPreference(name, fullName string) *cobra.Command {
|
||||
|
||||
// Main Commands
|
||||
preferenceViewCmd := NewCmdView(viewCommandName, util.GetFullName(fullName, viewCommandName))
|
||||
preferenceSetCmd := NewCmdSet(setCommandName, util.GetFullName(fullName, setCommandName))
|
||||
preferenceUnsetCmd := NewCmdUnset(unsetCommandName, util.GetFullName(fullName, unsetCommandName))
|
||||
registryCmd := registry.NewCmdRegistry(registry.RecommendedCommandName, util.GetFullName(fullName, registry.RecommendedCommandName))
|
||||
|
||||
// Subcommands
|
||||
|
||||
// Set the examples
|
||||
preferenceCmd := &cobra.Command{
|
||||
Use: name,
|
||||
Short: "Modifies preference settings",
|
||||
@@ -33,8 +41,10 @@ func NewCmdPreference(name, fullName string) *cobra.Command {
|
||||
),
|
||||
}
|
||||
|
||||
// Add the commands, help, usage and annotations
|
||||
preferenceCmd.AddCommand(preferenceViewCmd, preferenceSetCmd)
|
||||
preferenceCmd.AddCommand(preferenceUnsetCmd)
|
||||
preferenceCmd.AddCommand(registryCmd)
|
||||
preferenceCmd.SetUsageTemplate(util.CmdUsageTemplate)
|
||||
preferenceCmd.Annotations = map[string]string{"command": "main"}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
// Built-in packages
|
||||
"fmt"
|
||||
|
||||
util2 "github.com/redhat-developer/odo/pkg/odo/cli/registry/util"
|
||||
util2 "github.com/redhat-developer/odo/pkg/odo/cli/preference/registry/util"
|
||||
"github.com/redhat-developer/odo/pkg/odo/cmdline"
|
||||
"github.com/redhat-developer/odo/pkg/odo/genericclioptions/clientset"
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
ktemplates "k8s.io/kubectl/pkg/util/templates"
|
||||
|
||||
// odo packages
|
||||
registryUtil "github.com/redhat-developer/odo/pkg/odo/cli/registry/util"
|
||||
registryUtil "github.com/redhat-developer/odo/pkg/odo/cli/preference/registry/util"
|
||||
"github.com/redhat-developer/odo/pkg/odo/cmdline"
|
||||
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
|
||||
"github.com/redhat-developer/odo/pkg/odo/genericclioptions/clientset"
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
ktemplates "k8s.io/kubectl/pkg/util/templates"
|
||||
|
||||
// odo packages
|
||||
util "github.com/redhat-developer/odo/pkg/odo/cli/registry/util"
|
||||
util "github.com/redhat-developer/odo/pkg/odo/cli/preference/registry/util"
|
||||
"github.com/redhat-developer/odo/pkg/odo/cmdline"
|
||||
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
|
||||
"github.com/redhat-developer/odo/pkg/odo/genericclioptions/clientset"
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
ktemplates "k8s.io/kubectl/pkg/util/templates"
|
||||
|
||||
// odo packages
|
||||
registryUtil "github.com/redhat-developer/odo/pkg/odo/cli/registry/util"
|
||||
registryUtil "github.com/redhat-developer/odo/pkg/odo/cli/preference/registry/util"
|
||||
"github.com/redhat-developer/odo/pkg/odo/cmdline"
|
||||
"github.com/redhat-developer/odo/pkg/odo/genericclioptions"
|
||||
"github.com/redhat-developer/odo/pkg/odo/genericclioptions/clientset"
|
||||
@@ -21,10 +21,9 @@ const setCommandName = "set"
|
||||
|
||||
var (
|
||||
setLongDesc = ktemplates.LongDesc(`Set an individual value in the odo preference file.
|
||||
|
||||
%[1]s`)
|
||||
setExample = ktemplates.Examples(`
|
||||
# Set a preference value in the global preference`)
|
||||
# All available preference values you can set`)
|
||||
)
|
||||
|
||||
// SetOptions encapsulates the options for the command
|
||||
@@ -88,7 +87,7 @@ func NewCmdSet(name, fullName string) *cobra.Command {
|
||||
o := NewSetOptions()
|
||||
preferenceSetCmd := &cobra.Command{
|
||||
Use: name,
|
||||
Short: "Set a value in odo config file",
|
||||
Short: "Set a value in the odo preference file",
|
||||
Long: fmt.Sprintf(setLongDesc, preference.FormatSupportedParameters()),
|
||||
Example: func(exampleString, fullName string) string {
|
||||
prefClient, err := preference.NewClient()
|
||||
|
||||
@@ -92,9 +92,8 @@ func NewCmdUnset(name, fullName string) *cobra.Command {
|
||||
Short: "Unset a value in odo preference file",
|
||||
Long: fmt.Sprintf(unsetLongDesc, preference.FormatSupportedParameters()),
|
||||
Example: func(exampleString, fullName string) string {
|
||||
for _, property := range preference.GetSupportedParameters() {
|
||||
exampleString += fmt.Sprintf("\n %s %s", fullName, property)
|
||||
}
|
||||
// Just show one example of how to unset a value.
|
||||
exampleString += fmt.Sprintf("\n %s %s", fullName, preference.GetSupportedParameters()[0])
|
||||
return "\n" + exampleString
|
||||
}(unsetExample, fullName),
|
||||
Args: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
const viewCommandName = "view"
|
||||
|
||||
var viewExample = ktemplates.Examples(`# For viewing the current preference value
|
||||
var viewExample = ktemplates.Examples(`# View all set preference values
|
||||
%[1]s
|
||||
`)
|
||||
|
||||
@@ -58,10 +58,9 @@ func (o *ViewOptions) Run() (err error) {
|
||||
w := tabwriter.NewWriter(os.Stdout, 5, 2, 2, ' ', tabwriter.TabIndent)
|
||||
fmt.Fprintln(w, "PARAMETER", "\t", "CURRENT_VALUE")
|
||||
fmt.Fprintln(w, "UpdateNotification", "\t", showBlankIfNil(o.clientset.PreferenceClient.UpdateNotification()))
|
||||
fmt.Fprintln(w, "NamePrefix", "\t", showBlankIfNil(o.clientset.PreferenceClient.NamePrefix()))
|
||||
fmt.Fprintln(w, "Timeout", "\t", showBlankIfNil(o.clientset.PreferenceClient.Timeout()))
|
||||
fmt.Fprintln(w, "BuildTimeout", "\t", showBlankIfNil(o.clientset.PreferenceClient.BuildTimeout()))
|
||||
fmt.Fprintln(w, "PushTimeout", "\t", showBlankIfNil(o.clientset.PreferenceClient.PushTimeout()))
|
||||
fmt.Fprintln(w, "RegistryCacheTime", "\t", showBlankIfNil(o.clientset.PreferenceClient.RegistryCacheTime()))
|
||||
fmt.Fprintln(w, "Ephemeral", "\t", showBlankIfNil(o.clientset.PreferenceClient.EphemeralSourceVolume()))
|
||||
fmt.Fprintln(w, "ConsentTelemetry", "\t", showBlankIfNil(o.clientset.PreferenceClient.ConsentTelemetry()))
|
||||
|
||||
|
||||
@@ -36,9 +36,8 @@ func TestView(t *testing.T) {
|
||||
}
|
||||
|
||||
prefClient.EXPECT().UpdateNotification().Return(pointer.Bool(false))
|
||||
prefClient.EXPECT().NamePrefix().Return(pointer.String("aprefix"))
|
||||
prefClient.EXPECT().Timeout().Return(pointer.Int(10))
|
||||
prefClient.EXPECT().BuildTimeout().Return(pointer.Int(10))
|
||||
prefClient.EXPECT().RegistryCacheTime().Return(pointer.Int(240))
|
||||
prefClient.EXPECT().PushTimeout().Return(pointer.Int(10))
|
||||
prefClient.EXPECT().EphemeralSourceVolume().Return(pointer.Bool(false))
|
||||
prefClient.EXPECT().ConsentTelemetry().Return(pointer.Bool(false))
|
||||
|
||||
@@ -23,15 +23,9 @@ type odoSettings struct {
|
||||
// Controls if an update notification is shown or not
|
||||
UpdateNotification *bool `yaml:"UpdateNotification,omitempty"`
|
||||
|
||||
// Holds the prefix part of generated random application name
|
||||
NamePrefix *string `yaml:"NamePrefix,omitempty"`
|
||||
|
||||
// Timeout for OpenShift server connection check
|
||||
Timeout *int `yaml:"Timeout,omitempty"`
|
||||
|
||||
// BuildTimeout for OpenShift build timeout check
|
||||
BuildTimeout *int `yaml:"BuildTimeout,omitempty"`
|
||||
|
||||
// PushTimeout for OpenShift pod timeout check
|
||||
PushTimeout *int `yaml:"PushTimeout,omitempty"`
|
||||
|
||||
@@ -266,16 +260,6 @@ func (c *preferenceInfo) SetConfiguration(parameter string, value string) error
|
||||
}
|
||||
c.OdoSettings.Timeout = &typedval
|
||||
|
||||
case "buildtimeout":
|
||||
typedval, err := strconv.Atoi(value)
|
||||
if err != nil {
|
||||
return errors.Errorf("unable to set %q to %q, value must be an integer", parameter, value)
|
||||
}
|
||||
if typedval < 0 {
|
||||
return errors.Errorf("cannot set timeout to less than 0")
|
||||
}
|
||||
c.OdoSettings.BuildTimeout = &typedval
|
||||
|
||||
case "pushtimeout":
|
||||
typedval, err := strconv.Atoi(value)
|
||||
if err != nil {
|
||||
@@ -303,10 +287,6 @@ func (c *preferenceInfo) SetConfiguration(parameter string, value string) error
|
||||
}
|
||||
c.OdoSettings.UpdateNotification = &val
|
||||
|
||||
// TODO: should we add a validator here? What is the use of nameprefix?
|
||||
case "nameprefix":
|
||||
c.OdoSettings.NamePrefix = &value
|
||||
|
||||
case "ephemeral":
|
||||
val, err := strconv.ParseBool(strings.ToLower(value))
|
||||
if err != nil {
|
||||
@@ -363,12 +343,6 @@ func (c *preferenceInfo) GetTimeout() int {
|
||||
return util.GetIntOrDefault(c.OdoSettings.Timeout, DefaultTimeout)
|
||||
}
|
||||
|
||||
// GetBuildTimeout gets the value set by BuildTimeout
|
||||
func (c *preferenceInfo) GetBuildTimeout() int {
|
||||
// default timeout value is 300
|
||||
return util.GetIntOrDefault(c.OdoSettings.BuildTimeout, DefaultBuildTimeout)
|
||||
}
|
||||
|
||||
// GetPushTimeout gets the value set by PushTimeout
|
||||
func (c *preferenceInfo) GetPushTimeout() int {
|
||||
// default timeout value is 1
|
||||
@@ -389,13 +363,7 @@ func (c *preferenceInfo) GetUpdateNotification() bool {
|
||||
// GetEphemeralSourceVolume returns the value of ephemeral from preferences
|
||||
// and if absent then returns default
|
||||
func (c *preferenceInfo) GetEphemeralSourceVolume() bool {
|
||||
return util.GetBoolOrDefault(c.OdoSettings.Ephemeral, DefaultEphemeralSettings)
|
||||
}
|
||||
|
||||
// GetNamePrefix returns the value of Prefix from preferences
|
||||
// and if absent then returns default
|
||||
func (c *preferenceInfo) GetNamePrefix() string {
|
||||
return util.GetStringOrEmpty(c.OdoSettings.NamePrefix)
|
||||
return util.GetBoolOrDefault(c.OdoSettings.Ephemeral, DefaultEphemeralSetting)
|
||||
}
|
||||
|
||||
// GetConsentTelemetry returns the value of ConsentTelemetry from preferences
|
||||
@@ -405,26 +373,33 @@ func (c *preferenceInfo) GetConsentTelemetry() bool {
|
||||
return util.GetBoolOrDefault(c.OdoSettings.ConsentTelemetry, DefaultConsentTelemetrySetting)
|
||||
}
|
||||
|
||||
// GetEphemeral returns the value of Ephemeral from preferences
|
||||
// and if absent then returns default
|
||||
// default value: true, ephemeral is enabled by default
|
||||
func (c *preferenceInfo) GetEphemeral() bool {
|
||||
return util.GetBoolOrDefault(c.OdoSettings.Ephemeral, DefaultEphemeralSetting)
|
||||
}
|
||||
|
||||
func (c *preferenceInfo) UpdateNotification() *bool {
|
||||
return c.OdoSettings.UpdateNotification
|
||||
}
|
||||
|
||||
func (c *preferenceInfo) NamePrefix() *string {
|
||||
return c.OdoSettings.NamePrefix
|
||||
func (c *preferenceInfo) Ephemeral() *bool {
|
||||
return c.OdoSettings.Ephemeral
|
||||
}
|
||||
|
||||
func (c *preferenceInfo) Timeout() *int {
|
||||
return c.OdoSettings.Timeout
|
||||
}
|
||||
|
||||
func (c *preferenceInfo) BuildTimeout() *int {
|
||||
return c.OdoSettings.BuildTimeout
|
||||
}
|
||||
|
||||
func (c *preferenceInfo) PushTimeout() *int {
|
||||
return c.OdoSettings.PushTimeout
|
||||
}
|
||||
|
||||
func (c *preferenceInfo) RegistryCacheTime() *int {
|
||||
return c.OdoSettings.RegistryCacheTime
|
||||
}
|
||||
|
||||
func (c *preferenceInfo) EphemeralSourceVolume() *bool {
|
||||
return c.OdoSettings.Ephemeral
|
||||
}
|
||||
|
||||
@@ -70,62 +70,6 @@ func TestNew(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetBuildTimeout(t *testing.T) {
|
||||
tempConfigFile, err := ioutil.TempFile("", "odoconfig")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer tempConfigFile.Close()
|
||||
os.Setenv(GlobalConfigEnvName, tempConfigFile.Name())
|
||||
zeroValue := 0
|
||||
nonzeroValue := 5
|
||||
tests := []struct {
|
||||
name string
|
||||
existingConfig Preference
|
||||
want int
|
||||
}{
|
||||
{
|
||||
name: "Case 1: Validating default value from test case",
|
||||
existingConfig: Preference{},
|
||||
want: 300,
|
||||
},
|
||||
|
||||
{
|
||||
name: "Case 2: Validating value 0 from configuration",
|
||||
existingConfig: Preference{
|
||||
OdoSettings: odoSettings{
|
||||
BuildTimeout: &zeroValue,
|
||||
},
|
||||
},
|
||||
want: 0,
|
||||
},
|
||||
|
||||
{
|
||||
name: "Case 3: Validating value 5 from configuration",
|
||||
existingConfig: Preference{
|
||||
OdoSettings: odoSettings{
|
||||
BuildTimeout: &nonzeroValue,
|
||||
},
|
||||
},
|
||||
want: 5,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
cfg, err := newPreferenceInfo()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
cfg.Preference = tt.existingConfig
|
||||
|
||||
output := cfg.GetBuildTimeout()
|
||||
if output != tt.want {
|
||||
t.Errorf("GetBuildTimeout returned unexpected value\ngot: %d \nexpected: %d\n", output, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetPushTimeout(t *testing.T) {
|
||||
tempConfigFile, err := ioutil.TempFile("", "odoconfig")
|
||||
if err != nil {
|
||||
@@ -358,15 +302,7 @@ func TestSetConfiguration(t *testing.T) {
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: fmt.Sprintf("Case 12: %s set to 50 with mixed case in parameter name", TimeoutSetting),
|
||||
parameter: "BuildTimeout",
|
||||
value: "50",
|
||||
existingConfig: Preference{},
|
||||
want: 50,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: fmt.Sprintf("Case 13: %s set to 0", TimeoutSetting),
|
||||
name: fmt.Sprintf("Case 12: %s set to 0", TimeoutSetting),
|
||||
parameter: TimeoutSetting,
|
||||
value: "0",
|
||||
existingConfig: Preference{},
|
||||
@@ -374,21 +310,14 @@ func TestSetConfiguration(t *testing.T) {
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: fmt.Sprintf("Case 14: %s set to -1 with mixed case in parameter name", TimeoutSetting),
|
||||
parameter: "BuildTimeout",
|
||||
value: "-1",
|
||||
existingConfig: Preference{},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: fmt.Sprintf("Case 15: %s invalid value", TimeoutSetting),
|
||||
name: fmt.Sprintf("Case 13: %s invalid value", TimeoutSetting),
|
||||
parameter: TimeoutSetting,
|
||||
value: "invalid",
|
||||
existingConfig: Preference{},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: fmt.Sprintf("Case 16: %s set to 99 with mixed case in parameter name", TimeoutSetting),
|
||||
name: fmt.Sprintf("Case 14: %s set to 99 with mixed case in parameter name", TimeoutSetting),
|
||||
parameter: "PushTimeout",
|
||||
value: "99",
|
||||
existingConfig: Preference{},
|
||||
@@ -396,28 +325,28 @@ func TestSetConfiguration(t *testing.T) {
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "Case 17: set RegistryCacheTime to 1",
|
||||
name: "Case 15: set RegistryCacheTime to 1",
|
||||
parameter: "RegistryCacheTime",
|
||||
value: "1",
|
||||
existingConfig: Preference{},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "Case 18: set RegistryCacheTime to non int value",
|
||||
name: "Case 16: set RegistryCacheTime to non int value",
|
||||
parameter: "RegistryCacheTime",
|
||||
value: "a",
|
||||
existingConfig: Preference{},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: fmt.Sprintf("Case 19: set %s to non bool value", ConsentTelemetrySetting),
|
||||
name: fmt.Sprintf("Case 17: set %s to non bool value", ConsentTelemetrySetting),
|
||||
parameter: ConsentTelemetrySetting,
|
||||
value: "123",
|
||||
existingConfig: Preference{},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: fmt.Sprintf("Case 20: set %s from nil to true", ConsentTelemetrySetting),
|
||||
name: fmt.Sprintf("Case 18: set %s from nil to true", ConsentTelemetrySetting),
|
||||
parameter: ConsentTelemetrySetting,
|
||||
value: "true",
|
||||
existingConfig: Preference{},
|
||||
@@ -425,7 +354,7 @@ func TestSetConfiguration(t *testing.T) {
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: fmt.Sprintf("Case 21: set %s from true to false", ConsentTelemetrySetting),
|
||||
name: fmt.Sprintf("Case 19: set %s from true to false", ConsentTelemetrySetting),
|
||||
parameter: ConsentTelemetrySetting,
|
||||
value: "false",
|
||||
existingConfig: Preference{
|
||||
|
||||
@@ -44,13 +44,6 @@ func toPreferenceItems(prefInfo preferenceInfo) []PreferenceItem {
|
||||
Type: getType(prefInfo.GetUpdateNotification()), // use the Getter here to determine type
|
||||
Description: UpdateNotificationSettingDescription,
|
||||
},
|
||||
{
|
||||
Name: NamePrefixSetting,
|
||||
Value: settings.NamePrefix,
|
||||
Default: "",
|
||||
Type: getType(prefInfo.GetNamePrefix()),
|
||||
Description: NamePrefixSettingDescription,
|
||||
},
|
||||
{
|
||||
Name: TimeoutSetting,
|
||||
Value: settings.Timeout,
|
||||
@@ -58,13 +51,6 @@ func toPreferenceItems(prefInfo preferenceInfo) []PreferenceItem {
|
||||
Type: getType(prefInfo.GetTimeout()),
|
||||
Description: TimeoutSettingDescription,
|
||||
},
|
||||
{
|
||||
Name: BuildTimeoutSetting,
|
||||
Value: settings.BuildTimeout,
|
||||
Default: DefaultBuildTimeout,
|
||||
Type: getType(prefInfo.GetBuildTimeout()),
|
||||
Description: BuildTimeoutSettingDescription,
|
||||
},
|
||||
{
|
||||
Name: PushTimeoutSetting,
|
||||
Value: settings.PushTimeout,
|
||||
@@ -72,12 +58,26 @@ func toPreferenceItems(prefInfo preferenceInfo) []PreferenceItem {
|
||||
Type: getType(prefInfo.GetPushTimeout()),
|
||||
Description: PushTimeoutSettingDescription,
|
||||
},
|
||||
{
|
||||
Name: RegistryCacheTimeSetting,
|
||||
Value: settings.RegistryCacheTime,
|
||||
Default: DefaultRegistryCacheTime,
|
||||
Type: getType(prefInfo.GetRegistryCacheTime()),
|
||||
Description: RegistryCacheTimeSettingDescription,
|
||||
},
|
||||
{
|
||||
Name: ConsentTelemetrySetting,
|
||||
Value: settings.ConsentTelemetry,
|
||||
Default: DefaultConsentTelemetrySetting,
|
||||
Type: getType(prefInfo.GetConsentTelemetry()),
|
||||
Description: ConsentTelemetryDescription,
|
||||
Description: ConsentTelemetrySettingDescription,
|
||||
},
|
||||
{
|
||||
Name: EphemeralSetting,
|
||||
Value: settings.Ephemeral,
|
||||
Default: DefaultEphemeralSetting,
|
||||
Type: getType(prefInfo.GetEphemeral()),
|
||||
Description: EphemeralSettingDescription,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,20 +33,6 @@ func (m *MockClient) EXPECT() *MockClientMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// BuildTimeout mocks base method.
|
||||
func (m *MockClient) BuildTimeout() *int {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "BuildTimeout")
|
||||
ret0, _ := ret[0].(*int)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// BuildTimeout indicates an expected call of BuildTimeout.
|
||||
func (mr *MockClientMockRecorder) BuildTimeout() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BuildTimeout", reflect.TypeOf((*MockClient)(nil).BuildTimeout))
|
||||
}
|
||||
|
||||
// ConsentTelemetry mocks base method.
|
||||
func (m *MockClient) ConsentTelemetry() *bool {
|
||||
m.ctrl.T.Helper()
|
||||
@@ -89,20 +75,6 @@ func (mr *MockClientMockRecorder) EphemeralSourceVolume() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EphemeralSourceVolume", reflect.TypeOf((*MockClient)(nil).EphemeralSourceVolume))
|
||||
}
|
||||
|
||||
// GetBuildTimeout mocks base method.
|
||||
func (m *MockClient) GetBuildTimeout() int {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetBuildTimeout")
|
||||
ret0, _ := ret[0].(int)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// GetBuildTimeout indicates an expected call of GetBuildTimeout.
|
||||
func (mr *MockClientMockRecorder) GetBuildTimeout() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetBuildTimeout", reflect.TypeOf((*MockClient)(nil).GetBuildTimeout))
|
||||
}
|
||||
|
||||
// GetConsentTelemetry mocks base method.
|
||||
func (m *MockClient) GetConsentTelemetry() bool {
|
||||
m.ctrl.T.Helper()
|
||||
@@ -131,20 +103,6 @@ func (mr *MockClientMockRecorder) GetEphemeralSourceVolume() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEphemeralSourceVolume", reflect.TypeOf((*MockClient)(nil).GetEphemeralSourceVolume))
|
||||
}
|
||||
|
||||
// GetNamePrefix mocks base method.
|
||||
func (m *MockClient) GetNamePrefix() string {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetNamePrefix")
|
||||
ret0, _ := ret[0].(string)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// GetNamePrefix indicates an expected call of GetNamePrefix.
|
||||
func (mr *MockClientMockRecorder) GetNamePrefix() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNamePrefix", reflect.TypeOf((*MockClient)(nil).GetNamePrefix))
|
||||
}
|
||||
|
||||
// GetPushTimeout mocks base method.
|
||||
func (m *MockClient) GetPushTimeout() int {
|
||||
m.ctrl.T.Helper()
|
||||
@@ -215,20 +173,6 @@ func (mr *MockClientMockRecorder) IsSet(parameter interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsSet", reflect.TypeOf((*MockClient)(nil).IsSet), parameter)
|
||||
}
|
||||
|
||||
// NamePrefix mocks base method.
|
||||
func (m *MockClient) NamePrefix() *string {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "NamePrefix")
|
||||
ret0, _ := ret[0].(*string)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// NamePrefix indicates an expected call of NamePrefix.
|
||||
func (mr *MockClientMockRecorder) NamePrefix() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NamePrefix", reflect.TypeOf((*MockClient)(nil).NamePrefix))
|
||||
}
|
||||
|
||||
// NewPreferenceList mocks base method.
|
||||
func (m *MockClient) NewPreferenceList() PreferenceList {
|
||||
m.ctrl.T.Helper()
|
||||
@@ -243,6 +187,20 @@ func (mr *MockClientMockRecorder) NewPreferenceList() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewPreferenceList", reflect.TypeOf((*MockClient)(nil).NewPreferenceList))
|
||||
}
|
||||
|
||||
// RegistryCacheTime mocks base method.
|
||||
func (m *MockClient) RegistryCacheTime() *int {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "RegistryCacheTime")
|
||||
ret0, _ := ret[0].(*int)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// RegistryCacheTime indicates an expected call of RegistryCacheTime.
|
||||
func (mr *MockClientMockRecorder) RegistryCacheTime() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegistryCacheTime", reflect.TypeOf((*MockClient)(nil).RegistryCacheTime))
|
||||
}
|
||||
|
||||
// PushTimeout mocks base method.
|
||||
func (m *MockClient) PushTimeout() *int {
|
||||
m.ctrl.T.Helper()
|
||||
|
||||
@@ -6,9 +6,7 @@ type Client interface {
|
||||
DeleteConfiguration(parameter string) error
|
||||
|
||||
GetUpdateNotification() bool
|
||||
GetNamePrefix() string
|
||||
GetTimeout() int
|
||||
GetBuildTimeout() int
|
||||
GetPushTimeout() int
|
||||
GetEphemeralSourceVolume() bool
|
||||
GetConsentTelemetry() bool
|
||||
@@ -16,10 +14,9 @@ type Client interface {
|
||||
RegistryHandler(operation string, registryName string, registryURL string, forceFlag bool, isSecure bool) error
|
||||
|
||||
UpdateNotification() *bool
|
||||
NamePrefix() *string
|
||||
Timeout() *int
|
||||
BuildTimeout() *int
|
||||
PushTimeout() *int
|
||||
RegistryCacheTime() *int
|
||||
EphemeralSourceVolume() *bool
|
||||
ConsentTelemetry() *bool
|
||||
RegistryList() *[]Registry
|
||||
|
||||
@@ -19,27 +19,15 @@ const (
|
||||
// DefaultPushTimeout is the default timeout for pods (in seconds)
|
||||
DefaultPushTimeout = 240
|
||||
|
||||
// DefaultBuildTimeout is the default build timeout for pods (in seconds)
|
||||
DefaultBuildTimeout = 300
|
||||
|
||||
// UpdateNotificationSetting is the name of the setting controlling update notification
|
||||
UpdateNotificationSetting = "UpdateNotification"
|
||||
|
||||
// UpdateNotificationSettingDescription is human-readable description for the update notification setting
|
||||
UpdateNotificationSettingDescription = "Flag to control if an update notification is shown or not (Default: true)"
|
||||
|
||||
// NamePrefixSetting is the name of the setting controlling name prefix
|
||||
NamePrefixSetting = "NamePrefix"
|
||||
|
||||
// NamePrefixSettingDescription is human-readable description for the name prefix setting
|
||||
NamePrefixSettingDescription = "Use this value to set a default name prefix (Default: current directory name)"
|
||||
|
||||
// TimeoutSetting is the name of the setting controlling timeout for connection check
|
||||
TimeoutSetting = "Timeout"
|
||||
|
||||
// BuildTimeoutSetting is the name of the setting controlling BuildTimeout
|
||||
BuildTimeoutSetting = "BuildTimeout"
|
||||
|
||||
// PushTimeoutSetting is the name of the setting controlling PushTimeout
|
||||
PushTimeoutSetting = "PushTimeout"
|
||||
|
||||
@@ -61,8 +49,8 @@ const (
|
||||
// EphemeralSetting specifies if ephemeral volumes needs to be used as source volume.
|
||||
EphemeralSetting = "Ephemeral"
|
||||
|
||||
// DefaultEphemeralSettings is a default value for Ephemeral preference
|
||||
DefaultEphemeralSettings = true
|
||||
// DefaultEphemeralSetting is a default value for Ephemeral preference
|
||||
DefaultEphemeralSetting = true
|
||||
|
||||
// ConsentTelemetrySettings specifies if the user consents to telemetry
|
||||
ConsentTelemetrySetting = "ConsentTelemetry"
|
||||
@@ -77,17 +65,14 @@ var TimeoutSettingDescription = fmt.Sprintf("Timeout (in seconds) for OpenShift
|
||||
// PushTimeoutSettingDescription adds a description for PushTimeout
|
||||
var PushTimeoutSettingDescription = fmt.Sprintf("PushTimeout (in seconds) for waiting for a Pod to come up (Default: %d)", DefaultPushTimeout)
|
||||
|
||||
// BuildTimeoutSettingDescription adds a description for BuildTimeout
|
||||
var BuildTimeoutSettingDescription = fmt.Sprintf("BuildTimeout (in seconds) for waiting for a build of the git component to complete (Default: %d)", DefaultBuildTimeout)
|
||||
// RegistryCacheTimeSettingDescription adds a description for RegistryCacheTime
|
||||
var RegistryCacheTimeSettingDescription = fmt.Sprintf("For how long (in minutes) odo will cache information from the Devfile registry (Default: %d)", DefaultRegistryCacheTime)
|
||||
|
||||
// RegistryCacheTimeDescription adds a description for RegistryCacheTime
|
||||
var RegistryCacheTimeDescription = fmt.Sprintf("For how long (in minutes) odo will cache information from Devfile registry (Default: %d)", DefaultRegistryCacheTime)
|
||||
// EphemeralSettingDescription adds a description for EphemeralSourceVolume
|
||||
var EphemeralSettingDescription = fmt.Sprintf("If true, odo will create an emptyDir volume to store source code (Default: %t)", DefaultEphemeralSetting)
|
||||
|
||||
// EphemeralDescription adds a description for EphemeralSourceVolume
|
||||
var EphemeralDescription = fmt.Sprintf("If true, odo will create an emptyDir volume to store source code (Default: %t)", DefaultEphemeralSettings)
|
||||
|
||||
//TelemetryConsentDescription adds a description for TelemetryConsentSetting
|
||||
var ConsentTelemetryDescription = fmt.Sprintf("If true, odo will collect telemetry for the user's odo usage (Default: %t)\n\t\t For more information: https://developers.redhat.com/article/tool-data-collection", DefaultConsentTelemetrySetting)
|
||||
// ConsentTelemetrySettingDescription adds a description for TelemetryConsentSetting
|
||||
var ConsentTelemetrySettingDescription = fmt.Sprintf("If true, odo will collect telemetry for the user's odo usage (Default: %t)\n\t\t For more information: https://developers.redhat.com/article/tool-data-collection", DefaultConsentTelemetrySetting)
|
||||
|
||||
// This value can be provided to set a seperate directory for users 'homedir' resolution
|
||||
// note for mocking purpose ONLY
|
||||
@@ -97,13 +82,11 @@ var (
|
||||
// records information on supported parameters
|
||||
supportedParameterDescriptions = map[string]string{
|
||||
UpdateNotificationSetting: UpdateNotificationSettingDescription,
|
||||
NamePrefixSetting: NamePrefixSettingDescription,
|
||||
TimeoutSetting: TimeoutSettingDescription,
|
||||
BuildTimeoutSetting: BuildTimeoutSettingDescription,
|
||||
PushTimeoutSetting: PushTimeoutSettingDescription,
|
||||
RegistryCacheTimeSetting: RegistryCacheTimeDescription,
|
||||
EphemeralSetting: EphemeralDescription,
|
||||
ConsentTelemetrySetting: ConsentTelemetryDescription,
|
||||
RegistryCacheTimeSetting: RegistryCacheTimeSettingDescription,
|
||||
EphemeralSetting: EphemeralSettingDescription,
|
||||
ConsentTelemetrySetting: ConsentTelemetrySettingDescription,
|
||||
}
|
||||
|
||||
// set-like map to quickly check if a parameter is supported
|
||||
|
||||
@@ -3,7 +3,7 @@ package segment
|
||||
import (
|
||||
"github.com/Xuanwo/go-locale"
|
||||
registryLibrary "github.com/devfile/registry-support/registry-library/library"
|
||||
registryConsts "github.com/redhat-developer/odo/pkg/odo/cli/registry/consts"
|
||||
registryConsts "github.com/redhat-developer/odo/pkg/odo/cli/preference/registry/consts"
|
||||
"github.com/redhat-developer/odo/pkg/preference"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
@@ -397,7 +397,7 @@ func VerifyResourcesToBeDeleted(runner CliRunner, resources []ResourceInfo) {
|
||||
func SetDefaultDevfileRegistryAsStaging() {
|
||||
const registryName string = "DefaultDevfileRegistry"
|
||||
const addRegistryURL string = "https://registry.stage.devfile.io"
|
||||
Cmd("odo", "registry", "update", registryName, addRegistryURL, "-f").ShouldPass()
|
||||
Cmd("odo", "preference", "registry", "update", registryName, addRegistryURL, "-f").ShouldPass()
|
||||
}
|
||||
|
||||
// CopyAndCreate copies required source code and devfile to the given context directory, and creates a component
|
||||
|
||||
@@ -58,7 +58,7 @@ var _ = Describe("odo preference and config command tests", func() {
|
||||
})
|
||||
It("should get the default global config keys", func() {
|
||||
configOutput := helper.Cmd("odo", "preference", "view").ShouldPass().Out()
|
||||
preferences := []string{"UpdateNotification", "NamePrefix", "Timeout", "BuildTimeout", "PushTimeout", "Ephemeral", "ConsentTelemetry"}
|
||||
preferences := []string{"UpdateNotification", "Timeout", "PushTimeout", "RegistryCacheTime", "Ephemeral", "ConsentTelemetry"}
|
||||
helper.MatchAllInOutput(configOutput, preferences)
|
||||
for _, key := range preferences {
|
||||
value := helper.GetPreferenceValue(key)
|
||||
@@ -73,11 +73,11 @@ var _ = Describe("odo preference and config command tests", func() {
|
||||
}{
|
||||
{"UpdateNotification", "false", "true", "foo"},
|
||||
{"Timeout", "5", "6", "foo"},
|
||||
{"NamePrefix", "foo", "bar", ""},
|
||||
{"BuildTimeout", "5", "7", "foo"},
|
||||
// !! Do not test ConsentTelemetry with true because it sends out the telemetry data and messes up the statistics !!
|
||||
{"ConsentTelemetry", "false", "false", "foo"},
|
||||
{"PushTimeout", "4", "6", "f00"},
|
||||
{"PushTimeout", "4", "6", "foo"},
|
||||
{"RegistryCacheTime", "4", "6", "foo"},
|
||||
{"Ephemeral", "false", "true", "foo"},
|
||||
}
|
||||
|
||||
It("should successfully updated", func() {
|
||||
@@ -98,15 +98,6 @@ var _ = Describe("odo preference and config command tests", func() {
|
||||
os.RemoveAll(filepath.Join(globalConfPath, ".odo"))
|
||||
})
|
||||
|
||||
It("should unsuccessfully update", func() {
|
||||
for _, pref := range preferences {
|
||||
// TODO: Remove this once we decide something on checking NamePrefix
|
||||
if pref.name != "NamePrefix" {
|
||||
helper.Cmd("odo", "preference", "set", "-f", pref.name, pref.invalidValue).ShouldFail()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
It("should show json output", func() {
|
||||
prefJSONOutput, err := helper.Unindented(helper.Cmd("odo", "preference", "view", "-o", "json").ShouldPass().Out())
|
||||
Expect(err).Should(BeNil())
|
||||
@@ -131,10 +122,10 @@ var _ = Describe("odo preference and config command tests", func() {
|
||||
output := helper.Cmd("odo", "preference", "view").ShouldPass().Out()
|
||||
Expect(output).ToNot(ContainSubstring(promptMessageSubString))
|
||||
|
||||
output = helper.Cmd("odo", "preference", "set", "buildtimeout", "5", "-f").ShouldPass().Out()
|
||||
output = helper.Cmd("odo", "preference", "set", "timeout", "5", "-f").ShouldPass().Out()
|
||||
Expect(output).ToNot(ContainSubstring(promptMessageSubString))
|
||||
|
||||
output = helper.Cmd("odo", "preference", "unset", "buildtimeout", "-f").ShouldPass().Out()
|
||||
output = helper.Cmd("odo", "preference", "unset", "timeout", "-f").ShouldPass().Out()
|
||||
Expect(output).ToNot(ContainSubstring(promptMessageSubString))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -113,12 +113,12 @@ var _ = Describe("odo devfile catalog command tests", func() {
|
||||
var output string
|
||||
|
||||
BeforeEach(func() {
|
||||
helper.Cmd("odo", "registry", "add", "fake", "http://fake").ShouldPass()
|
||||
helper.Cmd("odo", "preference", "registry", "add", "fake", "http://fake").ShouldPass()
|
||||
output = helper.Cmd("odo", "catalog", "list", "components").ShouldPass().Out()
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
helper.Cmd("odo", "registry", "delete", "fake", "-f").ShouldPass()
|
||||
helper.Cmd("odo", "preference", "registry", "delete", "fake", "-f").ShouldPass()
|
||||
})
|
||||
|
||||
It("should list components from valid registry", func() {
|
||||
@@ -139,7 +139,7 @@ var _ = Describe("odo devfile catalog command tests", func() {
|
||||
var output string
|
||||
|
||||
BeforeEach(func() {
|
||||
helper.Cmd("odo", "registry", "add", registryName, addRegistryURL).ShouldPass()
|
||||
helper.Cmd("odo", "preference", "registry", "add", registryName, addRegistryURL).ShouldPass()
|
||||
output = helper.Cmd("odo", "catalog", "describe", "component", "nodejs").ShouldPass().Out()
|
||||
|
||||
})
|
||||
|
||||
@@ -27,36 +27,36 @@ var _ = Describe("odo devfile registry command tests", func() {
|
||||
})
|
||||
|
||||
It("Should list all default registries", func() {
|
||||
output := helper.Cmd("odo", "registry", "list").ShouldPass().Out()
|
||||
output := helper.Cmd("odo", "preference", "registry", "list").ShouldPass().Out()
|
||||
helper.MatchAllInOutput(output, []string{"DefaultDevfileRegistry"})
|
||||
})
|
||||
|
||||
It("Should list all default registries with json", func() {
|
||||
output := helper.Cmd("odo", "registry", "list", "-o", "json").ShouldPass().Out()
|
||||
output := helper.Cmd("odo", "preference", "registry", "list", "-o", "json").ShouldPass().Out()
|
||||
helper.MatchAllInOutput(output, []string{"DefaultDevfileRegistry"})
|
||||
})
|
||||
|
||||
It("Should fail with an error with no registries", func() {
|
||||
helper.Cmd("odo", "registry", "delete", "DefaultDevfileRegistry", "-f").ShouldPass()
|
||||
output := helper.Cmd("odo", "registry", "list").ShouldFail().Err()
|
||||
helper.Cmd("odo", "preference", "registry", "delete", "DefaultDevfileRegistry", "-f").ShouldPass()
|
||||
output := helper.Cmd("odo", "preference", "registry", "list").ShouldFail().Err()
|
||||
helper.MatchAllInOutput(output, []string{"No devfile registries added to the configuration. Refer `odo registry add -h` to add one"})
|
||||
})
|
||||
|
||||
It("Should fail to update the registry, when registry is not present", func() {
|
||||
helper.Cmd("odo", "registry", "update", registryName, updateRegistryURL, "-f").ShouldFail()
|
||||
helper.Cmd("odo", "preference", "registry", "update", registryName, updateRegistryURL, "-f").ShouldFail()
|
||||
})
|
||||
|
||||
It("Should fail to delete the registry, when registry is not present", func() {
|
||||
helper.Cmd("odo", "registry", "delete", registryName, "-f").ShouldFail()
|
||||
helper.Cmd("odo", "preference", "registry", "delete", registryName, "-f").ShouldFail()
|
||||
})
|
||||
|
||||
When("adding a registry", func() {
|
||||
BeforeEach(func() {
|
||||
helper.Cmd("odo", "registry", "add", registryName, addRegistryURL).ShouldPass()
|
||||
helper.Cmd("odo", "preference", "registry", "add", registryName, addRegistryURL).ShouldPass()
|
||||
})
|
||||
|
||||
It("should list newly added registry", func() {
|
||||
output := helper.Cmd("odo", "registry", "list").ShouldPass().Out()
|
||||
output := helper.Cmd("odo", "preference", "registry", "list").ShouldPass().Out()
|
||||
helper.MatchAllInOutput(output, []string{registryName, addRegistryURL})
|
||||
})
|
||||
|
||||
@@ -65,21 +65,21 @@ var _ = Describe("odo devfile registry command tests", func() {
|
||||
})
|
||||
|
||||
It("should fail, when adding same registry", func() {
|
||||
helper.Cmd("odo", "registry", "add", registryName, addRegistryURL).ShouldFail()
|
||||
helper.Cmd("odo", "preference", "registry", "add", registryName, addRegistryURL).ShouldFail()
|
||||
})
|
||||
|
||||
It("should successfully delete registry", func() {
|
||||
helper.Cmd("odo", "registry", "delete", registryName, "-f").ShouldPass()
|
||||
helper.Cmd("odo", "preference", "registry", "delete", registryName, "-f").ShouldPass()
|
||||
})
|
||||
|
||||
It("should successfully update the registry", func() {
|
||||
helper.Cmd("odo", "registry", "update", registryName, updateRegistryURL, "-f").ShouldPass()
|
||||
output := helper.Cmd("odo", "registry", "list").ShouldPass().Out()
|
||||
helper.Cmd("odo", "preference", "registry", "update", registryName, updateRegistryURL, "-f").ShouldPass()
|
||||
output := helper.Cmd("odo", "preference", "registry", "list").ShouldPass().Out()
|
||||
helper.MatchAllInOutput(output, []string{registryName, updateRegistryURL})
|
||||
})
|
||||
|
||||
It("deleting registry and creating component with registry flag ", func() {
|
||||
helper.Cmd("odo", "registry", "delete", registryName, "-f").ShouldPass()
|
||||
helper.Cmd("odo", "preference", "registry", "delete", registryName, "-f").ShouldPass()
|
||||
helper.Cmd("odo", "create", "java-maven", "--registry", registryName).ShouldFail()
|
||||
})
|
||||
})
|
||||
@@ -92,13 +92,13 @@ var _ = Describe("odo devfile registry command tests", func() {
|
||||
})
|
||||
|
||||
It("should not show deprication warning, if git registry is not used", func() {
|
||||
out, err = helper.Cmd("odo", "registry", "list").ShouldPass().OutAndErr()
|
||||
out, err = helper.Cmd("odo", "preference", "registry", "list").ShouldPass().OutAndErr()
|
||||
helper.DontMatchAllInOutput(fmt.Sprintln(out, err), []string{deprecated, docLink})
|
||||
})
|
||||
|
||||
When("adding git based registries", func() {
|
||||
BeforeEach(func() {
|
||||
out, err = helper.Cmd("odo", "registry", "add", "RegistryFromGitHub", "https://github.com/odo-devfiles/registry").ShouldPass().OutAndErr()
|
||||
out, err = helper.Cmd("odo", "preference", "registry", "add", "RegistryFromGitHub", "https://github.com/odo-devfiles/registry").ShouldPass().OutAndErr()
|
||||
|
||||
})
|
||||
It("should show deprication warning", func() {
|
||||
@@ -106,7 +106,7 @@ var _ = Describe("odo devfile registry command tests", func() {
|
||||
helper.MatchAllInOutput(co, []string{deprecated, docLink})
|
||||
|
||||
By("odo resgistry list is executed, should show the warning", func() {
|
||||
out, err = helper.Cmd("odo", "registry", "list").ShouldPass().OutAndErr()
|
||||
out, err = helper.Cmd("odo", "preference", "registry", "list").ShouldPass().OutAndErr()
|
||||
co = fmt.Sprintln(out, err)
|
||||
helper.MatchAllInOutput(co, []string{deprecated, docLink})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user