* Fix potential unit tests failures caused by envconfig relying on the system env by default
See https://github.com/sethvargo/go-envconfig#testing for more details.
* Document functions in the 'config' package
* Add support for devfile volume
* Add unit test
* Use same naming strategy as for cluster
* Apply suggestions from code review
Co-authored-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Parthvi Vala <pvala@redhat.com>
* Add utility functions allowing to report files generated by odo
The end goal is for 'odo delete component --files' to gather a list of
files that were initially generated by odo, so as to delete only those.
This way, we are less likely to delete the wrong files.
This list is collected in a '.odo/generated' file.
It will then be up to odo commands to call those methods
accordingly. For example, this is called:
- by odo init, odo dev, or odo deploy, when generating a new devfile.yaml
- by odo dev, when there is no .gitignore file and odo generated one
Note that it is quite impossible to cover all scenarios; for example,
if odo generates a new devfile.yaml file, but the user deletes it
manually and recreates it, 'odo delete component --files'
will still list it as a possible candidate for deletion
(because it would be listed in .odo/generated).
* Report files generated by commands like init, dev or deploy
* Implement 'odo delete component --files'
* Add integration tests for 'odo delete component --files'
* Document the `--files` flag
Co-authored-by: Philippe Martin <contact@elol.fr>
* Do not delete the .gitignore file
It is more likely to be modified by the user afterward (for another
usage).
Co-authored-by: Philippe Martin <phmartin@redhat.com>
* fixup! Document the `--files` flag
* fixup! Implement 'odo delete component --files'
* Apply review suggestions on integration tests
Co-authored-by: Parthvi Vala <pvala@redhat.com>
* fixup! fixup! Document the `--files` flag
Co-authored-by: Philippe Martin <contact@elol.fr>
Co-authored-by: Philippe Martin <phmartin@redhat.com>
Co-authored-by: Parthvi Vala <pvala@redhat.com>
* Go: Bump github.com/mattn/go-colorable from 0.1.9 to 0.1.13
Bumps [github.com/mattn/go-colorable](https://github.com/mattn/go-colorable) from 0.1.9 to 0.1.13.
- [Release notes](https://github.com/mattn/go-colorable/releases)
- [Commits](https://github.com/mattn/go-colorable/compare/v0.1.9...v0.1.13)
---
updated-dependencies:
- dependency-name: github.com/mattn/go-colorable
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com>
* Compare slices regardless of order in 'TestGetKubernetesComponentsToPush'
'GetKubernetesComponentsToPush' internally iterates over a map to return
the resulting slice, but the iteration order of a Map in Go is not guaranteed.
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
* Run build-images command without cluster
* Test odo remove binding without cluster
* Make odo describe component work without cluster
* Tests: configure cluster depending on nocluster label
* Make odo list component work when --namespace is not used
* Test odo list component before deployment without cluster
* Some Generic tests
* Unset KUBERNETES_SERVICE_HOST to disable in-cluster config
* Set KUBECONFIG to empty file for no-cluster tests
* Run no-cluster tests on Windows
* Fix ListIngresses related changes
* Add warning/error when no cluster connection is available
* Add runOn flag
* Instantiate Kube/Podman DevClient instance according to runOn flag
* Start and stop Podman Pod
* Unit tests for createPodFromComponent
* podman mode runs without Kube config
* Fix tests + rebase
* Add sync and exec clients to podman dev
* tbc: call sync
* Remove unnecessary kclient dependency from exec client
* Inject podman client
* Implement ExecCMDInContainer for podman client
* Move [gG]etFirstContainerWithSourceVolume to dev/common package and use it for Podman
* TBC: execute build/run commands
* Fix rebase
* Fix unit test
* Comments for refacto
* Prepare implementation of Platform
* Use ExecuteRunCommand for run handler
* Do not pass parameters present in context
* Move back instanciation of devclient to clientset package
* Move CleanupDevResources method from Watch to Dev package
* CleanupResources: Do not pass parameters present in context
* Fix deleting volumes at exit time
* Check volumes do not exist
* Add support for postStart event
* Make odo dev work when no cluster is configured
* Review
* Add more TODOs
* User interface
* More info on ExitError errors
* Display forwarded ports in output and devstate file
* Add tests for forwarded ports
* Create .odo when necessary
* Add keyboard commands message
* Add doc on podman platform
* Remove Dharmit from OWNERS files across the repo
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* Remove Dharmit and Charlie from OWNERS
* Adds Tomas to owners
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* Add integration test
* odo dev deletes remote resources not present in the Devfile
* Delete the servicebinding secret without SBO
* Fix integration tests failure for when SBO is installed
* code Refactor
* Refactor the code
* Fix components_test.go
* add todos to integration tests
* Code review from feloy
* Move secret removal out of UnbindWithLibrary; rename deleteServiceBindingSecrets; add spinner end defer
* Attempt at making resource deletion concurrent
* Temp changes
* temp change
* Use errgroup wg to handle go routines
* Use single spinner for all the resources
* Fix validation failures
* Temp changes
* Optimize the code
* Optimize error messages; remove the unnecessary use of 'Kubernetes'
* List routes/ingresses deployed by odo in the describe output
* Remove ListDyanmicResourcesFromSelector and use ListDyanmicResources instead by add a selector argument to it
Signed-off-by: Parthvi Vala <pvala@redhat.com>
* Update pkg/api/component.go
Co-authored-by: Armel Soro <armel@rm3l.org>
* Replace DyanmicClient for ingress with a kubeclient
* Show ing/route name if *.hosts is empty
* Change API format
* Ignore owned ing/routes
* Add devfile with default backend ingress
* Add tests for named describe command
* mock kclient
* Fix integration test failure
* Fix integration test failure with registry
* Add test for ingress with default backend
* Add unit test for ListRoutesAndIngresses
* Add documentation
* Fix circular dependency and test failures
* Update upstream docs
* Fix integration test and add unit test for owner reference
* DRY the unit test code
* Update pkg/component/component.go
Co-authored-by: Philippe Martin <contact@elol.fr>
* Use context to obtain app
* rm3l's review
Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <armel@rm3l.org>
Co-authored-by: Philippe Martin <contact@elol.fr>
* Adds ability to list namespaces in JSON format
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* Tests without Expect
Using `Expect` directly or through something that uses it under the hood
is a problem when using `Eventually`. In normal case, a failure in
matching test condition behaves like `continue` and `Evnetually` keeps
trying again till timeout is reached. But `Expect` changes that
behaviour to be like `break` and doesn't keep testing repeatedly as we
would like it to.
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* UI fixes when there's no project on cluster
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* Adds an import to fix unit tests
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* More JSON specific checks
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* Consistent JSON output for namespaces
JSON output for components, bindings and services when odo can't find
any of these resources is simply a `{}`. This commit makes output of
`odo list namespaces -o json` consistent with that of these commands.
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* Add doc for namespaces JSON output
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* Test if some other namespace is marked as active: false
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* Define central config
* Use envConfig in GenericRun for segment parameters
* Pass the env config into the context passed to CLI methods
* Use PodmanCmd and DockerCmd from context
* Remove tests now that ODO_DISABLE_TELEMETRY is checked for a bool value
* deploy.Deploy: Use values from ctx instead of parameters + use FS from DI
* dev.Start: Use values from ctx instead of parameters
* image.Build*: Use values from ctx instead of parameters
* Use telemetry file from context
* Pass ctx to segment.getTelemetryForDevfileRegistry
* Use ctx in getTelemetryForDevfileRegistry
* Call IsTelemetryEnabled once and use scontext.GetTelemetryStatus after
* Fix unit tests
* Use envConfig in segment.IsTelemetryEnabled
* Define TelemetryCaller constant in test helper
* IsTrackingConsentEnabled: get value from envconfig instead of env
* Use ctx instead of GLOBALODOCONFIG
* Place ODO_EXPERIMENTAL_MODE in configuration
* Use maintained envconfig package
* Define default values when exist
* Document accepted boolean values
* fix to prioritize newly added registry
Signed-off-by: anandrkskd <anandrkskd@gmail.com>
* update RegistryList func to reverse the list and return []Registry
Signed-off-by: anandrkskd <anandrkskd@gmail.com>
* update the usage of RegistryList
Signed-off-by: anandrkskd <anandrkskd@gmail.com>
* update unit test and mock
Signed-off-by: anandrkskd <anandrkskd@gmail.com>
* fix: lint error and check for empty registry list
Signed-off-by: anandrkskd <anandrkskd@gmail.com>
* add documentation
Signed-off-by: anandrkskd <anandrkskd@gmail.com>
Signed-off-by: anandrkskd <anandrkskd@gmail.com>
* Add test cases highlighting the issue
* Sanitize value for 'app.openshift.io/runtime' label
* Lowercase value of 'app.openshift.io/runtime' label after sanitization
As suggested in review, this is to follow what's done by OpenShift console;
it is always lowercase when added by OpenShift Console.
Co-authored-by: Tomas Kral <tkral@redhat.com>
Co-authored-by: Tomas Kral <tkral@redhat.com>
* Add support for an experimental mode at the CLI level
This is backed by an "ODO_EXPERIMENTAL_MODE" environment variable.
* Mark the generic '--run-on' flag as experimental
Besides being hidden, it will error out as invalid flag
if the ODO_EXPERIMENTAL_MODE env var is not set to 'true'.
* Add integration test cases
* Document the experimental mode.
* fixup! Add support for an experimental mode at the CLI level
* fixup! Mark the generic '--run-on' flag as experimental
* Update odo to use go 1.18
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* Update golangci-lint version in Makefile
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* Use go 1.18, not go 1.19
Erroneously I had used go 1.19 at various places.
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* Rearrange imports; fix golangci-lint errors
Fixed a bunch of golangci-lint errors like below:
`File is not `gofmt`-ed with `-s``
using the command: `golangci-lint run --fix`
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* Use go install instead of go get
This is because with go 1.18, `go get` behaves as `go get -d` by
default. Which means that it will only download, but not install.
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
* resolve inconsistent order of registries in preference view
Signed-off-by: anandrkskd <anandrkskd@gmail.com>
* reverse regList on business layer
Signed-off-by: anandrkskd <anandrkskd@gmail.com>
* update unit test, add functional test and small refactor
Signed-off-by: anandrkskd <anandrkskd@gmail.com>
* update functional tests to use proxy
Signed-off-by: anandrkskd <anandrkskd@gmail.com>
Signed-off-by: anandrkskd <anandrkskd@gmail.com>
* Panic if platform for Exec is not supported yet
This will make the error more visible,
instead of hiding it.
* Use a consistent receiver name in 'pkg/kclient.Client#DeploymentWatcher'
* Make 'pkg/logs/LogsClient' rely on the generic 'platform.Client'
Co-authored-by: Philippe Martin <phmartin@redhat.com>
* Make 'pkg/component#Log' function rely on the generic 'platform.Client'
Co-authored-by: Philippe Martin <phmartin@redhat.com>
* Make the 'execHandler' in 'pkg/component' rely on the generic 'platform.Client'
Co-authored-by: Philippe Martin <phmartin@redhat.com>
* Move 'matchOwnerReferenceWithResources' unit tests from 'pkg/logs' to 'pkg/kclient'
Those tests are specific to the Kubernetes implementation.
Co-authored-by: Philippe Martin <phmartin@redhat.com>
* Add support for ODO_TRACKING_CONSENT env variable
Co-authored-by: Armel Soro <asoro@redhat.com>
* Replace deprecated 'ODO_DISABLE_TELEMETRY' env var with 'ODO_TRACKING_CONSENT' in integration tests
* Log environment of process launched with 'helper_run' in integration tests
`odo` behavior might be altered based on certain environment variables.
So this is to help debug future issues that might happen.
Because the process environment also contains the
current OS environment, we purposely limit the content
to variables prefixed with 'ODO_' or particular ones
(like 'TELEMETRY_CALLER').
* Test conflicting situations when using both 'ODO_DISABLE_TELEMETRY' and 'ODO_TRACKING_CONSENT'
* Disable golangci-lint 'staticcheck' check about using the deprecated 'segment.DisableTelemetryEnv'
However, due to [1], line-based directives do not seem to be working.
* Make ODO_TRACKING_CONSENT env var take precedence over the ConsentTelemetry preference
See [1] for more context.
[1] https://github.com/redhat-developer/odo/pull/6258\#issuecomment-1293736398
* Add new 'segment#isTrackingConsentEnabled' function, as suggested in review
This would make it easier to rename the values if needed or add aliases later.
* Add more unit test cases, especially when any of the telemetry var is not there in the env
* Document ODO_TRACKING_CONSENT
* fixup! Add new 'segment#isTrackingConsentEnabled' function, as suggested in review
* fixup! fixup! Add new 'segment#isTrackingConsentEnabled' function, as suggested in review
Co-authored-by: Tomas Kral <tkral@redhat.com>
For some reason, this happened with NodeJS starter projects for example,
where killing the parent pid for the application ('npm start')
would not stop the underlying 'node' process, causing the application
port to still being used.
Given the following process tree for the Node.JS application:
```
default 49 0.0 0.0 11924 2828 ? Ss 20:23 0:00 /bin/sh -c echo $$ > /opt/odo/.odo_cmd_run.pid && cd ${PROJECT_SOURCE} && (npm start) 1>>/proc/1/fd/1 2>>/proc/1/fd/2; echo $? >> /opt/odo/.odo_cmd_run.pid
default 55 1.0 0.0 735940 62956 ? Sl 20:23 0:00 \_npm start
default 66 0.0 0.0 11928 2760 ? S 20:23 0:00 \_ sh /tmp/start-c40b5918.sh
default 67 0.5 0.0 624368 49772 ? Sl 20:23 0:00 \_ node server.js
```
We were previously just killing the direct process (pid 55 here),
and it used to also stop all its descendents. This appears to no longer
be the case.
So to make sure the application is stopped correctly,
we are now making sure to traverse the full parent-child tree
using a post-order strategy, to start killing children processes first.
So in the example above, we would start killing pids 67, 66 and 55 in
this order.
* Remove non existing --project flag
* do not set the namespace as it is already the set one
* Use ctx to pass namespace
* Remove KClient from old context
* Pass appname through Context
* Remove unnecessary ctx builders
* Remove unused LocalConfigProvider from old context
* Move DevfileObj outside of Context EnvSpecificInfo
* Move DevfilePath outside of Context EnvSpecificInfoD
* Remove unused componentContext from old context
* Remove context flag
* Pre-run Init in a generic way
* Pass working directory in context
* Get Devfile and pass it in ctx, and use it for odo dev
* add binding: use new context
* build-images: use new context
* create namespace: use new context
* list namespace: use new context
* set namespace: use new context
* delete namespace: use new context
* delete component: use new context
* deploy: use new context
* describe binding: use new context
* list binding: use new context
* remove binding: use new context
* describe component: use new context
* list component: use new context
* list: use new context
* list services: use new context
* logout: use new context
* logs: use new context
* Remove old context code
* Some refactoring to avoid passing ctx when building it
to avoid complex dependency management during this building
* More doc on context.Get* functions
* Add integration test cases highlighting the acceptance criteria
* Set the caller property for telemetry based on the 'TELEMETRY_CALLER' env var
Note that this property is set in telemetry even if it is not in the set
of allowed values, but does not prevent the odo command from running.
* Update documentation
* Centralize code about o flag into commonflags pkg
* Add generic --run-on flag
* Pass ctx to Complete and Validate
* Pass value of -o in ctx
* Pass value of --run-on in ctx
* Add unit tests
* Fix functions names
* Remove kclient from interface / signatures
* Create Exec package
* Call ExecuteCommand with client
* Call ExecuteCommand with client from sync package
* Fix order of dependencies
* Move Dev Handler to specific file
* Do not pass unnecessary namespace to Dev package
* Pass FS with dependency injection
* Merge Dev.Start and Dev.Watch
* Simplify Handler
* Move Dev Handler inside the Dev package
* Update mock
* Review