зеркало из https://github.com/Azure/ARO-RP.git
remove pkg/util/deployment and revert to isDevelopment bool
This commit is contained in:
Родитель
c1e0ef99a5
Коммит
10554999eb
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/metrics/statsd/k8s"
|
||||
pkgmonitor "github.com/Azure/ARO-RP/pkg/monitor"
|
||||
"github.com/Azure/ARO-RP/pkg/proxy"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/encryption"
|
||||
"github.com/Azure/ARO-RP/pkg/util/keyvault"
|
||||
)
|
||||
|
@ -31,7 +30,7 @@ func monitor(ctx context.Context, log *logrus.Entry) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if _env.DeploymentMode() != deployment.Development {
|
||||
if !_env.IsDevelopmentMode() {
|
||||
for _, key := range []string{
|
||||
"CLUSTER_MDM_ACCOUNT",
|
||||
"CLUSTER_MDM_NAMESPACE",
|
||||
|
@ -82,22 +81,22 @@ func monitor(ctx context.Context, log *logrus.Entry) error {
|
|||
return err
|
||||
}
|
||||
|
||||
dbMonitors, err := database.NewMonitors(ctx, _env.DeploymentMode(), dbc)
|
||||
dbMonitors, err := database.NewMonitors(ctx, _env.IsDevelopmentMode(), dbc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbOpenShiftClusters, err := database.NewOpenShiftClusters(ctx, _env.DeploymentMode(), dbc)
|
||||
dbOpenShiftClusters, err := database.NewOpenShiftClusters(ctx, _env.IsDevelopmentMode(), dbc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbSubscriptions, err := database.NewSubscriptions(ctx, _env.DeploymentMode(), dbc)
|
||||
dbSubscriptions, err := database.NewSubscriptions(ctx, _env.IsDevelopmentMode(), dbc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dialer, err := proxy.NewDialer(_env.DeploymentMode())
|
||||
dialer, err := proxy.NewDialer(_env.IsDevelopmentMode())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"k8s.io/client-go/kubernetes"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
pkgoperator "github.com/Azure/ARO-RP/pkg/operator"
|
||||
aroclient "github.com/Azure/ARO-RP/pkg/operator/clientset/versioned"
|
||||
"github.com/Azure/ARO-RP/pkg/operator/controllers"
|
||||
|
@ -31,7 +32,6 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/operator/controllers/rbac"
|
||||
"github.com/Azure/ARO-RP/pkg/operator/controllers/routefix"
|
||||
"github.com/Azure/ARO-RP/pkg/operator/controllers/workaround"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/dynamichelper"
|
||||
utillog "github.com/Azure/ARO-RP/pkg/util/log"
|
||||
// +kubebuilder:scaffold:imports
|
||||
|
@ -44,8 +44,10 @@ func operator(ctx context.Context, log *logrus.Entry) error {
|
|||
default:
|
||||
return fmt.Errorf("invalid role %s", role)
|
||||
}
|
||||
deploymentMode := deployment.NewMode()
|
||||
log.Infof("running in %s mode", deploymentMode)
|
||||
isDevelopmentMode := env.IsDevelopmentMode()
|
||||
if isDevelopmentMode {
|
||||
log.Info("running in development mode")
|
||||
}
|
||||
|
||||
ctrl.SetLogger(utillog.LogrWrapper(log))
|
||||
|
||||
|
@ -152,7 +154,7 @@ func operator(ctx context.Context, log *logrus.Entry) error {
|
|||
|
||||
if err = (checker.NewReconciler(
|
||||
log.WithField("controller", controllers.CheckerControllerName),
|
||||
maocli, arocli, role, deploymentMode)).SetupWithManager(mgr); err != nil {
|
||||
maocli, arocli, role, isDevelopmentMode)).SetupWithManager(mgr); err != nil {
|
||||
return fmt.Errorf("unable to create controller InternetChecker: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
pkgportal "github.com/Azure/ARO-RP/pkg/portal"
|
||||
"github.com/Azure/ARO-RP/pkg/portal/middleware"
|
||||
"github.com/Azure/ARO-RP/pkg/proxy"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/encryption"
|
||||
"github.com/Azure/ARO-RP/pkg/util/keyvault"
|
||||
)
|
||||
|
@ -31,7 +30,7 @@ func portal(ctx context.Context, log *logrus.Entry) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if _env.DeploymentMode() != deployment.Development {
|
||||
if !_env.IsDevelopmentMode() {
|
||||
for _, key := range []string{
|
||||
"MDM_ACCOUNT",
|
||||
"MDM_NAMESPACE",
|
||||
|
@ -93,12 +92,12 @@ func portal(ctx context.Context, log *logrus.Entry) error {
|
|||
return err
|
||||
}
|
||||
|
||||
dbOpenShiftClusters, err := database.NewOpenShiftClusters(ctx, _env.DeploymentMode(), dbc)
|
||||
dbOpenShiftClusters, err := database.NewOpenShiftClusters(ctx, _env.IsDevelopmentMode(), dbc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbPortal, err := database.NewPortal(ctx, _env.DeploymentMode(), dbc)
|
||||
dbPortal, err := database.NewPortal(ctx, _env.IsDevelopmentMode(), dbc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -135,7 +134,7 @@ func portal(ctx context.Context, log *logrus.Entry) error {
|
|||
return err
|
||||
}
|
||||
|
||||
dialer, err := proxy.NewDialer(_env.DeploymentMode())
|
||||
dialer, err := proxy.NewDialer(_env.IsDevelopmentMode())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -149,7 +148,7 @@ func portal(ctx context.Context, log *logrus.Entry) error {
|
|||
hostname := "localhost:8444"
|
||||
address := "localhost:8444"
|
||||
sshAddress := "localhost:2222"
|
||||
if _env.DeploymentMode() != deployment.Development {
|
||||
if !_env.IsDevelopmentMode() {
|
||||
hostname = os.Getenv("PORTAL_HOSTNAME")
|
||||
address = ":8444"
|
||||
sshAddress = ":2222"
|
||||
|
|
|
@ -28,7 +28,6 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/metrics/statsd/azure"
|
||||
"github.com/Azure/ARO-RP/pkg/metrics/statsd/k8s"
|
||||
"github.com/Azure/ARO-RP/pkg/util/clusterdata"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/encryption"
|
||||
)
|
||||
|
||||
|
@ -39,7 +38,7 @@ func rp(ctx context.Context, log, audit *logrus.Entry) error {
|
|||
}
|
||||
|
||||
var keys []string
|
||||
if _env.DeploymentMode() == deployment.Development {
|
||||
if _env.IsDevelopmentMode() {
|
||||
keys = []string{
|
||||
"PULL_SECRET",
|
||||
}
|
||||
|
@ -89,22 +88,22 @@ func rp(ctx context.Context, log, audit *logrus.Entry) error {
|
|||
return err
|
||||
}
|
||||
|
||||
dbAsyncOperations, err := database.NewAsyncOperations(ctx, _env.DeploymentMode(), dbc)
|
||||
dbAsyncOperations, err := database.NewAsyncOperations(ctx, _env.IsDevelopmentMode(), dbc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbBilling, err := database.NewBilling(ctx, _env.DeploymentMode(), dbc)
|
||||
dbBilling, err := database.NewBilling(ctx, _env.IsDevelopmentMode(), dbc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbOpenShiftClusters, err := database.NewOpenShiftClusters(ctx, _env.DeploymentMode(), dbc)
|
||||
dbOpenShiftClusters, err := database.NewOpenShiftClusters(ctx, _env.IsDevelopmentMode(), dbc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dbSubscriptions, err := database.NewSubscriptions(ctx, _env.DeploymentMode(), dbc)
|
||||
dbSubscriptions, err := database.NewSubscriptions(ctx, _env.IsDevelopmentMode(), dbc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ func run(ctx context.Context, log *logrus.Entry) error {
|
|||
return err
|
||||
}
|
||||
|
||||
openShiftClusters, err := database.NewOpenShiftClusters(ctx, _env.DeploymentMode(), dbc)
|
||||
openShiftClusters, err := database.NewOpenShiftClusters(ctx, _env.IsDevelopmentMode(), dbc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ package admin
|
|||
|
||||
import (
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
// APIVersion contains a version string as it will be used by clients
|
||||
|
@ -16,7 +15,7 @@ func init() {
|
|||
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {
|
||||
return &openShiftClusterConverter{}
|
||||
},
|
||||
OpenShiftClusterStaticValidator: func(string, string, deployment.Mode, string) api.OpenShiftClusterStaticValidator {
|
||||
OpenShiftClusterStaticValidator: func(string, string, bool, string) api.OpenShiftClusterStaticValidator {
|
||||
return &openShiftClusterStaticValidator{}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -3,10 +3,6 @@ package api
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the Apache License 2.0.
|
||||
|
||||
import (
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
type OpenShiftClusterConverter interface {
|
||||
ToExternal(*OpenShiftCluster) interface{}
|
||||
ToExternalList([]*OpenShiftCluster, string) interface{}
|
||||
|
@ -24,7 +20,7 @@ type OpenShiftClusterCredentialsConverter interface {
|
|||
// Version is a set of endpoints implemented by each API version
|
||||
type Version struct {
|
||||
OpenShiftClusterConverter func() OpenShiftClusterConverter
|
||||
OpenShiftClusterStaticValidator func(string, string, deployment.Mode, string) OpenShiftClusterStaticValidator
|
||||
OpenShiftClusterStaticValidator func(string, string, bool, string) OpenShiftClusterStaticValidator
|
||||
OpenShiftClusterCredentialsConverter func() OpenShiftClusterCredentialsConverter
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/api/validate"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/immutable"
|
||||
"github.com/Azure/ARO-RP/pkg/util/pullsecret"
|
||||
"github.com/Azure/ARO-RP/pkg/util/subnet"
|
||||
|
@ -22,10 +21,10 @@ import (
|
|||
)
|
||||
|
||||
type openShiftClusterStaticValidator struct {
|
||||
location string
|
||||
domain string
|
||||
deploymentMode deployment.Mode
|
||||
resourceID string
|
||||
location string
|
||||
domain string
|
||||
isDevelopmentMode bool
|
||||
resourceID string
|
||||
|
||||
r azure.Resource
|
||||
}
|
||||
|
@ -213,7 +212,7 @@ func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, n
|
|||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateMasterProfile(path string, mp *MasterProfile) error {
|
||||
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.deploymentMode, true) {
|
||||
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.isDevelopmentMode, true) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vmSize", "The provided master VM size '%s' is invalid.", mp.VMSize)
|
||||
}
|
||||
if !validate.RxSubnetID.MatchString(mp.SubnetID) {
|
||||
|
@ -234,7 +233,7 @@ func (sv *openShiftClusterStaticValidator) validateWorkerProfile(path string, wp
|
|||
if wp.Name != "worker" {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".name", "The provided worker name '%s' is invalid.", wp.Name)
|
||||
}
|
||||
if !validate.VMSizeIsValid(api.VMSize(wp.VMSize), sv.deploymentMode, false) {
|
||||
if !validate.VMSizeIsValid(api.VMSize(wp.VMSize), sv.isDevelopmentMode, false) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vmSize", "The provided worker VM size '%s' is invalid.", wp.VMSize)
|
||||
}
|
||||
if !validate.DiskSizeIsValid(wp.DiskSizeGB) {
|
||||
|
|
|
@ -13,17 +13,16 @@ import (
|
|||
"github.com/gofrs/uuid"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/version"
|
||||
"github.com/Azure/ARO-RP/test/validate"
|
||||
)
|
||||
|
||||
type validateTest struct {
|
||||
name string
|
||||
current func(oc *OpenShiftCluster)
|
||||
modify func(oc *OpenShiftCluster)
|
||||
deploymentMode deployment.Mode
|
||||
wantErr string
|
||||
name string
|
||||
current func(oc *OpenShiftCluster)
|
||||
modify func(oc *OpenShiftCluster)
|
||||
isDevelopmentMode bool
|
||||
wantErr string
|
||||
}
|
||||
|
||||
type testMode string
|
||||
|
@ -102,10 +101,10 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
v := &openShiftClusterStaticValidator{
|
||||
location: "location",
|
||||
domain: "location.aroapp.io",
|
||||
deploymentMode: tt.deploymentMode,
|
||||
resourceID: id,
|
||||
location: "location",
|
||||
domain: "location.aroapp.io",
|
||||
isDevelopmentMode: tt.isDevelopmentMode,
|
||||
resourceID: id,
|
||||
r: azure.Resource{
|
||||
SubscriptionID: subscriptionID,
|
||||
ResourceGroup: "resourceGroup",
|
||||
|
@ -512,8 +511,8 @@ func TestOpenShiftClusterStaticValidateWorkerProfile(t *testing.T) {
|
|||
modify: func(oc *OpenShiftCluster) {
|
||||
oc.Properties.WorkerProfiles[0].VMSize = "Standard_D4s_v3"
|
||||
},
|
||||
deploymentMode: deployment.Development,
|
||||
wantErr: "400: InvalidParameter: properties.workerProfiles['worker'].vmSize: The provided worker VM size 'Standard_D4s_v3' is invalid.",
|
||||
isDevelopmentMode: true,
|
||||
wantErr: "400: InvalidParameter: properties.workerProfiles['worker'].vmSize: The provided worker VM size 'Standard_D4s_v3' is invalid.",
|
||||
},
|
||||
{
|
||||
name: "disk too small",
|
||||
|
|
|
@ -5,7 +5,6 @@ package v20191231preview
|
|||
|
||||
import (
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
// APIVersion contains a version string as it will be used by clients
|
||||
|
@ -21,12 +20,12 @@ func init() {
|
|||
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {
|
||||
return &openShiftClusterConverter{}
|
||||
},
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, deploymentMode deployment.Mode, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, isDevelopmentMode bool, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
return &openShiftClusterStaticValidator{
|
||||
location: location,
|
||||
domain: domain,
|
||||
deploymentMode: deploymentMode,
|
||||
resourceID: resourceID,
|
||||
location: location,
|
||||
domain: domain,
|
||||
isDevelopmentMode: isDevelopmentMode,
|
||||
resourceID: resourceID,
|
||||
}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: func() api.OpenShiftClusterCredentialsConverter {
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/api/validate"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/immutable"
|
||||
"github.com/Azure/ARO-RP/pkg/util/pullsecret"
|
||||
"github.com/Azure/ARO-RP/pkg/util/subnet"
|
||||
|
@ -22,10 +21,10 @@ import (
|
|||
)
|
||||
|
||||
type openShiftClusterStaticValidator struct {
|
||||
location string
|
||||
domain string
|
||||
deploymentMode deployment.Mode
|
||||
resourceID string
|
||||
location string
|
||||
domain string
|
||||
isDevelopmentMode bool
|
||||
resourceID string
|
||||
|
||||
r azure.Resource
|
||||
}
|
||||
|
@ -213,7 +212,7 @@ func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, n
|
|||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateMasterProfile(path string, mp *MasterProfile) error {
|
||||
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.deploymentMode, true) {
|
||||
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.isDevelopmentMode, true) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vmSize", "The provided master VM size '%s' is invalid.", mp.VMSize)
|
||||
}
|
||||
if !validate.RxSubnetID.MatchString(mp.SubnetID) {
|
||||
|
@ -234,7 +233,7 @@ func (sv *openShiftClusterStaticValidator) validateWorkerProfile(path string, wp
|
|||
if wp.Name != "worker" {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".name", "The provided worker name '%s' is invalid.", wp.Name)
|
||||
}
|
||||
if !validate.VMSizeIsValid(api.VMSize(wp.VMSize), sv.deploymentMode, false) {
|
||||
if !validate.VMSizeIsValid(api.VMSize(wp.VMSize), sv.isDevelopmentMode, false) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vmSize", "The provided worker VM size '%s' is invalid.", wp.VMSize)
|
||||
}
|
||||
if !validate.DiskSizeIsValid(wp.DiskSizeGB) {
|
||||
|
|
|
@ -13,17 +13,16 @@ import (
|
|||
"github.com/gofrs/uuid"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/version"
|
||||
"github.com/Azure/ARO-RP/test/validate"
|
||||
)
|
||||
|
||||
type validateTest struct {
|
||||
name string
|
||||
current func(oc *OpenShiftCluster)
|
||||
modify func(oc *OpenShiftCluster)
|
||||
deploymentMode deployment.Mode
|
||||
wantErr string
|
||||
name string
|
||||
current func(oc *OpenShiftCluster)
|
||||
modify func(oc *OpenShiftCluster)
|
||||
isDevelopmentMode bool
|
||||
wantErr string
|
||||
}
|
||||
|
||||
type testMode string
|
||||
|
@ -102,10 +101,10 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
v := &openShiftClusterStaticValidator{
|
||||
location: "location",
|
||||
domain: "location.aroapp.io",
|
||||
deploymentMode: tt.deploymentMode,
|
||||
resourceID: id,
|
||||
location: "location",
|
||||
domain: "location.aroapp.io",
|
||||
isDevelopmentMode: tt.isDevelopmentMode,
|
||||
resourceID: id,
|
||||
r: azure.Resource{
|
||||
SubscriptionID: subscriptionID,
|
||||
ResourceGroup: "resourceGroup",
|
||||
|
@ -512,8 +511,8 @@ func TestOpenShiftClusterStaticValidateWorkerProfile(t *testing.T) {
|
|||
modify: func(oc *OpenShiftCluster) {
|
||||
oc.Properties.WorkerProfiles[0].VMSize = "Standard_D4s_v3"
|
||||
},
|
||||
deploymentMode: deployment.Development,
|
||||
wantErr: "400: InvalidParameter: properties.workerProfiles['worker'].vmSize: The provided worker VM size 'Standard_D4s_v3' is invalid.",
|
||||
isDevelopmentMode: true,
|
||||
wantErr: "400: InvalidParameter: properties.workerProfiles['worker'].vmSize: The provided worker VM size 'Standard_D4s_v3' is invalid.",
|
||||
},
|
||||
{
|
||||
name: "disk too small",
|
||||
|
|
|
@ -5,7 +5,6 @@ package v20200430
|
|||
|
||||
import (
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
// APIVersion contains a version string as it will be used by clients
|
||||
|
@ -21,12 +20,12 @@ func init() {
|
|||
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {
|
||||
return &openShiftClusterConverter{}
|
||||
},
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, deploymentMode deployment.Mode, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, isDevelopmentMode bool, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
return &openShiftClusterStaticValidator{
|
||||
location: location,
|
||||
domain: domain,
|
||||
deploymentMode: deploymentMode,
|
||||
resourceID: resourceID,
|
||||
location: location,
|
||||
domain: domain,
|
||||
isDevelopmentMode: isDevelopmentMode,
|
||||
resourceID: resourceID,
|
||||
}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: func() api.OpenShiftClusterCredentialsConverter {
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/api/validate"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/immutable"
|
||||
"github.com/Azure/ARO-RP/pkg/util/pullsecret"
|
||||
"github.com/Azure/ARO-RP/pkg/util/subnet"
|
||||
|
@ -22,10 +21,10 @@ import (
|
|||
)
|
||||
|
||||
type openShiftClusterStaticValidator struct {
|
||||
location string
|
||||
domain string
|
||||
deploymentMode deployment.Mode
|
||||
resourceID string
|
||||
location string
|
||||
domain string
|
||||
isDevelopmentMode bool
|
||||
resourceID string
|
||||
|
||||
r azure.Resource
|
||||
}
|
||||
|
@ -213,7 +212,7 @@ func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, n
|
|||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateMasterProfile(path string, mp *MasterProfile) error {
|
||||
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.deploymentMode, true) {
|
||||
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.isDevelopmentMode, true) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vmSize", "The provided master VM size '%s' is invalid.", mp.VMSize)
|
||||
}
|
||||
if !validate.RxSubnetID.MatchString(mp.SubnetID) {
|
||||
|
@ -234,7 +233,7 @@ func (sv *openShiftClusterStaticValidator) validateWorkerProfile(path string, wp
|
|||
if wp.Name != "worker" {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".name", "The provided worker name '%s' is invalid.", wp.Name)
|
||||
}
|
||||
if !validate.VMSizeIsValid(api.VMSize(wp.VMSize), sv.deploymentMode, false) {
|
||||
if !validate.VMSizeIsValid(api.VMSize(wp.VMSize), sv.isDevelopmentMode, false) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vmSize", "The provided worker VM size '%s' is invalid.", wp.VMSize)
|
||||
}
|
||||
if !validate.DiskSizeIsValid(wp.DiskSizeGB) {
|
||||
|
|
|
@ -13,17 +13,16 @@ import (
|
|||
"github.com/gofrs/uuid"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/version"
|
||||
"github.com/Azure/ARO-RP/test/validate"
|
||||
)
|
||||
|
||||
type validateTest struct {
|
||||
name string
|
||||
current func(oc *OpenShiftCluster)
|
||||
modify func(oc *OpenShiftCluster)
|
||||
deploymentMode deployment.Mode
|
||||
wantErr string
|
||||
name string
|
||||
current func(oc *OpenShiftCluster)
|
||||
modify func(oc *OpenShiftCluster)
|
||||
isDevelopmentMode bool
|
||||
wantErr string
|
||||
}
|
||||
|
||||
type testMode string
|
||||
|
@ -102,10 +101,10 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
|
|||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
v := &openShiftClusterStaticValidator{
|
||||
location: "location",
|
||||
domain: "location.aroapp.io",
|
||||
deploymentMode: tt.deploymentMode,
|
||||
resourceID: id,
|
||||
location: "location",
|
||||
domain: "location.aroapp.io",
|
||||
isDevelopmentMode: tt.isDevelopmentMode,
|
||||
resourceID: id,
|
||||
r: azure.Resource{
|
||||
SubscriptionID: subscriptionID,
|
||||
ResourceGroup: "resourceGroup",
|
||||
|
@ -512,8 +511,8 @@ func TestOpenShiftClusterStaticValidateWorkerProfile(t *testing.T) {
|
|||
modify: func(oc *OpenShiftCluster) {
|
||||
oc.Properties.WorkerProfiles[0].VMSize = "Standard_D4s_v3"
|
||||
},
|
||||
deploymentMode: deployment.Development,
|
||||
wantErr: "400: InvalidParameter: properties.workerProfiles['worker'].vmSize: The provided worker VM size 'Standard_D4s_v3' is invalid.",
|
||||
isDevelopmentMode: true,
|
||||
wantErr: "400: InvalidParameter: properties.workerProfiles['worker'].vmSize: The provided worker VM size 'Standard_D4s_v3' is invalid.",
|
||||
},
|
||||
{
|
||||
name: "disk too small",
|
||||
|
|
|
@ -5,7 +5,6 @@ package v20210131preview
|
|||
|
||||
import (
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
// APIVersion contains a version string as it will be used by clients
|
||||
|
@ -21,12 +20,12 @@ func init() {
|
|||
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {
|
||||
return &openShiftClusterConverter{}
|
||||
},
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, deploymentMode deployment.Mode, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, isDevelopmentMode bool, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
return &openShiftClusterStaticValidator{
|
||||
location: location,
|
||||
domain: domain,
|
||||
deploymentMode: deploymentMode,
|
||||
resourceID: resourceID,
|
||||
location: location,
|
||||
domain: domain,
|
||||
isDevelopmentMode: isDevelopmentMode,
|
||||
resourceID: resourceID,
|
||||
}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: func() api.OpenShiftClusterCredentialsConverter {
|
||||
|
|
|
@ -5,14 +5,13 @@ package validate
|
|||
|
||||
import (
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
func DiskSizeIsValid(sizeGB int) bool {
|
||||
return sizeGB >= 128
|
||||
}
|
||||
|
||||
func VMSizeIsValid(vmSize api.VMSize, deploymentMode deployment.Mode, isMaster bool) bool {
|
||||
func VMSizeIsValid(vmSize api.VMSize, isDevelopmentMode, isMaster bool) bool {
|
||||
if isMaster {
|
||||
switch vmSize {
|
||||
case api.VMSizeStandardD8sV3,
|
||||
|
@ -21,7 +20,7 @@ func VMSizeIsValid(vmSize api.VMSize, deploymentMode deployment.Mode, isMaster b
|
|||
return true
|
||||
}
|
||||
} else {
|
||||
if deploymentMode == deployment.Development {
|
||||
if isDevelopmentMode {
|
||||
switch vmSize {
|
||||
case api.VMSizeStandardD2sV3:
|
||||
return true
|
||||
|
|
|
@ -8,11 +8,10 @@ import (
|
|||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/util/acrtoken"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
func (m *manager) ensureACRToken(ctx context.Context) error {
|
||||
if m.env.DeploymentMode() == deployment.Development {
|
||||
if m.env.IsDevelopmentMode() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/util/acrtoken"
|
||||
"github.com/Azure/ARO-RP/pkg/util/azureclient"
|
||||
"github.com/Azure/ARO-RP/pkg/util/azureerrors"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/dns"
|
||||
"github.com/Azure/ARO-RP/pkg/util/rbac"
|
||||
"github.com/Azure/ARO-RP/pkg/util/stringutils"
|
||||
|
@ -304,7 +303,7 @@ func (m *manager) Delete(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if m.env.DeploymentMode() != deployment.Development {
|
||||
if !m.env.IsDevelopmentMode() {
|
||||
managedDomain, err := dns.ManagedDomain(m.env, m.doc.OpenShiftCluster.Properties.ClusterProfile.Domain)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
aroclient "github.com/Azure/ARO-RP/pkg/operator/clientset/versioned"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/restconfig"
|
||||
"github.com/Azure/ARO-RP/pkg/util/steps"
|
||||
"github.com/Azure/ARO-RP/pkg/util/version"
|
||||
|
@ -150,7 +149,7 @@ func (m *manager) Install(ctx context.Context) error {
|
|||
|
||||
func (m *manager) runSteps(ctx context.Context, s []steps.Step) error {
|
||||
err := steps.Run(ctx, m.log, 10*time.Second, s)
|
||||
if err != nil && m.env.DeploymentMode() != deployment.Development {
|
||||
if err != nil && !m.env.IsDevelopmentMode() {
|
||||
m.gatherFailureLogs(ctx)
|
||||
}
|
||||
return err
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
"k8s.io/client-go/kubernetes/fake"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
mock_env "github.com/Azure/ARO-RP/pkg/util/mocks/env"
|
||||
"github.com/Azure/ARO-RP/pkg/util/steps"
|
||||
"github.com/Azure/ARO-RP/pkg/util/version"
|
||||
|
@ -147,7 +146,7 @@ func TestStepRunnerWithInstaller(t *testing.T) {
|
|||
defer controller.Finish()
|
||||
|
||||
env := mock_env.NewMockInterface(controller)
|
||||
env.EXPECT().DeploymentMode().Return(deployment.Production)
|
||||
env.EXPECT().IsDevelopmentMode().Return(false)
|
||||
|
||||
h, log := testlog.New()
|
||||
m := &manager{
|
||||
|
|
|
@ -10,13 +10,11 @@ import (
|
|||
operatorv1 "github.com/openshift/api/operator/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/util/retry"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
// disableSamples disables the samples if there's no appropriate pull secret
|
||||
func (m *manager) disableSamples(ctx context.Context) error {
|
||||
if m.env.DeploymentMode() != deployment.Development &&
|
||||
if !m.env.IsDevelopmentMode() &&
|
||||
m.doc.OpenShiftCluster.Properties.ClusterProfile.PullSecret != "" {
|
||||
return nil
|
||||
}
|
||||
|
@ -37,7 +35,7 @@ func (m *manager) disableSamples(ctx context.Context) error {
|
|||
// disableOperatorHubSources disables operator hub sources if there's no
|
||||
// appropriate pull secret
|
||||
func (m *manager) disableOperatorHubSources(ctx context.Context) error {
|
||||
if m.env.DeploymentMode() != deployment.Development &&
|
||||
if !m.env.IsDevelopmentMode() &&
|
||||
m.doc.OpenShiftCluster.Properties.ClusterProfile.PullSecret != "" {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -15,14 +15,13 @@ import (
|
|||
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
"k8s.io/client-go/util/retry"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/dns"
|
||||
"github.com/Azure/ARO-RP/pkg/util/keyvault"
|
||||
utilpem "github.com/Azure/ARO-RP/pkg/util/pem"
|
||||
)
|
||||
|
||||
func (m *manager) createCertificates(ctx context.Context) error {
|
||||
if m.env.DeploymentMode() == deployment.Development {
|
||||
if m.env.IsDevelopmentMode() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -120,7 +119,7 @@ func (m *manager) ensureSecret(ctx context.Context, secrets corev1client.SecretI
|
|||
}
|
||||
|
||||
func (m *manager) configureAPIServerCertificate(ctx context.Context) error {
|
||||
if m.env.DeploymentMode() == deployment.Development {
|
||||
if m.env.IsDevelopmentMode() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -161,7 +160,7 @@ func (m *manager) configureAPIServerCertificate(ctx context.Context) error {
|
|||
}
|
||||
|
||||
func (m *manager) configureIngressCertificate(ctx context.Context) error {
|
||||
if m.env.DeploymentMode() == deployment.Development {
|
||||
if m.env.IsDevelopmentMode() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/database/cosmosdb"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
type asyncOperations struct {
|
||||
|
@ -26,8 +25,8 @@ type AsyncOperations interface {
|
|||
}
|
||||
|
||||
// NewAsyncOperations returns a new AsyncOperations
|
||||
func NewAsyncOperations(ctx context.Context, deploymentMode deployment.Mode, dbc cosmosdb.DatabaseClient) (AsyncOperations, error) {
|
||||
dbid, err := databaseName(deploymentMode)
|
||||
func NewAsyncOperations(ctx context.Context, isDevelopmentMode bool, dbc cosmosdb.DatabaseClient) (AsyncOperations, error) {
|
||||
dbid, err := databaseName(isDevelopmentMode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/database/cosmosdb"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
type billing struct {
|
||||
|
@ -30,8 +29,8 @@ type Billing interface {
|
|||
}
|
||||
|
||||
// NewBilling returns a new Billing
|
||||
func NewBilling(ctx context.Context, deploymentMode deployment.Mode, dbc cosmosdb.DatabaseClient) (Billing, error) {
|
||||
dbid, err := databaseName(deploymentMode)
|
||||
func NewBilling(ctx context.Context, isDevelopmentMode bool, dbc cosmosdb.DatabaseClient) (Billing, error) {
|
||||
dbid, err := databaseName(isDevelopmentMode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/metrics"
|
||||
dbmetrics "github.com/Azure/ARO-RP/pkg/metrics/statsd/cosmosdb"
|
||||
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/documentdb"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/encryption"
|
||||
)
|
||||
|
||||
|
@ -80,8 +79,8 @@ func NewJSONHandle(aead encryption.AEAD) (*codec.JsonHandle, error) {
|
|||
return h, nil
|
||||
}
|
||||
|
||||
func databaseName(deploymentMode deployment.Mode) (string, error) {
|
||||
if deploymentMode != deployment.Development {
|
||||
func databaseName(isDevelopmentMode bool) (string, error) {
|
||||
if !isDevelopmentMode {
|
||||
return "ARO", nil
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import (
|
|||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/database/cosmosdb"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
type monitors struct {
|
||||
|
@ -32,8 +31,8 @@ type Monitors interface {
|
|||
}
|
||||
|
||||
// NewMonitors returns a new Monitors
|
||||
func NewMonitors(ctx context.Context, deploymentMode deployment.Mode, dbc cosmosdb.DatabaseClient) (Monitors, error) {
|
||||
dbid, err := databaseName(deploymentMode)
|
||||
func NewMonitors(ctx context.Context, isDevelopmentMode bool, dbc cosmosdb.DatabaseClient) (Monitors, error) {
|
||||
dbid, err := databaseName(isDevelopmentMode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/database/cosmosdb"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -53,8 +52,8 @@ type OpenShiftClusters interface {
|
|||
}
|
||||
|
||||
// NewOpenShiftClusters returns a new OpenShiftClusters
|
||||
func NewOpenShiftClusters(ctx context.Context, deploymentMode deployment.Mode, dbc cosmosdb.DatabaseClient) (OpenShiftClusters, error) {
|
||||
dbid, err := databaseName(deploymentMode)
|
||||
func NewOpenShiftClusters(ctx context.Context, isDevelopmentMode bool, dbc cosmosdb.DatabaseClient) (OpenShiftClusters, error) {
|
||||
dbid, err := databaseName(isDevelopmentMode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/database/cosmosdb"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
type portals struct {
|
||||
|
@ -26,8 +25,8 @@ type Portal interface {
|
|||
}
|
||||
|
||||
// NewPortal returns a new Portal
|
||||
func NewPortal(ctx context.Context, deploymentMode deployment.Mode, dbc cosmosdb.DatabaseClient) (Portal, error) {
|
||||
dbid, err := databaseName(deploymentMode)
|
||||
func NewPortal(ctx context.Context, isDevelopmentMode bool, dbc cosmosdb.DatabaseClient) (Portal, error) {
|
||||
dbid, err := databaseName(isDevelopmentMode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import (
|
|||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/database/cosmosdb"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
const SubscriptionsDequeueQuery string = `SELECT * FROM Subscriptions doc WHERE (doc.deleting ?? false) AND (doc.leaseExpires ?? 0) < GetCurrentTimestamp() / 1000`
|
||||
|
@ -35,8 +34,8 @@ type Subscriptions interface {
|
|||
}
|
||||
|
||||
// NewSubscriptions returns a new Subscriptions
|
||||
func NewSubscriptions(ctx context.Context, deploymentMode deployment.Mode, dbc cosmosdb.DatabaseClient) (Subscriptions, error) {
|
||||
dbid, err := databaseName(deploymentMode)
|
||||
func NewSubscriptions(ctx context.Context, isDevelopmentMode bool, dbc cosmosdb.DatabaseClient) (Subscriptions, error) {
|
||||
dbid, err := databaseName(isDevelopmentMode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -10,13 +10,12 @@ import (
|
|||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/instancemetadata"
|
||||
"github.com/Azure/ARO-RP/pkg/util/rpauthorizer"
|
||||
)
|
||||
|
||||
type Core interface {
|
||||
DeploymentMode() deployment.Mode
|
||||
IsDevelopmentMode() bool
|
||||
instancemetadata.InstanceMetadata
|
||||
rpauthorizer.RPAuthorizer
|
||||
}
|
||||
|
@ -25,18 +24,20 @@ type core struct {
|
|||
instancemetadata.InstanceMetadata
|
||||
rpauthorizer.RPAuthorizer
|
||||
|
||||
deploymentMode deployment.Mode
|
||||
isDevelopmentMode bool
|
||||
}
|
||||
|
||||
func (c *core) DeploymentMode() deployment.Mode {
|
||||
return c.deploymentMode
|
||||
func (c *core) IsDevelopmentMode() bool {
|
||||
return c.isDevelopmentMode
|
||||
}
|
||||
|
||||
func NewCore(ctx context.Context, log *logrus.Entry) (Core, error) {
|
||||
deploymentMode := deployment.NewMode()
|
||||
log.Infof("running in %s mode", deploymentMode)
|
||||
isDevelopmentMode := IsDevelopmentMode()
|
||||
if isDevelopmentMode {
|
||||
log.Info("running in development mode")
|
||||
}
|
||||
|
||||
im, err := instancemetadata.New(ctx, deploymentMode)
|
||||
im, err := instancemetadata.New(ctx, isDevelopmentMode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -47,7 +48,7 @@ func NewCore(ctx context.Context, log *logrus.Entry) (Core, error) {
|
|||
}
|
||||
log.Infof("running on %s", im.Environment().Name)
|
||||
|
||||
rpauthorizer, err := rpauthorizer.New(deploymentMode, im)
|
||||
rpauthorizer, err := rpauthorizer.New(isDevelopmentMode, im)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -56,7 +57,7 @@ func NewCore(ctx context.Context, log *logrus.Entry) (Core, error) {
|
|||
InstanceMetadata: im,
|
||||
RPAuthorizer: rpauthorizer,
|
||||
|
||||
deploymentMode: deploymentMode,
|
||||
isDevelopmentMode: isDevelopmentMode,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -66,8 +67,10 @@ func NewCore(ctx context.Context, log *logrus.Entry) (Core, error) {
|
|||
// resolve their tenant ID, and also may access resources in a different tenant
|
||||
// (e.g. AME).
|
||||
func NewCoreForCI(ctx context.Context, log *logrus.Entry) (Core, error) {
|
||||
deploymentMode := deployment.NewMode()
|
||||
log.Infof("running in %s mode", deploymentMode)
|
||||
isDevelopmentMode := IsDevelopmentMode()
|
||||
if isDevelopmentMode {
|
||||
log.Info("running in development mode")
|
||||
}
|
||||
|
||||
im, err := instancemetadata.NewDev(false)
|
||||
if err != nil {
|
||||
|
@ -80,8 +83,8 @@ func NewCoreForCI(ctx context.Context, log *logrus.Entry) (Core, error) {
|
|||
}
|
||||
|
||||
return &core{
|
||||
InstanceMetadata: im,
|
||||
deploymentMode: deploymentMode,
|
||||
InstanceMetadata: im,
|
||||
isDevelopmentMode: isDevelopmentMode,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -8,12 +8,13 @@ import (
|
|||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/proxy"
|
||||
"github.com/Azure/ARO-RP/pkg/util/clientauthorizer"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/keyvault"
|
||||
"github.com/Azure/ARO-RP/pkg/util/refreshable"
|
||||
)
|
||||
|
@ -68,9 +69,13 @@ type Interface interface {
|
|||
}
|
||||
|
||||
func NewEnv(ctx context.Context, log *logrus.Entry) (Interface, error) {
|
||||
if deployment.NewMode() == deployment.Development {
|
||||
if IsDevelopmentMode() {
|
||||
return newDev(ctx, log)
|
||||
}
|
||||
|
||||
return newProd(ctx, log)
|
||||
}
|
||||
|
||||
func IsDevelopmentMode() bool {
|
||||
return strings.EqualFold(os.Getenv("RP_MODE"), "development")
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/proxy"
|
||||
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/compute"
|
||||
"github.com/Azure/ARO-RP/pkg/util/clientauthorizer"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/keyvault"
|
||||
"github.com/Azure/ARO-RP/pkg/util/refreshable"
|
||||
"github.com/Azure/ARO-RP/pkg/util/version"
|
||||
|
@ -63,7 +62,7 @@ func newProd(ctx context.Context, log *logrus.Entry) (*prod, error) {
|
|||
}
|
||||
}
|
||||
|
||||
if deployment.NewMode() != deployment.Development {
|
||||
if !IsDevelopmentMode() {
|
||||
for _, key := range []string{
|
||||
"CLUSTER_MDSD_CONFIG_VERSION",
|
||||
"MDSD_ENVIRONMENT",
|
||||
|
@ -79,7 +78,7 @@ func newProd(ctx context.Context, log *logrus.Entry) (*prod, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
dialer, err := proxy.NewDialer(core.DeploymentMode())
|
||||
dialer, err := proxy.NewDialer(core.IsDevelopmentMode())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -267,7 +267,7 @@ func (f *frontend) setupRouter() *mux.Router {
|
|||
r.Use(middleware.Log(f.env, f.auditLog, f.baseLog.WithField("component", "access")))
|
||||
r.Use(middleware.Metrics(f.m))
|
||||
r.Use(middleware.Panic)
|
||||
r.Use(middleware.Headers(f.env.DeploymentMode()))
|
||||
r.Use(middleware.Headers(f.env.IsDevelopmentMode()))
|
||||
r.Use(middleware.Validate(f.env, f.apis))
|
||||
r.Use(middleware.Body)
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import (
|
|||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
mock_env "github.com/Azure/ARO-RP/pkg/util/mocks/env"
|
||||
testlog "github.com/Azure/ARO-RP/test/util/log"
|
||||
)
|
||||
|
@ -176,7 +175,7 @@ func TestRoutesAreNamedWithLowerCasePaths(t *testing.T) {
|
|||
defer controller.Finish()
|
||||
|
||||
_env := mock_env.NewMockInterface(controller)
|
||||
_env.EXPECT().DeploymentMode().AnyTimes().Return(deployment.Production)
|
||||
_env.EXPECT().IsDevelopmentMode().AnyTimes().Return(false)
|
||||
|
||||
f := &frontend{
|
||||
baseLog: logrus.NewEntry(logrus.StandardLogger()),
|
||||
|
|
|
@ -6,11 +6,9 @@ package middleware
|
|||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
func Headers(deploymentMode deployment.Mode) func(http.Handler) http.Handler {
|
||||
func Headers(isDevelopmentMode bool) func(http.Handler) http.Handler {
|
||||
return func(h http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
@ -19,7 +17,7 @@ func Headers(deploymentMode deployment.Mode) func(http.Handler) http.Handler {
|
|||
w.Header().Set("X-Ms-Client-Request-Id", r.Header.Get("X-Ms-Client-Request-Id"))
|
||||
}
|
||||
|
||||
if deploymentMode == deployment.Development {
|
||||
if isDevelopmentMode {
|
||||
r.Header.Set("Referer", "https://localhost:8443"+r.URL.String())
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ func (f *frontend) putOrPatchOpenShiftCluster(w http.ResponseWriter, r *http.Req
|
|||
var b []byte
|
||||
err := cosmosdb.RetryOnPreconditionFailed(func() error {
|
||||
var err error
|
||||
b, err = f._putOrPatchOpenShiftCluster(ctx, log, r, &header, f.apis[vars["api-version"]].OpenShiftClusterConverter(), f.apis[vars["api-version"]].OpenShiftClusterStaticValidator(f.env.Location(), f.env.Domain(), f.env.DeploymentMode(), r.URL.Path))
|
||||
b, err = f._putOrPatchOpenShiftCluster(ctx, log, r, &header, f.apis[vars["api-version"]].OpenShiftClusterConverter(), f.apis[vars["api-version"]].OpenShiftClusterStaticValidator(f.env.Location(), f.env.Domain(), f.env.IsDevelopmentMode(), r.URL.Path))
|
||||
return err
|
||||
})
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/proxy"
|
||||
"github.com/Azure/ARO-RP/pkg/util/bucket"
|
||||
"github.com/Azure/ARO-RP/pkg/util/clusterdata"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/version"
|
||||
testdatabase "github.com/Azure/ARO-RP/test/database"
|
||||
)
|
||||
|
@ -38,7 +37,7 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
|
|||
apis := map[string]*api.Version{
|
||||
"admin": {
|
||||
OpenShiftClusterConverter: api.APIs["admin"].OpenShiftClusterConverter,
|
||||
OpenShiftClusterStaticValidator: func(string, string, deployment.Mode, string) api.OpenShiftClusterStaticValidator {
|
||||
OpenShiftClusterStaticValidator: func(string, string, bool, string) api.OpenShiftClusterStaticValidator {
|
||||
return &dummyOpenShiftClusterValidator{}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: api.APIs["admin"].OpenShiftClusterCredentialsConverter,
|
||||
|
@ -280,7 +279,7 @@ func TestPutOrPatchOpenShiftCluster(t *testing.T) {
|
|||
apis := map[string]*api.Version{
|
||||
"2020-04-30": {
|
||||
OpenShiftClusterConverter: api.APIs["2020-04-30"].OpenShiftClusterConverter,
|
||||
OpenShiftClusterStaticValidator: func(string, string, deployment.Mode, string) api.OpenShiftClusterStaticValidator {
|
||||
OpenShiftClusterStaticValidator: func(string, string, bool, string) api.OpenShiftClusterStaticValidator {
|
||||
return &dummyOpenShiftClusterValidator{}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: api.APIs["2020-04-30"].OpenShiftClusterCredentialsConverter,
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
// checkReady checks the ready status of the frontend to make it consistent
|
||||
|
@ -16,7 +15,7 @@ import (
|
|||
// minutes before indicating health. This ensures that there will be a gap in
|
||||
// our health metric if we crash or restart.
|
||||
func (f *frontend) checkReady() bool {
|
||||
if f.env.DeploymentMode() != deployment.Development &&
|
||||
if !f.env.IsDevelopmentMode() &&
|
||||
time.Since(f.startTime) < 2*time.Minute {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
"github.com/Azure/ARO-RP/pkg/metrics/noop"
|
||||
"github.com/Azure/ARO-RP/pkg/util/clientauthorizer"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/log/audit"
|
||||
mock_env "github.com/Azure/ARO-RP/pkg/util/mocks/env"
|
||||
mock_keyvault "github.com/Azure/ARO-RP/pkg/util/mocks/keyvault"
|
||||
|
@ -57,7 +56,7 @@ func TestSecurity(t *testing.T) {
|
|||
keyvault.EXPECT().GetCertificateSecret(gomock.Any(), env.RPServerSecretName).AnyTimes().Return(serverkey, servercerts, nil)
|
||||
|
||||
_env := mock_env.NewMockInterface(controller)
|
||||
_env.EXPECT().DeploymentMode().AnyTimes().Return(deployment.Production)
|
||||
_env.EXPECT().IsDevelopmentMode().AnyTimes().Return(false)
|
||||
_env.EXPECT().Environment().AnyTimes().Return(&azure.PublicCloud)
|
||||
_env.EXPECT().Hostname().AnyTimes().Return("testhost")
|
||||
_env.EXPECT().Location().AnyTimes().Return("eastus")
|
||||
|
|
|
@ -26,7 +26,6 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/database/cosmosdb"
|
||||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
"github.com/Azure/ARO-RP/pkg/util/clientauthorizer"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
mock_env "github.com/Azure/ARO-RP/pkg/util/mocks/env"
|
||||
mock_keyvault "github.com/Azure/ARO-RP/pkg/util/mocks/keyvault"
|
||||
utiltls "github.com/Azure/ARO-RP/pkg/util/tls"
|
||||
|
@ -90,7 +89,7 @@ func newTestInfra(t *testing.T) *testInfra {
|
|||
keyvault.EXPECT().GetCertificateSecret(gomock.Any(), env.RPServerSecretName).AnyTimes().Return(serverkey, servercerts, nil)
|
||||
|
||||
_env := mock_env.NewMockInterface(controller)
|
||||
_env.EXPECT().DeploymentMode().AnyTimes().Return(deployment.Production)
|
||||
_env.EXPECT().IsDevelopmentMode().AnyTimes().Return(false)
|
||||
_env.EXPECT().Environment().AnyTimes().Return(&azure.PublicCloud)
|
||||
_env.EXPECT().Hostname().AnyTimes().Return("testhost")
|
||||
_env.EXPECT().Location().AnyTimes().Return("eastus")
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
|
||||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
"github.com/Azure/ARO-RP/pkg/metrics"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/recover"
|
||||
)
|
||||
|
||||
|
@ -106,7 +105,7 @@ func (s *statsd) run() {
|
|||
|
||||
func (s *statsd) dial() (err error) {
|
||||
path := "/var/etw/mdm_statsd.socket"
|
||||
if s.env.DeploymentMode() == deployment.Development {
|
||||
if s.env.IsDevelopmentMode() {
|
||||
path = "mdm_statsd.socket"
|
||||
}
|
||||
|
||||
|
@ -127,7 +126,7 @@ func (s *statsd) write(m *metric) (err error) {
|
|||
if s.conn == nil {
|
||||
err = s.dial()
|
||||
if err != nil {
|
||||
if s.env.DeploymentMode() == deployment.Development {
|
||||
if s.env.IsDevelopmentMode() {
|
||||
err = nil
|
||||
}
|
||||
return
|
||||
|
|
|
@ -23,7 +23,6 @@ import (
|
|||
arov1alpha1 "github.com/Azure/ARO-RP/pkg/operator/apis/aro.openshift.io/v1alpha1"
|
||||
aroclient "github.com/Azure/ARO-RP/pkg/operator/clientset/versioned"
|
||||
"github.com/Azure/ARO-RP/pkg/operator/controllers"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
// CheckerController runs a number of checkers
|
||||
|
@ -33,11 +32,11 @@ type CheckerController struct {
|
|||
checkers []Checker
|
||||
}
|
||||
|
||||
func NewReconciler(log *logrus.Entry, maocli maoclient.Interface, arocli aroclient.Interface, role string, deploymentMode deployment.Mode) *CheckerController {
|
||||
func NewReconciler(log *logrus.Entry, maocli maoclient.Interface, arocli aroclient.Interface, role string, isDevelopmentMode bool) *CheckerController {
|
||||
checkers := []Checker{NewInternetChecker(log, arocli, role)}
|
||||
|
||||
if role == operator.RoleMaster {
|
||||
checkers = append(checkers, NewMachineChecker(log, maocli, arocli, role, deploymentMode))
|
||||
checkers = append(checkers, NewMachineChecker(log, maocli, arocli, role, isDevelopmentMode))
|
||||
}
|
||||
|
||||
return &CheckerController{
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
arov1alpha1 "github.com/Azure/ARO-RP/pkg/operator/apis/aro.openshift.io/v1alpha1"
|
||||
aroclient "github.com/Azure/ARO-RP/pkg/operator/clientset/versioned"
|
||||
"github.com/Azure/ARO-RP/pkg/operator/controllers"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
_ "github.com/Azure/ARO-RP/pkg/util/scheme"
|
||||
)
|
||||
|
||||
|
@ -32,20 +31,20 @@ const (
|
|||
|
||||
// MachineChecker reconciles the alertmanager webhook
|
||||
type MachineChecker struct {
|
||||
clustercli maoclient.Interface
|
||||
arocli aroclient.Interface
|
||||
log *logrus.Entry
|
||||
deploymentMode deployment.Mode
|
||||
role string
|
||||
clustercli maoclient.Interface
|
||||
arocli aroclient.Interface
|
||||
log *logrus.Entry
|
||||
isDevelopmentMode bool
|
||||
role string
|
||||
}
|
||||
|
||||
func NewMachineChecker(log *logrus.Entry, clustercli maoclient.Interface, arocli aroclient.Interface, role string, deploymentMode deployment.Mode) *MachineChecker {
|
||||
func NewMachineChecker(log *logrus.Entry, clustercli maoclient.Interface, arocli aroclient.Interface, role string, isDevelopmentMode bool) *MachineChecker {
|
||||
return &MachineChecker{
|
||||
clustercli: clustercli,
|
||||
arocli: arocli,
|
||||
log: log,
|
||||
deploymentMode: deploymentMode,
|
||||
role: role,
|
||||
clustercli: clustercli,
|
||||
arocli: arocli,
|
||||
log: log,
|
||||
isDevelopmentMode: isDevelopmentMode,
|
||||
role: role,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +79,7 @@ func (r *MachineChecker) machineValid(ctx context.Context, machine *machinev1bet
|
|||
return []error{fmt.Errorf("machine %s: failed to read provider spec: %T", machine.Name, o)}
|
||||
}
|
||||
|
||||
if !validate.VMSizeIsValid(api.VMSize(machineProviderSpec.VMSize), r.deploymentMode, isMaster) {
|
||||
if !validate.VMSizeIsValid(api.VMSize(machineProviderSpec.VMSize), r.isDevelopmentMode, isMaster) {
|
||||
errs = append(errs, fmt.Errorf("machine %s: invalid VM size '%s'", machine.Name, machineProviderSpec.VMSize))
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ import (
|
|||
arov1alpha1 "github.com/Azure/ARO-RP/pkg/operator/apis/aro.openshift.io/v1alpha1"
|
||||
aroclient "github.com/Azure/ARO-RP/pkg/operator/clientset/versioned"
|
||||
"github.com/Azure/ARO-RP/pkg/operator/controllers/genevalogging"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/dynamichelper"
|
||||
"github.com/Azure/ARO-RP/pkg/util/pullsecret"
|
||||
"github.com/Azure/ARO-RP/pkg/util/ready"
|
||||
|
@ -102,7 +101,7 @@ func (o *operator) resources() ([]runtime.Object, error) {
|
|||
for i := range d.Spec.Template.Spec.Containers {
|
||||
d.Spec.Template.Spec.Containers[i].Image = o.env.AROOperatorImage()
|
||||
|
||||
if o.env.DeploymentMode() == deployment.Development {
|
||||
if o.env.IsDevelopmentMode() {
|
||||
d.Spec.Template.Spec.Containers[i].Env = append(d.Spec.Template.Spec.Containers[i].Env, corev1.EnvVar{
|
||||
Name: "RP_MODE",
|
||||
Value: "development",
|
||||
|
|
|
@ -24,7 +24,6 @@ import (
|
|||
"golang.org/x/oauth2/microsoft"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/roundtripper"
|
||||
)
|
||||
|
||||
|
@ -88,11 +87,11 @@ type claims struct {
|
|||
}
|
||||
|
||||
type aad struct {
|
||||
deploymentMode deployment.Mode
|
||||
log *logrus.Entry
|
||||
env env.Core
|
||||
now func() time.Time
|
||||
rt http.RoundTripper
|
||||
isDevelopmentMode bool
|
||||
log *logrus.Entry
|
||||
env env.Core
|
||||
now func() time.Time
|
||||
rt http.RoundTripper
|
||||
|
||||
tenantID string
|
||||
clientID string
|
||||
|
@ -123,11 +122,11 @@ func NewAAD(log *logrus.Entry,
|
|||
}
|
||||
|
||||
a := &aad{
|
||||
deploymentMode: env.DeploymentMode(),
|
||||
log: log,
|
||||
env: env,
|
||||
now: time.Now,
|
||||
rt: http.DefaultTransport,
|
||||
isDevelopmentMode: env.IsDevelopmentMode(),
|
||||
log: log,
|
||||
env: env,
|
||||
now: time.Now,
|
||||
rt: http.DefaultTransport,
|
||||
|
||||
tenantID: env.TenantID(),
|
||||
clientID: clientID,
|
||||
|
|
|
@ -26,7 +26,6 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/oauth2"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
mock_env "github.com/Azure/ARO-RP/pkg/util/mocks/env"
|
||||
"github.com/Azure/ARO-RP/pkg/util/roundtripper"
|
||||
utiltls "github.com/Azure/ARO-RP/pkg/util/tls"
|
||||
|
@ -160,7 +159,7 @@ func TestAAD(t *testing.T) {
|
|||
controller := gomock.NewController(t)
|
||||
defer controller.Finish()
|
||||
env := mock_env.NewMockInterface(controller)
|
||||
env.EXPECT().DeploymentMode().AnyTimes().Return(deployment.Production)
|
||||
env.EXPECT().IsDevelopmentMode().AnyTimes().Return(false)
|
||||
env.EXPECT().TenantID().AnyTimes().Return("")
|
||||
|
||||
a, err := NewAAD(logrus.NewEntry(logrus.StandardLogger()), env, logrus.NewEntry(logrus.StandardLogger()), "", make([]byte, 32), "", nil, nil, nil, mux.NewRouter(), nil)
|
||||
|
@ -256,7 +255,7 @@ func TestRedirect(t *testing.T) {
|
|||
controller := gomock.NewController(t)
|
||||
defer controller.Finish()
|
||||
env := mock_env.NewMockInterface(controller)
|
||||
env.EXPECT().DeploymentMode().AnyTimes().Return(deployment.Production)
|
||||
env.EXPECT().IsDevelopmentMode().AnyTimes().Return(false)
|
||||
env.EXPECT().TenantID().AnyTimes().Return("")
|
||||
|
||||
a, err := NewAAD(logrus.NewEntry(logrus.StandardLogger()), env, logrus.NewEntry(logrus.StandardLogger()), "", make([]byte, 32), "", nil, nil, nil, mux.NewRouter(), nil)
|
||||
|
@ -372,7 +371,7 @@ func TestLogout(t *testing.T) {
|
|||
controller := gomock.NewController(t)
|
||||
defer controller.Finish()
|
||||
env := mock_env.NewMockInterface(controller)
|
||||
env.EXPECT().DeploymentMode().AnyTimes().Return(deployment.Production)
|
||||
env.EXPECT().IsDevelopmentMode().AnyTimes().Return(false)
|
||||
env.EXPECT().TenantID().AnyTimes().Return("")
|
||||
|
||||
a, err := NewAAD(logrus.NewEntry(logrus.StandardLogger()), env, logrus.NewEntry(logrus.StandardLogger()), "", make([]byte, 32), "", nil, nil, nil, mux.NewRouter(), nil)
|
||||
|
@ -734,7 +733,7 @@ func TestCallback(t *testing.T) {
|
|||
controller := gomock.NewController(t)
|
||||
defer controller.Finish()
|
||||
env := mock_env.NewMockInterface(controller)
|
||||
env.EXPECT().DeploymentMode().AnyTimes().Return(deployment.Production)
|
||||
env.EXPECT().IsDevelopmentMode().AnyTimes().Return(false)
|
||||
env.EXPECT().TenantID().AnyTimes().Return("")
|
||||
|
||||
a, err := NewAAD(logrus.NewEntry(logrus.StandardLogger()), env, logrus.NewEntry(logrus.StandardLogger()), "", make([]byte, 32), clientID, clientkey, clientcerts, groups, mux.NewRouter(), tt.verifier)
|
||||
|
@ -851,7 +850,7 @@ func TestClientAssertion(t *testing.T) {
|
|||
defer controller.Finish()
|
||||
env := mock_env.NewMockInterface(controller)
|
||||
env.EXPECT().Environment().AnyTimes().Return(&azure.PublicCloud)
|
||||
env.EXPECT().DeploymentMode().AnyTimes().Return(deployment.Production)
|
||||
env.EXPECT().IsDevelopmentMode().AnyTimes().Return(false)
|
||||
env.EXPECT().TenantID().AnyTimes().Return("")
|
||||
|
||||
clientID := "00000000-0000-0000-0000-000000000000"
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/portal/middleware"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
mock_env "github.com/Azure/ARO-RP/pkg/util/mocks/env"
|
||||
utiltls "github.com/Azure/ARO-RP/pkg/util/tls"
|
||||
testdatabase "github.com/Azure/ARO-RP/test/database"
|
||||
|
@ -39,7 +38,7 @@ func TestSecurity(t *testing.T) {
|
|||
defer controller.Finish()
|
||||
|
||||
_env := mock_env.NewMockCore(controller)
|
||||
_env.EXPECT().DeploymentMode().AnyTimes().Return(deployment.Production)
|
||||
_env.EXPECT().IsDevelopmentMode().AnyTimes().Return(false)
|
||||
_env.EXPECT().Location().AnyTimes().Return("eastus")
|
||||
_env.EXPECT().TenantID().AnyTimes().Return("00000000-0000-0000-0000-000000000001")
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
"github.com/Azure/ARO-RP/pkg/portal/middleware"
|
||||
"github.com/Azure/ARO-RP/pkg/proxy"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -166,7 +165,7 @@ func (s *ssh) new(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
port := ""
|
||||
if s.env.DeploymentMode() == deployment.Development {
|
||||
if s.env.IsDevelopmentMode() {
|
||||
port = "-p 2222 "
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/database/cosmosdb"
|
||||
"github.com/Azure/ARO-RP/pkg/portal/middleware"
|
||||
"github.com/Azure/ARO-RP/pkg/portal/util/responsewriter"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
mock_env "github.com/Azure/ARO-RP/pkg/util/mocks/env"
|
||||
utiltls "github.com/Azure/ARO-RP/pkg/util/tls"
|
||||
testdatabase "github.com/Azure/ARO-RP/test/database"
|
||||
|
@ -40,7 +39,6 @@ func TestNew(t *testing.T) {
|
|||
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
deploymentMode deployment.Mode
|
||||
r func(*http.Request)
|
||||
checker func(*testdatabase.Checker, *cosmosdb.FakePortalDocumentClient)
|
||||
wantStatusCode int
|
||||
|
@ -138,7 +136,7 @@ func TestNew(t *testing.T) {
|
|||
defer ctrl.Finish()
|
||||
|
||||
env := mock_env.NewMockCore(ctrl)
|
||||
env.EXPECT().DeploymentMode().AnyTimes().Return(tt.deploymentMode)
|
||||
env.EXPECT().IsDevelopmentMode().AnyTimes().Return(false)
|
||||
|
||||
aadAuthenticatedRouter := &mux.Router{}
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@ import (
|
|||
"path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
type Dialer interface {
|
||||
|
@ -110,8 +108,8 @@ func (d *dev) DialContext(ctx context.Context, network, address string) (net.Con
|
|||
return &conn{Conn: c, r: r}, nil
|
||||
}
|
||||
|
||||
func NewDialer(deploymentMode deployment.Mode) (Dialer, error) {
|
||||
if deploymentMode != deployment.Development {
|
||||
func NewDialer(isDevelopmentMode bool) (Dialer, error) {
|
||||
if !isDevelopmentMode {
|
||||
return &prod{}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
|
||||
mgmtredhatopenshift20200430 "github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
)
|
||||
|
||||
// OpenShiftClustersClient is a minimal interface for azure OpenshiftClustersClient
|
||||
|
@ -32,7 +32,7 @@ var _ OpenShiftClustersClient = &openShiftClustersClient{}
|
|||
// NewOpenShiftClustersClient creates a new OpenShiftClustersClient
|
||||
func NewOpenShiftClustersClient(environment *azure.Environment, subscriptionID string, authorizer autorest.Authorizer) OpenShiftClustersClient {
|
||||
var client mgmtredhatopenshift20200430.OpenShiftClustersClient
|
||||
if deployment.NewMode() == deployment.Development {
|
||||
if env.IsDevelopmentMode() {
|
||||
client = mgmtredhatopenshift20200430.NewOpenShiftClustersClientWithBaseURI("https://localhost:8443", subscriptionID)
|
||||
client.Sender = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
|
||||
mgmtredhatopenshift20200430 "github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
)
|
||||
|
||||
// OperationsClient is a minimal interface for azure OperationsClient
|
||||
|
@ -28,7 +28,7 @@ var _ OperationsClient = &operationsClient{}
|
|||
// NewOperationsClient creates a new OperationsClient
|
||||
func NewOperationsClient(environment *azure.Environment, subscriptionID string, authorizer autorest.Authorizer) OperationsClient {
|
||||
var client mgmtredhatopenshift20200430.OperationsClient
|
||||
if deployment.NewMode() == deployment.Development {
|
||||
if env.IsDevelopmentMode() {
|
||||
client = mgmtredhatopenshift20200430.NewOperationsClientWithBaseURI("https://localhost:8443", subscriptionID)
|
||||
client.Sender = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
|
||||
mgmtredhatopenshift20210131preview "github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2021-01-31-preview/redhatopenshift"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
)
|
||||
|
||||
// OpenShiftClustersClient is a minimal interface for azure OpenshiftClustersClient
|
||||
|
@ -32,7 +32,7 @@ var _ OpenShiftClustersClient = &openShiftClustersClient{}
|
|||
// NewOpenShiftClustersClient creates a new OpenShiftClustersClient
|
||||
func NewOpenShiftClustersClient(environment *azure.Environment, subscriptionID string, authorizer autorest.Authorizer) OpenShiftClustersClient {
|
||||
var client mgmtredhatopenshift20210131preview.OpenShiftClustersClient
|
||||
if deployment.NewMode() == deployment.Development {
|
||||
if env.IsDevelopmentMode() {
|
||||
client = mgmtredhatopenshift20210131preview.NewOpenShiftClustersClientWithBaseURI("https://localhost:8443", subscriptionID)
|
||||
client.Sender = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
|
||||
mgmtredhatopenshift20210131preview "github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2021-01-31-preview/redhatopenshift"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
)
|
||||
|
||||
// OperationsClient is a minimal interface for azure OperationsClient
|
||||
|
@ -28,7 +28,7 @@ var _ OperationsClient = &operationsClient{}
|
|||
// NewOperationsClient creates a new OperationsClient
|
||||
func NewOperationsClient(environment *azure.Environment, subscriptionID string, authorizer autorest.Authorizer) OperationsClient {
|
||||
var client mgmtredhatopenshift20210131preview.OperationsClient
|
||||
if deployment.NewMode() == deployment.Development {
|
||||
if env.IsDevelopmentMode() {
|
||||
client = mgmtredhatopenshift20210131preview.NewOperationsClientWithBaseURI("https://localhost:8443", subscriptionID)
|
||||
client.Sender = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/database/cosmosdb"
|
||||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/storage"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/feature"
|
||||
)
|
||||
|
||||
|
@ -150,7 +149,7 @@ func isSubscriptionRegisteredForE2E(sub *api.SubscriptionProperties) bool {
|
|||
// storage account. This is used later on by the billing e2e
|
||||
func (m *manager) createOrUpdateE2EBlob(ctx context.Context, doc *api.BillingDocument) error {
|
||||
//skip updating the storage account if this is a dev scenario
|
||||
if m.env.DeploymentMode() == deployment.Development {
|
||||
if m.env.IsDevelopmentMode() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
mock_env "github.com/Azure/ARO-RP/pkg/util/mocks/env"
|
||||
testdatabase "github.com/Azure/ARO-RP/test/database"
|
||||
)
|
||||
|
@ -197,7 +196,7 @@ func TestDelete(t *testing.T) {
|
|||
defer controller.Finish()
|
||||
|
||||
_env := mock_env.NewMockInterface(controller)
|
||||
_env.EXPECT().DeploymentMode().AnyTimes().Return(deployment.Production)
|
||||
_env.EXPECT().IsDevelopmentMode().AnyTimes().Return(false)
|
||||
|
||||
log := logrus.NewEntry(logrus.StandardLogger())
|
||||
openShiftClusterDatabase, _ := testdatabase.NewFakeOpenShiftClusters()
|
||||
|
@ -389,7 +388,7 @@ func TestEnsure(t *testing.T) {
|
|||
defer controller.Finish()
|
||||
|
||||
_env := mock_env.NewMockInterface(controller)
|
||||
_env.EXPECT().DeploymentMode().AnyTimes().Return(deployment.Production)
|
||||
_env.EXPECT().IsDevelopmentMode().AnyTimes().Return(false)
|
||||
|
||||
log := logrus.NewEntry(logrus.StandardLogger())
|
||||
openShiftClusterDatabase, _ := testdatabase.NewFakeOpenShiftClusters()
|
||||
|
|
|
@ -39,7 +39,6 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/network"
|
||||
redhatopenshift20200430 "github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/redhatopenshift/2020-04-30/redhatopenshift"
|
||||
redhatopenshift20210131preview "github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/redhatopenshift/2021-01-31-preview/redhatopenshift"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/rbac"
|
||||
)
|
||||
|
||||
|
@ -77,7 +76,7 @@ func (errs errors) Error() string {
|
|||
}
|
||||
|
||||
func New(log *logrus.Entry, env env.Core, ci bool) (*Cluster, error) {
|
||||
if env.DeploymentMode() == deployment.Development {
|
||||
if env.IsDevelopmentMode() {
|
||||
for _, key := range []string{
|
||||
"AZURE_FP_CLIENT_ID",
|
||||
} {
|
||||
|
@ -116,7 +115,7 @@ func New(log *logrus.Entry, env env.Core, ci bool) (*Cluster, error) {
|
|||
}
|
||||
|
||||
if ci {
|
||||
if env.DeploymentMode() == deployment.Development {
|
||||
if env.IsDevelopmentMode() {
|
||||
c.ciParentVnet = fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/virtualNetworks/dev-vnet", c.env.SubscriptionID(), c.env.ResourceGroup())
|
||||
} else {
|
||||
c.ciParentVnet = "/subscriptions/46626fc5-476d-41ad-8c76-2ec49c6994eb/resourceGroups/e2einfra-eastus/providers/Microsoft.Network/virtualNetworks/dev-vnet"
|
||||
|
@ -417,8 +416,7 @@ func (c *Cluster) createCluster(ctx context.Context, vnetResourceGroup, clusterN
|
|||
Location: c.env.Location(),
|
||||
}
|
||||
|
||||
switch c.env.DeploymentMode() {
|
||||
case deployment.Development:
|
||||
if c.env.IsDevelopmentMode() {
|
||||
oc.Properties.WorkerProfiles[0].VMSize = api.VMSizeStandardD2sV3
|
||||
ext := api.APIs[v20210131preview.APIVersion].OpenShiftClusterConverter().ToExternal(&oc)
|
||||
data, err := json.Marshal(ext)
|
||||
|
@ -433,7 +431,8 @@ func (c *Cluster) createCluster(ctx context.Context, vnetResourceGroup, clusterN
|
|||
}
|
||||
|
||||
return c.openshiftclustersv20210131preview.CreateOrUpdateAndWait(ctx, vnetResourceGroup, clusterName, ocExt)
|
||||
default:
|
||||
|
||||
} else {
|
||||
ext := api.APIs[v20200430.APIVersion].OpenShiftClusterConverter().ToExternal(&oc)
|
||||
data, err := json.Marshal(ext)
|
||||
if err != nil {
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
package deployment
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the Apache License 2.0.
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Mode int
|
||||
|
||||
const (
|
||||
Production Mode = iota
|
||||
Integration
|
||||
Development
|
||||
|
||||
strDevelopment = "development"
|
||||
strIntegration = "int"
|
||||
strProduction = "production"
|
||||
)
|
||||
|
||||
func NewMode() Mode {
|
||||
switch strings.ToLower(os.Getenv("RP_MODE")) {
|
||||
case strDevelopment:
|
||||
return Development
|
||||
case strIntegration:
|
||||
return Integration
|
||||
default:
|
||||
return Production
|
||||
}
|
||||
}
|
||||
|
||||
func (m Mode) String() string {
|
||||
switch m {
|
||||
case Development:
|
||||
return strDevelopment
|
||||
case Integration:
|
||||
return strIntegration
|
||||
default:
|
||||
return strProduction
|
||||
}
|
||||
}
|
|
@ -7,8 +7,6 @@ import (
|
|||
"context"
|
||||
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
type InstanceMetadata interface {
|
||||
|
@ -53,8 +51,8 @@ func (im *instanceMetadata) Environment() *azure.Environment {
|
|||
return im.environment
|
||||
}
|
||||
|
||||
func New(ctx context.Context, deploymentMode deployment.Mode) (InstanceMetadata, error) {
|
||||
if deploymentMode == deployment.Development {
|
||||
func New(ctx context.Context, isDevelopmentMode bool) (InstanceMetadata, error) {
|
||||
if isDevelopmentMode {
|
||||
return NewDev(true)
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import (
|
|||
|
||||
env "github.com/Azure/ARO-RP/pkg/env"
|
||||
clientauthorizer "github.com/Azure/ARO-RP/pkg/util/clientauthorizer"
|
||||
deployment "github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
keyvault "github.com/Azure/ARO-RP/pkg/util/keyvault"
|
||||
refreshable "github.com/Azure/ARO-RP/pkg/util/refreshable"
|
||||
)
|
||||
|
@ -45,20 +44,6 @@ func (m *MockCore) EXPECT() *MockCoreMockRecorder {
|
|||
return m.recorder
|
||||
}
|
||||
|
||||
// DeploymentMode mocks base method
|
||||
func (m *MockCore) DeploymentMode() deployment.Mode {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DeploymentMode")
|
||||
ret0, _ := ret[0].(deployment.Mode)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeploymentMode indicates an expected call of DeploymentMode
|
||||
func (mr *MockCoreMockRecorder) DeploymentMode() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeploymentMode", reflect.TypeOf((*MockCore)(nil).DeploymentMode))
|
||||
}
|
||||
|
||||
// Environment mocks base method
|
||||
func (m *MockCore) Environment() *azure.Environment {
|
||||
m.ctrl.T.Helper()
|
||||
|
@ -87,6 +72,20 @@ func (mr *MockCoreMockRecorder) Hostname() *gomock.Call {
|
|||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Hostname", reflect.TypeOf((*MockCore)(nil).Hostname))
|
||||
}
|
||||
|
||||
// IsDevelopmentMode mocks base method
|
||||
func (m *MockCore) IsDevelopmentMode() bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IsDevelopmentMode")
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// IsDevelopmentMode indicates an expected call of IsDevelopmentMode
|
||||
func (mr *MockCoreMockRecorder) IsDevelopmentMode() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDevelopmentMode", reflect.TypeOf((*MockCore)(nil).IsDevelopmentMode))
|
||||
}
|
||||
|
||||
// Location mocks base method
|
||||
func (m *MockCore) Location() string {
|
||||
m.ctrl.T.Helper()
|
||||
|
@ -308,20 +307,6 @@ func (mr *MockInterfaceMockRecorder) ClusterKeyvault() *gomock.Call {
|
|||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ClusterKeyvault", reflect.TypeOf((*MockInterface)(nil).ClusterKeyvault))
|
||||
}
|
||||
|
||||
// DeploymentMode mocks base method
|
||||
func (m *MockInterface) DeploymentMode() deployment.Mode {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DeploymentMode")
|
||||
ret0, _ := ret[0].(deployment.Mode)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DeploymentMode indicates an expected call of DeploymentMode
|
||||
func (mr *MockInterfaceMockRecorder) DeploymentMode() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeploymentMode", reflect.TypeOf((*MockInterface)(nil).DeploymentMode))
|
||||
}
|
||||
|
||||
// DialContext mocks base method
|
||||
func (m *MockInterface) DialContext(arg0 context.Context, arg1, arg2 string) (net.Conn, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
@ -436,6 +421,20 @@ func (mr *MockInterfaceMockRecorder) InitializeAuthorizers() *gomock.Call {
|
|||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitializeAuthorizers", reflect.TypeOf((*MockInterface)(nil).InitializeAuthorizers))
|
||||
}
|
||||
|
||||
// IsDevelopmentMode mocks base method
|
||||
func (m *MockInterface) IsDevelopmentMode() bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IsDevelopmentMode")
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// IsDevelopmentMode indicates an expected call of IsDevelopmentMode
|
||||
func (mr *MockInterfaceMockRecorder) IsDevelopmentMode() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDevelopmentMode", reflect.TypeOf((*MockInterface)(nil).IsDevelopmentMode))
|
||||
}
|
||||
|
||||
// Listen mocks base method
|
||||
func (m *MockInterface) Listen() (net.Listener, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/azure/auth"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/instancemetadata"
|
||||
)
|
||||
|
||||
|
@ -40,8 +39,8 @@ func (prodRPAuthorizer) NewRPAuthorizer(resource string) (autorest.Authorizer, e
|
|||
return auth.NewAuthorizerFromEnvironmentWithResource(resource)
|
||||
}
|
||||
|
||||
func New(deploymentMode deployment.Mode, im instancemetadata.InstanceMetadata) (RPAuthorizer, error) {
|
||||
if deploymentMode == deployment.Development {
|
||||
func New(isDevelopmentMode bool, im instancemetadata.InstanceMetadata) (RPAuthorizer, error) {
|
||||
if isDevelopmentMode {
|
||||
for _, key := range []string{
|
||||
"AZURE_RP_CLIENT_ID",
|
||||
"AZURE_RP_CLIENT_SECRET",
|
||||
|
|
|
@ -16,11 +16,11 @@ import (
|
|||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api/admin"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
)
|
||||
|
||||
func adminRequest(ctx context.Context, method, path string, params url.Values, in, out interface{}) (*http.Response, error) {
|
||||
if deployment.NewMode() != deployment.Development {
|
||||
if !env.IsDevelopmentMode() {
|
||||
return nil, errors.New("only development RP mode is supported")
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ import (
|
|||
redhatopenshift20200430 "github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/redhatopenshift/2020-04-30/redhatopenshift"
|
||||
redhatopenshift20210131preview "github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/redhatopenshift/2021-01-31-preview/redhatopenshift"
|
||||
"github.com/Azure/ARO-RP/pkg/util/cluster"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/test/util/kubeadminkubeconfig"
|
||||
)
|
||||
|
||||
|
@ -62,7 +61,7 @@ var (
|
|||
)
|
||||
|
||||
func skipIfNotInDevelopmentEnv() {
|
||||
if _env.DeploymentMode() != deployment.Development {
|
||||
if !_env.IsDevelopmentMode() {
|
||||
Skip("skipping tests in non-development environment")
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче