@@ -20,8 +20,8 @@ import (
2020// when unit testing
2121type WrappedAPI interface {
2222 KeepAlive (uptimeTracking bool ) error
23- Register (regcode , instanceDataFile string ) error
24- RegisterOrKeepAlive (regcode , instanceDataFile string , uptimeTracking bool ) error
23+ Register (opts * Options ) error
24+ RegisterOrKeepAlive (opts * Options ) error
2525 IsRegistered () bool
2626 AssignLabels (labels []string ) ([]labels.Label , error )
2727
@@ -145,7 +145,7 @@ func (w Wrapper) KeepAlive(uptimeTracking bool) error {
145145 return err
146146}
147147
148- func (w Wrapper ) Register (regcode , instanceDataFile string ) error {
148+ func (w Wrapper ) Register (opts * Options ) error {
149149 arch , _ := collectors .DetectArchitecture ()
150150 hwinfo , err := FetchSystemInformation (arch )
151151 if err != nil {
@@ -157,8 +157,8 @@ func (w Wrapper) Register(regcode, instanceDataFile string) error {
157157 // "extra" data. This will be used inside of the `registration.Register`
158158 // code.
159159 extraData := registration.ExtraData {}
160- if instanceDataFile != "" {
161- data , err := os .ReadFile (instanceDataFile )
160+ if opts . InstanceDataFile != "" {
161+ data , err := os .ReadFile (opts . InstanceDataFile )
162162 if err != nil {
163163 return err
164164 }
@@ -170,7 +170,10 @@ func (w Wrapper) Register(regcode, instanceDataFile string) error {
170170 profileData , err := FetchSystemProfiles (arch , true )
171171 extraData ["system_profiles" ] = profileData
172172
173- _ , err = registration .Register (w .Connection , regcode , hostname , hwinfo , extraData )
173+ // add distro_target to extra data
174+ extraData ["distro_target" ] = opts .Product .DistroTarget ()
175+
176+ _ , err = registration .Register (w .Connection , opts .Token , hostname , hwinfo , extraData )
174177 if err != nil {
175178 profiles .DeleteProfileCache ("*-profile-id" )
176179 }
@@ -179,11 +182,11 @@ func (w Wrapper) Register(regcode, instanceDataFile string) error {
179182
180183// RegisterOrKeepAlive calls either `Register` or `KeepAlive` depending on
181184// whether the current system is registered or not.
182- func (w Wrapper ) RegisterOrKeepAlive (regcode , instanceDataFile string , uptimeTracking bool ) error {
185+ func (w Wrapper ) RegisterOrKeepAlive (opts * Options ) error {
183186 if w .Registered {
184- return w .KeepAlive (uptimeTracking )
187+ return w .KeepAlive (opts . EnableSystemUptimeTracking )
185188 }
186- return w .Register (regcode , instanceDataFile )
189+ return w .Register (opts )
187190}
188191
189192func (w Wrapper ) IsRegistered () bool {
0 commit comments