pathcompiler

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName      = pathsconst.AppName
	AppNameLower = pathsconst.AppNameLower
)

Variables

View Source
var (
	TempAppTestRoot                = pathsconst.TempAppTestRoot                // /tmp/{app-name}-test-env/
	TempAppRoot                    = pathsconst.TempAppRoot                    // /var/tmp/{app-name}
	AppWindowsUserSpecificTempRoot = pathsconst.AppWindowsUserSpecificTempRoot // %temp%\{app-name}

	CurrentOsType = osmixtype.CurrentOsMixType()

	DefaultApp = Basic{
		AppName:      AppName,
		AppNameLower: AppNameLower,
		ProductionMap: map[osmixtype.Variant]*Specific{
			osmixtype.AnyOs:   &UnixOs,
			osmixtype.Ubuntu:  &UnixOs,
			osmixtype.Windows: &WindowsOs,
		},
		TestMap: map[osmixtype.Variant]*Specific{
			osmixtype.AnyOs: &AnyOsTest,
		},
	}
)
View Source
var AnyOsTest = Specific{
	Name:                     "AnyOs Test",
	Description:              "all os test paths",
	Url:                      "",
	ReplacerMap:              nil,
	SpecificPathFileLocation: TempAppTestRoot + DefaultSuffix.SpecificPathFileLocation,
	VarAppRoot:               TempAppTestRoot,
	EtcAppRoot:               TempAppTestRoot + "/etc/",
	EtcAppConfigRoot:         TempAppTestRoot + "/etc/config",
	AppDbRoot:                TempAppTestRoot + DefaultSuffix.AppDbRoot,
	TempRoot:                 TempAppTestRoot + pathsconst.UnixTemp,
	UserTempRoot:             TempAppTestRoot + pathsconst.UnixTemp + DefaultSuffix.UserTempRoot,
	CacheTempRoot:            TempAppTestRoot + pathsconst.UnixTemp + DefaultSuffix.CacheTempRoot,
	InstructionTempRoot:      TempAppTestRoot + pathsconst.UnixTemp + DefaultSuffix.InstructionTempRoot,
	MigrationCacheRoot:       TempAppTestRoot + pathsconst.UnixTemp + DefaultSuffix.MigrationCacheRoot,
	PackageTempRoot:          TempAppTestRoot + pathsconst.UnixTemp + DefaultSuffix.PackageTempRoot,
	LogAppRoot:               TempAppTestRoot + pathsconst.VarLog,
	VarCacheRoot:             TempAppTestRoot + pathsconst.VarOpt + DefaultSuffix.VarCacheRoot,
	DownloadsRoot:            TempAppTestRoot + pathsconst.VarOpt + DefaultSuffix.DownloadsRoot,
	ScriptsRoot:              TempAppTestRoot + DefaultSuffix.ScriptsRoot,
	DecompressRoot:           TempAppTestRoot + DefaultSuffix.DecompressRoot,
	PackagesRoot:             TempAppTestRoot + DefaultSuffix.PackagesRoot,
	PackagesDownloadRoot:     TempAppTestRoot + DefaultSuffix.PackagesDownloadRoot,
	DefaultInstructionsRoot:  TempAppTestRoot + DefaultSuffix.DefaultInstructionsRoot,
	DefaultEnvRoot:           TempAppTestRoot + DefaultSuffix.DefaultEnvRoot,
	DefaultEnvPathRoot:       TempAppTestRoot + DefaultSuffix.DefaultEnvPathRoot,
	BackupRoot:               TempAppTestRoot + DefaultSuffix.BackupRoot,
	ArchiveRoot:              TempAppTestRoot + DefaultSuffix.ArchiveRoot,
	ZipsRoot:                 TempAppTestRoot + DefaultSuffix.ZipsRoot,
	DefaultConfigFilePath:    TempAppTestRoot + DefaultSuffix.DefaultConfigFilePath,
	SnapshotsRoot:            TempAppTestRoot + "/all" + DefaultSuffix.SnapshotsRoot,
	PublicRoot:               TempAppTestRoot + "/var/" + DefaultSuffix.PublicRoot,
	SslRoot:                  TempAppTestRoot + "/all" + DefaultSuffix.SslRoot,
}
View Source
var DefaultSuffix = Suffixes{
	Specific{
		Name:                     "Suffix map",
		Description:              "Only suffix",
		SpecificPathFileLocation: "/defined-paths/paths.json",
		VarAppRoot:               AppNameLower,
		EtcAppRoot:               AppNameLower,
		EtcAppConfigRoot:         defaultConfigRootSuffix,
		AppDbRoot:                "/databases/",
		TempRoot:                 AppNameLower,
		UserTempRoot:             "/users/",
		CacheTempRoot:            "/cache/",
		InstructionTempRoot:      instructionDirName,
		MigrationCacheRoot:       "/migration-cache/",
		PackageTempRoot:          packagesDirName,
		LogAppRoot:               AppNameLower,
		VarCacheRoot:             "/cache/",
		DownloadsRoot:            "/downloads/",
		ScriptsRoot:              "/scripts/",
		DecompressRoot:           "/decompress/",
		PackagesRoot:             packagesDirName,
		PackagesDownloadRoot:     "/packages-downloaded/",
		DefaultInstructionsRoot:  instructionDirName,
		DefaultEnvRoot:           "/env/",
		DefaultEnvPathRoot:       "/env-paths/",
		BackupRoot:               "/backups/",
		ArchiveRoot:              "/archived/",
		ZipsRoot:                 "/compressed/",
		DefaultConfigFilePath:    defaultConfigRootSuffix + "/default-config.json",
		SnapshotsRoot:            "-snapshots/",
		PublicRoot:               "www/",
		SslRoot:                  "-ssl/",
	},
}
View Source
var UnixOs = Specific{
	Name:                     "Unix",
	Description:              "all unix(ubuntu, debian, linux, darwin ...) related os paths",
	SpecificPathFileLocation: unixVarAppRoot + DefaultSuffix.SpecificPathFileLocation,
	VarAppRoot:               unixVarAppRoot,
	EtcAppRoot:               etcApp,
	EtcAppConfigRoot:         unixConfigRoot,
	AppDbRoot:                unixVarAppRoot + DefaultSuffix.AppDbRoot,
	TempRoot:                 TempAppRoot,
	UserTempRoot:             TempAppRoot + DefaultSuffix.UserTempRoot,
	CacheTempRoot:            TempAppRoot + DefaultSuffix.CacheTempRoot,
	InstructionTempRoot:      TempAppRoot + DefaultSuffix.InstructionTempRoot,
	MigrationCacheRoot:       TempAppRoot + DefaultSuffix.MigrationCacheRoot,
	PackageTempRoot:          TempAppRoot + DefaultSuffix.PackageTempRoot,
	LogAppRoot:               unixLogAppRoot,
	VarCacheRoot:             unixVarAppRoot + DefaultSuffix.VarCacheRoot,
	DownloadsRoot:            unixVarAppRoot + DefaultSuffix.DownloadsRoot,
	ScriptsRoot:              unixVarAppRoot + DefaultSuffix.ScriptsRoot,
	DecompressRoot:           TempAppRoot + DefaultSuffix.DecompressRoot,
	PackagesRoot:             etcApp + DefaultSuffix.PackagesRoot,
	PackagesDownloadRoot:     unixVarAppRoot + DefaultSuffix.PackagesDownloadRoot,
	DefaultInstructionsRoot:  unixVarAppRoot + DefaultSuffix.DefaultInstructionsRoot,
	DefaultEnvRoot:           unixVarAppRoot + DefaultSuffix.DefaultEnvRoot,
	DefaultEnvPathRoot:       unixVarAppRoot + DefaultSuffix.DefaultEnvPathRoot,
	BackupRoot:               unixVarAppRoot + DefaultSuffix.BackupRoot,
	ArchiveRoot:              unixVarAppRoot + DefaultSuffix.ArchiveRoot,
	ZipsRoot:                 unixVarAppRoot + DefaultSuffix.ZipsRoot,
	DefaultConfigFilePath:    etcApp + DefaultSuffix.DefaultConfigFilePath,
	SnapshotsRoot:            unixVarAppRoot + DefaultSuffix.SnapshotsRoot,
	PublicRoot:               "/var/" + DefaultSuffix.PublicRoot,
	SslRoot:                  unixVarAppRoot + DefaultSuffix.SslRoot,
}
View Source
var WindowsOs = Specific{
	Name:                     "Windows",
	Description:              "all windows related os paths",
	Url:                      "",
	SpecificPathFileLocation: windowsProductionDefault + DefaultSuffix.SpecificPathFileLocation,
	VarAppRoot:               windowsProductionDefault,
	EtcAppRoot:               windowsProductionDefault,
	EtcAppConfigRoot:         windowsProductionDefault + DefaultSuffix.EtcAppConfigRoot,
	AppDbRoot:                windowsProductionDefault + DefaultSuffix.AppDbRoot,
	TempRoot:                 AppWindowsUserSpecificTempRoot,
	UserTempRoot:             AppWindowsUserSpecificTempRoot + DefaultSuffix.UserTempRoot,
	CacheTempRoot:            AppWindowsUserSpecificTempRoot + DefaultSuffix.CacheTempRoot,
	InstructionTempRoot:      AppWindowsUserSpecificTempRoot + DefaultSuffix.InstructionTempRoot,
	MigrationCacheRoot:       AppWindowsUserSpecificTempRoot + DefaultSuffix.MigrationCacheRoot,
	PackageTempRoot:          AppWindowsUserSpecificTempRoot + DefaultSuffix.PackageTempRoot,
	LogAppRoot:               windowsProductionDefault + "\\logs",
	VarCacheRoot:             windowsProductionDefault + DefaultSuffix.VarCacheRoot,
	DownloadsRoot:            TempAppRoot + DefaultSuffix.DownloadsRoot,
	ScriptsRoot:              windowsProductionDefault + DefaultSuffix.ScriptsRoot,
	DecompressRoot:           TempAppRoot + DefaultSuffix.DecompressRoot,
	PackagesRoot:             windowsProductionDefault + DefaultSuffix.PackagesRoot,
	PackagesDownloadRoot:     windowsProductionDefault + DefaultSuffix.PackagesDownloadRoot,
	DefaultInstructionsRoot:  windowsProductionDefault + DefaultSuffix.DefaultInstructionsRoot,
	DefaultEnvRoot:           windowsProductionDefault + DefaultSuffix.DefaultEnvRoot,
	DefaultEnvPathRoot:       windowsProductionDefault + DefaultSuffix.DefaultEnvPathRoot,
	BackupRoot:               windowsProductionDefault + DefaultSuffix.BackupRoot,
	ArchiveRoot:              windowsProductionDefault + DefaultSuffix.ArchiveRoot,
	ZipsRoot:                 windowsProductionDefault + DefaultSuffix.ZipsRoot,
	DefaultConfigFilePath:    windowsProductionDefault + DefaultSuffix.DefaultConfigFilePath,
	SnapshotsRoot:            windowsProductionDefault + "\\config" + DefaultSuffix.SnapshotsRoot,
	PublicRoot:               osconsts.WindowsCDrive + "public_root\\" + DefaultSuffix.PublicRoot,
	SslRoot:                  windowsProductionDefault + "\\all" + DefaultSuffix.SslRoot,
}

Functions

This section is empty.

Types

type Basic

type Basic struct {
	AppName       string
	AppNameLower  string
	ProductionMap map[osmixtype.Variant]*Specific
	TestMap       map[osmixtype.Variant]*Specific
}

func (Basic) AsJsonContractsBinder

func (it Basic) AsJsonContractsBinder() corejson.JsonContractsBinder

func (*Basic) By

func (it *Basic) By(
	osType osmixtype.Variant,
) *Specific

func (*Basic) ByEnv

func (it *Basic) ByEnv(
	envType enuminf.EnvironmentTyper,
) *Specific

func (*Basic) ByEnvFlagOs added in v0.7.8

func (it *Basic) ByEnvFlagOs(
	isTestEnv bool,
	osType osmixtype.Variant,
) *Specific

func (*Basic) ByEnvOs added in v0.7.8

func (it *Basic) ByEnvOs(
	envVariant envtype.Variant,
	osType osmixtype.Variant,
) *Specific

func (*Basic) CurrentOs

func (it *Basic) CurrentOs() *Specific

func (*Basic) DefaultConfigFilePath

func (it *Basic) DefaultConfigFilePath() string

DefaultConfigFilePath

eg. unix :
pathsconst.UnixVarAppRoot + "/config/default-config.json" =>
"/var/opt/{app-name}/config/default-config.json"

func (*Basic) JoinWithAppConfigRoot

func (it *Basic) JoinWithAppConfigRoot(
	relativePaths ...string,
) string

func (*Basic) JoinWithDefaultInstructionsRoot

func (it *Basic) JoinWithDefaultInstructionsRoot(
	relativePaths ...string,
) string

func (*Basic) JoinWithInstructionTempRoot

func (it *Basic) JoinWithInstructionTempRoot(
	relativePaths ...string,
) string

func (*Basic) JoinWithTempRoot

func (it *Basic) JoinWithTempRoot(
	relativePaths ...string,
) string

func (*Basic) JoinWithVarAppRoot

func (it *Basic) JoinWithVarAppRoot(
	relativePaths ...string,
) string

func (*Basic) Json

func (it *Basic) Json() corejson.Result

func (*Basic) JsonParseSelfInject

func (it *Basic) JsonParseSelfInject(jsonResult *corejson.Result) error

func (*Basic) JsonPtr

func (it *Basic) JsonPtr() *corejson.Result

func (*Basic) PrettyJsonString

func (it *Basic) PrettyJsonString() string

func (*Basic) ReflectSetTo

func (it *Basic) ReflectSetTo(toPtr interface{}) error

func (*Basic) ReflectSetToErrWrap

func (it *Basic) ReflectSetToErrWrap(toPtr interface{}) *errorwrapper.Wrapper

func (*Basic) TestBy

func (it *Basic) TestBy(
	osType osmixtype.Variant,
) *Specific

func (*Basic) TestCurrentOs

func (it *Basic) TestCurrentOs() *Specific

func (*Basic) ToNonPtr

func (it *Basic) ToNonPtr() Basic

func (Basic) ToPtr

func (it Basic) ToPtr() *Basic

type Segment

type Segment struct {
	Name, Format string
	// contains filtered or unexported fields
}

type Specific

type Specific struct {
	Name                     string            `json:"Name,omitempty"`
	Description              string            `json:"Description,omitempty"`
	Url                      string            `json:"Url,omitempty"`
	ReplacerMap              map[string]string `json:"ReplacerMap,omitempty"` // todo later add dynamic way of getting format path
	SpecificPathFileLocation string            // eg. self saving location, unix : "/var/opt/{app-name}/defined-paths/paths.json"
	VarAppRoot               string            // eg. unix : "/var/opt/{app-name}"
	EtcAppRoot               string            // eg. unix : "/etc/{app-name}"
	EtcAppConfigRoot         string            // eg. unix : "/etc/{app-name}/config"
	AppDbRoot                string            // eg. unix : "/var/opt/{app-name}/databases"
	TempRoot                 string            // eg. unix : TempAppRoot => TempPermanentDir + AppNameLower => "/{os-temp}/{app-name}"
	UserTempRoot             string            // eg. unix : "/{os-temp}/{app-name}/users/"
	CacheTempRoot            string            // eg. unix : "/{os-temp}/{app-name}/cache/"
	InstructionTempRoot      string            // eg. unix : "/{os-temp}/{app-name}/instructions/"
	MigrationCacheRoot       string            // eg. unix : "/{os-temp}/{app-name}/migration-cache/"
	PackageTempRoot          string            // eg. unix : "/{os-temp}/{app-name}/packages/"
	LogAppRoot               string            // eg. unix : pathsconst.UnixLogAppRoot + {app-name} => "/var/log/{app-name}/"
	VarCacheRoot             string            // eg. unix : pathsconst.UnixVarAppRoot + "cache" => "/var/opt/{app-name}/cache"
	DownloadsRoot            string            // eg. unix : pathsconst.UnixVarAppRoot + "downloads" => "/var/opt/{app-name}/downloads"
	ScriptsRoot              string            // eg. unix : pathsconst.UnixVarAppRoot + "scripts" => "/var/opt/{app-name}/scripts"
	DecompressRoot           string            // eg. unix : pathsconst.UnixVarAppRoot + "decompress" => "/var/opt/{app-name}/decompress"
	PackagesRoot             string            // eg. unix : pathsconst.UnixVarAppRoot + "packages" => "/var/opt/{app-name}/packages"
	PackagesDownloadRoot     string            // eg. unix : pathsconst.UnixVarAppRoot + "packages-downloaded" => "/var/opt/{app-name}/packages-downloaded/"
	DefaultInstructionsRoot  string            // eg. unix : pathsconst.UnixVarAppRoot + "/instructions/" => "/var/opt/{app-name}/instructions/"
	DefaultEnvRoot           string            // eg. unix : pathsconst.UnixVarAppRoot + "/env/" => "/var/opt/{app-name}/env/"
	DefaultEnvPathRoot       string            // eg. unix : pathsconst.UnixVarAppRoot + "/env-paths/" => "/var/opt/{app-name}/env-paths/"
	BackupRoot               string            // eg. unix : pathsconst.UnixVarAppRoot + "/backups/" => "/var/opt/{app-name}/backups/"
	ArchiveRoot              string            // eg. unix : pathsconst.UnixVarAppRoot + "/archived/" => "/var/opt/{app-name}/archived/"
	ZipsRoot                 string            // eg. unix : pathsconst.UnixVarAppRoot + "/compressed/" => "/var/opt/{app-name}/compressed/"
	DefaultConfigFilePath    string            // eg. unix : pathsconst.UnixVarAppRoot + "/config/default-config.json" => "/var/opt/{app-name}/config/default-config.json"
	SnapshotsRoot            string            // eg. unix : "/var/opt/{app-name}-snapshots/"
	PublicRoot               string            // eg. unix : "/var/www"
	SslRoot                  string            // eg. unix : "/var/opt/{app-name}-ssl/"
}

