Giter Club home page Giter Club logo

giraffle's Introduction

Giraffle Build Status Build Scan Maven Central

This plugin creates a dsl for Tigergraph. The dsl allows you to describe connections to a Tigergraph server.

Status

The Giraffle plugin has been published to the Gradle plugins repository. You may use it by referencing it within your plugins block.

plugins {
    id("com.optum.giraffle") version "1.0.2"
}

Development Assistance

Fork and clone this repository. After this you should be able to make changes, compile, test and publish. The publishToMavenLocal will make the plugin available to your Gradle projects.

Using the plugin

In order to use this plugin you’ll need to install this plugin and Tigergraph’s gsql client.

To install the gradle plugin, follow the instructions outlined in Development Assistance.

The Tigergraph plugin in published to bintray, and is available via a jcenter() repository. To use the gsql_client you’ll need to add the jcenter() to you repositories block.

repositories {
    jcenter()
    mavenLocal() // (1)
}
  1. Not required unless you’re doing local plugin development.

build.gradle.kts

plugins {
    id("com.optum.giraffle) version "1.0.2" // (1)
}


dependencies {
    gsqlRuntime("com.tigergraph.client:gsql_client:2.3.2.1") // (2)
}

tigergraph {
    scriptDir.set(file("scripts"))
    tokens.set(emptyMap())
    serverName.set("")
    userName.set("")
    password.set("")
    adminUserName.set("")
    adminPassword.set("")
}
  1. Watch this version. You’ll need to update it as development proceeds.

  2. This configuration isn’t required. The defaults within the plugin provide this dependency already. However, if you need to override the defaults, this is how you do that. You might want to override this value if you need a different version of the gsql_client.

This should put everything in order. The plugin defines a couple of tasks, and a dsl to handle connection parameters to your Tigergraph server(s).

Plugin DSL and Tasks

The plugin creates a dsl, custom task types, and custom tasks.

Tigergraph DSL

The dsl provided by this plugin allow configuration that applies to all the tasks and types created by the plugin.

DSL Components

All the components belong within a tigergraph closure. All of these are properties, and need to be set accordingly.

scriptDir

The scriptDir configuration is a file path location for where the gsql scripts for your project live.

The default value for scriptDir is db_scripts. It is not necessary to set this value if you’ve placed you scripts in this directory already.

Example: Kotlin

build.gradle.kts

tigergraph {
    scriptDir.set(file("scripts"))
}

Example: Groovy

build.gradle

tigergraph {
    scriptDir = file("scripts")
}
tokens

This plugin supports token replacement within your source scripts. Internally it uses an Ant filter. Simply provide a map as the parameter to this property, and your sources will have the tokens replaced before execution.

Example: Kotlin

build.gradl.kts

val tokenMap: LinkedHashMap<String, String> = linkedMapOf("graphname" to "hc")

tigergraph {
    tokens.set(tokenMap)
}

This configuration will take each occurrence of @graphname@ and replace it with the value of hc within the source scripts.

serverName

The serverName property configures which server to execute your scripts against.

Example: Kotlin

build.gradle.kts

tigergraph {
    serverName.set("dbsw00001")
}
userName

The userName property configures the username to use for connecting to tigergraph. This is the default username to use. When a script requires elevated privileges, see adminUserName and superUser.

password

The password property configures the password to use for connecting to tigergraph. This is property is used in conjunction with userName.

adminUserName

The adminUserName property configures the username to use for connecting to tigergraph. This is used when the superUser property is set on a gsql script. See superUser.

adminPassword

The adminPassword property configures the password to use for connecting to tigergraph. This is property is used in conjunction with adminUserName.

gsqlCopyTasks

The plugin defines this task, and adds it to the project. This task copies files from the scriptDir directory and copies the files to the project’s buildDir.

This is the step where token replacement occurs, as defined by the tokens property.

gsqlTaskType

This defines a task type that allows you to execute your scripts against the tigergraph server with the properties set by the Tigergraph DSL

To use this task type you simply need to define the name of the script to execute, and optionally the superUser directive.

scriptPath

The path, relative to scriptDir to execute.

superUser

The directive that indicates whether this can be executed by the default user (false), or the superUser (true).

Examples

I like using this with plugin in conjunction with the Properties plugin. This allows you to use and configure different environments.

gradle.properties

username=joe
password=joehasabadpassword
host=dbsrv001
graphname=hc

build.gradle.kts

import com.optum.giraffle.tasks.GsqlCopySources
import com.optum.giraffle.tasks.GsqlTask

plugins {
    id("com.optum.giraffle") version "0.1.0"
}

repositories {
    mavenLocal()
    jcenter()
}

val graphname: String by project // (1)
val host: String by project
val username: String by project
val password: String by project
val tokenMap: LinkedHashMap<String, String> = linkedMapOf("graphname" to graphname) // (2)

tigergraph { // (3)
    scriptDir.set(file("db_scripts"))
    tokens.set(tokenMap)
    serverName.set(host)
    userName.set(username)
    password.set(password)
}

val createSchema by tasks.creating(GsqlTask::class) {
    group = "Tigergraph Schema"
    description = "Create the schema on the database"
    scriptPath = "schema.gsql" // (4)
    superUser = true // (5)
}
  1. by project is how you references project properties using the Kotlin DSL for Gradle.

  2. This is how you create a Kotlin map to pass to a property.

  3. Our Tigergraph DSL. These settings apply for all interactions with Tigergraph.

  4. The path to the source script relative to scriptDir.

  5. Informs the plugin which credentials to use.

giraffle's People

Contributors

jmeekhof avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.