Skip to content

Feature/more flexibility for managed object names #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rockcarver/frodo-lib",
"version": "2.3.1-0",
"version": "2.4.0",
"type": "commonjs",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
15 changes: 11 additions & 4 deletions src/ops/ApplicationOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,18 @@ export function createApplicationExportTemplate({
}

export function getRealmManagedApplication({ state }: { state: State }) {
let realmManagedOrg = 'application';
if (state.getDeploymentType() === constants.CLOUD_DEPLOYMENT_TYPE_KEY) {
realmManagedOrg = `${getCurrentRealmName(state)}_application`;
let realmManagedApp = 'application';
if (
state.getDeploymentType() === constants.CLOUD_DEPLOYMENT_TYPE_KEY ||
state.getUseRealmPrefixOnManagedObjects() === true
) {
realmManagedApp = `${getCurrentRealmName(state)}_application`;
debugMessage({
message: `DeploymentType === cloud or UseRealmPrefixOnManagedObjects is true, returning '${realmManagedApp}'`,
state: state,
});
}
return realmManagedOrg;
return realmManagedApp;
}

export async function createApplication({
Expand Down
10 changes: 9 additions & 1 deletion src/ops/OrganizationOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { IdObjectSkeletonInterface } from '../api/ApiTypes';
import { queryAllManagedObjectsByType } from '../api/ManagedObjectApi';
import Constants from '../shared/Constants';
import { State } from '../shared/State';
import { debugMessage } from '../utils/Console';
import { FrodoError } from './FrodoError';

export type Organization = {
Expand Down Expand Up @@ -53,8 +54,15 @@ export default (state: State): Organization => {
*/
export function getRealmManagedOrganization({ state }: { state: State }) {
let realmManagedOrg = 'organization';
if (state.getDeploymentType() === Constants.CLOUD_DEPLOYMENT_TYPE_KEY) {
if (
state.getDeploymentType() === Constants.CLOUD_DEPLOYMENT_TYPE_KEY ||
state.getUseRealmPrefixOnManagedObjects() === true
) {
realmManagedOrg = `${state.getRealm()}_organization`;
debugMessage({
message: `DeploymentType === cloud or UseRealmPrefixOnManagedObjects is true, returning '${realmManagedOrg}'`,
state: state,
});
}
return realmManagedOrg;
}
Expand Down
10 changes: 10 additions & 0 deletions src/shared/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export type State = {
getPassword(): string;
setRealm(realm: string): void;
getRealm(): string;
setUseRealmPrefixOnManagedObjects(useRealmPrefixOnManagedObjects: boolean): void;
getUseRealmPrefixOnManagedObjects(): boolean;
setDeploymentType(type: string): void;
getDeploymentType(): string;
setAdminClientId(type: string): void;
Expand Down Expand Up @@ -207,6 +209,13 @@ export default (initialState: StateInterface): State => {
return state.realm || process.env.FRODO_REALM;
},

setUseRealmPrefixOnManagedObjects(useRealmPrefixOnManagedObjects: boolean) {
state.useRealmPrefixOnManagedObjects = useRealmPrefixOnManagedObjects;
},
getUseRealmPrefixOnManagedObjects() {
return state.useRealmPrefixOnManagedObjects || false;
},

setDeploymentType(type: string) {
state.deploymentType = type;
},
Expand Down Expand Up @@ -500,6 +509,7 @@ export interface StateInterface {
username?: string;
password?: string;
realm?: string;
useRealmPrefixOnManagedObjects?: boolean;
deploymentType?: string;
adminClientId?: string;
adminClientRedirectUri?: string;
Expand Down
10 changes: 9 additions & 1 deletion src/utils/ForgeRockUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getRealms } from '../ops/RealmOps';
import Constants from '../shared/Constants';
import { State } from '../shared/State';
import { debugMessage } from '../utils/Console';

export type FRUtils = {
applyNameCollisionPolicy(name: string): string;
Expand Down Expand Up @@ -211,8 +212,15 @@ export function getCurrentRealmManagedUser({
state: State;
}): string {
let realmManagedUser = 'user';
if (state.getDeploymentType() === Constants.CLOUD_DEPLOYMENT_TYPE_KEY) {
if (
state.getDeploymentType() === Constants.CLOUD_DEPLOYMENT_TYPE_KEY ||
state.getUseRealmPrefixOnManagedObjects() === true
) {
realmManagedUser = `${getCurrentRealmName(state)}_user`;
debugMessage({
message: `DeploymentType === cloud or UseRealmPrefixOnManagedObjects is true, returning '${realmManagedUser}'`,
state: state,
});
}
return realmManagedUser;
}
Expand Down