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 Header and Method support for HTTP checks #3031

Merged
merged 14 commits into from
Aug 18, 2017
Merged

Conversation

schmichael
Copy link
Member

@schmichael schmichael commented Aug 15, 2017

Fixes #2924

@dadgar Please check my work in diff.go. I haven't had to edit the diff logic before.

I modeled our header field after Consul's which is modeled after the Go stdlib which ... is kind of awkward for people not used to it for 2 reasons:

  1. Header (singluar) when people probably expect Headers (plural)
  2. map[string][]string instead of []string (like env vars)

It's unfortunate that it's kind of an awkward API, but I default to consistency above trying to make a subjective UX tweak.

@schmichael schmichael changed the title [WIP] Add Header and Method support for HTTP checks Add Header and Method support for HTTP checks Aug 16, 2017
Name: "name",
ServiceID: serviceID,
}
expected.Timeout = "0s"
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason these aren't inline with struct creation?

jobspec/parse.go Outdated
if headerI, ok := cm["header"]; ok {
headerRaw, ok := headerI.([]map[string]interface{})
if !ok {
return fmt.Errorf("check -> header -> expected a []map[string]interface{} but found %T", headerI)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we show interface{} or []string since that is the only thing that is parsable.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point.

Interval: 10 * time.Second,
Timeout: 2 * time.Second,
InitialStatus: capi.HealthPassing,
Method: "POST",
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a failing case? With numbers or something.

@@ -592,6 +592,23 @@ func serviceCheckDiff(old, new *ServiceCheck, contextual bool) *ObjectDiff {

// Diff the primitive fields.
diff.Fields = fieldDiffs(oldPrimitiveFlat, newPrimitiveFlat, contextual)

// Diff Header
headerDiff := &ObjectDiff{Type: DiffTypeNone, Name: "Header"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind just popping it into a method?

Copy link
Contributor

@dadgar dadgar left a comment

Choose a reason for hiding this comment

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

Needs docs as well. HCL and JSON

@schmichael schmichael force-pushed the f-2924-consul-headers branch 2 times, most recently from b76a221 to 77f4d96 Compare August 17, 2017 23:10
@schmichael
Copy link
Member Author

Travis failure is unrelated.

@schmichael schmichael merged commit 0a4ea47 into master Aug 18, 2017
@schmichael schmichael deleted the f-2924-consul-headers branch August 18, 2017 20:35
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants