├── .gitignore ├── .ottoid ├── .travis.yml ├── README.md ├── app.go ├── app_test.go └── main.go /.gitignore: -------------------------------------------------------------------------------- 1 | .otto 2 | otto.example 3 | otto-plugin-example 4 | -------------------------------------------------------------------------------- /.ottoid: -------------------------------------------------------------------------------- 1 | d7093cc2-c35b-34d6-768e-7c4521fdd2da 2 | 3 | DO NOT MODIFY OR DELETE THIS FILE! 4 | 5 | This file should be checked in to version control. Do not ignore this file. 6 | 7 | The first line is a unique UUID that represents the Appfile in this directory. 8 | This UUID is used globally across your projects to identify this specific 9 | Appfile. This UUID allows you to modify the name of an application, or have 10 | duplicate application names without conflicting. 11 | 12 | If you delete this file, then deploys may duplicate this application since 13 | Otto will be unable to tell that the application is deployed. 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Otto Example App Plugin 2 | 3 | This repository contains an example app type plugin for 4 | [Otto](https://www.ottoproject.io). App types enable Otto to detect and 5 | work with new types of applications. 6 | 7 | **NOTE:** Otto 0.2 (currently unreleased) is required for app type plugins. 8 | This repository is used for the documentation and as an example in preparation 9 | for that release. Once it is released, this section will be removed. 10 | 11 | ## Building the Plugin 12 | 13 | To build the plugin, compile it like a normal go executable: 14 | 15 | ``` 16 | $ go get 17 | $ go build -o otto-plugin-example 18 | ``` 19 | 20 | The output name of "otto-plugin-example" is important. Otto looks for 21 | the pattern `otto-plugin-*` to find plugins. 22 | -------------------------------------------------------------------------------- /app.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/hashicorp/otto/app" 5 | "github.com/hashicorp/otto/appfile/detect" 6 | "github.com/hashicorp/otto/appfile" 7 | ) 8 | 9 | // AppFactory implements plugin.AppFunc for use to serve the plugin. 10 | func AppFactory() app.App { 11 | return &App{} 12 | } 13 | 14 | // Meta is the metadata for this app type. 15 | var Meta = &app.Meta{ 16 | Tuples: []app.Tuple{ 17 | {"example", "*", "*"}, 18 | }, 19 | Detectors: []*detect.Detector{ 20 | &detect.Detector{ 21 | Type: "example", 22 | File: []string{"otto.example"}, 23 | }, 24 | }, 25 | } 26 | 27 | // App implements app.App which is the interface necessary for an app type. 28 | // 29 | // The best example of real implementations is in Otto itself. The "builtin" 30 | // folder contains App implementations that are built-in to Otto. Otto 31 | // uses the same API as plugins, so you can see how the built-in app types 32 | // do things and build your plugin based on that. 33 | type App struct{} 34 | 35 | func (a *App) Meta() (*app.Meta, error) { 36 | return Meta, nil 37 | } 38 | 39 | func (a *App) Implicit(ctx *app.Context) (*appfile.File, error) { 40 | return nil, nil 41 | } 42 | 43 | func (a *App) Compile(ctx *app.Context) (*app.CompileResult, error) { 44 | return nil, nil 45 | } 46 | 47 | func (a *App) Build(ctx *app.Context) error { 48 | return nil 49 | } 50 | 51 | func (a *App) Deploy(ctx *app.Context) error { 52 | return nil 53 | } 54 | 55 | func (a *App) Dev(ctx *app.Context) error { 56 | return nil 57 | } 58 | 59 | func (a *App) DevDep(dst, src *app.Context) (*app.DevDep, error) { 60 | return nil, nil 61 | } 62 | -------------------------------------------------------------------------------- /app_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/hashicorp/otto/app" 7 | ) 8 | 9 | func TestApp_impl(t *testing.T) { 10 | var _ app.App = new(App) 11 | } 12 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/hashicorp/otto/plugin" 5 | ) 6 | 7 | func main() { 8 | // This runs this binary as an Otto plugin. No other machinery is needed 9 | // to make the plugin work! 10 | plugin.Serve(&plugin.ServeOpts{ 11 | AppFunc: AppFactory, 12 | }) 13 | } 14 | --------------------------------------------------------------------------------