astefanutti commented on a change in pull request #2858: URL: https://github.com/apache/camel-k/pull/2858#discussion_r781036971
########## File path: pkg/util/maven/maven_settings.go ########## @@ -34,30 +32,46 @@ import ( var DefaultMavenRepositories = "https://repo.maven.apache.org/maven2@id=central" func (s Settings) MarshalBytes() ([]byte, error) { - w := &bytes.Buffer{} - w.WriteString(xml.Header) - - e := xml.NewEncoder(w) - e.Indent("", " ") - - if err := e.Encode(s); err != nil { - return []byte{}, err - } + return util.EncodeXML(s) +} - return w.Bytes(), nil +type SettingsOption interface { + apply(settings *Settings) error } -func NewSettings() Settings { - return Settings{ +func NewSettings(options ...SettingsOption) (Settings, error) { + settings := Settings{ XMLName: xml.Name{Local: "settings"}, XMLNs: "http://maven.apache.org/SETTINGS/1.0.0", XMLNsXsi: "http://www.w3.org/2001/XMLSchema-instance", XsiSchemaLocation: "http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd", + Profiles: []Profile{ + { + ID: "camel-k", + Activation: Activation{ + ActiveByDefault: true, + }, + }, + }, + } + + for _, option := range options { + err := option.apply(&settings) + if err != nil { + return Settings{}, err + } } + + return settings, nil } func NewDefaultSettings(repositories []v1.Repository, mirrors []Mirror) Settings { - settings := NewSettings() + settings := Settings{ + XMLName: xml.Name{Local: "settings"}, + XMLNs: "http://maven.apache.org/SETTINGS/1.0.0", Review comment: It's addressed with 2e7075bccb7758e1e12fac6128e9c01b78fec124. I forgot to mention it still is WIP with the list of TODOs documented in the PR description. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
