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

spec.clusters: Required value 버그 픽스 #382

Merged
merged 1 commit into from
Apr 16, 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
8 changes: 7 additions & 1 deletion internal/policy-template/policy-operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ func PolicyToTksPolicyCR(policy *model.Policy) *TKSPolicy {
}
}

targetClusterIds := make([]string, 0)

if policy.TargetClusterIds != nil {
targetClusterIds = policy.TargetClusterIds
}

return &TKSPolicy{
TypeMeta: metav1.TypeMeta{
APIVersion: "tkspolicy.openinfradev.github.io/v1",
Expand All @@ -63,7 +69,7 @@ func PolicyToTksPolicyCR(policy *model.Policy) *TKSPolicy {

Spec: TKSPolicySpec{
EnforcementAction: policy.EnforcementAction,
Clusters: policy.TargetClusterIds,
Clusters: targetClusterIds,
Template: policy.PolicyTemplate.Kind,
Match: policy.Match,
Params: params,
Expand Down
18 changes: 9 additions & 9 deletions internal/usecase/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ func (u *PolicyUsecase) ListStackPolicyStatus(ctx context.Context, clusterId str
// result[i].TemplateCurrentVersion = version
// }

result[i].TemplateLatestVerson = latestVersion
result[i].TemplateLatestVersion = latestVersion
result[i].TemplateDescription = policy.PolicyTemplate.Description
}

Expand Down Expand Up @@ -711,14 +711,14 @@ func (u *PolicyUsecase) GetStackPolicyTemplateStatus(ctx context.Context, cluste
}

result := domain.GetStackPolicyTemplateStatusResponse{
TemplateName: currentTemplate.TemplateName,
TemplateId: policyTemplateId.String(),
TemplateDescription: currentTemplate.Description,
TemplateLatestVerson: latestTemplate.Version,
TemplateCurrentVersion: currentTemplate.Version,
TemplateLatestVersonReleaseDate: latestTemplate.CreatedAt,
AffectedPolicies: affectedPolicies,
UpdatedPolicyParameters: updatedPolicyParameters,
TemplateName: currentTemplate.TemplateName,
TemplateId: policyTemplateId.String(),
TemplateDescription: currentTemplate.Description,
TemplateLatestVersion: latestTemplate.Version,
TemplateCurrentVersion: currentTemplate.Version,
TemplateLatestVersionReleaseDate: latestTemplate.CreatedAt,
AffectedPolicies: affectedPolicies,
UpdatedPolicyParameters: updatedPolicyParameters,
}

return &result, nil
Expand Down
20 changes: 10 additions & 10 deletions pkg/domain/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,23 @@ type StackPolicyStatusResponse struct {
TemplateId string `json:"templateId" example:"708d1e5b-4e6f-40e9-87a3-329e2fd051a5"`
TemplateDescription string `json:"templateDescription" example:"파라미터로 설정된 레이블 검사"`
TemplateCurrentVersion string `json:"templateCurrentVersion" example:"v1.0.1"`
TemplateLatestVerson string `json:"templateLatestVerson" example:"v1.0.3"`
TemplateLatestVersion string `json:"templateLatestVersion" example:"v1.0.3"`
}

type ListStackPolicyStatusResponse struct {
Polices []StackPolicyStatusResponse `json:"polices"`
}

type GetStackPolicyTemplateStatusResponse struct {
TemplateName string `json:"templateName" example:"레이블 요구"`
TemplateId string `json:"templateId" example:"708d1e5b-4e6f-40e9-87a3-329e2fd051a5"`
TemplateDescription string `json:"templateDescription" example:"파라미터로 설정된 레이블 검사"`
TemplateMandatory bool `json:"templateMandatory"`
TemplateCurrentVersion string `json:"templateCurrentVersion" example:"v1.0.1"`
TemplateLatestVerson string `json:"templateLatestVerson" example:"v1.0.3"`
TemplateLatestVersonReleaseDate time.Time `json:"templateLatestVersonReleaseDate" format:"date-time"`
UpdatedPolicyParameters []UpdatedPolicyTemplateParameter `json:"updatedPolicyParameters"`
AffectedPolicies []PolicyStatus `json:"affectedPolicies"`
TemplateName string `json:"templateName" example:"레이블 요구"`
TemplateId string `json:"templateId" example:"708d1e5b-4e6f-40e9-87a3-329e2fd051a5"`
TemplateDescription string `json:"templateDescription" example:"파라미터로 설정된 레이블 검사"`
TemplateMandatory bool `json:"templateMandatory"`
TemplateCurrentVersion string `json:"templateCurrentVersion" example:"v1.0.1"`
TemplateLatestVersion string `json:"templateLatestVersion" example:"v1.0.3"`
TemplateLatestVersionReleaseDate time.Time `json:"templateLatestVersionReleaseDate" format:"date-time"`
UpdatedPolicyParameters []UpdatedPolicyTemplateParameter `json:"updatedPolicyParameters"`
AffectedPolicies []PolicyStatus `json:"affectedPolicies"`
}

type PolicyStatus struct {
Expand Down
Loading