func newWsfcManager()

in google_guest_agent/wsfc.go [53:88]


func newWsfcManager() *wsfcManager {
	newState := stopped
	config := cfg.Get()

	if func() bool {
		if config.WSFC != nil && config.WSFC.Enable && config.WSFC.Addresses != "" {
			return config.WSFC.Enable
		}
		if newMetadata.Instance.Attributes.EnableWSFC != nil {
			return *newMetadata.Instance.Attributes.EnableWSFC
		}
		if newMetadata.Instance.Attributes.WSFCAddresses != "" {
			return true
		}
		if newMetadata.Project.Attributes.EnableWSFC != nil {
			return *newMetadata.Project.Attributes.EnableWSFC
		}
		if newMetadata.Project.Attributes.WSFCAddresses != "" {
			return true
		}
		return false
	}() {
		newState = running
	}

	newPort := wsfcDefaultAgentPort
	if config.WSFC != nil && config.WSFC.Port != "" {
		newPort = config.WSFC.Port
	} else if newMetadata.Instance.Attributes.WSFCAgentPort != "" {
		newPort = newMetadata.Instance.Attributes.WSFCAgentPort
	} else if newMetadata.Project.Attributes.WSFCAgentPort != "" {
		newPort = newMetadata.Instance.Attributes.WSFCAgentPort
	}

	return &wsfcManager{agentNewState: newState, agentNewPort: newPort, agent: getWsfcAgentInstance()}
}