All Projects → Integralist → go-fastly-cli

Integralist / go-fastly-cli

Licence: MIT license
CLI tool for interacting with Fastly CDN services via official REST API.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects
shell
77523 projects

Projects that are alternatives of or similar to go-fastly-cli

ShareX-CDN
Basic image, text & file uploader CDN for ShareX
Stars: ✭ 22 (+57.14%)
Mutual labels:  cdn, upload
cdnupload
Upload your site's static files to a directory or CDN, using content-based hashing
Stars: ✭ 41 (+192.86%)
Mutual labels:  cdn, upload
windows-azure-storage
Use the Microsoft Azure Storage service to host your website's media files.
Stars: ✭ 48 (+242.86%)
Mutual labels:  cdn, upload
uploadcare-rails
Rails wrapper for Uploadcare
Stars: ✭ 48 (+242.86%)
Mutual labels:  cdn, upload
Awesome Wp Speed Up
Plugins and resources to speed up and optimize your WordPress site.
Stars: ✭ 375 (+2578.57%)
Mutual labels:  cdn, varnish
fastly
Fastly API client for Node.js
Stars: ✭ 70 (+400%)
Mutual labels:  cdn, fastly
ElUploader-OSS-Solution
ElementUI - Upload 组件结合 OSS 的封装
Stars: ✭ 28 (+100%)
Mutual labels:  cdn, upload
nucked-truth-of-files
HollyJS Moscow
Stars: ✭ 14 (+0%)
Mutual labels:  upload
lambda-resize-image
An AWS Lambda Function to resize images automatically with API Gateway and S3 for imagemagick tasks. When an image is called on AWS Api Gateway, this package will resize it and send it to the S3.
Stars: ✭ 56 (+300%)
Mutual labels:  cdn
aws-s3-bucket-purger
A program that will purge any AWS S3 Bucket of objects and versions quickly
Stars: ✭ 18 (+28.57%)
Mutual labels:  delete
typo3-varnish
Varnish Connector for TYPO3. Mirrored from https://gitlab.com/opsone_ch/typo3/varnish.
Stars: ✭ 44 (+214.29%)
Mutual labels:  varnish
react-file-input-previews-base64
This package provides an easy to use, ready to go and customizable wrapper around file input, with option for image previews and returning file as base64 string.
Stars: ✭ 15 (+7.14%)
Mutual labels:  upload
jQuery-Merge-for-php-diff
A client side merge tool for JBlonds PHP-Diff @ https://github.com/JBlond/php-diff.
Stars: ✭ 74 (+428.57%)
Mutual labels:  diff
node-csgo-cdn
Retrieves the Steam CDN Image URLs for CS:GO Items
Stars: ✭ 51 (+264.29%)
Mutual labels:  cdn
terraform-aws-cloudfront-cdn
Terraform Module that implements a CloudFront Distribution (CDN) for a custom origin.
Stars: ✭ 89 (+535.71%)
Mutual labels:  cdn
upload-compression-plugin
Compress and decompress files on https://upload.io/
Stars: ✭ 21 (+50%)
Mutual labels:  upload
media-delivery
This collection of samples demonstrates best practices to achieve optimal video quality and performance on Intel GPUs for content delivery networks. Check out our demo, recommended command lines and quality and performance measuring tools.
Stars: ✭ 26 (+85.71%)
Mutual labels:  cdn
LNSwipeCell
一套友好的、方便集成的针对cell的左滑编辑功能!
Stars: ✭ 16 (+14.29%)
Mutual labels:  delete
ncdu-diff
ncdu fork that can compare and diff results
Stars: ✭ 21 (+50%)
Mutual labels:  diff
got
An enjoyable golang test framework.
Stars: ✭ 234 (+1571.43%)
Mutual labels:  diff

go-fastly-cli

Note: this project was hacked together many years ago to solve a specific problem I had. It works perfectly for me but if you're reviewing the code to see how it is put together, then just remember that A.) the code quality isn't as good as it probably could be, and B.) the code design equally could be greatly improved. Otherwise have fun with it.

CLI tool for:

  • Uploading local VCL to Fastly.
  • Diffing local VCL with remote Fastly VCL.
  • Listing remote Fastly VCL files.
  • Deleting remote Fastly VCL files.
  • Creating, Activating and Validating Fastly service versions.

This tool is an abstraction layer built on top of "go-fastly".

Install

go get github.com/integralist/go-fastly-cli

GOOS=darwin GOARCH=386 go build fastly.go

Usage

fastcli <flags> [diff <options>]
fastcli <flags> [upload <options>]
fastcli <flags> [list <options>]
fastcli <flags> [delete <options>]

Flags:

fastcli -help

  -activate string
        specify Fastly service version to activate
  -debug
        show any debug logs and subcommand specific information
  -dir string
        the directory where your vcl files are located
  -help, -h
        show available flags
  -match string
        regex for matching vcl directories (fallback: VCL_MATCH_PATH)
  -service string
        your Fastly service id (fallback: FASTLY_SERVICE_ID) 
  -settings string
        get settings for the specified Fastly service version (try: 'latest')
  -skip string
        regex for skipping vcl directories (will also try: VCL_SKIP_PATH) 
  -status string
        get status for the specified Fastly service version (try: 'latest')
  -token string
        your fastly api token (fallback: FASTLY_API_TOKEN) 
  -validate string
        specify Fastly service version to validate
  -version
        show application version

Diff Options:

fastcli diff -help

Usage of diff:
  -version string
        specify Fastly service version to verify against

Upload Options:

fastcli upload -help

Usage of upload:
  -clone string
        specify a Fastly service version to clone from (files will upload to it)
  -latest
        use latest Fastly service version to upload to (presumes not activated)
  -version string
        specify non-active Fastly service version to upload to

List Options:

fastcli list -help

Usage of list:
  -version string
        specify Fastly service version to list VCL files from

Delete Options:

fastcli delete -help

Usage of delete:
  -name string
        specify VCL filename to delete
  -version string
        specify Fastly service version to delete VCL files from

Environment Variables

The use of environment variables help to reduce the amount of flags required by the fastly CLI tool.

For example, I always diff against a 'stage' service in our Fastly account and so I don't want to have to put in the same credentials all the time.

Below is a list of environment variables this tool supports:

  • FASTLY_API_TOKEN (-token)
  • FASTLY_SERVICE_ID (-service)
  • VCL_DIRECTORY (-dir)
  • VCL_MATCH_PATH (-match)
  • VCL_SKIP_PATH (-skip)

Use the relevant CLI flags to override these values

You can quickly view the relevant environment variables in your current shell using the following bash command:

env | sort | grep -iE '(vcl|fastly)'

FASTLY_API_TOKEN=123
FASTLY_SERVICE_ID=456
VCL_DIRECTORY=/Users/integralist/code/organization/cdn
VCL_MATCH_PATH=stage|www
VCL_SKIP_PATH=utils

In the above output we can see that the files I'll upload will be only those that are located in either a stage or www sub directory of my repository (which is found at VCL_DIRECTORY). I'll also skip uploading any files stored in the utils sub directory.

Examples

Note: all examples presume FASTLY_API_TOKEN/FASTLY_SERVICE_ID env vars set

# view status for the latest service version
fastcli -status latest

# view status for the specified service version
fastcli -status 123

# view settings for the latest service version
fastcli -settings latest

# view settings for the specified service version
fastcli -settings 123

# validate specified service version
fastcli -validate 123

# activate specified service version
fastcli -activate 123

# view latest version of remote service vcl files
fastcli list

# view version 123 of remote service vcl files
fastcli list -version 123

# delete specified vcl file from latest version of remote service
fastcli delete -name test_file

# delete specified vcl file from specific version of remote service
fastcli delete -name test_file -version 123

# diff local vcl files against the lastest remote versions
fastcli diff

# diff local vcl files against the specific remote versions
fastcli diff -version 123

# enable debug mode
# this will mean debug logs are displayed
# for 'diff' subcommand: also display per file diff
fastcli -debug diff -version 123

# upload local files to remote service version
fastcli upload -version 123

# token and service explicitly set to override env vars
fastcli -service xxx -token xxx upload -version 123

# modify VCL directory temporarily + use different token/service id
VCL_MATCH_PATH=foo fastcli -token $FASTLY_API_TOKEN_FOO -service $FASTLY_SERVICE_ID_FOO diff

# clone specified service version and upload local files to it
fastcli upload -clone 123

# upload local files to the latest remote service version
fastcli upload -latest

# clone latest service version available and upload local files to it
fastcli upload

Makefile

To compile binaries for multiple OS architectures:

make compile

To start up a dockerized development environment (inc. Vim):

make dev

To install a local binary for testing (darwin):

make install

To remove all compiled binaries, vim files and containers:

make clean

TODO

  • Ability to purge URLs (both individual and those associated by surrogate keys)
  • Ability to 'dry run' a command (to see what files are affected, e.g. what files will be uploaded and where)
  • Ability to diff two remote services (not just local against a remote)
  • Ability to upload individual files (not just pattern matched list of files)
  • Ability to display all available services (along with their ID)
  • Better diffing tool than linux diff command
  • Setup for homebrew install
  • Test Suite
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].