Skip to content

Commit

Permalink
Release 4.4.b - for terrafrom sdk cut over (#118)
Browse files Browse the repository at this point in the history
* Intial sdk cutover push

* fix cluster group

* fix

* draft 2

* fix3

* updated go mod

* removed deprecated edge

* commented swith org

* added comment

* corrected the comment

* PLT-1310: As part of sdk cutover removing libvirt support

* solving revive issues

* revive fix

* refreshed api-go for user info api

* fix revive issue

* fix

* revive fix2

* removed lint issue

* PLT-1323: Fixed pause agent upgrades.

---------

Co-authored-by: Tyler Gillson <[email protected]>
  • Loading branch information
SivaanandM and TylerGillson authored Aug 5, 2024
1 parent c16c4e2 commit cd5a464
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 0 deletions.
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) {
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

0 comments on commit cd5a464

Please sign in to comment.