Environment variabled are populated in random order, causing functional tests in golang #518 to fail

This commit is contained in:
Abhishek
2017-06-14 12:58:56 +05:30
parent f066834e3d
commit 719dae97e4
3 changed files with 32 additions and 3 deletions
+20
View File
@@ -28,6 +28,7 @@ import (
"path/filepath"
"github.com/pkg/errors"
"k8s.io/kubernetes/pkg/api"
)
const Selector = "io.kompose.service"
@@ -151,3 +152,22 @@ func formatProviderName(provider string) string {
}
return provider
}
// Sort struct
type EnvSort []api.EnvVar
// returns the number of elements in the collection.
func (env EnvSort) Len() int {
return len(env)
}
// returns whether the element with index i should sort before
// the element with index j.
func (env EnvSort) Less(i, j int) bool {
return env[i].Name < env[j].Name
}
// swaps the elements with indexes i and j.
func (env EnvSort) Swap(i, j int) {
env[i], env[j] = env[j], env[i]
}