Commit Graph

1779 Commits

Author SHA1 Message Date
Armel Soro
a4ee0e4cea Fix potential port conflict issue with the API server tests by using a random server port if --random-ports is set (#6995)
* Let the OS assign a random ephemeral port if `--random-ports` is specified when running `odo dev` or `odo api-server`

This should hopefully fix the potential port conflict flaky
issue we are seeing, especially on Windows.

* Do not allow setting `--random-ports` and a specific port value

This applies to:
- `odo dev --random-ports --api-server --api-server-port=<port>`
- `odo api-server --random-ports --port=<port>`
2023-07-21 09:52:24 +02:00
Philippe Martin
159ca02b89 Add UI telemetry (#6981)
* Load Segment module

* First events

* Add GET /telemetry epoint to API

* Init telemetry with data from API

* Add more tracking

* Update ui static files

* Send telemetry for tab changes

* Update UI static files

* Set IP to 0.0.0.0

* Update UI static files
2023-07-19 18:20:18 +02:00
Armel Soro
8c9bcdeb1f Propagate local Devfile changes to the UI (#6970)
* Add '/notifications' endpoint for subscribing to server-sent events

* Generate server and client

* Try implementing the notification service endpoint

* Revert "Try implementing the notification service endpoint"

This does not seem to work because the generated server always responds
with application/json, and it is not possible to respond with a
different content-type.

This reverts commit cf3ce83677649763b8166c4847501c37246dd757.

* Revert "Generate server and client"

This reverts commit b985c007a0561edbe185adc3b9582e12aa3f072b.

* Revert "Add '/notifications' endpoint for subscribing to server-sent events"

This reverts commit c5c903329f13dbe4ec096d83b1c8624fd622bef3.

* Implement 'GET /notifications' SSE endpoint and logic to detect and notify Devfile changes

* Leverage EventSource to subscribe to Server Sent Events

Here, this is being used to automatically reload the Devfile in the YAML view
whenever the API server notifies of filesystem changes in the Devfile
(and related resources).

* Add Preference Client to apiserver CLI

This is needed to be able to persist Devfiles from the UI to the filesystem

* Add E2E test case

* fixup! Leverage EventSource to subscribe to Server Sent Events

Co-authored-by: Philippe Martin <phmartin@redhat.com>

* Limit the round-trips by sending the whole Devfile content in the DevfileUpdated event data

Co-authored-by: Philippe Martin <phmartin@redhat.com>

* [Cypress] Make sure to wait for APi responses after visiting the home page

Co-authored-by: Philippe Martin <phmartin@redhat.com>

* Generate static UI

* fixup! [Cypress] Make sure to wait for APi responses after visiting the home page

---------

Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-07-18 17:02:12 +02:00
Armel Soro
6e725952bd Display information about the running API Server and web UI in odo describe component output (#6964)
* refactor: Set the experimental mode env var in a single place for the '--api-server' related tests

* Add integration tests highlighting the expectations

* Make the state client return the API server ports per platform

'odo dev' might be running on both cluster and podman,
so we might end up with several API servers.

* Make 'odo describe component' return information about the API Server and web UI

This is viewable only when running 'odo describe component'
with the experimental mode enabled.

* fixup! refactor: Set the experimental mode env var in a single place for the '--api-server' related tests

* Unit-test describe#filterByPlatform logic

* Simplify logic for 'describe#filterByPlatform', as suggested in review

Co-authored-by: Philippe Martin <phmartin@redhat.com>

---------

Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-07-18 16:31:14 +02:00
Philippe Martin
53cb806a65 Add Preference dependency to api-server command (#6974) 2023-07-18 14:44:17 +02:00
Armel Soro
9fd65cd27d Generate static UI files from within a container (#6972)
* Generate static UI files from within a container, for more predictability

For some reason, Angular was not generating the same hash
for the `runtime*.js` file (even with the same content),
causing the 'check-ui-static-files' job to sometimes fail.

Leveraging a container (as we are already doing for the
'generate-apiserver' and 'generate-apifront' tasks)
should allow for more predictable output.

Co-authored-by: Philippe Martin <phmartin@redhat.com>

* Generate static UI

---------

Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-07-18 08:21:50 +02:00
Armel Soro
abdb1c568d Update go.mod with new location of the Alizer library (#6962)
* Update 'go.mod' with new location of the Alizer library

* Downgrade and pin conflicting versions of 'github.com/docker/{cli,distributions}'

Pinning it to the version we had before.
Otherwise, there were issues when running 'go mod tidy':

```
$ go mod tidy
go: downloading github.com/operator-framework/api v0.17.6
go: finding module for package github.com/docker/docker/pkg/term
github.com/redhat-developer/odo/pkg/auth imports
        github.com/openshift/oc/pkg/cli/login imports
                github.com/openshift/oc/pkg/helpers/term imports
                        github.com/docker/docker/pkg/term: module
                        github.com/docker/docker@latest found
                        (v24.0.4+incompatible), but does not contain
                        package github.com/docker/docker/pkg/term

```

* Fix expected output in quickstart guides doc automation tests
2023-07-17 12:57:31 +02:00
Parthvi Vala
abc808bdec Fix oc to odo project translation (#6949)
* Fix oc to odo project translation

Signed-off-by: Parthvi <parthvi.vala@gmail.com>

* Attempt at fixing regression

Signed-off-by: Parthvi <parthvi.vala@gmail.com>

* Add unit test for filteredInformation

Signed-off-by: Parthvi <parthvi.vala@gmail.com>

* Use oc command instead of odo

Signed-off-by: Parthvi <parthvi.vala@gmail.com>
Co-authored-by: Armel Soro <asoro@redhat.com>

---------

Signed-off-by: Parthvi <parthvi.vala@gmail.com>
Co-authored-by: Parthvi Vala <pvala@localhost.localdomain>
Co-authored-by: Armel Soro <asoro@redhat.com>
2023-07-17 12:38:36 +02:00
Armel Soro
5bf6a92a89 Support Architectures in odo registry (#6959)
* Display the supported architectures in `odo registry` output

* Allow filtering by architectures

* Update documentation accordingly

* Add test cases

* fixup! Update documentation accordingly

* fixup! Allow filtering by architectures

Devfiles with no architecture declared are supposed to be compatible
with all known architectures.

Co-authored-by: Philippe Martin <phmartin@redhat.com>

* fixup! Add test cases

---------

Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-07-07 12:57:52 -04:00
Philippe Martin
9624721ed3 odo dev --logs (#6957)
* Move logic to pkg/logs

* Fix Ctrl-c

* odo dev --logs

* Add integration test
2023-07-07 10:58:56 -04:00
Philippe Martin
ebe003ede0 Serve UI from api server (#6954)
* Serve UI from api server

* Build UI static files + check generation with GHAction

* Update UI static files

* Use specific commit for verify-changed-files action

* Add pkg/apiserver-impl/ui to .gitattributes

* Ignore pkg/apiserver-impl/ui/** for sonar
2023-07-07 07:07:14 -04:00
Philippe Martin
2c3d2ea0b1 Add /devfile PUT and GET endpoints (#6950)
* Serve /devfile

* Implement /devfile endpoints

* Load/Save devfile from UI

* Required metadata fields in the response

* Add an Apply button on 1st tab

* Fix: validate new devfile, not previous one

* Add generated UI files to gitattributes file

* Fix rebase
2023-07-06 12:30:48 -04:00
Armel Soro
c4b103d9c4 Add new --run-port flag to odo init to set ports non-interactively (#6953)
* Add new `--run-port` flag to `odo init` to set ports non-interactively

As depicted in [1], this leverages the default (or single non-default) run command to find the linked container component.
As such, it assumes that the command found is an exec command,
and that the linked component is a container component.

[1] https://github.com/redhat-developer/odo/issues/6925

* Add unit and integration tests highlighting the expectations

* Document the new `--run-port` flag

* Fix some typos and language correctness issues in the `odo init` doc

* Add doc automation test for the output of `odo init --run-port`

This ensures the output and sample in the doc are kept in sync with the code base.
2023-07-06 10:35:24 -04:00
Philippe Martin
f6bb4e2689 Implement odo api-server command (#6952)
* Implement odo api-server command

* Make api-server an experimental mode command

* Add --api-server-port flag

* Support DELETE /instance

* Review
2023-07-06 10:03:15 -04:00
Parthvi Vala
5911930a11 [UX] Fix default value of ImageRegistry in odo preference view output (#6951)
* [UX] Fix default value of ImageRegistry in odo preference view output

Signed-off-by: Parthvi <parthvi.vala@gmail.com>

* Update pkg/preference/machine_output.go

Co-authored-by: Armel Soro <armel@rm3l.org>

---------

Signed-off-by: Parthvi <parthvi.vala@gmail.com>
Co-authored-by: Armel Soro <armel@rm3l.org>
2023-07-05 15:32:15 -04:00
Philippe Martin
649181c1dc Implement devfile state in odo api (#6941)
* POST /devstate/container

* Implement POST /devstate/container

* Generate DELETE /devstate/container/{containerName}

* Implement DELETE /devstate/container/{containerName}

* Serve /devstate/image

* Implement /devstate/image

* Serve /devstate/resource

* Implement /devstate/resource

* Move Components specific code to components.go

* Serve /devstate/*command

* Implement /devstate/*command

* Serve /devstate/metadata

* Implement /devstate/metadata

* Serve devstate/chart

* Implement /devstate/chart

* Create a DevfileContent schema reference

* Use `DELETE /command/{name}` instead of `DELETE /*Command/{name}`

* Serve /devstate/command/move

* Implement /devstate/command/move

* Serve /devstate/command/{name}/[un]setDefault

* Implement /devstate/command/{name}/[un]setDefault

* serve /devstate/events

* Implement /devstate/events

* Serve /devstate/quantityValid

* Implement /devstate/quantityValid

* Add json tag to API result value

* Sets a proxy for the API

* Move calls from wasm to api (first part)

* Implement PUT /devsatte/devfile

* Move calls from wasm to api (end)

* Implement GET /devstate/devfile

* Implement DELETE /devstate/devfile

* At startup, get devfile from api, not from localStorage

* Rename service wasmGo -> devstate

* Remove wasm module

* Update to latest devfile-lifecycle version, license compatible

* Apply suggestions from code review

Co-authored-by: Armel Soro <armel@rm3l.org>

* Remove wasm from ui/{Makefile/devfile.yaml}

* Define DevfileContent into apispec

* Define required fields

* Generate API models from front

* Regenerate API server after spec changes

* Fix examples case

* Fix github action e2e tests not running

* Make target for all generated api code

---------

Co-authored-by: Armel Soro <armel@rm3l.org>
2023-07-05 05:19:29 -04:00
Armel Soro
4479c24dfe Display list of commands from the local devfile in odo describe component output (#6944)
* Add integration tests highlighting the expectations

* Add and fill a 'Commands' field from the DevfileData struct returned by `describe`

* Display commands in the human-readable output of 'odo describe'

* Add documentation and sample outputs
2023-07-03 10:19:06 -04:00
Philippe Martin
f276d0d77b Watch for new pods when logs --follow (#6914)
* Watch for new pods when logs --follow

* Fix integration tests

* Implement --follow for podman platform

* Add integration test
2023-06-28 14:21:04 +02:00
Philippe Martin
c8a1414926 Document and return JSON data for API errors (#6938) 2023-06-28 13:20:05 +02:00
Armel Soro
c0127ce201 Bump version to 3.12.0 (#6935) 2023-06-27 18:07:21 +02:00
Parthvi Vala
3bf5ffc369 List namespace right after namespace has been created (#6922)
* List namespace right after namespace has been created

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add sleep after listing namespaces

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Error out when timeout is reached

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Modify spinner messages

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Attempt at fixing doc tests

Signed-off-by: Parthvi Vala <pvala@redhat.com>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
2023-06-27 16:02:54 +02:00
Philippe Martin
94e32303bd Implement API endpoints (#6915)
* Pass odo context to api server

* Get /instance

* DELETE /instance implementation

* Move describe logic to pkg/component/describe

* Get /component implementation

* POST /component/command implementation

* Fix example by replacing action with name

* Fix integration test

* Integration tests

* Add comment for PushWatcher

* Test DELETE /instance without --no-watch

* Apply suggestions from code review

Co-authored-by: Armel Soro <armel@rm3l.org>

* Return an error if not ready for push

* Fix windows tests

* Fix tests for Windows

---------

Co-authored-by: Armel Soro <armel@rm3l.org>
2023-06-26 16:00:49 +02:00
Parthvi Vala
2bafd31b6c Add podman version to odo version output (#6913)
* Show podman version in odo version; TODO: fix test and implement json

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add integration test

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add support for JSON

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add documentation

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Fix missing OpenShift version

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add warnings when unable to fetch version information

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Do not print warning when --client is used and review

Signed-off-by: Parthvi Vala <pvala@redhat.com>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
2023-06-24 22:46:37 +02:00
Armel Soro
147542db69 Do not necessarily error out if odo dev is stopped via Ctrl+C (#6917)
* Add test highlighting the expectations

* Propagate errors and call os.Exit only in 'main' functions

See ExitInMain[1] and ExitInMain_ExitOnce[2] coding convention guidelines.

[1] https://github.com/redhat-developer/odo/wiki/Dev:-Coding-Conventions#exit-in-main
[2] https://github.com/redhat-developer/odo/wiki/Dev:-Coding-Conventions#exit-once

* Handle errors returned by Cleanuper#Cleanup

This makes sure the exit code of the command
is mapped onto any error returned by Cleanup

* Do not return an error when the watch loop in 'odo dev' is interrupted

* Test that the exit code of 'odo dev' matches the error returned by the cleanup logic
2023-06-22 13:14:07 +02:00
Armel Soro
28ed064133 Do not return an error in odo analyze if current directory contains an invalid Devfile (#6905)
* Add unit test highliging the issue

* Fix 'delete' unit tests

* Pass the filesystem object where it is relevant

* Add a way for CLI commands to indicate whether of not they require a valid Devfile

For the 'analyze' command, this is not required,
so Devfile parsing will be ignored completely.

* Make the fake filesystem return an absolute current dir

Otherwise, some code will assume it is relative,
and try to prepend the current physical directory
2023-06-22 10:06:18 +02:00
Philippe Martin
a29253521c Replace odo delete component integration with unit tests (#6904) 2023-06-21 17:43:03 +02:00
Philippe Martin
50ba3868a6 Add --sync-git-dir flag to odo dev (#6910)
* Indexer does not ignore .git

* add --sync-git-dir flag to odo dev

* Integration tests

* Add doc

* Force sync of complete .git content
2023-06-20 10:26:14 -04:00
Parthvi Vala
0b012f30e5 Implement HTTP Server based on OpenAPI spec (#6835)
* Implement HTTP Server based on OpenAPI spec

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
Co-authored-by: Philippe Martin <phmartin@redhat.com>

* Starter server when odo dev starts

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add --api-server and --api-server-port flags to start API Server; write the port to stat file; TODO: make this feature experimental

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
Co-authored-by: Philippe Martin <phmartin@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>

Make the flag experimental

Signed-off-by: Parthvi Vala <pvala@redhat.com>

Make apiserver and apiserverport flag local

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Use container image to run openapi-generator-tool instead of a local CLI

Co-authored-by: Armel Soro <asoro@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add integration test

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Use label podman

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Regenerate the api files with openapitool v6.6.0 and changes from review

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-06-19 10:29:36 -04:00
Armel Soro
63c8e27e2a Implement odo dev --no-commands (#6855)
* Document the '--no-commands' flag

Co-authored-by: Philippe Martin <phmartin@redhat.com>

* Add integration tests highlighting the expectations

* Add '--no-commands' flag to the 'dev' sub-command

* Implement '--no-command' on Podman

* Implement '--no-command' on cluster

* Validate the '--no-commands' flag in the CLI

For example, it should not be possible to call it alongside '--build-command' or '--run-command',
because we won't be able to know what to do.

* Fix 'odo dev' tests when the run/debug does not exist

For consistency with how e.g., the build command works,
instead of erroring out, `odo dev` will
now simply log the error message and wait for new input.

* Check for command existence when we want to run them

As suggested in review, this makes it more adaptable.
As a consequence, if the default (or single) build/run command does not exist,
"odo dev" will not error out immediately; instead, it will behave a bit like
"odo dev --no-commands" (by starting, but printing a warning about the
missing command).
The difference here is that if a run command is added later on
during the dev session, "odo dev" will pick it up and run it,
but "odo dev --no-commands" will continue to purposely ignore it.

The existence of the optional default Build is already checked
by the 'libdevfile.Build' command. It does not error out if there is
no default (or single) Build command. It errors out only if the specified
'--build-command' does not exist in the Devfile.

Co-authored-by: Philippe Martin <phmartin@redhat.com>

* Check for application ports only if the Devfile has run or debug command and if there are ports to forward

This prevents:
i) displaying the "Waiting for the application to be ready" spinner for nothing,
  if there are no ports to forward
ii) waiting until the timeout of 1m has expired if there was no run/debug command executed,
  in which case, it is less unlikely that the application ports defined in the Devfile
  will ever be reachable.

* Test "odo run" command against a Dev Session started with and without "--no-commands"

---------

Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-06-14 09:28:06 -04:00
Philippe Martin
aabbded7e1 Unit tests/inject test clientset (#6874)
* Inject testClientset

* Test analyze CLI as unit test

* Replace odo analyze integration tests with unit tests
2023-06-13 13:16:31 -04:00
Philippe Martin
6bc30110ba Display outputs when executing odo run (#6865)
* Change NewRunHandler params with Options

* Pass an options to RunHandler to show logs

* Hide spinner and std output since outputs are displayed

* Integration tests with failing command

* Fix outputs

* use raw terminal and local standard i/o streams

* Fix podman i/o

* Fix stdout/err

* Test if in/out are terminal

* command reference doc
2023-06-12 10:45:31 -04:00
Philippe Martin
330b724753 Add an odo run command to manually execute command during odo dev (#6857)
* Add a run command

* Check command name passed as arg

* Check platform is available

* Add a Run method to the DevClient

* Run command on cluster

* Add test with run command on cluster

* Implement and test run on podman

* Enhance test to check that command has been executed in container

* Fix `odo help` test

* Refactor common code for podman/cluster

* Test Apply commands on Kubernetes/Images

* Test  a msg is displayed when executing odo run without odo dev

* Review

* makes GetRunningPodFromSelector return only Running pods on Podman
2023-06-02 09:33:21 -04:00
Armel Soro
b6c9c88245 Make sure the "Syncing files into the container" spinner is displayed on Podman (#6863)
* Check that the "Syncing files into the container" spinner is correctly displayed on both Podman and cluster

* Add missing "Syncing files into the container" spinner when running 'odo dev' on Podman

This indicates to the user that we are sync'ing the files,
which might be a potentially long operation.
This is to be consistent with the output when using 'odo dev' on cluster.
2023-06-02 05:13:13 -04:00
Philippe Martin
b481d4c410 Bump version 3.11.0 (#6852)
* Bump to version 3.11.0

* Update docs with v3.11.0
2023-05-30 07:26:48 -04:00
Armel Soro
a79c953e7a Track preference options usage (#6843)
* Add integration test highlighting the expectations

* Record parameter (and value) set or unset using the 'odo preference set/unset' commands

By default, values are anonymized.
Only parameters explicitly declared list will be recorded verbatim.
This list is currently empty, but that might change later on.

* Mark all current preference parameters except ImageRegistry as clear-text

Co-authored-by: Philippe Martin <phmartin@redhat.com>

---------

Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-05-30 05:02:02 -04:00
Armel Soro
85b4ff92e8 Make sure event is recorded whenever telemetry preference is changed (#6842)
* Add integration test highlighting the expectations

* Use the cancellable context derived from 'cmd.Context' where needed

* Introduce new 'wasTelemetryEnabled' telemetry property

This is recorded before any command is run.
And it will help determine if telemetry was
changed (e.g., from enabled to disabled),
so that we can record the event in this case.

* Send telemetry if it was enabled previously or if it is currently enabled

This is done by reading the actual telemetry setting
(either from env vars or the preferences file)
at the moment we want to record the telemetry event.
This covers cases where a command ('odo preference set ConsentTelemetry')
or an environment variable ('ODO_TRACKING_CONSENT')
updated the telemetry consent for example.
2023-05-26 11:25:24 -04:00
Philippe Martin
9a239c4e77 Use a single handler for executing all commands (#6826)
* Document current implementations of command handlers

* Add unit tests for execHAndler

* Refactor pkg/devfile/image to inject Backend as dependency

* Use same handler for kubedev/podmandev

* Fail after SelectBackend==nil only if backend is needed

* Move runHandler to dev/common

* Unit tests for runHandler

* Create a component.ExecuteTerminatingCommand

* ExecuteTerminatingCommand/ExecuteNonTerminatingCommand for Handler

* Fix calling other command types

* Consider parent group to determine if a command is terminating

* Replace component.execHandler by common.runHandler

* Remove execHandler

* Make runHandler and most of fields private and pass containersRunning to handler

* Pass containersRunning value

* deploy using common Handler

* Fix tests

* Use specific Dev/Deploy mode for Apply

* Fix cmdline for job

* Fix unit tests

* Pass appName and componentName with ctx to handler

* Move handler to pkg/component package

* Update doc

* Unit tests Deploy

* Unit tests Build

* Unit tests Run

* Unit tests PostStart

* Unit tests PreStop

* Update doc

* Fix Podman tests

* Fix hotReload on podman

* Change podman version timeout to 30s for tests

* Cleanup + fix doc
2023-05-26 11:01:21 -04:00
Parthvi Vala
e9077be4d6 Fix issues with describe/list binding tests (#6839)
* Fix issues with describe/list binding tests

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>

* Attempt at fixing human readable failure

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Fix bug with odo list --namespace while fetching binding information

Signed-off-by: Parthvi Vala <pvala@redhat.com>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
2023-05-26 07:51:47 -04:00
Armel Soro
dcf9009df4 Do not error out in port detection if any of the /proc/net/{tc,ud}p{,6} files are missing in the dev container (#6831)
* Do  not error out in port detection if any of `/proc/net/{tc,ud}p{,6}` files are missing

/proc/net/{tc,ud}p6 files might be missing if IPv6 is disabled in the host networking stack,
as reported by a user on RHEL.

Actually /proc/net/{tc,ud}p* files might be totally missing if network stats are disabled.

* Do not error out if we are not able to detect container ports bound on the loopback interface

We are already displaying a warning in such case
(saying that port forwarding might not work correctly);
so this should not prevent port-forwarding messages to be displayed.

We are already behaving this way when detecting if endpoints in the Devfile
are actually opened in the container.
A warning is displayed if any error occurs while checking this.

* fixup! Do  not error out in port detection if any of `/proc/net/{tc,ud}p{,6}` files are missing
2023-05-23 09:36:39 -04:00
Armel Soro
ec747b4ab3 Allow using imageName as a selector (#6768)
* Add integration tests highlighting our expectations

* Bump Devfile library to latest commit

f041d79870

* Expose preference that allows users to globally configure an image registry

* Return the effective Devfile view by default from the initial context

This is supposed to be read-only, so that tools can rely on it
and to the operations they need to perform right away.

Raw Devfile objects can still be obtained upon request
if there is need to update them (for example via 'odo add/remove
binding' commands.

* Pass the image registry preference to the Devfile parser to build the effective view

* Fix 'odo init' integration tests

- The test spec was actually not doing what it was supposed to do
- Now 'odo init' returns a complete Devfile, where the parent is flattened,
  because the goal of 'odo init' is to bootstrap a Devfile.
  Previously, 'odo init' would not download the parent referenced,
  making it hard to understand the resulting Devfile.

* Document how odo now handles relative image names as selectors

* fixup! Document how odo now handles relative image names as selectors

Co-authored-by: Philippe Martin <phmartin@redhat.com>

* Revert "Fix 'odo init' integration tests"

This reverts commit 78868b03fd.

Co-authored-by: Philippe Martin <phmartin@redhat.com>

* Do not make `odo init` return an effective Devfile as a result

This would change the behavior of `odo init`.

Furthermore, due to an issue [1] in the Devfile library,
it is not possible to parse some Devfiles with parents linked as GitHub URLs (like GitHub release artifacts).

[1] https://github.com/devfile/api/issues/1119

Co-authored-by: Philippe Martin <phmartin@redhat.com>

* fixup! Document how odo now handles relative image names as selectors

---------

Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-05-22 10:45:27 -04:00
dependabot[bot]
50cb5c9b3b Go: Bump github.com/securego/gosec/v2 from 2.14.0 to 2.15.0 (#6686)
* Go: Bump github.com/securego/gosec/v2 from 2.14.0 to 2.15.0

Bumps [github.com/securego/gosec/v2](https://github.com/securego/gosec) from 2.14.0 to 2.15.0.
- [Release notes](https://github.com/securego/gosec/releases)
- [Changelog](https://github.com/securego/gosec/blob/master/.goreleaser.yml)
- [Commits](https://github.com/securego/gosec/compare/v2.14.0...v2.15.0)

---
updated-dependencies:
- dependency-name: github.com/securego/gosec/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Make sure to handle error returned by io.Closer.Close() in 'defer' statements

This is considered unsafe by gosec otherwise.

[1] https://github.com/securego/gosec/issues/512
[2] https://github.com/securego/gosec/issues/714
[3] https://www.joeshaw.org/dont-defer-close-on-writable-files/

---------

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>
2023-05-16 09:51:30 -04:00
Philippe Martin
67709ff895 Move parent devfiles in specific directories (#6818) 2023-05-16 03:29:07 -04:00
Parthvi Vala
a6da3e015a Add spinner when determining a devfile using alizer (#6793)
* Add spinner when determining a devfile using alizer and handle panic on odo dev

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Change HandleSignal signature, handle context cancellation in AlizerBackend Select Devfile

Co-authored-by: Philippe Martin <phmartin@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Fix spinner and terminate on terminal interrupt

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Fix validation errors

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Fix doc test error

Signed-off-by: Parthvi Vala <pvala@redhat.com>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Philippe Martin <phmartin@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
2023-05-16 03:10:33 -04:00
Parthvi Vala
0cdc2e5542 Fix: odo init overwrites personalized configuration when downloading starter project (#6800)
* Fix personalized configuration overwritten by starter project

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Update pkg/registry/registry_test.go

Co-authored-by: Armel Soro <armel@rm3l.org>
Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Adding intergration tests for personalizing configurations with odo init

Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>

Modified changes

Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>

Update tests/integration/interactive_init_test.go

Co-authored-by: Parthvi Vala <pvala@redhat.com>

Update tests/integration/interactive_init_test.go

Co-authored-by: Parthvi Vala <pvala@redhat.com>

Update interactive_init_test.go

Update interactive_init_test.go

Update interactive_init_test.go

Update tests/integration/interactive_init_test.go

Co-authored-by: Parthvi Vala <pvala@redhat.com>

Update interactive_init_test.go

* Updated changes

Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>

* Attempt at fixing interactive tests

Signed-off-by: Parthvi Vala <pvala@redhat.com>

* Add multiple devfile version check

Co-authored-by: Armel Soro <asoro@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Signed-off-by: Ritu Deshmukh <rideshmu@redhat.com>
Co-authored-by: Armel Soro <armel@rm3l.org>
Co-authored-by: Ritu Deshmukh <rideshmu@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
2023-05-11 16:06:49 -04:00
Armel Soro
c217741cc7 Add a timeout when initializing the Podman client (broken Podman should not affect odo dev on cluster) (#6808)
* Add test highlighting the issue and setting the expectations

* Add a timeout of 1s to the 'podman version' command

This command is called at dependency injection time to initialize a (nil-able) Podman client,
even if users won't use Podman at all.
As discussed, this command is supposed to be
quite fast to return, hence this timeout of 1 second.

Initially, we were using cmd.Output to get the command output,
but as reported in [1], cmd.Output does not respect the context timeout.
This explains the workaround of reading from both stdout and stderr pipes,
*and* relying on cmd.Wait() to close those pipes properly when the program exits
(either as expected or when the timeout is reached).

[1] https://github.com/golang/go/issues/57129

Co-authored-by: Philippe Martin <phmartin@redhat.com>

* Log the errors returned at dependency injection time when the optional Kubernetes/Podman clients could not be initialized

This helps debug such potential issues instead of swallowing the errors.

* Make the timeout configurable via the 'PODMAN_CMD_INIT_TIMEOUT' env var

This will allow setting a different value for environments like
in GitHub where the Podman client would take slightly more time to return
(I guess because of we are running a lot of Podman commands in parallel?).

* Increase the timeout for Podman tests to an arbitrary value of 10s

Some tests did not pass because the Podman client did not
initialize in 1s; I guess because we are running a lot of Podman commands in parallel?
This should hopefully improve this situation.

* fixup! Add a timeout of 1s to the 'podman version' command

---------

Co-authored-by: Philippe Martin <phmartin@redhat.com>
2023-05-11 15:34:34 -04:00
Philippe Martin
f491bcc7db Reuse same volumes when devfile is modified, on podman (#6810)
* Reuse same volumes when devfile is modified

* Fix doc /comment
2023-05-11 03:57:12 -04:00
Philippe Martin
da28e7d286 Delete previous pod and creates new ond when modifying devfile on podman (#6802)
* Delete previous pod and creates new ond when modifying devfile on podman

* Add integration tests
2023-05-10 06:45:19 -04:00
Vinu K
f1ccc5eb60 Check if namespace exists before the delete confirmation (#6233) 2023-05-06 12:53:40 -04:00
Philippe Martin
56d0b6f95e Fix HotReloadCapable Build command (#6696)
* On cluster, run Build command again only if Build command itself is not hotReloadCapable

* On Podman, execute Build command only if itself is not hotReloadcapable

* Handle hotReloadCapable in handler

* Add integration tests

* Update doc

* review
2023-05-04 10:20:21 -04:00
Armel Soro
6241a66129 Allow passing extra flags to Podman/Docker (#6785)
* Allow passing extra build flags to Podman/Docker

This is supported via 2 new env vars:
- ODO_IMAGE_BUILD_ARGS: passed when building images via Podman/Docker
- ODO_CONTAINER_RUN_ARGS: passed when running odo dev on Podman

Those are comma-separated list of options
that can be passed to either Podman or Docker
(depending on the PODMAN_CMD env var).

* Refactor 'build-images' tests to make it easier to add additional tests

* Add integration tests for passing build extra args

* Add integration tests for passing global extra args to Podman

* Distinguish between global options passed to Podman and specific options for 'podman play kube'

Previously, we were handling 'ODO_CONTAINER_RUN_ARGS' as global options for Podman,
but this turns our not being that useful if we want to pass dedicated options to 'podman play kube'.
This commit introduces a new 'ODO_CONTAINER_BACKEND_GLOBAL_ARGS' env var,
which will be used as global options passed to every Podman command we execute.

This paves the way to isolating our Podman-related tests further
using the '--root' and '--runroot' global options.

* Use `ODO_IMAGE_BUILD_ARGS` in the Advanced Guides

* Use a semicolon as delimiter for extra flags

Doing so because some of the options of Podman/Docker can actually be either repeated or comma-separated.
2023-05-04 04:59:18 -04:00