Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

resolve variables #264

Merged
merged 1 commit into from Oct 3, 2019
Merged

resolve variables #264

merged 1 commit into from Oct 3, 2019

Conversation

fibonacci1729
Copy link
Collaborator

resolves: #70

@hongchaodeng
Copy link
Member

Hi @fibonacci1729 , can you take a look and reply my comment at #70 (comment)

Thanks!

Copy link
Contributor

@technosophos technosophos left a comment

Choose a reason for hiding this comment

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

LGTM. And I learned a few things reading this PR!

use regex::Regex;

fn parse_from_variable(input: String) -> Option<String> {
lazy_static! {
Copy link
Contributor

Choose a reason for hiding this comment

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

On lazy_static!, where have you been all my life?

.collect()
}

// TODO: variables are unique per config should redefinition should be an error.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think dedup can be done silently. I don't think an error is necessary.

if let serde_json::Value::String(s) = value {
if let Some(ref var) = parse_from_variable(s.clone()) {
param.value = vars.get(var).map(|var| var.clone());
ensure!(param.value.is_some(), format!(
Copy link
Contributor

Choose a reason for hiding this comment

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

Ooo... I didn't know about ensure! either!

@fibonacci1729 fibonacci1729 merged commit f662f60 into oam-dev:master Oct 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the [variable(NAME)] function in YAML for ApplicationConfigurations
3 participants