Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(instance): publish WaitForServer #244

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions api/instance/v1/server_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ func (s *API) UpdateServer(req *UpdateServerRequest, opts ...scw.RequestOption)
return s.updateServer((*UpdateServerRequest)(req), opts...)
}

// waitForServerRequest is used by waitForServer method.
type waitForServerRequest struct {
// WaitForServerRequest is used by WaitForServer method.
type WaitForServerRequest struct {
ServerID string
Zone scw.Zone
Timeout time.Duration
}

// waitForServer wait for the server to be in a "terminal state" before returning.
// WaitForServer wait for the server to be in a "terminal state" before returning.
// This function can be used to wait for a server to be started for example.
func (s *API) waitForServer(req *waitForServerRequest) (*Server, scw.SdkError) {
func (s *API) WaitForServer(req *WaitForServerRequest) (*Server, scw.SdkError) {

terminalStatus := map[ServerState]struct{}{
ServerStateStopped: {},
Expand Down Expand Up @@ -109,7 +109,7 @@ func (s *API) ServerActionAndWait(req *ServerActionAndWaitRequest) error {
return err
}

finalServer, err := s.waitForServer(&waitForServerRequest{
finalServer, err := s.WaitForServer(&WaitForServerRequest{
Zone: req.Zone,
ServerID: req.ServerID,
Timeout: req.Timeout,
Expand Down