fix: not updating when only something other than hostname or description changed
This commit is contained in:
@@ -64,17 +64,20 @@ func authenticatedRequest(method, url, authorization string, urlparams url.Value
|
||||
|
||||
request, err := http.NewRequest(method, url, body)
|
||||
if err != nil {
|
||||
log.Println("Error: ", err)
|
||||
return nil, err
|
||||
}
|
||||
request.Header.Set("Authorization", authorization)
|
||||
|
||||
resp, err := client.Do(request)
|
||||
if err != nil {
|
||||
log.Println("Error: ", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Println("Error: ", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +252,6 @@ func (p *Plugin) Update(ctx context.Context, req *resource.UpdateRequest) (*reso
|
||||
}, fmt.Errorf("can't change vmid")
|
||||
}
|
||||
|
||||
if prior.Hostname != desir.Hostname || prior.Description != desir.Description {
|
||||
config, err := parseTargetConfig(req.TargetConfig)
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
@@ -286,7 +285,7 @@ func (p *Plugin) Update(ctx context.Context, req *resource.UpdateRequest) (*reso
|
||||
"description": {desir.Description},
|
||||
}
|
||||
|
||||
_, err = authenticatedRequest(http.MethodPut, config.URL+"/api2/json/nodes/"+config.NODE+"/lxc/"+desir.VMID+"/config", createAuthorizationString(username, token), urlparams)
|
||||
_, err = authenticatedRequest("PUT", config.URL+"/api2/json/nodes/"+config.NODE+"/lxc/"+desir.VMID+"/config", createAuthorizationString(username, token), urlparams)
|
||||
|
||||
if err != nil {
|
||||
return &resource.UpdateResult{
|
||||
@@ -298,7 +297,6 @@ func (p *Plugin) Update(ctx context.Context, req *resource.UpdateRequest) (*reso
|
||||
},
|
||||
}, err
|
||||
}
|
||||
}
|
||||
|
||||
result, err := p.Read(ctx, &resource.ReadRequest{
|
||||
NativeID: req.NativeID,
|
||||
|
||||
Reference in New Issue
Block a user