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

Release 4.4.b - for terrafrom sdk cut over #118

Merged
merged 21 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
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: 10 additions & 0 deletions client/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,13 @@ func (h *V1Client) DownloadLogs(uid string, logFetcherUID string) (io.Writer, er

return logfile, nil
}

// UpdatePauseAgentUpgradeSettingCluster updates the upgrade settings of a specific cluster to pause the agent upgrade process.
func (h *V1Client) UpdatePauseAgentUpgradeSettingCluster(upgradeSetting *models.V1ClusterUpgradeSettingsEntity, clusterUID string) error {
params := clientv1.NewV1SpectroClustersUIDUpgradeSettingsParamsWithContext(h.ctx).WithUID(clusterUID).WithBody(upgradeSetting)
_, err := h.Client.V1SpectroClustersUIDUpgradeSettings(params)
if err != nil {
return err
}
return nil
}
12 changes: 12 additions & 0 deletions client/cluster_host_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@ func (h *V1Client) UpdateClusterHostConfig(uid string, config *models.V1HostClus
_, err := h.Client.V1HostClusterConfigUpdate(params)
return err
}

// ApplyClusterHostConfig applies the specified host configuration to the cluster identified by the given UID.
func (h *V1Client) ApplyClusterHostConfig(uid string, config *models.V1HostClusterConfigEntity) error {
policy, err := h.GetClusterScanConfig(uid)
if err != nil {
return err
}
if policy == nil {
return h.UpdateClusterHostConfig(uid, config)
}
return h.UpdateClusterHostConfig(uid, config)
}
13 changes: 13 additions & 0 deletions client/cluster_profile_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package client

import (
"github.com/go-openapi/runtime"
"github.com/spectrocloud/palette-api-go/models"

clientv1 "github.com/spectrocloud/palette-api-go/client/v1"
"github.com/spectrocloud/palette-sdk-go/client/apiutil"
Expand All @@ -18,3 +19,15 @@ func (h *V1Client) CreateClusterProfileImport(importFile runtime.NamedReadCloser
}
return *resp.Payload.UID, nil
}

// ClusterProfileExport retrieves and exports a cluster profile by its unique identifier.
func (h *V1Client) ClusterProfileExport(uid string) (*models.V1ClusterProfile, error) {
// no need to switch request context here as /v1/clusterprofiles/{uid} works for profile in any scope.
params := clientv1.NewV1ClusterProfilesGetParamsWithContext(h.ctx).WithUID(uid)
success, err := h.Client.V1ClusterProfilesGet(params)
if err != nil {
return nil, err
}
return success.Payload, nil

}
8 changes: 8 additions & 0 deletions client/node_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import (
"github.com/spectrocloud/palette-api-go/models"
)

// GetMaintenanceStatus defines a function type that retrieves the maintenance status of a machine.
type GetMaintenanceStatus func(string, string, string) (*models.V1MachineMaintenanceStatus, error)

// ToggleMaintenanceOnNode updates maintenance configuration for a node.
func (h *V1Client) ToggleMaintenanceOnNode(nodeMaintenance *models.V1MachineMaintenance, cloudType, configUID, machineName, nodeID string) error {
params := clientv1.NewV1CloudConfigsMachinePoolsMachineUIDMaintenanceUpdateParamsWithContext(h.ctx).
Expand All @@ -18,6 +21,11 @@ func (h *V1Client) ToggleMaintenanceOnNode(nodeMaintenance *models.V1MachineMain
return err
}

// GetNodeMaintenanceStatus retrieves the maintenance status of a specific node.
func (h *V1Client) GetNodeMaintenanceStatus(fn GetMaintenanceStatus, ConfigUID, machineName, nodeID string) (*models.V1MachineMaintenanceStatus, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious to understand how this function simplifies things on the TF side. You still need to provide a cloud-specific function as a param, so it's not providing anything that's actually generic.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll still approve, but I don't see how this is any better than just calling the function you want directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so basically from terraform we are sending cloud specific function as parameter, will simplify it soon

return fn(ConfigUID, machineName, nodeID)
}

// GetNodeMaintenanceStatusAws retrieves maintenance status for an AWS IaaS node.
func (h *V1Client) GetNodeMaintenanceStatusAws(configUID, machineName, nodeID string) (*models.V1MachineMaintenanceStatus, error) {
params := clientv1.NewV1CloudConfigsAwsPoolMachinesUIDGetParamsWithContext(h.ctx).
Expand Down
1 change: 1 addition & 0 deletions client/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ func (h *V1Client) GetTenantUID() (string, error) {
if err != nil {
return "", err
}

if resp == nil {
return "", errors.New("empty response received from GetUsersInfo()")
}
Expand Down
1 change: 1 addition & 0 deletions client/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func (h *V1Client) AuthRefreshToken(token string) (*models.V1UserToken, error) {
// GetUsersInfo retrieves the authenticated user info.
func (h *V1Client) GetUsersInfo() (*models.V1UserInfo, error) {
params := clientv1.NewV1UsersInfoGetParamsWithContext(h.ctx)

resp, err := h.Client.V1UsersInfoGet(params)
if err != nil {
return nil, err
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ require (
golang.org/x/sys v0.22.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

//replace github.com/spectrocloud/palette-api-go => ../palette-api-go
Loading