Skip to content

Conversation

@SayakMukhopadhyay
Copy link

@SayakMukhopadhyay SayakMukhopadhyay commented May 11, 2024

This PR has been moved here from pulumi/pulumi-yaml#576 based on the discussion on this comment.

OP:
Some providers outputs unix timestamps and some other RFC 3339 where some providers input unix and others RFC 3339 and I need to convert between the 2 formats when passing outputs to inputs. I am using YAML only as I want to keep using declarative syntax. Hence, based on the discussion I had in the community slack (ref: https://pulumi-community.slack.com/archives/C037PV12W6L/p1715335945150989) with @t0yv0 .

Please note that for now, I have only implemented one of the 2 functions I want to implement to check with you folks if I am going in the right direction.

I have implemented both the functions.

@github-actions
Copy link

PR is now waiting for a maintainer to take action.

Note for the maintainer: Commands available:

  • /run-acceptance-tests - used to test run the acceptance tests for the project

@SayakMukhopadhyay SayakMukhopadhyay marked this pull request as draft May 11, 2024 11:57
@github-actions
Copy link

PR is now waiting for a maintainer to take action.

Note for the maintainer: Commands available:

  • /run-acceptance-tests - used to test run the acceptance tests for the project

"github.com/pulumi/pulumi-go-provider/infer"
)

type Rfc3339tounix struct{}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
type Rfc3339tounix struct{}
type Rfc3339ToUnix struct{}

CamelCase all the names

Copy link
Author

Choose a reason for hiding this comment

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

Other functions are also using the sentence case like

type Base64decode struct{}

type Cidrnetmask struct{}

type Filebase64sha256 struct{}

and others, hence I used that casing here. I also tried naming RFC3999ToUnix and that resulted in some tokens being rfC3999ToUnix which is weird.

@github-actions
Copy link

PR is now waiting for a maintainer to take action.

Note for the maintainer: Commands available:

  • /run-acceptance-tests - used to test run the acceptance tests for the project

@SayakMukhopadhyay
Copy link
Author

SayakMukhopadhyay commented May 12, 2024

@Frassle , I am in a bit of a dilemma regarding the seconds precision that I should allow in these functions. RFC3999 allows fractional seconds but Unix time itself is seconds precision. It is possible to have millisecond, microsecond or nanosecond precision Unix time but that means I will have to ensure that the user inputs the precision I am asking, even adding 0's at the end if their unix time is only in seconds.

I am torn between allowing more than seconds precision as a lot of systems support millisecond unix time and I have seen a lot of RFC3999 times with millisecond fractions. But then, why stick at millisecond when modern systems can handle up to nanoseconds.

I fact, I can see even more issues. Imagine my functions only allow nanoseconds as UNIX input and output. If another resource outputs or needs an input of the time in milliseconds, I will need to do a math conversion, which I don't know if its possible in YAML. Even if it's possible, it creates a dangerous point of failure as if the other resource suddenly changes its schema to seconds instead of milliseconds, my mathematical operation can point to a totally different instance in time.

Or I can just keep things to spec and only handle unix seconds...

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.

2 participants