Skip to content

Commit 4708dcd

Browse files
authored
Merge branch 'master' into master
2 parents 7a77ee2 + ef8d03c commit 4708dcd

File tree

14 files changed

+313
-177
lines changed

14 files changed

+313
-177
lines changed

applicationset/services/pull_request/bitbucket_server.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
bitbucketv1 "github.com/gfleury/go-bitbucket-v1"
99
log "github.com/sirupsen/logrus"
1010

11-
"github.com/argoproj/argo-cd/v3/applicationset/utils"
11+
"github.com/argoproj/argo-cd/v3/applicationset/services"
1212
)
1313

1414
type BitbucketService struct {
@@ -49,15 +49,10 @@ func NewBitbucketServiceNoAuth(ctx context.Context, url, projectKey, repositoryS
4949
}
5050

5151
func newBitbucketService(ctx context.Context, bitbucketConfig *bitbucketv1.Configuration, projectKey, repositorySlug string, scmRootCAPath string, insecure bool, caCerts []byte) (PullRequestService, error) {
52-
bitbucketConfig.BasePath = utils.NormalizeBitbucketBasePath(bitbucketConfig.BasePath)
53-
tlsConfig := utils.GetTlsConfig(scmRootCAPath, insecure, caCerts)
54-
bitbucketConfig.HTTPClient = &http.Client{Transport: &http.Transport{
55-
TLSClientConfig: tlsConfig,
56-
}}
57-
bitbucketClient := bitbucketv1.NewAPIClient(ctx, bitbucketConfig)
52+
bbClient := services.SetupBitbucketClient(ctx, bitbucketConfig, scmRootCAPath, insecure, caCerts)
5853

5954
return &BitbucketService{
60-
client: bitbucketClient,
55+
client: bbClient,
6156
projectKey: projectKey,
6257
repositorySlug: repositorySlug,
6358
}, nil

applicationset/services/scm_provider/bitbucket_server.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
bitbucketv1 "github.com/gfleury/go-bitbucket-v1"
1111
log "github.com/sirupsen/logrus"
1212

13-
"github.com/argoproj/argo-cd/v3/applicationset/utils"
13+
"github.com/argoproj/argo-cd/v3/applicationset/services"
1414
)
1515

1616
type BitbucketServerProvider struct {
@@ -49,15 +49,10 @@ func NewBitbucketServerProviderNoAuth(ctx context.Context, url, projectKey strin
4949
}
5050

5151
func newBitbucketServerProvider(ctx context.Context, bitbucketConfig *bitbucketv1.Configuration, projectKey string, allBranches bool, scmRootCAPath string, insecure bool, caCerts []byte) (*BitbucketServerProvider, error) {
52-
bitbucketConfig.BasePath = utils.NormalizeBitbucketBasePath(bitbucketConfig.BasePath)
53-
tlsConfig := utils.GetTlsConfig(scmRootCAPath, insecure, caCerts)
54-
bitbucketConfig.HTTPClient = &http.Client{Transport: &http.Transport{
55-
TLSClientConfig: tlsConfig,
56-
}}
57-
bitbucketClient := bitbucketv1.NewAPIClient(ctx, bitbucketConfig)
52+
bbClient := services.SetupBitbucketClient(ctx, bitbucketConfig, scmRootCAPath, insecure, caCerts)
5853

5954
return &BitbucketServerProvider{
60-
client: bitbucketClient,
55+
client: bbClient,
6156
projectKey: projectKey,
6257
allBranches: allBranches,
6358
}, nil

applicationset/services/util.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package services
2+
3+
import (
4+
"context"
5+
"net/http"
6+
7+
bitbucketv1 "github.com/gfleury/go-bitbucket-v1"
8+
9+
"github.com/argoproj/argo-cd/v3/applicationset/utils"
10+
)
11+
12+
// SetupBitbucketClient configures and creates a Bitbucket API client with TLS settings
13+
func SetupBitbucketClient(ctx context.Context, config *bitbucketv1.Configuration, scmRootCAPath string, insecure bool, caCerts []byte) *bitbucketv1.APIClient {
14+
config.BasePath = utils.NormalizeBitbucketBasePath(config.BasePath)
15+
tlsConfig := utils.GetTlsConfig(scmRootCAPath, insecure, caCerts)
16+
17+
transport := http.DefaultTransport.(*http.Transport).Clone()
18+
transport.TLSClientConfig = tlsConfig
19+
config.HTTPClient = &http.Client{Transport: transport}
20+
21+
return bitbucketv1.NewAPIClient(ctx, config)
22+
}

applicationset/services/util_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package services
2+
3+
import (
4+
"context"
5+
"crypto/tls"
6+
"net/http"
7+
"testing"
8+
"time"
9+
10+
bitbucketv1 "github.com/gfleury/go-bitbucket-v1"
11+
"github.com/stretchr/testify/require"
12+
)
13+
14+
func TestSetupBitbucketClient(t *testing.T) {
15+
ctx := context.Background()
16+
cfg := &bitbucketv1.Configuration{}
17+
18+
// Act
19+
client := SetupBitbucketClient(ctx, cfg, "", false, nil)
20+
21+
// Assert
22+
require.NotNil(t, client, "expected client to be created")
23+
require.NotNil(t, cfg.HTTPClient, "expected HTTPClient to be set")
24+
25+
// The transport should be a clone of DefaultTransport
26+
tr, ok := cfg.HTTPClient.Transport.(*http.Transport)
27+
require.True(t, ok, "expected HTTPClient.Transport to be *http.Transport")
28+
require.NotSame(t, http.DefaultTransport, tr, "transport should be a clone, not the global DefaultTransport")
29+
30+
// Ensure TLSClientConfig is set
31+
require.IsType(t, &tls.Config{}, tr.TLSClientConfig)
32+
33+
// Defaults from http.DefaultTransport.Clone() should be preserved
34+
require.Greater(t, tr.IdleConnTimeout, time.Duration(0), "IdleConnTimeout should be non-zero")
35+
require.Positive(t, tr.MaxIdleConns, "MaxIdleConns should be non-zero")
36+
require.Greater(t, tr.TLSHandshakeTimeout, time.Duration(0), "TLSHandshakeTimeout should be non-zero")
37+
}

docs/operator-manual/applicationset/Progressive-Syncs.md

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,30 @@ As an experimental feature, progressive syncs must be explicitly enabled, in one
2121

2222
## Strategies
2323

24-
* AllAtOnce (default)
25-
* RollingSync
24+
ApplicationSet strategies control both how applications are created (or updated) and deleted. These operations are configured using two separate fields:
2625

27-
### AllAtOnce
26+
* **Creation Strategy** (`type` field): Controls application creation and updates
27+
* **Deletion Strategy** (`deletionOrder` field): Controls application deletion order
28+
29+
### Creation Strategies
30+
31+
The `type` field controls how applications are created and updated. Available values:
32+
33+
* **AllAtOnce** (default)
34+
* **RollingSync**
35+
36+
#### AllAtOnce
2837
This default Application update behavior is unchanged from the original ApplicationSet implementation.
2938

3039
All Applications managed by the ApplicationSet resource are updated simultaneously when the ApplicationSet is updated.
3140

32-
### RollingSync
41+
```yaml
42+
spec:
43+
strategy:
44+
type: AllAtOnce # explicit, but this is the default
45+
```
46+
47+
#### RollingSync
3348
This update strategy allows you to group Applications by labels present on the generated Application resources.
3449
When the ApplicationSet changes, the changes will be applied to each group of Application resources sequentially.
3550
@@ -46,6 +61,78 @@ When the ApplicationSet changes, the changes will be applied to each group of Ap
4661
* If an Application is considered "Pending" for `applicationsetcontroller.default.application.progressing.timeout` seconds, the Application is automatically moved to Healthy status (default 300).
4762
* If an Application is not selected in any step, it will be excluded from the rolling sync and needs to be manually synced through the CLI or UI.
4863

64+
```yaml
65+
spec:
66+
strategy:
67+
type: RollingSync
68+
rollingSync:
69+
steps:
70+
- matchExpressions:
71+
- key: envLabel
72+
operator: In
73+
values:
74+
- env-dev
75+
- matchExpressions:
76+
- key: envLabel
77+
operator: In
78+
values:
79+
- env-prod
80+
maxUpdate: 10%
81+
```
82+
83+
### Deletion Strategies
84+
85+
The `deletionOrder` field controls the order in which applications are deleted when they are removed from the ApplicationSet. Available values:
86+
87+
* **AllAtOnce** (default)
88+
* **Reverse**
89+
90+
#### AllAtOnce Deletion
91+
This is the default behavior where all applications that need to be deleted are removed simultaneously. This works with both `AllAtOnce` and `RollingSync` creation strategies.
92+
93+
```yaml
94+
spec:
95+
strategy:
96+
type: RollingSync # or AllAtOnce
97+
deletionOrder: AllAtOnce # explicit, but this is the default
98+
```
99+
100+
#### Reverse Deletion
101+
When using `deletionOrder: Reverse` with RollingSync strategy, applications are deleted in reverse order of the steps defined in `rollingSync.steps`. This ensures that applications deployed in later steps are deleted before applications deployed in earlier steps.
102+
This strategy is particularly useful when you need to tear down dependent services in the particular sequence.
103+
104+
**Requirements for Reverse deletion:**
105+
- Must be used with `type: RollingSync`
106+
- Requires `rollingSync.steps` to be defined
107+
- Applications are deleted in reverse order of step sequence
108+
109+
**Important:** The ApplicationSet finalizer is not removed until all applications are successfully deleted. This ensures proper cleanup and prevents the ApplicationSet from being removed before its managed applications.
110+
111+
```yaml
112+
spec:
113+
strategy:
114+
type: RollingSync
115+
deletionOrder: Reverse
116+
rollingSync:
117+
steps:
118+
- matchExpressions:
119+
- key: envLabel
120+
operator: In
121+
values:
122+
- env-dev # Step 1: Created first, deleted last
123+
- matchExpressions:
124+
- key: envLabel
125+
operator: In
126+
values:
127+
- env-prod # Step 2: Created second, deleted first
128+
```
129+
130+
In this example, when applications are deleted:
131+
1. `env-prod` applications (Step 2) are deleted first
132+
2. `env-dev` applications (Step 1) are deleted second
133+
134+
This deletion order is useful for scenarios where you need to tear down dependent services in the correct sequence, such as deleting frontend services before backend dependencies.
135+
49136
#### Example
50137
The following example illustrates how to stage a progressive sync over Applications with explicitly configured environment labels.
51138

@@ -75,6 +162,7 @@ spec:
75162
env: env-prod
76163
strategy:
77164
type: RollingSync
165+
deletionOrder: Reverse # Applications will be deleted in reverse order of steps
78166
rollingSync:
79167
steps:
80168
- matchExpressions:

docs/operator-manual/rbac.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ spec:
341341
- name: admin
342342
description: Admin privileges to team-beta
343343
policies:
344-
- p, proj:team-beta-project:admin, applications, *, *, allow
344+
- p, proj:team-beta-project:admin, applications, *, team-beta-project/*, allow
345345
groups:
346346
- [email protected] # Value from the email scope
347347
- my-org:team-beta # Value from the groups scope

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ go 1.25.0
55
require (
66
code.gitea.io/sdk/gitea v0.21.0
77
dario.cat/mergo v1.0.2
8-
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.2
9-
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1
8+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.0
9+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.11.0
1010
github.com/Azure/kubelogin v0.2.10
1111
github.com/Masterminds/semver/v3 v3.4.0
1212
github.com/Masterminds/sprig/v3 v3.3.0
@@ -85,7 +85,7 @@ require (
8585
github.com/stretchr/testify v1.10.0
8686
github.com/valyala/fasttemplate v1.2.2
8787
github.com/yuin/gopher-lua v1.1.1
88-
gitlab.com/gitlab-org/api/client-go v0.141.2
88+
gitlab.com/gitlab-org/api/client-go v0.142.0
8989
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0
9090
go.opentelemetry.io/otel v1.37.0
9191
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.36.0

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA=
4444
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
4545
github.com/42wim/httpsig v1.2.2 h1:ofAYoHUNs/MJOLqQ8hIxeyz2QxOz8qdSVvp3PX/oPgA=
4646
github.com/42wim/httpsig v1.2.2/go.mod h1:P/UYo7ytNBFwc+dg35IubuAUIs8zj5zzFIgUCEl55WY=
47-
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.2 h1:Hr5FTipp7SL07o2FvoVOX9HRiRH3CR3Mj8pxqCcdD5A=
48-
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.2/go.mod h1:QyVsSSN64v5TGltphKLQ2sQxe4OBQg0J1eKRcVBnfgE=
49-
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 h1:B+blDbyVIG3WaikNxPnhPiJ1MThR03b3vKGtER95TP4=
50-
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1/go.mod h1:JdM5psgjfBf5fo2uWOZhflPWyDBZ/O/CNAH9CtsuZE4=
47+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.0 h1:ci6Yd6nysBRLEodoziB6ah1+YOzZbZk+NYneoA6q+6E=
48+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.0/go.mod h1:QyVsSSN64v5TGltphKLQ2sQxe4OBQg0J1eKRcVBnfgE=
49+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.11.0 h1:MhRfI58HblXzCtWEZCO0feHs8LweePB3s90r7WaR1KU=
50+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.11.0/go.mod h1:okZ+ZURbArNdlJ+ptXoyHNuOETzOl1Oww19rm8I2WLA=
5151
github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY=
5252
github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8=
5353
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.2 h1:9iefClla7iYpfYWdzPCRDozdmndjTm8DXdpCzPajMgA=
@@ -897,8 +897,8 @@ github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd
897897
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
898898
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
899899
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
900-
gitlab.com/gitlab-org/api/client-go v0.141.2 h1:Ijlg+4sYV6WQgiw7rbNHYdHqrnt+bR0CTOm7u5n243M=
901-
gitlab.com/gitlab-org/api/client-go v0.141.2/go.mod h1:3YuWlZCirs2TTcaAzM6qNwVHB7WvV67ATb0GGpBCdlQ=
900+
gitlab.com/gitlab-org/api/client-go v0.142.0 h1:cR8+RhDc7ooH0SiGNhgm3Nf5ZpW5D1R3DLshfAXJZmQ=
901+
gitlab.com/gitlab-org/api/client-go v0.142.0/go.mod h1:3YuWlZCirs2TTcaAzM6qNwVHB7WvV67ATb0GGpBCdlQ=
902902
go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM=
903903
go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4=
904904
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=

resource_customizations/external-secrets.io/ExternalSecret/actions/action_test.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ actionTests:
22
- action: refresh
33
inputPath: testdata/external-secret.yaml
44
expectedOutputPath: testdata/external-secret-updated.yaml
5+
6+
discoveryTests:
7+
- inputPath: testdata/external-secret.yaml
8+
result:
9+
- name: "refresh"

resource_customizations/external-secrets.io/ExternalSecret/actions/discovery.lua

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ local actions = {}
33
local disable_refresh = false
44
local time_units = {"ns", "us", "µs", "ms", "s", "m", "h"}
55
local digits = obj.spec.refreshInterval
6-
for _, time_unit in ipairs(time_units) do
7-
digits, _ = digits:gsub(time_unit, "")
8-
if tonumber(digits) == 0 then
9-
disable_refresh = true
10-
break
6+
if digits ~= nil then
7+
digits = tostring(digits)
8+
for _, time_unit in ipairs(time_units) do
9+
if digits == "0" or digits == "0" .. time_unit then
10+
disable_refresh = true
11+
break
12+
end
1113
end
1214
end
1315

0 commit comments

Comments
 (0)