mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-08 18:39:25 +02:00
This finishes the work started at #1619 by introducing the following changes: - You can now set `HELMFILE_TEMPDIR` and `CHARTIFY_TEMPDIR` as the directory to persist temporary values files rendered by helmfile and temporary charts generated by chartify. Note that chartify is used internally when you use kustomize integration or raw K8s manifests as a chart. - Helmfile uses the hash sum of the release config and the values file content in the file name of the temporary values file. In combination with `HELMFILE_TEMPDIR` and `CHARTIFY_TEMPDIR`, this enables helmfile to use the stable file names for temporary values files, which contribute to stabilize log messages like `Comparing release=appset, chart=PATH/TO/TEMPORARY/CHART`, where the `PATH/TO/TEMPORARY/CHART` had been randomized due to formerly random helmfile tempdir and temporary values file names, and random chartify tempdir. You can try this feature with a script like: ``` tempdir=$(mktemp -d -t helmfile) HELMFILE_TEMPDIR=${tempdir} CHARTIFY_TEMPDIR=${tempdir} helmfile diff rm -rf ${tempdir} ```
34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
/*
|
|
Copyright 2015 The Kubernetes Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
// See k8s.io/apimachinery/pkg/util/rand/rand.go
|
|
package state
|
|
|
|
const (
|
|
// We omit vowels from the set of available characters to reduce the chances
|
|
// of "bad words" being formed.
|
|
alphanums = "bcdfghjklmnpqrstvwxz2456789"
|
|
)
|
|
|
|
// SafeEncodeString encodes s using the same characters as rand.String. This reduces the chances of bad words and
|
|
// ensures that strings generated from hash functions appear consistent throughout the API.
|
|
func SafeEncodeString(s string) string {
|
|
r := make([]byte, len(s))
|
|
for i, b := range []rune(s) {
|
|
r[i] = alphanums[(int(b) % len(alphanums))]
|
|
}
|
|
return string(r)
|
|
}
|