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
#!/usr/bin/env bash | |
git clone --bare [email protected]:mayankshah1607/dotfiles.git $HOME/dotfiles | |
# define config alias locally since the dotfiles | |
# aren't installed on the system yet | |
function config { | |
git --git-dir=$HOME/dotfiles/ --work-tree=$HOME $@ | |
} |
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
package main | |
import ( | |
"time" | |
) | |
type Batch struct { | |
events []int | |
} |
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
### Keybase proof | |
I hereby claim: | |
* I am mayankshah1607 on github. | |
* I am mayankshah1607 (https://keybase.io/mayankshah1607) on keybase. | |
* I have a public key ASAo84WtFyNl0p685QEtF5oMmgKCIjaFMT9xYOm1zgBWWgo | |
To claim this, I am signing this object: |
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
# AddonCR | |
apiVersion: addons.managed.openshift.io/v1alpha1 | |
kind: Addon | |
metadata: | |
name: reference-addon | |
spec: | |
# <remaining spec omitted for redability> | |
monitoring: | |
monitoringStack: | |
enabled: 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
import gitlab | |
gl = gitlab.Gitlab('https://gitlab.cee.redhat.com/', private_token='', ssl_verify=False) | |
gl.auth() | |
project = gl.projects.get() # Enter project ID here | |
data = { | |
'branch': 'main', |
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
diff --git a/controllers/clusterconfigmap_controller.go b/controllers/clusterconfigmap_controller.go | |
index 913832f..675fea3 100644 | |
--- a/controllers/clusterconfigmap_controller.go | |
+++ b/controllers/clusterconfigmap_controller.go | |
@@ -24,7 +24,9 @@ import ( | |
"k8s.io/apimachinery/pkg/types" | |
ref "k8s.io/client-go/tools/reference" | |
+ "sigs.k8s.io/controller-runtime/pkg/handler" | |
"sigs.k8s.io/controller-runtime/pkg/predicate" |
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
func (le *LeaderElector) tryAcquireOrRenew(ctx context.Context) bool { | |
now := metav1.Now() | |
leaderElectionRecord := rl.LeaderElectionRecord{ | |
HolderIdentity: le.config.Lock.Identity(), | |
LeaseDurationSeconds: int(le.config.LeaseDuration / time.Second), | |
RenewTime: now, | |
AcquireTime: now, | |
} | |
// 1. obtain or create the ElectionRecord |
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
// Run starts the leader election loop. Run will not return | |
// before leader election loop is stopped by ctx or it has | |
// stopped holding the leader lease | |
func (le *LeaderElector) Run(ctx context.Context) { | |
defer runtime.HandleCrash() | |
defer func() { | |
le.config.Callbacks.OnStoppedLeading() | |
}() | |
if !le.acquire(ctx) { |
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
// RunOrDie starts a client with the provided config or panics if the config | |
// fails to validate. RunOrDie blocks until leader election loop is | |
// stopped by ctx or it has stopped holding the leader lease | |
func RunOrDie(ctx context.Context, lec LeaderElectionConfig) { | |
le, err := NewLeaderElector(lec) | |
if err != nil { | |
panic(err) | |
} | |
if lec.WatchDog != nil { | |
lec.WatchDog.SetLeaderElection(le) |
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
func runLeaderElection(lock *resourcelock.LeaseLock, ctx context.Context, id string) { | |
leaderelection.RunOrDie(ctx, leaderelection.LeaderElectionConfig{ | |
Lock: lock, | |
ReleaseOnCancel: true, | |
LeaseDuration: 15 * time.Second, | |
RenewDeadline: 10 * time.Second, | |
RetryPeriod: 2 * time.Second, | |
Callbacks: leaderelection.LeaderCallbacks{ | |
OnStartedLeading: func(c context.Context) { | |
doStuff() |
NewerOlder