27 Commits

Author SHA1 Message Date
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
Philippe Martin
7a721348b3 Automount volumes (#6698)
* Simplify AddOdoProjectVolume and AddOdoMandatoryVolume

* Rename / Clarify HandleEphemeralStorage function

* Regroup volume-specific code

* Move volume specific code to a separated function

* Add a new module configAutomount

* Automount PVC (without options)

* Add unit tests

* Separate functions

* Mount secrets

* Mount configmaps

* Specific mount path

* MountAs annotation

* Mounting cm/secret as env

* Refacto: use inAllContainers + replace result with volume

* Mounting cm/secret as subpath

* Read-only

* Integration tests

* Rename label

* Automount during odo deploy Exec command

* Add documentation

* Fix TODO

* Review

* Fix indentation

* Rename labels/annotations
2023-04-18 07:58:45 -04:00
Parthvi Vala
ef6489c424 Add mockgen installation to the script (#6604)
* Add mockgen installation to the script

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

* Use go install -mod=readonly instead of installing the binary

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

* Add mockgen installation to goget-tools target incase the user wants to run the script individually

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

* Update Makefile

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

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <asoro@redhat.com>
Co-authored-by: Armel Soro <armel@rm3l.org>
2023-03-06 15:01:57 +01:00
Philippe Martin
20ea3a2043 Podman dev (#6183)
* 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
2022-11-21 08:56:44 -05:00
Philippe Martin
67272fd81d Remove localconfigLocalConfigProvider abstraction (#6285)
* Remove localconfigLocalConfigProvider abstraction

* Remove LocalConfigProvider interface

* Move LocalStorage to pkg/storage (with ListStorage)
2022-11-16 12:33:29 +00:00
Philippe Martin
e03b1e0a12 Move --var-file and --var as generic flags (#6201)
* Define --var-file and --var global flags

* Fix sync mock

* Fix comments

* odo deploy: Use variables from context

* Change FlagValuesIfSet with FlagValues
2022-10-10 13:54:37 +02:00
Philippe Martin
f78096d264 Refactor remotecmd (#6169)
* Remove kclient from interface / signatures

* Create Exec package

* Call ExecuteCommand with client

* Call ExecuteCommand with client from sync package

* Fix order of dependencies
2022-09-27 09:38:54 +02:00
Philippe Martin
2c0b2ee2a6 Refacto sync pkg (#6163)
* Rename interface to SyncExtracter

* Inline PushParameters fields into SyncParameters

* Move SyncParameters to sync package

* Move ComponentName as parameter to SyncFiles

* Move SyncAdapter as handler

* Build syncclient with dependency injection system

* Move ForcePush logic outside of sync package + remove unused ForceBuild option
2022-09-23 16:30:55 +02:00
Philippe Martin
a0b0d0f3c1 Simplify pkg/devfile/adapters/... packages (#5914)
* Remove dependency on common.AdapterContext for sync.Adapter

* Simplify adapters.NewComponentAdapter

* NewComponentAdapter accepts kubernetes.KubernetesContext instead of interface{}

* Replace KubernetesContext with its only field Namespace

* Move the Push Interface and  builders to the kubernetes.component  package

* Move AdapterContext to kubernetes.component package

* Embeds component.New into NewKubernetesAdapter

* Move GetCommandsMap where it is used

* Move GetSyncFilesFromAttributes  where it is used

* Move constants where they are used

* Move types to adapters package

* Update pkg/devfile/adapters/kubernetes/component/adapter.go

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

Co-authored-by: Armel Soro <armel@rm3l.org>
2022-07-06 07:35:42 +00:00
Parthvi Vala
6cf24bbc33 Create binding between devfile component and existing service (#5641)
* Skeleton for odo create binding

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

* Add logic

* Add functions to add data to devfile and create files

* Dharmit's review + make it work with <name>/<kind>.<apigroup>

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

* Add support for more formats

* Add integration tests and supporting helper functions

* create > add

* Add default ServiceBinding name

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

* Fix timeout, and move cli/add/binding.go to cli/add/binding/binding.go

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

* Update pkg/binding/binding.go

Co-authored-by: Philippe Martin <contact@elol.fr>

* Update pkg/binding/binding.go

Co-authored-by: Philippe Martin <contact@elol.fr>

* Update pkg/binding/interface.go

Co-authored-by: Philippe Martin <contact@elol.fr>

* Philippe's review

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

* Self review

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

* Fix unit test failure

* Philippe's review: round 2

* Tomas review; self review

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

* Fix windows test failure

* Randomize binding name for test

Co-authored-by: Philippe Martin <phmartin@redhat.com>
Co-authored-by: Philippe Martin <contact@elol.fr>
2022-05-12 15:05:17 +02:00
Philippe Martin
b8e6e5f112 odo alizer command (#5646)
* Cleanup v2 json output

* odo alizer command

* Doc

* review
2022-04-12 13:01:04 -04:00
Armel Soro
2132cb516f [#5561] Remove odo url (#5571)
* Remove `odo url` from CLI layer

* Adapt tests

* Adapt test from deleted `cmd_devfile_delete_test.go`

This test still makes sense, as it tests the removal
of URL-related resources, like Services and Ingresses.

* Remove call to `odo project set ...` in test, as suggested in review

This command will get removed in the near future.

* Remove places where URL manipulation could modify  Devfiles

Also remove dead code

* Remove unused `updateURL` field from EnvInfo struct

* Adapt test by mimicking some behavior that `odo url create` used to perform

`odo url` used to modify the `env.yaml` file,
and `odo dev` currently creates Kubernetes/OCP resources related to URLs.

We may remove this test later on if `odo dev`
no longer needs to create such Ingresses and Routes.

* Remove all places where URLs, Ingresses and Routes are manipulated

* Port test in cmd_dev_test instead and make sure no Ingress/Route is created

* Remove no-longer `test-cmd-devfile-url` target from Makefile

The corresponding test file has been deleted.

* Remove `create url` command reference from V3 docs, as suggested in review

* Use existing `devfile-with-multiple-endpoints.yaml` Devfile  in test, as suggested in review
2022-03-28 16:39:53 +02:00
Dharmit Shah
0396b435c3 Implements port forwarding for odo dev (#5526)
* First pass of port-forward for odo dev

* Supports forwarding multiple ports/endpoints

* Change message wording

* Port forwarding happens port 40001 onward

* Organize the code

* Integration tests

* Update the CLI help message

* Catch and check err

* Changes for failing unit tests

* Fix test and add newline to a message

* Remote label and use for loop

* Adds TODO to cleanup when port-forwarding fails

* Change messaging printed on the CLI

* Break Start method into multiple methods

* Set debug port while creating push parameters in dev

* Test after making a change to a file in pwd

* Refactoring to put things where they should be

* Notify user to run odo dev again if endpoints change

* Unit tests and rebase mistakes

* Add newline character for clear formatting

* Create business logic for reuse to find endpoints

* Fix unit and integration test failures

* Self review

* Changes based on Philippe's review

* Two more changes based on Philippe's review

* More changes based on PR review

* Changes based on PR feedback and more

- Renames all receivers in kclient package to `c`
- Adds mocks

* Removes unnecessary function

* Make function more generic for reuse

* Rename Options to DevOptions

* Address review comments by Tomas

* Fix failing unit test

* Modify message to restart odo dev

* Use helper.RunDevMode in odo dev tests

* Remove doubly imported log package

* Modifies clientset at CLI and business layer

- No need of KUBERNETES client for `odo dev` business layer.
- Added KUBERNETES client for `odo dev` CLI layer.

* Remove hardcoding of URL in tests

- It uses @feloy's work in PR #5570.

* Uses regexp to find strings.

* Makes FindAllMatchingStrings more generally usable

* Adds constant for localhost regex

* Replace matches with urls and remove unnecessary Sprintf

* Documents what urls is in RunDevMode function.

* Update tests/helper/helper_dev.go

Co-authored-by: Philippe Martin <contact@elol.fr>

* Update tests/helper/helper_dev.go

Co-authored-by: Philippe Martin <contact@elol.fr>

* Update tests/helper/helper_dev.go

Co-authored-by: Philippe Martin <contact@elol.fr>

* Update tests/helper/helper_dev.go

Co-authored-by: Philippe Martin <contact@elol.fr>

Co-authored-by: Philippe Martin <contact@elol.fr>
2022-03-25 15:14:13 +01:00
Tomas Kral
614976a0bf remove odo catalog command (#5577)
* remove odo catalog command

- move devfile registry relevant code to pkg/registry

* remove odo catalog page form docs

* remove a few forgotten uses of catalog from clientset.go

* fix typos in docs
2022-03-23 12:15:41 +01:00
Philippe Martin
daa9c61a41 odo delete component without a devfile (#5511)
* Namespace

* Get all resources with selector

* Delete resources

* Display errors

* Add start message

* Set correct labels for odo deploy

* Add unit tests

* Add integration tests

* Delete managed by odo only

* Fix rebase

* Review + small fixes

* AdD/fix logs
2022-03-10 05:44:18 -05:00
Dharmit Shah
f80207b029 Implements odo dev (#5441)
* Skeleton for odo dev and a unit test

* Update go mod for fsnotify

* Start method Pushes and then Watches

* More understandable code comments

* Client and interface for watch package

* Mocks for watch package

* Add CLI layer

* Fix infinite watch & push trigger

* Remove context flag from odo dev

* Add integration tests for odo dev

* Add klog to dev.go

* Replace errors.Wrap with fmt.Errorf

* Self review

* Removes `odo watch` command, but the business logic exists as it's
  used by odo dev
* Removes integration tests for `odo watch`
* Removes errors.go and types.go from pkg/dev/ since they are empty

* Check if error is not nil

* Use real client in watch unit tests

* Uncomment AfterEach from tests

* Modify the logs printed to stdout

* Changes based on Philippe's review

* Remove unused clients

* Parthvi's PR review and unit test fixes

* Fix gofmt message, remove message to not expect

* Fix lint complains, add mistakenly deleted URL creation logic

* Remove or modify tests that rely on odo push output

* Remove unused variables based on golangci-lint

* Fixes based on Philippe's review

* Initialize first index after first run of odo dev

* Modify odo dev test, and uncomment a mistake
2022-03-03 04:15:37 -05:00
Philippe Martin
0e4e55bdd0 Deploy, Events without devfile/adapters (#5460)
* Execute devfile command

* Undeploy

* cleanup devfile/adapters

* refactor

* Move GetOnePod to component package

* Move DoesComponentExist and Log from devfile/adapter to component package

* Exec without devfile/adapters

* Move Delete from devfile/adapters to component

* Remove old Deploy code

* review

* Add tests for issue 5454

* Review
2022-02-23 03:48:52 -05:00
Philippe Martin
06ba84ec28 Refactor odo init to make parts reusable by odo dev/deploy (#5434)
* Init package

* Fix starter not found

* More unit tests

* More doc

* Review

* Determine backend upfront
2022-02-11 09:50:57 -05:00
Philippe Martin
850c7cd723 Remove commands that wont be implemented for v3-alpha1 (#5433)
* Remove odo staorage commands

* Remove "odo service" + "odo catalog * service" commands

* Remove odo link/unlink commands

* Remove related integration tests

* Remove application concept

* fix rebase

* fix test

* Remove config command

* Remove env command

* Remove application package

* Remove config package

* Move odogenerator and unions packages into kclient

* Move notify package to cli/version

* Fix script mockgen

* Remove odo debug command oand debug package

* Remove odo component describe/exec/log/status/test

* Remove operator-hub tests from IBM tests

* Remove operator hub tests from CI

* Fix e2e tests
2022-02-06 23:42:15 -05:00
Philippe Martin
b75fa552ce Init command (#5348)
* Init command

* More tests + check empty dir

* Move function from catalog to service package

* Interactive asks lang + type

* Interactive

* Refactor catalog package with interface

* Add mocks for catalog and init/asker

* Add tests

* Create sub-packages for init + starter project

* Rename files in pkg/catalog

* More validations

* fix

* Logs

* Rollback

* Go back and No starter

* Review

* Use filesystem.Filesystem in pkg/catalog

* Change pull from registry strategy

* More unit tests

* More tests

* Integration tests

* Review

* Use full path to fix problem with Unzip

* Add integration test for devfile with parent URI

* Add prefClient dependence to catalog package

* Move function to pkg/init package

* Review

* Fix rebase

* Review
2022-02-01 04:48:54 -05:00
Dharmit Shah
9fcb25ecbe Add server flag to odo login (#5363)
* Add server flag to odo login

* Add unit tests

* Catch but ignore the error for Complete

* Create factory method for KubernetesClient
2022-01-28 09:46:09 -05:00
Philippe Martin
e63773cc15 Separate layers : Preference (#5296)
* Refactor preference package

* Unit tests

* Apply suggestions from code review

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

* Review

* Review from Dharmit

* Replace panic with LogErrorAndExit

* Remove preference from kclient/oc_server

* Remove preference.New from devfile

* Remove preference.New from kclient/WaitAndGetPodWithEvents

* Get prefClient from CreateOptions

* Parthvi review

Co-authored-by: Parthvi Vala <pvala@redhat.com>
2022-01-10 16:00:53 +01:00
Philippe Martin
b20103c9f3 Separate layers - Application + Project (#5293)
* Application interface

* Application describe

* Application list

* Fix --output/-o flag

* Test Run()

* Tests on application pkg

* Unit tests on kclient relative to application

* comment

* Add ComponentList method to Application

* Project interface

* Project CLI tests

* Dharmit review
2022-01-05 16:08:40 +01:00
Philippe Martin
c58e4c7e6b Create a cmdline interface for testing Context creation + Complete function (#5256)
* Create a cmdline interface
The interface abstracts the cobra.Command

* Remove cobra relation from Context

* Remove cmd parameter to Run method

* Remove direct use of cobra.Command

* Add mock for cmdline interface

* First test

* Fix typo in rebase

* Restore SetClusterType

* Move constants to specific package to avoid import cycle

* Fix rebase
2021-12-15 00:42:55 +01:00
Philippe Martin
ac478e9cd1 odo deploy command (#5228)
* Update devfile library

* deploy cmd

* Init "odo deploy" command reference

* Integration test

* Fix odo deploy

* Filter components to apply during odo push

* Output

* Remove redondant level 1 title

* Doc review

* Use server-side apply to apply Kubernetes components

* Review

* Replace PROJECT_ROOT with PROJECTS_ROOT
2021-11-24 15:26:03 +01:00
Philippe Martin
eab5036c53 odo build-images command (#5192)
* Init

* Add command reference

* Integration tests (tbc)

* Fix reference doc order

* Stream out/err of Docker/podman

* Tests

* Move images to devfile directory
2021-11-05 15:06:22 +01:00
Philippe Martin
99484663b7 Use interface for kclient (#5065)
* Use interface for kclient

* Fix + add mocks

* Add mockgen script

* remove unused param + add unit test

* fix rebase
2021-09-27 03:51:12 -04:00