Skip to content

Commit

Permalink
Add advanced settings to remote update
Browse files Browse the repository at this point in the history
  • Loading branch information
tomer-shefler committed Jan 14, 2024
1 parent 7139270 commit 2644635
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cbcontainers/models/remote_configuration_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ var (
ChangeStatusFailed RemoteChangeStatus = "FAILED"
)

type AdvancedSettings struct {
ProxyVersion *string `json:"proxy_version,omitempty"`
RegistryServer *string `json:"registry_server,omitempty"`
}

type ConfigurationChange struct {
ID string `json:"id"`
Status RemoteChangeStatus `json:"status"`
AgentVersion *string `json:"agent_version"`
Timestamp string `json:"timestamp"`
ID string `json:"id"`
Status RemoteChangeStatus `json:"status"`
AgentVersion *string `json:"agent_version"`
AdvancedSettings *AdvancedSettings `json:"advancedSettings,omitempty"`
Timestamp string `json:"timestamp"`
}

type ConfigurationChangeStatusUpdate struct {
Expand Down
15 changes: 15 additions & 0 deletions cbcontainers/remote_configuration/change_applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func ApplyConfigChangeToCR(change models.ConfigurationChange, cr *cbcontainersv1
if change.AgentVersion != nil {
cr.Spec.Version = *change.AgentVersion

applyAdvancedSettings(change.AdvancedSettings, cr)
resetImageTagsInCR(cr)
toggleFeaturesBasedOnCompatibility(cr, *change.AgentVersion, sensorMetadata)
}
Expand Down Expand Up @@ -78,3 +79,17 @@ func toggleFeaturesBasedOnCompatibility(cr *cbcontainersv1.CBContainersAgent, ve
cr.Spec.Components.Cndr.Enabled = &falseRef
}
}

func applyAdvancedSettings(settings *models.AdvancedSettings, cr *cbcontainersv1.CBContainersAgent) {
if settings == nil {
return
}

if settings.RegistryServer != nil {
cr.Spec.Components.Settings.DefaultImagesRegistry = *settings.RegistryServer
}
if settings.ProxyVersion != nil {
cr.Spec.Components.Settings.Proxy.HttpsProxy = settings.ProxyVersion
cr.Spec.Components.Settings.Proxy.HttpProxy = settings.ProxyVersion
}
}

0 comments on commit 2644635

Please sign in to comment.