62 Commits

Author SHA1 Message Date
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
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
Armel Soro
4fb7308cfa Automatically use in-cluster Devfile registries if any (#6622)
* Add kubeclient as dependency of the registry client

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

* Add GetRegistryList method to the kube client interface

This is yet to be implemented.

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

* Implement GetRegistryList

* adding test if devfileRegistryListCR is present in cluster

Signed-off-by: anandrkskd <anandrkskd@gmail.com>

* Unit tests (to be continued)

* Add unit test cases against kclient#GetRegistryList()

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

* Ignore in-cluster registries with an empty URL

This should ideally not happen if the registry operator
 is installed in the cluster (because it validates the
 URL to make sure it is reachable), but you never know ;-)

* Update error message when trying to remove registry

Registries might be found in the cluster.

* Pass isSecure value to the registry handler

* Make it possible to use in-cluster registries when calling 'odo registry --details'

* Remove unused 'preferenceClient' from registry.getRegistryStacks

* Handle in-cluster registries in 'odo init' non-interactive mode

* Handle in-cluster registries in 'odo init' interactive mode

* Add integration test for odo init --devfile-registry

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

* Use proxy when available

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

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

* Make sure tests work even if the registry operator is installed in the cluster or if there are cluster-wide registry lists

* Add tests for 'odo init' interactive mode

* Remove useless CR file

CRs are now dynamically created and applied from the tests

* fixup! Add tests for 'odo init' interactive mode

---------

