You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* refactor: type-safe sub-agent ID
There are (or will be) functions around that are intended to operate with a SubAgentID and should not **ever** receive the AC AgentID or any other reserved AgentID that we add in the future. With this we can be a bit more sure that we are using the correct IDs.
* style: remove `new_unchecked`
* style: remove `AgentID::is_valid_format`
/// following [RFC 1035 Label names](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#rfc-1035-label-names).
16
16
pubenumAgentID{
17
17
AgentControl,
18
-
SubAgent(String),
19
-
}
20
-
21
-
#[derive(Error,Debug)]
22
-
pubenumAgentIDError{
23
-
#[error(
24
-
"AgentID must contain 32 characters at most, contain lowercase alphanumeric characters or dashes only, start with alphabetic, and end with alphanumeric"
25
-
)]
26
-
InvalidFormat,
27
-
#[error("AgentID '{0}' is reserved")]
28
-
Reserved(String),
18
+
SubAgent(SubAgentID),
29
19
}
30
20
31
21
implAgentID{
32
22
pubfnas_str(&self) -> &str{
33
23
matchself{
34
24
Self::AgentControl => AGENT_CONTROL_ID,
35
-
Self::SubAgent(id) => id,
25
+
Self::SubAgent(id) => id.as_str(),
36
26
}
37
27
}
38
-
39
-
/// Checks if a string reference has valid format to build an [AgentID].
40
-
/// It follows [RFC 1035 Label names](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#rfc-1035-label-names),
41
-
/// and sets a shorter maximum length to avoid issues when the agent-id is used to compose names.
// TODO: define how SubAgentID should be converted to a Path here.
107
+
Path::new(self.as_str())
108
+
}
109
+
}
110
+
111
+
#[derive(Error,Debug)]
112
+
pubenumAgentIDError{
113
+
#[error(
114
+
"AgentID must contain 32 characters at most, contain lowercase alphanumeric characters or dashes only, start with alphabetic, and end with alphanumeric"
115
+
)]
116
+
InvalidFormat,
117
+
#[error("AgentID '{0}' is reserved")]
118
+
Reserved(String),
119
+
}
120
+
121
+
/// Checks if a string reference has valid format to build an [`AgentID`] or [`SubAgentID`].
122
+
/// It follows [RFC 1035 Label names](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#rfc-1035-label-names),
123
+
/// and sets a shorter maximum length to avoid issues when the agent-id is used to compose names.
0 commit comments