{"id":16370761,"url":"https://github.com/integralist/go-fastly-cli","last_synced_at":"2025-03-23T02:34:11.345Z","repository":{"id":57525544,"uuid":"89577088","full_name":"Integralist/go-fastly-cli","owner":"Integralist","description":"CLI tool for interacting with Fastly CDN services via official REST API.","archived":false,"fork":false,"pushed_at":"2020-07-29T08:20:36.000Z","size":49,"stargazers_count":13,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-18T06:15:18.154Z","etag":null,"topics":["cdn","cli","client","command-line","delete","diff","fastly","go","golang","list","tool","upload","varnish","vcl"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Integralist.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-27T08:53:51.000Z","updated_at":"2022-09-30T13:35:56.000Z","dependencies_parsed_at":"2022-09-12T14:22:55.327Z","dependency_job_id":null,"html_url":"https://github.com/Integralist/go-fastly-cli","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2Fgo-fastly-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2Fgo-fastly-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2Fgo-fastly-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2Fgo-fastly-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Integralist","download_url":"https://codeload.github.com/Integralist/go-fastly-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221843062,"owners_count":16890250,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cdn","cli","client","command-line","delete","diff","fastly","go","golang","list","tool","upload","varnish","vcl"],"created_at":"2024-10-11T03:05:55.645Z","updated_at":"2024-10-28T14:47:44.895Z","avatar_url":"https://github.com/Integralist.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-fastly-cli\n\n\u003e **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.\n\nCLI tool for:\n\n* Uploading local VCL to Fastly.\n* Diffing local VCL with remote Fastly VCL.\n* Listing remote Fastly VCL files.\n* Deleting remote Fastly VCL files.\n* Creating, Activating and Validating Fastly service versions.\n\nThis tool is an abstraction layer built on top of \"[go-fastly](https://github.com/sethvargo/go-fastly)\".\n\n## Install\n\n```bash\ngo get github.com/integralist/go-fastly-cli\n```\n\n\u003e GOOS=darwin GOARCH=386 go build fastly.go\n\n## Usage\n\n```bash\nfastcli \u003cflags\u003e [diff \u003coptions\u003e]\nfastcli \u003cflags\u003e [upload \u003coptions\u003e]\nfastcli \u003cflags\u003e [list \u003coptions\u003e]\nfastcli \u003cflags\u003e [delete \u003coptions\u003e]\n```\n\nFlags:\n\n```bash\nfastcli -help\n\n  -activate string\n        specify Fastly service version to activate\n  -debug\n        show any debug logs and subcommand specific information\n  -dir string\n        the directory where your vcl files are located\n  -help, -h\n        show available flags\n  -match string\n        regex for matching vcl directories (fallback: VCL_MATCH_PATH)\n  -service string\n        your Fastly service id (fallback: FASTLY_SERVICE_ID) \n  -settings string\n        get settings for the specified Fastly service version (try: 'latest')\n  -skip string\n        regex for skipping vcl directories (will also try: VCL_SKIP_PATH) \n  -status string\n        get status for the specified Fastly service version (try: 'latest')\n  -token string\n        your fastly api token (fallback: FASTLY_API_TOKEN) \n  -validate string\n        specify Fastly service version to validate\n  -version\n        show application version\n```\n\nDiff Options:\n\n```bash\nfastcli diff -help\n\nUsage of diff:\n  -version string\n        specify Fastly service version to verify against\n```\n\nUpload Options:\n\n```bash\nfastcli upload -help\n\nUsage of upload:\n  -clone string\n        specify a Fastly service version to clone from (files will upload to it)\n  -latest\n        use latest Fastly service version to upload to (presumes not activated)\n  -version string\n        specify non-active Fastly service version to upload to\n```\n\nList Options:\n\n```bash\nfastcli list -help\n\nUsage of list:\n  -version string\n        specify Fastly service version to list VCL files from\n```\n\nDelete Options:\n\n```bash\nfastcli delete -help\n\nUsage of delete:\n  -name string\n        specify VCL filename to delete\n  -version string\n        specify Fastly service version to delete VCL files from\n```\n\n## Environment Variables\n\nThe use of environment variables help to reduce the amount of flags required by the `fastly` CLI tool.\n\nFor 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.\n\nBelow is a list of environment variables this tool supports:\n\n* `FASTLY_API_TOKEN` (`-token`)\n* `FASTLY_SERVICE_ID` (`-service`)\n* `VCL_DIRECTORY` (`-dir`)\n* `VCL_MATCH_PATH` (`-match`)\n* `VCL_SKIP_PATH` (`-skip`)\n\n\u003e Use the relevant CLI flags to override these values\n\nYou can quickly view the relevant environment variables in your current shell using the following bash command:\n\n```bash\nenv | sort | grep -iE '(vcl|fastly)'\n\nFASTLY_API_TOKEN=123\nFASTLY_SERVICE_ID=456\nVCL_DIRECTORY=/Users/integralist/code/organization/cdn\nVCL_MATCH_PATH=stage|www\nVCL_SKIP_PATH=utils\n```\n\nIn 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.\n\n## Examples\n\n\u003e Note: all examples presume `FASTLY_API_TOKEN`/`FASTLY_SERVICE_ID` env vars set\n\n```bash\n# view status for the latest service version\nfastcli -status latest\n\n# view status for the specified service version\nfastcli -status 123\n\n# view settings for the latest service version\nfastcli -settings latest\n\n# view settings for the specified service version\nfastcli -settings 123\n\n# validate specified service version\nfastcli -validate 123\n\n# activate specified service version\nfastcli -activate 123\n\n# view latest version of remote service vcl files\nfastcli list\n\n# view version 123 of remote service vcl files\nfastcli list -version 123\n\n# delete specified vcl file from latest version of remote service\nfastcli delete -name test_file\n\n# delete specified vcl file from specific version of remote service\nfastcli delete -name test_file -version 123\n\n# diff local vcl files against the lastest remote versions\nfastcli diff\n\n# diff local vcl files against the specific remote versions\nfastcli diff -version 123\n\n# enable debug mode\n# this will mean debug logs are displayed\n# for 'diff' subcommand: also display per file diff\nfastcli -debug diff -version 123\n\n# upload local files to remote service version\nfastcli upload -version 123\n\n# token and service explicitly set to override env vars\nfastcli -service xxx -token xxx upload -version 123\n\n# modify VCL directory temporarily + use different token/service id\nVCL_MATCH_PATH=foo fastcli -token $FASTLY_API_TOKEN_FOO -service $FASTLY_SERVICE_ID_FOO diff\n\n# clone specified service version and upload local files to it\nfastcli upload -clone 123\n\n# upload local files to the latest remote service version\nfastcli upload -latest\n\n# clone latest service version available and upload local files to it\nfastcli upload\n```\n\n## Makefile\n\nTo compile binaries for multiple OS architectures:\n\n```bash\nmake compile\n```\n\nTo start up a dockerized development environment (inc. Vim):\n\n```bash\nmake dev\n```\n\nTo install a local binary for testing (darwin):\n\n```bash\nmake install\n```\n\nTo remove all compiled binaries, vim files and containers:\n\n```bash\nmake clean\n```\n\n## TODO\n\n* Ability to purge URLs (both individual and those associated by surrogate keys)\n* Ability to 'dry run' a command (to see what files are affected, e.g. what files will be uploaded and where)\n* Ability to diff two remote services (not just local against a remote)\n* Ability to upload individual files (not just pattern matched list of files)\n* Ability to display all available services (along with their ID)\n* Better diffing tool than linux `diff` command\n* Setup for homebrew install\n* Test Suite\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintegralist%2Fgo-fastly-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintegralist%2Fgo-fastly-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintegralist%2Fgo-fastly-cli/lists"}