Signed-off-by: anandrkskd <anandrkskd@gmail.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Philippe Martin <phmartin@redhat.com>
Co-authored-by: anandrkskd <anandrkskd@gmail.com>
Co-authored-by: Parthvi Vala <pvala@redhat.com>
2023-03-06 09:19:02 +01:00
Armel Soro
7b9f214299 Bump Go to 1.19 (#6586)
* Set Go version in go.mod

go mod edit -go=1.19

* Fix formatting issues reported by gofmt

* Fix SA1019 check (usage of deprecated "io/ioutil"), reported by golangci-lint

SA1019: "io/ioutil" has been deprecated since Go 1.16:
As of Go 1.16, the same functionality is now provided by package io or package os,
and those implementations should be preferred in new code.
See the specific function documentation for details. (staticcheck)

* Use Go 1.19 in our Dockerfiles

* Use Go 1.19 in the rpm-prepare.sh script

* Update the tag for the IBM Cloud CI image
2023-02-16 09:03:48 -05:00
Parthvi Vala
19f8e0ebdb Update devfile/library to support pod-overrides and container-overrides attributes and add integration test for it (#6512)
* Update the Devfile library

* Add test for container-overrides and pod-overrides attributes

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

Attempt at fixing CI failures

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

* Fix CI failure

* Attempt at fixing OC integration test failures

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

* Use random name in integration test

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

* Rebase and fix integration test failure

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

* Make integration test work for podman

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

* Temp attempt at fixing podman test for GH

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

* Another attempt at fixing CI test for podman

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

* One more attempt at fixing integration test for podman

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

Signed-off-by: Parthvi Vala <pvala@redhat.com>
2023-01-23 15:21:18 -05:00
Armel Soro
5660093167 Use go-cmp instead of reflect.DeepEqual to compare unit test results (#6343) 2022-11-24 07:24:32 -05:00
Philippe Martin
712254ae66 Centralize environment configuration (#6293)
* 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
2022-11-17 17:57:34 +00:00
Anand Kumar Singh
9a2aa229ce fix to prioritize newly added registry (#6289)
* 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>
2022-11-16 17:31:52 +00:00
Anand Kumar Singh
99f4a0dbc6 resolve inconsistent order of registries in preference view (#6266)
* 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>
2022-11-03 17:58:10 -04:00
Philippe Martin
c5f8c5aed8 JSON output for preference view (#6105)
* JSON output for preference view

* Document

* Integration tests
2022-09-09 10:23:02 +02:00
Eng Zer Jun
53a733b04b test: use T.Setenv to set env vars in tests (#6037)
This commit replaces `os.Setenv` with `t.Setenv` in tests. The
environment variable is automatically restored to its original value
when the test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.Setenv
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-08-19 12:32:06 +00:00
Philippe Martin
062160280f Add assertions for types implementing interfaces (#5893) 2022-07-01 08:12:24 +00:00
Parthvi Vala
dce95d62e2 Add preference add and remove commands (#5873)
* Add add, and remove commands

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

* Remove add and delete files

* Move cli/preference/registry/util.go > registry/utils.go

* Update tests, and documentation

* Move cli/preference/registry/consts/consts.go > segment/segment.go

* Fix test failures

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

* Rebase changes

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

* Remove old references

* Fix docs post-rebase

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

* Fix typo
2022-06-28 11:33:47 +00:00
Tomas Kral
d72b30c0fe change ephemeral default to false (#5795)
Signed-off-by: Tomas Kral <tkral@redhat.com>
2022-06-24 15:02:34 +00:00
Philippe Martin
d74a1a8b81 odo add binding without devfile.yaml (#5858)
* Set Kind in servicebinding instead or Resource

* odo add binding without Devfile

* Force select at least one operation option

* Change message for selecting operations

* Add Go back when selecting resource name for waorkload

* Doc

* Enable interactive binding tests for Kubernetes

* Add integration tests

* Validate and Test workload flag

* Fix doc about workload flag

* Apply suggestions from code review

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

* Review

* Fix interactive test

Co-authored-by: Parthvi Vala <pvala@redhat.com>
2022-06-24 13:01:40 +00:00
Parthvi Vala
b1fbfaa6f1 Preference cleanup (1/n) (#5822)
* Preference(Timeout) int > time.Duration

* Fix odo preference --help for unset examples

* Preference(PushTimeout) int > time.Duration

* Change set, and unset messages

* Preference(RegistryCacheTime) int > time.Duration

* use cobra.ExactArgs for set, and unset

* mockgen

* Unit tests and integration tests

* Fix unit test failure

* Update k8s.io/utils pkg

* Philippe's review

* Fix error message

* Philippe's review

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

* Add minimum acceptable value for preferences accepting time.Difference type

* Fix unit test failure

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

* Add migration plan with a warning, add better error message for incompatible formats

Signed-off-by: Parthvi Vala <pvala@redhat.com>
2022-06-23 14:27:39 +00:00
Mohammed Ahmed
77d6b6df5c Adding missing telemetry to init, deploy and dev commands (#5576)
* Adding missing telemetry information

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Adding telemetry to odo dev command

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Auto consenting to telemetry if debugtelemetry env is set

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Saving actual telemtry status in telemtry debug mode

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Adding telemetry to odo deploy command

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Removing telemtry disable and enabling debug

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Adding a telemetry test to odo init command

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Adding makefile target for odo init tests

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Remove str conv

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Check for debug telemetry even without tty

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing imports

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Switching telemetry write to file to json

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Updating to cleaner logic for debug check

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Updating tests

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Updating tests with more information

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Lowering sleep before test happens

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Updating how file content for telemetry is timed out

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Adding telemetry tests for odo deploy

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Adding more checks and fixing broken deploy test

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Adding telemetry test for odo dev and fixing some tests

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing test

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing test

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing tests and adding setter for debug telemetry

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Write something to tempfile to ensure it exists

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing lint errors

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing after rebase

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* changing component import alias in pkg/odo/cli/dev/dev.go

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

* Fixing as per comments

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing errors

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Modifying runnable to provide cmdline to run

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Moving away from commandContext

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Revertign test changes

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing gofmt

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing signature in uts

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Update tests/helper/helper_telemetry.go

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

* Addressing comments

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing uts

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Addressing comments

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Removing unneeded code

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Switchingto cmdline.Context()

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Using anytimes

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Switching to eventually

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Restructuring tests

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Using constants

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* unstaging make targets

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Updating Run to expect context instead of cmdline

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Renaming funcs to clearer names

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Moving setter function

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Moving writetojsonfile and adapting err msgs

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Renaming WriteToFile

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Updating and removing comments

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Splitting out reset telemetry

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Removing context from rebase

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing imports

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Using context.Background()

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing gofmt

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Updating runnable logic

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Addressing comments

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Formatting

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Putting things back

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing after rebase

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing after rebase

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Addressing comments

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing gofmt

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing after rebase

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing test

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Update pkg/odo/cli/dev/dev.go

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

* Update pkg/odo/cli/project/create.go

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

* Moving telemetry test

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing some tests

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Removing shadow declaration

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing tests

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing test

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing tests

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing tests

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

Co-authored-by: Parthvi Vala <pvala@redhat.com>
2022-03-28 13:18:03 +02:00
Philippe Martin
24fd02673d Remove github.com/pkg/errors dependency (#5557)
* Change errors.Wrapf

* Replace errors.Wrap

* Dont use pkg/errors (except error.Cause)

* Fix errors on Windows (do not test system underlying message)

* Replace errors.Cause

* Review
2022-03-21 11:32:42 +01:00
Philippe Martin
ff03b8e49a Select and pull a devfile using Alizer (#5464)
* Add alizer library and test functionality

<!--
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:**

Adds the alizer library from
https://github.com/redhat-developer/alizer/tree/main/go as part of our
implementaion of `odo dev` and `odo init`.

This builds upon @feloy 's PR located here: https://github.com/redhat-developer/odo/pull/5434

**Which issue(s) this PR fixes:**
<!--
Specifying the issue will automatically close it when this PR is merged
-->

Fixes #

**PR acceptance criteria:**

- [X] Unit test

- [X] Integration test

- [X] Documentation

**How to test changes / Special notes to the reviewer:**

N/A. Only function implementation

* New alizer version

* Use alizer for odo init

* Add integration tests

* Add Alizer to odo deploy

* review

* Ask component name for odo deploy

* Fix unit test

Co-authored-by: Charlie Drage <charlie@charliedrage.com>
2022-02-23 01:52:51 -05:00
Philippe Martin
21ea375695 Use functions from devfile library (#5457)
* Remove duplicated functions from pkg/util

* Use generator.GetVolumeMountPath from devfile library
2022-02-14 00:40:37 -05:00
Charlie Drage
9fc77eeeb6 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:**
2022-02-10 06:31:56 -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
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
Tomas Kral
5f79c542a8 openshift/odo -> redhat-developer/odo (#5268)
* openshift/odo -> redhat-developer/odo

* update more links to redhat-developer
2021-12-01 16:38:34 +01:00
Tomasz Janiszewski
0512d3a2cf Fix shadow (#5172)
* Configure golint

* auth/login.go

* catalog/catalog.go

* component/component.go

* component/component_full_description.go

* config/config.go

* component/adapter.go

* component/podwatcher_test.go

* envinfo/envinfo.go

* envinfo/storage.go

* envinfo/url.go

* kclient/deployments.go

* occlient/occlient.go

* describe/component.go

* component/create.go

* component/delete.go

* component/list.go

* component/push.go

* config/set.go

* config/unset.go

* service/operator_backend.go

* genericclioptions/context.go

* preference/preference_test.go

* project/project.go

* service/link.go

* service/service.go

* storage/storage.go

* sync/adapter.go

* sync/adapter_test.go

* sync/sync.go

* url/kubernetes.go

* util/file_indexer.go

* util/util.go

* util/util_test.go

* watch/watch.go

* watch/watch_test.go

* helper/helper_filesystem.go

* devfile/cmd_devfile_push_test.go

* devfile/cmd_devfile_url_test.go

* devfile/cmd_devfile_watch_test.go

* operatorhub/cmd_service_test.go

* gofmt

* Enable gofmt in golangci

* Return context not nil

* reanme context

* Remove unused value in watch

* Fix pkg/catalog/catalog.go
2021-10-27 18:02:17 +00:00
Dimitra Zuccarelli
511673f19b Remove experimental mode flag (#5117)
* Remove experimental mode flag

Signed-off-by: dimitraz <dimitrazuccarelli@gmail.com>

* Remove unused function

Signed-off-by: dimitraz <dimitrazuccarelli@gmail.com>

* Update example strings for url and push commands

* Update watch tests

Signed-off-by: dimitraz <dimitrazuccarelli@gmail.com>
2021-10-11 08:33:46 +02:00
Parthvi Vala
33fad0bea4 Add documentation for global configuration (#4921)
* Add documentation for global configuration

* Cosmetic changes, add a few notes

* Add more clarification to docs and fix Ephemeral default value

* Add tabs for location example and add other examples

* Fix file paths and add requested changes

* Change the username in example file path.

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>

* Fix unsetting preference statement.

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>
2021-07-23 16:23:49 -04:00
Jingfu Wang
7f998e4a2a fix: registry migration (#4702)
Signed-off-by: jingfu wang <jingfwan@redhat.com>
2021-05-10 14:17:46 -04:00
Dharmit Shah
1f49f7c7fd Removes docker related code (#4634)
* Removes docker related code

* Remove pushtarget tests from unit tests

* Makes `go vet` happy

* Makes `wwhrd check -q` happy

* Removes docker url code

* Removes docker tests
2021-04-19 01:51:50 -04:00
Jingfu Wang
cdd92ef3a5 OCI-based devifle registry support (#4525)
* feat: OCI-based registry support

Signed-off-by: jingfu wang <jingfwan@redhat.com>

* refactor: download the whole stack by default

Signed-off-by: jingfu wang <jingfwan@redhat.com>

* fix: invalid folder issue

Signed-off-by: jingfu wang <jingfwan@redhat.com>

* fix: address comments

Signed-off-by: jingfu wang <jingfwan@redhat.com>

* fix: test case and auto migration

Signed-off-by: jingfu wang <jingfwan@redhat.com>

* fix: code issue detected by unit test

Signed-off-by: jingfu wang <jingfwan@redhat.com>

* test: fix unit test

Signed-off-by: jingfu wang <jingfwan@redhat.com>

* Merge branch 'master' of github.com:openshift/odo into odoMigration

Signed-off-by: jingfu wang <jingfwan@redhat.com>

* refactor: adopt the latest devfile library

Signed-off-by: jingfu wang <jingfwan@redhat.com>

* test: fix unit tests

Signed-off-by: jingfu wang <jingfwan@redhat.com>

* test: fix unit tests

Signed-off-by: jingfu wang <jingfwan@redhat.com>

* Merge branch 'master' of github.com:openshift/odo into odoMigration

Signed-off-by: jingfu wang <jingfwan@redhat.com>
2021-04-15 18:20:07 -04:00
Parthvi Vala
c98445f8bb Enter Telemetry (#4482)
* Send telemetry to segment

* Add tests and other properties

* Add comments

* Fix fmt

* Add telemetry dev key

* Add non-test related changes requested to the PR and add consenttelemetry prompt

* Handle prompt while running tests

* First attempt at fixing unit job failure

* Modify tests as requested

* Stop prompting when preference is called

* Fix comments

* Add more unit tests and integration test(WIP)

* Fix failing tests

* Stop prompting when help is called

* Make tests more verbose

* Add Usage data doc

* Add segment key

* Add a better usage doc

* Add comments, move tests and other requested changes

* Fix comments and remove focus

* Add set ConsentTelemetry unit tests

* Change want from string to bool

* Fix failing integration test

* Fix failing operator hub test

* Fix failing devfile integration test

* Fix tests failing due to cmdwrapper WithEnv

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>
2021-03-26 11:43:09 +00:00
Parthvi Vala
3fc780e7bd Make errors pretty (#4541) 2021-03-23 04:57:13 -07:00
Parthvi Vala
19ddda76f8 modify preference errors (#4498) 2021-03-09 19:58:50 +01:00
Parthvi Vala
eed0087ba1 Add telemetry consent to preference (#4456)
* Add telemetry consent

* Add telemetry preference to view

* Add integration test for preference
2021-03-08 08:52:53 -05:00
Tomas Kral
38c2f9d974 Change default value for ephemral preference (#4360)
* Change default value for ephemral preference

For not it assumes default value for ephemeral 'false'.
It future  releases we might change it 'true'. But for now we should
play it safe and keep the old behaviour. We are not sure about all the
consequences that this can have.

* fix failing test due to incorrect pvc count
2021-01-19 05:06:47 -05:00
Aditi Sharma
20d67e25f9 Implement PVC for odo source volume (#4316)
* Implement source storage as pvc

add label for source pvc, to filter out from storage list

* Add "ephermeral" option in preference.yaml

* Add test and update preference settings

* Fix ephemeral spelling

* fix integration test

ignore lost+found

* Capitalize ephemeral

* Fix Preference issues
2020-12-24 11:03:29 +01:00
Jingfu Wang
12fdfada0a Fix default registry support (#3941)
* fix: default registry support

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* tests: fix unit tests

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>
2020-09-15 03:11:20 -04:00
Charlie Drage
3fcd3670e8 Make Devfile the default deployment mechanism (#3705)
* Add default registry when preferences initialized

Signed-off-by: John Collier <John.J.Collier@ibm.com>

* Make Devfile the default deployment mechanism for odo

**What type of PR is this?**
> Uncomment only one ` /kind` line, and delete the rest.
> For example, `> /kind bug` would simply become: `/kind bug`

/kind feature

**What does does this PR do / why we need it**:

Makes Devfile the default deployment mechanism, removing S2I in favour
of Devfile deployment.

**Which issue(s) this PR fixes**:

Closes https://github.com/openshift/odo/issues/3550

**How to test changes / Special notes to the reviewer**:

Run:

```sh
odo preference set experimental false
odo create --starter nodejs
odo push
```

* Review round 1

* Pass testing

* Pass testing

* Remove failing devfile test since this test does not run against openshift testing suite

* Temporarily disable OperatorHub tests

Co-authored-by: John Collier <John.J.Collier@ibm.com>
2020-09-10 18:07:05 -04:00
Girish Ramnani
ce7b8efbbe remove unnecessary unit tests (#3856) 2020-08-28 14:55:31 -04:00
Girish Ramnani
68bc98ba89 odo config for devfile (#3702)
* add feature complete odo set and unset

* added json output

* added json output for odo config

* resolved golint

* addressed some comments

* separated out devfile and s2i run sections

* Add example and descriptions

* some spacing

* added integration tests

* only odo injected ports can be managed

* typo resolved and DRYed the config tests

* updated desc and use dns friendly component name

* add devfile config tests to travis

* resolved the panic

* format the help for all config flows

* now a user can remove all ports

* resolved failing tests

* added the format test back

* not pushing in intg test

* added unit tests for devfile config

* unique portname for different protocol

* removed a comment
2020-08-26 06:37:21 -04:00
Tomas Kral
319b914b01 Caching registry responses to fix client.Timeout issue (#3681)
* debuging timeout issue

* use httpcaching (15min) for registry related requests

* update vendor

* add RegistryCacheTime preference option

* fix preference unit test

* add DownloadFileWithCache function

* address PR review comments

* address PR review comments

* errors related to caching should not be fatal

* cleaner cache logging
2020-08-06 04:49:48 +02:00
Chris Laprun
56eed90ea3 Clean ups (#3588)
* refactor: remove redundant information

* refactor: remove API check as it's implied when retrieving schema

* refactor: simplify type check

* fix: typo

* refactor: introduce getStringOrEmpty function

* refactor: extract Get*OrDefault functions and use them where appropriate
2020-07-17 13:34:17 -04:00
Amit Rout
aa05fb4799 Expose oc build timeout in preference (#3232)
* Expose oc build timeout in preference

* Fixing failures

* Fixing make bin failure

* Fixing make unit test failure

* Fixing gofmt issue

* Fixing UTs failure

* Addressing review comments

* Addressing review comment

* Addressing review comment

* Fixing timeout

* Fixing failure

* Added integration test

* Update integration test scenario

* Updated machine readable preference view

* Consumed suggestion

* Adding more unit tests

* Addressed review comment
2020-07-16 02:14:52 -04:00
Jingfu Wang
86fa18dbdb Secure registry support (#3516)
* feat: secure registry support

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* test: fix TestDownloadFile test

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* docs: update error message

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* refactor: move credential prefix to util package

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* feat: display and store registry type

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* refactor: remove optional argumetns

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* fix: unit test

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* refactor: add unit test and refactor

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>
2020-07-14 16:54:45 +02:00
Girish Ramnani
fdea76febc implement machine readable output for odo preference view (#3522) 2020-07-14 05:42:54 +02:00
Maysun J Faisal
9a47062947 Devfile v2 command group impl + Odo catalog list components (#3291)
* First working draft of complete command group kind

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Refactor devfile parse and validate funcs

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Update catalog for devfile v2 registry

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Cleanup, Unit tests, update catalog list components

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Remove SUPPORTED for devfile catalog

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Update integration tests for devfile v2 - 1

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Fix odo catalog list and odo create

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Update devfile integration tests

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Update devfile tests for Kube cluster

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* PR Feedback for command group

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Apply Feedback 2 for commands group

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Catalog & Create PR Feedback 1

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Create and Catalog Feedback 2

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* rebase with master

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* Update Registry integration tests for v2

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>

* rebase with master and update test

Signed-off-by: Maysun J Faisal <maysun.j.faisal@ibm.com>
2020-06-26 22:39:32 -04:00
Jingfu Wang
b632256b1c Fix multiple registry related issues (#3341)
* feat: fix registry issues

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* docs: improve error/help message

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* test: improve registry tests

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* feat: github raw url conversion support

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* test: refactor testing output format

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* test: fix breaking tests

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* refactor: add validation for raw url conversion

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>
2020-06-20 09:10:34 -04:00
Tomas Kral
6714e1c841 use odo.dev instead of odo.openshift.io apigroup (#3103)
Signed-off-by: Tomas Kral <tkral@redhat.com>
2020-05-12 07:52:39 -07:00
Jingfu Wang
bfa9922b1b Dynamic registry support (#2940)
* Draft PR for dynamic registry support

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Handle migration

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Handle migration with experimental

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Improve error handling

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Add unit tests

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Fix unit tests

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Fix unit tests

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Add integration tests

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Update "odo delete" and display registry name

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Add confirmation dialog for update and delete

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Fix catalog test

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Update help page and delete functions

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Help page cleanup

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* update confirmation page

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Add URL validation

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Fix unit test

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Use built-in library for URL parsing

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Update message

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Update help page and use const default registry

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Update registry URL

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Update help page

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Update registry tests

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Add github registry example

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Update template

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Fix typo

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Update k8s packages

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>

* Fix registry test

Signed-off-by: jingfu wang <jingfu.j.wang@ibm.com>
2020-05-09 13:07:54 +02:00
Tomas Kral
a82f3e0256 Update openshift to 4.4. and k8s to 1.17 (#3081)
* update openshift libs to 4.4

* update vendor
2020-05-06 18:53:51 +02:00