Skip to content

Commit d408cb0

Browse files
committed
fix: address feedbacks
1 parent 02b8f57 commit d408cb0

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

packages/credential-provider-ini/src/index.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,8 +853,8 @@ credential_source = ${credentialSource}
853853
});
854854
return expect(async () => await provider()).rejects.toMatchObject({
855855
message:
856-
`Unsupported credential source in profile default. Got ${someProvider}, expect EcsContainer or ` +
857-
`Ec2InstanceMetadata or Environment`,
856+
`Unsupported credential source in profile default. Got ${someProvider}, expected EcsContainer or ` +
857+
`Ec2InstanceMetadata or Environment.`,
858858
});
859859
});
860860

packages/credential-provider-ini/src/index.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,19 @@ interface AssumeRoleWithProviderProfile extends Profile {
128128
credential_source: string;
129129
}
130130

131-
const isAssumeRoleWithSourceProfile = (arg: any): arg is AssumeRoleWithSourceProfile =>
131+
const isAssumeRoleProfile = (arg: any) =>
132132
Boolean(arg) &&
133133
typeof arg === "object" &&
134134
typeof arg.role_arn === "string" &&
135-
typeof arg.source_profile === "string" &&
136-
typeof arg.credential_source === "undefined" &&
137135
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 &&
138136
["undefined", "string"].indexOf(typeof arg.external_id) > -1 &&
139137
["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1;
140138

139+
const isAssumeRoleWithSourceProfile = (arg: any): arg is AssumeRoleWithSourceProfile =>
140+
isAssumeRoleProfile(arg) && typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
141+
141142
const isAssumeRoleWithProviderProfile = (arg: any): arg is AssumeRoleWithProviderProfile =>
142-
Boolean(arg) &&
143-
typeof arg === "object" &&
144-
typeof arg.role_arn === "string" &&
145-
typeof arg.credential_source === "string" &&
146-
typeof arg.source_profile === "undefined" &&
147-
["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 &&
148-
["undefined", "string"].indexOf(typeof arg.external_id) > -1 &&
149-
["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1;
143+
isAssumeRoleProfile(arg) && typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
150144

151145
/**
152146
* Creates a credential provider that will read from ini files and supports
@@ -282,7 +276,7 @@ const resolveCredentialSource = (credentialSource: string, profileName: string):
282276
} else {
283277
throw new ProviderError(
284278
`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, ` +
285-
`expect EcsContainer or Ec2InstanceMetadata or Environment`
279+
`expected EcsContainer or Ec2InstanceMetadata or Environment.`
286280
);
287281
}
288282
};

0 commit comments

Comments
 (0)