<commit_before>#!/usr/bin/env bash
#
# Define functions to customize the Kubeflow app for GCP.
#
set -xe

gcpCreateSecretsDir() {
  # Create a directory to contain GCP secrets.
  mkdir -p ${KUBEFLOW_SECRETS_DIR}

  # We want to prevent secrets from being checked into source control.
  # We have two different checks.
  # 1. We put the secrets in a directory with a .gitignore file
  # 2. We will delete the secrets immediately.
  if [ ! -f ${KUBEFLOW_SECRETS_DIR}/.gitignore ]; then
    cat > ${KUBEFLOW_SECRETS_DIR}/.gitignore <<EOF
**
EOF
  fi
}

gcpInitProject() {
  # Enable GCloud APIs
  gcloud services enable deploymentmanager.googleapis.com \
    servicemanagement.googleapis.com \
    container.googleapis.com \
    cloudresourcemanager.googleapis.com \
    endpoints.googleapis.com \
    file.googleapis.com \
    ml.googleapis.com \
    iam.googleapis.com --project=${PROJECT}

  # Set IAM Admin Policy
  gcloud projects add-iam-policy-binding ${PROJECT} \
    --member serviceAccount:${PROJECT_<EMAIL> \
    --role roles/resourcemanager.projectIamAdmin
}

generateDMConfigs() {
  # Create the DM configs if they don't exist.
  if [ ! -d "${KUBEFLOW_DM_DIR}" ]; then
    echo creating Deployment Manager configs in directory "${KUBEFLOW_DM_DIR}"
    mkdir -p "${KUBEFLOW_DM_DIR}"
    cp -r "${KUBEFLOW_REPO}"/deployment/gke/deployment_manager_configs/cluster* "${KUBEFLOW_DM_DIR}"

    if [[ "$EMAIL" =~ .*iam\.gserviceaccount\.com ]]; then
      IAP_IAM_ENTRY="serviceAccount:${EMAIL}"
    else
      IAP_IAM_ENTRY="user:${EMAIL}"
    fi

    cp "${KUBEFLOW_REPO}"/deployment/gke/deployment_manager_configs/iam_bindings_template.yaml "${KUBEFLOW_DM_DIR}"/iam_bindings.yaml

    # Set the various service accounts in iam_bindings.yaml
    sed -i.bak "s/set-kubeflow-admin-service-account/serviceAccount:${DEPLOYMENT_NAME}-admin@${PROJECT}.iam.gserviceaccount.com/" "${KUBEFLOW_DM_DIR}"/iam_bindings.yaml
    sed -i.bak "s/set-kubeflow-user-service-account/serviceAccount:${DEPLOYMENT_NAME}-user@${PROJECT}.iam.gserviceaccount.com/" "${KUBEFLOW_DM_DIR}"/iam_bindings.yaml
    sed -i.bak "s/set-kubeflow-vm-service-account/serviceAccount:${DEPLOYMENT_NAME}-vm@${<EMAIL>}.<EMAIL>/" "${KUBEFLOW_DM_DIR}"/iam_bindings.yaml
    sed -i.bak "s/set-kubeflow-iap-account/${IAP_IAM_ENTRY}/" "${KUBEFLOW_DM_DIR}"/iam_bindings.yaml
    rm "${KUBEFLOW_DM_DIR}/iam_bindings.yaml.bak"<commit_msg>Don't grant cloudservices account IAM admin priveleges. (#2101)<commit_after>#!/usr/bin/env bash
#
# Define functions to customize the Kubeflow app for GCP.
#
set -xe

gcpCreateSecretsDir() {
  # Create a directory to contain GCP secrets.
  mkdir -p ${KUBEFLOW_SECRETS_DIR}

  # We want to prevent secrets from being checked into source control.
  # We have two different checks.
  # 1. We put the secrets in a directory with a .gitignore file
  # 2. We will delete the secrets immediately.
  if [ ! -f ${KUBEFLOW_SECRETS_DIR}/.gitignore ]; then
    cat > ${KUBEFLOW_SECRETS_DIR}/.gitignore <<EOF
**
EOF
  fi
}

gcpInitProject() {
  # Enable GCloud APIs
  gcloud services enable deploymentmanager.googleapis.com \
    servicemanagement.googleapis.com \
    container.googleapis.com \
    cloudresourcemanager.googleapis.com \
    endpoints.googleapis.com \
    file.googleapis.com \
    ml.googleapis.com \
    iam.googleapis.com --project=${PROJECT}
}

generateDMConfigs() {
  # Create the DM configs if they don't exist.
  if [ ! -d "${KUBEFLOW_DM_DIR}" ]; then
    echo creating Deployment Manager configs in directory "${KUBEFLOW_DM_DIR}"
    mkdir -p "${KUBEFLOW_DM_DIR}"
    cp -r "${KUBEFLOW_REPO}"/deployment/gke/deployment_manager_configs/cluster* "${KUBEFLOW_DM_DIR}"

    if [[ "$EMAIL" =~ .*iam\.gserviceaccount\.com ]]; then
      IAP_IAM_ENTRY="serviceAccount:${EMAIL}"
    else
      IAP_IAM_ENTRY="user:${EMAIL}"
    fi

    cp "${KUBEFLOW_REPO}"/deployment/gke/deployment_manager_configs/iam_bindings_template.yaml "${KUBEFLOW_DM_DIR}"/iam_bindings.yaml

    # Set the various service accounts in iam_bindings.yaml
    sed -i.bak "s/set-kubeflow-admin-service-account/serviceAccount:${DEPLOYMENT_NAME}-admin@${PROJECT}.<EMAIL>/" "${KUBEFLOW_DM_DIR}"/iam_bindings.yaml
    sed -i.bak "s/set-kubeflow-user-service-account/serviceAccount:${DEPLOYMENT_NAME}-user@${PROJECT}.iam.<EMAIL>/" "${KUBEFLOW_DM_DIR}"/iam_bindings.yaml
    sed -i.bak "s/set-kubeflow-vm-service-account/serviceAccount:${DEPLOYMENT_NAME}-vm@${PROJECT}.<EMAIL>/" "${KUBEFLOW_DM_DIR}"/iam_bindings.yaml
    sed -i.bak "s/set-kubeflow-iap-account/${IAP_IAM_ENTRY}/" "${KUBEFLOW_DM_DIR}"/iam_bindings.yaml
    rm "${KUBEFLOW_DM_DIR}/iam_bindings.yaml.bak"
{'fraction_non_alphanumeric': 0.1343702743573126, 'fraction_numerical': 0.0017282350399654353, 'mean_word_length': 4.13873473917869, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5481683', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1688, 'n_words': 314}