gg_deployer

package
v0.2.99 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2024 License: BSD-3-Clause Imports: 12 Imported by: 1

README

Deployer

Deploy files into output directory.

Use a Virtual File System approach, so you can write your own file writer (FTP, Google Drive, etc...).

Sample usage:

package main

import (
	"bitbucket.org/digi-sense/gg-core"
	"bitbucket.org/digi-sense/gg-core/gg_deployer"
)

func main(){
	// init workspace
	gg.Paths.SetWorkspacePath("./")

	// load options for deployer
	options, err := gg_deployer.NewDeployerOptions("./deployer.json")
	if nil!=err{
		panic(err)
    }

	// create a deployer
	deployer, err := gg_deployer.NewDeployer(options)
	if nil!=err{
		panic(err)
	}
	
	// open and load from "DirLoad" option 
	err = deployer.Open()
	if nil!=err{
		panic(err)
	}

	// load a file to deploy later
	err = deployer.LoadFilename("./sample.txt")
	if nil!=err{
		panic(err)
	}
	
	// deploy anything loaded from "DirLoad" option and LoadFile method
	err = deployer.DeployAll()
	if nil!=err{
		panic(err)
	}
	
	// close and remove all deployed files if "empty-dir-deploy-on-close" options is true
    err = deployer.Close()
	if nil!=err{
		panic(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeployCtrl

type DeployCtrl struct {
	// contains filtered or unexported fields
}

func NewDeployer

func NewDeployer(args ...interface{}) (instance *DeployCtrl, err error)

func (*DeployCtrl) Close

func (instance *DeployCtrl) Close() (err error)

func (*DeployCtrl) CountLoaded added in v0.2.71

func (instance *DeployCtrl) CountLoaded() int

func (*DeployCtrl) Deploy

func (instance *DeployCtrl) Deploy(content string, fileName string, overwrite bool) (err error)

func (*DeployCtrl) DeployAll

func (instance *DeployCtrl) DeployAll() (count int, err error)

func (*DeployCtrl) DeployFile

func (instance *DeployCtrl) DeployFile(file *DeployerFile) (err error)

func (*DeployCtrl) DeployFileWithOptions

func (instance *DeployCtrl) DeployFileWithOptions(file *DeployerFile, options *DeployerFileWriteOptions) (err error)

func (*DeployCtrl) DeployFilename

func (instance *DeployCtrl) DeployFilename(filename string) (err error)

func (*DeployCtrl) Deployed

func (instance *DeployCtrl) Deployed() []string

func (*DeployCtrl) LoadFile

func (instance *DeployCtrl) LoadFile(file *DeployerFile) (err error)

func (*DeployCtrl) LoadFilename

func (instance *DeployCtrl) LoadFilename(filename string) (err error)

func (*DeployCtrl) Loaded

func (instance *DeployCtrl) Loaded() []*DeployerFile

func (*DeployCtrl) Map

func (instance *DeployCtrl) Map() (response map[string]interface{})

func (*DeployCtrl) Open

func (instance *DeployCtrl) Open() (err error)

func (*DeployCtrl) String

func (instance *DeployCtrl) String() string

func (*DeployCtrl) Uid added in v0.2.71

func (instance *DeployCtrl) Uid() string

func (*DeployCtrl) WalkLoaded added in v0.2.65

func (instance *DeployCtrl) WalkLoaded(callback func(file *DeployerFile)) *DeployCtrl

WalkLoaded pass all loaded files to a callback function for changes

type DeployerFile

type DeployerFile struct {
	Filename  string `json:"filename"` // name of the file. i.e. "index.html"
	Content   []byte `json:"content"`  // content in bytes
	Path      string `json:"path"`     // Output path. For example, "/files/out/". If empty is used the default value
	Overwrite bool   `json:"overwrite"`
	Minify    bool   `json:"minify"`
}

func NewDeployerFile added in v0.2.67

func NewDeployerFile(filename string, content []byte, dirDeploy string, overwrite, minify bool) (response *DeployerFile)

func (*DeployerFile) GetAbsolutePath

func (instance *DeployerFile) GetAbsolutePath() string

func (*DeployerFile) String

func (instance *DeployerFile) String() string

type DeployerFileSystemOptions

type DeployerFileSystemOptions struct {
	DriverName string                 `json:"driver-name"`
	Payload    map[string]interface{} `json:"payload"`
}

type DeployerFileWriteOptions

type DeployerFileWriteOptions struct {
	FileSystem *DeployerFileSystemOptions `json:"file-system"`
	DirDeploy  string                     `json:"dir-deploy"`
	Overwrite  bool                       `json:"overwrite"` // default overwrite
	Minify     bool                       `json:"minify"`
}

type DeployerHelper

type DeployerHelper struct {
}
var Deployer *DeployerHelper

func (*DeployerHelper) New

func (instance *DeployerHelper) New(args ...interface{}) (response *DeployCtrl, err error)

type DeployerOptions

type DeployerOptions struct {
	DeployerFileWriteOptions
	DirLoad               []string `json:"dir-load"`
	DirLoadFileFilter     string   `json:"dir-load-file-filter"`
	EmptyDirDeployOnClose bool     `json:"empty-dir-deploy-on-close"`
}

func NewDeployerOptions

func NewDeployerOptions(args ...interface{}) (instance *DeployerOptions, err error)

func (*DeployerOptions) Map

func (instance *DeployerOptions) Map() (response map[string]interface{})

func (*DeployerOptions) String

func (instance *DeployerOptions) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL