common

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigFileBasename = ".yaml"

Variables

View Source
var (
	Version   = "Unknown version"
	BuildTime = "Unknown build time"
	GitCommit = "Unknown GitCommit"
)

Functions

func CheckFileOverSSH

func CheckFileOverSSH(filePath string, user string, host string, privateKeyFilePath string, hostKeyFilePath string) bool

func CheckLocalFile

func CheckLocalFile(filePath string) bool

func FormatForecastTimeShort added in v0.9.0

func FormatForecastTimeShort(forecastTime time.Duration) string

func GenerateForecastTime added in v0.9.0

func GenerateForecastTime(forecastTime time.Duration, timeInterval string) time.Duration

GenerateForecastTime generate a new time duration calculated from a forecast time and a time interval. should be used with getForecastHour, getForecastMinute functions.

func GenerateStartTime added in v0.9.0

func GenerateStartTime(startTime time.Time, hour int) time.Time

GenerateStartTime generates a new time add or minus some hours. used in template files. should be used with getYear, getMonth, getDay, getHour functions. usage:

{generateStartTime .StartTime -3 | getYear}

func GetDay added in v0.9.0

func GetDay(startTime time.Time) string

func GetForecastHour added in v0.9.0

func GetForecastHour(forecastTime time.Duration) int

GetForecastHour get hour from forecast time. used in template files. Usage:

{.ForecastTime | getForecastHour | printf "%03d"}

func GetForecastMinute added in v0.9.0

func GetForecastMinute(forecastTime time.Duration) int

GetForecastMinute get minute from forecast time. used in template files. Usage:

{.ForecastTime | getForecastMinute | printf "%02d"}

func GetHour added in v0.9.0

func GetHour(startTime time.Time) string

func GetMonth added in v0.9.0

func GetMonth(startTime time.Time) string

func GetYear added in v0.9.0

func GetYear(startTime time.Time) string

func LoadConfigContent added in v0.9.0

func LoadConfigContent(configDir string, dataType string) (string, error)

LoadConfigContent read config content from a local file or from embedded config strings.

func ParseForecastTime

func ParseForecastTime(value string) (time.Duration, error)

func ParseStartTime

func ParseStartTime(value string) (time.Time, error)

func PrepareLocalDir

func PrepareLocalDir(filePath string)

func PrintVersionInformation

func PrintVersionInformation()

Types

type DataConfig

type DataConfig struct {
	Default   string     `yaml:"default"`
	FileName  string     `yaml:"file_name"`
	FileNames []string   `yaml:"file_names"`
	Paths     []PathItem `yaml:"paths"`
}

func LoadConfig

func LoadConfig(configDir string, dataType string) (DataConfig, error)

func LoadDataConfigFromContent added in v0.9.0

func LoadDataConfigFromContent(content string) (DataConfig, error)

LoadDataConfigFromContent parse DataConfig from string content.

func ParseConfigContent added in v0.9.0

func ParseConfigContent(content string, startTime time.Time, forecastTime time.Duration) (DataConfig, error)

ParseConfigContent parse config content template with start time and forecast time.

type PathItem

type PathItem struct {
	PathType  string `yaml:"type"`
	LevelType string `yaml:"level"`
	Path      string `yaml:"path"`
}

func FindHpcFile

func FindHpcFile(
	config DataConfig, locationLevels []string, startTime time.Time, forecastTime time.Duration,
	storageUser string, storageHost string, privateKeyFilePath string, hostKeyFilePath string,
) PathItem

func FindLocalFile deprecated

func FindLocalFile(config DataConfig, locationLevels []string, startTime time.Time, forecastTime time.Duration) PathItem

Deprecated: FindLocalFile should be replaced by FindLocalFileV2.

func FindLocalFileV2 added in v0.9.0

func FindLocalFileV2(config DataConfig, locationLevels []string, startTime time.Time, forecastTime time.Duration) PathItem

type TimeTemplateVariable

type TimeTemplateVariable struct {
	StartTime      time.Time
	ForecastTime   time.Duration
	Year           string
	Month          string
	Day            string
	Hour           string
	ForecastHour   string
	ForecastMinute string
}

func GenerateTimeTemplateVariable

func GenerateTimeTemplateVariable(startTime time.Time, forecastTime time.Duration) TimeTemplateVariable

Directories

Path Synopsis
this is a auto generated file.
this is a auto generated file.
generate command

Jump to

Keyboard shortcuts

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