Repository: deislabs/ratify
Pull request #520 (2022-12-21 22:03:08)

refactor: Move authprovider to pkg/common/oras
# Description

## What this PR does / why we need it:

Per 2022-12-21 community call:

- moving authprovider from `pkg/referrerstore/oras/authprovider` -> `pkg/common/oras/authprovider` so that it can be used by other Ratify packages in a future PR (i.e.: plugin downloads)

## Type of change

- [x] Pure refactor only, no functionality changes

# How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also list any relevant details for your test configuration

- [x] Current tests pass


susanshi: @akashsinghal , please review when convenient thanks!
susanshi: just to point out @noelbundick-msft , it might be good to do some manual test to validate at least basic auth provider works, i think we don't have any authprovider integration tests today.

Patch:
diff --git a/pkg/referrerstore/oras/authprovider/authprovider.go b/pkg/common/oras/authprovider/authprovider.go
similarity index 100%
rename from pkg/referrerstore/oras/authprovider/authprovider.go
rename to pkg/common/oras/authprovider/authprovider.go
diff --git a/pkg/referrerstore/oras/authprovider/authprovider_test.go b/pkg/common/oras/authprovider/authprovider_test.go
similarity index 100%
rename from pkg/referrerstore/oras/authprovider/authprovider_test.go
rename to pkg/common/oras/authprovider/authprovider_test.go
diff --git a/pkg/referrerstore/oras/authprovider/authproviderconfig.go b/pkg/common/oras/authprovider/authproviderconfig.go
similarity index 100%
rename from pkg/referrerstore/oras/authprovider/authproviderconfig.go
rename to pkg/common/oras/authprovider/authproviderconfig.go
diff --git a/pkg/referrerstore/oras/authprovider/authproviderfactory.go b/pkg/common/oras/authprovider/authproviderfactory.go
similarity index 100%
rename from pkg/referrerstore/oras/authprovider/authproviderfactory.go
rename to pkg/common/oras/authprovider/authproviderfactory.go
diff --git a/pkg/referrerstore/oras/authprovider/authproviderfactory_test.go b/pkg/common/oras/authprovider/authproviderfactory_test.go
similarity index 100%
rename from pkg/referrerstore/oras/authprovider/authproviderfactory_test.go
rename to pkg/common/oras/authprovider/authproviderfactory_test.go
diff --git a/pkg/referrerstore/oras/authprovider/aws/awsecrbasic.go b/pkg/common/oras/authprovider/aws/awsecrbasic.go
similarity index 98%
rename from pkg/referrerstore/oras/authprovider/aws/awsecrbasic.go
rename to pkg/common/oras/authprovider/aws/awsecrbasic.go
index ffb387c..157830d 100644
--- a/pkg/referrerstore/oras/authprovider/aws/awsecrbasic.go
+++ b/pkg/common/oras/authprovider/aws/awsecrbasic.go
@@ -22,7 +22,7 @@ import (
 	"github.com/aws/aws-sdk-go-v2/config"
 	"github.com/aws/aws-sdk-go-v2/credentials/stscreds"
 	"github.com/aws/aws-sdk-go-v2/service/ecr"
-	provider "github.com/deislabs/ratify/pkg/referrerstore/oras/authprovider"
+	provider "github.com/deislabs/ratify/pkg/common/oras/authprovider"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 	"os"
diff --git a/pkg/referrerstore/oras/authprovider/aws/awsecrbasic_test.go b/pkg/common/oras/authprovider/aws/awsecrbasic_test.go
similarity index 100%
rename from pkg/referrerstore/oras/authprovider/aws/awsecrbasic_test.go
rename to pkg/common/oras/authprovider/aws/awsecrbasic_test.go
diff --git a/pkg/referrerstore/oras/authprovider/aws/ecrauthtypes.go b/pkg/common/oras/authprovider/aws/ecrauthtypes.go
similarity index 100%
rename from pkg/referrerstore/oras/authprovider/aws/ecrauthtypes.go
rename to pkg/common/oras/authprovider/aws/ecrauthtypes.go
diff --git a/pkg/referrerstore/oras/authprovider/azure/azureidentity.go b/pkg/common/oras/authprovider/azure/azureidentity.go
similarity index 98%
rename from pkg/referrerstore/oras/authprovider/azure/azureidentity.go
rename to pkg/common/oras/authprovider/azure/azureidentity.go
index 8c532d6..41e251f 100644
--- a/pkg/referrerstore/oras/authprovider/azure/azureidentity.go
+++ b/pkg/common/oras/authprovider/azure/azureidentity.go
@@ -22,7 +22,7 @@ import (
 	"os"
 	"time"
 
-	provider "github.com/deislabs/ratify/pkg/referrerstore/oras/authprovider"
+	provider "github.com/deislabs/ratify/pkg/common/oras/authprovider"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 
diff --git a/pkg/referrerstore/oras/authprovider/azure/azureworkloadidentity.go b/pkg/common/oras/authprovider/azure/azureworkloadidentity.go
similarity index 98%
rename from pkg/referrerstore/oras/authprovider/azure/azureworkloadidentity.go
rename to pkg/common/oras/authprovider/azure/azureworkloadidentity.go
index 809b388..afa6c79 100644
--- a/pkg/referrerstore/oras/authprovider/azure/azureworkloadidentity.go
+++ b/pkg/common/oras/authprovider/azure/azureworkloadidentity.go
@@ -23,7 +23,7 @@ import (
 	"time"
 
 	"github.com/AzureAD/microsoft-authentication-library-for-go/apps/confidential"
-	provider "github.com/deislabs/ratify/pkg/referrerstore/oras/authprovider"
+	provider "github.com/deislabs/ratify/pkg/common/oras/authprovider"
 	"github.com/pkg/errors"
 	"github.com/sirupsen/logrus"
 
diff --git a/pkg/referrerstore/oras/authprovider/azure/const.go b/pkg/common/oras/authprovider/azure/const.go
similarity index 100%
rename from pkg/referrerstore/oras/authprovider/azure/const.go
rename to pkg/common/oras/authprovider/azure/const.go
diff --git a/pkg/referrerstore/oras/authprovider/k8secret_authprovider.go b/pkg/common/oras/authprovider/k8secret_authprovider.go
similarity index 100%
rename from pkg/referrerstore/oras/authprovider/k8secret_authprovider.go
rename to pkg/common/oras/authprovider/k8secret_authprovider.go
diff --git a/pkg/referrerstore/oras/authprovider/k8secret_authprovider_test.go b/pkg/common/oras/authprovider/k8secret_authprovider_test.go
similarity index 100%
rename from pkg/referrerstore/oras/authprovider/k8secret_authprovider_test.go
rename to pkg/common/oras/authprovider/k8secret_authprovider_test.go
diff --git a/pkg/executor/config/config.go b/pkg/executor/config/config.go
index abd39e4..5c64c08 100644
--- a/pkg/executor/config/config.go
+++ b/pkg/executor/config/config.go
@@ -17,6 +17,6 @@ package config
 
 // ExecutorConfig represents the configuration for the executor
 type ExecutorConfig struct {
-	RequestTimeout *int   `json:"requestTimeout"`
+	RequestTimeout *int `json:"requestTimeout"`
 	// TODO Add cache config
 }
diff --git a/pkg/referrerstore/oras/oras.go b/pkg/referrerstore/oras/oras.go
index 9937b6b..7c21f7b 100644
--- a/pkg/referrerstore/oras/oras.go
+++ b/pkg/referrerstore/oras/oras.go
@@ -37,14 +37,14 @@ import (
 
 	ratifyconfig "github.com/deislabs/ratify/config"
 	"github.com/deislabs/ratify/pkg/common"
+	"github.com/deislabs/ratify/pkg/common/oras/authprovider"
+	_ "github.com/deislabs/ratify/pkg/common/oras/authprovider/aws"
+	_ "github.com/deislabs/ratify/pkg/common/oras/authprovider/azure"
 	"github.com/deislabs/ratify/pkg/homedir"
 	"github.com/deislabs/ratify/pkg/ocispecs"
 	"github.com/deislabs/ratify/pkg/referrerstore"
 	"github.com/deislabs/ratify/pkg/referrerstore/config"
 	"github.com/deislabs/ratify/pkg/referrerstore/factory"
-	"github.com/deislabs/ratify/pkg/referrerstore/oras/authprovider"
-	_ "github.com/deislabs/ratify/pkg/referrerstore/oras/authprovider/aws"
-	_ "github.com/deislabs/ratify/pkg/referrerstore/oras/authprovider/azure"
 	"github.com/deislabs/ratify/pkg/referrerstore/utils"
 	retryablehttp "github.com/hashicorp/go-retryablehttp"
 	"github.com/opencontainers/go-digest"


Test patch:
diff --git a/pkg/referrerstore/oras/authprovider/azure/azureidentity_test.go b/pkg/common/oras/authprovider/azure/azureidentity_test.go
similarity index 97%
rename from pkg/referrerstore/oras/authprovider/azure/azureidentity_test.go
rename to pkg/common/oras/authprovider/azure/azureidentity_test.go
index 048dbf4..e524636 100644
--- a/pkg/referrerstore/oras/authprovider/azure/azureidentity_test.go
+++ b/pkg/common/oras/authprovider/azure/azureidentity_test.go
@@ -22,7 +22,7 @@ import (
 	"testing"
 
 	"github.com/Azure/azure-sdk-for-go/sdk/azcore"
-	"github.com/deislabs/ratify/pkg/referrerstore/oras/authprovider"
+	"github.com/deislabs/ratify/pkg/common/oras/authprovider"
 )
 
 // Verifies that Enabled checks if tenantID is empty or AAD token is empty
diff --git a/pkg/referrerstore/oras/authprovider/azure/azureworkloadidentity_test.go b/pkg/common/oras/authprovider/azure/azureworkloadidentity_test.go
similarity index 97%
rename from pkg/referrerstore/oras/authprovider/azure/azureworkloadidentity_test.go
rename to pkg/common/oras/authprovider/azure/azureworkloadidentity_test.go
index bc61fb9..fb67dcd 100644
--- a/pkg/referrerstore/oras/authprovider/azure/azureworkloadidentity_test.go
+++ b/pkg/common/oras/authprovider/azure/azureworkloadidentity_test.go
@@ -22,7 +22,7 @@ import (
 	"testing"
 
 	"github.com/AzureAD/microsoft-authentication-library-for-go/apps/confidential"
-	"github.com/deislabs/ratify/pkg/referrerstore/oras/authprovider"
+	"github.com/deislabs/ratify/pkg/common/oras/authprovider"
 )
 
 // Verifies that Enabled checks if tenantID is empty or AAD token is empty