Skip to content

Commit

Permalink
Remove unused parameters (#7473)
Browse files Browse the repository at this point in the history
# Description
Remove unused parameters

## Type of change
- This pull request is a minor refactor, code cleanup, test improvement,
or other maintenance task and doesn't change the functionality of Radius
(issue link optional).

Signed-off-by: ytimocin <[email protected]>
  • Loading branch information
ytimocin authored and sk593 committed Apr 15, 2024
1 parent 0a3d68a commit 9a540af
Show file tree
Hide file tree
Showing 81 changed files with 326 additions and 365 deletions.
4 changes: 2 additions & 2 deletions pkg/armrpc/asyncoperation/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (w *AsyncRequestProcessWorker) Start(ctx context.Context) error {
// 1. The same message is delivered twice in multiple instances.
// 2. provisioningState is not matched between resource and operationStatuses

dup, err := w.isDuplicated(reqCtx, asyncCtrl.StorageClient(), op.ResourceID, op.OperationID)
dup, err := w.isDuplicated(reqCtx, op.ResourceID, op.OperationID)
if err != nil {
opLogger.Error(err, "failed to check potential deduplication.")
return
Expand Down Expand Up @@ -370,7 +370,7 @@ func (w *AsyncRequestProcessWorker) updateResourceAndOperationStatus(ctx context
return nil
}

func (w *AsyncRequestProcessWorker) isDuplicated(ctx context.Context, sc store.StorageClient, resourceID string, operationID uuid.UUID) (bool, error) {
func (w *AsyncRequestProcessWorker) isDuplicated(ctx context.Context, resourceID string, operationID uuid.UUID) (bool, error) {
rID, err := resources.ParseResource(resourceID)
if err != nil {
return false, err
Expand Down
6 changes: 2 additions & 4 deletions pkg/armrpc/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ type Builder struct {
// defaultHandlerOptions returns HandlerOption for the default operations such as getting operationStatuses and
// operationResults.
func defaultHandlerOptions(
ctx context.Context,
rootRouter chi.Router,
rootScopePath string,
namespace string,
availableOperations []v1.Operation,
ctrlOpts apictrl.Options) []server.HandlerOptions {
availableOperations []v1.Operation) []server.HandlerOptions {
namespace = strings.ToLower(namespace)

handlers := []server.HandlerOptions{}
Expand Down Expand Up @@ -122,7 +120,7 @@ func (b *Builder) ApplyAPIHandlers(ctx context.Context, r chi.Router, ctrlOpts a
rootScopePath := ctrlOpts.PathBase + UCPRootScopePath

// Configure the default handlers.
handlerOptions := defaultHandlerOptions(ctx, r, rootScopePath, b.namespaceNode.Name, b.namespaceNode.availableOperations, ctrlOpts)
handlerOptions := defaultHandlerOptions(r, rootScopePath, b.namespaceNode.Name, b.namespaceNode.availableOperations)

routerMap := map[string]chi.Router{}
for _, h := range b.registrations {
Expand Down
3 changes: 0 additions & 3 deletions pkg/azure/roleassignment/roleassignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ func Create(ctx context.Context, armConfig *armauth.ArmConfig, subscriptionID, p
pager := client.NewListForScopePager(scope, &armauthorization.RoleAssignmentsClientListForScopeOptions{
Filter: &requestFilter,
})
if err != nil {
return nil, fmt.Errorf("failed to list role assignments: %w", err)
}

for pager.More() {
nextPage, err := pager.NextPage(ctx)
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/clients/management.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (amc *UCPApplicationsManagementClient) ListAllResourcesOfTypeInApplication(
return nil, err
}
for _, resource := range resourceList {
isResourceWithApplication := isResourceInApplication(ctx, resource, applicationName)
isResourceWithApplication := isResourceInApplication(resource, applicationName)
if isResourceWithApplication {
results = append(results, resource)
}
Expand Down Expand Up @@ -162,7 +162,7 @@ func (amc *UCPApplicationsManagementClient) ListAllResourcesOfTypeInEnvironment(
return nil, err
}
for _, resource := range resourceList {
isResourceWithApplication := isResourceInEnvironment(ctx, resource, environmentName)
isResourceWithApplication := isResourceInEnvironment(resource, environmentName)
if isResourceWithApplication {
results = append(results, resource)
}
Expand Down Expand Up @@ -393,7 +393,7 @@ func (amc *UCPApplicationsManagementClient) CreateEnvironment(ctx context.Contex

}

func isResourceInApplication(ctx context.Context, resource generated.GenericResource, applicationName string) bool {
func isResourceInApplication(resource generated.GenericResource, applicationName string) bool {
obj, found := resource.Properties["application"]
// A resource may not have an application associated with it.
if !found {
Expand All @@ -417,7 +417,7 @@ func isResourceInApplication(ctx context.Context, resource generated.GenericReso
return false
}

func isResourceInEnvironment(ctx context.Context, resource generated.GenericResource, environmentName string) bool {
func isResourceInEnvironment(resource generated.GenericResource, environmentName string) bool {
obj, found := resource.Properties["environment"]
// A resource may not have an environment associated with it.
if !found {
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/cmd/bicep/publish/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (r *Runner) publish(ctx context.Context) error {
}

// Prepare Destination
dst, err := r.prepareDestination(ctx)
dst, err := r.prepareDestination()
if err != nil {
return err
}
Expand Down Expand Up @@ -264,7 +264,7 @@ func (r *Runner) prepareSource(ctx context.Context) (*memory.Store, error) {
return src, nil
}

func (r *Runner) prepareDestination(ctx context.Context) (*remote.Repository, error) {
func (r *Runner) prepareDestination() (*remote.Repository, error) {
// Create a new credential store from Docker to get local credentials
ds, err := credentials.NewStoreFromDocker(credentials.StoreOptions{
AllowPlaintextPut: true,
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/cmd/bicep/publish/publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func TestRunner_prepareDestination(t *testing.T) {
Destination: tt.dest,
PlainHTTP: tt.plainHTTP,
}
got, err := r.prepareDestination(context.Background())
got, err := r.prepareDestination()
if (err != nil) != tt.wantErr {
t.Errorf("Runner.prepareDestination() error = %v, wantErr %v", err, tt.wantErr)
return
Expand Down Expand Up @@ -318,7 +318,7 @@ func TestRunner_Validate(t *testing.T) {
radcli.SharedValidateValidation(t, NewCommand, tests)
}

func getError(registerUrl string, statusCode int) *errcode.ErrorResponse {
func getError(registerUrl string, statusCode int) *errcode.ErrorResponse {

err := &errcode.ErrorResponse{
URL: &url.URL{Host: registerUrl},
Expand Down
3 changes: 1 addition & 2 deletions pkg/cli/cmd/radinit/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package radinit

import (
"context"
"os"
"path/filepath"

Expand All @@ -30,7 +29,7 @@ const (
enterApplicationNamePlaceholder = "Enter application name..."
)

func (r *Runner) enterApplicationOptions(ctx context.Context, options *initOptions) error {
func (r *Runner) enterApplicationOptions(options *initOptions) error {
var err error
options.Application.Scaffold, err = prompt.YesOrNoPrompt(confirmSetupApplicationPrompt, prompt.ConfirmYes, r.Prompter)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions pkg/cli/cmd/radinit/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package radinit

import (
"context"
"testing"

"github.com/golang/mock/gomock"
Expand All @@ -34,7 +33,7 @@ func Test_enterApplicationOptions(t *testing.T) {
setScaffoldApplicationPromptYes(prompter)

options := initOptions{}
err := runner.enterApplicationOptions(context.Background(), &options)
err := runner.enterApplicationOptions(&options)
require.NoError(t, err)

require.Equal(t, applicationOptions{Scaffold: true, Name: "radinit"}, options.Application)
Expand All @@ -47,7 +46,7 @@ func Test_enterApplicationOptions(t *testing.T) {
setScaffoldApplicationPromptNo(prompter)

options := initOptions{}
err := runner.enterApplicationOptions(context.Background(), &options)
err := runner.enterApplicationOptions(&options)
require.NoError(t, err)

require.Equal(t, applicationOptions{Scaffold: false, Name: ""}, options.Application)
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/cmd/radinit/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const (
awsAccessKeysCreateInstructionFmt = "\nAWS IAM Access keys (Access key ID and Secret access key) are required to access and create AWS resources.\n\nFor example, you can create one using the following command:\n\033[36maws iam create-access-key\033[0m\n\nFor more information refer to https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html.\n\n"
)

func (r *Runner) enterAWSCloudProvider(ctx context.Context, options *initOptions) (*aws.Provider, error) {
func (r *Runner) enterAWSCloudProvider(ctx context.Context) (*aws.Provider, error) {
r.Output.LogInfo(awsAccessKeysCreateInstructionFmt)

accessKeyID, err := r.Prompter.GetTextInput(enterAWSIAMAcessKeyIDPrompt, prompt.TextInputOptions{Placeholder: enterAWSIAMAcessKeyIDPlaceholder})
Expand All @@ -53,7 +53,7 @@ func (r *Runner) enterAWSCloudProvider(ctx context.Context, options *initOptions
return nil, err
}

accountId, err := r.getAccountId(ctx, QueryRegion, accessKeyID, secretAccessKey)
accountId, err := r.getAccountId(ctx, accessKeyID, secretAccessKey)
if err != nil {
return nil, err
}
Expand All @@ -71,7 +71,7 @@ func (r *Runner) enterAWSCloudProvider(ctx context.Context, options *initOptions
}, nil
}

func (r *Runner) getAccountId(ctx context.Context, region, accessKeyID, secretAccessKey string) (string, error) {
func (r *Runner) getAccountId(ctx context.Context, accessKeyID, secretAccessKey string) (string, error) {
callerIdentityOutput, err := r.awsClient.GetCallerIdentity(ctx, QueryRegion, accessKeyID, secretAccessKey)
if err != nil {
return "", clierrors.MessageWithCause(err, "AWS credential verification failed.")
Expand Down
3 changes: 1 addition & 2 deletions pkg/cli/cmd/radinit/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ func Test_enterAWSCloudProvider(t *testing.T) {
setAWSListRegions(client, QueryRegion, "access-key-id", "secret-access-key", &ec2.DescribeRegionsOutput{Regions: ec2Regions})
setAWSRegionPrompt(prompter, regions, "region")

options := initOptions{}
provider, err := runner.enterAWSCloudProvider(context.Background(), &options)
provider, err := runner.enterAWSCloudProvider(context.Background())
require.NoError(t, err)

expected := &aws.Provider{
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/cmd/radinit/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
azureServicePrincipalCreateInstructionsFmt = "\nAn Azure service principal with a corresponding role assignment on your resource group is required to create Azure resources.\n\nFor example, you can create one using the following command:\n\033[36maz ad sp create-for-rbac --role Owner --scope /subscriptions/%s/resourceGroups/%s\033[0m\n\nFor more information refer to https://docs.microsoft.com/cli/azure/ad/sp?view=azure-cli-latest#az-ad-sp-create-for-rbac and https://aka.ms/azadsp-more\n\n"
)

func (r *Runner) enterAzureCloudProvider(ctx context.Context, options *initOptions) (*azure.Provider, error) {
func (r *Runner) enterAzureCloudProvider(ctx context.Context) (*azure.Provider, error) {
subscription, err := r.selectAzureSubscription(ctx)
if err != nil {
return nil, err
Expand Down Expand Up @@ -144,7 +144,7 @@ func (r *Runner) selectAzureResourceGroup(ctx context.Context, subscription azur
return r.selectExistingAzureResourceGroup(ctx, subscription)
}

name, err := r.enterAzureResourceGroupName(ctx)
name, err := r.enterAzureResourceGroupName()
if err != nil {
return "", err
}
Expand Down Expand Up @@ -200,7 +200,7 @@ func (r *Runner) buildAzureResourceGroupList(groups []armresources.ResourceGroup
return names
}

func (r *Runner) enterAzureResourceGroupName(ctx context.Context) (string, error) {
func (r *Runner) enterAzureResourceGroupName() (string, error) {
name, err := r.Prompter.GetTextInput(enterAzureResourceGroupNamePrompt, prompt.TextInputOptions{
Placeholder: enterAzureResourceGroupNamePlaceholder,
Validate: prompt.ValidateResourceName,
Expand Down
5 changes: 2 additions & 3 deletions pkg/cli/cmd/radinit/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ func Test_enterAzureCloudProvider(t *testing.T) {
setAzureServicePrincipalPasswordPrompt(prompter, "service-principal-password")
setAzureServicePrincipalTenantIDPrompt(prompter, "service-principal-tenant-id")

options := initOptions{}
provider, err := runner.enterAzureCloudProvider(context.Background(), &options)
provider, err := runner.enterAzureCloudProvider(context.Background())
require.NoError(t, err)

expected := &azure.Provider{
Expand Down Expand Up @@ -376,7 +375,7 @@ func Test_enterAzureResourceGroupName(t *testing.T) {

setAzureResourceGroupNamePrompt(prompter, "test-resource-group")

name, err := runner.enterAzureResourceGroupName(context.Background())
name, err := runner.enterAzureResourceGroupName()
require.NoError(t, err)
require.Equal(t, "test-resource-group", name)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/cmd/radinit/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ func (r *Runner) enterCloudProviderOptions(ctx context.Context, options *initOpt

switch cloudProvider {
case azure.ProviderDisplayName:
provider, err := r.enterAzureCloudProvider(ctx, options)
provider, err := r.enterAzureCloudProvider(ctx)
if err != nil {
return err
}

options.CloudProviders.Azure = provider
case aws.ProviderDisplayName:
provider, err := r.enterAWSCloudProvider(ctx, options)
provider, err := r.enterAWSCloudProvider(ctx)
if err != nil {
return err
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/cli/cmd/radinit/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package radinit

import (
"context"
"sort"

"github.com/radius-project/radius/pkg/cli/clierrors"
Expand All @@ -29,9 +28,9 @@ const (
selectClusterPrompt = "Select the kubeconfig context to install Radius into"
)

func (r *Runner) enterClusterOptions(ctx context.Context, options *initOptions) error {
func (r *Runner) enterClusterOptions(options *initOptions) error {
var err error
options.Cluster.Context, err = r.selectCluster(ctx)
options.Cluster.Context, err = r.selectCluster()
if err != nil {
return err
}
Expand All @@ -56,7 +55,7 @@ func (r *Runner) enterClusterOptions(ctx context.Context, options *initOptions)
return nil
}

func (r *Runner) selectCluster(ctx context.Context) (string, error) {
func (r *Runner) selectCluster() (string, error) {
kubeContextList, err := r.KubernetesInterface.GetKubeContext()
if err != nil {
return "", clierrors.MessageWithCause(err, "Failed to read Kubernetes config.")
Expand Down
5 changes: 2 additions & 3 deletions pkg/cli/cmd/radinit/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package radinit

import (
"context"
"testing"

"github.com/golang/mock/gomock"
Expand All @@ -40,7 +39,7 @@ func Test_enterClusterOptions(t *testing.T) {
initHelmMockRadiusNotInstalled(helm)

options := initOptions{}
err := runner.enterClusterOptions(context.Background(), &options)
err := runner.enterClusterOptions(&options)
require.NoError(t, err)
require.Equal(t, "kind-kind", options.Cluster.Context)
require.Equal(t, true, options.Cluster.Install)
Expand All @@ -55,7 +54,7 @@ func Test_selectCluster(t *testing.T) {
initGetKubeContextSuccess(k8s)
initKubeContextWithKind(prompter)

name, err := runner.selectCluster(context.Background())
name, err := runner.selectCluster()
require.NoError(t, err)
require.Equal(t, "kind-kind", name)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/cmd/radinit/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ func (r *Runner) enterEnvironmentOptions(ctx context.Context, workspace *workspa
}

var err error
options.Environment.Name, err = r.enterEnvironmentName(ctx)
options.Environment.Name, err = r.enterEnvironmentName()
if err != nil {
return err
}

options.Environment.Namespace, err = r.enterEnvironmentNamespace(ctx)
options.Environment.Namespace, err = r.enterEnvironmentNamespace()
if err != nil {
return err
}
Expand Down Expand Up @@ -212,7 +212,7 @@ func (r *Runner) buildExistingEnvironmentList(existing []corerp.EnvironmentResou
return items
}

func (r *Runner) enterEnvironmentName(ctx context.Context) (string, error) {
func (r *Runner) enterEnvironmentName() (string, error) {
// When no flags are specified we don't ask for a name, just use 'default'
if !r.Full {
return defaultEnvironmentName, nil
Expand All @@ -230,7 +230,7 @@ func (r *Runner) enterEnvironmentName(ctx context.Context) (string, error) {
return name, nil
}

func (r *Runner) enterEnvironmentNamespace(ctx context.Context) (string, error) {
func (r *Runner) enterEnvironmentNamespace() (string, error) {
// When no flags are specified we don't want to ask about namespaces.
if !r.Full {
return defaultEnvironmentNamespace, nil
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/cmd/radinit/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func Test_enterEnvironmentName(t *testing.T) {
prompter := prompt.NewMockInterface(ctrl)
runner := Runner{Prompter: prompter}

name, err := runner.enterEnvironmentName(context.Background())
name, err := runner.enterEnvironmentName()
require.NoError(t, err)
require.Equal(t, defaultEnvironmentName, name)
})
Expand All @@ -260,7 +260,7 @@ func Test_enterEnvironmentName(t *testing.T) {

initEnvNamePrompt(prompter, "test-name")

name, err := runner.enterEnvironmentName(context.Background())
name, err := runner.enterEnvironmentName()
require.NoError(t, err)
require.Equal(t, "test-name", name)
})
Expand All @@ -272,7 +272,7 @@ func Test_enterEnvironmentNamespace(t *testing.T) {
prompter := prompt.NewMockInterface(ctrl)
runner := Runner{Prompter: prompter}

namespace, err := runner.enterEnvironmentNamespace(context.Background())
namespace, err := runner.enterEnvironmentNamespace()
require.NoError(t, err)
require.Equal(t, defaultEnvironmentNamespace, namespace)
})
Expand All @@ -284,7 +284,7 @@ func Test_enterEnvironmentNamespace(t *testing.T) {

initNamespacePrompt(prompter, "test-namespace")

namespace, err := runner.enterEnvironmentNamespace(context.Background())
namespace, err := runner.enterEnvironmentNamespace()
require.NoError(t, err)
require.Equal(t, "test-namespace", namespace)
})
Expand Down
Loading

0 comments on commit 9a540af

Please sign in to comment.