Skip to content

Commit

Permalink
feat: Remove obsolete docker features
Browse files Browse the repository at this point in the history
  • Loading branch information
MrExplode committed Nov 2, 2023
1 parent 0a13b2e commit cfd8340
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 65 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A small webhook transformation tool.

### What?

Receive webhook pushes from Docker Registries or Jira, and forward them to Discord Webhooks (with neat embeds)
Receive webhook pushes from Jira and forward them to Discord Webhooks (with neat embeds)

## Docker Compose

Expand All @@ -19,12 +19,11 @@ services:
environment:
JIRA_TOKEN: "" # URL query field for authenticating the jira post request
JIRA_URL: "" # Discord webhook URL for jira messages
DOCKER_TOKEN: "" # Bearer token for Docker Registry post request
DOCKER_URL: "" # Discord webhook URL for docker messages
# In order to deliver issue type & project avatars, we have to download and redirect the images using an authorized
JIRA_EMAIL: "" # account email
JIRA_REST_TOKEN: "" # account rest api token
HOST_URL: "" # the base url for the service
LOG_REQUESTS: "true/false" # if you want to save the received requests set it to true
volumes:
- /path/to/images:/app/img
- /path/to/requests:/app/requests
Expand Down
33 changes: 0 additions & 33 deletions src/docker.rs

This file was deleted.

4 changes: 2 additions & 2 deletions src/jira.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use serde::Deserialize;
use serde_json::json;
use webhook::models::{Embed, Message};

use crate::types::JiraComment;
use crate::types::Comment;
use crate::{imgstore, types::JiraData, Clients};

const ENV_KEY: &str = "JIRA_TOKEN";
Expand Down Expand Up @@ -172,7 +172,7 @@ fn decorate_issue_embed(e: &mut Embed, data: &JiraData, project_url: String, iss
}
}

fn decorate_comment_embed(e: &mut Embed, c: &JiraComment) {
fn decorate_comment_embed(e: &mut Embed, c: &Comment) {
e.author(
c.author.display_name.as_str(),
None,
Expand Down
6 changes: 0 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod docker;
mod imgstore;
mod jira;
mod types;
Expand All @@ -15,7 +14,6 @@ use webhook::client::WebhookClient;

struct Clients {
jira_client: WebhookClient,
docker_client: WebhookClient,
}

#[actix_web::main]
Expand All @@ -26,19 +24,15 @@ async fn main() -> Result<()> {

let jira_url = env::var("JIRA_URL").expect("missing jira url");

let docker_url = env::var("DOCKER_URL").expect("missing docker url");

let data = Arc::new(Clients {
jira_client: WebhookClient::new(&jira_url),
docker_client: WebhookClient::new(&docker_url),
});

HttpServer::new(move || {
App::new()
.app_data(bearer::Config::default())
.app_data(Data::new(data.clone()))
.service(jira::handle)
.service(docker::handle)
.service(imgstore::serve_image)
})
.bind(("0.0.0.0", 3000))?
Expand Down
42 changes: 21 additions & 21 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@ use serde::Deserialize;
pub struct JiraData {
pub timestamp: i64,
pub webhook_event: String,
pub user: Option<JiraUser>,
pub issue: Option<JiraIssue>,
pub user: Option<User>,
pub issue: Option<Issue>,
pub issue_event_type_name: Option<String>,
pub changelog: Option<JiraChangelog>,
pub comment: Option<JiraComment>,
pub changelog: Option<Changelog>,
pub comment: Option<Comment>,
}

#[derive(Deserialize)]
pub struct JiraIssue {
pub struct Issue {
#[serde(rename = "self")]
pub self_url: String,
pub id: String,
pub key: String,
pub fields: JiraIssueFields,
pub fields: IssueFields,
}

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JiraIssueFields {
pub creator: Option<JiraUser>,
pub project: JiraProject,
pub struct IssueFields {
pub creator: Option<User>,
pub project: Project,
pub summary: String,
pub description: Option<String>,
pub priority: JiraIssuePriority,
pub priority: IssuePriority,
#[serde(rename = "issuetype")]
pub issue_type: JiraIssueType,
pub issue_type: IssueType,
}

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JiraIssuePriority {
pub struct IssuePriority {
#[serde(rename = "self")]
pub self_url: String,
pub icon_url: String,
Expand All @@ -47,7 +47,7 @@ pub struct JiraIssuePriority {

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JiraIssueType {
pub struct IssueType {
#[serde(rename = "self")]
pub self_url: String,
pub id: String,
Expand All @@ -58,7 +58,7 @@ pub struct JiraIssueType {

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JiraUser {
pub struct User {
#[serde(rename = "self")]
pub self_url: String,
pub account_id: String,
Expand All @@ -68,7 +68,7 @@ pub struct JiraUser {

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JiraProject {
pub struct Project {
#[serde(rename = "self")]
pub self_url: String,
pub id: String,
Expand All @@ -78,14 +78,14 @@ pub struct JiraProject {
}

#[derive(Deserialize)]
pub struct JiraChangelog {
pub struct Changelog {
pub id: String,
pub items: Vec<JiraChangelogItem>,
pub items: Vec<ChangelogItem>,
}

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JiraChangelogItem {
pub struct ChangelogItem {
pub field: String,
pub field_id: String,
pub from_string: Option<String>,
Expand All @@ -94,13 +94,13 @@ pub struct JiraChangelogItem {

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct JiraComment {
pub struct Comment {
#[serde(rename = "self")]
pub self_url: String,
pub id: String,
pub author: JiraUser,
pub author: User,
pub body: String,
pub update_author: JiraUser,
pub update_author: User,
pub created: String,
pub updated: String,
}

0 comments on commit cfd8340

Please sign in to comment.