Skip to content

Commit

Permalink
Document .gitignore and .odoignore usage
Browse files Browse the repository at this point in the history
  • Loading branch information
feloy committed Apr 19, 2023
1 parent 7f25f0c commit a6c32bc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/website/docs/development/architecture/how-odo-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -732,12 +732,13 @@ spec:
As mentioned in [how `odo dev` works](#how-odo-dev-works), `odo` is able to perform a one-way synchronization of the local source code, i.e., from the developer machine to the development pod running in the cluster.
This is done via a Volume, named `odo-projects`, mounted in the container.

However, this is subject to two things:
However, this is subject to three things:
- the value of the `mountSources` flag (default value is `true`) in the Devfile container component. Project sources are not mounted in the container if this is set to `false`.
Note that odo requires at least one component in the Devfile to set `mountSources: true` in order to synchronize files.
- the type of volume created depends on the [configuration of `odo`](../../overview/configure#preference-key-table), and more specifically on the value of the `Ephemeral` setting:
- if `Ephemeral` is `false`, which is the default setting, `odo` creates a [PersistentVolumeClaim](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) (PVC) (with the default storage class)
- if `Ephemeral` is `true`, `odo` creates an [`emptyDir`](https://kubernetes.io/docs/concepts/storage/volumes/#emptydir) volume, tied to the lifetime of the Pod.
- the complete content of the current directory and its sub-directories is pushed to the container, except the files listed in the `.odoignore` file, or, if this file is not present, in the `.gitignore` file. `dev.odo.push.path:target` attributes are also considered to push only selected files. See [Pushing Source Files](../../user-guides/advanced/pushing-specific-files) for more details.

| Volume name | Volume Type | Mount Path | Description |
|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|-----------------------------------------------|
Expand Down
22 changes: 21 additions & 1 deletion docs/website/docs/user-guides/advanced/pushing-specific-files.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
---
title: Only Push Specific Files
title: Pushing Source Files
sidebar_position: 2
---

During the execution of `odo dev`, the files of the current directory and its sub-directories are pushed
to the container. You can influence which files are pushed with the following methods.


## Pushing only specific files

`odo` uses the `dev.odo.push.path` related attribute from the devfile's run commands to push only the specified files and folders to the component.

The format of the attribute is `"dev.odo.push.path:<local_relative_path>": "<remote_relative_path>"`. We can mention multiple such attributes in the run command's `attributes` section.
Expand Down Expand Up @@ -40,3 +47,16 @@ commands:
In the above example the contents of the `quarkus-app` folder, which is inside the `target` folder, will be pushed to the remote location of `remote-target/quarkus-app` and the file `README.txt` will be pushed to `doc/README.txt`.
The local path is relative to the component's local folder. The remote location is relative to the folder containing the component's source code inside the container.

## Ignoring files to push

`odo` excludes from the push the files present in the `.odoignore` file, or, if
this file does not exist, the files present in the `.gitignore` file.

By default, `odo` does not create a `.odoignore` file and relies on the `.gitignore` file.
Also, during each execution, `odo dev` adds the `.odo` entry to the `.gitignore` file if it is not already present in this file,
to avoid an infinite loop on the synchronization, this directory containing a file with the state of the sync.

If you want to use the `.odoignore` file instead, to have a different set of files ignored for sync and ignored for git,
you will need to add the `.odo` directory to the `.odoignore` file.

0 comments on commit a6c32bc

Please sign in to comment.