Skip to content

Commit

Permalink
Merge branch 'main' into metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
gvicentin committed Jun 10, 2024
2 parents a14f25a + a1adca7 commit b83f8b0
Show file tree
Hide file tree
Showing 24 changed files with 8,945 additions and 311 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version: "1.21"
- uses: golangci/golangci-lint-action@v3
- uses: golangci/golangci-lint-action@v6
with:
version: v1.56
version: v1.59
args: --timeout=10m
- run: make test

integration:
Expand All @@ -21,8 +22,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 Expand Up @@ -195,9 +196,9 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version: "1.21"
- uses: goreleaser/goreleaser-action@v4
- uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --rm-dist
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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

0 comments on commit b83f8b0

Please sign in to comment.