Giter Club home page Giter Club logo

fastly2git's Introduction

Logo fastly2git

Create a git repository from Fastly service generated VCL.

Build Status

Screencast

Screencast

Synopsis

Usage: fastly2git [options]

Create a git repository from Fastly service generated VCL.

Options
    -a, --apikey APIKEY              Fastly API key
    -s, --serviceid SERVICEID        Fastly service ID
    -d, --directory DIRECTORY        Directory
    -v, --verbose                    Run verbosely
    -h, --help                       Show this message

fastly2git will even work incrementally, pulling all new locked versions.

Installation

Clone the repo and then run the following command while in fastly2git directory:

bundle install # to install dependencies
bundle exec rake test # to run tests
bundle exec rake install # to install the gem
bundle exec rake -T # to see the list of other available rake tasks

Example

$ fastly2git -v --apikey XXX --serviceid YYY --directory /tmp/vcl
Service Name: uuid.astray.com
Importing version...
Importing version...
Importing version...
Importing version...
Importing version...
Importing version...
Importing version...
Importing version...
Importing version...
Importing version...
.... done! Imported to /tmp/vcl

Docker

Build first the image by cloning the repo and executing the following command while in fastly2git directly:

docker build -t fastly2git . 

You can then execute the tool as follows:

mkdir /tmp/vcl
docker run -ti -v /tmp/vcl:/tmp/vcl fastly2git -v --apikey XXX --serviceid YYY --directory /tmp/vcl

Inspect

Then change to the new directory:

$ cd /tmp/vcl

Inspect the changes version by version:

$ git log -p
...
commit d150836cae065e4e9fbc42879c6b9dd7dfc0be0d
Author: Fastly User <[email protected]>
Date:   Tue Oct 20 10:05:52 2015 +0100

    Version 9

diff --git a/generated.vcl b/generated.vcl
index 9b183a1..c48023e 100644
--- a/generated.vcl
+++ b/generated.vcl
@@ -32,6 +32,7 @@ sub vcl_recv {


 #--FASTLY RECV CODE END
+    set req.http.vcl = req.vcl;

     if (req.request != "HEAD" && req.request != "GET" && req.request !=
"FASTLYPURGE") {
       return(pass);
@@ -289,6 +290,7 @@ sub vcl_error {
     set obj.response = "OK";
     synthetic "X-Varnish: " req.http.X-Varnish {"
 "} "server.identity: " server.identity {"
+"} "req.vcl: " req.http.vcl {"
 "} "req.service_id: " req.service_id;
     return(deliver);
   }
...

Or annotate the VCL by version:

$ git annotate --line-porcelain generated.vcl | perl -lne 'if ($_ =~
s/^\t//) { printf "%-10.10s %s\n", $s, $_} else { ($k, $v) = split(" ",
$_,2); $s = $v if $k eq "summary" }'
...
Version 2    if (obj.status == 900) {
Version 2      set obj.status = 200;
Version 2      set obj.response = "OK";
Version 6      synthetic "X-Varnish: " req.http.X-Varnish {"
Version 8  "} "server.identity: " server.identity {"
Version 9  "} "req.vcl: " req.http.vcl {"
Version 8  "} "req.service_id: " req.service_id;
Version 2      return(deliver);
Version 2    }
...

License

The gem is available as open source under the terms of the MIT License.

Future

Is this useful? Let me know! Léon Brocard <[email protected]>

fastly2git's People

Contributors

acme avatar ezkl avatar brevetlamersports avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.