160 Commits

Author SHA1 Message Date
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
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
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
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
Parthvi Vala
010e9634d3 Use custom address for port forwarding (#6766)
* Custom address for port forwarding

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

* Add integration tests

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

* Use private variables for custom address and ports

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

* Update pkg/util/util.go

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

* Assign custom address to HostIP for podman

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

* Add validation for free port when --port-forward is provided in the Validate() method, add integration test for running parallel dev sessions on same platform, same port and different addresses

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

* Fix unit test failure

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

* Attempt at fixing windows failure

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

* Add documentation

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

* Use default value for --address flag

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

* Changes from review

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

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <armel@rm3l.org>
Co-authored-by: Armel Soro <asoro@redhat.com>
2023-05-02 07:34:19 -04:00
Parthvi Vala
47234b94b3 Fix: Starterproject not replace existing devfile stack files of the context dir (#6633)
* Starterproject does not replace existing files of the context dir

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

* Fix issue with os.RemoveAll

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

* Fix errors, it works now

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

* Fix test failures

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

* Use filesystem to perform file operations wherever possible

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

* Use filesystem to perform file operations wherever possible (2)

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

* Add unit test for DownloadStarterProject 1/n

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

* Fix zip files

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

* Fix zip files (2)

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

* Add unit test starter project with Devfile

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

* Fix zip files (3)

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

* Finish unit tests

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

* Remove unnecessary integration test

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

* Add comments and verbosity, cleanup code

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

* Update pkg/registry/registry.go

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

* Update pkg/util/util.go

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

* Update pkg/registry/registry.go

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

* rm3l's suggestion on using err when not shadowed and enhance error messages

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

Fix validation errors

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

* Change arg position in IsValidProjectDir

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

* rename isConflicting to getConflictingFiles

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

* Add zip files for starterproject with empty dir

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

* Add unit tests covering starterprojects with empty dir for both conflicting and non-conflicting cases

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

* Handle error while walking

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

* Delete temp dirs

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

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
Co-authored-by: Armel Soro <armel@rm3l.org>
2023-03-21 08:55:42 -04:00
Philippe Martin
93d1330182 Patch Pods to pass pod security admission (#6602)
* Bump devfile/library

* Use generator.GetPodTemplateSpec instead of Get[Init]Containers

* Fix deprecated pointer.*

* Fix more deprecated

* Workaround for ServerPreferredResources panicking

* Pass policy to GetPodTemplateSpec

* Integration test

* document behaviour

* Review
2023-03-20 10:16:14 -04:00
Armel Soro
86b271d65c Fix issue with conflicting ports when starting multiple Dev sessions on Podman (#6660)
Due to regression on 6.1+ kernels [1], binding on 127.0.0.1:$port after some process
listens on 0.0.0.0:$port does pass, which is not expected.
Until this issue is fixed [2], a possible workaround is to try to bind on 0.0.0.0:$port.
This works correctly on Podman, and also on Kubernetes
(because we do port-forwarding on Kubernetes on 127.0.0.1:$port).

The unit test added should allow us to detect similar issues faster in the future,
should it happen again.

[1] https://lore.kernel.org/stable/e21bf153-80b0-9ec0-15ba-e04a4ad42c34@redhat.com/T/
[2] https://lore.kernel.org/netdev/20230312031904.4674-3-kuniyu@amazon.com/T/
2023-03-20 04:44:54 -04:00
Parthvi Vala
775adfd01e Support exec command (#6579)
* Support exec command for deploy

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

* Print log after timeout

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

* Add helper function to form proper commandLine

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

* Mockgen kclient

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

* Enhance error message

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

* Attempt at fixing unit test failures

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

* Rename import v1 to batchv1

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

* Remove TODOs

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

* Add integration tests and cleanup on user interrupt

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

* Temp changes

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

* Log tip to run odo logs after a minute

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

* List components to delete even if there are no devfile resources

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

* Fix integration tests

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

* Fix deploy exec delete integration test

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

* Temp Change

* Fix delete command tests

* Fix mockgen client

* Fix validation errors

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

* Fix unit test failure

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

* Attemp at writing less flaky integration test

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

* Remove TODOs

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

* Add tip after 1 minute and return the go routine if job finishes before that

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

* Use the container as it is so that container-overrides can be taken into account

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

* Move job spec code to a different helper function inside the libdevfile pkg

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

* Modify the Execute method to use the new helper function and refactoring

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

* Attempt at fixing integration and unit tests

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

* Move defer to print remaining resources to a separate function, fix func doc and gofmt the files

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

* Fix test failures

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

* Cleanup

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

* Cleanup unused functions

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

---------

Signed-off-by: Parthvi Vala <pvala@redhat.com>
2023-03-03 11:28:16 +01:00
Philippe Martin
99d6450499 Allow : character in devfile registry URI (#6624)
* Allow `:` character in devfile registry URI

* Add unit test
2023-02-27 18:32:11 +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
Eng Zer Jun
0f1d226431 test: use t.TempDir to create temporary test directory (#6533)
This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests [complete.

Prior to this commit, temporary directory created using `ioutil.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
	defer func() {
		if err := os.RemoveAll(dir); err != nil {
			t.Fatal(err)
		}
	}
is also tedious, but `t.TempDir` handles this for us nicely.

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

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2023-01-25 07:02:46 -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
Parthvi Vala
aa8a3c7c79 Fix: odo dev unable to sync files with name containing special characters (#6507)
* Fix: odo dev unable to sync files with name containing special characters

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

* Cover in unit tests and refactor them

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

* Add test for globEscape

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

Signed-off-by: Parthvi Vala <pvala@redhat.com>
2023-01-20 14:05:42 -05:00
Parthvi Vala
8dbf42e5e1 Fix typo with file_indexer.go (#6502)
Signed-off-by: Parthvi Vala <pvala@redhat.com>

Signed-off-by: Parthvi Vala <pvala@redhat.com>
2023-01-18 04:32:09 -05:00
Philippe Martin
38273df019 Fix adding .odo to .gitignore file (#6495) 2023-01-17 11:47:16 -05:00
Philippe Martin
6c99ca1024 Get next free port when forwarding ports on podman (#6377)
* Refacto get first free port

* Use next free port for Podman

* Save used ports to reuse them

* Fix unit tests

* Do not rely on system for ports during tests
2022-12-09 06:41:29 -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
Armel Soro
d921a17821 Implement odo delete component --files to delete files generated by odo (#6255)
* Add utility functions allowing to report files generated by odo

The end goal is for 'odo delete component --files' to gather a list of
files that were initially generated by odo, so as to delete only those.
This way, we are less likely to delete the wrong files.

This list is collected in a '.odo/generated' file.

It will then be up to odo commands to call those methods
accordingly. For example, this is called:
- by odo init, odo dev, or odo deploy, when generating a new devfile.yaml
- by odo dev, when there is no .gitignore file and odo generated one

Note that it is quite impossible to cover all scenarios; for example,
if odo generates a new devfile.yaml file, but the user deletes it
manually and recreates it, 'odo delete component --files'
will still list it as a possible candidate for deletion
(because it would be listed in .odo/generated).

* Report files generated by commands like init, dev or deploy

* Implement 'odo delete component --files'

* Add integration tests for 'odo delete component --files'

* Document the `--files` flag

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

* Do not delete the .gitignore file

It is more likely to be modified by the user afterward (for another
usage).

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

* fixup! Document the `--files` flag

* fixup! Implement 'odo delete component --files'

* Apply review suggestions on integration tests

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

* fixup! fixup! Document the `--files` flag

Co-authored-by: Philippe Martin <contact@elol.fr>
Co-authored-by: Philippe Martin <phmartin@redhat.com>
Co-authored-by: Parthvi Vala <pvala@redhat.com>
2022-11-22 00:47:01 -05:00
Dharmit Shah
f062c11a11 Update odo to use go 1.18 (#6166)
* Update odo to use go 1.18

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

* Update golangci-lint version in Makefile

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

* Use go 1.18, not go 1.19

Erroneously I had used go 1.19 at various places.

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

* Rearrange imports; fix golangci-lint errors

Fixed a bunch of golangci-lint errors like below:

`File is not `gofmt`-ed with `-s``

using the command: `golangci-lint run --fix`

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

* Use go install instead of go get

This is because with go 1.18, `go get` behaves as `go get -d` by
default. Which means that it will only download, but not install.

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>
2022-11-09 05:31:38 -05:00
Philippe Martin
6dcc11af3a Fix panic when component name is long but not app (#6136)
* Fix panic when component name is long but not app

* Fix comment

* No more magic numbers
2022-09-21 15:46:19 +02:00
Philippe Martin
0a83f1d899 Do not use env.yaml file anymore (#6057)
* Remove GetApplication from LocalConfigProvider interface and all related stuff

* Remove GetName from LocalConfigProvider interface and all related stuff

* Remove GetContainers from LocalConfigProvider interface

* Remove Exists method from LocalConfigProvider interface and stop odo dev writing env.yaml file

* Remove GetDebugort method from LocalConfigProvider interface + fix #6056

* Remove unnecessary fields from EnvInfo structure

* Remove all references to env.yaml file

* Review

* Test for #6056
2022-08-29 09:25:09 -04:00
Philippe Martin
f22c3f854d odo dev: react to changes as soon as possible (#5933)
* Create auxialiary functions to find current deployment and pod name

* Create auxialiary function for pushing Kubernetes components to cluster

* Auxiliary function getPushDevfileCommands and remocve RunModeChanged flag as it is not possible anymore with long running dev command
+ move prelimiray tests at the beginning

* Create auxiliary function updatePVCsOwnerReferences + move isMainStorageEphemeral inside aux. function

* Watch for deployments in addition to watching for files during odo dev

* - Check the Deployment Generation to return earlier when generation changed
- Return earlier when pod is not ready

* Push receives a Status that it can update, to indicate the status of the component when the function returns. This status is passed from Start to Watch

* Use status to decide to sync files

* Simplify getting pod

* Status for PostStartEvents

* - Touch .gitignore earlier so it is not synced
- Add devstate.jso file to .gitignore

* Fix the integration tests.

* Make --no-watch work again

* Get smaller volumes for tests

* Quit when fail to exec port forwarding

* Exponential delay after an error

* Fix: get running pod

* Remove testing odo dev stops when the build command fails. odo dev now gives a change to the user to fix the problem

* Fix order or volumes and volume mounts in pod spec

* Use server side apply for updating PVC when supported

* Watch Devfile separately

* Adapt tests for devfile handled separately

* Update forwarded ports when necessary

* Display kubernetes resources created only when created/updated

* Do not set ResourceVersion when patching

* TEMP: Add more logs on failing integrattests

* Tests: select the *running* pod

* Use forward slashes for .gitignore content, even on Windows

* Rename GetOnePodFromSelector to GetRunningPodFromSelector

* Cleanup logs

* Fix 'odo log' integration test

* Add log "Waiting for Kubernetes resources"

* Fail if service bindings are not injected

* Rename sources related watcher, timer

* Fix delay after error

* Display info about Pod

* Disambiguate error messages

* Display events related to components pod

* Remove now unused functions used to wait for Deployment / Pod

* Typos + function renaming

* Do not watch devfile with --no-watch

* Use type switch for Kubernertes watch event

* Do not fail when watching Events is Forbidden

* Do not fail when servicebinding resources are forbidden

* Exit when build command fails on no-watch mode

* Sync devfile.yaml by default, workaround when commands change on devfile

* Rename to warningsWatcher

* Fix comment
2022-08-08 10:20:55 +00:00
Armel Soro
77ff2b89de Add support for composite run/debug commands (#5841)
* Change integration test expectations regarding composite run commands

* Add integration test supporting composite debug commands

* Rename in-container pid file from '.odo_devfile_cmd_<name>.pid' into '.odo_cmd_<name>.pid'

The implementation in kubeexec.go is indeed able to run any kind of commands,
not only Devfile-related.

* Pave the way to supporting composite run/debug commands

Drop validation rules that prevented from going further
with composite run or debug commands.

* Update logic for determining which containers should have their entrypoint overridden or env vars updated

The previous implementation was limited to Exec commands solely.
This now makes it easier to support other kind of commands.
For example, when handling a composite command, we are now recursively
determining the containers (a.k.a components) that would get used by this composite command.

* Store the process exit code in the pid file handled by kubeexec.go

This allows to more accurately determine how the process could be reported.

* Fix issue with util#DisplayLogs potentially not picking the last element of lines

* Make sure to execute the Build command only once when running a composite command

* Test that the Build command is executed once running a composite command

* Make sure not to retrieve the parent default command uselessly

* Log the command Id when it is about to be restarted

* Redirect build command logs to PID 1 process

This way, users would be able to display them (and follow them) with `odo logs` or `kubectl logs`

* Handle Errored case when logging information about the process that exited

* Make sure to override container entrypoint if needed for Build commands

Build commands (which could also be composite ones)
might be executed in a container different from the run or debug ones.

* Redirect output from commands handled by component.exec_handler to PID 1 process streams

This way, we can also have them displayed with `odo logs` or `kubectl logs`.
This includes Build and Devfile events commands.

* Make remotecmd#ExecuteCommand log stdout or stderr content only if there not empty

This reduces the clutter in case of an error with the command execution.

* Add integration test with more complex Devfile (composite build/run/debug commands running in different containers and with a shared volume)

* Update the 'Executing the application' spinner accordingly when the related command is done
2022-06-24 16:50:56 +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
Armel Soro
74516a9f58 Add support for command/args fields in container components (#5768)
* Introduce new 'pkg/remotecmd' package

This package allows to execute commands in remote packages
and exposes an interface for managing processes associated
to given Devfile commands.

* Rely on 'pkg/libdevfile' as much as possible for Devfile command execution

This requires passing a handler at the odo side,
which in turns uses the 'pkg/remotecmd' package to
run commands in remote containers.

* Switch to running without Supervisord as PID 1 in containers

To do this, the idea is to start the container component:
1- using the command/args defined in the Devfile
2- using whatever was defined in the container image
   if there is no command/args defined in the Devfile

Then, once the container is started, we would execute the Devfile
commands directly in the container component, just like a simple
'kubectl exec' command would do.
Since this is a long-running command (and potentially never ending),
we would need to run it in the background, i.e. in a side goroutine.

Point 2) above requires implementing a temporary hack (as discussed in [1]),
without us having to wait for [2] to be merged on the Devfile side.
This temporary hack overrides the container entrypoint with "tail -f /dev/null"
if the component defines no command or args (in which case we should have
used whatever is defined in the image, per the specification).

[1] https://github.com/redhat-developer/odo/pull/5768#issuecomment-1147190409
[2] https://github.com/devfile/registry/pull/102

* Rename K8s adapter struct 'client' field into 'kubeClient', as suggested in review

* Rename sync adapter struct 'client' fields to better distinguish between them

* Make sure messages displayed to users running 'odo dev' are the same

* Update temporary hack log message

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

* Make sure to handle process output line by line, for performance purposes

* Handle remote process output and errors in the Devfile command handler

The implementation in kubeexec.go should remain
as generic as possible

* Keep retrying remote process status until timeout, rather than just waiting for 1 sec

Now that the command is run via a goroutine,
there might be some situations where we were checking
the status just before the goroutine had a chance to start.

* Handle remote process output and errors in the Devfile command handler

The implementation in kubeexec.go should remain
as generic as possible

* Update kubeexec StopProcessForCommand implementation such that it relies on /proc to kill the parent children processes

* Ignore missing children file in getProcessChildren

* Unit-test methods in kubexec.go

* Fix missing logs when build command does not pass when running 'odo dev'

Also add integration test case

* Fix spinner status when commands passed to exec_handler do not pass

* Make sure to check process status right after stopping it

The process just stopped might take longer to exit (it might have caught
the signal and is performing additional cleanup)

* Keep retrying remote process status until timeout, rather than just waiting for 1 sec

Now that the command is run via a goroutine,
there might be some situations where we were checking
the status just before the goroutine had a chance to start.

* Fix potential deadlock when reading output from remotecmd#ExecuteCommandAndGetOutput

Rely on the same logic in ExecuteCommand

* Add more unit tests

* Remove block that used to check debug port from env info

As commented out in [1], we don't store anymore the debug port value in the ENV file.

[1] https://github.com/redhat-developer/odo/pull/5768#discussion_r893163382

* Rename 'getCommandFromFlag' into 'getCommandByName', as suggested in review

* Make remotecmd package more generic

This package no longer depends on Devfile-related packages.

* Fix comments in libdevfile.go

* Move errorIfTimeout struct field as parameter of RetryWithSchedule

This boolean is tied to the given retry schedule,
so it makes sense for it to be passed with the schedule.

* Expose a single ExecuteCommand function that returns both stdout and stderr

Co-authored-by: Philippe Martin <contact@elol.fr>
2022-06-17 10:51:02 +00:00
Anand Kumar Singh
098389b027 update go version to use go 1.17 (#5497)
* update go version to 1.17

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

* update go version to 1.17 and fix failure

Signed-off-by: anandrkskd <anandrkskd@gmail.com>
2022-04-29 12:20:35 -04:00
Philippe Martin
e42d6575e5 Fix ignores files during sync (#5689)
* fix ignore files

* Add tests for synced files

* Use go-gitignore library

* rename topPath
2022-04-26 15:12:36 -04:00
Armel Soro
06550eb233 Add additional checks to golangci-lint (#5567) (#5687)
* Document golangci-lint configuration options

* Do not limit the number of issues reported per linter

* Add check preventing the use of the deprecated 'github.com/pkg/errors' package

* Upgrade golangci-lint to 1.37.0, so we can use 'revive' Linter

- revive is a drop-in replacement for the deprecated golint Linter
- revive will allow to check for error strings

Note: We are purposely not using the latest golangci-lint (1.45.0)
but the minimum version from which revive is available.
This is because the latest 1.45.0 reports additional linting issues
(from govet and staticcheck for example). And fixing those side errors
is outside of the scope of this issue.
Also some of those issues are already fixed in #5497 (update to Go 1.17).

* Configure revive to check for error strings

More rules can be added later on if needed

* Fix issues reported by revive's error-strings rule

Some rules are purposely ignored when the
error messages represent top-level errors that are
displayed to be displayed as is to end users

* Fix more error-strings issues

For some reason, those were not reported by revive's error-strings rule,
but only by GoLand inspection tool.

* Fix missing `revive:disable:error-strings` comment directive

Also replace "fmt.Errorf" by "errors.New" when the error message is static
2022-04-25 07:32:20 -04:00
Parthvi Vala
abc4b59369 Remove references to v2 commands, remove unused functions, and constants (#5638)
* Remove references to v2 commands, remove unused functions, and constants

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

* Dharmit's review

Signed-off-by: Parthvi Vala <pvala@redhat.com>
2022-04-20 00:54:15 -04: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
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
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
Parthvi Vala
1d2cf39cf7 Delete with devfile.yaml (#5500)
Signed-off-by: Parthvi Vala <pvala@redhat.com>
2022-03-20 18:20:52 +01:00
Mohammed Ahmed
2d7c993796 Moving to use gitignore library go-gitignore (#5181)
* Adding gitignore to odo

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

* Adding indexer to file indexer

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

* Fixing file closed error

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

* Updating to simpler logic

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

* Updating path to check if its a directory

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

* Trying to fix directroy matching

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

* Adding debug stmts

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

* Adding more debug

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

* Removing unneeded code

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

* Updating logic and removing IsGlobExpMatch usage

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

* Adding back changes

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

* Moving to simpler gitignore package

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

* Removing debug stmts

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

* Removing old code

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

* Removing unnessasary code

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

* Fixing gofmt

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

* Making replace string longer to avoid clash with actual names

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

* Removing duplicate code

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

* Adding intergration test

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

* Adding orignal ignore rules as argument to file indexer funcs

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

* Updating uts as needed

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

* Removing unused function

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

* Cleanup

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>

* Updating unit tests to inlude a subdir

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

* Adding unit test for subdir ignore case

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

* Removing the now unneeded integration test

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

* Fixing gofmt

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

* Removing unneeded example

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

* Cleaning up

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

* Removing todos

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

* Removing unused consts from rebase

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
2022-03-16 10:56:22 -04: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
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
Philippe Martin
e4a65e81ed Cleanup more functions not used after removing old v2 commands (#5447)
* Remove service.FindDevfileServiceBinding

* Remove IsOperatorServiceNameValid

* Remove MapFromParameters

* Remove OperatorSvcExists

* Remove AddKubernetesComponentToDevfile

* Remove AddKubernetesComponent

* Remove DeleteKubernetesComponentFromDevfile

* Remove from kclient/operators.go

* Remove unused functions from pkg/service

* Remove Storage methods from LocalConfigProvider

* Remove unused from pkg/envinfo

* Cleanup util packages

* Remove unused code with the help of staticcheck --unused.whole-program=true -- ./...
2022-02-10 12:10:00 -05: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
cbdd829628 Use adler32 into URL name (#5238)
* Use adler32 into URL name

* Create an utility function to get Adler32 hash of a string
2021-12-03 07:58:55 +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
Parthvi Vala
6b99ec420b Fix odo overwrites devfile with flattened/resolved devfile and refactor component creation (#5199)
* refactor

* Make refactor work for existing devfile and --devfile

* Make refactor work for interactive and direct mode

* Pass tests

* Temp interface conversion

* Temp movement

* Add interface and methods

* Add rollback

* Fix failures

* Move create_refactor to create

* Attempt at fixing sonar cloud issues

* Final refactor

* Add changes requested by feloy; move conflict checks to struct methods

* Only delete devfile and .odo dir
2021-11-09 10:39:27 +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
Parthvi Vala
fc34e880dd Cleanup S2I; remove BuildConfig, LocalConfig, Imagestreams and DeploymentConfig (#5125)
* Clean LocalConfig

* Clean dc, bc, is

* Remove leftover code

* Comment the failing unit test

* Fix failing tests: part 1

* Fix failing tests: part 2

* Remove unused flag: temp

* Fix failing tests: part3

* Fix ci failures

* Rename devfile specific context

* Fix merge conflicts: remove convert.go

* Changes requested by Philippe

* Add missing changes requested by Philippe

* Fix unit test failure
2021-10-15 08:45:44 +02:00
Tomas Kral
f9baeecbb5 update devfile/library v1.2.0 (#5130)
* update devfile/library to v1.2.0

* go mod vendor

* updates to make it work with devfile/library v1.2.0

* fix tests: new error messages
2021-10-11 11:34:20 +02:00
Mohammed Ahmed
455815ba9f Updating config cmds and tests for logged out senario (#4975)
* Updating config cmds and tests for logged out senario

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

* Updating error and fixing missing error

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

* Changing to error

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

* Fixing error check

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

* Trying to not have duplicates

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

* Prevent panic on invalid kubeconfig (not path but config itself)

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

* Removing duplicates

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

* Updating tests

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

* Disabling path check for invalid kubeconfig path

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

* Fixing condition check for kubeconfig path

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

* Loggin back in with token

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

* Removing kubecinfg path check

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

* Fixiing uneedd kubeconfig set

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

* Using err and ignoring duplication warnings

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

* Adding changelog

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

* Fixing some stuff

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

* Fixing as per comments

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

* Renaming function

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

* Update pkg/util/util.go

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

* Addressing comments by dharmit

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

* Update pkg/util/util.go

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

Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>
Co-authored-by: Philippe Martin <contact@elol.fr>
2021-09-02 09:46:15 -04:00
Parthvi Vala
0312f1ba2c Send telemetry data on user interrupt (#4963)
* Send odo push telemetry data on user interrupt

* Add signal to contextual properties

* Add defer signal.Stop

* Changes requested by Philippe

* Move the signal watcher caller

* Replace an unused arg with _

* Fix arg name
2021-08-24 16:02:24 -04:00
Mrinal Das
e308b6bc8c Renames the service name to include the app name (#4858)
* Renames the service name to include the app name

* Renames route names to include the app name instead of the component

* Fixes comments and modifies the error message for some service related errors
2021-07-07 10:23:09 -04:00
Josh Soref
f4c4865a3a Correct ioutil.WriteFile comment about os.Create (#4864)
Correct incorrect comment introduced in #2660
2021-07-01 04:42:25 -04:00