From 7c0bb9f220e36c2a3e9c8968b71377977032d595 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Mon, 27 Nov 2023 19:48:45 +0000 Subject: [PATCH] Fix build --- .github/workflows/docker-publish.yml | 48 +++------------------------- src/errors.rs | 2 +- src/main.rs | 8 ++--- 3 files changed, 10 insertions(+), 48 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 97648bf..acffcf1 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -24,70 +24,32 @@ env: jobs: build: - runs-on: ubuntu-latest permissions: contents: read packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. - id-token: write - steps: - name: Checkout repository - uses: actions/checkout@v2 - - # Install the cosign tool except on PR - # https://github.com/sigstore/cosign-installer - - name: Install cosign - if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@1e95c1de343b5b0c23352d6417ee3e48d5bcd422 - with: - cosign-release: 'v1.4.0' - - - # Workaround: https://github.com/docker/build-push-action/issues/461 + uses: actions/checkout@v4 - name: Setup Docker buildx - uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf - - # Login against a Docker registry except on PR - # https://github.com/docker/login-action + uses: docker/setup-buildx-action@v3 - name: Log into registry ${{ env.REGISTRY }} if: github.event_name != 'pull_request' - uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - # Extract metadata (tags, labels) for Docker - # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - # Build and push Docker image with Buildx (don't push on PR) - # https://github.com/docker/build-push-action - name: Build and push Docker image id: build-and-push - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + uses: docker/build-push-action@v5 with: context: . push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - - # Sign the resulting Docker image digest except on PRs. - # This will only write to the public Rekor transparency log when the Docker - # repository is public to avoid leaking data. If you would like to publish - # transparency data even for private images, pass --force to cosign below. - # https://github.com/sigstore/cosign - - name: Sign the published Docker image - if: ${{ github.event_name != 'pull_request' }} - env: - COSIGN_EXPERIMENTAL: "true" - # This step uses the identity token to provision an ephemeral certificate - # against the sigstore community Fulcio instance. - run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push.outputs.digest }} diff --git a/src/errors.rs b/src/errors.rs index 65ae0b9..09c81e1 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -46,7 +46,7 @@ pub trait HtmlResponseError: ResponseError { fn error_response(&self) -> HttpResponse { let mut resp = HttpResponse::new(HtmlResponseError::status_code(self)); let mut buf = web::BytesMut::new(); - let _ = write!(&mut buf, "{}", self); + let _ = write!(&mut buf, "{self}"); resp.headers_mut().insert( header::CONTENT_TYPE, header::HeaderValue::from_static("text/html; charset=utf-8"), diff --git a/src/main.rs b/src/main.rs index 4727c49..95d327b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -98,7 +98,7 @@ struct IndexForm { async fn submit(input: web::Form, store: Data) -> impl Responder { let id = generate_id(); - let uri = format!("/{}", &id); + let uri = format!("/{id}"); store_paste(&store, id, input.into_inner().val); HttpResponse::Found() .append_header((header::LOCATION, uri)) @@ -112,9 +112,9 @@ async fn submit_raw( ) -> Result { let id = generate_id(); let uri = if let Some(Ok(host)) = host.0.as_ref().map(|v| std::str::from_utf8(v.as_bytes())) { - format!("https://{}/{}", host, id) + format!("https://{host}/{id}") } else { - format!("/{}", id) + format!("/{id}") }; store_paste(&store, id, data); @@ -186,7 +186,7 @@ fn render_template(req: &HttpRequest, template: &T) -> Result Ok(HttpResponse::Ok().content_type("text/html").body(html)), Err(e) => { - error!("Error while rendering template for {}: {}", req.uri(), e); + error!("Error while rendering template for {}: {e}", req.uri()); Err(InternalServerError(Box::new(e)).into()) } }