Skip to content
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

Allow built-in reason to be replaced easily from assertion helper #354

Closed
BernieWhite opened this issue Dec 11, 2019 · 0 comments · Fixed by #355
Closed

Allow built-in reason to be replaced easily from assertion helper #354

BernieWhite opened this issue Dec 11, 2019 · 0 comments · Fixed by #355
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@BernieWhite
Copy link
Member

Currently to add a custom reason using assertion helper methods an implementation might look like this.

# Synopsis: AKS agent pools should run the same Kubernetes version as the cluster
Rule 'Azure.AKS.PoolVersion' {
    $clusterVersion = $TargetObject.Properties.kubernetesVersion
    foreach ($pool in $TargetObject.Properties.agentPoolProfiles) {
        $result = $Assert.HasDefaultValue($pool, 'orchestratorVersion', $clusterVersion);
        $result.AddReason(($LocalizedData.AKSNodePoolVersion -f $pool.name, $pool.orchestratorVersion));
        $result;
    }
}

This can be simplified with a fluent method like:

# Synopsis: AKS agent pools should run the same Kubernetes version as the cluster
Rule 'Azure.AKS.PoolVersion' {
    $clusterVersion = $TargetObject.Properties.kubernetesVersion
    foreach ($pool in $TargetObject.Properties.agentPoolProfiles) {
        $Assert.
            HasDefaultValue($pool, 'orchestratorVersion', $clusterVersion).
            WithReason(($LocalizedData.AKSNodePoolVersion -f $pool.name, $pool.orchestratorVersion));
    }
}

Additionally replacement of reasons is more involved.

@BernieWhite BernieWhite added the enhancement New feature or request label Dec 11, 2019
@BernieWhite BernieWhite added this to the v0.13.0 milestone Dec 11, 2019
@BernieWhite BernieWhite self-assigned this Dec 11, 2019
@BernieWhite BernieWhite mentioned this issue Jan 5, 2020
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant