Skip to content

Commit

Permalink
fix(cloud): update to use UUIDs (#3834)
Browse files Browse the repository at this point in the history
* fix(cloud): updated project response types to use id instead of uid

* fix(cloud): bumped to new version of api-types with string ids

---------

Co-authored-by: Emanuele Libralato <[email protected]>
  • Loading branch information
2 people authored and vvagaytsev committed Mar 15, 2023
1 parent 361381a commit 90c39a6
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"devDependencies": {
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@garden-io/platform-api-types": "1.367.0",
"@garden-io/platform-api-types": "1.455.0",
"@google-cloud/kms": "^2.11.1",
"@types/analytics-node": "^3.1.10",
"@types/async": "^3.2.18",
Expand Down
10 changes: 4 additions & 6 deletions core/src/cloud/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,13 @@ export interface RegisterSessionResponse {

// Represents a cloud environment
export interface CloudEnvironment {
id: number
id: string
name: string
}

// Represents a cloud project
export interface CloudProject {
id: number
uid: string
id: string
name: string
repositoryUrl: string
environments: CloudEnvironment[]
Expand All @@ -130,7 +129,6 @@ function toCloudProject(

return {
id: project.id,
uid: project.uid,
name: project.name,
repositoryUrl: project.repositoryUrl,
environments,
Expand Down Expand Up @@ -415,7 +413,7 @@ export class CloudApi {

// This is necessary to internally configure the project for this instance
this._project = project
this.projectId = project.uid
this.projectId = project.id

return project
}
Expand Down Expand Up @@ -650,7 +648,7 @@ export class CloudApi {
// NOTE: If we wan't to use this with multiple project IDs we need
// a cache supporting that + check if the remote project metadata
// was updated.
if (this._project && this._project.uid === this.projectId) {
if (this._project && this._project.id === this.projectId) {
return this._project
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/commands/cloud/groups/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { noApiMsg, applyFilter } from "../helpers"

// TODO: Add created at and updated at timestamps. Need to add it to the API response first.
interface Groups {
id: number
id: string
name: string
description: string
defaultAdminGroup: boolean
Expand Down
10 changes: 5 additions & 5 deletions core/src/commands/cloud/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,29 @@ export interface ApiCommandError {
}

export interface SecretResult {
id: number
id: string
createdAt: string
updatedAt: string
name: string
environment?: {
name: string
id: number
id: string
}
user?: {
name: string
id: number
id: string
vcsUsername: string
}
}

export interface UserResult {
id: number
id: string
createdAt: string
updatedAt: string
name: string
vcsUsername: string | null | undefined
groups: {
id: number
id: string
name: string
}[]
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/commands/cloud/secrets/secrets-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class SecretsCreateCommand extends Command<Args, Opts> {
)
}

let environmentId: number | undefined
let environmentId: string | undefined

if (envName) {
const environment = project.environments.find((e) => e.name === envName)
Expand Down
2 changes: 1 addition & 1 deletion core/src/commands/cloud/users/users-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class UsersCreateCommand extends Command<Args, Opts> {
}

async action({ garden, log, opts, args }: CommandParams<Args, Opts>): Promise<CommandResult<UserResult[]>> {
const addToGroups = (opts["add-to-groups"] || []).map((groupId) => parseInt(groupId, 10))
const addToGroups: string[] = opts["add-to-groups"] || []
const fromFile = opts["from-file"] as string | undefined
let users: StringMap

Expand Down
4 changes: 2 additions & 2 deletions core/test/unit/src/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ class FakeCloudApi extends CloudApi {
}
async getProfile() {
return {
id: 1,
id: "1",
createdAt: new Date().toString(),
updatedAt: new Date().toString(),
name: "gordon",
vcsUsername: "[email protected]",
serviceAccount: false,
organization: {
id: 1,
id: "1",
name: "garden",
},
cachedPermissions: {},
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock

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

0 comments on commit 90c39a6

Please sign in to comment.