Skip to content

Commit

Permalink
Cluster: update version message
Browse files Browse the repository at this point in the history
  • Loading branch information
fwang committed Sep 18, 2024
1 parent 2ab601e commit 331445d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion platform/src/components/aws/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,11 @@ export class Cluster extends Component {
opts?: ComponentResourceOptions,
) {
const _version = 2;
super(__pulumiType, name, args, opts, _version);
const _breakingChange = [
`The new version of "sst.aws.Cluster" deploys services in the public subnets by default, and does not require VPC to have NAT gateways.`,
`Where previously in "sst.aws.Cluster.v1" it would deploy the services in the private subnets.`,
].join(" ");
super(__pulumiType, name, args, opts, { _version, _breakingChange });

const parent = this;

Expand Down
2 changes: 1 addition & 1 deletion platform/src/components/aws/vpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class Vpc extends Component implements Link.Linkable {

constructor(name: string, args?: VpcArgs, opts?: ComponentResourceOptions) {
const _version = 2;
super(__pulumiType, name, args, opts, _version);
super(__pulumiType, name, args, opts, { _version });

if (args && "ref" in args) {
const ref = args as VpcRef;
Expand Down
10 changes: 8 additions & 2 deletions platform/src/components/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export class Component extends ComponentResource {
name: string,
args?: Inputs,
opts?: ComponentResourceOptions,
_version: number = 1,
_versionInfo: {
_version: number;
_breakingChange?: string;
} = { _version: 1 },
) {
const transforms = ComponentTransforms.get(type) ?? [];
for (const transform of transforms) {
Expand Down Expand Up @@ -331,13 +334,16 @@ export class Component extends ComponentResource {

// Check component version
const oldVersion = $cli.state.version[name];
const newVersion = _version;
const newVersion = _versionInfo._version;
if (oldVersion) {
const className = type.replaceAll(":", ".");
if (oldVersion < newVersion) {
throw new VisibleError(
[
`There is a new version of "${className}" that has breaking changes.`,
...(_versionInfo._breakingChange
? [_versionInfo._breakingChange]
: []),
`To continue using the previous version, rename "${className}" to "${className}.v${oldVersion}".`,
`Or recreate this component to update - https://ion.sst.dev/docs/components/#versioning`,
].join(" "),
Expand Down

0 comments on commit 331445d

Please sign in to comment.