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

Support Marathon 1.5 Network API #283

Merged
merged 6 commits into from
Feb 1, 2018
Merged

Support Marathon 1.5 Network API #283

merged 6 commits into from
Feb 1, 2018

Conversation

zanes2016
Copy link
Contributor

@zanes2016 zanes2016 commented Jan 30, 2018

I've manually tested this end-to-end with Marathon, Consul, and this new binary. This patch addresses issue #230

I'm able to manually compile this code using native go run. But I'm not able to run make build, etc. So maybe someone (@janisz) can test this?

apps/app.go Outdated
@@ -162,14 +167,22 @@ type indexedPortDefinition struct {
}

func (app App) findConsulPortDefinitions() []indexedPortDefinition {
var appPortDefinitions []PortDefinition
if len(app.Container.PortMappings) > 0 {
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 a comment here with information about deprecation of PortDefinitons in favour of PortMappings and link to Marathon release notes?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can extract this part to a function with proper godoc. e.g.

func (app App) getPortDefinitions() []PortDefinition {
	var appPortDefinitions []PortDefinition
        if len(app.Container.PortMappings) > 0 {
		appPortDefinitions = app.Container.PortMappings
 	} else {
 		appPortDefinitions = app.PortDefinitions
 	}
        return appPortDefinitions
}

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 a test for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. Added the changes and unittest

Copy link
Contributor

@janisz janisz left a comment

Choose a reason for hiding this comment

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

Thanks for nice patch. It looks like it's backward compatible, cool! Please add a comment with information about why we need this logic and a test for this logic.

apps/app.go Outdated
// Deprecated: Allows for backward compatibility with Marathons' network API
// PortDefinitions are deprecated in favor of Marathons' new PortMappings
// see https://github.com/mesosphere/marathon/pull/5391
func extractPortDefinitions(app *App) []PortDefinition {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not a struct receiver?

func (app App) extractPortDefinitions()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion. I'll update.

@janisz janisz merged commit 612f5e9 into allegro:master Feb 1, 2018
@janisz
Copy link
Contributor

janisz commented Feb 1, 2018

@zanes2016 Thanks a lot!

@zanes2016
Copy link
Contributor Author

@janisz No problem! Thanks for the quick feedback

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.

2 participants