GithubHelp home page GithubHelp logo

catalog-deployer's Introduction

catalog-deployer

Introduction

Tool observes files and subdirectories in given directory and shares its contents via API.

If searched path is a directory then the list of files and subdirectories (not recursive) within will be shown, else the file content. So if we have for example a ROOT_DIR=/storage

/
└── storage
    └── substorage1
        └── file.txt

and we want to check the content of file.txt, we need to send request GET to $(DEPLOY_HOST):$(DEPLOY_PORT)/substorage1<slash>file.txt.

It is important to use <slash> and to not add /storage in request link. $ROOT_DIR is hidden behind first / not written as <slash>. <slash> is a trick which allow api to notice new directories on the lowest height in a tree.

Launch

It is required to set ROOT_DIR variable with path to directory that should be observed and shared.

API is deployed on 0.0.0.0:8080 by default, it can be overridden by setting environment variables DEPLOY_HOST and DEPLOY_PORT.

Example launch

ROOT_DIR=./storage go run .

Example docker-compose.yml setup.

version: '3.8'

services:
  catalog_deployer:
    build:
      context: .
    ports:
      - "8080:8080"
    environment:
      - ROOT_DIR=/storage
    volumes:
      - ./tests/test_dir:/storage

volumes:
  storage:

Code Example

func GetEntityInfo(path string) Entity {
var (
eType   string
content string
)
name := filepath.Base(path)
if isDir(path) {
eType = "directory"
content = strings.Join(listEntities(path), ",")
} else {
fileContent, err := ioutil.ReadFile(path)
if err != nil {
log.Fatal(err)
}
eType = getFileType(name)
content = string(fileContent)
}

return Entity{
Name:    name,
Type:    eType,
Content: content,
}
}

catalog-deployer's People

Contributors

sqoshi avatar

Stargazers

Jarrod Roberson avatar

Watchers

 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.