Skip to content

Commit af2251a

Browse files
Use app_id when looking up channel and revision
Signed-off-by: Kate Goldenring <kate.goldenring@fermyon.com>
1 parent 855f9ee commit af2251a

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

src/commands/deploy.rs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,18 @@ impl DeployCommand {
169169
// TODO: this process involves many calls to Hippo. Should be able to update the channel
170170
// via only `add_revision` if bindle naming schema is updated so bindles can be deterministically ordered by Hippo.
171171
let channel_id = match self.get_app_id(&hippo_client, name.clone()).await {
172-
Ok(_) => {
172+
Ok(app_id) => {
173173
Client::add_revision(
174174
&hippo_client,
175175
name.clone(),
176176
bindle_id.version_string().clone(),
177177
)
178178
.await?;
179179
let existing_channel_id = self
180-
.get_channel_id(&hippo_client, SPIN_DEPLOY_CHANNEL_NAME.to_string())
180+
.get_channel_id(&hippo_client, SPIN_DEPLOY_CHANNEL_NAME.to_string(), app_id)
181181
.await?;
182182
let active_revision_id = self
183-
.get_revision_id(&hippo_client, bindle_id.version_string().clone())
183+
.get_revision_id(&hippo_client, bindle_id.version_string().clone(), app_id)
184184
.await?;
185185
Client::patch_channel(
186186
&hippo_client,
@@ -292,23 +292,42 @@ impl DeployCommand {
292292
}
293293
}
294294

295-
async fn get_revision_id(&self, hippo_client: &Client, bindle_version: String) -> Result<Uuid> {
295+
async fn get_revision_id(
296+
&self,
297+
hippo_client: &Client,
298+
bindle_version: String,
299+
app_id: Uuid,
300+
) -> Result<Uuid> {
296301
let revisions = Client::list_revisions(hippo_client).await?;
297302
let revision = revisions
298303
.items
299304
.iter()
300-
.find(|&x| x.revision_number == bindle_version);
305+
.find(|&x| x.revision_number == bindle_version && x.app_id == app_id);
301306
Ok(revision
302-
.ok_or_else(|| anyhow::anyhow!("No revision with version {}", bindle_version))?
307+
.ok_or_else(|| {
308+
anyhow::anyhow!(
309+
"No revision with version {} and app id {}",
310+
bindle_version,
311+
app_id
312+
)
313+
})?
303314
.id)
304315
}
305316

306-
async fn get_channel_id(&self, hippo_client: &Client, name: String) -> Result<Uuid> {
317+
async fn get_channel_id(
318+
&self,
319+
hippo_client: &Client,
320+
name: String,
321+
app_id: Uuid,
322+
) -> Result<Uuid> {
307323
let channels_vm = Client::list_channels(hippo_client).await?;
308-
let channel = channels_vm.items.iter().find(|&x| x.name == name.clone());
324+
let channel = channels_vm
325+
.items
326+
.iter()
327+
.find(|&x| x.app_id == app_id && x.name == name.clone());
309328
match channel {
310329
Some(c) => Ok(c.id),
311-
None => anyhow::bail!("No channel with name: {}", name),
330+
None => anyhow::bail!("No channel with app_id {} and name {}", app_id, name),
312331
}
313332
}
314333

0 commit comments

Comments
 (0)