Skip to content

Commit

Permalink
Merge pull request #8 from hashicorp/expand_binary_configs
Browse files Browse the repository at this point in the history
Allow more configuration of packaged binary
  • Loading branch information
kpenfound authored Sep 2, 2022
2 parents d3bec88 + 4cd2d2c commit 514d75d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ inputs:
binary:
description: 'Binary location to package.'
default: ''
required: true
required: false
bin_path:
description: 'Path to install the binary at'
default: '/usr/bin'
required: false
config_dir:
description: 'Directory of configs in desired filesystem structure.'
default: ''
Expand Down
10 changes: 7 additions & 3 deletions fpm_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type NfpmInput struct {
License string
Depends []string
Binary string
BinaryName string
BinaryDest string
Preinstall string
Postinstall string
Preremove string
Expand Down Expand Up @@ -78,6 +78,7 @@ func main() {
inputLicense := os.Getenv("INPUT_LICENSE")
inputDepends := os.Getenv("INPUT_DEPENDS")
inputBinary := os.Getenv("INPUT_BINARY")
inputBinPath := os.Getenv("INPUT_BIN_PATH")
inputConfigDir := os.Getenv("INPUT_CONFIG_DIR")
inputPreinstall := os.Getenv("INPUT_PREINSTALL")
inputPostinstall := os.Getenv("INPUT_POSTINSTALL")
Expand All @@ -89,6 +90,7 @@ func main() {
depends = []string{}
}
binName := filepath.Base(inputBinary)
binDest := filepath.Join(inputBinPath, binName)

// This maps to "armv7hl" for rpm and "armhf" for deb
// "arm" is not a valid arch for either type, and it
Expand All @@ -110,7 +112,7 @@ func main() {
License: inputLicense,
Depends: depends,
Binary: inputBinary,
BinaryName: binName,
BinaryDest: binDest,
Preinstall: inputPreinstall,
Postinstall: inputPostinstall,
Preremove: inputPreremove,
Expand Down Expand Up @@ -142,8 +144,10 @@ depends:
{{- end }}
{{- end }}
contents:
{{- if ne .Binary "" }}
- src: {{ .Binary }}
dst: /usr/bin/{{ .BinaryName }}
dst: {{ .BinaryDest }}
{{- end }}
{{- with .ConfigFiles }}
{{- range $index, $element := . }}
- src: {{ .LocalPath }}
Expand Down

0 comments on commit 514d75d

Please sign in to comment.