cochonou

package module
v0.0.0-...-4d56773 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2018 License: MIT Imports: 2 Imported by: 0

README

cochonou

GoDoc Build Status Quay.io

Sub-domain generator for image listing written in Go

Installation

User

# Pull the latest version from quay.io
docker pull quay.io/genesor/cochonou
# Create & start the cochonou container from the pulled image
docker run -d -p 94:9494 -v /cochonou/db:/db --env-file /cochonou/cochonou.env --name cochonou quay.io/genesor/cochonou

Replace /cochonou/db:/db with your desired path of for the shared volume containing the BoltDB file. Replace /cochonou/cochonou.env with the path of your own env file with the needed environment vars filled. You can also set the env vars with the -e option.

Your cochonou will be then accessible via http://localhost:9494

Contributor

You need to have glide installed

If you don't have the github.com in your GOPATH/src

cd $GOPATH/src
mkdir github.com

You'll need to update the values inside dev.env to work correctly with your domain.

Then follow this

# Create the genesor directory inside your GOPATH
cd $GOPATH/src/github.com
mkdir genesor
cd genesor
git clone git@github.com:genesor/cochonou.git
cd cochonou
# Install dependencies (glide etc.)
make install
# Launch the project with
make run

Supported domains providers

Cochonou supports thw following providers:

  • OVH
Setup OVH

To use cochonou with OVH you need to create an OVH API App and a Token allowing Cochonou to manage Subdomain.

Create your app here https://eu.api.ovh.com/createToken/ and allow the following access:

  • GET /domain/*
  • POST /domain/*
  • PUT /domain/*
  • DELETE /domain/*

You can choose the validity you want, but you'll have to update the value inside the project when the Token will expire and you'll need to create a new one.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSubDomainUsed is thrown when a a creation of an Redirection fails
	// because the subdomain wished for is already used.
	ErrSubDomainUsed = errors.New("The subdomain is already used")
	// ErrNotFound is thrown when no redirection is found.
	ErrNotFound = errors.New("no redirection found")
)
View Source
var (
	// ErrSubDomainAlreadyExists is used when a subdomain is already taken.
	ErrSubDomainAlreadyExists = errors.New("the subdomain cannot be created because it already exists")
)

Functions

This section is empty.

Types

type DomainHandler

type DomainHandler interface {
	CreateDomainRedirection(subDomain string, dest string) error
	Sync() ([]*Redirection, error)
}

DomainHandler is the interface used to handle domain related operations.

type Redirection

type Redirection struct {
	ID        int
	SubDomain string
	URL       string
}

Redirection is the struct that represents a redirection.

type RedirectionStore

type RedirectionStore interface {
	Save(redir *Redirection) error
	GetBySubDomain(string) (*Redirection, error)
	GetAll() ([]*Redirection, error)
}

RedirectionStore is the interface used to store Redirections

type StoredDomainHandler

type StoredDomainHandler struct {
	DomainHandler DomainHandler
	OVHClient     ovh.Client
	Store         RedirectionStore
}

StoredDomainHandler is the implementation of DomainHandler With a layer that store the redirection in a store.

func (*StoredDomainHandler) CreateDomainRedirection

func (h *StoredDomainHandler) CreateDomainRedirection(subDomain string, dest string) error

CreateDomainRedirection calls another DomainHandler and save the redirection inside a store.

func (*StoredDomainHandler) Sync

func (h *StoredDomainHandler) Sync() ([]*Redirection, error)

Sync fetches all the domains from the provider and saves them inside the database

Directories

Path Synopsis
cmd
ovh

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL