Compare commits
No commits in common. "4765502109aaf120c33f9f1ba52c003a6266b126" and "319360968bcf5fd43a2cc28f97d7c372f0640a23" have entirely different histories.
4765502109
...
319360968b
62
.drone.yml
62
.drone.yml
@ -1,62 +0,0 @@
|
|||||||
kind: pipeline
|
|
||||||
name: default
|
|
||||||
type: docker
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: load_secret
|
|
||||||
image: debian:buster-slim
|
|
||||||
volumes:
|
|
||||||
- name: ssh
|
|
||||||
path: /root/.ssh/
|
|
||||||
environment:
|
|
||||||
SSH_KEY:
|
|
||||||
from_secret: gitea_id_ed25519
|
|
||||||
commands:
|
|
||||||
- mkdir -p $HOME/.ssh/
|
|
||||||
- echo "$SSH_KEY" > $HOME/.ssh/id_ed25519
|
|
||||||
- ls $HOME/.ssh/
|
|
||||||
- cat $HOME/.ssh/id_ed25519
|
|
||||||
|
|
||||||
- name: build
|
|
||||||
image: kasperhermansen/cuddle-image:latest
|
|
||||||
pull: always
|
|
||||||
volumes:
|
|
||||||
- name: ssh
|
|
||||||
path: /root/.ssh/
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
commands:
|
|
||||||
- apk add bash
|
|
||||||
- cuddle_cli x build_cuddle_image
|
|
||||||
environment:
|
|
||||||
DOCKER_BUILDKIT: 1
|
|
||||||
DOCKER_USERNAME:
|
|
||||||
from_secret: docker_username
|
|
||||||
DOCKER_PASSWORD:
|
|
||||||
from_secret: docker_password
|
|
||||||
depends_on:
|
|
||||||
- "load_secret"
|
|
||||||
|
|
||||||
- name: send telegram notification
|
|
||||||
image: appleboy/drone-telegram
|
|
||||||
settings:
|
|
||||||
token:
|
|
||||||
from_secret: telegram_token
|
|
||||||
to: 2129601481
|
|
||||||
format: markdown
|
|
||||||
when:
|
|
||||||
status: [failure]
|
|
||||||
|
|
||||||
services:
|
|
||||||
- name: docker
|
|
||||||
image: docker:dind
|
|
||||||
privileged: true
|
|
||||||
volumes:
|
|
||||||
- name: dockersock
|
|
||||||
path: /var/run
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: ssh
|
|
||||||
temp: {}
|
|
||||||
- name: dockersock
|
|
||||||
temp: {}
|
|
18
cuddle.yaml
18
cuddle.yaml
@ -1,18 +0,0 @@
|
|||||||
# yaml-language-server: $schema=https://git.front.kjuulh.io/kjuulh/cuddle/raw/branch/main/schemas/base.json
|
|
||||||
|
|
||||||
base: "git@git.front.kjuulh.io:kjuulh/cuddle-base.git"
|
|
||||||
|
|
||||||
vars:
|
|
||||||
service: "cuddle-image"
|
|
||||||
registry: kasperhermansen
|
|
||||||
|
|
||||||
scripts:
|
|
||||||
build_cuddle_image:
|
|
||||||
type: shell
|
|
||||||
args:
|
|
||||||
docker_username:
|
|
||||||
key: "DOCKER_USERNAME"
|
|
||||||
type: env
|
|
||||||
docker_password:
|
|
||||||
key: "DOCKER_PASSWORD"
|
|
||||||
type: env
|
|
@ -9,7 +9,6 @@ use clap::Command;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
actions::CuddleAction,
|
actions::CuddleAction,
|
||||||
config::{CuddleConfig, CuddleFetchPolicy},
|
|
||||||
context::{CuddleContext, CuddleTreeType},
|
context::{CuddleContext, CuddleTreeType},
|
||||||
model::*,
|
model::*,
|
||||||
util::git::GitCommit,
|
util::git::GitCommit,
|
||||||
@ -24,21 +23,16 @@ pub struct CuddleCli<'a> {
|
|||||||
context: Arc<Mutex<Vec<CuddleContext>>>,
|
context: Arc<Mutex<Vec<CuddleContext>>>,
|
||||||
command: Option<Command<'a>>,
|
command: Option<Command<'a>>,
|
||||||
tmp_dir: Option<PathBuf>,
|
tmp_dir: Option<PathBuf>,
|
||||||
config: CuddleConfig,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CuddleCli<'a> {
|
impl<'a> CuddleCli<'a> {
|
||||||
pub fn new(
|
pub fn new(context: Arc<Mutex<Vec<CuddleContext>>>) -> anyhow::Result<CuddleCli<'a>> {
|
||||||
context: Arc<Mutex<Vec<CuddleContext>>>,
|
|
||||||
config: CuddleConfig,
|
|
||||||
) -> anyhow::Result<CuddleCli<'a>> {
|
|
||||||
let mut cli = CuddleCli {
|
let mut cli = CuddleCli {
|
||||||
scripts: vec![],
|
scripts: vec![],
|
||||||
variables: vec![],
|
variables: vec![],
|
||||||
context: context.clone(),
|
context: context.clone(),
|
||||||
command: None,
|
command: None,
|
||||||
tmp_dir: None,
|
tmp_dir: None,
|
||||||
config,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
cli = cli
|
cli = cli
|
||||||
@ -112,14 +106,9 @@ impl<'a> CuddleCli<'a> {
|
|||||||
.tmp_dir
|
.tmp_dir
|
||||||
.clone()
|
.clone()
|
||||||
.ok_or(anyhow::anyhow!("tmp_dir does not exist aborting"))?;
|
.ok_or(anyhow::anyhow!("tmp_dir does not exist aborting"))?;
|
||||||
match self.config.get_fetch_policy()? {
|
|
||||||
CuddleFetchPolicy::Always => {
|
|
||||||
if tmp_dir.exists() && tmp_dir.ends_with("tmp") {
|
if tmp_dir.exists() && tmp_dir.ends_with("tmp") {
|
||||||
std::fs::remove_dir_all(tmp_dir.clone())?;
|
std::fs::remove_dir_all(tmp_dir.clone())?;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
std::fs::create_dir_all(tmp_dir.clone())?;
|
std::fs::create_dir_all(tmp_dir.clone())?;
|
||||||
// Handle all templating with variables and such.
|
// Handle all templating with variables and such.
|
||||||
// TODO: use actual templating engine, for new we just copy templates to the final folder
|
// TODO: use actual templating engine, for new we just copy templates to the final folder
|
||||||
|
@ -6,7 +6,7 @@ pub enum CuddleFetchPolicy {
|
|||||||
Never,
|
Never,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Envconfig, Clone, Debug)]
|
#[derive(Envconfig, Clone)]
|
||||||
pub struct CuddleConfig {
|
pub struct CuddleConfig {
|
||||||
#[envconfig(from = "CUDDLE_FETCH_POLICY", default = "once")]
|
#[envconfig(from = "CUDDLE_FETCH_POLICY", default = "once")]
|
||||||
fetch_policy: String,
|
fetch_policy: String,
|
||||||
|
@ -14,7 +14,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let config = CuddleConfig::from_env()?;
|
let config = CuddleConfig::from_env()?;
|
||||||
|
|
||||||
let context = context::extract_cuddle(config.clone())?;
|
let context = context::extract_cuddle(config.clone())?;
|
||||||
_ = cli::CuddleCli::new(context, config)?.execute()?;
|
_ = cli::CuddleCli::new(context)?.execute()?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
tag="$REGISTRY/$SERVICE:${COMMIT_SHA:0:10}"
|
|
||||||
latest_tag="$REGISTRY/$SERVICE:latest"
|
|
||||||
|
|
||||||
echo "logging in"
|
|
||||||
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
|
|
||||||
|
|
||||||
echo "building image"
|
|
||||||
DOCKER_BUILDKIT=1 docker build -t "$tag" -t "$latest_tag" -f "$TMP/build_cuddle_image.Dockerfile" .
|
|
||||||
|
|
||||||
echo "pushing image"
|
|
||||||
docker push "$tag"
|
|
||||||
docker push "$latest_tag"
|
|
@ -1,23 +0,0 @@
|
|||||||
FROM rust:1.62.1-slim-bullseye as base
|
|
||||||
|
|
||||||
RUN rustup target add x86_64-unknown-linux-musl
|
|
||||||
|
|
||||||
RUN apt-get update -qq && \
|
|
||||||
apt-get install -y \
|
|
||||||
musl-tools \
|
|
||||||
musl-dev
|
|
||||||
|
|
||||||
RUN update-ca-certificates
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get upgrade -y
|
|
||||||
RUN apt-get install -y -q build-essential curl git
|
|
||||||
|
|
||||||
WORKDIR /app/cuddle/
|
|
||||||
|
|
||||||
RUN cargo install --target x86_64-unknown-linux-musl --git https://git.front.kjuulh.io/kjuulh/cuddle.git cuddle_cli
|
|
||||||
|
|
||||||
FROM docker:stable-dind
|
|
||||||
|
|
||||||
COPY --from=base /usr/local/cargo/bin/ /usr/local/cargo/bin/
|
|
||||||
ENV PATH="${PATH}:/usr/local/cargo/bin"
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
|||||||
.cuddle/
|
|
||||||
.git/
|
|
Loading…
Reference in New Issue
Block a user