Is there a way to clear pending installs using the...
# automation-api
p
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
Copy code
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
I think just the following should suffice because import doesn't import pending operations
Copy code
const exportedStack = await stack.exportStack();
await stack.importStack(exportedStack);
p
that is different behaviour then from the CLI ? I clean them out with jq in CLI programs
w
@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
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:
Copy code
const exportedStack = await stack.exportStack();
exportedStack.deployment.pending_operations = [];
await stack.importStack(exportedStack);
w
@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
Lol fair point