https://pulumi.com logo
Title
p

proud-pizza-80589

12/08/2021, 2:16 PM
Is there a way to clear pending installs using the automation api (typescript)
found exportStack but it not really clear where to remove them
never mind, got it
try {
      const exportedStack = await stack.exportStack();
      if (exportedStack.deployment.pending_operations?.length > 0) {
        exportedStack.deployment.pending_operations = [];
        await stack.importStack(exportedStack);
      }
    } catch (error) {
      // swallow
    }
r

red-match-15116

12/08/2021, 4:25 PM
I think just the following should suffice because import doesn't import pending operations
const exportedStack = await stack.exportStack();
await stack.importStack(exportedStack);
p

proud-pizza-80589

12/09/2021, 7:58 AM
that is different behaviour then from the CLI ? I clean them out with jq in CLI programs
w

wet-soccer-72485

12/10/2021, 8:45 PM
@red-match-15116 thanks for explaining that pending operations are auto omitted. I have in my automation pipeline similar code to @proud-pizza-80589. Always glad to learn more about the code I’m calling 😆
r

red-match-15116

12/11/2021, 1:17 AM
I think @proud-pizza-80589 is right here actually, I was mistaken. Although I guess checking if there are pending operations isn't really necessary so you can save one line and do:
const exportedStack = await stack.exportStack();
exportedStack.deployment.pending_operations = [];
await stack.importStack(exportedStack);
w

wet-soccer-72485

12/11/2021, 1:35 AM
@red-match-15116 I think @proud-pizza-80589’s code saves time, because it doesn’t import the stack if there aren’t any pending ops
r

red-match-15116

12/11/2021, 5:55 AM
Lol fair point