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

kubernetes/conversion_test: use test-builders package #2180

Merged
merged 2 commits into from
Oct 31, 2019

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Oct 30, 2019

also some small changes to the internal/test/builders

relates to #2173

}
}

// TODO convertToServices currently doesn't set swarm.EndpointSpec.Ports
Copy link
Member Author

Choose a reason for hiding this comment

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

Added a TODO for this; looks like the conversion doesn't return the ports in the spec for the service

@@ -8,15 +8,9 @@ import (
// Any number of service builder functions can be passed to augment it.
// Currently, only ServiceName is implemented
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really in scope of this PR, but this comment line seems obsoleted. Since commit dea478b which added it (and the mentioned ServiceName()), we got 535af2d which adds ServicePort(), ServiceImage() etc.

}
service := &swarm.Service{}
ServiceID("serviceID")
ServiceName("defaultServiceName")
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this part. You call a function that returns a function and then you discard its result, meaning you never call the function returned.

Should be something like

ServiceID("serviceID")(service)
ServiceName("defaultServiceName")(service)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, lol, think I forgot to push a change 😂

o(&s)
}
return s
options := append([]func(*swarm.Service){}, ServiceID(id), ServiceName(name), ServiceImage("image"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Appending to an empty slice does not make sense to me. Easier to write as

options := []func(*swarm.Service){ServiceID(id), ServiceName(name), ServiceImage("image")}

Copy link
Contributor

@silvin-lubecki silvin-lubecki left a comment

Choose a reason for hiding this comment

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

LGTM with @kolyshkin changes 👍

Also rewrite `Service()` to use the available options

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah force-pushed the refactor_conversion_test branch from 2c711f5 to b80fd0c Compare October 31, 2019 15:09
@thaJeztah thaJeztah force-pushed the refactor_conversion_test branch from b80fd0c to 2d0c10d Compare October 31, 2019 15:10
},
}
service := &swarm.Service{}
defaults := []func(*swarm.Service){ServiceID("serviceID"), ServiceName("defaultServiceName")}
Copy link
Member Author

Choose a reason for hiding this comment

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

Actually thinking that we could even remove these defaults; looks like it's currently not used in other locations where the code depends on it being set (which means we could convert this package to something that can be used outside of testing as well

@thaJeztah
Copy link
Member Author

@silvin-lubecki updated; PTAL

Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah thaJeztah merged commit ab255f1 into docker:master Oct 31, 2019
@thaJeztah thaJeztah deleted the refactor_conversion_test branch October 31, 2019 18:20
@thaJeztah thaJeztah added this to the next milestone Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants