* Add random string generator util
This commit adds a genric utility(and UTs to test associated
functionality) to generate random names using:
1. a prefix
2. an optional suffix
and additionally checks if the generated name is already in use in:
3. passed existList.
The utility generates the name in the form of prefix-suffix but if
the same is already in use(present already in the passed existList),
a new unique(not in existList) name of the form prefix-suffix-(a-z){4}
will be attempted to be generated. Additionally, if suffix is not passed,
it attempts to generate a suffix using the MIT licensed vendored library
`github.com/Pallinder/go-randomdata` that can generate the random strings
as in: `https://github.com/Pallinder/go-randomdata/blob/master/README.md`
fixes#216
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Make app name non-mandatory for odo create app
This commit makes the `odo create app`command generate a
random name for the application if the user has not passed the
app name as `odo create app <app_name>`.
The random name involves the following parts:
1. configurable prefix with `app` as safe default
2. randomly generated suffix which if already used will be further
appended with a 4 character random string for duplicate resolution
fixes#216
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Add vendored package
fixes#216
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @snarwade and @syamgk comments
fixes#741
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Add UTs and e2e tests
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @mik-dass comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix travis errors
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate comments from @golangcibot
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix travis failures
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Random generate component names
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @cdrage comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Changes as per new suggestions by @jorgemoralespou
The new behaviour is as follows:
By default(in absence of prefix in config being overriden) app and component
names will be named after the directory from which `odo app create` and
`odo create` components are used along with a random 4 char length string as
unique suffix. However, if the prefix in config is overriden by user, the same
will be used instead of fetching any directory/path names along with the random
4 char length string unique suffix..
This is achieved as follows:
1. For component create, in absence of `prefix` being overriden by user in the
odo config:
a. If component is created from git, the git url's ending part which
is the repository name is used for app and compoennt names. For,
component name, additionally we use component type also.
case 1: Component creation in absence of an app
app name: ${repo_name}-${random_4_char_str}
component name: ${repo_name}-${component_type}-${random_4_char_str}
case 2: App exists already
component name: ${repo_name}-${component_type}-${random_4_char_str}
b. If component is created from local source, the last part of source path,
which is the source directory, is used for app and compoennt names. For,
component name, additionally we use component type also.
case 1: Component creation in absence of an app
app name: ${src_dir_name}-${random_4_char_str}
component name: ${src_dir_name}-${component_type}-${random_4_char_str}
case 2: App exists already
component name: ${src_dir_name}-${component_type}-${random_4_char_str}
c. If component is created from binary, the binary name excluding its extension
is used for app and compoennt names. For component name, additionally we use
component type also.
case 1: Component creation in absence of an app
app name: ${binary_name}-${random_4_char_str}
component name: ${binary_name}-${component_type}-${random_4_char_str}
case 2: App exists already
component name: ${binary_name}-${component_type}-${random_4_char_str}
2. For app create, in absence of `prefix` being overriden by user in the
odo config:
app name: ${current-dir}-${random_4_char_str}
3. For app create in case of prefix in config being overriden,
app name: ${prefix}-${random_4_char_str}
4. For component create, in case of a configured prefix,
app name: ${prefix}-${random_4_char_str}
component name: ${prefix}-${component_type}-${random_4_char_str}
fixes#216
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix tests as per latest changes
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Remove the no-more required vendored package go-randomdata
This is no longer required due to new changes
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @codeclimate and @golangcibot comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix travis failures
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @GolangCI comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @cdrage comments
This commit adds option to delete app(current app) if app name
is not passed for deletion.
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incorporate @snarwade comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Rebase
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @cdrage comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @mik-dass comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix travis failure
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incorporate @kadel comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incorporate @tkral comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @tkral comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Doc update
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix travis failures
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incorporate @cdrage comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* fix#690 : odo version shows server version without logging in
odo version shows the server version without logging in.
* rename variable GlobalConnectionCheck
rename GlobalConnectionCheck to GlobalSkipConnectionCheck
* add e2e test for odo version
* Delete project enhancements + unit tests and e2e tests
This PR adds the following:
1. When a project is deleted, the delete project now displays also the
active project post deletion if there are more projects left post deletion
2. Adds UTs and e2e tests for project delete
3. Handles the case of project list with no projects with a proper message
indicating that there are no currently available projects and suggests the
command to create a project instead of displaying an empty table.
fixes#726#750
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Addess @codeclimate comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @cdrage and @snarwade comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @snarwade and @tkral comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix gofmt errors
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @codeclimate comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incorporate @cdrage comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix travis failures
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incorporate @tkral comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix error msgs -- start them with small letters
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix#721
* Enhance service instance's creation to generate automatically the secret with the parameters of the plan
* Add command odo service link to link the secret to component
* Add step to rollout the DC and redeploy it
* Remove comment non required
* Remove panic
* Change the test condition to raise an exception if we don't have exactly an array of 2 strings
* Change type from interface{} to Map[string]string
* Add unit tests
* Fix printf string
* Improve ParametersAsMap
* Move and rename function
* Fix broken test
* Replace string magic with --plan flag
* Remove the need to have parameters as mandatory
* Fix example text
* Fix comment issues
* Fix validation issue
* Polish
* Fix comments
* Use appropriate parameter names
* Replace link command with service link
* Polish link creation
* Fix LinkSecret issue
* Improve error messages for erroneous service creation
* Fix erroneous comments
* Fail the application if parsing args ConvertKeyValueStringToMap fails
* Polish
* Fix flag name
* Polish
* Revert "Fix flag name"
This reverts commit bb04449d
* Fix parameter name
* Improve parameters handling
* Fix odo service create to accept service name
* When only one plan is available, select it if not is specified
* Polish
* Fix logging issue
* Fix test after rebasing onto master
* Improve error messages during service linking
* Further improve error handling during linking
* Fix service deletion
* Fix error messages
The update functionality was changed to add the env vars to the buildConfig incase of git otherwise remove it. A new fucntion GetEnvVarsFromDC() was introduced to retrieve the env vars from the DC.
Function getinputEnvsFromStrings is added to retrive the env vars from the input strings. Also function addEnv is added to add the corev1.EnvVars to the deploymentConfig.
Signed-off-by: mdas <mrinald7@gmail.com>
This implements a new SupervisorD method for both local and binary
components. Rather than using BuildConfig which takes a considerable
amount of time, this uses multiple initContainer's in order to
successfully deploy source code to OpenShift.
The related code can be found within `pkg/occlient/templates.go`.
This commit also:
- Removes BuildConfig dependency within `odo update`
- Refactors `occlient.go` considerably by moving "template" code into
`templates.go`
- Refactors multiple functions within occlient.go and component.go to
use commonObjectMeta more frequently, reducing the amount of
parameters needed for certain functions.
- Adds a new constant into the labels with Namespace
`const ComponentTypeNamespace =
"app.kubernetes.io/component-namespace"`
- A new image is used (and provided under the `scripts/supervisord`
directory) to deploy the supervisorD image
- New functions such as: PatchCurrentDC which will correctly patch a
DeploymentConfig but still contain / be consistent with volumes which
were previously created with `odo create`
This PR modifies `service catalog list services` command to show corresponding plans
to services,
For example,
```
$ odo catalog list services
NAME PLANS
dh-gluster-s3-apb default
dh-nginx-apb default
dh-proxy-config-apb passthrough,custom
dh-eclipse-che-apb prod
dh-galera-apb persistent,ephemeral
```
Signed-off-by: Suraj Narwade <surajnarwade353@gmail.com>
* Add support for odo app list --project name
Add e2e regarding the new command
Refactored list function to make code reusable
Use tabwriter to print everything
Fix typos
Fixes#206
* Adds function to set all applications inactive
Implemented a function to set all applications inactive
of the current project when switching to other project
Refactored the unset active component to be able to
use in project because we want to unset active component
also when switching to other project
Refactored delete component function because we want
to unset only if application name and current application
name are equal
* Fix typo
* Make odo watch command configurable
This commit makes the list of filepath patterns to be ignored
and also the watch-push delay configurable which can now be
passed as arguements to the command. It also performs the
following fixes to the watch command:
1. Ignore watch on directories and files matching the ignore paths
2. Avoid pushing changes in files and folders that match ignore paths
2 above is required in-spite of 1, because, 1 can only ignore paths
that match the ignores along with their children but not their parents.
So, the watch on parent dir still can potentially catch a change in its
immediate child which can only be ignored at the time of push.
fixes#639#640
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @cdrage and @kadel comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* More fixes
This commit does the following:
1. Additionally filter out anything in ignores list from the list of changed files
notified by fsnotifier . This is important inspite of not watching the
ignores paths because, when a directory that is ignored, is deleted,
because its parent is watched, the fsnotify automatically raises an event
for it.
2. In windows, any folder creation event, generates 2 events:
a. Create event for the new folder
b. Write event for the parent folder of newly created folder
Ignore (b) to avoid duplicate events.
3. makeTar always expects the event to be generated for a file. But events
for directories are also possible. So, call recursivetar instead of individual
tar
fixes#639#640
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incorporate @kadel comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fixes
This commit adds the following fixes:
1. In case of delete/rename, os.Lstat would fail on a non-existant file
hence it should be done for non-delete and non-rename cases.
2. Adds a check before pushing changes to remote pod to see if the changes
to be pushed is empty. Because without this check, even if the changeset
is empty, if an ignored file under a watched directory changes, the watched
directory detects an event for the change of its child file that is ignored
and the push happens whenever an event is caught.
3. Clear changedFiles slice after pushing updates so that, the previously
changed files are not again pushed along with the current changes
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @cdrage comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Avoid crash for temporary files
When a file is edited using editors like vim,
a buffer file with extension .swp and .swx are generated which are
created until the edit is in progress and is deleted immediately
after exiting from the editor.
This commit handles such a case by adding a nil check for os.Lstat
o/p.
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
Without flag.Parse, glog complains "ERROR: logging before flag.Parse".
To avoid it, this PR adds flag.Parse() call
fixes#752
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* add odo utils config command for enable/disable parameters
- add config command
- create a new field 'config' in odoconfig file
for storing odo specific configurations
* update CLI structure in Readme.md
* Add documentation for logging in odo and odo create enhancements
This PR adds the following information:
1. Enhancements in odo create command added to docs/cli-reference.md
2. docs/logging.md describes about the use of glog for logging
fixes#667
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @cdrage comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* [Component Create]: Allow imagestreams from current namespace to be used
This PR allows, components to be created using imagestreams from current
namespace. This is as per below:
```
If User has not chosen image NS(as in `odo create nodejs --git https://github.com/openshift/django-ex.git`)then,
1. Use image from current NS if available
2. If not 1, use default openshift NS
3. If not 2, return errors from both 1 and 2
else(as in `odo create myproject/nodejs --git https://github.com/openshift/django-ex.git`)
Use user chosen namespace
If image doesn't exist in user chosen namespace,
error out
else
Proceed with build and deployment
```
fixes#566
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* [Catalog list]: Allow imagestreams from current namespace to be listed
This PR allows listing of catalogs from current namespace as they can be also
used for creating components. It lists the catalogs as under:
$IS_NAMESPACE/$IS_NAME $TAG
fixes#566
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Add tests
fixes#566
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Add `*` to catalog of priority in catalog list
This PR adds `*` to the catalog that will be considered on priority
for component creation in cases when a imagestream of same name exists
in both openshift and the current namespaces.
fixes#566
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix component name creation from component type
Extract the component type part from passed fully qualified or un-qualified
default component type and use it as default chosen component name
fixes#566
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @tkral comments
fixes#566
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incorporate @ashetty1 comments
fixes#566
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix validate errors
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Add e2e test
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Rebase
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporated @tkral comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @ashetty1 comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incorporate @cdrage comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @snarwade comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Fix e2e test after rebase
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @cdrage comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @ashetty1 comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incorporate @cdrage comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @syamgk comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @cdrage comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>
* Incoporate @cdrage comments
Signed-off-by: anmolbabu <anmolbudugutta@gmail.com>