-
Notifications
You must be signed in to change notification settings - Fork 148
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
Added support for sidecaraddons API #7934
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
export interface AddOnConfig { | ||
addOnAttributes: AddOnAttribute[]; | ||
sidecarImages: SidecarImage[]; | ||
} | ||
|
||
export interface AddOnAttribute { | ||
displayText: string; | ||
id: string; | ||
type: string; | ||
isRequired: boolean; | ||
} | ||
|
||
export interface SidecarImage { | ||
releaseChannel: string; | ||
displayText: string; | ||
value: string; | ||
isEarlyAccess: boolean; | ||
deprecated: boolean; | ||
supportedLinuxFxVersions: string[]; | ||
sitecontainerMetadata: SitecontainerMetadata; | ||
} | ||
|
||
export interface SitecontainerMetadata { | ||
appSettingMappings: AppSettingMapping[]; | ||
volumeMappings: VolumeMapping[]; | ||
port: any; | ||
startUpCommand: any; | ||
} | ||
|
||
export interface AppSettingMapping { | ||
appSettingName: string; | ||
environmentVariableName: any; | ||
} | ||
|
||
export interface VolumeMapping { | ||
volumeSubPath: any; | ||
containerMountPath: any; | ||
readOnly: boolean; | ||
} | ||
|
||
export interface SidecarAddOn { | ||
id: string; | ||
displayText: string; | ||
organization: string; | ||
legalInformation: string; | ||
value: string; | ||
supportedOs: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For type-safety, you can limit which string values are possible like so: supportedOs: "Linux" | "Windows"; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add Os and any other limited sets of values (like supportedFeatures?) as enums. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fine too though if you did use an enum, make sure it's a string-based enum and not a regular number-based one. There isn't too much of a difference between a type definition and a string-based enum. The compiler is going to help you with type-safety regardless. If you're doing a lot of values then sure, an enum is probably the better way to go for sure. |
||
supportedFeatures: string[]; | ||
additionalInformation: string; | ||
addOnConfig: AddOnConfig; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { SidecarAddOn } from '../models/SidecarAddOnModel'; | ||
import { redisSidecarAddOn } from '../sidecaraddons/redis'; | ||
|
||
@Injectable() | ||
export class SidecarAddOnService { | ||
getSidecarAddOns(): SidecarAddOn[] { | ||
const redisSidecarAddOnCopy = JSON.parse(JSON.stringify(redisSidecarAddOn)); | ||
|
||
let sidecarAddOns: SidecarAddOn[] = [redisSidecarAddOnCopy]; | ||
|
||
return sidecarAddOns; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Controller, Query, Post, Get } from '@nestjs/common'; | ||
import { SidecarAddOnService } from './service/SidecarAddOnService'; | ||
|
||
@Controller('sidecaraddons') | ||
export class SidecarAddOnsController { | ||
constructor(private _sidecarAddOnService: SidecarAddOnService) {} | ||
|
||
@Get('') | ||
sideCarAddOns(@Query('api-version') apiVersion: string) { | ||
return this._sidecarAddOnService.getSidecarAddOns(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { SharedModule } from '../shared/shared.module'; | ||
import { SidecarAddOnsController } from './sidecaraddons.controller'; | ||
import { SidecarAddOnService } from './service/SidecarAddOnService'; | ||
|
||
@Module({ | ||
imports: [SharedModule], | ||
controllers: [SidecarAddOnsController], | ||
providers: [SidecarAddOnService], | ||
}) | ||
export class SidecarAddOnsModule {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { SidecarAddOn } from '../models/SidecarAddOnModel'; | ||
|
||
const getRedisSidecarAddOn: () => SidecarAddOn = () => { | ||
return { | ||
id: 'redis', | ||
displayText: '<ADD_ON_NAME_DISPLAY_TEXT_DESCRIPTION>', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll have to look into a way to localize strings on our server |
||
organization: 'redis', | ||
legalInformation: '<ADD_ON_LEGAL_INFORMATION>', | ||
value: 'redis', | ||
supportedOs: 'Linux', | ||
supportedFeatures: ['LOGS', 'TRACES'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is supportedFeatures a limited set of possible values? Or could it be anything that's unpredictable? |
||
additionalInformation: '<Any Extra information for Addon>', | ||
addOnConfig: { | ||
addOnAttributes: [ | ||
{ | ||
displayText: '<ADD_ON_ATTRIBUTE_DISPLAY_TEXT>', | ||
id: '<ADD_ON_ATTRIBUTE_ID>', | ||
type: '<WELL-DEFINED-TYPE>', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you give an example of a "well-defined-type"? |
||
isRequired: true, | ||
}, | ||
], | ||
sidecarImages: [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since sidecarImages is an array, I assume this means that when I install an add-on, I may need to configure multiple containers at the same time? @yoonaoh do our mocks handle that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The mocks don't handle adding multiple containers at one time. I thought the array was meant to store multiple versions of the same image and that we would most likely configure with the latest image. |
||
{ | ||
releaseChannel: 'Latest', | ||
displayText: '<VENDOR_IMAGE_1>', | ||
value: '<IMAGE_PATH>', | ||
isEarlyAccess: true, | ||
deprecated: false, | ||
supportedLinuxFxVersions: ['DOTNETCORE|*', 'PYTHON|*'], | ||
sitecontainerMetadata: { | ||
appSettingMappings: [ | ||
{ | ||
appSettingName: '<ADD_ON_ATTRIBUTE_ID>', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if I understand correctly, appSettingName is just a reference to an existing app setting that's defined on the site itself yes? If so, is the UX supposed to add those app setting values to the site when adding the add-on? And if that's true, how do we know what value to set for the app setting? |
||
environmentVariableName: null, | ||
}, | ||
], | ||
volumeMappings: [ | ||
{ | ||
volumeSubPath: null, | ||
containerMountPath: null, | ||
readOnly: false, | ||
}, | ||
], | ||
port: null, | ||
startUpCommand: null, | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
}; | ||
|
||
export const redisSidecarAddOn: SidecarAddOn = getRedisSidecarAddOn(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of returning the result of getRedisSidecarAddOn(), you can just export getRedisSidecarAddon the function. That way you wouldn't need to do a deep copy of the result in the SidecarAddOnService.ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should never be using "any" as a type. I'm guessing this should be "number"? Same comment for all the other instances of "any" below.