-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle deprecation migrations for validate/reconcile
- Loading branch information
1 parent
6d45fb5
commit 01db61e
Showing
4 changed files
with
48 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { UDSPackage } from "."; | ||
|
||
/** | ||
* Migrates the package to the latest version | ||
* | ||
* @param pkg the package to migrate | ||
* @returns | ||
*/ | ||
export function migrate(pkg: UDSPackage) { | ||
const exposeList = pkg.spec?.network?.expose ?? []; | ||
|
||
for (const expose of exposeList) { | ||
// Migrate expose[].match -> expose[].advancedHTTP.match | ||
if (expose.match) { | ||
expose.advancedHTTP = expose.advancedHTTP ?? {}; | ||
expose.advancedHTTP.match = expose.match; | ||
delete expose.match; | ||
} | ||
} | ||
|
||
const allowList = pkg.spec?.network?.allow ?? []; | ||
|
||
for (const allow of allowList) { | ||
// Migrate allow[].podLabels -> allow[].selector | ||
if (allow.podLabels) { | ||
allow.selector = allow.podLabels; | ||
delete allow.podLabels; | ||
} | ||
|
||
// Migrate allow[].remotePodLabels -> allow[].remoteSelector | ||
if (allow.remotePodLabels) { | ||
allow.remoteSelector = allow.remotePodLabels; | ||
delete allow.remotePodLabels; | ||
} | ||
} | ||
|
||
return pkg; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters