fabric8-tenant

command module
v0.0.0-...-bf90f01 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2020 License: Apache-2.0 Imports: 29 Imported by: 0

README

= Fabric8 Tenant Service

image:https://ci.centos.org/buildStatus/icon?job=devtools-fabric8-tenant-build-master[Jenkins,link="https://ci.centos.org/view/Devtools/job/devtools-fabric8-tenant-build-master/lastBuild/"]
image:https://goreportcard.com/badge/github.com/fabric8-services/fabric8-tenant[Go Report Card, link="https://goreportcard.com/report/github.com/fabric8-services/fabric8-tenant"]
image:https://godoc.org/github.com/fabric8-services/fabric8-tenant?status.png[GoDoc,link="https://godoc.org/github.com/fabric8-services/fabric8-tenant"]
image:https://codecov.io/gh/fabric8-services/fabric8-tenant/branch/master/graph/badge.svg[Codecov.io,link="https://codecov.io/gh/fabric8-services/fabric8-tenant"]


== Service for initializing and updating the tenant services in fabric8/openshift.io

=== Template YAML files

All template YAML files and YAML files containing resource quotas and limits are located in link:environment/templates/[] directory.
Every template uses the same versioning system - the version is stored as a label called `version` and is equal to a short version of `SHA` of the latest commit that changes the particular file.

==== In-production testing

To be able to use the in-production testing feature, you need to have the `Internal Experimental Features` toggle activated. To do that:

* visit http://openshift.io/ and login
* go to https://openshift.io/_profile/_settings/feature-opt-in
* check `Internal Experimental Features` option

===== Pull request

When a PR is made on one of the YAML files you can test in production in your tenant via the following:

* http://openshift.io/ and login
* go to https://openshift.io/_profile/_tenant
* enter the `SHA` of the latest commit in your PR as the "Repository blob SHA"
* check `Auto-update your tenant`
* click `Save and Update Tenant` - your tenant should now be updating/running namespaces using the files from your PR
* the version (label) inside of the updated tenant namespaces is set to the blob `SHA` that was set in the form

===== Without creating a pull request

If it is needed to test templates without submitting a PR, you can do in a similar way as in case of PR, but on the https://openshift.io/_profile/_tenant page, you have to also specify the name of the repository and path to the directory where the templates are stored. The blob SHA is mandatory even if it should be taken from the master branch.

===== Reset back

To go back to using the default YAML:

* go back to your tenant page like https://openshift.io/_profile/_tenant
* click `Clear Values`
* check `Auto-update your tenant`
* click `Save and Update Tenant` - and you should be back to the default versions

=== Development

==== Prerequisites

* git
* make
* go (tested with go 1.10.2)

==== How to build

Get the project:
```
$ git clone https://github.com/fabric8-services/fabric8-tenant $GOPATH/src/github.com/fabric8-services/fabric8-tenant
$ cd $GOPATH/src/github.com/fabric8-services/fabric8-tenant
```
Build the project:
```
$ make
```

==== Run unit tests


Clean and generate objects (to have the latest version of the generated files in case of any changes since the last run):
```
$ make clean && make generate
```

Check any dependency changes:
```
$ make deps
```

Run tests (without code coverage):
```
$ make test-unit-no-coverage
```

==== Run integration tests

You can do the same clean, generate and fetch the dependencies as it is suggested for unit tests:
```
$ make clean && make generate && make deps
```

Start the DB:
```
$ make integration-test-env-prepare
```

Run all integration tests (without code coverage):
```
$ make test-migration && make test-integration-no-coverage && make test-remote-no-coverage
```

To stop DB:
```
$ make integration-test-env-tear-down
```

==== Run Minishift integration tests

Follow the instruction from <<Run integration tests>> to make sure you have DB running
Start https://github.com/minishift/minishift[Minishift] (if it is not running already):
```
$ minishift start
```

https://docs.okd.io/latest/minishift/using/addons.html#installing-addons[Install] and https://docs.okd.io/latest/minishift/using/addons.html#apply-addons[apply] the https://docs.okd.io/latest/minishift/using/addons.html#default-addons[admin-user] Minishift addon.
The reason is that we need to use a user (admin) with cluster-admin rights for creating/updating/deleting namespaces.
```
$ minishift addons apply admin-user
```

Run Minishift integration tests. Some of the tests may take a longer time to finish
```
$ make test-with-minishift
```

NOTE: These minishift integration tests create a new user for every run using a format `tenant.minishift.test.$(date +'%H.%M.%S')`. It is possible to use a specific already created one by setting a variable `MINISHIFT_USER_NAME` to the name of the intended user.
The test-cases then create,update and delete namespaces, but it can happen that the proper cleanup is not correctly performed at the end of each test.
To remove all namespaces starting with `tenant-minishift-test-\*` please use `$ make clean-minishift-namespaces`. To remove all users starting with `tenant.minishift.test.*` please use `$ make clean-minishift-users`. To remove both users and namespaces use `$ make clean-minishift`.

==== Run all tests

Expecting that the DB is running (see <<Run integration tests>>) you can trigger all tests by a command:
```
make test-all
```

==== Code formatting

To check if the code is properly formatted run:
```
$ make check-go-format
```

To format the code:
```
$ make format-go-code
```

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package configuration is in charge of the validation and extraction of all the configuration details from a configuration file.
Package configuration is in charge of the validation and extraction of all the configuration details from a configuration file.
resource
Package resource is used to manage which tests shall be executed.
Package resource is used to manage which tests shall be executed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL