Skip to content

Commit 28681f4

Browse files
committed
Remove deprecated auto-login flags
Remove support for deprecated auto-login controller flags: - --aws-autologin-for-ecr - --gcp-autologin-for-gcr - --azure-autologin-for-acr These flags have been deprecated since v0.25.0 and users should migrate to using the .spec.provider field in ImageRepository objects. The following changes are made: - Remove flag definitions and variables from main.go - Remove DeprecatedLoginOpts field from ImageRepositoryReconciler - Remove deprecated login options handling from registry options - Clean up unused imports (errors, aws, azure, gcp packages) - Clarify switch statement logic for provider auto-login Breaking change: Auto-login flags no longer work and will cause the controller to fail with "flag provided but not defined" error. Users must update their ImageRepository objects to use .spec.provider. Signed-off-by: cappyzawa <[email protected]>
1 parent fc95ba9 commit 28681f4

File tree

3 files changed

+15
-50
lines changed

3 files changed

+15
-50
lines changed

internal/controller/imagerepository_controller.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ type ImageRepositoryReconciler struct {
111111
DatabaseWriter
112112
DatabaseReader
113113
}
114-
DeprecatedLoginOpts []auth.Provider
115-
AuthOptionsGetter *registry.AuthOptionsGetter
114+
AuthOptionsGetter *registry.AuthOptionsGetter
116115

117116
patchOptions []patch.Option
118117
}
@@ -270,7 +269,7 @@ func (r *ImageRepositoryReconciler) reconcile(ctx context.Context, sp *patch.Ser
270269
Namespace: obj.GetNamespace(),
271270
Operation: cache.OperationReconcile,
272271
}
273-
opts, err := r.AuthOptionsGetter.GetOptions(ctx, obj, involvedObject, r.DeprecatedLoginOpts...)
272+
opts, err := r.AuthOptionsGetter.GetOptions(ctx, obj, involvedObject)
274273
if err != nil {
275274
e := fmt.Errorf("failed to configure authentication options: %w", err)
276275
conditions.MarkFalse(obj, meta.ReadyCondition, imagev1.AuthenticationFailedReason, "%s", e)

internal/registry/options.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type AuthOptionsGetter struct {
5757
}
5858

5959
func (r *AuthOptionsGetter) GetOptions(ctx context.Context, repo *imagev1.ImageRepository,
60-
involvedObject *cache.InvolvedObject, deprecatedLoginOpts ...auth.Provider) ([]remote.Option, error) {
60+
involvedObject *cache.InvolvedObject) ([]remote.Option, error) {
6161
timeout := repo.GetTimeout()
6262
ctx, cancel := context.WithTimeout(ctx, timeout)
6363
defer cancel()
@@ -104,9 +104,10 @@ func (r *AuthOptionsGetter) GetOptions(ctx context.Context, repo *imagev1.ImageR
104104
if proxyURL != nil {
105105
opts = append(opts, auth.WithProxyURL(*proxyURL))
106106
}
107+
// Auto-login is only supported for specific cloud providers
107108
switch provider := repo.GetProvider(); provider {
108109
case aws.ProviderName, azure.ProviderName, gcp.ProviderName:
109-
// Support new features (service account and cache) only for non-deprecated code paths.
110+
// Cloud provider auto-login with service account and cache support
110111
if repo.Spec.ServiceAccountName != "" {
111112
serviceAccount := client.ObjectKey{
112113
Name: repo.Spec.ServiceAccountName,
@@ -118,15 +119,10 @@ func (r *AuthOptionsGetter) GetOptions(ctx context.Context, repo *imagev1.ImageR
118119
opts = append(opts, auth.WithCache(*r.TokenCache, *involvedObject))
119120
}
120121
authenticator, authErr = authutils.GetArtifactRegistryCredentials(ctx, provider, repo.Spec.Image, opts...)
122+
case "generic":
123+
// No auto-login for generic provider
121124
default:
122-
// Handle deprecated auto-login controller flags.
123-
for _, provider := range deprecatedLoginOpts {
124-
if _, err := provider.ParseArtifactRepository(repo.Spec.Image); err == nil {
125-
authenticator, authErr = authutils.GetArtifactRegistryCredentials(ctx,
126-
provider.GetName(), repo.Spec.Image, opts...)
127-
break
128-
}
129-
}
125+
// Unknown provider - no auto-login (maintains backward compatibility)
130126
}
131127
}
132128
if authErr != nil {

main.go

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package main
1818

1919
import (
20-
"errors"
2120
"fmt"
2221
"os"
2322
"time"
@@ -38,9 +37,6 @@ import (
3837
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3938

4039
"github.com/fluxcd/pkg/auth"
41-
"github.com/fluxcd/pkg/auth/aws"
42-
"github.com/fluxcd/pkg/auth/azure"
43-
"github.com/fluxcd/pkg/auth/gcp"
4440
pkgcache "github.com/fluxcd/pkg/cache"
4541
"github.com/fluxcd/pkg/runtime/acl"
4642
"github.com/fluxcd/pkg/runtime/client"
@@ -96,9 +92,6 @@ func main() {
9692
storageValueLogFileSize int64
9793
gcInterval uint16 // max value is 65535 minutes (~ 45 days) which is well under the maximum time.Duration
9894
concurrent int
99-
awsAutoLogin bool
100-
gcpAutoLogin bool
101-
azureAutoLogin bool
10295
aclOptions acl.Options
10396
rateLimiterOptions helper.RateLimiterOptions
10497
featureGates feathelper.FeatureGates
@@ -113,11 +106,6 @@ func main() {
113106
flag.Uint16Var(&gcInterval, "gc-interval", 10, "The number of minutes to wait between garbage collections. 0 disables the garbage collector.")
114107
flag.IntVar(&concurrent, "concurrent", 4, "The number of concurrent resource reconciles.")
115108

116-
// NOTE: Deprecated flags.
117-
flag.BoolVar(&awsAutoLogin, "aws-autologin-for-ecr", false, "(AWS) Attempt to get credentials for images in Elastic Container Registry, when no secret is referenced")
118-
flag.BoolVar(&gcpAutoLogin, "gcp-autologin-for-gcr", false, "(GCP) Attempt to get credentials for images in Google Container Registry, when no secret is referenced")
119-
flag.BoolVar(&azureAutoLogin, "azure-autologin-for-acr", false, "(Azure) Attempt to get credentials for images in Azure Container Registry, when no secret is referenced")
120-
121109
clientOptions.BindFlags(flag.CommandLine)
122110
logOptions.BindFlags(flag.CommandLine)
123111
leaderElectionOptions.BindFlags(flag.CommandLine)
@@ -131,12 +119,6 @@ func main() {
131119

132120
logger.SetLogger(logger.NewLogger(logOptions))
133121

134-
if awsAutoLogin || gcpAutoLogin || azureAutoLogin {
135-
setupLog.Error(errors.New("use of deprecated flags"),
136-
"autologin flags have been deprecated. These flags will be removed in a future release."+
137-
" Please update the respective ImageRepository objects with .spec.provider field.")
138-
}
139-
140122
if err := featureGates.WithLogger(setupLog).SupportedFeatures(features.FeatureGates()); err != nil {
141123
setupLog.Error(err, "unable to load feature gates")
142124
os.Exit(1)
@@ -265,31 +247,19 @@ func main() {
265247
}
266248
}
267249

268-
var deprecatedLoginOpts []auth.Provider
269-
if awsAutoLogin {
270-
deprecatedLoginOpts = append(deprecatedLoginOpts, aws.Provider{})
271-
}
272-
if azureAutoLogin {
273-
deprecatedLoginOpts = append(deprecatedLoginOpts, azure.Provider{})
274-
}
275-
if gcpAutoLogin {
276-
deprecatedLoginOpts = append(deprecatedLoginOpts, gcp.Provider{})
277-
}
278-
279250
authOptionsGetter := &registry.AuthOptionsGetter{
280251
Client: mgr.GetClient(),
281252
TokenCache: tokenCache,
282253
}
283254

284255
if err := (&controller.ImageRepositoryReconciler{
285-
Client: mgr.GetClient(),
286-
EventRecorder: eventRecorder,
287-
Metrics: metricsH,
288-
Database: db,
289-
ControllerName: controllerName,
290-
TokenCache: tokenCache,
291-
AuthOptionsGetter: authOptionsGetter,
292-
DeprecatedLoginOpts: deprecatedLoginOpts,
256+
Client: mgr.GetClient(),
257+
EventRecorder: eventRecorder,
258+
Metrics: metricsH,
259+
Database: db,
260+
ControllerName: controllerName,
261+
TokenCache: tokenCache,
262+
AuthOptionsGetter: authOptionsGetter,
293263
}).SetupWithManager(mgr, controller.ImageRepositoryReconcilerOptions{
294264
RateLimiter: helper.GetRateLimiter(rateLimiterOptions),
295265
}); err != nil {

0 commit comments

Comments
 (0)