Skip to content

Commit 4426cfe

Browse files
feat: add token field
1 parent 380d526 commit 4426cfe

4 files changed

Lines changed: 44 additions & 25 deletions

File tree

agent-control/agent-type-registry/newrelic/com.newrelic.infrastructure-0.1.0.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ variables:
5858
required: false
5959
default: ""
6060
bearer:
61-
description: "Bearer token for authentication"
62-
type: string
63-
required: false
64-
default: ""
61+
token:
62+
description: "Bearer token for authentication"
63+
type: string
64+
required: false
65+
default: ""
6566
version:
6667
description: "Agent version"
6768
type: string
@@ -127,10 +128,11 @@ variables:
127128
required: false
128129
default: ""
129130
bearer:
130-
description: "Bearer token for authentication"
131-
type: string
132-
required: false
133-
default: ""
131+
token:
132+
description: "Bearer token for authentication"
133+
type: string
134+
required: false
135+
default: ""
134136
version:
135137
description: "Agent version"
136138
type: string
@@ -224,7 +226,8 @@ deployment:
224226
basic:
225227
username: ${nr-var:oci.auth.basic.username}
226228
password: ${nr-var:oci.auth.basic.password}
227-
bearer: ${nr-var:oci.auth.bearer}
229+
bearer:
230+
token: ${nr-var:oci.auth.bearer.token}
228231
version:
229232
path: ${nr-sub:packages.infra-agent.dir}\\newrelic-infra.exe
230233
args:
@@ -299,7 +302,8 @@ deployment:
299302
basic:
300303
username: ${nr-var:oci.auth.basic.username}
301304
password: ${nr-var:oci.auth.basic.password}
302-
bearer: ${nr-var:oci.auth.bearer}
305+
bearer:
306+
token: ${nr-var:oci.auth.bearer.token}
303307
version:
304308
path: ${nr-sub:packages.infra-agent.dir}/newrelic-infra
305309
args:

agent-control/agent-type-registry/newrelic/com.newrelic.opentelemetry.collector-0.1.0.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ variables:
6262
required: false
6363
default: ""
6464
bearer:
65-
description: "Bearer token for authentication"
66-
type: string
67-
required: false
68-
default: ""
65+
token:
66+
description: "Bearer token for authentication"
67+
type: string
68+
required: false
69+
default: ""
6970
version:
7071
description: "Agent version"
7172
type: string
@@ -125,10 +126,11 @@ variables:
125126
required: false
126127
default: ""
127128
bearer:
128-
description: "Bearer token for authentication"
129-
type: string
130-
required: false
131-
default: ""
129+
token:
130+
description: "Bearer token for authentication"
131+
type: string
132+
required: false
133+
default: ""
132134
version:
133135
description: "Agent version"
134136
type: string
@@ -195,7 +197,8 @@ deployment:
195197
basic:
196198
username: ${nr-var:oci.auth.basic.username}
197199
password: ${nr-var:oci.auth.basic.password}
198-
bearer: ${nr-var:oci.auth.bearer}
200+
bearer:
201+
token: ${nr-var:oci.auth.bearer.token}
199202
version:
200203
path: ${nr-sub:packages.nrdot.dir}\\nrdot-collector.exe
201204
args:
@@ -233,7 +236,8 @@ deployment:
233236
basic:
234237
username: ${nr-var:oci.auth.basic.username}
235238
password: ${nr-var:oci.auth.basic.password}
236-
bearer: ${nr-var:oci.auth.bearer}
239+
bearer:
240+
token: ${nr-var:oci.auth.bearer.token}
237241
health:
238242
interval: 30s
239243
initial_delay: 90s

agent-control/src/agent_type/runtime_config/on_host.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@ packages:
858858
basic:
859859
username: ${nr-var:oci.auth.basic.username}
860860
password: ${nr-var:oci.auth.basic.password}
861-
bearer: ${nr-var:oci.auth.bearer}
861+
bearer:
862+
token: ${nr-var:oci.auth.bearer.token}
862863
"#;
863864
}

agent-control/src/agent_type/runtime_config/on_host/package.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub struct Oci {
4444
#[derive(Debug, Deserialize, Default, Clone, PartialEq)]
4545
pub struct Auth {
4646
pub basic: BasicAuth,
47-
pub bearer: TemplateableValue<String>,
47+
pub bearer: BearerAuth,
4848
}
4949

5050
#[derive(Debug, Deserialize, Default, Clone, PartialEq)]
@@ -53,6 +53,11 @@ pub struct BasicAuth {
5353
pub password: TemplateableValue<String>,
5454
}
5555

56+
#[derive(Debug, Deserialize, Default, Clone, PartialEq)]
57+
pub struct BearerAuth {
58+
pub token: TemplateableValue<String>,
59+
}
60+
5661
impl Templateable for Package {
5762
type Output = rendered::Package;
5863
fn template_with(self, variables: &Variables) -> Result<Self::Output, AgentTypeError> {
@@ -129,6 +134,7 @@ impl Templateable for Auth {
129134
})?;
130135
let token = self
131136
.bearer
137+
.token
132138
.template_with(variables)
133139
.map_err(|_| AgentTypeError::OCIAuthError("error templating token".to_string()))?;
134140

@@ -257,7 +263,7 @@ mod tests {
257263
username: TemplateableValue::from_template("${nr-var:username}".to_string()),
258264
password: TemplateableValue::from_template("${nr-var:password}".to_string()),
259265
},
260-
bearer: TemplateableValue::default(),
266+
bearer: BearerAuth::default(),
261267
},
262268
};
263269

@@ -283,7 +289,9 @@ mod tests {
283289
public_key_url: None,
284290
auth: Auth {
285291
basic: BasicAuth::default(),
286-
bearer: TemplateableValue::from_template("${nr-var:token}".to_string()),
292+
bearer: BearerAuth {
293+
token: TemplateableValue::from_template("${nr-var:token}".to_string()),
294+
},
287295
},
288296
};
289297

@@ -320,7 +328,9 @@ mod tests {
320328
username: TemplateableValue::from_template("${nr-var:username}".to_string()),
321329
password: TemplateableValue::from_template("${nr-var:password}".to_string()),
322330
},
323-
bearer: TemplateableValue::from_template("${nr-var:token}".to_string()),
331+
bearer: BearerAuth {
332+
token: TemplateableValue::from_template("${nr-var:token}".to_string()),
333+
},
324334
},
325335
};
326336

0 commit comments

Comments
 (0)