Skip to content

Vanity allows you to setup a domain which go packages can be pulled from using a Knative Service

License

Notifications You must be signed in to change notification settings

n3wscott/vanity

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vanity, vanity domain mapping for go-imports

This configures an Knative Service which will act as a router for go cli, this means you don't have to reference all your go packages using the full github.com/{org}/{project} path, you'll be able to use your own domain like the Kubernetes (k8s.io, sigs.k8s.io), Etcd (etcd.io), etc.

Why

There are a couple reasons why this might be useful for you.

  1. If you plan on moving your project around but want to be independent of github domains and orgs.
  2. Shorten the package imports for cleanliness.
  3. You like customizing things 😄

Setup

The following assumes Kubernetes and Knative, but with a little work you can modify the deployment to be anything you need.

Prerequisites

YAML config

A simple example config is provided in the kodata repo.

host: example.com
paths:
  /foo:
    repo: https://github.com/example/foo

  /bar:
    repo: https://github.com/example/bar

Full options are:

host: <vanity host>                                           # required
cache_max_age: <max cache age for http responses, in seconds> # optional, defaults to 24 hours
paths:                                                        # required
  <path relitive to vanity host>:                             # required
    repo: <repo location (without .git)>                      # required
    display: <go-import config for go-source metadata>        # optional
    vcs: <repo kind, one of: [git, bzr, git, hg, svn]>        # optional

Running Locally

You can test out your config by running,

go run .

And then you can poke around with curl http://localhost:8080 or curl http://localhost:8080/foo.

Running on Knative Serving,

Edit the service.yaml file to suite your own needs and configuration. Then publish it.

ko apply -f service.yaml

Tie a domain to the service, and you are good to go!

Running on Cloud Run

ko lets you publish containers from go paths directly, so you can do something like the following:

ko publish github.com/n3wscott/vanity

Use the resulting image and set VANITY_CONFIG in the env vars to be your config, set the vanity domain on the service, and you are good to go!

Or (experimentally) via the gcloud cli:

gcloud beta run services replace service.yaml

Thanks

This was based on code from christopherhein/go-path-router and GoogleCloudPlatform/govanityurls

About

Vanity allows you to setup a domain which go packages can be pulled from using a Knative Service

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%