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

API of validation #148

Merged
merged 23 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 22 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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
go-version: "1.21"
- uses: golangci/golangci-lint-action@v3
with:
version: v1.56
version: v1.58
- run: make test

integration:
Expand All @@ -21,8 +21,8 @@ jobs:
fail-fast: true
matrix:
k8s_version:
- 1.24.13 # current version at GKE stable channel (https://cloud.google.com/kubernetes-engine/docs/release-notes#current_versions)
- 1.25.8 # current version at GKE regular channel (https://cloud.google.com/kubernetes-engine/docs/release-notes#current_versions)
- 1.27.11 # current version at GKE stable channel (https://cloud.google.com/kubernetes-engine/docs/release-notes#current_versions)
- 1.28.7 # current version at GKE regular channel (https://cloud.google.com/kubernetes-engine/docs/release-notes#current_versions)
steps:
- uses: actions/checkout@master
- name: Running up Kubernetes (using Minikube)
Expand Down
16 changes: 15 additions & 1 deletion api/v1alpha1/rpaasinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import (
)

const (
DefaultLabelKeyPrefix = "rpaas.extensions.tsuru.io"
DefaultLabelKeyPrefix = "rpaas.extensions.tsuru.io"

RpaasOperatorValidationNameLabelKey = DefaultLabelKeyPrefix + "/validation-name"
RpaasOperatorValidationHashAnnotationKey = DefaultLabelKeyPrefix + "/validation-hash"

RpaasOperatorInstanceNameLabelKey = DefaultLabelKeyPrefix + "/instance-name"
RpaasOperatorServiceNameLabelKey = DefaultLabelKeyPrefix + "/service-name"
RpaasOperatorPlanNameLabelKey = DefaultLabelKeyPrefix + "/plan-name"
Expand Down Expand Up @@ -123,3 +127,13 @@ func mergeMap(a, b map[string]string) map[string]string {
}
return a
}

func (i *RpaasValidation) BelongsToCluster(clusterName string) bool {
instanceCluster := i.Labels[RpaasOperatorClusterNameLabelKey]

if instanceCluster == "" {
return false
}

return clusterName == instanceCluster
}
50 changes: 50 additions & 0 deletions api/v1alpha1/rpaasvalidation_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright 2024 tsuru authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +kubebuilder:object:root=true
// +kubebuilder:resource:shortName=rpaas-validation
// +kubebuilder:subresource:status
// RpaasInstance is the Schema for the rpaasinstances API
type RpaasValidation struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Status RpaasValidationStatus `json:"status,omitempty"`
// Spec reuse the same properties of RpaasInstance, just to avoid duplication of code
Spec RpaasInstanceSpec `json:"spec,omitempty"`
}

// RpaasValidationStatus defines the observed state of RpaasValidation
type RpaasValidationStatus struct {
//Revision hash calculated for the current spec of rpaasvalidation
RevisionHash string `json:"revisionHash,omitempty"`

// The most recent generation observed by the rpaas operator controller.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// Valid determines whether validation is valid
Valid *bool `json:"valid,omitempty"`

// Feedback of validation of nginx
Error string `json:"error,omitempty"`
}

// +kubebuilder:object:root=true

// RpaasValidationList contains a list of RpaasInstance
type RpaasValidationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []RpaasValidation `json:"items"`
}

func init() {
SchemeBuilder.Register(&RpaasValidation{}, &RpaasValidationList{})
}
79 changes: 79 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/plugin/rpaasv2/cmd/autoscale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

"github.com/tsuru/rpaas-operator/pkg/rpaas/client/autogenerated"
)
Expand Down Expand Up @@ -71,7 +71,7 @@ max replicas: 5
Schedules: []autogenerated.ScheduledWindow{
{MinReplicas: 1, Start: "00 08 * * 1-5", End: "00 20 * * 1-5"},
{MinReplicas: 5, Start: "00 20 * * 2", End: "00 01 * * 3"},
{MinReplicas: 5, Start: "00 22 * * 0", End: "00 02 * * 1", Timezone: pointer.String("America/Chile")},
{MinReplicas: 5, Start: "00 22 * * 0", End: "00 02 * * 1", Timezone: ptr.To("America/Chile")},
},
})
}),
Expand Down
Loading
Loading