Skip to content

Commit

Permalink
Enhancement: Add support in JWT token refresh with shouldLoopInfinite…
Browse files Browse the repository at this point in the history
…ly and nextReconcile fields (#26)

feat: add support for custom reconcile intervals with shouldLoopInfinitely and nextReconcile fields

- Added `shouldLoopInfinitely` and `nextReconcile` fields to `DisposableRequest` resource.
- Updated the `WithCustomPollIntervalHook` function to handle the new fields.
- Enhanced example `DisposableRequest` definition to demonstrate usage of new fields.
- Updated tests to cover new functionality.
- This change allows for efficient handling of reconciliation intervals and looping behavior.

Signed-off-by: arielsepton <[email protected]>
  • Loading branch information
arielsepton committed Jun 21, 2024
1 parent 9d109d3 commit da9c07e
Show file tree
Hide file tree
Showing 35 changed files with 1,073 additions and 1,386 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:

env:
# Common versions
GO_VERSION: '1.20.2'
GOLANGCI_VERSION: 'v1.51.2'
GO_VERSION: '1.22.3'
GOLANGCI_VERSION: 'v1.55.2'
DOCKER_BUILDX_VERSION: 'v0.8.2'

XPKG_ACCESS_ID: ${{ secrets.XPKG_ACCESS_ID }}
Expand Down Expand Up @@ -309,4 +309,4 @@ jobs:
run: make -j2 publish BRANCH_NAME=${GITHUB_REF##*/}
if: env.XPKG_ACCESS_ID != ''
env:
GIT_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
version:
description: "Release version (e.g. v1.0.1)"
description: "Release version (e.g. v1.0.2)"
required: true
channel:
description: "Release channel"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
version:
description: "Release version (e.g. v1.0.1)"
description: "Release version (e.g. v1.0.2)"
required: true
message:
description: "Tag message"
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "build"]
path = build
url = https://github.com/upbound/build
url = https://github.com/crossplane/build
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ GOLANGCILINT_VERSION = 1.51.2

# ====================================================================================
# Setup Kubernetes tools
KIND_VERSION = v0.18.0
UP_VERSION = v0.17.0
UPTEST_VERSION = v0.5.0
KIND_VERSION = v0.23.0
UP_VERSION = v0.28.0
UPTEST_VERSION = v0.11.1
UP_CHANNEL = stable
USE_HELM3 = true
CROSSPLANE_VERSION = 1.14.6

-include build/makelib/k8s_tools.mk

# ====================================================================================
Expand Down Expand Up @@ -94,7 +96,7 @@ UPTEST_EXAMPLE_LIST := $(shell find ./examples/sample -path '*.yaml' | paste -s

uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
@$(INFO) running automated tests
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e "$(UPTEST_EXAMPLE_LIST)" --setup-script=cluster/test/setup.sh || $(FAIL)
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=$(CROSSPLANE_NAMESPACE) $(UPTEST) e2e "$(UPTEST_EXAMPLE_LIST)" --setup-script=cluster/test/setup.sh || $(FAIL)
@$(OK) running automated tests

local-dev: controlplane.up
Expand Down Expand Up @@ -127,3 +129,6 @@ manifests:
@$(INFO) Deprecated. Run make generate instead.

.PHONY: cobertura submodules fallthrough test-integration run manifests

vendor: modules.download
vendor.check: modules.check
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ To install `provider-http`, you have two options:
1. Using the Crossplane CLI in a Kubernetes cluster where Crossplane is installed:

```console
crossplane xpkg install provider xpkg.upbound.io/crossplane-contrib/provider-http:v1.0.1
crossplane xpkg install provider xpkg.upbound.io/crossplane-contrib/provider-http:v1.0.2
```

2. Manually creating a Provider by applying the following YAML:
Expand All @@ -20,7 +20,7 @@ To install `provider-http`, you have two options:
metadata:
name: provider-http
spec:
package: "xpkg.upbound.io/crossplane-contrib/provider-http:v1.0.1"
package: "xpkg.upbound.io/crossplane-contrib/provider-http:v1.0.2"
```
## Supported Resources
Expand Down
10 changes: 6 additions & 4 deletions apis/disposablerequest/v1alpha1/zz_generated.deepcopy.go

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

28 changes: 6 additions & 22 deletions apis/disposablerequest/v1alpha1/zz_generated.managed.go

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

13 changes: 11 additions & 2 deletions apis/disposablerequest/v1alpha2/disposablerequest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ type DisposableRequestParameters struct {

// ExpectedResponse is a jq filter expression used to evaluate the HTTP response and determine if it matches the expected criteria.
// The expression should return a boolean; if true, the response is considered expected.
// Example: '.Body.job_status == "success"'
// Example: '.body.job_status == "success"'
ExpectedResponse string `json:"expectedResponse,omitempty"`

// SecretInjectionConfig specifies the secrets receiving patches for response data.
// NextReconcile specifies the duration after which the next reconcile should occur.
NextReconcile *metav1.Duration `json:"nextReconcile,omitempty"`

// ShouldLoopInfinitely specifies whether the reconciliation should loop indefinitely.
ShouldLoopInfinitely bool `json:"shouldLoopInfinitely,omitempty"`

// SecretInjectionConfig specifies the secrets receiving patches from response data.
SecretInjectionConfigs []SecretInjectionConfig `json:"secretInjectionConfigs,omitempty"`
}

Expand Down Expand Up @@ -102,6 +108,9 @@ type DisposableRequestStatus struct {
Error string `json:"error,omitempty"`
Synced bool `json:"synced,omitempty"`
RequestDetails Mapping `json:"requestDetails,omitempty"`

// LastReconcileTime records the last time the resource was reconciled.
LastReconcileTime metav1.Time `json:"lastReconcileTime,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
10 changes: 10 additions & 0 deletions apis/disposablerequest/v1alpha2/status_setters.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package v1alpha2

import (
"time"

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

func (d *DisposableRequest) SetStatusCode(statusCode int) {
d.Status.Response.StatusCode = statusCode
}
Expand All @@ -18,6 +24,10 @@ func (d *DisposableRequest) SetSynced(synced bool) {
d.Status.Error = ""
}

func (d *DisposableRequest) SetLastReconcileTime() {
d.Status.LastReconcileTime = metav1.NewTime(time.Now())
}

func (d *DisposableRequest) SetError(err error) {
d.Status.Failed++
d.Status.Synced = true
Expand Down
16 changes: 12 additions & 4 deletions apis/disposablerequest/v1alpha2/zz_generated.deepcopy.go

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

28 changes: 6 additions & 22 deletions apis/disposablerequest/v1alpha2/zz_generated.managed.go

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

10 changes: 6 additions & 4 deletions apis/request/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit da9c07e

Please sign in to comment.