Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix delete metadata filters #179

Merged
merged 3 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions hack/e2e.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ test.serial("E2E: `pepr deploy`", async t => {
stdio: "inherit",
});


// Check the controller logs
const logs = await getPodLogs("pepr-system", "app=pepr-static-test")
t.is(logs.includes("File hash matches, running module"), true);
t.is(logs.includes("Capability hello-pepr registered"), true);
t.is(logs.includes("CM with label 'change=by-label' was deleted."), true);
t.log("Validated controller logs");

t.pass();
} catch (e) {
t.fail(e.message);
Expand Down Expand Up @@ -340,3 +348,23 @@ async function waitForSecret(namespace, name) {
function delay2Secs() {
return new Promise(resolve => setTimeout(resolve, 2000));
}


async function getPodLogs(namespace, labelSelector) {
let allLogs = '';

try {
const res = await k8sCoreApi.listNamespacedPod(namespace, undefined, undefined, undefined, undefined, labelSelector);
const pods = res.body.items;

for (const pod of pods) {
const podName = pod.metadata.name;
const log = await k8sCoreApi.readNamespacedPodLog(podName, namespace);
allLogs += log.body;
}
} catch (err) {
console.error('Error: ', err);
}

return allLogs;
}
7 changes: 7 additions & 0 deletions src/cli/init/templates/capabilities/hello-pepr.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Capability,
Log,
PeprRequest,
RegisterKind,
a,
Expand Down Expand Up @@ -105,6 +106,12 @@ When(a.ConfigMap)
request.SetAnnotation("pepr.dev", "making-waves");
});

// This action will log an entry when a CM with the label `change=by-label` is deleted
When(a.ConfigMap)
.IsDeleted()
.WithLabel("change", "by-label")
.Then(() => Log.info("CM with label 'change=by-label' was deleted."));

/**
* ---------------------------------------------------------------------------------------------------
* CAPABILITY ACTION (CM Example 4) *
Expand Down
75 changes: 0 additions & 75 deletions src/fixtures/data/cm1.json

This file was deleted.

File renamed without changes.
Loading