Skip to content

Instantly share code, notes, and snippets.

View dinukadev's full-sized avatar

Dinuka Arseculeratne dinukadev

  • Australia
View GitHub Profile
object PascalsTriangle extends App {
/**
* 1
* 1 1
* 1 2 1
* 1 3 3 1
* 1 4 6 4 1
*
*/
@ControllerAdvice(annotations = RestController.class)
public class ExceptionHandlerAdvice {
@ExceptionHandler(InvalidDataException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ResponseEntity<String> handleInvalidDataExceptions(InvalidDataException e) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.TEXT_PLAIN);
return new ResponseEntity<>(e.getMessage(), headers, HttpStatus.BAD_REQUEST);
}
@dinukadev
dinukadev / IAM Role based Service Account Creation
Created May 19, 2020 03:48
A script to create an IAM role with full S3 access linked to a service account in Kubernetes
#!/bin/bash
CLUSTER_NAME=`eksctl get cluster --region ap-southeast-2 -o json | jq -r '.[0].name'`
ISSUER_URL=$(aws eks describe-cluster \
--name $CLUSTER_NAME \
--query cluster.identity.oidc.issuer \
--output text \
--region ap-southeast-2)
ISSUER_HOSTPATH=$(echo $ISSUER_URL | cut -f 3- -d'/')
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
@dinukadev
dinukadev / jenkins_build_jenkinsfile
Last active November 13, 2019 00:05
Jenkins build plan pipeline
node {
def mvnHome
env.JAVA_HOME="${tool 'JDK12'}"
env.MAVEN_HOME="${tool 'M3'}"
env.PATH="${env.JAVA_HOME}/bin:${env.MAVEN_HOME}/bin:${env.PATH}"
stage('Checkout source') {
git(
url: "${repo}",
credentialsId: "${GithubCredentialsId}",