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 fieldManager querystring to all operations #1031

Merged
merged 2 commits into from Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions kube-core/src/params.rs
Expand Up @@ -183,6 +183,15 @@ pub struct PostParams {
}

impl PostParams {
pub(crate) fn populate_qp(&self, qp: &mut form_urlencoded::Serializer<String>) {
if self.dry_run {
qp.append_pair("dryRun", "All");
}
if let Some(ref fm) = self.field_manager {
qp.append_pair("fieldManager", fm);
}
}

pub(crate) fn validate(&self) -> Result<(), Error> {
if let Some(field_manager) = &self.field_manager {
// Implement the easy part of validation, in future this may be extended to provide validation as in go code
Expand Down
16 changes: 4 additions & 12 deletions kube-core/src/request.rs
Expand Up @@ -115,9 +115,7 @@ impl Request {
pp.validate()?;
let target = format!("{}?", self.url_path);
let mut qp = form_urlencoded::Serializer::new(target);
if pp.dry_run {
qp.append_pair("dryRun", "All");
}
pp.populate_qp(&mut qp);
let urlstr = qp.finish();
let req = http::Request::post(urlstr).header(http::header::CONTENT_TYPE, JSON_MIME);
req.body(data).map_err(Error::BuildRequest)
Expand Down Expand Up @@ -192,9 +190,7 @@ impl Request {
) -> Result<http::Request<Vec<u8>>, Error> {
let target = format!("{}/{}?", self.url_path, name);
let mut qp = form_urlencoded::Serializer::new(target);
if pp.dry_run {
qp.append_pair("dryRun", "All");
}
pp.populate_qp(&mut qp);
let urlstr = qp.finish();
let req = http::Request::put(urlstr).header(http::header::CONTENT_TYPE, JSON_MIME);
req.body(data).map_err(Error::BuildRequest)
Expand Down Expand Up @@ -226,9 +222,7 @@ impl Request {
) -> Result<http::Request<Vec<u8>>, Error> {
let target = format!("{}/{}/{}?", self.url_path, name, subresource_name);
let mut qp = form_urlencoded::Serializer::new(target);
if pp.dry_run {
qp.append_pair("dryRun", "All");
}
pp.populate_qp(&mut qp);
let urlstr = qp.finish();
let req = http::Request::post(urlstr).header(http::header::CONTENT_TYPE, JSON_MIME);
req.body(data).map_err(Error::BuildRequest)
Expand Down Expand Up @@ -265,9 +259,7 @@ impl Request {
) -> Result<http::Request<Vec<u8>>, Error> {
let target = format!("{}/{}/{}?", self.url_path, name, subresource_name);
let mut qp = form_urlencoded::Serializer::new(target);
if pp.dry_run {
qp.append_pair("dryRun", "All");
}
pp.populate_qp(&mut qp);
let urlstr = qp.finish();
let req = http::Request::put(urlstr).header(http::header::CONTENT_TYPE, JSON_MIME);
req.body(data).map_err(Error::BuildRequest)
Expand Down
4 changes: 1 addition & 3 deletions kube-core/src/subresource.rs
Expand Up @@ -102,9 +102,7 @@ impl Request {
let pp = &ep.post_options;
pp.validate()?;
let mut qp = form_urlencoded::Serializer::new(target);
if pp.dry_run {
qp.append_pair("dryRun", "All");
}
pp.populate_qp(&mut qp);
let urlstr = qp.finish();
// eviction body parameters are awkward, need metadata with name
let data = serde_json::to_vec(&serde_json::json!({
Expand Down