Skip to content

Commit bc587ba

Browse files
committed
fix
1 parent 8b5cd3f commit bc587ba

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

golem-common/src/base_model/worker.rs

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,13 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use super::agent::AgentTypeName;
16-
use super::component_metadata::ComponentMetadata;
1715
use crate::base_model::account::AccountId;
1816
use crate::base_model::component::{ComponentFilePermissions, ComponentRevision, PluginPriority};
1917
use crate::base_model::environment::EnvironmentId;
2018
use crate::base_model::oplog::WorkerResourceId;
2119
use crate::base_model::regions::OplogRegion;
2220
use crate::base_model::{OplogIndex, Timestamp, WorkerId, WorkerResourceDescription, WorkerStatus};
23-
use crate::model::agent::{ConfigKeyValueType, ConfigValueType};
2421
use crate::{declare_enums, declare_structs, declare_unions};
25-
use golem_wasm::ValueAndType;
2622
use golem_wasm_derive::{FromValue, IntoValue};
2723
use std::collections::{BTreeMap, HashMap, HashSet};
2824
use std::fmt::{Display, Formatter};
@@ -74,42 +70,6 @@ pub struct UntypedParsedWorkerCreationLocalAgentConfigEntry {
7470
pub value: golem_wasm::Value,
7571
}
7672

77-
impl UntypedParsedWorkerCreationLocalAgentConfigEntry {
78-
pub fn enrich_with_type(
79-
self,
80-
component_metadata: &ComponentMetadata,
81-
agent_type_name: Option<&AgentTypeName>,
82-
) -> Result<ParsedWorkerCreationLocalAgentConfigEntry, String> {
83-
let agent_type_name = agent_type_name.ok_or_else(|| {
84-
"cannot enrich local agent config for non-agentic workers".to_string()
85-
})?;
86-
87-
let value_type = component_metadata
88-
.find_agent_type_by_name(agent_type_name)
89-
.ok_or("did not find expected agent type in the metadata")?
90-
.config
91-
.into_iter()
92-
.find_map(|c| match c {
93-
ConfigKeyValueType {
94-
key,
95-
value: ConfigValueType::Local(inner),
96-
} if key == self.key => Some(inner),
97-
_ => None,
98-
})
99-
.ok_or_else(|| {
100-
format!(
101-
"did not find config key {} in the metadata",
102-
self.key.join(".")
103-
)
104-
})?;
105-
106-
Ok(ParsedWorkerCreationLocalAgentConfigEntry {
107-
key: self.key,
108-
value: ValueAndType::new(self.value, value_type.value),
109-
})
110-
}
111-
}
112-
11373
declare_structs! {
11474
pub struct WorkerCreationLocalAgentConfigEntry {
11575
pub key: Vec<String>,

golem-common/src/model/worker.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,47 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use super::agent::AgentTypeName;
16+
use super::component_metadata::ComponentMetadata;
1517
pub use crate::base_model::worker::*;
18+
use crate::model::agent::{ConfigKeyValueType, ConfigValueType};
19+
use golem_wasm::ValueAndType;
20+
21+
impl UntypedParsedWorkerCreationLocalAgentConfigEntry {
22+
pub fn enrich_with_type(
23+
self,
24+
component_metadata: &ComponentMetadata,
25+
agent_type_name: Option<&AgentTypeName>,
26+
) -> Result<ParsedWorkerCreationLocalAgentConfigEntry, String> {
27+
let agent_type_name = agent_type_name.ok_or_else(|| {
28+
"cannot enrich local agent config for non-agentic workers".to_string()
29+
})?;
30+
31+
let value_type = component_metadata
32+
.find_agent_type_by_name(agent_type_name)
33+
.ok_or("did not find expected agent type in the metadata")?
34+
.config
35+
.into_iter()
36+
.find_map(|c| match c {
37+
ConfigKeyValueType {
38+
key,
39+
value: ConfigValueType::Local(inner),
40+
} if key == self.key => Some(inner),
41+
_ => None,
42+
})
43+
.ok_or_else(|| {
44+
format!(
45+
"did not find config key {} in the metadata",
46+
self.key.join(".")
47+
)
48+
})?;
49+
50+
Ok(ParsedWorkerCreationLocalAgentConfigEntry {
51+
key: self.key,
52+
value: ValueAndType::new(self.value, value_type.value),
53+
})
54+
}
55+
}
1656

1757
mod protobuf {
1858
use super::{

0 commit comments

Comments
 (0)