func (Specific) AsJsonContractsBinder

func (it Specific) AsJsonContractsBinder() corejson.JsonContractsBinder

func (*Specific) Clone

func (it *Specific) Clone() Specific

func (*Specific) ClonePtr

func (it *Specific) ClonePtr() *Specific

func (*Specific) CloneReplacerMap

func (it *Specific) CloneReplacerMap() map[string]string

func (*Specific) ExecutableDirPath

func (it *Specific) ExecutableDirPath() string

func (*Specific) IsDefined

func (it *Specific) IsDefined() bool

func (*Specific) IsNull

func (it *Specific) IsNull() bool

func (*Specific) JoinNormalized

func (it *Specific) JoinNormalized(
	baseDir string,
	relativePaths ...string,
) string

func (*Specific) JoinNormalizedExpand

func (it *Specific) JoinNormalizedExpand(
	baseDir string,
	relativePaths ...string,
) string

func (*Specific) JoinSimpleWith

func (it *Specific) JoinSimpleWith(
	baseDir string,
	relativePaths ...string,
) string

func (*Specific) JoinWith

func (it *Specific) JoinWith(
	baseDir string,
	relativePaths ...string,
) string

func (*Specific) JoinWithAppConfigRoot

func (it *Specific) JoinWithAppConfigRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithAppDbRoot

