|
| 1 | +# Development Scripts Configuration |
| 2 | + |
| 3 | +## Environment Variables |
| 4 | + |
| 5 | +### Required Variables |
| 6 | +These must be set before running any hack scripts: |
| 7 | + |
| 8 | +```bash |
| 9 | +export BOT_TOKEN="your-slack-bot-token" |
| 10 | +export BOT_SIGNING_SECRET="your-slack-signing-secret" |
| 11 | +``` |
| 12 | + |
| 13 | +### Optional Configuration |
| 14 | + |
| 15 | +#### Organizational Data Backend |
| 16 | + |
| 17 | +**Option 1: Use GCS Backend (Production)** |
| 18 | +```bash |
| 19 | +export USE_GCS_ORGDATA=true |
| 20 | +export GCS_BUCKET="resolved-org" # Default: resolved-org |
| 21 | +export GCS_OBJECT_PATH="orgdata/comprehensive_index_dump.json" # Default path |
| 22 | +export GCS_PROJECT_ID="openshift-crt-mce" # Default project |
| 23 | +export GCS_CHECK_INTERVAL="5m" # Default: 5 minutes |
| 24 | +export GCS_CREDENTIALS_JSON='{"type":"service_account",...}' # Optional: explicit creds |
| 25 | +``` |
| 26 | + |
| 27 | +**Option 2: Use Local Files (Development)** |
| 28 | +```bash |
| 29 | +export ORGDATA_PATHS="/path/to/your/comprehensive_index_dump.json" |
| 30 | +# Default: ../cyborg/org_tools/comprehensive_index_dump.json (relative to ci-chat-bot) |
| 31 | +``` |
| 32 | + |
| 33 | +#### Authorization Configuration |
| 34 | +```bash |
| 35 | +export AUTH_CONFIG="/path/to/your/authorization.yaml" |
| 36 | +# Default: ./test-authorization.yaml (relative to ci-chat-bot root) |
| 37 | +``` |
| 38 | + |
| 39 | +## GCS Authentication Setup |
| 40 | + |
| 41 | +### Using Application Default Credentials (Recommended) |
| 42 | +```bash |
| 43 | +# Authenticate with gcloud |
| 44 | +gcloud auth login |
| 45 | +gcloud config set project openshift-crt-mce |
| 46 | +``` |
| 47 | + |
| 48 | +### Using Service Account (Production) |
| 49 | +```bash |
| 50 | +# Set credentials via environment variable |
| 51 | +export GCS_CREDENTIALS_JSON='{"type":"service_account",...}' |
| 52 | + |
| 53 | +# OR via file |
| 54 | +export GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account.json" |
| 55 | +``` |
| 56 | + |
| 57 | +### GCS Bucket Security |
| 58 | +The GCS bucket should be configured with: |
| 59 | +- ✅ **Public access prevention**: Enforced |
| 60 | +- ✅ **Uniform bucket-level access**: Enabled |
| 61 | +- ✅ **IAM-based access control**: Project members only |
| 62 | +- ✅ **Bucket-level encryption**: Enabled |
| 63 | + |
| 64 | +## Directory Structure Assumptions |
| 65 | + |
| 66 | +The scripts assume this directory layout (relative to ci-chat-bot): |
| 67 | +``` |
| 68 | +workspace/ |
| 69 | +├── ci-chat-bot/ # This repository |
| 70 | +│ ├── hack/ |
| 71 | +│ │ ├── run.sh # Main development script |
| 72 | +│ │ └── run-with-gcs.sh # GCS convenience script |
| 73 | +│ └── test-authorization.yaml # Default auth config |
| 74 | +├── cyborg/ # Optional: orgdata repository |
| 75 | +│ └── org_tools/ |
| 76 | +│ └── comprehensive_index_dump.json |
| 77 | +└── release/ # OpenShift release repository (required) |
| 78 | + ├── ci-operator/ |
| 79 | + └── core-services/ |
| 80 | +``` |
| 81 | + |
| 82 | +## Usage Examples |
| 83 | + |
| 84 | +### Quick Start with GCS |
| 85 | +```bash |
| 86 | +# Set required tokens |
| 87 | +export BOT_TOKEN="xoxb-your-token" |
| 88 | +export BOT_SIGNING_SECRET="your-secret" |
| 89 | + |
| 90 | +# Use GCS backend |
| 91 | +./hack/run-with-gcs.sh |
| 92 | +``` |
| 93 | + |
| 94 | +### Development with Local Files |
| 95 | +```bash |
| 96 | +# Set required tokens |
| 97 | +export BOT_TOKEN="xoxb-your-token" |
| 98 | +export BOT_SIGNING_SECRET="your-secret" |
| 99 | + |
| 100 | +# Point to your local orgdata file |
| 101 | +export ORGDATA_PATHS="/your/path/to/comprehensive_index_dump.json" |
| 102 | + |
| 103 | +# Run with local file backend |
| 104 | +./hack/run.sh |
| 105 | +``` |
| 106 | + |
| 107 | +### Custom Configuration |
| 108 | +```bash |
| 109 | +# Required tokens |
| 110 | +export BOT_TOKEN="xoxb-your-token" |
| 111 | +export BOT_SIGNING_SECRET="your-secret" |
| 112 | + |
| 113 | +# Custom GCS configuration |
| 114 | +export USE_GCS_ORGDATA=true |
| 115 | +export GCS_BUCKET="my-org-bucket" |
| 116 | +export GCS_PROJECT_ID="my-project" |
| 117 | +export GCS_CREDENTIALS_JSON="$(cat /path/to/service-account.json)" |
| 118 | + |
| 119 | +# Custom auth config |
| 120 | +export AUTH_CONFIG="/path/to/my-auth-config.yaml" |
| 121 | + |
| 122 | +./hack/run.sh |
| 123 | +``` |
| 124 | + |
| 125 | +## Script Behavior |
| 126 | + |
| 127 | +1. **`hack/run.sh`** - Main development script |
| 128 | + - Detects GCS vs local file mode via `USE_GCS_ORGDATA` |
| 129 | + - Uses sensible defaults for file paths relative to project |
| 130 | + - Extracts secrets from OpenShift CI clusters |
| 131 | + - Builds and runs ci-chat-bot with appropriate flags |
| 132 | + |
| 133 | +2. **`hack/run-with-gcs.sh`** - Convenience wrapper |
| 134 | + - Sets `USE_GCS_ORGDATA=true` |
| 135 | + - Uses production GCS defaults |
| 136 | + - Calls `hack/run.sh` |
| 137 | + |
| 138 | +## Troubleshooting |
| 139 | + |
| 140 | +### File Not Found Errors |
| 141 | +If you see errors about missing files: |
| 142 | +1. Check that `ORGDATA_PATHS` points to a valid file |
| 143 | +2. Ensure the `../cyborg` directory exists if using defaults |
| 144 | +3. Verify the `../release` directory exists (OpenShift release repo) |
| 145 | + |
| 146 | +### GCS Authentication Errors |
| 147 | +If GCS fails to authenticate: |
| 148 | +1. **Check authentication**: `gcloud auth list` |
| 149 | +2. **Test access**: `gcloud storage ls gs://resolved-org/orgdata/` |
| 150 | +3. **Verify permissions**: Check bucket IAM settings |
| 151 | +4. **Try service account**: Set `GCS_CREDENTIALS_JSON` if ADC fails |
| 152 | + |
| 153 | +Common GCS errors: |
| 154 | +- **"Authentication failed"**: Run `gcloud auth login` |
| 155 | +- **"Access denied"**: Check bucket IAM permissions |
| 156 | +- **"Object not found"**: Verify `GCS_BUCKET` and `GCS_OBJECT_PATH` |
| 157 | + |
| 158 | +### Authorization Issues |
| 159 | +If authorization is too restrictive: |
| 160 | +1. Check `AUTH_CONFIG` points to a valid YAML file |
| 161 | +2. Review the authorization rules in that file |
| 162 | +3. Set `AUTH_CONFIG=""` to disable authorization for testing |
| 163 | + |
| 164 | +### Migration from File-based to GCS |
| 165 | +1. **Upload your existing data**: |
| 166 | + ```bash |
| 167 | + gcloud storage cp comprehensive_index_dump.json gs://resolved-org/orgdata/ |
| 168 | + ``` |
| 169 | +2. **Test GCS access**: `./hack/run-with-gcs.sh` |
| 170 | +3. **Update your workflow**: Set `USE_GCS_ORGDATA=true` in your environment |
0 commit comments