# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#      http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This file was generated by running `make generate`. DO NOT EDIT

version: 0.2

env:
  variables:
    ARTIFACTS_BUCKET: "eks-d-postsubmit-artifacts"
    BUILDKIT_PLATFORMS: "linux/amd64"
    EKS_D_BUILD_TOOLING_REMOTE_URL: "https://github.com/aws/eks-distro-build-tooling.git"
    IMAGE_NAME: "builder-base-development"
    TARGET_BRANCH: "main"
    UPDATE_BASE_IMAGE: "false"

phases:
  pre_build:
    commands:
      - echo Running pre-build setup and initialization...
      - scripts/sync_uninitialized_git_repository.sh . $EKS_D_BUILD_TOOLING_REMOTE_URL $TARGET_BRANCH
      - scripts/setup_ecr_credential_helper.sh
      - projects/golang/go/scripts/replace_builder_base_go_versions.sh
  build:
    commands:
      - mkdir -p builder-base/tmp/golang-downloads/x86_64
      - >-
        for f in ${CODEBUILD_SRC_DIR_eks_go_amd64}/golang_*/eks_go_amd64/projects/golang/go/*/rpmbuild/*/golang-*.rpm; do
          fileName=$(basename ${f})
          cp ${f} "${CODEBUILD_SRC_DIR}/builder-base/tmp/golang-downloads/x86_64/${fileName}"
        done
      - make -C builder-base copy-generate-attribution
      - make -C builder-base download-golang
      - make -C builder-base images
  post_build:
    commands:
      - echo Updating EKS Distro rebuild job to use custom builder base image...
      - projects/golang/go/scripts/update_codebuild_base_image.sh build-eks-distro-custom-builder-base builder-base-development latest $AWS_REGION
