@@ -76,6 +76,10 @@ pub struct AgentControlConfig {
7676 /// Contains configuration for on-host self-update mechanism
7777 #[ serde( default ) ]
7878 pub self_update : SelfUpdateConfig ,
79+
80+ /// Oci configuration (used for AC and agents packages)
81+ #[ serde( default ) ]
82+ pub oci : OciConfig ,
7983}
8084
8185#[ derive( Debug , Default , Deserialize , PartialEq , Clone ) ]
@@ -94,6 +98,48 @@ pub struct PackagesConfig {
9498 pub signature_verification_enabled : SignatureVerificationEnabled ,
9599}
96100
101+ #[ derive( Debug , Deserialize , Serialize , Clone , PartialEq ) ]
102+ pub struct OciConfig {
103+ #[ serde( default = "OciConfig::default_registry" ) ]
104+ pub registry : String ,
105+ #[ serde( default ) ]
106+ pub auth : OciAuth ,
107+ }
108+
109+ impl Default for OciConfig {
110+ fn default ( ) -> Self {
111+ OciConfig {
112+ registry : Self :: default_registry ( ) ,
113+ auth : OciAuth :: default ( ) ,
114+ }
115+ }
116+ }
117+
118+ impl OciConfig {
119+ fn default_registry ( ) -> String {
120+ "docker.io" . to_string ( )
121+ }
122+ }
123+
124+ #[ derive( Debug , Deserialize , Serialize , Default , Clone , PartialEq ) ]
125+ pub struct OciAuth {
126+ #[ serde( default ) ]
127+ pub basic : BasicAuth ,
128+ #[ serde( default ) ]
129+ pub bearer : BearerAuth ,
130+ }
131+
132+ #[ derive( Debug , Deserialize , Serialize , Default , Clone , PartialEq ) ]
133+ pub struct BasicAuth {
134+ pub username : String ,
135+ pub password : String ,
136+ }
137+
138+ #[ derive( Debug , Deserialize , Serialize , Default , Clone , PartialEq ) ]
139+ pub struct BearerAuth {
140+ pub token : String ,
141+ }
142+
97143const DEFAULT_SIGNATURE_VERIFICATION_ENABLED : bool = true ;
98144#[ derive( Debug , Deserialize , Clone , Copy , PartialEq , WrapperWithDefault ) ]
99145#[ wrapper_default_value( DEFAULT_SIGNATURE_VERIFICATION_ENABLED ) ]
@@ -1041,6 +1087,31 @@ k8s:
10411087 assert_matches ! ( result, Err ( AgentControlConfigError ( _) ) ) ;
10421088 }
10431089
1090+ #[ test]
1091+ fn test_deserialize_oci_config ( ) {
1092+ let config_input = r#"agents: {}"# ;
1093+ let config = serde_yaml:: from_str :: < AgentControlConfig > ( config_input) . unwrap ( ) ;
1094+ assert_eq ! ( "docker.io" . to_string( ) , config. oci. registry) ;
1095+
1096+ let config_input = r#"
1097+ agents: {}
1098+ oci:
1099+ auth:
1100+ bearer:
1101+ token: "token"
1102+ "# ;
1103+ let config = serde_yaml:: from_str :: < AgentControlConfig > ( config_input) . unwrap ( ) ;
1104+ assert_eq ! ( "docker.io" . to_string( ) , config. oci. registry) ;
1105+
1106+ let config_input = r#"
1107+ agents: {}
1108+ oci:
1109+ registry: "custom-registry.io"
1110+ "# ;
1111+ let config = serde_yaml:: from_str :: < AgentControlConfig > ( config_input) . unwrap ( ) ;
1112+ assert_eq ! ( "custom-registry.io" . to_string( ) , config. oci. registry) ;
1113+ }
1114+
10441115 ////////////////////////////////////////////////////////////////////////////////////
10451116 // Test helpers
10461117 ////////////////////////////////////////////////////////////////////////////////////
0 commit comments