#!/usr/bin/env bash

NC=128
SC=128
SIZE=32K # in `head` format

generate_namespace_secrets() {
  local ns=$1

  for j in $(seq $SC)
  do
    encoded=$(head -c "$SIZE" /dev/urandom | base64 -w0)
    cat <<EOF
---
apiVersion: v1
kind: Secret
metadata:
  namespace: $ns
  name: $ns-$j
data:
  random.bin: $encoded
EOF
  done
}

for i in $(seq $NC)
do
  ns="test-random-secret$i"
  oc create -f - <<EOF
apiVersion: v1
kind: Namespace
metadata:
  name: $ns
EOF

  generate_namespace_secrets "$ns" | oc create -f -

done
