Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove keygen.sh #551

Merged
merged 4 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions crates/cli/src/commands/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
info!(" Build SHA: unknown");
}

let mut updater = Updater::from_current_bin().await?;

Check failure on line 37 in crates/cli/src/commands/doctor.rs

View workflow job for this annotation

GitHub Actions / clippy

variable does not need to be mutable

error: variable does not need to be mutable --> crates/cli/src/commands/doctor.rs:37:9 | 37 | let mut updater = Updater::from_current_bin().await?; | ----^^^^^^^ | | | help: remove this `mut` | = note: `-D unused-mut` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unused_mut)]`

info!("{}", "Configuration".bold());

Expand Down Expand Up @@ -132,12 +132,6 @@
);
continue;
}
let manifest = existing_manifests.get(&name).unwrap();
if manifest.version.is_none() {
if let Some(supported) = SupportedApp::from_all_app(manifest.name.clone()) {
updater.sync_manifest_version(supported).await?;
}
}
}

for app_manifest in updater.binaries.values() {
Expand Down
54 changes: 0 additions & 54 deletions crates/cli/src/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
}
}

pub fn from_all_app(app: AllApp) -> Option<Self> {

Check failure on line 99 in crates/cli/src/updater.rs

View workflow job for this annotation

GitHub Actions / clippy

associated function `from_all_app` is never used

error: associated function `from_all_app` is never used --> crates/cli/src/updater.rs:99:12 | 75 | impl SupportedApp { | ----------------- associated function in this implementation ... 99 | pub fn from_all_app(app: AllApp) -> Option<Self> { | ^^^^^^^^^^^^ | = note: `-D dead-code` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(dead_code)]`
match app {
AllApp::Marzano => Some(SupportedApp::Marzano),
AllApp::Gouda => Some(SupportedApp::Gouda),
Expand Down Expand Up @@ -140,8 +140,6 @@
}

const MANIFEST_FILE: &str = "manifests.json";
const KEYGEN_API: &str = "https://api.keygen.sh/";
const KEYGEN_ACCOUNT: &str = "custodian-dev";

#[derive(Debug)]
pub struct Updater {
Expand Down Expand Up @@ -538,26 +536,6 @@
bail!("Attempted to install {} but could not find it", app);
}

pub async fn sync_manifest_version(&mut self, app: SupportedApp) -> Result<Option<String>> {
let app_string = app.get_base_name();
let release = match self.binaries.get(&app_string) {
Some(app_manifest) => app_manifest.release.clone(),
None => None,
};
if release.is_none() {
return Ok(None);
}
let info_url = release_details_relative_url(release.as_ref().unwrap());
let manifest = fetch_manifest(&info_url, app).await?;
if manifest.version.is_none() || manifest.release.is_none() {
return Ok(None);
}
let version = manifest.version.clone();
self.set_app_version(app, manifest.version.unwrap(), manifest.release.unwrap())?;
self.dump().await?;
Ok(version)
}

fn set_app_version(
&mut self,
app: SupportedApp,
Expand Down Expand Up @@ -625,38 +603,6 @@
Ok(new_version)
}

async fn fetch_manifest(relative_url: &str, app: SupportedApp) -> Result<AppManifest> {
let client = reqwest::Client::builder().build()?;
let url = format!("{}{}", KEYGEN_API, relative_url);
let res = client.get(url).send().await?.text().await?;
let json_data: serde_json::Value = serde_json::from_str(&res).unwrap();

let version = if let Some(version) = json_data["data"]
.get("attributes")
.and_then(|attributes| attributes.get("version"))
{
version.as_str().unwrap().to_string()
} else {
bail!("Could not find version");
};

let release = if let Some(id) = json_data["data"].get("id") {
id.as_str().unwrap().to_string()
} else {
bail!("Could not find release");
};

Ok(AppManifest {
name: AllApp::from_supported_app(app),
release: Some(release),
version: Some(version),
})
}

fn release_details_relative_url(release: &str) -> String {
format!("/v1/accounts/{}/releases/{}", KEYGEN_ACCOUNT, release)
}

#[cfg(test)]
mod tests {

Expand Down
5 changes: 0 additions & 5 deletions python/gritql/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@

import httpx

# handles downloading the Grit CL if not found already

KEYGEN_ACCOUNT = "custodian-dev"


def _cache_dir() -> Path:
xdg = os.environ.get("XDG_CACHE_HOME")
if xdg is not None:
Expand Down
Loading