-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add pvcviewer-controller rock (#154)
* Added rockcraft.yaml * Added sanity tests * Added tox.ini
- Loading branch information
Showing
3 changed files
with
142 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,61 @@ | ||
# Source https://github.com/kubeflow/kubeflow/blob/v1.9.0/components/pvcviewer-controller/Dockerfile | ||
|
||
name: pvcviewer-controller | ||
summary: An image for PVC viewer controller | ||
description: | | ||
This image is used as part of the Kubeflow ecosystem. The controller allows users to | ||
manage and view Persistent Volume Claims (PVCs) in the cluster. | ||
version: "1.9.0" | ||
license: Apache-2.0 | ||
base: ubuntu@22.04 | ||
run-user: _daemon_ | ||
platforms: | ||
amd64: | ||
|
||
services: | ||
pvcviewer-operator: | ||
override: replace | ||
summary: "pvcviewer-operator service" | ||
startup: enabled | ||
user: ubuntu | ||
command: "/manager" | ||
|
||
parts: | ||
security-team-requirement: | ||
plugin: nil | ||
override-build: | | ||
mkdir -p ${CRAFT_PART_INSTALL}/usr/share/rocks | ||
(echo "# os-release" && cat /etc/os-release && echo "# dpkg-query" && \ | ||
dpkg-query -f '${db:Status-Abbrev},${binary:Package},${Version},${source:Package},${Source:Version}\n' -W) > \ | ||
${CRAFT_PART_INSTALL}/usr/share/rocks/dpkg.query | ||
pvcviewer-operator: | ||
plugin: go | ||
source-type: git | ||
source: https://github.com/kubeflow/kubeflow.git | ||
source-depth: 1 | ||
source-tag: v1.9.0 | ||
source-subdir: components/pvcviewer-controller/ | ||
build-snaps: | ||
- go/1.22/stable | ||
build-packages: | ||
- apt | ||
- bash | ||
build-environment: | ||
- CGO_ENABLED: 0 | ||
- GOOS: linux | ||
stage-packages: | ||
- bash | ||
organize: | ||
bin/pvc-viewer: "/manager" | ||
prime: | ||
- manager | ||
|
||
non-root-user: | ||
plugin: nil | ||
after: [pvcviewer-operator] | ||
overlay-script: | | ||
# Create a user in the $CRAFT_OVERLAY chroot | ||
groupadd -R $CRAFT_OVERLAY -g 1001 ubuntu | ||
useradd -R $CRAFT_OVERLAY -M -r -u 1001 -g ubuntu ubuntu | ||
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,30 @@ | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
import pytest | ||
import subprocess | ||
|
||
from charmed_kubeflow_chisme.rock import CheckRock | ||
|
||
|
||
@pytest.mark.abort_on_fail | ||
def test_rock(): | ||
"""Test rock.""" | ||
check_rock = CheckRock("rockcraft.yaml") | ||
rock_image = check_rock.get_name() | ||
rock_version = check_rock.get_version() | ||
LOCAL_ROCK_IMAGE = f"{rock_image}:{rock_version}" | ||
|
||
subprocess.run( | ||
[ | ||
"docker", | ||
"run", | ||
"--rm", | ||
LOCAL_ROCK_IMAGE, | ||
"exec", | ||
"ls", | ||
"-la", | ||
"/manager", | ||
], | ||
check=True, | ||
) |
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,51 @@ | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
[tox] | ||
skipsdist = True | ||
skip_missing_interpreters = True | ||
envlist = pack, export-to-docker, sanity, integration | ||
|
||
[testenv] | ||
setenv = | ||
PYTHONPATH={toxinidir} | ||
PYTHONBREAKPOINT=ipdb.set_trace | ||
|
||
[testenv:pack] | ||
passenv = * | ||
allowlist_externals = | ||
rockcraft | ||
commands = | ||
rockcraft pack | ||
|
||
[testenv:export-to-docker] | ||
passenv = * | ||
allowlist_externals = | ||
bash | ||
skopeo | ||
yq | ||
commands = | ||
# export rock to docker | ||
bash -c 'NAME=$(yq eval .name rockcraft.yaml) && \ | ||
VERSION=$(yq eval .version rockcraft.yaml) && \ | ||
ARCH=$(yq eval ".platforms | keys | .[0]" rockcraft.yaml) && \ | ||
ROCK="$\{NAME\}_$\{VERSION\}_$\{ARCH\}.rock" && \ | ||
DOCKER_IMAGE=$NAME:$VERSION && \ | ||
echo "Exporting $ROCK to docker as $DOCKER_IMAGE" && \ | ||
skopeo --insecure-policy copy oci-archive:$ROCK docker-daemon:$DOCKER_IMAGE' | ||
|
||
[testenv:sanity] | ||
passenv = * | ||
deps = | ||
pytest | ||
charmed-kubeflow-chisme | ||
commands = | ||
# run rock tests | ||
pytest -s -v --tb native --show-capture=all --log-cli-level=INFO {posargs} {toxinidir}/tests | ||
|
||
[testenv:integration] | ||
passenv = * | ||
allowlist_externals = | ||
echo | ||
commands = | ||
# TODO: Implement integration tests here | ||
echo "WARNING: This is a placeholder test - no test is implemented here." |