-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from canonical/initial-implementation
Initial implementation
- Loading branch information
Showing
19 changed files
with
2,405 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Description | ||
|
||
Please include a summary of the change. Please also include relevant motivation and context. List any dependencies that are required for this change. | ||
|
||
# Checklist: | ||
|
||
- [ ] My code follows the [style guidelines](/CONTRIBUTING.md) of this project | ||
- [ ] I have performed a self-review of my own code | ||
- [ ] I have made corresponding changes to the documentation | ||
- [ ] I have added tests that validate the behaviour of the software | ||
- [ ] I validated that new and existing unit tests pass locally with my changes | ||
- [ ] Any dependent changes have been merged and published in downstream modules | ||
- [ ] I have bumped the version of the library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# For most projects, this workflow file will not need changing; you simply need | ||
# to commit it to your repository. | ||
# | ||
# You may wish to alter this file to override the set of languages analyzed, | ||
# or to provide custom queries or build logic. | ||
# | ||
# ******** NOTE ******** | ||
# We have attempted to detect the languages in your repository. Please check | ||
# the `language` matrix defined below to confirm you have the correct set of | ||
# supported CodeQL languages. | ||
# | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [ "main" ] | ||
schedule: | ||
- cron: '25 13 * * 0' | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: [ 'python' ] | ||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] | ||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
# Initializes the CodeQL tools for scanning. | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: ${{ matrix.language }} | ||
# If you wish to specify custom queries, you can do so here or in a config file. | ||
# By default, queries listed here will override any specified in a config file. | ||
# Prefix the list here with "+" to use these queries and those in the config file. | ||
|
||
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs | ||
# queries: security-extended,security-and-quality | ||
|
||
|
||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). | ||
# If this step fails, then you should remove it and run the build manually (see below) | ||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v2 | ||
|
||
# ℹ️ Command-line programs to run using the OS shell. | ||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun | ||
|
||
# If the Autobuild fails above, remove it and uncomment the following three lines. | ||
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. | ||
|
||
# - run: | | ||
# echo "Run, Build Application using script" | ||
# ./location_of_script_within_repo/buildscript.sh | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 | ||
with: | ||
category: "/language:${{matrix.language}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
lint-report: | ||
name: Lint report | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install tox | ||
run: pip install tox | ||
- name: Run tests using tox | ||
run: tox -e lint | ||
|
||
static-analysis: | ||
name: Static analysis | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install tox | ||
run: pip install tox | ||
- name: Run tests using tox | ||
run: tox -e static | ||
|
||
unit-tests-with-coverage: | ||
name: Unit tests | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install tox | ||
run: pip install tox | ||
- name: Run tests using tox | ||
run: tox -e unit | ||
|
||
integration-test: | ||
name: Integration tests | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup LXD | ||
uses: canonical/setup-lxd@main | ||
with: | ||
channel: 5.12/stable | ||
- name: Setup operator environment | ||
uses: charmed-kubernetes/actions-operator@main | ||
with: | ||
provider: microk8s | ||
- name: Run integration tests | ||
run: tox -e integration | ||
- name: Archive Tested Charm | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ github.ref_name == 'main' }} | ||
with: | ||
name: tested-charm | ||
path: .tox/**/httpreq-acme-operator_ubuntu-22.04-amd64.charm | ||
retention-days: 5 | ||
- name: Archive charmcraft logs | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: charmcraft-logs | ||
path: /home/runner/.local/state/charmcraft/log/*.log | ||
- name: Archive juju crashdump | ||
if: failure() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: juju-crashdump | ||
path: juju-crashdump-*.tar.xz | ||
|
||
publish-charm: | ||
name: Publish Charm | ||
needs: | ||
- lint-report | ||
- static-analysis | ||
- unit-tests-with-coverage | ||
- integration-test | ||
runs-on: ubuntu-22.04 | ||
if: ${{ github.ref_name == 'main' }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install charmcraft | ||
run: sudo snap install charmcraft --classic | ||
- name: Fetch Tested Charm | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: tested-charm | ||
- name: Move charm in current directory | ||
run: find ./ -name httpreq-acme-operator_ubuntu-22.04-amd64.charm -exec mv -t ./ {} \; | ||
- name: Select Charmhub channel | ||
uses: canonical/charming-actions/channel@2.2.5 | ||
id: channel | ||
- name: Upload charm to Charmhub | ||
uses: canonical/charming-actions/upload-charm@2.2.5 | ||
with: | ||
credentials: "${{ secrets.CHARMHUB_TOKEN }}" | ||
github-token: "${{ secrets.GITHUB_TOKEN }}" | ||
channel: "${{ steps.channel.outputs.name }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Promote Charm | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
promotion: | ||
type: choice | ||
description: Channel to promote from | ||
options: | ||
- edge -> beta | ||
- beta -> candidate | ||
- candidate -> stable | ||
|
||
jobs: | ||
promote: | ||
name: Promote Charm | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set target channel | ||
env: | ||
PROMOTE_FROM: ${{ github.event.inputs.promotion }} | ||
run: | | ||
if [ "${PROMOTE_FROM}" == "edge -> beta" ]; then | ||
echo "promote-from=edge" >> ${GITHUB_ENV} | ||
echo "promote-to=beta" >> ${GITHUB_ENV} | ||
elif [ "${PROMOTE_FROM}" == "beta -> candidate" ]; then | ||
echo "promote-from=beta" >> ${GITHUB_ENV} | ||
echo "promote-to=candidate" >> ${GITHUB_ENV} | ||
elif [ "${PROMOTE_FROM}" == "candidate -> stable" ]; then | ||
echo "promote-from=candidate" >> ${GITHUB_ENV} | ||
echo "promote-to=stable" >> ${GITHUB_ENV} | ||
fi | ||
- name: Promote Charm | ||
uses: canonical/charming-actions/release-charm@2.2.5 | ||
with: | ||
base-channel: 22.04 | ||
credentials: ${{ secrets.CHARMHUB_TOKEN }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
destination-channel: latest/${{ env.promote-to }} | ||
origin-channel: latest/${{ env.promote-from }} | ||
charmcraft-channel: latest/stable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
venv/ | ||
build/ | ||
*.charm | ||
|
||
.coverage | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
.tox/ | ||
|
||
.idea/ | ||
|
||
### VisualStudioCode ### | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
*.code-workspace | ||
|
||
# Local History for Visual Studio Code | ||
.history/ | ||
|
||
### VisualStudioCode Patch ### | ||
# Ignore all local history of files | ||
.history | ||
.ionide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Contributing | ||
|
||
To make contributions to this charm, you'll need a working [development setup](https://juju.is/docs/sdk/dev-setup). | ||
|
||
You can use the environments created by `tox` for development: | ||
|
||
```shell | ||
tox --notest -e unit | ||
source .tox/unit/bin/activate | ||
``` | ||
|
||
## Testing | ||
|
||
This project uses `tox` for managing test environments. There are some pre-configured environments | ||
that can be used for linting and formatting code when you're preparing contributions to the charm: | ||
|
||
```shell | ||
tox -e lint # code style | ||
tox -e static # static analysis | ||
tox -e unit # unit tests | ||
tox -e integration # integration tests | ||
tox # runs 'lint' and 'unit' environments | ||
``` | ||
|
||
|
||
## Build | ||
Building and publishing charms is done using charmcraft (official documentation | ||
[here](https://juju.is/docs/sdk/publishing)). You can install charmcraft using `snap`: | ||
|
||
```bash | ||
sudo snap install charmcraft --channel=classic | ||
``` | ||
|
||
Initialize LXD: | ||
|
||
```bash | ||
lxd init --auto | ||
``` | ||
|
||
Go to the charm directory and run: | ||
|
||
```bash | ||
charmcraft pack | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# httpreq-acme-operator | ||
|
||
## Description | ||
|
||
ACME operator implementing the provider side of the `tls-certificates` | ||
interface to get signed certificates from the `Let's Encrypt` ACME server | ||
using the HTTP Request plugin for DNS-01 challenge. | ||
|
||
# Pre-requisites | ||
|
||
This charm is a provider of the [`tls-certificates-interface`](https://github.com/canonical/tls-certificates-interface), | ||
charms that require Let's Encrypt certificates need to implement the requirer side. | ||
|
||
This operator targets a custom implementation of an API defined in | ||
[`go-acme lego documentation`](https://go-acme.github.io/lego/dns/httpreq/). | ||
This custom API needs be implemented for you particular use case and its URL | ||
provided to as a configuration to this operator. | ||
|
||
## Usage | ||
|
||
Create a YAML configuration file with the following fields: | ||
|
||
```yaml | ||
httpreq-acme-operator: | ||
email: <Account email address> | ||
httpreq_endpoint: <HTTP/HTTPS URL> | ||
``` | ||
|
||
Deploy `httpreq-acme-operator`: | ||
|
||
```bash | ||
juju deploy httpreq-acme-operator --config <yaml config file> | ||
``` | ||
|
||
Relate it to a `tls-certificates-requirer` charm: | ||
|
||
```bash | ||
juju relate httpreq-acme-operator:certificates <tls-certificates-requirer> | ||
```` | ||
|
||
## Config | ||
|
||
### Required configuration properties | ||
|
||
- email: Let's Encrypt email address | ||
- httpreq_endpoint: HTTP/HTTPS URL to the service implementing the HTTPREQ API | ||
### Optional configuration properties | ||
- server: Let's Encrypt server to use (default: `https://acme-v02.api.letsencrypt.org/directory`) | ||
- httpreq_http_timeout: API request timeout | ||
- httpreq_mode: "'RAW' or None" | ||
- httpreq_password: Basic authentication password | ||
- httpreq_polling_interval: Time between DNS propagation checks | ||
- httpreq_propagation_timeout: Maximum waiting time for DNS propagation | ||
- httpreq_username: Basic authentication username | ||
|
||
## Relations | ||
|
||
- `certificates`: `tls-certificates-interface` provider | ||
|
||
## OCI Images | ||
|
||
- [Lego Rock Image](https://github.com/canonical/lego-rock) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
type: "charm" | ||
bases: | ||
- build-on: | ||
- name: "ubuntu" | ||
channel: "22.04" | ||
run-on: | ||
- name: "ubuntu" | ||
channel: "22.04" | ||
|
||
parts: | ||
charm: | ||
build-packages: | ||
- libffi-dev | ||
- libssl-dev | ||
- rustc | ||
- cargo | ||
- pkg-config |
Oops, something went wrong.