From 61efb704384b999be0690705b1a01a4c7e28ed1e Mon Sep 17 00:00:00 2001 From: Felix Uellendall Date: Tue, 27 Feb 2024 03:11:27 +0100 Subject: [PATCH] Regenerate core clients to be compatible with the latest changes (#1566) - fix hibernation override validation - fix cloudprovider references --- astro-client-core/api.gen.go | 236 ++++++++++++++++-- astro-client-core/mocks/client.go | 33 +++ astro-client-platform-core/api.gen.go | 40 +-- cloud/deployment/deployment.go | 4 +- cloud/deployment/deployment_test.go | 16 +- cloud/deployment/deployment_variable_test.go | 2 +- cloud/deployment/fromfile/fromfile_test.go | 2 +- cloud/deployment/inspect/inspect_test.go | 22 +- .../workerqueue/workerqueue_test.go | 4 +- cmd/cloud/deployment_test.go | 23 +- go.mod | 1 - go.sum | 2 - 12 files changed, 311 insertions(+), 74 deletions(-) diff --git a/astro-client-core/api.gen.go b/astro-client-core/api.gen.go index 58d9928ab..d6e4a8853 100644 --- a/astro-client-core/api.gen.go +++ b/astro-client-core/api.gen.go @@ -964,7 +964,12 @@ const ( // Defines values for ListSelfUserRepositoriesParamsGitProvider. const ( - GITHUB ListSelfUserRepositoriesParamsGitProvider = "GITHUB" + ListSelfUserRepositoriesParamsGitProviderGITHUB ListSelfUserRepositoriesParamsGitProvider = "GITHUB" +) + +// Defines values for GetSelfUserRepositoryBranchParamsGitProvider. +const ( + GetSelfUserRepositoryBranchParamsGitProviderGITHUB GetSelfUserRepositoryBranchParamsGitProvider = "GITHUB" ) // AddTeamMembersRequest defines model for AddTeamMembersRequest. @@ -1038,6 +1043,7 @@ type BasicSubjectProfileSubjectType string type Cluster struct { AppliedTemplateVersion string `json:"appliedTemplateVersion"` CloudProvider ClusterCloudProvider `json:"cloudProvider"` + Cohort *string `json:"cohort,omitempty"` CreatedAt time.Time `json:"createdAt"` DbInstanceType string `json:"dbInstanceType"` DeletedAt *string `json:"deletedAt,omitempty"` @@ -1080,6 +1086,7 @@ type ClusterType string type ClusterDetailed struct { AppliedTemplateVersion string `json:"appliedTemplateVersion"` CloudProvider ClusterDetailedCloudProvider `json:"cloudProvider"` + Cohort *string `json:"cohort,omitempty"` CreatedAt time.Time `json:"createdAt"` CreatedBy BasicSubjectProfile `json:"createdBy"` DbInstanceType string `json:"dbInstanceType"` @@ -1851,7 +1858,19 @@ type DeploymentEnvironmentVariableRequest struct { // DeploymentHibernationOverride defines model for DeploymentHibernationOverride. type DeploymentHibernationOverride struct { // Hibernate Whether to go into hibernation or not via the override rule - Hibernate bool `json:"hibernate"` + Hibernate *bool `json:"hibernate,omitempty"` + + // IsActive Whether the override is currently active or not + IsActive *bool `json:"isActive,omitempty"` + + // OverrideUntil Timestamp till the override on the hibernation schedule is in effect + OverrideUntil *string `json:"overrideUntil,omitempty"` +} + +// DeploymentHibernationOverrideRequest defines model for DeploymentHibernationOverrideRequest. +type DeploymentHibernationOverrideRequest struct { + // Hibernate Whether to go into hibernation or not via the override rule + Hibernate *bool `json:"hibernate,omitempty"` // OverrideUntil Timestamp till the override on the hibernation schedule is in effect OverrideUntil *string `json:"overrideUntil,omitempty"` @@ -1882,7 +1901,7 @@ type DeploymentHibernationSpec struct { // DeploymentHibernationSpecRequest defines model for DeploymentHibernationSpecRequest. type DeploymentHibernationSpecRequest struct { - Override *DeploymentHibernationOverride `json:"override,omitempty"` + Override *DeploymentHibernationOverrideRequest `json:"override,omitempty"` // Schedules The list of schedules for the hibernation spec Schedules *[]DeploymentHibernationSchedule `json:"schedules,omitempty"` @@ -2108,11 +2127,11 @@ type GitHubAccountAccountType string // GitRepository defines model for GitRepository. type GitRepository struct { + Account string `json:"account"` FullName string `json:"fullName"` HasPullPermission bool `json:"hasPullPermission"` HasPushPermission bool `json:"hasPushPermission"` Name string `json:"name"` - Owner string `json:"owner"` UserIsAdmin bool `json:"userIsAdmin"` } @@ -2218,14 +2237,15 @@ type MutateOrgUserRoleRequest struct { // MutateWorkerQueueRequest defines model for MutateWorkerQueueRequest. type MutateWorkerQueueRequest struct { - AstroMachine *MutateWorkerQueueRequestAstroMachine `json:"astroMachine,omitempty"` - Id *string `json:"id,omitempty"` - IsDefault bool `json:"isDefault"` - MaxWorkerCount int `json:"maxWorkerCount"` - MinWorkerCount int `json:"minWorkerCount"` - Name string `json:"name"` - NodePoolId *string `json:"nodePoolId,omitempty"` - WorkerConcurrency int `json:"workerConcurrency"` + AstroMachine *MutateWorkerQueueRequestAstroMachine `json:"astroMachine,omitempty"` + Id *string `json:"id,omitempty"` + IsDefault bool `json:"isDefault"` + MaxWorkerCount int `json:"maxWorkerCount"` + MinWorkerCount int `json:"minWorkerCount"` + Name string `json:"name"` + NodePoolId *string `json:"nodePoolId,omitempty"` + PodEphemeralStorage *string `json:"podEphemeralStorage,omitempty"` + WorkerConcurrency int `json:"workerConcurrency"` } // MutateWorkerQueueRequestAstroMachine defines model for MutateWorkerQueueRequest.AstroMachine. @@ -2355,6 +2375,11 @@ type RepositoriesPaginated struct { Repositories []GitRepository `json:"repositories"` } +// RepositoryBranch defines model for RepositoryBranch. +type RepositoryBranch struct { + Name string `json:"name"` +} + // ResourceOption defines model for ResourceOption. type ResourceOption struct { Cpu ResourceRange `json:"cpu"` @@ -2506,6 +2531,7 @@ type SelfSignupType string // SharedCluster defines model for SharedCluster. type SharedCluster struct { CloudProvider SharedClusterCloudProvider `json:"cloudProvider"` + Cohort *string `json:"cohort,omitempty"` CreatedAt time.Time `json:"createdAt"` DbInstanceType string `json:"dbInstanceType"` Id string `json:"id"` @@ -2983,16 +3009,17 @@ type WorkerMachineName string // WorkerQueue defines model for WorkerQueue. type WorkerQueue struct { - AstroMachine *string `json:"astroMachine,omitempty"` - Id string `json:"id"` - IsDefault bool `json:"isDefault"` - MaxWorkerCount int `json:"maxWorkerCount"` - MinWorkerCount int `json:"minWorkerCount"` - Name string `json:"name"` - NodePoolId *string `json:"nodePoolId,omitempty"` - PodCpu string `json:"podCpu"` - PodRam string `json:"podRam"` - WorkerConcurrency int `json:"workerConcurrency"` + AstroMachine *string `json:"astroMachine,omitempty"` + Id string `json:"id"` + IsDefault bool `json:"isDefault"` + MaxWorkerCount int `json:"maxWorkerCount"` + MinWorkerCount int `json:"minWorkerCount"` + Name string `json:"name"` + NodePoolId *string `json:"nodePoolId,omitempty"` + PodCpu string `json:"podCpu"` + PodEphemeralStorage *string `json:"podEphemeralStorage,omitempty"` + PodRam string `json:"podRam"` + WorkerConcurrency int `json:"workerConcurrency"` } // WorkerQueueOptions defines model for WorkerQueueOptions. @@ -3626,6 +3653,9 @@ type ListSelfUserRepositoriesParams struct { // ListSelfUserRepositoriesParamsGitProvider defines parameters for ListSelfUserRepositories. type ListSelfUserRepositoriesParamsGitProvider string +// GetSelfUserRepositoryBranchParamsGitProvider defines parameters for GetSelfUserRepositoryBranch. +type GetSelfUserRepositoryBranchParamsGitProvider string + // CreateOrganizationJSONRequestBody defines body for CreateOrganization for application/json ContentType. type CreateOrganizationJSONRequestBody = CreateOrganizationRequest @@ -4393,6 +4423,9 @@ type ClientInterface interface { // ListSelfUserRepositories request ListSelfUserRepositories(ctx context.Context, gitProvider ListSelfUserRepositoriesParamsGitProvider, gitAccount string, params *ListSelfUserRepositoriesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetSelfUserRepositoryBranch request + GetSelfUserRepositoryBranch(ctx context.Context, gitProvider GetSelfUserRepositoryBranchParamsGitProvider, gitAccount string, gitRepository string, gitBranch string, reqEditors ...RequestEditorFn) (*http.Response, error) + // UpdateSelfUserInvite request with any body UpdateSelfUserInviteWithBody(ctx context.Context, inviteId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -6019,6 +6052,18 @@ func (c *Client) ListSelfUserRepositories(ctx context.Context, gitProvider ListS return c.Client.Do(req) } +func (c *Client) GetSelfUserRepositoryBranch(ctx context.Context, gitProvider GetSelfUserRepositoryBranchParamsGitProvider, gitAccount string, gitRepository string, gitBranch string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetSelfUserRepositoryBranchRequest(c.Server, gitProvider, gitAccount, gitRepository, gitBranch) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) UpdateSelfUserInviteWithBody(ctx context.Context, inviteId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewUpdateSelfUserInviteRequestWithBody(c.Server, inviteId, contentType, body) if err != nil { @@ -12540,6 +12585,61 @@ func NewListSelfUserRepositoriesRequest(server string, gitProvider ListSelfUserR return req, nil } +// NewGetSelfUserRepositoryBranchRequest generates requests for GetSelfUserRepositoryBranch +func NewGetSelfUserRepositoryBranchRequest(server string, gitProvider GetSelfUserRepositoryBranchParamsGitProvider, gitAccount string, gitRepository string, gitBranch string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "gitProvider", runtime.ParamLocationPath, gitProvider) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "gitAccount", runtime.ParamLocationPath, gitAccount) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "gitRepository", runtime.ParamLocationPath, gitRepository) + if err != nil { + return nil, err + } + + var pathParam3 string + + pathParam3, err = runtime.StyleParamWithLocation("simple", false, "gitBranch", runtime.ParamLocationPath, gitBranch) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/users/self/git-providers/%s/accounts/%s/repositories/%s/branches/%s", pathParam0, pathParam1, pathParam2, pathParam3) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewUpdateSelfUserInviteRequest calls the generic UpdateSelfUserInvite builder with application/json body func NewUpdateSelfUserInviteRequest(server string, inviteId string, body UpdateSelfUserInviteJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader @@ -12998,6 +13098,9 @@ type ClientWithResponsesInterface interface { // ListSelfUserRepositories request ListSelfUserRepositoriesWithResponse(ctx context.Context, gitProvider ListSelfUserRepositoriesParamsGitProvider, gitAccount string, params *ListSelfUserRepositoriesParams, reqEditors ...RequestEditorFn) (*ListSelfUserRepositoriesResponse, error) + // GetSelfUserRepositoryBranch request + GetSelfUserRepositoryBranchWithResponse(ctx context.Context, gitProvider GetSelfUserRepositoryBranchParamsGitProvider, gitAccount string, gitRepository string, gitBranch string, reqEditors ...RequestEditorFn) (*GetSelfUserRepositoryBranchResponse, error) + // UpdateSelfUserInvite request with any body UpdateSelfUserInviteWithBodyWithResponse(ctx context.Context, inviteId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSelfUserInviteResponse, error) @@ -15622,6 +15725,32 @@ func (r ListSelfUserRepositoriesResponse) StatusCode() int { return 0 } +type GetSelfUserRepositoryBranchResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *RepositoryBranch + JSON401 *Error + JSON403 *Error + JSON404 *Error + JSON500 *Error +} + +// Status returns HTTPResponse.Status +func (r GetSelfUserRepositoryBranchResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetSelfUserRepositoryBranchResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type UpdateSelfUserInviteResponse struct { Body []byte HTTPResponse *http.Response @@ -16827,6 +16956,15 @@ func (c *ClientWithResponses) ListSelfUserRepositoriesWithResponse(ctx context.C return ParseListSelfUserRepositoriesResponse(rsp) } +// GetSelfUserRepositoryBranchWithResponse request returning *GetSelfUserRepositoryBranchResponse +func (c *ClientWithResponses) GetSelfUserRepositoryBranchWithResponse(ctx context.Context, gitProvider GetSelfUserRepositoryBranchParamsGitProvider, gitAccount string, gitRepository string, gitBranch string, reqEditors ...RequestEditorFn) (*GetSelfUserRepositoryBranchResponse, error) { + rsp, err := c.GetSelfUserRepositoryBranch(ctx, gitProvider, gitAccount, gitRepository, gitBranch, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetSelfUserRepositoryBranchResponse(rsp) +} + // UpdateSelfUserInviteWithBodyWithResponse request with arbitrary body returning *UpdateSelfUserInviteResponse func (c *ClientWithResponses) UpdateSelfUserInviteWithBodyWithResponse(ctx context.Context, inviteId string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSelfUserInviteResponse, error) { rsp, err := c.UpdateSelfUserInviteWithBody(ctx, inviteId, contentType, body, reqEditors...) @@ -22626,6 +22764,60 @@ func ParseListSelfUserRepositoriesResponse(rsp *http.Response) (*ListSelfUserRep return response, nil } +// ParseGetSelfUserRepositoryBranchResponse parses an HTTP response from a GetSelfUserRepositoryBranchWithResponse call +func ParseGetSelfUserRepositoryBranchResponse(rsp *http.Response) (*GetSelfUserRepositoryBranchResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetSelfUserRepositoryBranchResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest RepositoryBranch + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 403: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON403 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + // ParseUpdateSelfUserInviteResponse parses an HTTP response from a UpdateSelfUserInviteWithResponse call func ParseUpdateSelfUserInviteResponse(rsp *http.Response) (*UpdateSelfUserInviteResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/astro-client-core/mocks/client.go b/astro-client-core/mocks/client.go index 17c686baf..c303d4c70 100644 --- a/astro-client-core/mocks/client.go +++ b/astro-client-core/mocks/client.go @@ -2063,6 +2063,39 @@ func (_m *ClientWithResponsesInterface) GetOrganizationWithResponse(ctx context. return r0, r1 } +// GetSelfUserRepositoryBranchWithResponse provides a mock function with given fields: ctx, gitProvider, gitAccount, gitRepository, gitBranch, reqEditors +func (_m *ClientWithResponsesInterface) GetSelfUserRepositoryBranchWithResponse(ctx context.Context, gitProvider astrocore.GetSelfUserRepositoryBranchParamsGitProvider, gitAccount string, gitRepository string, gitBranch string, reqEditors ...astrocore.RequestEditorFn) (*astrocore.GetSelfUserRepositoryBranchResponse, error) { + _va := make([]interface{}, len(reqEditors)) + for _i := range reqEditors { + _va[_i] = reqEditors[_i] + } + var _ca []interface{} + _ca = append(_ca, ctx, gitProvider, gitAccount, gitRepository, gitBranch) + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *astrocore.GetSelfUserRepositoryBranchResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, astrocore.GetSelfUserRepositoryBranchParamsGitProvider, string, string, string, ...astrocore.RequestEditorFn) (*astrocore.GetSelfUserRepositoryBranchResponse, error)); ok { + return rf(ctx, gitProvider, gitAccount, gitRepository, gitBranch, reqEditors...) + } + if rf, ok := ret.Get(0).(func(context.Context, astrocore.GetSelfUserRepositoryBranchParamsGitProvider, string, string, string, ...astrocore.RequestEditorFn) *astrocore.GetSelfUserRepositoryBranchResponse); ok { + r0 = rf(ctx, gitProvider, gitAccount, gitRepository, gitBranch, reqEditors...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*astrocore.GetSelfUserRepositoryBranchResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, astrocore.GetSelfUserRepositoryBranchParamsGitProvider, string, string, string, ...astrocore.RequestEditorFn) error); ok { + r1 = rf(ctx, gitProvider, gitAccount, gitRepository, gitBranch, reqEditors...) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // GetSelfUserWithResponse provides a mock function with given fields: ctx, params, reqEditors func (_m *ClientWithResponsesInterface) GetSelfUserWithResponse(ctx context.Context, params *astrocore.GetSelfUserParams, reqEditors ...astrocore.RequestEditorFn) (*astrocore.GetSelfUserResponse, error) { _va := make([]interface{}, len(reqEditors)) diff --git a/astro-client-platform-core/api.gen.go b/astro-client-platform-core/api.gen.go index e82401c87..5db225c11 100644 --- a/astro-client-platform-core/api.gen.go +++ b/astro-client-platform-core/api.gen.go @@ -155,6 +155,13 @@ const ( CreateStandardDeploymentRequestTypeSTANDARD CreateStandardDeploymentRequestType = "STANDARD" ) +// Defines values for DeploymentCloudProvider. +const ( + DeploymentCloudProviderAWS DeploymentCloudProvider = "AWS" + DeploymentCloudProviderAZURE DeploymentCloudProvider = "AZURE" + DeploymentCloudProviderGCP DeploymentCloudProvider = "GCP" +) + // Defines values for DeploymentExecutor. const ( DeploymentExecutorCELERY DeploymentExecutor = "CELERY" @@ -397,9 +404,9 @@ const ( // Defines values for GetDeploymentOptionsParamsCloudProvider. const ( - GetDeploymentOptionsParamsCloudProviderAWS GetDeploymentOptionsParamsCloudProvider = "AWS" - GetDeploymentOptionsParamsCloudProviderAZURE GetDeploymentOptionsParamsCloudProvider = "AZURE" - GetDeploymentOptionsParamsCloudProviderGCP GetDeploymentOptionsParamsCloudProvider = "GCP" + AWS GetDeploymentOptionsParamsCloudProvider = "AWS" + AZURE GetDeploymentOptionsParamsCloudProvider = "AZURE" + GCP GetDeploymentOptionsParamsCloudProvider = "GCP" ) // Defines values for ListDeploymentsParamsSorts. @@ -694,7 +701,7 @@ type CreateDedicatedDeploymentRequest struct { // DefaultTaskPodCpu The default CPU resource usage for a worker Pod when running the Kubernetes executor or KubernetesPodOperator. Units are in number of CPU cores. DefaultTaskPodCpu string `json:"defaultTaskPodCpu"` - // DefaultTaskPodMemory The default memory resource usage for a worker Pod when running the Kubernetes executor or KubernetesPodOperator. Units are in `Gi`. This value must always be twice the value of `DefaultTaskPodCpu`. + // DefaultTaskPodMemory The default memory resource usage for a worker Pod when running the Kubernetes executor or KubernetesPodOperator. Units are in `Gi` and must be explicitly included. This value must always be twice the value of `DefaultTaskPodCpu`. DefaultTaskPodMemory string `json:"defaultTaskPodMemory"` // Description The Deployment's description. @@ -724,7 +731,7 @@ type CreateDedicatedDeploymentRequest struct { // ResourceQuotaCpu The CPU quota for worker Pods when running the Kubernetes executor or KubernetesPodOperator. If current CPU usage across all workers exceeds the quota, no new worker Pods can be scheduled. Units are in number of CPU cores. ResourceQuotaCpu string `json:"resourceQuotaCpu"` - // ResourceQuotaMemory The memory quota for worker Pods when running the Kubernetes executor or KubernetesPodOperator. If current memory usage across all workers exceeds the quota, no new worker Pods can be scheduled. Units are in `Gi`. This value must always be twice the value of `ResourceQuotaCpu`. + // ResourceQuotaMemory The memory quota for worker Pods when running the Kubernetes executor or KubernetesPodOperator. If current memory usage across all workers exceeds the quota, no new worker Pods can be scheduled. Units are in `Gi` and must be explicitly included. This value must always be twice the value of `ResourceQuotaCpu`. ResourceQuotaMemory string `json:"resourceQuotaMemory"` ScalingSpec *DeploymentScalingSpecRequest `json:"scalingSpec,omitempty"` @@ -890,7 +897,7 @@ type CreateStandardDeploymentRequest struct { // DefaultTaskPodCpu The default CPU resource usage for a worker Pod when running the Kubernetes executor or KubernetesPodOperator. Units are in number of CPU cores. DefaultTaskPodCpu string `json:"defaultTaskPodCpu"` - // DefaultTaskPodMemory The default memory resource usage for a worker Pod when running the Kubernetes executor or KubernetesPodOperator. Units are in `Gi`. This value must always be twice the value of `DefaultTaskPodCpu`. + // DefaultTaskPodMemory The default memory resource usage for a worker Pod when running the Kubernetes executor or KubernetesPodOperator. Units are in `Gi` and must be explicitly included. This value must always be twice the value of `DefaultTaskPodCpu`. DefaultTaskPodMemory string `json:"defaultTaskPodMemory"` // Description The Deployment's description. @@ -923,7 +930,7 @@ type CreateStandardDeploymentRequest struct { // ResourceQuotaCpu The CPU quota for worker Pods when running the Kubernetes executor or KubernetesPodOperator. If current CPU usage across all workers exceeds the quota, no new worker Pods can be scheduled. Units are in number of CPU cores. ResourceQuotaCpu string `json:"resourceQuotaCpu"` - // ResourceQuotaMemory The memory quota for worker Pods when running the Kubernetes executor or KubernetesPodOperator. If current memory usage across all workers exceeds the quota, no new worker Pods can be scheduled. Units are in `Gi`. This value must always be twice the value of `ResourceQuotaCpu`. + // ResourceQuotaMemory The memory quota for worker Pods when running the Kubernetes executor or KubernetesPodOperator. If current memory usage across all workers exceeds the quota, no new worker Pods can be scheduled. Units are in `Gi` and must be explicitly included. This value must always be twice the value of `ResourceQuotaCpu`. ResourceQuotaMemory string `json:"resourceQuotaMemory"` ScalingSpec *DeploymentScalingSpecRequest `json:"scalingSpec,omitempty"` @@ -976,7 +983,7 @@ type Deployment struct { AstroRuntimeVersion string `json:"astroRuntimeVersion"` // CloudProvider The cloud provider of the cluster. Only for Standard Deployment. - CloudProvider *string `json:"cloudProvider,omitempty"` + CloudProvider *DeploymentCloudProvider `json:"cloudProvider,omitempty"` // ClusterId The ID of the cluster where the Deployment is hosted. ClusterId *string `json:"clusterId,omitempty"` @@ -1127,6 +1134,9 @@ type Deployment struct { WorkspaceName *string `json:"workspaceName,omitempty"` } +// DeploymentCloudProvider The cloud provider of the cluster. Only for Standard Deployment. +type DeploymentCloudProvider string + // DeploymentExecutor The Deployment's executor type. type DeploymentExecutor string @@ -1169,10 +1179,10 @@ type DeploymentEnvironmentVariableRequest struct { // DeploymentHibernationOverride defines model for DeploymentHibernationOverride. type DeploymentHibernationOverride struct { // IsActive Whether the override is currently active or not - IsActive bool `json:"isActive"` + IsActive *bool `json:"isActive,omitempty"` // IsHibernating Whether to go into hibernation or not via the override rule - IsHibernating bool `json:"isHibernating"` + IsHibernating *bool `json:"isHibernating,omitempty"` // OverrideUntil Timestamp till the override on the hibernation schedule is in effect OverrideUntil *time.Time `json:"overrideUntil,omitempty"` @@ -1181,7 +1191,7 @@ type DeploymentHibernationOverride struct { // DeploymentHibernationOverrideRequest defines model for DeploymentHibernationOverrideRequest. type DeploymentHibernationOverrideRequest struct { // IsHibernating Whether to go into hibernation or not via the override rule - IsHibernating bool `json:"isHibernating"` + IsHibernating *bool `json:"isHibernating,omitempty"` // OverrideUntil Timestamp till the override on the hibernation schedule is in effect OverrideUntil *string `json:"overrideUntil,omitempty"` @@ -1609,7 +1619,7 @@ type UpdateDedicatedDeploymentRequest struct { // DefaultTaskPodCpu The default CPU resource usage for a worker Pod when running the Kubernetes executor or KubernetesPodOperator. Units are in number of CPU cores. DefaultTaskPodCpu string `json:"defaultTaskPodCpu"` - // DefaultTaskPodMemory The default memory resource usage for a worker Pod when running the Kubernetes executor or KubernetesPodOperator. Units are in `Gi`. This value must always be twice the value of `DefaultTaskPodCpu`. + // DefaultTaskPodMemory The default memory resource usage for a worker Pod when running the Kubernetes executor or KubernetesPodOperator. Units are in `Gi` and must be explicitly included. This value must always be twice the value of `DefaultTaskPodCpu`. DefaultTaskPodMemory string `json:"defaultTaskPodMemory"` // Description The Deployment's description. @@ -1636,7 +1646,7 @@ type UpdateDedicatedDeploymentRequest struct { // ResourceQuotaCpu The CPU quota for worker Pods when running the Kubernetes executor or KubernetesPodOperator. If current CPU usage across all workers exceeds the quota, no new worker Pods can be scheduled. Units are in number of CPU cores. ResourceQuotaCpu string `json:"resourceQuotaCpu"` - // ResourceQuotaMemory The memory quota for worker Pods when running the Kubernetes executor or KubernetesPodOperator. If current memory usage across all workers exceeds the quota, no new worker Pods can be scheduled. Units are in `Gi`. This value must always be twice the value of `ResourceQuotaCpu`. + // ResourceQuotaMemory The memory quota for worker Pods when running the Kubernetes executor or KubernetesPodOperator. If current memory usage across all workers exceeds the quota, no new worker Pods can be scheduled. Units are in `Gi` and must be explicitly included. This value must always be twice the value of `ResourceQuotaCpu`. ResourceQuotaMemory string `json:"resourceQuotaMemory"` ScalingSpec *DeploymentScalingSpecRequest `json:"scalingSpec,omitempty"` @@ -1766,7 +1776,7 @@ type UpdateStandardDeploymentRequest struct { // DefaultTaskPodCpu The default CPU resource usage for a worker Pod when running the Kubernetes executor or KubernetesPodOperator. Units are in number of CPU cores. DefaultTaskPodCpu string `json:"defaultTaskPodCpu"` - // DefaultTaskPodMemory The default memory resource usage for a worker Pod when running the Kubernetes executor or KubernetesPodOperator. Units are in `Gi`. This value must always be twice the value of `DefaultTaskPodCpu`. + // DefaultTaskPodMemory The default memory resource usage for a worker Pod when running the Kubernetes executor or KubernetesPodOperator. Units are in `Gi` and must be explicitly included. This value must always be twice the value of `DefaultTaskPodCpu`. DefaultTaskPodMemory string `json:"defaultTaskPodMemory"` // Description The Deployment's description. @@ -1793,7 +1803,7 @@ type UpdateStandardDeploymentRequest struct { // ResourceQuotaCpu The CPU quota for worker Pods when running the Kubernetes executor or KubernetesPodOperator. If current CPU usage across all workers exceeds the quota, no new worker Pods can be scheduled. Units are in number of CPU cores. ResourceQuotaCpu string `json:"resourceQuotaCpu"` - // ResourceQuotaMemory The memory quota for worker Pods when running the Kubernetes executor or KubernetesPodOperator. If current memory usage across all workers exceeds the quota, no new worker Pods can be scheduled. Units are in `Gi`. This value must always be twice the value of `ResourceQuotaCpu`. + // ResourceQuotaMemory The memory quota for worker Pods when running the Kubernetes executor or KubernetesPodOperator. If current memory usage across all workers exceeds the quota, no new worker Pods can be scheduled. Units are in `Gi` and must be explicitly included. This value must always be twice the value of `ResourceQuotaCpu`. ResourceQuotaMemory string `json:"resourceQuotaMemory"` ScalingSpec *DeploymentScalingSpecRequest `json:"scalingSpec,omitempty"` diff --git a/cloud/deployment/deployment.go b/cloud/deployment/deployment.go index 98ff95a21..8ff226d65 100644 --- a/cloud/deployment/deployment.go +++ b/cloud/deployment/deployment.go @@ -524,7 +524,7 @@ func deploymentToTableRow(table *printutil.Table, d *astroplatformcore.Deploymen clusterName := notApplicable region := notApplicable if d.CloudProvider != nil { - cloudProvider = *d.CloudProvider + cloudProvider = string(*d.CloudProvider) } if d.Region != nil { region = *d.Region @@ -1132,7 +1132,7 @@ func Update(deploymentID, name, ws, description, deploymentName, dagDeploy, exec cloudProvider := notApplicable region := notApplicable if d.CloudProvider != nil { - cloudProvider = *d.CloudProvider + cloudProvider = string(*d.CloudProvider) } if d.Region != nil { region = *d.Region diff --git a/cloud/deployment/deployment_test.go b/cloud/deployment/deployment_test.go index c812a3f74..1695947fd 100644 --- a/cloud/deployment/deployment_test.go +++ b/cloud/deployment/deployment_test.go @@ -72,7 +72,7 @@ var ( dedicatedType = astroplatformcore.DeploymentTypeDEDICATED hybridType = astroplatformcore.DeploymentTypeHYBRID testRegion = "region" - testProvider = "provider" + testProvider = astroplatformcore.DeploymentCloudProviderGCP testCluster = "cluster" testWorkloadIdentity = "test-workload-identity" mockCoreDeploymentResponse = []astroplatformcore.Deployment{ @@ -862,7 +862,7 @@ func TestCreate(t *testing.T) { testUtil.InitTestConfig(testUtil.LocalPlatform) csID := "test-cluster-id" var ( - cloudProvider = "test-provider" + cloudProvider = astroplatformcore.DeploymentCloudProviderAWS mockCreateDeploymentResponse = astroplatformcore.CreateDeploymentResponse{ JSON200: &astroplatformcore.Deployment{ Id: "test-id", @@ -1324,7 +1324,7 @@ func TestCanCiCdDeploy(t *testing.T) { func TestUpdate(t *testing.T) { //nolint testUtil.InitTestConfig(testUtil.LocalPlatform) - cloudProvider := "test-provider" + cloudProvider := astroplatformcore.DeploymentCloudProviderAZURE astroMachine := "test-machine" nodeID := "test-id" varValue := "VALUE" @@ -1873,13 +1873,14 @@ func TestUpdateDeploymentHibernationOverride(t *testing.T) { for _, tt := range tests { t.Run(tt.command, func(t *testing.T) { + isActive := true mockResponse := astroplatformcore.UpdateDeploymentHibernationOverrideResponse{ HTTPResponse: &http.Response{ StatusCode: astrocore.HTTPStatus200, }, JSON200: &astroplatformcore.DeploymentHibernationOverride{ - IsHibernating: tt.IsHibernating, - IsActive: true, + IsHibernating: &tt.IsHibernating, + IsActive: &isActive, }, } @@ -1897,14 +1898,15 @@ func TestUpdateDeploymentHibernationOverride(t *testing.T) { t.Run(fmt.Sprintf("%s with OverrideUntil", tt.command), func(t *testing.T) { overrideUntil := time.Now().Add(time.Hour) + isActive := true mockResponse := astroplatformcore.UpdateDeploymentHibernationOverrideResponse{ HTTPResponse: &http.Response{ StatusCode: astrocore.HTTPStatus200, }, JSON200: &astroplatformcore.DeploymentHibernationOverride{ - IsHibernating: tt.IsHibernating, + IsHibernating: &tt.IsHibernating, OverrideUntil: &overrideUntil, - IsActive: true, + IsActive: &isActive, }, } diff --git a/cloud/deployment/deployment_variable_test.go b/cloud/deployment/deployment_variable_test.go index 3f94f4ee1..afd76eee2 100644 --- a/cloud/deployment/deployment_variable_test.go +++ b/cloud/deployment/deployment_variable_test.go @@ -93,7 +93,7 @@ func TestVariableList(t *testing.T) { func TestVariableModify(t *testing.T) { testUtil.InitTestConfig(testUtil.LocalPlatform) - cloudProvider := "test-provider" + cloudProvider := astroplatformcore.DeploymentCloudProviderGCP mockUpdateDeploymentResponse := astroplatformcore.UpdateDeploymentResponse{ JSON200: &astroplatformcore.Deployment{ Id: "test-id", diff --git a/cloud/deployment/fromfile/fromfile_test.go b/cloud/deployment/fromfile/fromfile_test.go index d0a6538f4..96548a7ba 100644 --- a/cloud/deployment/fromfile/fromfile_test.go +++ b/cloud/deployment/fromfile/fromfile_test.go @@ -36,7 +36,7 @@ var ( highAvailability = true isDevelopmentMode = true region = "test-region" - cloudProvider = "aws" + cloudProvider = astroplatformcore.DeploymentCloudProviderAWS description = "description 1" schedulerAU = 5 schedulerTestSize = astroplatformcore.DeploymentSchedulerSizeSMALL diff --git a/cloud/deployment/inspect/inspect_test.go b/cloud/deployment/inspect/inspect_test.go index 36e810e50..db9837312 100644 --- a/cloud/deployment/inspect/inspect_test.go +++ b/cloud/deployment/inspect/inspect_test.go @@ -143,7 +143,7 @@ var ( defaultTaskPodMemory = "defaultTaskPodMemory" resourceQuotaCPU = "resourceQuotaCPU" resourceQuotaMemory = "ResourceQuotaMemory" - cloudProvider = "cloud-provider" + cloudProvider = astroplatformcore.DeploymentCloudProviderAWS schedulerTestSize = astroplatformcore.DeploymentSchedulerSizeSMALL hibernationDescription = "hibernation schedule 1" hibernationSchedules = []astroplatformcore.DeploymentHibernationSchedule{ @@ -405,7 +405,7 @@ func TestInspect(t *testing.T) { func TestGetDeploymentInspectInfo(t *testing.T) { mockCoreClient := new(astrocore_mocks.ClientWithResponsesInterface) description = "" - cloudProvider := "gcp" + cloudProvider := astroplatformcore.DeploymentCloudProviderGCP sourceDeployment.Description = &description sourceDeployment.CloudProvider = &cloudProvider sourceDeployment.Executor = &executorCelery @@ -450,7 +450,7 @@ func TestGetDeploymentConfig(t *testing.T) { t.Run("returns deployment config for the requested cloud deployment", func(t *testing.T) { sourceDeployment.Type = &hybridType sourceDeployment.WorkloadIdentity = &workloadIdentity - cloudProvider := "aws" + cloudProvider := astroplatformcore.DeploymentCloudProviderAWS sourceDeployment.CloudProvider = &cloudProvider var actualDeploymentConfig deploymentConfig testUtil.InitTestConfig(testUtil.LocalPlatform) @@ -466,7 +466,7 @@ func TestGetDeploymentConfig(t *testing.T) { Executor: string(*sourceDeployment.Executor), Region: *sourceDeployment.Region, DeploymentType: string(*sourceDeployment.Type), - CloudProvider: *sourceDeployment.CloudProvider, + CloudProvider: string(*sourceDeployment.CloudProvider), IsDevelopmentMode: *sourceDeployment.IsDevelopmentMode, } rawDeploymentConfig, err := getDeploymentConfig(&sourceDeployment, mockPlatformCoreClient) @@ -483,7 +483,7 @@ func TestGetDeploymentConfig(t *testing.T) { sourceDeployment.Type = &standardType taskPodNodePoolID := "task_node_id" sourceDeployment.TaskPodNodePoolId = &taskPodNodePoolID - cloudProvider := "azure" + cloudProvider := astroplatformcore.DeploymentCloudProviderAZURE sourceDeployment.CloudProvider = &cloudProvider var actualDeploymentConfig deploymentConfig testUtil.InitTestConfig(testUtil.LocalPlatform) @@ -499,7 +499,7 @@ func TestGetDeploymentConfig(t *testing.T) { Executor: string(*sourceDeployment.Executor), Region: *sourceDeployment.Region, DeploymentType: string(*sourceDeployment.Type), - CloudProvider: *sourceDeployment.CloudProvider, + CloudProvider: string(*sourceDeployment.CloudProvider), DefaultTaskPodCPU: *sourceDeployment.DefaultTaskPodCpu, DefaultTaskPodMemory: *sourceDeployment.DefaultTaskPodMemory, ResourceQuotaCPU: *sourceDeployment.ResourceQuotaCpu, @@ -703,7 +703,7 @@ func TestFormatPrintableDeployment(t *testing.T) { description = "description" sourceDeployment2.Description = &description empty := "" - sourceDeployment2.CloudProvider = &empty + sourceDeployment2.CloudProvider = nil sourceDeployment2.Region = &empty info, _ := getDeploymentInfo(sourceDeployment2) @@ -782,7 +782,7 @@ func TestFormatPrintableDeployment(t *testing.T) { sourceDeployment2.WebServerUrl = "some-url" sourceDeployment2.UpdatedAt = time.Date(2023, time.February, 1, 12, 0, 0, 0, time.UTC) sourceDeployment2.CreatedAt = time.Date(2023, time.February, 1, 12, 0, 0, 0, time.UTC) - provider := "azure" + provider := astroplatformcore.DeploymentCloudProviderAZURE sourceDeployment2.CloudProvider = &provider sourceDeployment2.ImageTag = "some-tag" sourceDeployment2.Status = "UNHEALTHY" @@ -825,7 +825,7 @@ func TestFormatPrintableDeployment(t *testing.T) { scheduler_count: 3 workspace_name: test-ws deployment_type: STANDARD - cloud_provider: azure + cloud_provider: AZURE region: us-central1 default_task_pod_cpu: "1" default_task_pod_memory: "1" @@ -872,7 +872,7 @@ func TestFormatPrintableDeployment(t *testing.T) { description = "description" sourceDeployment2.Description = &description empty := "" - sourceDeployment2.CloudProvider = &empty + sourceDeployment2.CloudProvider = nil sourceDeployment2.Region = &empty info, _ := getDeploymentInfo(sourceDeployment2) @@ -974,7 +974,7 @@ func TestFormatPrintableDeployment(t *testing.T) { sourceDeployment.Executor = &executorKubernetes sourceDeployment.WorkerQueues = nil empty := "" - sourceDeployment.CloudProvider = &empty + sourceDeployment.CloudProvider = nil sourceDeployment.Region = &empty info, _ := getDeploymentInfo(sourceDeployment) diff --git a/cloud/deployment/workerqueue/workerqueue_test.go b/cloud/deployment/workerqueue/workerqueue_test.go index aafd0de2d..359d6f90b 100644 --- a/cloud/deployment/workerqueue/workerqueue_test.go +++ b/cloud/deployment/workerqueue/workerqueue_test.go @@ -96,7 +96,7 @@ var ( }, } testRegion = "region" - testProvider = "provider" + testProvider = astroplatformcore.DeploymentCloudProviderAWS testCluster = "cluster" mockCoreDeploymentResponse = []astroplatformcore.Deployment{ { @@ -115,7 +115,7 @@ var ( ClusterName: &testCluster, }, } - cloudProvider = "test-provider" + cloudProvider = astroplatformcore.DeploymentCloudProviderAWS mockUpdateDeploymentResponse = astroplatformcore.UpdateDeploymentResponse{ JSON200: &astroplatformcore.Deployment{ Id: "test-id", diff --git a/cmd/cloud/deployment_test.go b/cmd/cloud/deployment_test.go index 3620806bc..a9a5c7bb5 100644 --- a/cmd/cloud/deployment_test.go +++ b/cmd/cloud/deployment_test.go @@ -71,7 +71,7 @@ var ( JSON200: &astroplatformcore.Deployment{ Name: "test-deployment-label", Id: "test-id-1", - CloudProvider: &cloudProvider, + CloudProvider: (*astroplatformcore.DeploymentCloudProvider)(&cloudProvider), Type: &hybridType, ClusterId: &clusterID, Region: ®ion, @@ -112,7 +112,7 @@ var ( SchedulerSize: &schedulerTestSize, Region: ®ion, WorkspaceName: &workspaceName, - CloudProvider: &cloudProvider, + CloudProvider: (*astroplatformcore.DeploymentCloudProvider)(&cloudProvider), DefaultTaskPodCpu: &defaultTaskPodCPU, DefaultTaskPodMemory: &defaultTaskPodMemory, WebServerAirflowApiUrl: "airflow-url", @@ -138,7 +138,7 @@ var ( Status: "HEALTHY", Type: &standardType, Region: &testRegion, - CloudProvider: &testProvider, + CloudProvider: (*astroplatformcore.DeploymentCloudProvider)(&testProvider), WorkspaceName: &workspaceName, IsDevelopmentMode: &developmentModeTest, }, @@ -258,7 +258,7 @@ var ( mockCreateDeploymentResponse = astroplatformcore.CreateDeploymentResponse{ JSON200: &astroplatformcore.Deployment{ Id: "test-id", - CloudProvider: &cloudProvider, + CloudProvider: (*astroplatformcore.DeploymentCloudProvider)(&cloudProvider), Type: &hybridType, Region: ®ion, ClusterName: &cluster.Name, @@ -1047,13 +1047,14 @@ func TestDeploymentHibernateAndWakeUp(t *testing.T) { mockPlatformCoreClient := new(astroplatformcore_mocks.ClientWithResponsesInterface) platformCoreClient = mockPlatformCoreClient + isActive := true mockResponse := astroplatformcore.UpdateDeploymentHibernationOverrideResponse{ HTTPResponse: &http.Response{ StatusCode: astrocore.HTTPStatus200, }, JSON200: &astroplatformcore.DeploymentHibernationOverride{ - IsHibernating: tt.IsHibernating, - IsActive: true, + IsHibernating: &tt.IsHibernating, + IsActive: &isActive, }, } @@ -1076,14 +1077,15 @@ func TestDeploymentHibernateAndWakeUp(t *testing.T) { until := "2022-11-17T13:25:55.275697-08:00" untilParsed, err := time.Parse(time.RFC3339, until) assert.NoError(t, err) + isActive := true mockResponse := astroplatformcore.UpdateDeploymentHibernationOverrideResponse{ HTTPResponse: &http.Response{ StatusCode: astrocore.HTTPStatus200, }, JSON200: &astroplatformcore.DeploymentHibernationOverride{ - IsHibernating: tt.IsHibernating, + IsHibernating: &tt.IsHibernating, OverrideUntil: &untilParsed, - IsActive: true, + IsActive: &isActive, }, } @@ -1113,14 +1115,15 @@ func TestDeploymentHibernateAndWakeUp(t *testing.T) { forDurationParsed, err := time.ParseDuration(forDuration) overrideUntil := time.Now().Add(forDurationParsed) assert.NoError(t, err) + isActive := true mockResponse := astroplatformcore.UpdateDeploymentHibernationOverrideResponse{ HTTPResponse: &http.Response{ StatusCode: astrocore.HTTPStatus200, }, JSON200: &astroplatformcore.DeploymentHibernationOverride{ - IsHibernating: tt.IsHibernating, + IsHibernating: &tt.IsHibernating, OverrideUntil: &overrideUntil, - IsActive: true, + IsActive: &isActive, }, } diff --git a/go.mod b/go.mod index 84ca2527f..40ae34a44 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,6 @@ require ( github.com/golangci/golangci-lint v1.55.2 github.com/google/go-github/v48 v48.2.0 github.com/mitchellh/mapstructure v1.5.0 - github.com/oapi-codegen/runtime v1.1.1 github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b github.com/vektra/mockery/v2 v2.32.0 github.com/whilp/git-urls v1.0.0 diff --git a/go.sum b/go.sum index 301ba739f..26e7be6dd 100644 --- a/go.sum +++ b/go.sum @@ -1081,8 +1081,6 @@ github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYX github.com/nunnatsa/ginkgolinter v0.14.1 h1:khx0CqR5U4ghsscjJ+lZVthp3zjIFytRXPTaQ/TMiyA= github.com/nunnatsa/ginkgolinter v0.14.1/go.mod h1:nY0pafUSst7v7F637e7fymaMlQqI9c0Wka2fGsDkzWg= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/oapi-codegen/runtime v1.1.1 h1:EXLHh0DXIJnWhdRPN2w4MXAzFyE4CskzhNLUmtpMYro= -github.com/oapi-codegen/runtime v1.1.1/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=