-
Notifications
You must be signed in to change notification settings - Fork 14
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
Windows settings time #109
base: main
Are you sure you want to change the base?
Conversation
@ryfu-msft And this one. There is still an issue that I have opened at PSDesiredStateConfiguration. |
resources/Microsoft.Windows.Setting.Time/Microsoft.Windows.Setting.Time.psm1
Outdated
Show resolved
Hide resolved
# Timezone values are taken from the list of timezones (Get-TimeZone -ListAvailable).Id | ||
# TODO: Track issue 125 on PSDesiredStateConfiguration repository to add a ValidateSet for time zones | ||
[DscProperty(Key)] | ||
# [ValidateSet( |
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.
Should probably be a validate script; Ref your linked issue - PowerShell/PSDesiredStateConfiguration#125 (comment)
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.
The only thing that I can think of, is create a enum without the spaces, and add another helper function to translate it. Might be a bit overkill, so I'm curious what the PS team is going to mention.
resources/Microsoft.Windows.Setting.Time/Microsoft.Windows.Setting.Time.psm1
Outdated
Show resolved
Hide resolved
resources/Microsoft.Windows.Setting.Time/Microsoft.Windows.Setting.Time.psm1
Outdated
Show resolved
Hide resolved
resources/Microsoft.Windows.Setting.Time/Microsoft.Windows.Setting.Time.psm1
Outdated
Show resolved
Hide resolved
resources/Microsoft.Windows.Setting.Time/Microsoft.Windows.Setting.Time.psm1
Outdated
Show resolved
Hide resolved
resources/Microsoft.Windows.Setting.Time/Microsoft.Windows.Setting.Time.psm1
Outdated
Show resolved
Hide resolved
AliasesToExport = '*' | ||
|
||
# DSC resources to export from this module | ||
DscResourcesToExport = @('Time') |
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.
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'll put it on #100
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.
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 would implement it as a single AdditionalClock
resource, which has Properties of Ensure
, TimeZone
, DisplayName
.
For Get
-
- Fetch the values in
1
- Compare against properties
- If the properties match, set ensure present and return the current state
- If the properties don't match, fetch the values in
2
- Compare against properties
- If the properties match, set ensure present; otherwise, set ensure absent
- Return the current state
For Test
-
- Run
Get
- Compare
Ensure
of the current state toEnsure
of the desired state - Return result of comparison
For Set
it's a bit more complicated, I'd imagine you'd first want to determine if either 1
or 2
had a matching DisplayName
, if it does, set the values for that clock. If no display names match, check if either timezone matches, if it does, set the values for that clock. If neither are a match, put it in slot 1 if the enable property of the slot is not set. If slot 1 is already enabled, put it in slot 2 if the enable property of the slot is not set. If slot 2 is already enabled, throw an error that the maximum number of additional clocks have been set.
Alternatively, you could just add a parameter for Id
and restrict it to being 1
or 2
and have it be mandatory for Set
operations but optional for Get
and Test
. That's honestly probably the better option
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.
Thanks for the details. One small question, how will users be able to specify both 1 and 2 in a single configuration document?
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.
They call the resource twice - once for setting slot one, and a second time for setting slot two
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 lack the knowledge on this part. Either clock 1 or clock 2 can be turned on, or both. Shouldn't the user be able to say something like: AdditionalClock1Settings
and AdditionaClock2Settings
?
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.
No need; They can confugure like:
- resource: Microsoft.Windows.Setting.Time/AdditionalClock
directives:
description: Set clock 1
allowPrerelease: true
settings:
Slot: 1
DisplayName: UTC
Timezone: UTC
Ensure: Present
- resource: Microsoft.Windows.Setting.Time/AdditionalClock
directives:
description: Set clock 2
allowPrerelease: true
settings:
Slot: 2
DisplayName: Current time in Redmond
Timezone: Pacific Standard Time
Ensure: Present
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.
Ah cool. I'll pick it up after this is merged!
resources/Microsoft.Windows.Setting.Time/Microsoft.Windows.Setting.Time.psd1
Outdated
Show resolved
Hide resolved
resources/Microsoft.Windows.Setting.Time/Microsoft.Windows.Setting.Time.psm1
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
resources/Microsoft.Windows.Setting.Time/Microsoft.Windows.Setting.Time.psm1
Outdated
Show resolved
Hide resolved
#endRegion Functions | ||
|
||
#region Enums | ||
enum TimeZoneTable { |
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.
This enum seems like overkill. I would just let the time zone id be used directly as a string parameter instead of creating this enum.
resources/Microsoft.Windows.Setting.Time/Microsoft.Windows.Setting.Time.psm1
Outdated
Show resolved
Hide resolved
class Time { | ||
# TODO: Track issue 125 on PSDesiredStateConfiguration repository to add a ValidateSet for time zones | ||
[DscProperty(Key)] | ||
[TimeZoneTable] $TimeZone = ((Get-TimeZone).Id -replace '[\+\s\-\(\)\.]', '') |
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.
[TimeZoneTable] $TimeZone = ((Get-TimeZone).Id -replace '[\+\s\-\(\)\.]', '') | |
[string] $TimeZoneId |
resources/Microsoft.Windows.Setting.Time/Microsoft.Windows.Setting.Time.psm1
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I forgot to add the daylight saving option. Should be good to go now. |
…ndows-setting-time
@ryfu-msft And the same for this one :) |
Addresses issue #34 and #100