Skip to content

Latest commit

 

History

History
51 lines (41 loc) · 1.11 KB

README.md

File metadata and controls

51 lines (41 loc) · 1.11 KB

Build Status Coverage Report Go Reference

fly

Package fly and its sub-packages implement helpers for Go apps running on fly.io.

Usage

package main

import (
	"context"
	"log"
	"strings"

	"github.com/azazeal/fly/dns"
	"github.com/azazeal/fly/env"
)

func main() {
	if !env.IsSet() {
		log.Fatal("not running on fly")
	}

	const format = `running on fly: %t
---
$FLY_APP_NAME: %s,
$FLY_ALLOC_ID: %s,
$FLY_PUBLIC_IP: %s,
$FLY_REGION: %s,
`
	log.Printf(format,
		env.IsSet(),
		env.AppName(),
		env.AllocID(),
		env.PublicIP(),
		env.Region(),
	)

	apps, err := dns.Apps(context.TODO())
	if err != nil {
		log.Fatalf("failed determining apps: %v", apps)
	}

	log.Printf("fly apps in our organization: %s", strings.Join(apps, ", "))
}