Skip to content
/ clay Public
forked from qb0C80aE/clay

An abstract system model store to automate various kind of operations

License

Notifications You must be signed in to change notification settings

Metallion/clay

 
 

Repository files navigation

Clay

Build Status

Clay is an abstract system model store to automate various kind of operations. It provides some APIs to access the system model store.

Related modules

  • Loam
    • The basic models and functions work on Clay
  • Pottery
    • A simple GUI module works with Loam on Clay

How to build and run

$ cd $GOPATH/src/github.com/qb0C80aE/clay
$ go build
$ ./clay

The server runs at http://localhost:8080 by default.

Environmental variables

You can give the environmental variables to Clay.

Key Description Options Default
HOST The host to listen. - localhost
PORT The port to listen. - 8080
DB_MODE The indentifier how the db is managed. memory/file memory
DB_FILE_PATH The path where the db file is located. This value is used if DB_MODE=file is set. - clay.db

Windows build

Due to mattn/go-sqlite3, mingw gcc is required.

  1. Install msys2 https://msys2.github.io/
  2. Run msys2 shell. i.e. C:\mingw64\msys2.exe
$ pacman -S mingw-w64-x86_64-gcc
$ cd $GOPATH/src/github.com/qb0C80aE/clay
$ go build
$ ./clay

Powershell

PS> C:\msys64\usr\bin\pacman -S mingw-w64-x86_64-gcc
PS> cd $env:GOPATH/src/github.com/qb0C80aE/clay
PS> powershell { $env:PATH+=";C:\msys64\mingw64\bin"; go build }
PS> .\clay.exe

Creating go-sqlite3 build archive makes rebuild time shorter.

PS> powershell { $env:PATH+=";C:\msys64\mingw64\bin"; go install github.com/mattn/go-sqlite3 }

You'll see $GOPATH\pkg\windows_amd64\github.com\mattn\go-sqlite3.a.

How to use

Import and export the design

You can import and export the models you created through design resource. Clay is designed as a standalone modeling tool, and the created design should be stored as human-readable text files in versioning repositories like git to make it easier to realize infrastructure-as-code.

$ # Export the design
$ curl -X GET 'localhost:8080/v1/designs/present?pretty' > design.json
$ # Import and overwrite the design
$ curl -X PUT 'localhost:8080/v1/designs/present' -H 'Content-Type: application/json' -d @design.json

Templates

You can register some text templates and generate something using the models in clay.

$ # register template and external parameters
$ curl -X POST "localhost:8080/v1/templates" -H "Content-Type: multipart/form-data" -F name=terraform -F template_content=@examples/sample.template
$ curl -X POST "localhost:8080/v1/template_external_parameters" -H "Content-Type: application/json" -d '{"template_id": 1, "name": "test", "value": "100"}'
$ # show generated template
$ curl -X GET "localhost:8080/v1/templates/1"
$ # Geenrate a text from the tempalte
$ curl -X PATCH "localhost:8080/v1/templates/1"

API Server

Simple Rest API using gin(framework) & gorm(orm)

Endpoint list

Designs Resource

GET    /<version>/designs/present
PUT    /<version>/designs/present
DELETE /<version>/designs/present

TemplateExternalParameter Resource

GET    /<version>/template_external_parameters
GET    /<version>/template_external_parameters/:id
POST   /<version>/template_external_parameters
PUT    /<version>/template_external_parameters/:id
DELETE /<version>/template_external_parameters/:id
PATCH /<version>/template_external_parameters/:id

Template Resource

GET    /<version>/templates
GET    /<version>/templates/:id
POST   /<version>/templates
PUT    /<version>/templates/:id
DELETE /<version>/templates/:id
PATCH /<version>/templates/:id

Thanks

About

An abstract system model store to automate various kind of operations

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%