Kotlin Ops
Purpose
Koops is Kotlin-based scripting language aimed at running command line tools commonly used in devops day-to-day work, such as maven, gradle, docker, git, AWS SDK, Google Cloud SDK etc.
It's an alternative to python
or bash
scripting, combining a simple way of calling commands with the power of the Kotlin language.
Getting Started
Here is an example of a koops
script:
#!/usr/bin/env kscript
import com.codingue.koops.core.*
import com.codingue.koops.maven.*
import com.codingue.koops.aws.*
import com.codingue.koops.aws.lambda.*
import com.codingue.koops.aws.s3.*
script {
// Run mvn clean install command, making sure the build is successful
mvn(Clean, Install) verifies Success
// If the build is successful, upload to S3
aws s3 {
putObject("mybucket", "target/myproject.jar")
}
// And update our lambda with the uploaded content
aws lambda {
val updateFunctionCodeResult = updateFunctionCode("mylambda") {
s3Bucket = "mybucket"
s3Key = "myproject.jar"
}
publishVersion("mylambda", {
codeSha256 = updateFunctionCodeResult.codeSha256
})
}
}
Installation
Any koops snippet being a Kotlin snippet, you can run it in any regular Kotlin program, just like this one.
But more interestingly, you can run koops
as a simple Kotlin script, using kscript.
The easiest is to install Kotlin, Kscript and Koops using sdkman:
curl -s "https://get.sdkman.io" | bash # install sdkman
source ~/.bash_profile # add sdkman to PATH
sdk install kotlin # install Kotlin
sdk install maven # install Maven
sdk install kscript # install Kscript
curl -s "http://get.koops.codingue.com" | bash # install koops extension for kscript
You can then run any .kts script:
koops -s <script.kts>
License
The source files found in this project are licensed under the Apache License 2.0.