forked from openshift/cluster-etcd-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/cmd/render: Backport adding support for s390 and s390x arch
This is a backport of openshift#317 with a few minor changes that were needed for 4.4
- Loading branch information
1 parent
92850d6
commit 1b099b9
Showing
5 changed files
with
132 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package render | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/openshift/cluster-etcd-operator/pkg/etcdenvvar" | ||
) | ||
|
||
var envVarFns = []envVarFunc{ | ||
getFixedEtcdEnvVars, | ||
getUnsupportedArch, | ||
getEtcdName, | ||
} | ||
|
||
type envVarFunc func(arch string) (map[string]string, error) | ||
|
||
func getEtcdEnv(arch string) (map[string]string, error) { | ||
ret := map[string]string{} | ||
for _, envVarFn := range envVarFns { | ||
newEnvVars, err := envVarFn(arch) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if newEnvVars == nil { | ||
continue | ||
} | ||
for k, v := range newEnvVars { | ||
if currV, ok := ret[k]; ok { | ||
return nil, fmt.Errorf("key %q already set to %q", k, currV) | ||
} | ||
ret[k] = v | ||
} | ||
} | ||
return ret, nil | ||
} | ||
|
||
func getFixedEtcdEnvVars(arch string) (map[string]string, error) { | ||
env := etcdenvvar.FixedEtcdEnvVars | ||
// single member cluster needs to start with "new" (default). | ||
delete(env, "ETCD_INITIAL_CLUSTER_STATE") | ||
return env, nil | ||
} | ||
|
||
func getEtcdName(arch string) (map[string]string, error) { | ||
return map[string]string{ | ||
"ETCD_NAME": "etcd-bootstrap", | ||
}, nil | ||
} | ||
|
||
func getUnsupportedArch(arch string) (map[string]string, error) { | ||
if !strings.HasPrefix(arch, "s390") { | ||
// dont set unless it is defined. | ||
return nil, nil | ||
} | ||
return map[string]string{ | ||
"ETCD_UNSUPPORTED_ARCH": arch, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package render | ||
|
||
import "testing" | ||
|
||
func TestEtcdEnv(t *testing.T) { | ||
for _, test := range []struct { | ||
arch, wantKey, wantValue string | ||
}{ | ||
{"s390x", "ETCD_UNSUPPORTED_ARCH", "s390x"}, | ||
} { | ||
env, _ := getEtcdEnv(test.arch) | ||
if env[test.wantKey] != test.wantValue { | ||
t.Errorf("getEtcdEnv(%q) = want %q = %q got %q = %q", test.arch, test.wantKey, test.wantValue, test.wantKey, env[test.wantKey]) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters