All Projects → hairyhenderson → go-fsimpl

hairyhenderson / go-fsimpl

Licence: MIT license
Go io/fs.FS filesystem implementations for various URL schemes

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to go-fsimpl

Goofys
a high-performance, POSIX-ish Amazon S3 file system written in Go
Stars: ✭ 3,932 (+1647.56%)
Mutual labels:  filesystem, s3, gcs
vault-consul-docker
HashiCorp Vault with Consul backend in Docker
Stars: ✭ 20 (-91.11%)
Mutual labels:  consul, vault
cubefs
CubeFS is a cloud native distributed storage platform.
Stars: ✭ 3,062 (+1260.89%)
Mutual labels:  filesystem, s3
offensive-infrastructure
Offensive Infrastructure with Modern Technologies
Stars: ✭ 88 (-60.89%)
Mutual labels:  consul, vault
nestjs-storage
Nestjs file system / file storage module wrapping flydrive
Stars: ✭ 92 (-59.11%)
Mutual labels:  filesystem, s3
hookpick
A tool to manage some operational concepts of Hashicorp Vault
Stars: ✭ 83 (-63.11%)
Mutual labels:  consul, vault
vault-consul-monitoring
Sample project to explore monitoring Vault and Consul with telegraf/influxdb/grafana
Stars: ✭ 52 (-76.89%)
Mutual labels:  consul, vault
vault-consul-kubernetes
vault + consul on kubernetes
Stars: ✭ 60 (-73.33%)
Mutual labels:  consul, vault
vault-consul-swarm
Deploy Vault and Consul with Docker Swarm
Stars: ✭ 20 (-91.11%)
Mutual labels:  consul, vault
vault-load-testing
Automated load tests for Vault and Consul using the locust.io Python framework
Stars: ✭ 44 (-80.44%)
Mutual labels:  consul, vault
sftp-gateway
This repository contains a docker image configured to use the SSH File Transfer Protocol (SFTP) to transfer all its files to Cloud Blob Storage Services. This image can be deployed on a Kubernetes cluster with Helm.
Stars: ✭ 18 (-92%)
Mutual labels:  s3, gcs
hubble
hubbling the universe nebula by nebula
Stars: ✭ 18 (-92%)
Mutual labels:  consul, vault
hub
Public reusable components for Polyaxon
Stars: ✭ 8 (-96.44%)
Mutual labels:  s3, gcs
vagrant-vault-consul-docker-monitoring
No description or website provided.
Stars: ✭ 20 (-91.11%)
Mutual labels:  consul, vault
hashicorp-labs
Deploy locally on VM an Hashicorp cluster formed by Vault, Consul and Nomad. Ready for deploying and testing your apps.
Stars: ✭ 32 (-85.78%)
Mutual labels:  consul, vault
nomad-box
Nomad Box - Simple Terraform-powered setup to Azure of clustered Consul, Nomad and Traefik Load Balancer that runs Docker/GoLang/Java workloads. NOTE: Only suitable in dev environments at the moment until I learn more Terraform, Consul, Nomad, Vault :P
Stars: ✭ 18 (-92%)
Mutual labels:  consul, vault
100 Days Of Go
100 days of Go learning
Stars: ✭ 24 (-89.33%)
Mutual labels:  consul, vault
Vscode Remote Workspace
Multi protocol support for handling remote files like local ones in Visual Studio Code.
Stars: ✭ 197 (-12.44%)
Mutual labels:  url, filesystem
kafka-connect-fs
Kafka Connect FileSystem Connector
Stars: ✭ 107 (-52.44%)
Mutual labels:  filesystem, s3
hcat
Hashicorp Configuration and Templating library (hcat, pronounced hashicat)
Stars: ✭ 89 (-60.44%)
Mutual labels:  consul, vault

hairyhenderson/go-fsimpl

GoDoc Build

This module contains a collection of Go filesystem implementations that can be discovered dynamically by URL scheme. All filesystems are read-only.

These filesystems implement the fs.FS interface introduced in Go 1.16

Most implementations implement the fs.ReadDirFS interface, though the https filesystem does not.

Some extensions are available to help add specific functionality to certain filesystems:

  • WithContextFS - injects a context into a filesystem, for propagating cancellation in filesystems that support it.
  • WithHeaderFS - sets the http.Header for all HTTP requests used by the filesystem. This can be useful for authentication, or for requesting specific content types.
  • WithHTTPClientFS - sets the *http.Client for all HTTP requests to be made with.

This module also provides ContentType, an extension to the fs.FileInfo type to help identify an appropriate MIME content type for a given file. For filesystems that support it, the HTTP Content-Type header is used for this. Otherwise, the type is guessed from the file extension.

History & Project Status

This module is in development, and the API is still subject to change. The filesystems that are supported should operate correctly.

Most of these filesystems are based on code from gomplate, which supports all of these as datasources. This module is intended to eventually be used within gomplate.

Supported Filesystems

Here's the list of planned filesystem support, along with status:

Scheme(s) Description Supported?
aws+sm AWS Secrets Manager
aws+smp AWS Systems Manager Parameter Store
azblob Azure Blob Storage
consul, consul+http, consul+https HashiCorp Consul
file local filesystem
git, git+file, git+http, git+https, git+ssh local/remote git repository
gs Google Cloud Storage
http, https HTTP server
s3 Amazon S3
vault, vault+http, vault+https HashiCorp Vault

See url_schemes.md for more details on each scheme.

Installation

You need Go 1.16 or above to use this module. Use go get to install the latest version of go-fsimpl:

$ go get -u github.com/hairyhenderson/go-fsimpl

Usage

If you know that you want an HTTP filesystem, for example:

import (
	"net/url"

	"github.com/hairyhenderson/go-fsimpl/httpfs"
)

func main() {
	base, _ := url.Parse("https://example.com")
	fsys, _ := httpfs.New(base)

	f, _ := fsys.Open("hello.txt")
	defer f.Close()

	// now do what you like with the file...
}

If you're not sure what filesystem type you need (for example, if you're dealing with a user-provided URL), you can use a filesystem mux:

import (
	"github.com/hairyhenderson/go-fsimpl"
	"github.com/hairyhenderson/go-fsimpl/blobfs"
	"github.com/hairyhenderson/go-fsimpl/filefs"
	"github.com/hairyhenderson/go-fsimpl/gitfs"
	"github.com/hairyhenderson/go-fsimpl/httpfs"
)

func main() {
	mux := fsimpl.NewMux()
	mux.Add(filefs.FS)
	mux.Add(httpfs.FS)
	mux.Add(blobfs.FS)
	mux.Add(gitfs.FS)

	// for example, a URL that points to a subdirectory at a specific tag in a
	// given git repo, hosted on GitHub and authenticated with SSH...
	fsys, err := mux.Lookup("git+ssh://[email protected]/foo/bar.git//baz#refs/tags/v1.0.0")
	if err != nil {
		log.Fatal(err)
	}

	f, _ := fsys.Open("hello.txt")
	defer f.Close()

	// now do what you like with the file...
}

License

The MIT License

Copyright (c) 2021 Dave Henderson

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].