-
Notifications
You must be signed in to change notification settings - Fork 10
feat: Rewrite using the new Framework instead of the old SDKv2. #45
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
Conversation
} | ||
|
||
// mapStringFromTypesMap converts a types.Map to map[string]string for template handling. | ||
func mapStringFromTypesMap(m types.Map) map[string]string { |
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 this be in a helper/util file?
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.
Moved this to the existing common.go
file.
alertmanagerConfig := plan.ConfigYAML.ValueString() | ||
templates := mapStringFromTypesMap(plan.TemplatesConfigYAML) | ||
|
||
err := cli.CreateAlertmanagerConfig(ctx, alertmanagerConfig, templates) |
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.
err := cli.CreateAlertmanagerConfig(ctx, alertmanagerConfig, templates) | |
err := r.client.CreateAlertmanagerConfig(ctx, alertmanagerConfig, templates) |
|
||
state.ConfigYAML = types.StringValue(alertmanagerConfig) | ||
|
||
// Convert templates map[string]string to types.Map |
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.
question: why not using mapStringFromTypesMap
here?
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.
it is the opposite, we have a map of string and we want a Terraform types.Map value.
Added a new dedicated function typeMapFromMapString
.
alertmanagerConfig := plan.ConfigYAML.ValueString() | ||
templates := mapStringFromTypesMap(plan.TemplatesConfigYAML) | ||
|
||
err := client.CreateAlertmanagerConfig(ctx, alertmanagerConfig, templates) |
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.
err := client.CreateAlertmanagerConfig(ctx, alertmanagerConfig, templates) | |
err := r.client.CreateAlertmanagerConfig(ctx, alertmanagerConfig, templates) |
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.
done, thanks.
Signed-off-by: Ludovic Terrier <[email protected]>
Changes
The
config_yaml
now contains the exact value submitted by the user. Additionally, a new attribute,remote_config_yaml
, has been introduced to reflect the configuration as stored in the backend.Here the
alerts/node-exporter.yaml
used for this demo:With the rewrite: