-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(appmesh): Move Client Policy from Virtual Service to backend structure #12943
Changes from 1 commit
8472ea1
3a784bd
32aff99
29c3626
fa5f6c0
db3821e
1df6f67
8b327f0
9075284
3a9ea8e
1ee03f4
1c7143b
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,92 @@ | ||
|
||
import { CfnVirtualNode } from './appmesh.generated'; | ||
import { ClientPolicy } from './client-policy'; | ||
import { IVirtualService } from './virtual-service'; | ||
|
||
// keep this import separate from other imports to reduce chance for merge conflicts with v2-main | ||
// eslint-disable-next-line no-duplicate-imports, import/order | ||
import { Construct } from '@aws-cdk/core'; | ||
|
||
/** | ||
* Represents the properties needed to define backend defaults | ||
*/ | ||
export interface BackendDefaultsOptions { | ||
/** | ||
* Client policy for backend defaults | ||
* | ||
* @default none | ||
*/ | ||
readonly clientPolicy?: ClientPolicy; | ||
} | ||
|
||
/** | ||
* Represents the properties needed to define a backend | ||
*/ | ||
export interface BackendOptions { | ||
/** | ||
* The Virtual Service this backend points to | ||
*/ | ||
readonly virtualService: IVirtualService; | ||
/** | ||
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. There should be a newline between comments and previous variable 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 second this motion 🙂. |
||
* Client policy for a backend | ||
* | ||
* @default none | ||
*/ | ||
readonly clientPolicy?: ClientPolicy; | ||
} | ||
|
||
/** | ||
* Provides static factory methods to generate backend API structures | ||
*/ | ||
export class Backends { | ||
/** | ||
* Creates a backend defaults | ||
*/ | ||
public static backendDefaults(props: BackendDefaultsOptions): BackendDefaults { | ||
return new BackendDefaults(props.clientPolicy); | ||
} | ||
/** | ||
* Creates a named backend | ||
*/ | ||
public static backend(props: BackendOptions): Backend { | ||
return new Backend(props.virtualService, props.clientPolicy); | ||
} | ||
} | ||
|
||
/** | ||
* Represents all the backends that aren't specifically defined using the backend . | ||
*/ | ||
export class BackendDefaults { | ||
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 wonder if we could just make this an interface. I'm trying to think of a situation where we would need to enforce mutual exclusivity for this field and I'm not sure if we would need this. What do you think? 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. Not sure if I'm following. Do you mean both 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. Like, just defining BackendDefaults as an interface type interface BackendDefaults {
readonly clientPolicy?: ClientPolicy;
} and then instead of having to call new VirtualNode(stack, 'VirtualNode', {
...
backendDefaults: {
clientPolicy: appmesh.ClientPolicy.acm({ ... }),
}
); 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. My understanding is the 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. Yeah, I agree. It doesn't seem like the Maybe something like this is what we need? export interface BackendDefaults {
readonly clientPolicy?: ClientPolicy;
}
export interface Backend {
readonly clientPolicy?: ClientPolicy;
readonly virtualService: IVirtualService;
} 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 hesitate to remove to remove the 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. Fair enough. I defer to the expert(s) here 🙂. |
||
|
||
constructor (private readonly clientPolicy: ClientPolicy | undefined) {} | ||
|
||
/** | ||
* Return backend defaults config | ||
*/ | ||
public bind(_scope: Construct): CfnVirtualNode.BackendDefaultsProperty { | ||
return { | ||
clientPolicy: this.clientPolicy?.bind(_scope).clientPolicy, | ||
}; | ||
} | ||
} | ||
|
||
/** | ||
* Represents the backend that a virtual node will send outbound traffic to | ||
*/ | ||
export class Backend { | ||
|
||
constructor (private readonly virtualService: IVirtualService, | ||
private readonly clientPolicy: ClientPolicy | undefined) {} | ||
|
||
/** | ||
* Return backend config | ||
*/ | ||
public bind(_scope: Construct): CfnVirtualNode.BackendProperty { | ||
return { | ||
virtualService: { | ||
virtualServiceName: this.virtualService.virtualServiceName, | ||
clientPolicy: this.clientPolicy?.bind(_scope).clientPolicy, | ||
}, | ||
}; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,9 @@ | |
"dotnet": { | ||
"namespace": "Amazon.CDK.AWS.AppMesh", | ||
"packageId": "Amazon.CDK.AWS.AppMesh", | ||
"iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png" | ||
"iconUrl": "https://raw.githubusercontent.com/aws/aws-cdk/master/logo/default-256-dark.png", | ||
"signAssembly": true, | ||
"assemblyOriginatorKeyFile": "../../key.snk" | ||
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 got rid of this - if you merge from |
||
}, | ||
"java": { | ||
"package": "software.amazon.awscdk.services.appmesh", | ||
|
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.
Remove this line
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.
I second this motion 🙂.