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

feat: allow advertising a fake version to clients #2228

Merged
merged 2 commits into from
Jul 2, 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
8 changes: 7 additions & 1 deletion crates/atuin-server/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ pub async fn index<DB: Database>(state: State<AppState<DB>>) -> Json<IndexRespon
// It's super unlikely this will happen
let count = state.database.total_history().await.unwrap_or(-1);

let version = state
.settings
.fake_version
.clone()
.unwrap_or(VERSION.to_string());

Json(IndexResponse {
homage: homage.to_string(),
version: VERSION.to_string(),
total_history: count,
version,
})
}

Expand Down
7 changes: 7 additions & 0 deletions crates/atuin-server/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ pub struct Settings<DbSettings> {
pub tls: Tls,
pub mail: Mail,

/// Advertise a version that is not what we are _actually_ running
/// Many clients compare their version with api.atuin.sh, and if they differ, notify the user
/// that an update is available.
/// Now that we take beta releases, we should be able to advertise a different version to avoid
/// notifying users when the server runs something that is not a stable release.
pub fake_version: Option<String>,

#[serde(flatten)]
pub db_settings: DbSettings,
}
Expand Down
1 change: 1 addition & 0 deletions crates/atuin/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub async fn start_server(path: &str) -> (String, oneshot::Sender<()>, JoinHandl
metrics: atuin_server::settings::Metrics::default(),
tls: atuin_server::settings::Tls::default(),
mail: atuin_server::settings::Mail::default(),
fake_version: None,
};

let (shutdown_tx, shutdown_rx) = tokio::sync::oneshot::channel();
Expand Down
Loading