func (it *Specific) JoinWithAppDbRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithAppTempRoot

func (it *Specific) JoinWithAppTempRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithArchiveRoot

func (it *Specific) JoinWithArchiveRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithBackupRoot

func (it *Specific) JoinWithBackupRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithCacheTempRoot

func (it *Specific) JoinWithCacheTempRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithDecompressRoot

func (it *Specific) JoinWithDecompressRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithDefaultEnvPathRoot

func (it *Specific) JoinWithDefaultEnvPathRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithDefaultEnvRoot

func (it *Specific) JoinWithDefaultEnvRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithDefaultInstructionsRoot

func (it *Specific) JoinWithDefaultInstructionsRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithDownloadsRoot

func (it *Specific) JoinWithDownloadsRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithEtcAppRoot

func (it *Specific) JoinWithEtcAppRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithExecutableDirPath

func (it *Specific) JoinWithExecutableDirPath(
	relativePaths ...string,
) string

func (*Specific) JoinWithInstructionTempRoot

func (it *Specific) JoinWithInstructionTempRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithLogAppRoot

func (it *Specific) JoinWithLogAppRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithMigrationCacheRoot

func (it *Specific) JoinWithMigrationCacheRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithOptions

func (it *Specific) JoinWithOptions(
	isSkipEmpty bool,
	isNormalize bool,
	isExpand bool,
	baseDir string,
	relativePaths ...string,
) string

func (*Specific) JoinWithPackageTempRoot

func (it *Specific) JoinWithPackageTempRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithPackagesDownloadRoot

func (it *Specific) JoinWithPackagesDownloadRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithPackagesRoot

func (it *Specific) JoinWithPackagesRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithPublicRoot added in v0.7.6

func (it *Specific) JoinWithPublicRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithScriptsRoot

func (it *Specific) JoinWithScriptsRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithSnapshotsRoot added in v0.7.6

func (it *Specific) JoinWithSnapshotsRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithSslRoot added in v0.7.6

func (it *Specific) JoinWithSslRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithTempRoot

func (it *Specific) JoinWithTempRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithTempWithoutApp

func (it *Specific) JoinWithTempWithoutApp(
	relativePaths ...string,
) string

func (*Specific) JoinWithUserTempRoot

func (it *Specific) JoinWithUserTempRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithVarAppRoot

func (it *Specific) JoinWithVarAppRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithVarCacheRoot

func (it *Specific) JoinWithVarCacheRoot(
	relativePaths ...string,
) string

func (*Specific) JoinWithZipsRoot

func (it *Specific) JoinWithZipsRoot(
	relativePaths ...string,
) string

func (*Specific) Json

func (it *Specific) Json() corejson.Result

func (*Specific) JsonParseSelfInject

func (it *Specific) JsonParseSelfInject(jsonResult *corejson.Result) error

func (*Specific) JsonPtr

func (it *Specific) JsonPtr() *corejson.Result

func (*Specific) PrettyJsonString

func (it *Specific) PrettyJsonString() string

func (*Specific) ReflectSetTo

func (it *Specific) ReflectSetTo(toPtr interface{}) error

func (*Specific) ReflectSetToErrWrap

func (it *Specific) ReflectSetToErrWrap(toPtr interface{}) *errorwrapper.Wrapper

func (*Specific) ToNonPtr

func (it *Specific) ToNonPtr() Specific

func (Specific) ToPtr

func (it Specific) ToPtr() *Specific

type Suffixes

type Suffixes struct {
	Specific
}

Jump to

Keyboard shortcuts

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