@@ -164,56 +164,60 @@ impl DeployCommand {
164
164
} ) ;
165
165
166
166
let name = bindle_id. name ( ) . to_string ( ) ;
167
- // Values for channel creation are determined by whether the app already exists
168
- let mut active_revision_id = None ;
169
- let mut range_rule = None ;
170
- let mut revision_selection_strategy = ChannelRevisionSelectionStrategy :: UseRangeRule ;
171
167
172
168
// Create or update app
173
- let app_id = match self . get_app_id ( & hippo_client, name. clone ( ) ) . await {
174
- Ok ( app_id) => {
169
+ // TODO: this process involves many calls to Hippo. Should be able to update the channel
170
+ // via only `add_revision` if bindle naming schema is updated so bindles can be deterministically ordered by Hippo.
171
+ let channel_id = match self . get_app_id ( & hippo_client, name. clone ( ) ) . await {
172
+ Ok ( _) => {
175
173
Client :: add_revision (
176
174
& hippo_client,
177
175
name. clone ( ) ,
178
176
bindle_id. version_string ( ) . clone ( ) ,
179
177
)
180
178
. await ?;
181
-
182
- // Remove existing channel to prevent conflict
183
- // TODO: in the future, expand hippo API to update channel rather than delete and recreate
184
179
let existing_channel_id = self
185
180
. get_channel_id ( & hippo_client, SPIN_DEPLOY_CHANNEL_NAME . to_string ( ) )
186
181
. await ?;
187
- Client :: remove_channel ( & hippo_client, existing_channel_id. to_string ( ) ) . await ?;
188
- active_revision_id = Some (
189
- self . get_revision_id ( & hippo_client, bindle_id. version_string ( ) . clone ( ) )
190
- . await ?,
191
- ) ;
192
- revision_selection_strategy =
193
- ChannelRevisionSelectionStrategy :: UseSpecifiedRevision ;
194
- app_id
182
+ let active_revision_id = self
183
+ . get_revision_id ( & hippo_client, bindle_id. version_string ( ) . clone ( ) )
184
+ . await ?;
185
+ Client :: patch_channel (
186
+ & hippo_client,
187
+ existing_channel_id,
188
+ None ,
189
+ None ,
190
+ Some ( ChannelRevisionSelectionStrategy :: UseSpecifiedRevision ) ,
191
+ None ,
192
+ Some ( active_revision_id) ,
193
+ None ,
194
+ None ,
195
+ )
196
+ . await
197
+ . context ( "Problem patching a channel in Hippo" ) ?;
198
+
199
+ existing_channel_id
195
200
}
196
201
Err ( _) => {
197
- range_rule = Some ( bindle_id. version_string ( ) ) ;
198
- Client :: add_app ( & hippo_client, name. clone ( ) , name. clone ( ) )
202
+ let range_rule = Some ( bindle_id. version_string ( ) ) ;
203
+ let app_id = Client :: add_app ( & hippo_client, name. clone ( ) , name. clone ( ) )
199
204
. await
200
- . context ( "Unable to create Hippo app" ) ?
205
+ . context ( "Unable to create Hippo app" ) ?;
206
+ Client :: add_channel (
207
+ & hippo_client,
208
+ app_id,
209
+ String :: from ( SPIN_DEPLOY_CHANNEL_NAME ) ,
210
+ None ,
211
+ ChannelRevisionSelectionStrategy :: UseRangeRule ,
212
+ range_rule,
213
+ None ,
214
+ None ,
215
+ )
216
+ . await
217
+ . context ( "Problem creating a channel in Hippo" ) ?
201
218
}
202
219
} ;
203
220
204
- let channel_id = Client :: add_channel (
205
- & hippo_client,
206
- app_id,
207
- String :: from ( SPIN_DEPLOY_CHANNEL_NAME ) ,
208
- None ,
209
- revision_selection_strategy,
210
- range_rule,
211
- active_revision_id,
212
- None ,
213
- )
214
- . await
215
- . context ( "Problem creating a channel in Hippo" ) ?;
216
-
217
221
println ! (
218
222
"Deployed {} version {}" ,
219
223
name. clone( ) ,
0 commit comments