Skip to content

Commit 7372b7b

Browse files
committed
lookup stored identity
1 parent 0b4d504 commit 7372b7b

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

src/services/GithubService.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,16 @@ export class GithubService {
110110
)})`,
111111
);
112112

113-
let storedIdentity: Identity | undefined;
114-
115-
if (stateLockRequest && stateLockRequest.identity) {
116-
const { pk, sk } = stateLockRequest.identity;
117-
118-
const identity = await this.identityModel.model.get(pk, sk);
119-
120-
if (identity) {
121-
storedIdentity = identity.attrs;
122-
}
123-
}
113+
const storedIdentity = await this.identityModel.model.get(
114+
IdentityModel.prefix('pk', tokenSha),
115+
IdentityModel.prefix('sk'),
116+
);
124117

125118
if (storedIdentity && stateLockRequest && stateLockRequest.Operation === 'OperationTypeApply') {
126119
// Terraform planfiles contain credentials from plan operations
127120
// Return the previously known identity from the plan operation
128121
console.log(`Found previously known identity (sha: ${tokenSha})`);
129-
return { ...storedIdentity, workspace: workspace || 'default' };
122+
return { ...storedIdentity.attrs, workspace: workspace || 'default' };
130123
}
131124

132125
const octokit = new Octokit({ auth });

0 commit comments

Comments
 (0)