Skip to content

Commit

Permalink
feat(init): Add the new/init subcommands (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpinder authored Nov 15, 2024
1 parent e3b246e commit 918da22
Show file tree
Hide file tree
Showing 19 changed files with 754 additions and 141 deletions.
64 changes: 28 additions & 36 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ oci-distribution = { version = "0.11", default-features = false }
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] }
miette = "7"
rstest = "0.18"
semver = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_yaml = { version = "0.0.12", package = "serde_yml" }
syntect = { version = "5", default-features = false, features = ["default-fancy"] }
# tempdir = "0.3"
tempfile = "3"
tokio = { version = "1", features = ["rt", "rt-multi-thread"] }
users = "0.11"
Expand Down Expand Up @@ -88,6 +88,7 @@ log.workspace = true
miette = { workspace = true, features = ["fancy", "syntect-highlighter"] }
oci-distribution.workspace = true
reqwest.workspace = true
semver.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_yaml.workspace = true
Expand All @@ -98,7 +99,9 @@ bon.workspace = true
users.workspace = true

[features]
# Top level features
default = []
init = []
stages = ["blue-build-recipe/stages"]
copy = ["blue-build-recipe/copy"]
multi-recipe = ["dep:rayon", "indicatif/rayon"]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG BASE_IMAGE="alpine"
FROM $BASE_IMAGE

RUN apk update && apk add buildah podman skopeo fuse-overlayfs gpg tini dumb-init
RUN apk update && apk add buildah podman skopeo fuse-overlayfs gpg tini dumb-init git

ENTRYPOINT ["/usr/bin/dumb-init", "--"]

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ RUN dnf -y install dnf-plugins-core \
podman \
skopeo \
gpg \
dumb-init
dumb-init \
git

ENTRYPOINT ["/usr/bin/dumb-init", "--"]

Expand Down
38 changes: 37 additions & 1 deletion integration-tests/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,39 @@ validate:
RUN --no-cache bluebuild -v validate recipes/recipe-invalid-stage.yml && exit 1 || exit 0
RUN --no-cache bluebuild -v validate recipes/recipe-invalid-from-file.yml && exit 1 || exit 0

init:
FROM +test-base

WORKDIR /tmp
RUN --no-cache bluebuild new test-github \
--image-name test-github \
--org-name test \
--description 'This is a description' \
--registry 'ghcr.io' \
--ci-provider github
RUN --no-cache bluebuild new test-gitlab \
--image-name test-gitlab \
--org-name test \
--description 'This is a description' \
--registry 'registry.gitlab.com' \
--ci-provider gitlab
RUN --no-cache bluebuild new test-none \
--image-name test-none \
--org-name test \
--description 'This is a description' \
--registry 'docker.io' \
--ci-provider none \
--no-git

WORKDIR /tmp/test-init
RUN --no-cache bluebuild init \
--image-name test-init \
--org-name test \
--description 'This is a description' \
--registry 'docker.io' \
--ci-provider none \
--no-git

legacy-base:
FROM ../+blue-build-cli-alpine --RELEASE=false
RUN apk update --no-cache && apk add bash grep jq sudo coreutils
Expand All @@ -108,7 +141,10 @@ legacy-base:

test-base:
FROM ../+blue-build-cli-alpine --RELEASE=false
RUN apk update --no-cache && apk add bash grep jq sudo coreutils
RUN apk update --no-cache && apk add bash grep jq sudo coreutils git && \
git config --global user.email "[email protected]" && \
git config --global user.name "Your Name"

ENV BB_TEST_LOCAL_IMAGE=/etc/bluebuild/cli_test.tar.gz
ENV CLICOLOR_FORCE=1

Expand Down
2 changes: 1 addition & 1 deletion process/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ nix = { version = "0.29", features = ["signal"] }
once_cell = "1"
os_pipe = { version = "1", features = ["io_safety"] }
rand = "0.8"
semver = { version = "1", features = ["serde"] }
signal-hook = { version = "0.3", features = ["extended-siginfo"] }
sigstore = { version = "0.10", features = ["full-rustls-tls", "cached-client", "sigstore-trust-root", "sign"], default-features = false, optional = true }
zeroize = { version = "1", features = ["aarch64", "derive", "serde"] }
Expand All @@ -36,6 +35,7 @@ log.workspace = true
miette.workspace = true
oci-distribution.workspace = true
reqwest.workspace = true
semver = { workspace = true, features = ["serde"] }
serde.workspace = true
serde_json.workspace = true
tempfile.workspace = true
Expand Down
41 changes: 18 additions & 23 deletions process/drivers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,25 @@ use log::{info, trace, warn};
use miette::{miette, IntoDiagnostic, Result};
use oci_distribution::Reference;
use once_cell::sync::Lazy;
use opts::{GenerateImageNameOpts, GenerateTagsOpts};
#[cfg(feature = "sigstore")]
use sigstore_driver::SigstoreDriver;
use types::Platform;
use opts::{
BuildOpts, BuildTagPushOpts, CheckKeyPairOpts, GenerateImageNameOpts, GenerateKeyPairOpts,
GenerateTagsOpts, GetMetadataOpts, PushOpts, RunOpts, SignOpts, TagOpts, VerifyOpts,
};
use types::{
BuildDriverType, CiDriverType, DetermineDriver, ImageMetadata, InspectDriverType, Platform,
RunDriverType, SigningDriverType,
};
use uuid::Uuid;

use crate::logging::Logger;

use self::{
buildah_driver::BuildahDriver,
cosign_driver::CosignDriver,
docker_driver::DockerDriver,
github_driver::GithubDriver,
gitlab_driver::GitlabDriver,
local_driver::LocalDriver,
opts::{
BuildOpts, BuildTagPushOpts, CheckKeyPairOpts, GenerateKeyPairOpts, GetMetadataOpts,
PushOpts, RunOpts, SignOpts, TagOpts, VerifyOpts,
},
podman_driver::PodmanDriver,
skopeo_driver::SkopeoDriver,
types::{
BuildDriverType, CiDriverType, DetermineDriver, ImageMetadata, InspectDriverType,
RunDriverType, SigningDriverType,
},
pub use self::{
buildah_driver::BuildahDriver, cosign_driver::CosignDriver, docker_driver::DockerDriver,
github_driver::GithubDriver, gitlab_driver::GitlabDriver, local_driver::LocalDriver,
podman_driver::PodmanDriver, skopeo_driver::SkopeoDriver, traits::*,
};

pub use traits::*;
#[cfg(feature = "sigstore")]
pub use sigstore_driver::SigstoreDriver;

mod buildah_driver;
mod cosign_driver;
Expand Down Expand Up @@ -449,4 +440,8 @@ impl CiDriver for Driver {
{
impl_ci_driver!(generate_image_name(opts))
}

fn default_ci_file_path() -> std::path::PathBuf {
impl_ci_driver!(default_ci_file_path())
}
}
Loading

0 comments on commit 918da22

Please sign in to comment.