v1.16.1
FIXED: * *Some* documentation weirdness on pkg.go dev rendering. It still uses the Markdown render by default, and it seems if you use anchor links in a bulletpoint list, pandoc just says "lol screw you"... ADDED: * tplx/sprigx tpl function `osHostname`
This commit is contained in:
@@ -21,11 +21,22 @@ SprigX are extensions to https://masterminds.github.io/sprig/[the `sprig` librar
|
|||||||
|
|
||||||
They provide functions that offer more enriched use cases and domain-specific data.
|
They provide functions that offer more enriched use cases and domain-specific data.
|
||||||
|
|
||||||
|
[TIP]
|
||||||
|
====
|
||||||
|
If you are reading this README on the Go Module Directory documentation (https://pkg.go.dev/r00t2.io/goutils/tplx/sprigx)
|
||||||
|
or the directory landing page (https://git.r00t2.io/r00t2/go_goutils/src/branch/master/tplx/sprigx), it may not render correctly.
|
||||||
|
|
||||||
|
Be sure to view it at properly via https://git.r00t2.io/r00t2/go_goutils/src/branch/master/tplx/sprigx/README.adoc[the AsciiDoc rendering^]
|
||||||
|
or by downloading and viewing the https://git.r00t2.io/r00t2/go_goutils/raw/branch/master/tplx/sprigx/README.html[HTML version^].
|
||||||
|
====
|
||||||
|
|
||||||
[id="use"]
|
[id="use"]
|
||||||
== How do I Use SprigX?
|
== How do I Use SprigX?
|
||||||
|
|
||||||
|
The same way you would `sprig`!
|
||||||
|
|
||||||
[%collapsible]
|
[%collapsible]
|
||||||
.The same way you would `sprig`!
|
.Like this.
|
||||||
====
|
====
|
||||||
[source,go]
|
[source,go]
|
||||||
----
|
----
|
||||||
@@ -53,8 +64,10 @@ var (
|
|||||||
----
|
----
|
||||||
====
|
====
|
||||||
|
|
||||||
|
They can even be combined/used together.
|
||||||
|
|
||||||
[%collapsible]
|
[%collapsible]
|
||||||
.They can even be combined/used together.
|
.Like this.
|
||||||
====
|
====
|
||||||
[source,go]
|
[source,go]
|
||||||
----
|
----
|
||||||
@@ -93,8 +106,10 @@ If a `<template>.FuncMap` is added via `.Funcs()` *after* template parsing, it w
|
|||||||
|
|
||||||
For example, if both `sprig` and `sprigx` provide a function `foo`:
|
For example, if both `sprig` and `sprigx` provide a function `foo`:
|
||||||
|
|
||||||
|
this will use `foo` from `sprigx`
|
||||||
|
|
||||||
[%collapsible]
|
[%collapsible]
|
||||||
.this will use `foo` from `sprigx`
|
.(show)
|
||||||
====
|
====
|
||||||
[source,go]
|
[source,go]
|
||||||
----
|
----
|
||||||
@@ -123,10 +138,10 @@ var (
|
|||||||
----
|
----
|
||||||
====
|
====
|
||||||
|
|
||||||
whereas
|
whereas this will use `foo` from `sprig`
|
||||||
|
|
||||||
[%collapsible]
|
[%collapsible]
|
||||||
.this will use `foo` from `sprig`
|
.(show)
|
||||||
====
|
====
|
||||||
[source,go]
|
[source,go]
|
||||||
----
|
----
|
||||||
@@ -155,10 +170,10 @@ var (
|
|||||||
----
|
----
|
||||||
====
|
====
|
||||||
|
|
||||||
and a function can even be
|
and a function can even be explicitly overridden.
|
||||||
|
|
||||||
[%collapsible]
|
[%collapsible]
|
||||||
.explicitly overridden.
|
.(show)
|
||||||
====
|
====
|
||||||
This would override a function `foo` and `foo2` in `sprigx` from `foo` and `foo2` from `sprig`, but leave all other `sprig` functions untouched.
|
This would override a function `foo` and `foo2` in `sprigx` from `foo` and `foo2` from `sprig`, but leave all other `sprig` functions untouched.
|
||||||
|
|
||||||
@@ -201,8 +216,17 @@ var (
|
|||||||
== Functions
|
== Functions
|
||||||
Expect this list to grow over time, and potentially more frequently than the `sprigx` functions.
|
Expect this list to grow over time, and potentially more frequently than the `sprigx` functions.
|
||||||
|
|
||||||
|
[id="fn_os"]
|
||||||
|
=== Operating System
|
||||||
|
|
||||||
|
[id="fn_os_hstnm"]
|
||||||
|
==== `osHostname`
|
||||||
|
`osHostname` simply wraps and returns the result of calling https://pkg.go.dev/os#Hostname[`os.Hostname`^].
|
||||||
|
|
||||||
|
As such, it comes with the same caveats - it's possible for it to error, and it isn't guaranteed to be an FQDN -- it will be precisely/exactly whatever the kernel's hostname is set as.
|
||||||
|
|
||||||
[id="fn_sys"]
|
[id="fn_sys"]
|
||||||
=== System/OS/Platform
|
=== System/Platform/Architecture
|
||||||
|
|
||||||
[id="fn_sys_arch"]
|
[id="fn_sys_arch"]
|
||||||
==== `sysArch`
|
==== `sysArch`
|
||||||
|
|||||||
13
tplx/sprigx/funcs_tpl_os.go
Normal file
13
tplx/sprigx/funcs_tpl_os.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package sprigx
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// osHostname returns os.Hostname()
|
||||||
|
func osHostname() (out string, err error) {
|
||||||
|
|
||||||
|
out, err = os.Hostname()
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user