All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.cloudshiftdev.awscdk.pipelines.PipelineBaseProps.kt Maven / Gradle / Ivy

The newest version!
@file:Suppress("RedundantVisibilityModifier","RedundantUnitReturnType","RemoveRedundantQualifierName","unused","UnusedImport","ClassName","REDUNDANT_PROJECTION","DEPRECATION")

package io.cloudshiftdev.awscdk.pipelines

import io.cloudshiftdev.awscdk.common.CdkDslMarker
import io.cloudshiftdev.awscdk.common.CdkObject
import io.cloudshiftdev.awscdk.common.CdkObjectWrappers
import kotlin.Unit

/**
 * Properties for a `Pipeline`.
 *
 * Example:
 *
 * ```
 * // The code below shows an example of how to instantiate this type.
 * // The values are placeholders you should change.
 * import io.cloudshiftdev.awscdk.pipelines.*;
 * IFileSetProducer fileSetProducer;
 * PipelineBaseProps pipelineBaseProps = PipelineBaseProps.builder()
 * .synth(fileSetProducer)
 * .build();
 * ```
 */
public interface PipelineBaseProps {
  /**
   * The build step that produces the CDK Cloud Assembly.
   *
   * The primary output of this step needs to be the `cdk.out` directory
   * generated by the `cdk synth` command.
   *
   * If you use a `ShellStep` here and you don't configure an output directory,
   * the output directory will automatically be assumed to be `cdk.out`.
   */
  public fun synth(): IFileSetProducer

  /**
   * A builder for [PipelineBaseProps]
   */
  @CdkDslMarker
  public interface Builder {
    /**
     * @param synth The build step that produces the CDK Cloud Assembly. 
     * The primary output of this step needs to be the `cdk.out` directory
     * generated by the `cdk synth` command.
     *
     * If you use a `ShellStep` here and you don't configure an output directory,
     * the output directory will automatically be assumed to be `cdk.out`.
     */
    public fun synth(synth: IFileSetProducer)
  }

  private class BuilderImpl : Builder {
    private val cdkBuilder: software.amazon.awscdk.pipelines.PipelineBaseProps.Builder =
        software.amazon.awscdk.pipelines.PipelineBaseProps.builder()

    /**
     * @param synth The build step that produces the CDK Cloud Assembly. 
     * The primary output of this step needs to be the `cdk.out` directory
     * generated by the `cdk synth` command.
     *
     * If you use a `ShellStep` here and you don't configure an output directory,
     * the output directory will automatically be assumed to be `cdk.out`.
     */
    override fun synth(synth: IFileSetProducer) {
      cdkBuilder.synth(synth.let(IFileSetProducer.Companion::unwrap))
    }

    public fun build(): software.amazon.awscdk.pipelines.PipelineBaseProps = cdkBuilder.build()
  }

  private class Wrapper(
    cdkObject: software.amazon.awscdk.pipelines.PipelineBaseProps,
  ) : CdkObject(cdkObject),
      PipelineBaseProps {
    /**
     * The build step that produces the CDK Cloud Assembly.
     *
     * The primary output of this step needs to be the `cdk.out` directory
     * generated by the `cdk synth` command.
     *
     * If you use a `ShellStep` here and you don't configure an output directory,
     * the output directory will automatically be assumed to be `cdk.out`.
     */
    override fun synth(): IFileSetProducer = unwrap(this).getSynth().let(IFileSetProducer::wrap)
  }

  public companion object {
    public operator fun invoke(block: Builder.() -> Unit = {}): PipelineBaseProps {
      val builderImpl = BuilderImpl()
      return Wrapper(builderImpl.apply(block).build())
    }

    internal fun wrap(cdkObject: software.amazon.awscdk.pipelines.PipelineBaseProps):
        PipelineBaseProps = CdkObjectWrappers.wrap(cdkObject) as? PipelineBaseProps ?:
        Wrapper(cdkObject)

    internal fun unwrap(wrapped: PipelineBaseProps):
        software.amazon.awscdk.pipelines.PipelineBaseProps = (wrapped as CdkObject).cdkObject as
        software.amazon.awscdk.pipelines.PipelineBaseProps
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy