Skip to content

Commit

Permalink
Merge pull request #982 from alesstimec/backport-charm-changes-from-f…
Browse files Browse the repository at this point in the history
…eature-rebac

CSS-4547 Backports charm changes from feature-rebac into main.
  • Loading branch information
alesstimec committed Jul 3, 2023
2 parents ba68eaa + a34498c commit b8373d8
Show file tree
Hide file tree
Showing 48 changed files with 13,811 additions and 659 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/charm-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
uses: ./.github/workflows/charm-build.yaml

lint:
# Delete this if statement once charms are updated and include tox.
if: ${{ 1 }} == ${{ 2 }}
name: Lint
runs-on: ubuntu-latest
strategy:
Expand All @@ -29,8 +27,6 @@ jobs:
- name: Run linters
run: tox -e lint
unit-tests:
# Delete this if statement once charms are updated and include tox.
if: ${{ 1 }} == ${{ 2 }}
name: Unit tests
runs-on: ubuntu-latest
strategy:
Expand Down
3 changes: 2 additions & 1 deletion charms/jimm-k8s/.flake8
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[flake8]
max-line-length = 99
max-line-length = 120
select: E,W,F,C,N
exclude:
venv
.git
build
dist
*.egg_info
ignore = W503
71 changes: 53 additions & 18 deletions charms/jimm-k8s/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,64 @@
# jimm
# Contributing

## Overview

This documents explains the processes and practices recommended for contributing enhancements to
this operator.

- If you would like to chat with us about your use-cases, you can reach
us at [Discourse](https://chat.charmhub.io/charmhub/channels/jaas).
- Familiarising yourself with the [Charmed Operator Framework](https://juju.is/docs/sdk) library
will help you a lot when working on new features or bug fixes.
- All enhancements require review before being merged. Code review typically examines
- code quality
- test coverage
- user experience for Juju administrators this charm.
- Please help us out in ensuring easy to review branches by rebasing your pull request branch onto
the `main` branch. This also avoids merge commits and creates a linear Git commit history.

## Developing

Create and activate a virtualenv with the development requirements:
You can create an environment for development with `tox`:

```shell
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements-dev.txt
pip install tox
```

The charm additionally requires the following relations:
- ingress, interface: ingress
- database, interface: postgresql_client
- vault, interface: vault-kv
- certificates, interface: tls-certificates

virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements-dev.txt
### Testing

## Intended use case
```shell
tox -e fmt # update your code according to linting rules
tox -e lint # code style
tox -e unit # unit tests
tox -e integration # integration tests
tox # runs 'lint' and 'unit' environments
```

This JIMM operator charm is intended for deploying the
Juju Intelligent Model Manager in a k8s cluster. The charm
does not use relations to connect to postgresql and/or
vault as it is assumed those services could be deployed
in a different model.

## Roadmap
## Build charm

* Add postgresql relation
* Add vault relation (when a k8s vault charm becomes available)
Build the charm in this git repository using:

## Testing
```shell
charmcraft pack
```

The Python operator framework includes a very nice harness for testing
operator behaviour without full deployment. Just `run_tests` :
### Deploy

./run_tests
```bash
# Create a model
juju add-model dev
# Enable DEBUG logging
juju model-config logging-config="<root>=INFO;unit=DEBUG"
# Deploy the charm
juju deploy ./juju-jimm-k8s_ubuntu-22.04-amd64.charm
```
24 changes: 21 additions & 3 deletions charms/jimm-k8s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ Create and activate a virtualenv with the development requirements:
## Testing

The Python operator framework includes a very nice harness for testing
operator behaviour without full deployment. Just `run_tests` :

./run_tests
operator behaviour without full deployment. The test suite can be run
using `tox`. You can either `pip install tox` system-wide or create a
virtual env and install tox there as follows
```
python3 -m venv venv
source ./venv/bin/activate
pip install tox
```
At this point you can run tests/linters/formatters.
```
tox -e fmt
tox -e lint
tox -e unit
tox -e integration
```
Note that integration tests will build the charm and deploy it to a local
microk8s controller (which must be setup prior to running the integration test).
To switch the integration test to use a locally built charm use
```
tox -e integration -- --localCharm
```
1 change: 0 additions & 1 deletion charms/jimm-k8s/actions.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Copyright 2022 Canonical Ltd
# See LICENSE file for licensing details.

20 changes: 16 additions & 4 deletions charms/jimm-k8s/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ type: "charm"
parts:
charm:
charm-python-packages: [setuptools]
charm-binary-python-packages:
- cryptography
- jsonschema
- PyYAML
- attrs
- importlib-resources
- urllib3
- zipp
bases:
# This run-on is not as strict as the machine charm
# as the jimm-server runs in a container.
# So the only restriction for build-on vs run-on is
# the charm code.
- build-on:
- name: "ubuntu"
channel: "20.04"
- name: "ubuntu"
channel: "20.04"
run-on:
- name: "ubuntu"
channel: "20.04"
- name: "ubuntu"
channel: "20.04"
15 changes: 3 additions & 12 deletions charms/jimm-k8s/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ options:
description: |
Whitespace separated list of candid users (or groups) that are
made controller admins by default.
dns-name:
type: string
description: Public DNS hostname that JIMM is being served from.
log-level:
type: string
description: |
Expand All @@ -53,16 +50,10 @@ options:
uuid:
type: string
description: The UUID advertised by the JIMM controller.
vault-url:
type: string
description: Vault URL.
vault-role-id:
type: string
description: Vault Role ID.
vault-token:
type: string
description: Vault Token.
juju-dashboard-location:
type: string
default: https://jaas.ai/models
description: URL of the Juju Dashboard for this controller.
dns-name:
type: string
description: DNS hostname that JIMM is being served from.
Loading

0 comments on commit b8373d8

Please sign in to comment.