func GetImmediateRunCommandGoalStates()

in internal/goalstate/goalstatefromvmsettings.go [12:32]


func GetImmediateRunCommandGoalStates(ctx *log.Context, communicator hostgacommunicator.IHostGACommunicator, lastProcessedETag string) ([]hostgacommunicator.ImmediateExtensionGoalState, string, error) {
	if communicator == nil {
		return nil, lastProcessedETag, errors.New("communicator cannot be nil")
	}

	responseData, err := communicator.GetImmediateVMSettings(ctx, lastProcessedETag)
	if err != nil {
		return nil, lastProcessedETag, errors.Wrapf(err, "failed to retrieve immediate VMSettings")
	}

	if responseData != nil && responseData.Modified {
		ctx.Log("message", "a new response was received with ETag: "+responseData.ETag)
		if responseData.VMSettings != nil {
			return filterImmediateRunCommandGoalStates(responseData.VMSettings.ImmediateExtensionGoalStates), responseData.ETag, nil
		} else {
			return []hostgacommunicator.ImmediateExtensionGoalState{}, responseData.ETag, nil
		}
	}

	return []hostgacommunicator.ImmediateExtensionGoalState{}, lastProcessedETag, nil
}