From 3bdea128ad265845b7e657c8905c2011aa4e805e Mon Sep 17 00:00:00 2001 From: Chad Roberts Date: Tue, 15 Aug 2023 12:09:22 -0400 Subject: [PATCH] Fixing names to make ci happy --- cmd/agent/main.go | 11 ++++++----- .../clean/{ad_unmigration => adunmigration}/ldap.go | 13 ++++++------- .../{ad_unmigration => adunmigration}/migrate.go | 2 +- .../clean/{ad_unmigration => adunmigration}/rtbs.go | 9 +++++---- .../{ad_unmigration => adunmigration}/tokens.go | 7 ++++--- .../{ad_unmigration => adunmigration}/users.go | 7 ++++--- pkg/multiclustermanager/app.go | 9 +++++---- 7 files changed, 31 insertions(+), 27 deletions(-) rename pkg/agent/clean/{ad_unmigration => adunmigration}/ldap.go (97%) rename pkg/agent/clean/{ad_unmigration => adunmigration}/migrate.go (99%) rename pkg/agent/clean/{ad_unmigration => adunmigration}/rtbs.go (99%) rename pkg/agent/clean/{ad_unmigration => adunmigration}/tokens.go (99%) rename pkg/agent/clean/{ad_unmigration => adunmigration}/users.go (99%) diff --git a/cmd/agent/main.go b/cmd/agent/main.go index 5328c326200..47a293776fd 100644 --- a/cmd/agent/main.go +++ b/cmd/agent/main.go @@ -24,17 +24,18 @@ import ( "github.com/docker/docker/client" "github.com/hashicorp/go-multierror" "github.com/mattn/go-colorable" + "github.com/rancher/remotedialer" + "github.com/rancher/wrangler/pkg/signals" + "github.com/sirupsen/logrus" + "github.com/rancher/rancher/pkg/agent/clean" - "github.com/rancher/rancher/pkg/agent/clean/ad_unmigration" + "github.com/rancher/rancher/pkg/agent/clean/adunmigration" "github.com/rancher/rancher/pkg/agent/cluster" "github.com/rancher/rancher/pkg/agent/node" "github.com/rancher/rancher/pkg/agent/rancher" "github.com/rancher/rancher/pkg/features" "github.com/rancher/rancher/pkg/logserver" "github.com/rancher/rancher/pkg/rkenodeconfigclient" - "github.com/rancher/remotedialer" - "github.com/rancher/wrangler/pkg/signals" - "github.com/sirupsen/logrus" ) var ( @@ -84,7 +85,7 @@ func main() { } else if os.Getenv("AD_GUID_CLEANUP") == "true" { dryrun := os.Getenv("DRY_RUN") == "true" deleteMissingUsers := os.Getenv("AD_DELETE_MISSING_GUID_USERS") == "true" - err = ad_unmigration.UnmigrateAdGUIDUsers(nil, dryrun, deleteMissingUsers) + err = adunmigration.UnmigrateAdGUIDUsers(nil, dryrun, deleteMissingUsers) } else { err = run(ctx) } diff --git a/pkg/agent/clean/ad_unmigration/ldap.go b/pkg/agent/clean/adunmigration/ldap.go similarity index 97% rename from pkg/agent/clean/ad_unmigration/ldap.go rename to pkg/agent/clean/adunmigration/ldap.go index ad9356b6447..69733e79a7e 100644 --- a/pkg/agent/clean/ad_unmigration/ldap.go +++ b/pkg/agent/clean/adunmigration/ldap.go @@ -1,4 +1,4 @@ -package ad_unmigration +package adunmigration import ( "bytes" @@ -295,7 +295,6 @@ func migrateAllowedUserPrincipals(workunits *[]migrateUserWorkUnit, sc *config.S } // Create an empty unstructured object to hold the decoded JSON - storedADConfig := &unstructured.Unstructured{} storedADConfig, ok := authConfigObj.(*unstructured.Unstructured) if !ok { return fmt.Errorf("[%v] expected unstructured authconfig, got %T", migrateAdUserOperation, authConfigObj) @@ -313,17 +312,17 @@ func migrateAllowedUserPrincipals(workunits *[]migrateUserWorkUnit, sc *config.S } for i, item := range listOfMaybeStrings { - principalId, ok := item.(string) + principalID, ok := item.(string) if !ok { return fmt.Errorf("[%v] expected string for allowed principal id, found instead %T", migrateAdUserOperation, item) } - if j, exists := adWorkUnitsByPrincipal[principalId]; exists { - newPrincipalId := activeDirectoryPrefix + (*workunits)[j].distinguishedName + if j, exists := adWorkUnitsByPrincipal[principalID]; exists { + newPrincipalID := activeDirectoryPrefix + (*workunits)[j].distinguishedName if dryRun { logrus.Infof("[%v] DRY RUN: would migrate allowed user %v to %v", migrateAdUserOperation, - principalId, newPrincipalId) + principalID, newPrincipalID) } else { - listOfMaybeStrings[i] = newPrincipalId + listOfMaybeStrings[i] = newPrincipalID } } } diff --git a/pkg/agent/clean/ad_unmigration/migrate.go b/pkg/agent/clean/adunmigration/migrate.go similarity index 99% rename from pkg/agent/clean/ad_unmigration/migrate.go rename to pkg/agent/clean/adunmigration/migrate.go index da2b2f8e242..f5272336c2e 100644 --- a/pkg/agent/clean/ad_unmigration/migrate.go +++ b/pkg/agent/clean/adunmigration/migrate.go @@ -3,7 +3,7 @@ Look for any active directory users with a GUID type principal. Convert these users to a distinguished name instead. */ -package ad_unmigration +package adunmigration import ( "context" diff --git a/pkg/agent/clean/ad_unmigration/rtbs.go b/pkg/agent/clean/adunmigration/rtbs.go similarity index 99% rename from pkg/agent/clean/ad_unmigration/rtbs.go rename to pkg/agent/clean/adunmigration/rtbs.go index 7e383079d4c..5c35249ba69 100644 --- a/pkg/agent/clean/ad_unmigration/rtbs.go +++ b/pkg/agent/clean/adunmigration/rtbs.go @@ -1,12 +1,13 @@ -package ad_unmigration +package adunmigration import ( "fmt" - v3 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3" - "github.com/rancher/rancher/pkg/types/config" "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + v3 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3" + "github.com/rancher/rancher/pkg/types/config" ) // principalsToMigrate collects workunits whose resources we wish to migrate into two groups: @@ -341,4 +342,4 @@ func migrateGRBs(workunit *migrateUserWorkUnit, sc *config.ScaledContext, dryRun } } return nil -} \ No newline at end of file +} diff --git a/pkg/agent/clean/ad_unmigration/tokens.go b/pkg/agent/clean/adunmigration/tokens.go similarity index 99% rename from pkg/agent/clean/ad_unmigration/tokens.go rename to pkg/agent/clean/adunmigration/tokens.go index 32514acbc91..12edf890a76 100644 --- a/pkg/agent/clean/ad_unmigration/tokens.go +++ b/pkg/agent/clean/adunmigration/tokens.go @@ -1,12 +1,13 @@ -package ad_unmigration +package adunmigration import ( "fmt" - "github.com/rancher/rancher/pkg/auth/tokens" - "github.com/rancher/rancher/pkg/types/config" "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/rancher/rancher/pkg/auth/tokens" + "github.com/rancher/rancher/pkg/types/config" ) func collectTokens(workunits *[]migrateUserWorkUnit, sc *config.ScaledContext) error { diff --git a/pkg/agent/clean/ad_unmigration/users.go b/pkg/agent/clean/adunmigration/users.go similarity index 99% rename from pkg/agent/clean/ad_unmigration/users.go rename to pkg/agent/clean/adunmigration/users.go index 9552d891d5b..a94ce80afa1 100644 --- a/pkg/agent/clean/ad_unmigration/users.go +++ b/pkg/agent/clean/adunmigration/users.go @@ -1,14 +1,15 @@ -package ad_unmigration +package adunmigration import ( "fmt" "strings" "github.com/pkg/errors" - v3 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3" - "github.com/rancher/rancher/pkg/types/config" "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + v3 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3" + "github.com/rancher/rancher/pkg/types/config" ) func describePlannedChanges(workunit migrateUserWorkUnit) { diff --git a/pkg/multiclustermanager/app.go b/pkg/multiclustermanager/app.go index 92b3d4df486..29a97b6f923 100644 --- a/pkg/multiclustermanager/app.go +++ b/pkg/multiclustermanager/app.go @@ -7,10 +7,13 @@ import ( "sync" "time" - "github.com/rancher/rancher/pkg/agent/clean/ad_unmigration" + "github.com/rancher/rancher/pkg/agent/clean/adunmigration" "github.com/pkg/errors" "github.com/rancher/norman/types" + "github.com/sirupsen/logrus" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/rancher/rancher/pkg/auth/providerrefresh" "github.com/rancher/rancher/pkg/auth/providers/common" "github.com/rancher/rancher/pkg/auth/tokens" @@ -30,8 +33,6 @@ import ( "github.com/rancher/rancher/pkg/tunnelserver/mcmauthorizer" "github.com/rancher/rancher/pkg/types/config" "github.com/rancher/rancher/pkg/wrangler" - "github.com/sirupsen/logrus" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) type Options struct { @@ -215,7 +216,7 @@ func (m *mcm) Start(ctx context.Context) error { return errors.Wrap(err, "failed to telemetry") } - go ad_unmigration.UnmigrateAdGUIDUsersOnce(m.ScaledContext) + go adunmigration.UnmigrateAdGUIDUsersOnce(m.ScaledContext) tokens.StartPurgeDaemon(ctx, management) providerrefresh.StartRefreshDaemon(ctx, m.ScaledContext, management) managementdata.CleanupOrphanedSystemUsers(ctx, management)