Commit 4db924c
authored
Validate
<!--
For the checkboxes below you must check each one to indicate that you
either did the relevant task, or considered it and decided there was
nothing that needed doing
-->
- [x] Did you write/update appropriate tests
- [x] Release notes updated (if appropriate)
- [x] Appropriate logging output
- [x] Issue linked
- [x] Docs updated (or issue created)
- [x] New package licenses are added to `ThirdPartyNotices.txt` (if
applicable)
Implements part of #629
Added some powershell to the start of the script generated by `bbs2gh
generate-script` that validates the proper environment variables are set
before executing the rest of the script.
This one was a bit trickier than `ado2gh` because depending on what args
you pass to `generate-script` the script will expect different sets of
env vars. This was the pseudocode I came up with before coding this up:
```
always validate GH_PAT
always validate BBS_PASSWORD unless args.Kerberos
if args.BbsUsername.IsNullOrWhitespace() and !args.Kerberos validate BBS_USERNAME
if args.AwsBucketName.HasValue() or args.AwsRegion.HasValue()
Validate AWS_ACCESS_KEY_ID
Validate AWS_SECRET_ACCESS_KEY
if AwsBucketName.IsNull and AwsRegion.IsNull
Validate AZURE_STORAGE_CONNECTION_STRING
if SmbUser.HasValue
Validate SMB_PASSWORD
```
These are all the various validation messages:
```
if (-not $env:GH_PAT) {
Write-Error "GH_PAT environment variable must be set to a valid GitHub Personal Access Token with the appropriate scopes. For more information see https://docs.github.com/en/migrations/using-github-enterprise-importer/preparing-to-migrate-with-github-enterprise-importer/managing-access-for-github-enterprise-importer#creating-a-personal-access-token-for-github-enterprise-importer"
exit 1
} else {
Write-Host "GH_PAT environment variable is set and will be used to authenticate to GitHub."
}
if (-not $env:BBS_USERNAME) {
Write-Error "BBS_USERNAME environment variable must be set to a valid user that will be used to call BBS API's to generate a migration archive."
exit 1
} else {
Write-Host "BBS_USERNAME environment variable is set and will be used to authenticate to BBS APIs."
}
if (-not $env:BBS_PASSWORD) {
Write-Error "BBS_PASSWORD environment variable must be set to a valid password that will be used to call BBS API's to generate a migration archive."
exit 1
} else {
Write-Host "BBS_PASSWORD environment variable is set and will be used to authenticate to BBS APIs."
}
if (-not $env:AZURE_STORAGE_CONNECTION_STRING) {
Write-Error "AZURE_STORAGE_CONNECTION_STRING environment variable must be set to a valid Azure Storage Connection String that will be used to upload the migration archive to Azure Blob Storage."
exit 1
} else {
Write-Host "AZURE_STORAGE_CONNECTION_STRING environment variable is set and will be used to upload the migration archive to Azure Blob Storage."
}
if (-not $env:AWS_ACCESS_KEY_ID) {
Write-Error "AWS_ACCESS_KEY_ID environment variable must be set to a valid AWS Access Key ID that will be used to upload the migration archive to AWS S3."
exit 1
} else {
Write-Host "AWS_ACCESS_KEY_ID environment variable is set and will be used to upload the migration archive to AWS S3."
}
if (-not $env:AWS_SECRET_ACCESS_KEY) {
Write-Error "AWS_SECRET_ACCESS_KEY environment variable must be set to a valid AWS Secret Access Key that will be used to upload the migration archive to AWS S3."
exit 1
} else {
Write-Host "AWS_SECRET_ACCESS_KEY environment variable is set and will be used to upload the migration archive to AWS S3."
}
if (-not $env:SMB_PASSWORD) {
Write-Error "SMB_PASSWORD environment variable must be set to a valid password that will be used to download the migration archive from your BBS server using SMB."
exit 1
} else {
Write-Host "SMB_PASSWORD environment variable is set and will be used to download the migration archive from your BBS server using SMB."
}
```
Note: I updated this PR to target another PR branch (instead of main) so
the diff is correct for reviewers. Will retarget it to main once that
other PR merges.
<!--
For docs we should review the docs at:
https://docs.github.com/en/early-access/github/migrating-with-github-enterprise-importer
and the README.md in this repo
If a doc update is required based on the changes in this PR, it is
sufficient to create an issue and link to it here. The doc update can be
made later/separately.
The process to update the docs can be found here:
https://github.com/github/docs-early-access#opening-prs
The markdown files are here:
https://github.com/github/docs-early-access/tree/main/content/github/migrating-with-github-enterprise-importer
-->bbs2gh env vars in the generated script (#923)1 parent 37cef2a commit 4db924c
File tree
3 files changed
+281
-4
lines changed- src
- OctoshiftCLI.Tests/bbs2gh/Handlers
- bbs2gh/Handlers
3 files changed
+281
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
Lines changed: 208 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
86 | 290 | | |
87 | 291 | | |
88 | 292 | | |
| |||
102 | 306 | | |
103 | 307 | | |
104 | 308 | | |
105 | | - | |
| 309 | + | |
106 | 310 | | |
107 | 311 | | |
108 | 312 | | |
| |||
488 | 692 | | |
489 | 693 | | |
490 | 694 | | |
491 | | - | |
| 695 | + | |
| 696 | + | |
492 | 697 | | |
493 | 698 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
67 | 90 | | |
68 | 91 | | |
69 | 92 | | |
| |||
232 | 255 | | |
233 | 256 | | |
234 | 257 | | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
235 | 307 | | |
236 | 308 | | |
0 commit comments