github.com/argoproj-labs/argocd-operator@v0.10.0/docs/developer-guide/development.md (about)

     1  
     2  # Development
     3  
     4  ### Requirements
     5  
     6  The requirements for building the operator are fairly minimal.
     7  
     8   * Go 1.16+
     9   * Operator SDK 1.11.0+
    10   * Bash or equivalent
    11   * Docker
    12   
    13  ### Building from Source
    14  
    15  The `Makefile` in the root directory contains several targets to build and release the operator binaries from source.
    16  
    17  #### Environment
    18  
    19  The `Makefile` defines several variables to control the names of the images to build and push.
    20  These variables can either be set as environment variables, or specified when invoking `make`.
    21  
    22   * `IMG` is the image URL to use all building/pushing image targets.
    23   * `BUNDLE_IMG` defines the image:tag used for the bundle.
    24  
    25  Have a look `Makefile` for all of the variables and how they are used.
    26  
    27  ### Build
    28  
    29  Use the following make target to build the operator. A container image wil be created locally. The name of the image is specified by the `IMG` variable defined in the `Makefile`.
    30  
    31  ``` bash
    32  make docker-build
    33  ```
    34  
    35  ### Release
    36  
    37  Push a locally created container image to a container registry for deployment.  The name of the image is specified by the `IMG` variable defined in the `Makefile`.
    38  
    39  ``` bash
    40  make docker-push
    41  ```
    42  
    43  ### Bundle
    44  
    45  Create and push the bundle image for to use the operator in OLM as a CatalogSource. 
    46  
    47  ``` bash
    48  make bundle-build bundle-push
    49  ```
    50  To override the name of the bundle image, specify the `BUNDLE_IMG` tag, for example
    51  
    52  ``` bash
    53  make bundle-build bundle-push BUNDLE_IMG=quay.io/my-org/argocd-operator-bundle:latest
    54  ```
    55  
    56  ### [WIP] Development Process
    57  
    58  This is the basic process for development. First, create a branch for the new feature or bug fix.
    59  
    60  ``` bash
    61  git switch -c MY_BRANCH
    62  ```
    63  
    64  #### Building and testing locally
    65  
    66  To run the operator locally on your machine (outside a container), invoke the following make target:
    67  
    68  ``` bash
    69  make install run
    70  ```
    71  
    72  This will install the CRDs into your cluster, then run the operator on your machine.
    73  
    74  To run the unit tests, invoke the following make target:
    75  
    76  ``` bash
    77  make test
    78  ```
    79  
    80  Run the e2e tests.
    81  
    82  Refer E2E test [guide](../e2e-test-guide.md) for the setup and execution.
    83  
    84  ```bash
    85  k3d cluster create --servers 3
    86  ```
    87  
    88  #### Building the operator images to test on a cluster
    89  
    90  Build the development container image.
    91  Override the name of the image to build by specifying the `IMG` variable.
    92  
    93  ``` bash
    94  make docker-build IMG=quay.io/my-org/argocd-operator:latest
    95  ```
    96  
    97  Push the development container image.
    98  Override the name of the image to push by specifying the `IMG` variable.
    99  
   100  ``` bash
   101  make docker-push IMG=quay.io/my-org/argocd-operator:latest
   102  ```
   103  
   104  Generate the bundle artifacts.
   105  Override the name of the development image by specifying the `IMG` variable.
   106  
   107  ``` bash
   108  rm -fr bundle/
   109  make bundle IMG=quay.io/my-org/argocd-operator:latest
   110  ```
   111  
   112  Build and push the development bundle image.
   113  Override the name of the bundle image by specifying the `BUNDLE_IMG` variable.
   114  
   115  ``` bash
   116  make bundle-build BUNDLE_IMG=quay.io/my-org/argocd-operator-bundle:latest
   117  make bundle-push BUNDLE_IMG=quay.io/my-org/argocd-operator-bundle:latest
   118  ```
   119  
   120  Build and push the development catalog image.
   121  Override the name of the catalog image by specifying the `CATALOG_IMG` variable.
   122  Specify the bundle image to include using the `BUNDLE_IMG` variable
   123  
   124  ``` bash
   125  make catalog-build BUNDLE_IMG=quay.io/my-org/argocd-operator-bundle:latest CATALOG_IMG=quay.io/my-org/argocd-operator-index:latest
   126  make catalog-push CATALOG_IMG=quay.io/my-org/argocd-operator-index:latest
   127  ```
   128  
   129  ### Build and Verify Argo CD Operator Docs
   130  
   131  **Note**: Please note that you need to have `Python3` Installed as a prerequisite.
   132  
   133  Create a Python Virtual Environment. This is not mandatory, you can continue without creating a Virtual Environment as well.
   134  
   135  ```bash
   136  python3 -m venv doc
   137  ```
   138  
   139  Get into the virtual environment, if you have created one using the above step.
   140  
   141  ```bash
   142  source doc/bin/activate
   143  ```
   144  
   145  Install the required Python libraries
   146  
   147  ```bash
   148  pip3 install mkdocs
   149  pip3 install mkdocs-material
   150  ```
   151  
   152  Start the `mkdocs` server locally to verify the UI changes.
   153  
   154  ```bash
   155  mkdocs serve
   156  ```
   157  
   158  ### Default Argo CD Version
   159  
   160  There are several steps required to update the default version of Argo CD that is installed by the operator.
   161  
   162  #### CRDs
   163  
   164  The operator bundles and provides the CRDs that are used by Argo CD to ensure that they are present in the cluster.
   165  
   166  Update the [CRDs][argocd_upstream_crds] from the upstream Argo CD project in the `config/crd/bases` directory to ensure they match the version of Argo CD that will be used as the default.
   167  
   168  [podman_link]:https://podman.io
   169  [argocd_upstream_crds]:https://github.com/argoproj/argo-cd/tree/master/manifests/crds
   170  
   171  #### Container Image
   172  
   173  Update the constant that contains the hash that corresponds to the version of Argo CD that should be deployed by default. This can be found in the `common/defaults.go` file.
   174  
   175  ```go
   176  ArgoCDDefaultArgoVersion = "sha256:abc123..."
   177  ```