Skip to content

Commit 8f0f5ce

Browse files
formatting
1 parent 8568b87 commit 8f0f5ce

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

backend/graph-proxy/src/graphql/workflow_templates.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,23 @@ use super::{
44
workflows::Workflow,
55
VisitInput,
66
};
7-
use crate::{ArgoServerUrl, graphql::{CLIENT, filters::WorkflowTemplatesFilter}};
7+
use crate::{
8+
graphql::{filters::WorkflowTemplatesFilter, CLIENT},
9+
ArgoServerUrl,
10+
};
811
use anyhow::anyhow;
912
use argo_workflows_openapi::APIResult;
1013
use async_graphql::{
1114
connection::{Connection, CursorType, Edge, EmptyFields, OpaqueCursor},
12-
Context, Json, Object, SimpleObject
15+
Context, Json, Object, SimpleObject,
1316
};
1417
use axum_extra::headers::{authorization::Bearer, Authorization};
15-
use kube::{Api, Client, api::{ApiResource, DynamicObject}, core::GroupVersionKind};
16-
use serde_json::{Value};
18+
use kube::{
19+
api::{ApiResource, DynamicObject},
20+
core::GroupVersionKind,
21+
Api, Client,
22+
};
23+
use serde_json::Value;
1724
use std::{collections::HashMap, ops::Deref};
1825
use tracing::{debug, instrument};
1926

@@ -40,7 +47,7 @@ impl GitHubPath {
4047
fn new(repo: impl Into<String>, path: impl Into<String>) -> Self {
4148
Self {
4249
repo: repo.into(),
43-
path: path.into()
50+
path: path.into(),
4451
}
4552
}
4653
}
@@ -105,37 +112,36 @@ impl WorkflowTemplate {
105112
}
106113

107114
async fn template_url(&self) -> Result<GitHubPath, WorkflowTemplateParsingError> {
108-
let instance = match self.metadata
109-
.labels
110-
.get("argocd.argoproj.io/instance") {
115+
let instance = match self.metadata.labels.get("argocd.argoproj.io/instance") {
111116
Some(val) => val,
112117
None => return Err(WorkflowTemplateParsingError::MissingInstanceLabel),
113118
};
114-
119+
115120
let client = Client::try_default().await.unwrap();
116121
let gvk = GroupVersionKind::gvk("argoproj.io", "v1alpha1", "application");
117122
let api = Api::<DynamicObject>::namespaced_with(
118123
client,
119124
"argocd",
120-
&ApiResource::from_gvk_with_plural(&gvk, "applications")
125+
&ApiResource::from_gvk_with_plural(&gvk, "applications"),
121126
);
122127

123128
let obj = api.get(&instance).await.unwrap();
124129
let annotations = obj.metadata.annotations.clone().unwrap_or_default();
125130
let path = match annotations.get("path") {
126131
Some(path) => path,
127-
None => &String::from("")
132+
None => &String::from(""),
128133
};
129-
let repo = match self.metadata
134+
let repo = match self
135+
.metadata
130136
.annotations
131-
.get("workflows.diamond.ac.uk/repository") {
132-
Some(repo) => repo,
133-
None => &String::from("")
134-
};
137+
.get("workflows.diamond.ac.uk/repository")
138+
{
139+
Some(repo) => repo,
140+
None => &String::from(""),
141+
};
135142

136143
Ok(GitHubPath::new(repo, path))
137144

138-
139145
// let list = api.list(&ListParams::default()).await?;
140146
// for obj in list {
141147
// let name = obj.name_any();

0 commit comments

Comments
 (0)