Skip to content

fix(tags): change map types used in all tags to pulumi.Inputs of the map#157

Merged
metral merged 2 commits into
masterfrom
metral/fix-tags-map-type
Jun 12, 2019
Merged

fix(tags): change map types used in all tags to pulumi.Inputs of the map#157
metral merged 2 commits into
masterfrom
metral/fix-tags-map-type

Conversation

@metral

@metral metral commented Jun 11, 2019

Copy link
Copy Markdown
Contributor

Fixes #146.

As showcased in the update examples/tags/index.ts, one can now supply pulumi.Inputs of the map types expected for the various resource tags. For example:

...
autoScalingGroupTags: cluster1.core.cluster.name.apply(clusterName => ({
    "myAutoScalingGroupTag1": "true",
    "myOtherAutoScalingGroupTag2": clusterName,
    [`k8s.io/cluster-autoscaler/${clusterName}`]: "true",
    "k8s.io/cluster-autoscaler/enabled": "true",
}));

@metral metral force-pushed the metral/fix-tags-map-type branch from fd1dd79 to 6b7e908 Compare June 11, 2019 07:38
@metral metral added this to the 0.24 milestone Jun 11, 2019
@metral metral added the bug label Jun 11, 2019
@metral metral self-assigned this Jun 11, 2019
@metral metral removed the bug label Jun 11, 2019
Comment thread nodejs/eks/nodegroup.ts
Comment thread nodejs/eks/nodegroup.ts Outdated
* The tags to apply to the CloudFormation Stack of the Worker NodeGroup.
*/
cloudFormationTags?: { [key: string]: string };
cloudFormationTags?: pulumi.Input<{ [key: string]: string }>;

@lukehoban lukehoban Jun 11, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect (but am not sure) that the usage of cloudFormationTags needs to change to support this new type.

At least the usage as written currently is highly misleading, as it does an untyped cast into a type that is no longer guaranteed to be correct.

It’s possible that it still just works because of how things get serialized before passing to the resource provider - but it might make sense to fix up the types to be correct as well.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW - I expect this is true for several of the other tag properties that have changed in this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved using Pat's suggestion below

Comment thread nodejs/eks/cluster.ts Outdated
Comment thread nodejs/eks/examples/tags/index.ts Outdated
@metral metral force-pushed the metral/fix-tags-map-type branch from 6b7e908 to 3e8efc6 Compare June 11, 2019 18:37
@metral

metral commented Jun 11, 2019

Copy link
Copy Markdown
Contributor Author

@pgavlin Feedback has been addressed. PTAL

Comment thread nodejs/eks/nodegroup.ts Outdated
@metral metral force-pushed the metral/fix-tags-map-type branch 3 times, most recently from 12ad814 to 6ac3257 Compare June 11, 2019 19:27

@lukehoban lukehoban left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved using Pat's suggestion below

I don't see any code that addresses the concern I was raising.

Code like this is no longer type-correct after this change. The ... throws away type information which hides the type mismatch, but args.nodeSecurityGroupTags is not assignable to aws.Tags. It's possible this doesn't matter, and that tags: itself allows the more general thing. But even then, the ..args.nodeSecurityGroupTags won't work as you can't splat through an Input<X>. This would need some sort of apply or Input<obj> merge function.

tags: <aws.Tags>{...args.tags, ...args.nodeSecurityGroupTags},

Comment thread nodejs/eks/cluster.ts Outdated
Comment thread nodejs/eks/nodegroup.ts Outdated
@lukehoban

Copy link
Copy Markdown
Contributor

Code like this is no longer type-correct after this change.

Relatedly - it would help to have test coverage of some of the other kinds of tags that are being changed here - since they are consumed in a quite different way.

@metral

metral commented Jun 11, 2019

Copy link
Copy Markdown
Contributor Author

Relatedly - it would help to have test coverage of some of the other kinds of tags that are being changed here - since they are consumed in a quite different way.

All the tags available are being tested in our tags example - do you see something missing that we are not testing?

@lukehoban

Copy link
Copy Markdown
Contributor

All the tags available are being tested in our tags example - do you see something missing that we are not testing?

I don't see any cases that pass Output<{[key:string]: string}> or { [key: string]: Output<string>}. I expect those two cases will not work correctly.

@metral metral force-pushed the metral/fix-tags-map-type branch 6 times, most recently from e9754d6 to 1129d99 Compare June 12, 2019 17:03
@metral

metral commented Jun 12, 2019

Copy link
Copy Markdown
Contributor Author

@lukehoban @pgavlin Feedback has been addressed, and a new test example/tests/tag-input-types has been added to test all variations of the pulumi.Input types for the tags:

  • pulumi.Input<{ [key: string]: string }>
  • { [key:string]: pulumi.Input<string> }
  • pulumi.Input<{ [key: string]: pulumi.Input<string> }

PTAL

@lukehoban lukehoban left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread nodejs/eks/index.ts
@metral metral force-pushed the metral/fix-tags-map-type branch from 1129d99 to 59ba355 Compare June 12, 2019 18:48
@metral metral force-pushed the metral/fix-tags-map-type branch from 59ba355 to da2c741 Compare June 12, 2019 19:27
@metral metral force-pushed the metral/fix-tags-map-type branch from da2c741 to 11e5bc6 Compare June 12, 2019 20:07
@metral metral merged commit 01fb1da into master Jun 12, 2019
@pulumi-bot pulumi-bot deleted the metral/fix-tags-map-type branch June 12, 2019 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Malformed YAML with autoscalingGroupTags

4 participants