Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,13 @@ func GetDefaultSquashfsCompressionOptions() []string {
// GetRunKeyEnvMap returns environment variable bindings to RunConfig data
func GetRunKeyEnvMap() map[string]string {
return map[string]string{
"poweroff": "POWEROFF",
"reboot": "REBOOT",
"strict": "STRICT",
"eject-cd": "EJECT_CD",
"snapshotter.type": "SNAPSHOTTER_TYPE",
"cloud-init-paths": "CLOUD_INIT_PATHS",
"poweroff": "POWEROFF",
"reboot": "REBOOT",
"strict": "STRICT",
"eject-cd": "EJECT_CD",
"snapshotter.type": "SNAPSHOTTER_TYPE",
"snapshotter.max-snaps": "SNAPSHOTTER_MAX_SNAPS",
"cloud-init-paths": "CLOUD_INIT_PATHS",
}
}

Expand Down
13 changes: 12 additions & 1 deletion pkg/types/snapshotter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package types

import (
"fmt"
"strconv"

mapstructure "github.com/mitchellh/mapstructure"
"github.com/rancher/elemental-toolkit/v2/pkg/constants"
Expand Down Expand Up @@ -142,7 +143,17 @@ func (c *SnapshotterConfig) CustomUnmarshal(data interface{}) (bool, error) {
if mData["max-snaps"] != nil {
maxSnaps, ok := mData["max-snaps"].(int)
if !ok {
return false, fmt.Errorf("'max-snap' must be of integer type")
// If not integer value, try to convert from string.
// This will be the case when passed as env variable ELEMENTAL_SNAPSHOTTER_MAX_SNAPS
maxSnapsFromEnv, ok := mData["max-snaps"].(string)
if !ok {
return false, fmt.Errorf("'max-snap' must be of integer type")
}
maxSnapsConverted, err := strconv.Atoi(maxSnapsFromEnv)
if err != nil {
return false, fmt.Errorf("converting 'max-snap' from string input to integer type: %w", err)
}
maxSnaps = maxSnapsConverted
}
c.MaxSnaps = maxSnaps
} else if c.Type == constants.BtrfsSnapshotterType {
Expand Down