Skip to content

Instantly share code, notes, and snippets.

View darkowlzz's full-sized avatar

Sunny darkowlzz

  • ‏‏‏‏‎ ‎
View GitHub Profile
@darkowlzz
darkowlzz / controller-patterns.md
Last active March 24, 2023 20:19
controller-patterns (flux)

Controller Patterns

This document describes some controller patterns built on top of the controller-runtime/kubebuilder tooling to help simplify how the controller code is written and organized. It does that by creating some abstractions and patterns to reduce the cognitive load while reading and writing controller code. Some of these are inspired by the ideas from the cluster API (CAPI) controllers, modified to fit the needs of flux controllers because of the differences in the domain of operations. Familiarity with controller code structure created by the kubebuilder scaffold is assumed.

kstatus conditions

The [kstatus document][kstatus_doc] describes a few concepts related to the status conditions and a few standard conditions that controllers can implement. This document tries to provide more details about the status conditions with various examples to describe the mechanics of how the conditions work, what they mean and what we can expected from them.

Starting with an example of status conditions:

kstatus - conditions and generations check

This document describes how the checker tool (CLI and library) can perform Kubernetes object status conditions and generations check as per [kstatus][kstatus_doc].

Before running the tests, the checker is provided with some context about the controller:

  • The status conditions it supports with their polarity and priority of the conditions.
@darkowlzz
darkowlzz / results-of-reconciliation.md
Created February 10, 2022 15:05
Results of Reconciliation (draft)

Results of Reconciliation

In a controller, a reconciliation loop execution performs some domain specific operations to eliminate any drift in the declared configuration and the state of the world. Usually, the result of the core operations of the reconciliation is directly a change in the world based on the declared configuration. Other results of the reconciliation are the reported status on the object, ctrl.Result value and any error during the reconciliation. The ctrl.Result and error are runtime results, and the reported status is an API change result on the target object. Based on the controller-patterns(flux) document, the core

Keybase proof

I hereby claim:

  • I am darkowlzz on github.
  • I am darkowlzz (https://keybase.io/darkowlzz) on keybase.
  • I have a public key whose fingerprint is A11B 7A23 3C47 6999 2452 C961 4322 DE32 A726 C94E

To claim this, I am signing this object:

Handlebars.registerHelper("linkify", function (message) {
function doIt(match) {
return "<a target='_blank' href='" + match + "'>" + match + "</a>";
};
console.log("linkifying...");
console.log("here: " + message.replace(REGEX, doIt));
return new Handlebars.SafeString(message.replace(REGEX, doIt));
});
var mystring = "hey there, here is the link http://www.mozilla.org yah!";
REGEX = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
function doIt(match) {
return "<a href='" + match + "'> " + match + "</a>";
}
console.log(mystring.replace(REGEX, doIt));
main.js
=======
const sp = require("sdk/simple-prefs");
const keys = require("keys");
sp.on("hotkey", keys.hotkeyCheck(showHotkey, pan));
keys.js
@darkowlzz
darkowlzz / Longest Sequence
Last active December 26, 2015 23:49
Longest Seq
def findSeq(str):
# A list to store the words.
seq = []
# Create words from the given string and
# store in seq.
word = str[0]
for i in range(len(str)-1):
current = ord(str[i])
next = ord(str[i+1])
if current <= next:
var sec = document.body.id;
$('ul#nav-main-menu > li').each(function( index ) {
if ($(this).text().toUpperCase() == sec.toUpperCase()) {
$('#nav-main-menu [tabindex=0]').get(index).focus();
}
});