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

update for in-development dropshot 0.9.0 #2156

Merged
merged 3 commits into from
Jan 19, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions common/src/api/external/http_pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ use serde::Deserialize;
use serde::Serialize;
use std::fmt::Debug;
use std::num::NonZeroU32;
use std::sync::Arc;
use uuid::Uuid;

// General pagination infrastructure
Expand Down Expand Up @@ -180,7 +179,7 @@ where
/// Given a request and pagination parameters, return a [`DataPageParams`]
/// describing the current page of results to return
pub fn data_page_params_for<'a, S, C>(
rqctx: &'a Arc<RequestContext<C>>,
rqctx: &'a RequestContext<C>,
pag_params: &'a PaginationParams<S, PageSelector<S, S::MarkerValue>>,
) -> Result<DataPageParams<'a, S::MarkerValue>, HttpError>
where
Expand Down
40 changes: 21 additions & 19 deletions gateway/src/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use dropshot::HttpError;
use dropshot::HttpResponseOk;
use dropshot::HttpResponseUpdatedNoContent;
use dropshot::Path;
use dropshot::RawRequest;
use dropshot::RequestContext;
use dropshot::TypedBody;
use futures::stream::FuturesUnordered;
Expand Down Expand Up @@ -357,7 +358,7 @@ struct PathSpComponent {
path = "/sp",
}]
async fn sp_list(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
) -> Result<HttpResponseOk<Vec<SpInfo>>, HttpError> {
let apictx = rqctx.context();
let mgmt_switch = &apictx.mgmt_switch;
Expand Down Expand Up @@ -451,7 +452,7 @@ async fn sp_list(
path = "/sp/{type}/{slot}",
}]
async fn sp_get(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
path: Path<PathSp>,
) -> Result<HttpResponseOk<SpInfo>, HttpError> {
let apictx = rqctx.context();
Expand Down Expand Up @@ -484,7 +485,7 @@ async fn sp_get(
path = "/sp/{type}/{slot}/component",
}]
async fn sp_component_list(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
path: Path<PathSp>,
) -> Result<HttpResponseOk<SpComponentList>, HttpError> {
let apictx = rqctx.context();
Expand All @@ -508,7 +509,7 @@ async fn sp_component_list(
path = "/sp/{type}/{slot}/component/{component}",
}]
async fn sp_component_get(
_rqctx: Arc<RequestContext<Arc<ServerContext>>>,
_rqctx: RequestContext<Arc<ServerContext>>,
_path: Path<PathSpComponent>,
) -> Result<HttpResponseOk<SpComponentInfo>, HttpError> {
todo!()
Expand All @@ -521,14 +522,15 @@ async fn sp_component_get(
path = "/sp/{type}/{slot}/component/{component}/serial-console/attach",
}]
async fn sp_component_serial_console_attach(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
path: Path<PathSpComponent>,
raw_request: RawRequest,
) -> Result<http::Response<hyper::Body>, HttpError> {
let apictx = rqctx.context();
let PathSpComponent { sp, component } = path.into_inner();

let component = component_from_str(&component)?;
let mut request = rqctx.request.lock().await;
let mut request = raw_request.into_inner();

let sp = sp.into();
Ok(crate::serial_console::attach(
Expand All @@ -548,7 +550,7 @@ async fn sp_component_serial_console_attach(
path = "/sp/{type}/{slot}/component/{component}/serial-console/detach",
}]
async fn sp_component_serial_console_detach(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
path: Path<PathSpComponent>,
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
let apictx = rqctx.context();
Expand Down Expand Up @@ -600,7 +602,7 @@ pub struct UpdateAbortBody {
path = "/sp/{type}/{slot}/reset",
}]
async fn sp_reset(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
path: Path<PathSp>,
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
let apictx = rqctx.context();
Expand Down Expand Up @@ -632,7 +634,7 @@ async fn sp_reset(
path = "/sp/{type}/{slot}/component/{component}/update",
}]
async fn sp_component_update(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
path: Path<PathSpComponent>,
body: TypedBody<UpdateBody>,
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
Expand All @@ -659,7 +661,7 @@ async fn sp_component_update(
path = "/sp/{type}/{slot}/component/{component}/update-status",
}]
async fn sp_component_update_status(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
path: Path<PathSpComponent>,
) -> Result<HttpResponseOk<SpUpdateStatus>, HttpError> {
let apictx = rqctx.context();
Expand All @@ -685,7 +687,7 @@ async fn sp_component_update_status(
path = "/sp/{type}/{slot}/component/{component}/update-abort",
}]
async fn sp_component_update_abort(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
path: Path<PathSpComponent>,
body: TypedBody<UpdateAbortBody>,
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
Expand All @@ -709,7 +711,7 @@ async fn sp_component_update_abort(
path = "/sp/{type}/{slot}/component/{component}/power-on",
}]
async fn sp_component_power_on(
_rqctx: Arc<RequestContext<Arc<ServerContext>>>,
_rqctx: RequestContext<Arc<ServerContext>>,
_path: Path<PathSpComponent>,
// TODO do we need a timeout?
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
Expand All @@ -724,7 +726,7 @@ async fn sp_component_power_on(
path = "/sp/{type}/{slot}/component/{component}/power-off",
}]
async fn sp_component_power_off(
_rqctx: Arc<RequestContext<Arc<ServerContext>>>,
_rqctx: RequestContext<Arc<ServerContext>>,
_path: Path<PathSpComponent>,
// TODO do we need a timeout?
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
Expand All @@ -741,7 +743,7 @@ async fn sp_component_power_off(
path = "/ignition",
}]
async fn ignition_list(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
) -> Result<HttpResponseOk<Vec<SpIgnitionInfo>>, HttpError> {
let apictx = rqctx.context();
let mgmt_switch = &apictx.mgmt_switch;
Expand All @@ -768,7 +770,7 @@ async fn ignition_list(
path = "/ignition/{type}/{slot}",
}]
async fn ignition_get(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
path: Path<PathSp>,
) -> Result<HttpResponseOk<SpIgnitionInfo>, HttpError> {
let apictx = rqctx.context();
Expand All @@ -795,7 +797,7 @@ async fn ignition_get(
path = "/ignition/{type}/{slot}/power-on",
}]
async fn ignition_power_on(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
path: Path<PathSp>,
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
let apictx = rqctx.context();
Expand All @@ -820,7 +822,7 @@ async fn ignition_power_on(
path = "/ignition/{type}/{slot}/power-off",
}]
async fn ignition_power_off(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
path: Path<PathSp>,
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
let apictx = rqctx.context();
Expand All @@ -846,7 +848,7 @@ async fn ignition_power_off(
path = "/sp/{type}/{slot}/power-state",
}]
async fn sp_power_state_get(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
path: Path<PathSp>,
) -> Result<HttpResponseOk<PowerState>, HttpError> {
let apictx = rqctx.context();
Expand All @@ -866,7 +868,7 @@ async fn sp_power_state_get(
path = "/sp/{type}/{slot}/power-state",
}]
async fn sp_power_state_set(
rqctx: Arc<RequestContext<Arc<ServerContext>>>,
rqctx: RequestContext<Arc<ServerContext>>,
path: Path<PathSp>,
body: TypedBody<PowerState>,
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
Expand Down
4 changes: 1 addition & 3 deletions installinator-artifactd/src/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

// Copyright 2022 Oxide Computer Company

use std::sync::Arc;

use dropshot::{
endpoint, ApiDescription, FreeformBody, HttpError, HttpResponseOk, Path,
RequestContext,
Expand Down Expand Up @@ -37,7 +35,7 @@ pub fn api() -> ArtifactServerApiDesc {
path = "/artifacts/{name}/{version}"
}]
async fn get_artifact(
rqctx: Arc<RequestContext<ServerContext>>,
rqctx: RequestContext<ServerContext>,
path: Path<ArtifactId>,
) -> Result<HttpResponseOk<FreeformBody>, HttpError> {
match rqctx.context().artifact_store.get_artifact(&path.into_inner()).await
Expand Down
8 changes: 4 additions & 4 deletions internal-dns/src/dropshot_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! Dropshot server for configuring DNS namespace

use crate::dns_data::{self, DnsKV, DnsRecordKey};
use dropshot::endpoint;
use dropshot::{endpoint, RequestContext};
use std::sync::Arc;

pub struct Context {
Expand All @@ -32,7 +32,7 @@ pub fn api() -> dropshot::ApiDescription<Arc<Context>> {
path = "/records",
)]
async fn dns_records_list(
rqctx: Arc<dropshot::RequestContext<Arc<Context>>>,
rqctx: RequestContext<Arc<Context>>,
) -> Result<dropshot::HttpResponseOk<Vec<DnsKV>>, dropshot::HttpError> {
let apictx = rqctx.context();
// XXX record key
Expand All @@ -47,7 +47,7 @@ async fn dns_records_list(
path = "/records",
)]
async fn dns_records_create(
rqctx: Arc<dropshot::RequestContext<Arc<Context>>>,
rqctx: RequestContext<Arc<Context>>,
rq: dropshot::TypedBody<Vec<DnsKV>>,
) -> Result<dropshot::HttpResponseUpdatedNoContent, dropshot::HttpError> {
let apictx = rqctx.context();
Expand All @@ -62,7 +62,7 @@ async fn dns_records_create(
path = "/records",
)]
async fn dns_records_delete(
rqctx: Arc<dropshot::RequestContext<Arc<Context>>>,
rqctx: RequestContext<Arc<Context>>,
rq: dropshot::TypedBody<Vec<DnsRecordKey>>,
) -> Result<dropshot::HttpResponseDeleted, dropshot::HttpError> {
let apictx = rqctx.context();
Expand Down
12 changes: 5 additions & 7 deletions nexus/src/authn/external/cookies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use anyhow::Context;
use async_trait::async_trait;
use cookie::{Cookie, CookieJar, ParseError};
use dropshot::{
ApiEndpointBodyContentType, ExtensionMode, Extractor, ExtractorMetadata,
HttpError, RequestContext, ServerContext,
ApiEndpointBodyContentType, ExtensionMode, ExtractorMetadata, HttpError,
RequestContext, ServerContext, SharedExtractor,
};
use std::sync::Arc;

pub fn parse_cookies(
headers: &http::HeaderMap<http::HeaderValue>,
Expand All @@ -35,12 +34,11 @@ NewtypeFrom! { () pub struct Cookies(pub CookieJar); }
NewtypeDeref! { () pub struct Cookies(pub CookieJar); }

#[async_trait]
impl Extractor for Cookies {
impl SharedExtractor for Cookies {
async fn from_request<Context: ServerContext>(
rqctx: Arc<RequestContext<Context>>,
rqctx: &RequestContext<Context>,
) -> Result<Self, HttpError> {
let request = &rqctx.request.lock().await;
let cookies = parse_cookies(request.headers())
let cookies = parse_cookies(rqctx.request.headers())
.unwrap_or_else(|_| CookieJar::new());
Ok(cookies.into())
}
Expand Down
Loading