From 9caf4bf38381f4ec0680a4b29ba26f9c1921fba0 Mon Sep 17 00:00:00 2001 From: BlackDex Date: Tue, 30 Mar 2021 21:45:10 +0200 Subject: [PATCH] Misc changes. Some small changes in general: - Moved the SQL Version check struct into the function. - Updated hadolint to 2.0.0 - Fixed hadolint 2.0.0 warnings - Updated github workflows - Added .editorconfig for some general shared editor settings. --- .dockerignore | 2 ++ .editorconfig | 23 +++++++++++++++++++++++ .github/workflows/build.yml | 14 ++++++-------- .github/workflows/hadolint.yml | 3 ++- docker/Dockerfile.j2 | 2 +- docker/amd64/Dockerfile | 2 +- docker/amd64/Dockerfile.alpine | 2 +- docker/arm64/Dockerfile | 2 +- docker/armv6/Dockerfile | 2 +- docker/armv7/Dockerfile | 2 +- docker/armv7/Dockerfile.alpine | 2 +- src/db/mod.rs | 14 +++++++------- 12 files changed, 47 insertions(+), 23 deletions(-) create mode 100644 .editorconfig diff --git a/.dockerignore b/.dockerignore index b3e43a23..69f51d2a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,6 +4,8 @@ target # Data folder data .env +.env.template +.gitattributes # IDE files .vscode diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..27c2a5e3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,23 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +end_of_line = lf +charset = utf-8 + +[*.{rs,py}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{yml,yaml}] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true + +[Makefile] +indent_style = tab diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 81151f17..2c4d4620 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,23 +2,21 @@ name: Build on: push: - # Ignore when there are only changes done too one of these paths - paths-ignore: - - "**.md" - - "**.txt" - - "azure-pipelines.yml" - - "docker/**" - - "hooks/**" - - "tools/**" pull_request: # Ignore when there are only changes done too one of these paths paths-ignore: - "**.md" - "**.txt" + - ".dockerignore" + - ".env.template" + - ".gitattributes" + - ".gitignore" - "azure-pipelines.yml" - "docker/**" - "hooks/**" - "tools/**" + - ".github/FUNDING.yml" + - ".github/ISSUE_TEMPLATE/**" jobs: build: diff --git a/.github/workflows/hadolint.yml b/.github/workflows/hadolint.yml index 7b799554..f2cd9732 100644 --- a/.github/workflows/hadolint.yml +++ b/.github/workflows/hadolint.yml @@ -1,6 +1,7 @@ name: Hadolint on: + push: pull_request: # Ignore when there are only changes done too one of these paths paths: @@ -24,7 +25,7 @@ jobs: sudo curl -L https://github.com/hadolint/hadolint/releases/download/v$HADOLINT_VERSION/hadolint-$(uname -s)-$(uname -m) -o /usr/local/bin/hadolint && \ sudo chmod +x /usr/local/bin/hadolint env: - HADOLINT_VERSION: 1.19.0 + HADOLINT_VERSION: 2.0.0 # End Download hadolint # Test Dockerfiles diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index 7793ff2d..be4b4151 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -250,6 +250,7 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage +WORKDIR / COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault {% if package_arch_target is defined %} @@ -264,6 +265,5 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! -WORKDIR / ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/amd64/Dockerfile b/docker/amd64/Dockerfile index 08cdb1a8..e24cca81 100644 --- a/docker/amd64/Dockerfile +++ b/docker/amd64/Dockerfile @@ -98,6 +98,7 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage +WORKDIR / COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/release/bitwarden_rs . @@ -108,6 +109,5 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! -WORKDIR / ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/amd64/Dockerfile.alpine b/docker/amd64/Dockerfile.alpine index 71d63132..eed79fc1 100644 --- a/docker/amd64/Dockerfile.alpine +++ b/docker/amd64/Dockerfile.alpine @@ -93,6 +93,7 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage +WORKDIR / COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/x86_64-unknown-linux-musl/release/bitwarden_rs . @@ -103,6 +104,5 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! -WORKDIR / ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/arm64/Dockerfile b/docker/arm64/Dockerfile index c6faf743..b6b50fbd 100644 --- a/docker/arm64/Dockerfile +++ b/docker/arm64/Dockerfile @@ -144,6 +144,7 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage +WORKDIR / COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/aarch64-unknown-linux-gnu/release/bitwarden_rs . @@ -154,6 +155,5 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! -WORKDIR / ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv6/Dockerfile b/docker/armv6/Dockerfile index c095e8c9..c6dc75e1 100644 --- a/docker/armv6/Dockerfile +++ b/docker/armv6/Dockerfile @@ -144,6 +144,7 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage +WORKDIR / COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/arm-unknown-linux-gnueabi/release/bitwarden_rs . @@ -154,6 +155,5 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! -WORKDIR / ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv7/Dockerfile b/docker/armv7/Dockerfile index a880d061..51d4c75c 100644 --- a/docker/armv7/Dockerfile +++ b/docker/armv7/Dockerfile @@ -144,6 +144,7 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage +WORKDIR / COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/armv7-unknown-linux-gnueabihf/release/bitwarden_rs . @@ -154,6 +155,5 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! -WORKDIR / ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/docker/armv7/Dockerfile.alpine b/docker/armv7/Dockerfile.alpine index 7a7e4433..14b7e9b8 100644 --- a/docker/armv7/Dockerfile.alpine +++ b/docker/armv7/Dockerfile.alpine @@ -99,6 +99,7 @@ EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage +WORKDIR / COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/armv7-unknown-linux-musleabihf/release/bitwarden_rs . @@ -109,6 +110,5 @@ COPY docker/start.sh /start.sh HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"] # Configures the startup! -WORKDIR / ENTRYPOINT ["/usr/bin/dumb-init", "--"] CMD ["/start.sh"] diff --git a/src/db/mod.rs b/src/db/mod.rs index 19191582..2472caa6 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -241,15 +241,15 @@ pub fn backup_database() -> Result<(), Error> { } -use diesel::sql_types::Text; -#[derive(QueryableByName,Debug)] -struct SqlVersion { - #[sql_type = "Text"] - version: String, -} - /// Get the SQL Server version pub fn get_sql_server_version(conn: &DbConn) -> String { + use diesel::sql_types::Text; + #[derive(QueryableByName)] + struct SqlVersion { + #[sql_type = "Text"] + version: String, + } + db_run! {@raw conn: postgresql, mysql { match diesel::sql_query("SELECT version() AS version;").get_result::(conn).ok() {