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 all commits
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
4 changes: 1 addition & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ jobs:
unzip terraform_1.6.0_linux_amd64.zip
chmod +x terraform
sudo mv terraform /usr/local/bin/
- name: install dependencies
run: |
cargo install buildkite-test-collector

- name: setup node.js environment
uses: actions/setup-node@v3
- name: Install prettier
Expand Down
15 changes: 0 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ openssl = { version = "0.10", features = ["vendored"] }

[dev-dependencies]
trim-margin = "0.1.0"
buildkite-test-collector = "0.1.1"
similar = "2.2.1"
reqwest = { version = "0.11.22", features = ["blocking", "json"] }
marzano-test-utils = { path = "../test_utils" }
Expand Down
8 changes: 1 addition & 7 deletions crates/cli/src/commands/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) async fn run_doctor(_arg: DoctorArgs) -> Result<()> {
info!(" Build SHA: unknown");
}

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

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

Expand Down Expand Up @@ -132,12 +132,6 @@ pub(crate) async fn run_doctor(_arg: DoctorArgs) -> Result<()> {
);
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
64 changes: 0 additions & 64 deletions crates/cli/src/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@ impl SupportedApp {
SupportedApp::WorkflowRunner => "GRIT_WORKFLOW_RUNNER".to_string(),
}
}

pub fn from_all_app(app: AllApp) -> Option<Self> {
match app {
AllApp::Marzano => Some(SupportedApp::Marzano),
AllApp::Gouda => Some(SupportedApp::Gouda),
#[cfg(feature = "workflows_v2")]
AllApp::WorkflowRunner => Some(SupportedApp::WorkflowRunner),
_ => None,
}
}
}

impl fmt::Display for SupportedApp {
Expand Down Expand Up @@ -140,8 +130,6 @@ async fn read_manifest(manifest_path: &PathBuf) -> Result<Manifest> {
}

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 +526,6 @@ impl Updater {
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 +593,6 @@ async fn check_release_axo(
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