Skip to content
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

refactor(redis-v5): Moving command 'redis:credentials' to CLI #2712

Merged
merged 4 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Rebased onto prerelease branch and resolved conflicts.
  • Loading branch information
sbosio committed Mar 15, 2024
commit 547534cd6b6ff97df3e2637fb4f26f5ac7af3ac2
2 changes: 1 addition & 1 deletion packages/cli/src/commands/redis/credentials.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Command, flags} from '@heroku-cli/command'
import {Args, ux} from '@oclif/core'
import redisApi, {RedisFormationResponse} from '../../lib/redis/info'
import redisApi, {RedisFormationResponse} from '../../lib/redis/api'

export default class Credentials extends Command {
static topic = 'redis'
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/redis/maxmemory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class MaxMemory extends Command {
const addon = await redisApi(app, database, false, this.heroku).getRedisAddon()

const {body: config} = await redisApi(app, database, false, this.heroku)
.request<RedisFormationConfigResponse>(`/redis/v0/databases/${addon.name}/config`, 'patch', {maxmemory_policy: policy})
.request<RedisFormationConfigResponse>(`/redis/v0/databases/${addon.name}/config`, 'PATCH', {maxmemory_policy: policy})
const configVars = addon.config_vars || []
ux.log(`Maxmemory policy for ${addon.name} (${configVars.join(', ')}) set to ${config.maxmemory_policy.value}.`)
ux.log(`${config.maxmemory_policy.value} ${config.maxmemory_policy.values[config.maxmemory_policy.value]}.`)
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/lib/redis/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ export type RedisFormationConfigResponse = {
},
}

type HttpVerb = 'GET' | 'POST' | 'PATCH' | 'DELETE'

export default (app: string, database: string | undefined, json: boolean, heroku: APIClient) => {
const HOST = process.env.HEROKU_REDIS_HOST || 'api.data.heroku.com'
const ADDON = process.env.HEROKU_REDIS_ADDON_NAME || 'heroku-redis'

return {
request<T>(path: string, method: 'GET' | 'POST' = 'GET', body = {}) {
request<T>(path: string, method: HttpVerb = 'GET', body = {}) {
const headers = {Accept: 'application/json'}
if (process.env.HEROKU_HEADERS) {
Object.assign(headers, JSON.parse(process.env.HEROKU_HEADERS))
Expand Down
Loading