#Is it possible to break out of sub pipelines?

1 messages · Page 1 of 1 (latest)

steep dune
#

I'm running multiple WithExec under a container sub pipeline. I was wondering if it's possible to end a pipine and start a new one, or if there is a better way to organize a group of constructs. Say I'm setting up AWS in the container, I'd like to group those operations then group the chain of exec under a different label, but not have them nested.

Sorry for the lack of an example, I'm not in front of my computer. I can add an example later.

mortal mural
steep dune
#

Thank you! I can definitely use this for some of what I'm doing.
Is there a way to do this with .with though? In TypeScript, .with has the signature with(arg: (param: Container) => Container): Container; so I'm not able to use sync or grab the id because of the promises, and I don't want to mix async with sync calls.

I currently have this code

export type ContainerRet = (container: Container) => Container;

export const withAws = (client: Client): ContainerRet => {
    const home = homedir();
    const awsConfigPath = ".aws/config";
    const awsSsoCachePath = ".aws/sso/cache/";
    const homeAwsConfigPath = `${home}/${awsConfigPath}`;
    const homeAwsSsoCachePath = `${home}/${awsSsoCachePath}`;
    const configSource = client.host().file(homeAwsConfigPath);
    const ssoCacheSource = client.host().directory(homeAwsSsoCachePath);
    return (container: Container) => container
        .pipeline("Setup AWS")
        .withDirectory(`/root/${awsSsoCachePath}`, ssoCacheSource)
        .withFile(`/root/${awsConfigPath}`, configSource)
        .withEnvVariable("AWS_PROFILE", "dev");
};

But if I use it using .with(withAws(client)).pipeline("something"), the something sub pipeline get nested within Setup AWS.

Switching that code to

export type ContainerRet = (container: Container) => Container | Promise<Container>;

export const withAws = (client: Client): ContainerRet => {
    const home = homedir();
    const awsConfigPath = ".aws/config";
    const awsSsoCachePath = ".aws/sso/cache/";
    const homeAwsConfigPath = `${home}/${awsConfigPath}`;
    const homeAwsSsoCachePath = `${home}/${awsSsoCachePath}`;
    const configSource = client.host().file(homeAwsConfigPath);
    const ssoCacheSource = client.host().directory(homeAwsSsoCachePath);
    return async (container: Container) => {
        const setupAws = await container
            .pipeline("Setup AWS")
            .withDirectory(`/root/${awsSsoCachePath}`, ssoCacheSource)
            .withFile(`/root/${awsConfigPath}`, configSource)
            .withEnvVariable("AWS_PROFILE", "dev").sync();
        const id = await setupAws.id();
        return client.container({
            id,
        });
    };
};

no longer works with with() type signature.