Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #22 from golemcloud/fmt
Browse files Browse the repository at this point in the history
rust fmt configuration
  • Loading branch information
justcoon authored Sep 7, 2023
2 parents 53ca978 + e08b1cf commit f2c30ea
Show file tree
Hide file tree
Showing 22 changed files with 96 additions and 67 deletions.
5 changes: 5 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
normalize_comments = true
reorder_imports = true
group_imports = "StdExternalCrate"
newline_style = "Unix"
imports_granularity = "Module"
7 changes: 4 additions & 3 deletions src/account.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use async_trait::async_trait;
use clap::Subcommand;
use golem_client::model::AccountData;

use crate::clients::account::AccountClient;
use crate::clients::grant::GrantClient;
use crate::clients::CloudAuthentication;
use crate::model::{AccountId, GolemError, GolemResult, Role};
use async_trait::async_trait;
use clap::Subcommand;
use golem_client::model::AccountData;

#[derive(Subcommand, Debug)]
#[command()]
Expand Down
14 changes: 8 additions & 6 deletions src/auth.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
use crate::clients::login::LoginClient;
use crate::clients::CloudAuthentication;
use crate::model::GolemError;
use std::fs::{create_dir_all, File, OpenOptions};
use std::io::{BufReader, BufWriter};
use std::path::{Path, PathBuf};

use async_trait::async_trait;
use chrono::{DateTime, Utc};
use golem_client::model::{OAuth2Data, Token, TokenSecret, UnsafeToken};
use indoc::printdoc;
use serde::{Deserialize, Serialize};
use std::fs::{create_dir_all, File, OpenOptions};
use std::io::{BufReader, BufWriter};
use std::path::{Path, PathBuf};
use tracing::info;
use uuid::Uuid;

use crate::clients::login::LoginClient;
use crate::clients::CloudAuthentication;
use crate::model::GolemError;

#[async_trait]
pub trait Auth {
async fn authenticate(
Expand Down
3 changes: 2 additions & 1 deletion src/clients.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::model::{AccountId, ProjectAction};
use golem_client::model::{TokenSecret, UnsafeToken};

use crate::model::{AccountId, ProjectAction};

pub mod account;
pub mod grant;
pub mod login;
Expand Down
5 changes: 3 additions & 2 deletions src/clients/account.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::clients::CloudAuthentication;
use crate::model::{AccountId, GolemError};
use async_trait::async_trait;
use golem_client::model::{Account, AccountData, Plan};
use tracing::info;

use crate::clients::CloudAuthentication;
use crate::model::{AccountId, GolemError};

#[async_trait]
pub trait AccountClient {
async fn get(&self, id: &AccountId, auth: &CloudAuthentication) -> Result<Account, GolemError>;
Expand Down
6 changes: 3 additions & 3 deletions src/clients/grant.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::clients::CloudAuthentication;
use crate::model::Role;
use crate::model::{AccountId, GolemError};
use async_trait::async_trait;
use tracing::info;

use crate::clients::CloudAuthentication;
use crate::model::{AccountId, GolemError, Role};

#[async_trait]
pub trait GrantClient {
async fn get_all(
Expand Down
5 changes: 3 additions & 2 deletions src/clients/login.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::clients::token_header;
use crate::model::GolemError;
use async_trait::async_trait;
use golem_client::login::Login;
use golem_client::model::{OAuth2Data, Token, TokenSecret, UnsafeToken};
use tracing::info;

use crate::clients::token_header;
use crate::model::GolemError;

#[async_trait]
pub trait LoginClient {
async fn token_details(&self, manual_token: TokenSecret) -> Result<Token, GolemError>;
Expand Down
8 changes: 5 additions & 3 deletions src/clients/policy.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use crate::clients::{action_cli_to_api, CloudAuthentication};
use crate::model::{GolemError, ProjectAction, ProjectPolicyId};
use std::collections::HashSet;

use async_trait::async_trait;
use golem_client::model::{ProjectActions, ProjectPolicy, ProjectPolicyData};
use std::collections::HashSet;
use tracing::info;

use crate::clients::{action_cli_to_api, CloudAuthentication};
use crate::model::{GolemError, ProjectAction, ProjectPolicyId};

#[async_trait]
pub trait ProjectPolicyClient {
async fn create(
Expand Down
5 changes: 3 additions & 2 deletions src/clients/project.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::clients::CloudAuthentication;
use crate::model::{GolemError, ProjectId, ProjectRef};
use async_trait::async_trait;
use golem_client::model::{Project, ProjectDataRequest};
use indoc::formatdoc;
use tracing::info;

use crate::clients::CloudAuthentication;
use crate::model::{GolemError, ProjectId, ProjectRef};

#[async_trait]
pub trait ProjectClient {
async fn create(
Expand Down
5 changes: 3 additions & 2 deletions src/clients/project_grant.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::clients::{action_cli_to_api, CloudAuthentication};
use crate::model::{AccountId, GolemError, ProjectAction, ProjectId, ProjectPolicyId};
use async_trait::async_trait;
use golem_client::model::{
ProjectGrant, ProjectGrantDataRequest, ProjectGrantDataWithProjectActions,
};
use tracing::info;

use crate::clients::{action_cli_to_api, CloudAuthentication};
use crate::model::{AccountId, GolemError, ProjectAction, ProjectId, ProjectPolicyId};

#[async_trait]
pub trait ProjectGrantClient {
async fn create(
Expand Down
10 changes: 6 additions & 4 deletions src/clients/template.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use crate::clients::CloudAuthentication;
use crate::model::{GolemError, TemplateName};
use crate::{ProjectId, RawTemplateId};
use std::path::PathBuf;

use async_trait::async_trait;
use golem_client::model::{
Component, ComponentQuery, Export, FunctionParameter, FunctionResult, Type,
};
use serde::Serialize;
use std::path::PathBuf;
use tokio::fs::File;
use tracing::info;

use crate::clients::CloudAuthentication;
use crate::model::{GolemError, TemplateName};
use crate::{ProjectId, RawTemplateId};

#[async_trait]
pub trait TemplateClient {
async fn find(
Expand Down
5 changes: 3 additions & 2 deletions src/clients/token.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
use crate::clients::CloudAuthentication;
use crate::model::{AccountId, GolemError, TokenId};
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use golem_client::model;
use golem_client::model::{CreateTokenDTO, UnsafeToken};
use golem_client::token::Token;
use tracing::info;

use crate::clients::CloudAuthentication;
use crate::model::{AccountId, GolemError, TokenId};

#[async_trait]
pub trait TokenClient {
async fn get_all(
Expand Down
19 changes: 10 additions & 9 deletions src/clients/worker.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::clients::CloudAuthentication;
use crate::model::{GolemError, InvocationKey, RawTemplateId};
use crate::WorkerName;
use std::fmt::{Display, Formatter};
use std::time::Duration;

use async_trait::async_trait;
use futures_util::{future, pin_mut, SinkExt, StreamExt};
use golem_client::model::{
Expand All @@ -9,15 +9,16 @@ use golem_client::model::{
use native_tls::TlsConnector;
use reqwest::Url;
use serde::Deserialize;
use std::fmt::{Display, Formatter};
use std::time::Duration;
use tokio::{task, time};
use tokio_tungstenite::{
connect_async_tls_with_config, tungstenite::client::IntoClientRequest,
tungstenite::protocol::Message, Connector,
};
use tokio_tungstenite::tungstenite::client::IntoClientRequest;
use tokio_tungstenite::tungstenite::protocol::Message;
use tokio_tungstenite::{connect_async_tls_with_config, Connector};
use tracing::{debug, info};

use crate::clients::CloudAuthentication;
use crate::model::{GolemError, InvocationKey, RawTemplateId};
use crate::WorkerName;

#[async_trait]
pub trait WorkerClient {
async fn new_worker(
Expand Down
8 changes: 5 additions & 3 deletions src/examples.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use crate::model::{ExampleDescription, GolemError};
use crate::GolemResult;
use std::env;

use golem_examples::model::{
ExampleName, ExampleParameters, GuestLanguage, GuestLanguageTier, PackageName, TemplateName,
};
use golem_examples::*;
use std::env;

use crate::model::{ExampleDescription, GolemError};
use crate::GolemResult;

pub fn process_new(
example_name: ExampleName,
Expand Down
13 changes: 7 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
extern crate derive_more;

use std::fmt::Debug;
use std::path::PathBuf;

use clap::builder::ValueParser;
use clap::{Parser, Subcommand};
use clap_verbosity_flag::Verbosity;
Expand All @@ -10,8 +13,10 @@ use golem_client::model::{ComponentInstance, InvokeParameters};
use golem_client::project::ProjectLive;
use golem_client::project_grant::ProjectGrantLive;
use golem_client::project_policy::ProjectPolicyLive;
use std::fmt::Debug;
use std::path::PathBuf;
use golem_examples::model::{ExampleName, GuestLanguage, GuestLanguageTier, PackageName};
use model::*;
use reqwest::Url;
use serde::Serialize;
use uuid::Uuid;

use crate::account::{AccountHandler, AccountHandlerLive, AccountSubcommand};
Expand All @@ -33,10 +38,6 @@ use crate::project_grant::{ProjectGrantHandler, ProjectGrantHandlerLive};
use crate::template::{TemplateHandler, TemplateHandlerLive, TemplateSubcommand};
use crate::token::{TokenHandler, TokenHandlerLive, TokenSubcommand};
use crate::worker::{WorkerHandler, WorkerHandlerLive, WorkerSubcommand};
use golem_examples::model::{ExampleName, GuestLanguage, GuestLanguageTier, PackageName};
use model::*;
use reqwest::Url;
use serde::Serialize;

mod account;
mod auth;
Expand Down
2 changes: 1 addition & 1 deletion src/model.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::ffi::OsStr;
use std::fmt::{Debug, Display, Formatter};
use std::str::FromStr;

use clap::builder::{StringValueParser, TypedValueParser};
use clap::error::{ContextKind, ContextValue, ErrorKind};
Expand All @@ -17,7 +18,6 @@ use golem_client::token::TokenError;
use golem_examples::model::{Example, ExampleName, GuestLanguage, GuestLanguageTier};
use indoc::indoc;
use serde::{Deserialize, Serialize};
use std::str::FromStr;
use strum::IntoEnumIterator;
use strum_macros::EnumIter;
use uuid::Uuid;
Expand Down
5 changes: 3 additions & 2 deletions src/policy.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use async_trait::async_trait;
use clap::Subcommand;

use crate::clients::policy::ProjectPolicyClient;
use crate::clients::CloudAuthentication;
use crate::model::{GolemError, GolemResult, ProjectAction, ProjectPolicyId};
use async_trait::async_trait;
use clap::Subcommand;

#[derive(Subcommand, Debug)]
#[command()]
Expand Down
5 changes: 3 additions & 2 deletions src/project.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use async_trait::async_trait;
use clap::Subcommand;

use crate::clients::project::ProjectClient;
use crate::clients::CloudAuthentication;
use crate::model::{GolemError, GolemResult};
use async_trait::async_trait;
use clap::Subcommand;

#[derive(Subcommand, Debug)]
#[command()]
Expand Down
3 changes: 2 additions & 1 deletion src/project_grant.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use async_trait::async_trait;

use crate::clients::project::ProjectClient;
use crate::clients::project_grant::ProjectGrantClient;
use crate::clients::CloudAuthentication;
use crate::model::{
AccountId, GolemError, GolemResult, ProjectAction, ProjectId, ProjectPolicyId, ProjectRef,
};
use async_trait::async_trait;

#[async_trait]
pub trait ProjectGrantHandler {
Expand Down
14 changes: 8 additions & 6 deletions src/template.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use std::path::PathBuf;

use async_trait::async_trait;
use clap::Subcommand;
use indoc::formatdoc;
use itertools::Itertools;
use uuid::Uuid;

use crate::clients::project::ProjectClient;
use crate::clients::template::{TemplateClient, TemplateView};
use crate::clients::CloudAuthentication;
use crate::model::{
GolemError, GolemResult, ProjectId, ProjectRef, RawTemplateId, TemplateIdOrName, TemplateName,
};
use async_trait::async_trait;
use clap::Subcommand;
use indoc::formatdoc;
use itertools::Itertools;
use std::path::PathBuf;
use uuid::Uuid;

#[derive(Subcommand, Debug)]
#[command()]
Expand Down
7 changes: 4 additions & 3 deletions src/token.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use crate::clients::token::TokenClient;
use crate::clients::CloudAuthentication;
use crate::model::{AccountId, GolemError, GolemResult, TokenId};
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use clap::Subcommand;

use crate::clients::token::TokenClient;
use crate::clients::CloudAuthentication;
use crate::model::{AccountId, GolemError, GolemResult, TokenId};

fn parse_instant(
s: &str,
) -> Result<DateTime<Utc>, Box<dyn std::error::Error + Send + Sync + 'static>> {
Expand Down
9 changes: 5 additions & 4 deletions src/worker.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
use async_trait::async_trait;
use clap::builder::ValueParser;
use clap::Subcommand;
use golem_client::model::InvokeParameters;

use crate::clients::worker::WorkerClient;
use crate::clients::CloudAuthentication;
use crate::model::{
GolemError, GolemResult, InvocationKey, JsonValueParser, TemplateIdOrName, WorkerName,
};
use crate::parse_key_val;
use crate::template::TemplateHandler;
use async_trait::async_trait;
use clap::builder::ValueParser;
use clap::Subcommand;
use golem_client::model::InvokeParameters;

#[derive(Subcommand, Debug)]
#[command()]
Expand Down

0 comments on commit f2c30ea

Please sign in to comment.