Skip to content

Commit

Permalink
Pass only specified options to spark dependencies (#708)
Browse files Browse the repository at this point in the history
* Pass only specified options to spark dependencies

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* generate

Signed-off-by: Pavol Loffay <ploffay@redhat.com>

* fmt

Signed-off-by: Pavol Loffay <ploffay@redhat.com>
  • Loading branch information
pavolloffay authored Oct 18, 2019
1 parent 3507174 commit 01e39a3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/apis/jaegertracing/v1/jaeger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,10 @@ type JaegerDependenciesSpec struct {
CassandraClientAuthEnabled bool `json:"cassandraClientAuthEnabled,omitempty"`

// +optional
ElasticsearchClientNodeOnly bool `json:"elasticsearchClientNodeOnly,omitempty"`
ElasticsearchClientNodeOnly *bool `json:"elasticsearchClientNodeOnly,omitempty"`

// +optional
ElasticsearchNodesWanOnly bool `json:"elasticsearchNodesWanOnly,omitempty"`
ElasticsearchNodesWanOnly *bool `json:"elasticsearchNodesWanOnly,omitempty"`

// +optional
TTLSecondsAfterFinished *int32 `json:"ttlSecondsAfterFinished,omitempty"`
Expand Down
10 changes: 10 additions & 0 deletions pkg/apis/jaegertracing/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions pkg/cronjob/spark_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,19 @@ func getStorageEnvs(s v1.JaegerStorageSpec) []corev1.EnvVar {
{Name: "CASSANDRA_CLIENT_AUTH_ENABLED", Value: strconv.FormatBool(s.Dependencies.CassandraClientAuthEnabled)},
}
case "elasticsearch":
return []corev1.EnvVar{
vars := []corev1.EnvVar{
{Name: "ES_NODES", Value: sFlagsMap["es.server-urls"]},
{Name: "ES_INDEX_PREFIX", Value: sFlagsMap["es.index-prefix"]},
{Name: "ES_USERNAME", Value: sFlagsMap["es.username"]},
{Name: "ES_PASSWORD", Value: sFlagsMap["es.password"]},
{Name: "ES_CLIENT_NODE_ONLY", Value: strconv.FormatBool(s.Dependencies.ElasticsearchClientNodeOnly)},
{Name: "ES_NODES_WAN_ONLY", Value: strconv.FormatBool(s.Dependencies.ElasticsearchNodesWanOnly)},
}
if s.Dependencies.ElasticsearchNodesWanOnly != nil {
vars = append(vars, corev1.EnvVar{Name: "ES_NODES_WAN_ONLY", Value: strconv.FormatBool(*s.Dependencies.ElasticsearchNodesWanOnly)})
}
if s.Dependencies.ElasticsearchClientNodeOnly != nil {
vars = append(vars, corev1.EnvVar{Name: "ES_CLIENT_NODE_ONLY", Value: strconv.FormatBool(*s.Dependencies.ElasticsearchClientNodeOnly)})
}
return vars
default:
return nil
}
Expand Down
14 changes: 13 additions & 1 deletion pkg/cronjob/spark_dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ func TestRemoveEmptyVars(t *testing.T) {
}

func TestStorageEnvs(t *testing.T) {
trueVar := true
falseVar := false
tests := []struct {
storage v1.JaegerStorageSpec
expected []corev1.EnvVar
Expand Down Expand Up @@ -65,8 +67,18 @@ func TestStorageEnvs(t *testing.T) {
{Name: "ES_INDEX_PREFIX", Value: "haha"},
{Name: "ES_USERNAME", Value: "jdoe"},
{Name: "ES_PASSWORD", Value: "none"},
{Name: "ES_CLIENT_NODE_ONLY", Value: "false"},
}},
{storage: v1.JaegerStorageSpec{Type: "elasticsearch",
Options: v1.NewOptions(map[string]interface{}{"es.server-urls": "lol:hol", "es.index-prefix": "haha",
"es.username": "jdoe", "es.password": "none"}),
Dependencies: v1.JaegerDependenciesSpec{ElasticsearchClientNodeOnly: &trueVar, ElasticsearchNodesWanOnly: &falseVar}},
expected: []corev1.EnvVar{
{Name: "ES_NODES", Value: "lol:hol"},
{Name: "ES_INDEX_PREFIX", Value: "haha"},
{Name: "ES_USERNAME", Value: "jdoe"},
{Name: "ES_PASSWORD", Value: "none"},
{Name: "ES_NODES_WAN_ONLY", Value: "false"},
{Name: "ES_CLIENT_NODE_ONLY", Value: "true"},
}},
}
for _, test := range tests {
Expand Down

0 comments on commit 01e39a3

Please sign in to comment.