Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support repetitive arguments to operand #1434

Merged
merged 6 commits into from
Aug 5, 2021

Conversation

rubenvp8510
Copy link
Collaborator

Fixes #1415

Signed-off-by: Ruben Vargas ruben.vp8510@gmail.com

@rubenvp8510 rubenvp8510 force-pushed the multi-options branch 2 times, most recently from 64367dd to 7ceebc2 Compare April 21, 2021 04:17
@jpkrohling
Copy link
Contributor

jpkrohling commented Apr 22, 2021

CI seems to be failing.

# github.com/jaegertracing/jaeger-operator/pkg/service
pkg/service/collector.go:111:36: cannot use val (type interface {}) as type string in argument to strconv.ParseBool: need type assertion
# github.com/jaegertracing/jaeger-operator/pkg/cronjob
pkg/cronjob/es_index_cleaner.go:22:62: cannot use jaeger.Spec.Storage.Options.Map() (type map[string]interface {}) as type map[string]string in argument to util.GetEsHostname
pkg/cronjob/es_index_cleaner.go:31:92: cannot use val (type interface {}) as type string in argument to strings.EqualFold: need type assertion
pkg/cronjob/es_rollover.go:92:87: cannot use jaeger.Spec.Storage.Options.Map() (type map[string]interface {}) as type map[string]string in argument to util.GetEsHostname
pkg/cronjob/es_rollover.go:161:54: cannot use val (type interface {}) as type string in field value: need type assertion
pkg/cronjob/spark_dependencies.go:129:39: cannot use sFlagsMap["cassandra.servers"] (type interface {}) as type string in field value: need type assertion
pkg/cronjob/spark_dependencies.go:130:33: cannot use keyspace (type interface {}) as type string in field value: need type assertion
pkg/cronjob/spark_dependencies.go:131:33: cannot use sFlagsMap["cassandra.username"] (type interface {}) as type string in field value: need type assertion
pkg/cronjob/spark_dependencies.go:132:33: cannot use sFlagsMap["cassandra.password"] (type interface {}) as type string in field value: need type assertion
pkg/cronjob/spark_dependencies.go:133:32: cannot use sFlagsMap["cassandra.tls"] (type interface {}) as type string in field value: need type assertion
pkg/cronjob/spark_dependencies.go:134:33: cannot use sFlagsMap["cassandra.local-dc"] (type interface {}) as type string in field value: need type assertion
pkg/cronjob/spark_dependencies.go:134:33: too many errors
make[1]: *** [Makefile:80: gobuild] Error 2
make[1]: Leaving directory '/home/runner/work/jaeger-operator/jaeger-operator'
Failed to build the operator.

@codecov
Copy link

codecov bot commented Apr 27, 2021

Codecov Report

Merging #1434 (014d50c) into master (05b0c69) will increase coverage by 0.02%.
The diff coverage is 96.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1434      +/-   ##
==========================================
+ Coverage   87.70%   87.73%   +0.02%     
==========================================
  Files          93       93              
  Lines        5839     5868      +29     
==========================================
+ Hits         5121     5148      +27     
- Misses        552      553       +1     
- Partials      166      167       +1     
Impacted Files Coverage Δ
pkg/util/util.go 93.93% <60.00%> (-1.13%) ⬇️
pkg/apis/jaegertracing/v1/options.go 92.68% <100.00%> (+3.02%) ⬆️
pkg/cronjob/es_index_cleaner.go 100.00% <100.00%> (ø)
pkg/cronjob/es_rollover.go 95.93% <100.00%> (ø)
pkg/cronjob/spark_dependencies.go 92.59% <100.00%> (ø)
pkg/ingress/query.go 100.00% <100.00%> (ø)
pkg/service/collector.go 100.00% <100.00%> (ø)
pkg/storage/cassandra_dependencies.go 100.00% <100.00%> (ø)
pkg/storage/elasticsearch_dependencies.go 100.00% <100.00%> (ø)
pkg/strategy/controller.go 94.32% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 05b0c69...014d50c. Read the comment docs.

@jpkrohling
Copy link
Contributor

Let me know when this gets ready to be reviewed.

@rubenvp8510
Copy link
Collaborator Author

This is ready for review

@@ -5,6 +5,8 @@ import (
"sort"
"testing"

"github.com/stretchr/testify/require"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import order.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this hasn't been fixed.


func TestStringMap(t *testing.T) {
o := NewOptions(nil)
err := o.UnmarshalJSON([]byte(`{"firstsarg":"v1", "additional-headers":["whatever:thing", "access-control-allow-origin:blerg"]}`))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an example with real values here? I'm failing to see why additional-headers should be removed instead of having something like --firstsarg=v1 --additional-headers="whatever:thing" --additional-headers="access-control-allow-origin:blerg"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add some real examples,

This is testing a new method I introduced in this PR. StringMap, this method only returns a map with strings (mimic the old behavior when we didn't support arrays) , it omits repeated arguments, I did in this way because this map is used in a lot of places, and I wand to preserve that behaviour for those places which is used, also I don't want to do type asserting each time the option map is used.

@@ -7,10 +7,28 @@ import (
"strings"
)

// Values represent and string or a slice of string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem accurate. Perhaps you meant "Values hold a map, with string as the key and either a string or a slice of strings as the value"

In any case, the name for this struct isn't really telling what the struct is. Can you come up with a better name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better comment :) I'll change it, and rename this to a better name

@@ -69,18 +86,24 @@ func (o Options) MarshalJSON() ([]byte, error) {
}

func (o *Options) parse(entries map[string]interface{}) {
o.opts = make(map[string]string)
o.opts = make(map[string]interface{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we have a structure with this signature already?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find it, We have FreeForm but that is a different structure with json *[]byte

@@ -5,6 +5,8 @@ import (
"sort"
"testing"

"github.com/stretchr/testify/require"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this hasn't been fixed.

Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
@rubenvp8510
Copy link
Collaborator Author

@pavolloffay Could you please review?

Thank you!

Copy link
Member

@pavolloffay pavolloffay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one test job is failing

@jpkrohling jpkrohling enabled auto-merge (squash) August 5, 2021 13:36
@jpkrohling jpkrohling enabled auto-merge (squash) August 5, 2021 13:36
@jpkrohling jpkrohling merged commit 5ec0aa1 into jaegertracing:master Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support repetitive arguments to operand
3 participants