зеркало из https://github.com/Azure/ARO-RP.git
pull out deployment.Mode
This commit is contained in:
Родитель
92bbd26830
Коммит
b663e73cb2
|
@ -19,6 +19,7 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/metrics/statsd/azure"
|
||||
"github.com/Azure/ARO-RP/pkg/metrics/statsd/k8s"
|
||||
pkgmonitor "github.com/Azure/ARO-RP/pkg/monitor"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/encryption"
|
||||
)
|
||||
|
||||
|
@ -31,7 +32,7 @@ func monitor(ctx context.Context, log *logrus.Entry) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if !_env.IsDevelopment() {
|
||||
if _env.DeploymentMode() != deployment.Development {
|
||||
for _, key := range []string{
|
||||
"CLUSTER_MDM_ACCOUNT",
|
||||
"CLUSTER_MDM_NAMESPACE",
|
||||
|
|
|
@ -7,8 +7,6 @@ import (
|
|||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
configclient "github.com/openshift/client-go/config/clientset/versioned"
|
||||
securityclient "github.com/openshift/client-go/security/clientset/versioned"
|
||||
|
@ -26,6 +24,7 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/operator/controllers/genevalogging"
|
||||
"github.com/Azure/ARO-RP/pkg/operator/controllers/pullsecret"
|
||||
"github.com/Azure/ARO-RP/pkg/operator/controllers/workaround"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
utillog "github.com/Azure/ARO-RP/pkg/util/log"
|
||||
// +kubebuilder:scaffold:imports
|
||||
)
|
||||
|
@ -37,10 +36,9 @@ func operator(ctx context.Context, log *logrus.Entry) error {
|
|||
default:
|
||||
return fmt.Errorf("invalid role %s", role)
|
||||
}
|
||||
developmentMode := false
|
||||
if strings.ToLower(os.Getenv("RP_MODE")) == "development" {
|
||||
deploymentMode := deployment.NewMode()
|
||||
if deploymentMode == deployment.Development {
|
||||
log.Warn("running in development mode")
|
||||
developmentMode = true
|
||||
}
|
||||
|
||||
ctrl.SetLogger(utillog.LogrWrapper(log))
|
||||
|
@ -109,7 +107,7 @@ func operator(ctx context.Context, log *logrus.Entry) error {
|
|||
|
||||
if err = (checker.NewReconciler(
|
||||
log.WithField("controller", controllers.CheckerControllerName),
|
||||
clustercli, arocli, role, developmentMode)).SetupWithManager(mgr); err != nil {
|
||||
clustercli, arocli, role, deploymentMode)).SetupWithManager(mgr); err != nil {
|
||||
return fmt.Errorf("unable to create controller InternetChecker: %v", err)
|
||||
}
|
||||
// +kubebuilder:scaffold:builder
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/metrics/statsd"
|
||||
"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/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/encryption"
|
||||
)
|
||||
|
||||
|
@ -41,7 +42,7 @@ func rp(ctx context.Context, log *logrus.Entry) error {
|
|||
}
|
||||
|
||||
var keys []string
|
||||
if _env.IsDevelopment() {
|
||||
if _env.DeploymentMode() == deployment.Development {
|
||||
keys = []string{
|
||||
"PULL_SECRET",
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ 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
|
||||
|
@ -15,7 +16,7 @@ func init() {
|
|||
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {
|
||||
return &openShiftClusterConverter{}
|
||||
},
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, developmentMode bool, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
OpenShiftClusterStaticValidator: func(string, string, deployment.Mode, string) api.OpenShiftClusterStaticValidator {
|
||||
return &openShiftClusterStaticValidator{}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -3,6 +3,10 @@ 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{}
|
||||
|
@ -20,7 +24,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, bool, string) OpenShiftClusterStaticValidator
|
||||
OpenShiftClusterStaticValidator func(string, string, deployment.Mode, string) OpenShiftClusterStaticValidator
|
||||
OpenShiftClusterCredentialsConverter func() OpenShiftClusterCredentialsConverter
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ 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"
|
||||
|
@ -21,10 +22,10 @@ import (
|
|||
)
|
||||
|
||||
type openShiftClusterStaticValidator struct {
|
||||
location string
|
||||
domain string
|
||||
developmentMode bool
|
||||
resourceID string
|
||||
location string
|
||||
domain string
|
||||
deploymentMode deployment.Mode
|
||||
resourceID string
|
||||
|
||||
r azure.Resource
|
||||
}
|
||||
|
@ -203,7 +204,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.developmentMode, true) {
|
||||
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.deploymentMode, 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) {
|
||||
|
@ -224,7 +225,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.developmentMode, false) {
|
||||
if !validate.VMSizeIsValid(api.VMSize(wp.VMSize), sv.deploymentMode, 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,15 +13,16 @@ import (
|
|||
uuid "github.com/satori/go.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
|
||||
modify func(oc *OpenShiftCluster)
|
||||
developmentMode bool
|
||||
wantErr string
|
||||
name string
|
||||
modify func(oc *OpenShiftCluster)
|
||||
deploymentMode deployment.Mode
|
||||
wantErr string
|
||||
}
|
||||
|
||||
type testMode string
|
||||
|
@ -100,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",
|
||||
developmentMode: tt.developmentMode,
|
||||
resourceID: id,
|
||||
location: "location",
|
||||
domain: "location.aroapp.io",
|
||||
deploymentMode: tt.deploymentMode,
|
||||
resourceID: id,
|
||||
r: azure.Resource{
|
||||
SubscriptionID: subscriptionID,
|
||||
ResourceGroup: "resourceGroup",
|
||||
|
@ -485,8 +486,8 @@ func TestOpenShiftClusterStaticValidateWorkerProfile(t *testing.T) {
|
|||
modify: func(oc *OpenShiftCluster) {
|
||||
oc.Properties.WorkerProfiles[0].VMSize = "Standard_D4s_v3"
|
||||
},
|
||||
developmentMode: true,
|
||||
wantErr: "400: InvalidParameter: properties.workerProfiles['worker'].vmSize: The provided worker VM size 'Standard_D4s_v3' is invalid.",
|
||||
deploymentMode: deployment.Development,
|
||||
wantErr: "400: InvalidParameter: properties.workerProfiles['worker'].vmSize: The provided worker VM size 'Standard_D4s_v3' is invalid.",
|
||||
},
|
||||
{
|
||||
name: "disk too small",
|
||||
|
|
|
@ -5,6 +5,7 @@ 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
|
||||
|
@ -20,12 +21,12 @@ func init() {
|
|||
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {
|
||||
return &openShiftClusterConverter{}
|
||||
},
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, developmentMode bool, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, deploymentMode deployment.Mode, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
return &openShiftClusterStaticValidator{
|
||||
location: location,
|
||||
domain: domain,
|
||||
developmentMode: developmentMode,
|
||||
resourceID: resourceID,
|
||||
location: location,
|
||||
domain: domain,
|
||||
deploymentMode: deploymentMode,
|
||||
resourceID: resourceID,
|
||||
}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: func() api.OpenShiftClusterCredentialsConverter {
|
||||
|
|
|
@ -14,6 +14,7 @@ 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"
|
||||
|
@ -21,10 +22,10 @@ import (
|
|||
)
|
||||
|
||||
type openShiftClusterStaticValidator struct {
|
||||
location string
|
||||
domain string
|
||||
developmentMode bool
|
||||
resourceID string
|
||||
location string
|
||||
domain string
|
||||
deploymentMode deployment.Mode
|
||||
resourceID string
|
||||
|
||||
r azure.Resource
|
||||
}
|
||||
|
@ -203,7 +204,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.developmentMode, true) {
|
||||
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.deploymentMode, 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) {
|
||||
|
@ -224,7 +225,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.developmentMode, false) {
|
||||
if !validate.VMSizeIsValid(api.VMSize(wp.VMSize), sv.deploymentMode, 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,15 +13,16 @@ import (
|
|||
uuid "github.com/satori/go.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
|
||||
modify func(oc *OpenShiftCluster)
|
||||
developmentMode bool
|
||||
wantErr string
|
||||
name string
|
||||
modify func(oc *OpenShiftCluster)
|
||||
deploymentMode deployment.Mode
|
||||
wantErr string
|
||||
}
|
||||
|
||||
type testMode string
|
||||
|
@ -100,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",
|
||||
developmentMode: tt.developmentMode,
|
||||
resourceID: id,
|
||||
location: "location",
|
||||
domain: "location.aroapp.io",
|
||||
deploymentMode: tt.deploymentMode,
|
||||
resourceID: id,
|
||||
r: azure.Resource{
|
||||
SubscriptionID: subscriptionID,
|
||||
ResourceGroup: "resourceGroup",
|
||||
|
@ -485,8 +486,8 @@ func TestOpenShiftClusterStaticValidateWorkerProfile(t *testing.T) {
|
|||
modify: func(oc *OpenShiftCluster) {
|
||||
oc.Properties.WorkerProfiles[0].VMSize = "Standard_D4s_v3"
|
||||
},
|
||||
developmentMode: true,
|
||||
wantErr: "400: InvalidParameter: properties.workerProfiles['worker'].vmSize: The provided worker VM size 'Standard_D4s_v3' is invalid.",
|
||||
deploymentMode: deployment.Development,
|
||||
wantErr: "400: InvalidParameter: properties.workerProfiles['worker'].vmSize: The provided worker VM size 'Standard_D4s_v3' is invalid.",
|
||||
},
|
||||
{
|
||||
name: "disk too small",
|
||||
|
|
|
@ -5,6 +5,7 @@ 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
|
||||
|
@ -20,12 +21,12 @@ func init() {
|
|||
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {
|
||||
return &openShiftClusterConverter{}
|
||||
},
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, developmentMode bool, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, deploymentMode deployment.Mode, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
return &openShiftClusterStaticValidator{
|
||||
location: location,
|
||||
domain: domain,
|
||||
developmentMode: developmentMode,
|
||||
resourceID: resourceID,
|
||||
location: location,
|
||||
domain: domain,
|
||||
deploymentMode: deploymentMode,
|
||||
resourceID: resourceID,
|
||||
}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: func() api.OpenShiftClusterCredentialsConverter {
|
||||
|
|
|
@ -14,6 +14,7 @@ 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"
|
||||
|
@ -21,10 +22,10 @@ import (
|
|||
)
|
||||
|
||||
type openShiftClusterStaticValidator struct {
|
||||
location string
|
||||
domain string
|
||||
developmentMode bool
|
||||
resourceID string
|
||||
location string
|
||||
domain string
|
||||
deploymentMode deployment.Mode
|
||||
resourceID string
|
||||
|
||||
r azure.Resource
|
||||
}
|
||||
|
@ -203,7 +204,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.developmentMode, true) {
|
||||
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.deploymentMode, 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) {
|
||||
|
@ -224,7 +225,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.developmentMode, false) {
|
||||
if !validate.VMSizeIsValid(api.VMSize(wp.VMSize), sv.deploymentMode, 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,15 +13,16 @@ import (
|
|||
uuid "github.com/satori/go.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
|
||||
modify func(oc *OpenShiftCluster)
|
||||
developmentMode bool
|
||||
wantErr string
|
||||
name string
|
||||
modify func(oc *OpenShiftCluster)
|
||||
deploymentMode deployment.Mode
|
||||
wantErr string
|
||||
}
|
||||
|
||||
type testMode string
|
||||
|
@ -100,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",
|
||||
developmentMode: tt.developmentMode,
|
||||
resourceID: id,
|
||||
location: "location",
|
||||
domain: "location.aroapp.io",
|
||||
deploymentMode: tt.deploymentMode,
|
||||
resourceID: id,
|
||||
r: azure.Resource{
|
||||
SubscriptionID: subscriptionID,
|
||||
ResourceGroup: "resourceGroup",
|
||||
|
@ -485,8 +486,8 @@ func TestOpenShiftClusterStaticValidateWorkerProfile(t *testing.T) {
|
|||
modify: func(oc *OpenShiftCluster) {
|
||||
oc.Properties.WorkerProfiles[0].VMSize = "Standard_D4s_v3"
|
||||
},
|
||||
developmentMode: true,
|
||||
wantErr: "400: InvalidParameter: properties.workerProfiles['worker'].vmSize: The provided worker VM size 'Standard_D4s_v3' is invalid.",
|
||||
deploymentMode: deployment.Development,
|
||||
wantErr: "400: InvalidParameter: properties.workerProfiles['worker'].vmSize: The provided worker VM size 'Standard_D4s_v3' is invalid.",
|
||||
},
|
||||
{
|
||||
name: "disk too small",
|
||||
|
|
|
@ -5,6 +5,7 @@ package v20201031preview
|
|||
|
||||
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
|
||||
|
@ -20,12 +21,12 @@ func init() {
|
|||
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {
|
||||
return &openShiftClusterConverter{}
|
||||
},
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, developmentMode bool, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, deploymentMode deployment.Mode, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
return &openShiftClusterStaticValidator{
|
||||
location: location,
|
||||
domain: domain,
|
||||
developmentMode: developmentMode,
|
||||
resourceID: resourceID,
|
||||
location: location,
|
||||
domain: domain,
|
||||
deploymentMode: deploymentMode,
|
||||
resourceID: resourceID,
|
||||
}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: func() api.OpenShiftClusterCredentialsConverter {
|
||||
|
|
|
@ -5,13 +5,14 @@ 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, developmentMode bool, isMaster bool) bool {
|
||||
func VMSizeIsValid(vmSize api.VMSize, deploymentMode deployment.Mode, isMaster bool) bool {
|
||||
if isMaster {
|
||||
switch vmSize {
|
||||
case api.VMSizeStandardD8sV3,
|
||||
|
@ -20,7 +21,7 @@ func VMSizeIsValid(vmSize api.VMSize, developmentMode bool, isMaster bool) bool
|
|||
return true
|
||||
}
|
||||
} else {
|
||||
if developmentMode {
|
||||
if deploymentMode == deployment.Development {
|
||||
switch vmSize {
|
||||
case api.VMSizeStandardD2sV3:
|
||||
return true
|
||||
|
|
|
@ -34,6 +34,7 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/bootstraplogging"
|
||||
"github.com/Azure/ARO-RP/pkg/cluster"
|
||||
"github.com/Azure/ARO-RP/pkg/util/azureerrors"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/pullsecret"
|
||||
"github.com/Azure/ARO-RP/pkg/util/stringutils"
|
||||
"github.com/Azure/ARO-RP/pkg/util/subnet"
|
||||
|
@ -65,7 +66,7 @@ func (m *Manager) Create(ctx context.Context) error {
|
|||
|
||||
resourceGroup := stringutils.LastTokenByte(m.doc.OpenShiftCluster.Properties.ClusterProfile.ResourceGroupID, '/')
|
||||
|
||||
if !m.env.IsDevelopment() {
|
||||
if m.env.DeploymentMode() != deployment.Development {
|
||||
rp := m.acrtoken.GetRegistryProfile(m.doc.OpenShiftCluster)
|
||||
if rp == nil {
|
||||
// 1. choose a name and establish the intent to create a token with
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/Azure/go-autorest/autorest"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/stringutils"
|
||||
)
|
||||
|
||||
|
@ -99,7 +100,7 @@ func (m *Manager) Delete(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if !m.env.IsDevelopment() {
|
||||
if m.env.DeploymentMode() != deployment.Development {
|
||||
managedDomain, err := m.env.ManagedDomain(m.doc.OpenShiftCluster.Properties.ClusterProfile.Domain)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -130,7 +131,7 @@ func (m *Manager) Delete(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if !m.env.IsDevelopment() {
|
||||
if m.env.DeploymentMode() != deployment.Development {
|
||||
rp := m.acrtoken.GetRegistryProfile(m.doc.OpenShiftCluster)
|
||||
if rp != nil {
|
||||
err = m.acrtoken.Delete(ctx, rp)
|
||||
|
|
|
@ -16,6 +16,7 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/features"
|
||||
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/network"
|
||||
"github.com/Azure/ARO-RP/pkg/util/billing"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/dns"
|
||||
"github.com/Azure/ARO-RP/pkg/util/encryption"
|
||||
"github.com/Azure/ARO-RP/pkg/util/keyvault"
|
||||
|
@ -64,7 +65,7 @@ func NewManager(log *logrus.Entry, _env env.Interface, db database.OpenShiftClus
|
|||
}
|
||||
|
||||
var acrtoken pkgacrtoken.Manager
|
||||
if !_env.IsDevelopment() {
|
||||
if _env.DeploymentMode() != deployment.Development {
|
||||
acrtoken, err = pkgacrtoken.NewManager(_env, localFPAuthorizer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -33,6 +33,7 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/util/arm"
|
||||
"github.com/Azure/ARO-RP/pkg/util/azureclient"
|
||||
"github.com/Azure/ARO-RP/pkg/util/azureclient/graphrbac"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/feature"
|
||||
"github.com/Azure/ARO-RP/pkg/util/stringutils"
|
||||
"github.com/Azure/ARO-RP/pkg/util/subnet"
|
||||
|
@ -111,7 +112,7 @@ func (i *manager) deployStorageTemplate(ctx context.Context, installConfig *inst
|
|||
Location: &installConfig.Config.Azure.Region,
|
||||
ManagedBy: to.StringPtr(i.doc.OpenShiftCluster.ID),
|
||||
}
|
||||
if i.env.IsDevelopment() {
|
||||
if i.env.DeploymentMode() == deployment.Development {
|
||||
group.ManagedBy = nil
|
||||
}
|
||||
_, err := i.groups.CreateOrUpdate(ctx, resourceGroup, group)
|
||||
|
@ -189,7 +190,7 @@ func (i *manager) deployStorageTemplate(ctx context.Context, installConfig *inst
|
|||
},
|
||||
}
|
||||
|
||||
if i.env.ShouldDeployDenyAssignment() {
|
||||
if i.env.DeploymentMode() == deployment.Production {
|
||||
t.Resources = append(t.Resources, i.denyAssignments(clusterSPObjectID))
|
||||
}
|
||||
|
||||
|
@ -282,7 +283,7 @@ func (i *manager) denyAssignments(clusterSPObjectID string) *arm.Resource {
|
|||
}
|
||||
|
||||
func (i *manager) deploySnapshotUpgradeTemplate(ctx context.Context) error {
|
||||
if !i.env.ShouldDeployDenyAssignment() {
|
||||
if i.env.DeploymentMode() != deployment.Production {
|
||||
// only need this upgrade in production, where there are DenyAssignments
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -11,11 +11,13 @@ import (
|
|||
configscheme "github.com/openshift/client-go/config/clientset/versioned/scheme"
|
||||
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 (i *manager) disableSamples(ctx context.Context) error {
|
||||
if !i.env.IsDevelopment() &&
|
||||
if i.env.DeploymentMode() != deployment.Development &&
|
||||
i.doc.OpenShiftCluster.Properties.ClusterProfile.PullSecret != "" {
|
||||
return nil
|
||||
}
|
||||
|
@ -36,7 +38,7 @@ func (i *manager) disableSamples(ctx context.Context) error {
|
|||
// disableOperatorHubSources disables operator hub sources if there's no
|
||||
// appropriate pull secret
|
||||
func (i *manager) disableOperatorHubSources(ctx context.Context) error {
|
||||
if !i.env.IsDevelopment() &&
|
||||
if i.env.DeploymentMode() != deployment.Development &&
|
||||
i.doc.OpenShiftCluster.Properties.ClusterProfile.PullSecret != "" {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -15,12 +15,13 @@ import (
|
|||
coreclient "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/keyvault"
|
||||
utilpem "github.com/Azure/ARO-RP/pkg/util/pem"
|
||||
)
|
||||
|
||||
func (i *manager) createCertificates(ctx context.Context) error {
|
||||
if i.env.IsDevelopment() {
|
||||
if i.env.DeploymentMode() == deployment.Development {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -67,7 +68,7 @@ func (i *manager) createCertificates(ctx context.Context) error {
|
|||
}
|
||||
|
||||
func (i *manager) upgradeCertificates(ctx context.Context) error {
|
||||
if i.env.IsDevelopment() {
|
||||
if i.env.DeploymentMode() == deployment.Development {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -143,7 +144,7 @@ func (i *manager) ensureSecret(ctx context.Context, secrets coreclient.SecretInt
|
|||
}
|
||||
|
||||
func (i *manager) configureAPIServerCertificate(ctx context.Context) error {
|
||||
if i.env.IsDevelopment() {
|
||||
if i.env.DeploymentMode() == deployment.Development {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -184,7 +185,7 @@ func (i *manager) configureAPIServerCertificate(ctx context.Context) error {
|
|||
}
|
||||
|
||||
func (i *manager) configureIngressCertificate(ctx context.Context) error {
|
||||
if i.env.IsDevelopment() {
|
||||
if i.env.DeploymentMode() == deployment.Development {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,6 @@ func newDev(ctx context.Context, log *logrus.Entry, instancemetadata instancemet
|
|||
}
|
||||
d.prod.clustersGenevaLoggingEnvironment = "Test"
|
||||
d.prod.clustersGenevaLoggingConfigVersion = "2.3"
|
||||
d.prod.envType = environmentTypeDevelopment
|
||||
|
||||
fpGraphAuthorizer, err := d.FPAuthorizer(instancemetadata.TenantID(), azure.PublicCloud.GraphEndpoint)
|
||||
if err != nil {
|
||||
|
@ -301,7 +300,3 @@ func (d *dev) E2EStorageAccountRGName() string {
|
|||
func (d *dev) E2EStorageAccountSubID() string {
|
||||
return "0cc1cafa-578f-4fa5-8d6b-ddfd8d82e6ea"
|
||||
}
|
||||
|
||||
func (d *dev) ShouldDeployDenyAssignment() bool {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -8,26 +8,17 @@ import (
|
|||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"github.com/Azure/go-autorest/autorest/azure/auth"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/util/clientauthorizer"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/instancemetadata"
|
||||
"github.com/Azure/ARO-RP/pkg/util/refreshable"
|
||||
)
|
||||
|
||||
type environmentType uint8
|
||||
|
||||
const (
|
||||
environmentTypeProduction environmentType = iota
|
||||
environmentTypeDevelopment
|
||||
environmentTypeIntegration
|
||||
)
|
||||
|
||||
const (
|
||||
RPFirstPartySecretName = "rp-firstparty"
|
||||
RPServerSecretName = "rp-server"
|
||||
|
@ -39,9 +30,9 @@ const (
|
|||
)
|
||||
|
||||
type Interface interface {
|
||||
DeploymentMode() deployment.Mode
|
||||
instancemetadata.InstanceMetadata
|
||||
|
||||
IsDevelopment() bool
|
||||
InitializeAuthorizers() error
|
||||
ArmClientAuthorizer() clientauthorizer.ClientAuthorizer
|
||||
AdminClientAuthorizer() clientauthorizer.ClientAuthorizer
|
||||
|
@ -67,11 +58,10 @@ type Interface interface {
|
|||
E2EStorageAccountName() string
|
||||
E2EStorageAccountRGName() string
|
||||
E2EStorageAccountSubID() string
|
||||
ShouldDeployDenyAssignment() bool
|
||||
}
|
||||
|
||||
func NewEnv(ctx context.Context, log *logrus.Entry) (Interface, error) {
|
||||
if strings.ToLower(os.Getenv("RP_MODE")) == "development" {
|
||||
if deployment.NewMode() == deployment.Development {
|
||||
log.Warn("running in development mode")
|
||||
return newDev(ctx, log, instancemetadata.NewDev())
|
||||
}
|
||||
|
@ -81,7 +71,7 @@ func NewEnv(ctx context.Context, log *logrus.Entry) (Interface, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if strings.ToLower(os.Getenv("RP_MODE")) == "int" {
|
||||
if deployment.NewMode() == deployment.Integration {
|
||||
log.Warn("running in int mode")
|
||||
return newInt(ctx, log, im)
|
||||
}
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
package env
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the Apache License 2.0.
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestEnvironmentType(t *testing.T) {
|
||||
p := &prod{envType: environmentTypeProduction}
|
||||
out := p.IsDevelopment()
|
||||
if out != false {
|
||||
t.Fatal("didn't return expected value")
|
||||
}
|
||||
|
||||
p = &prod{envType: environmentTypeIntegration}
|
||||
out = p.IsDevelopment()
|
||||
if out != false {
|
||||
t.Fatal("didn't return expected value")
|
||||
}
|
||||
|
||||
p = &prod{envType: environmentTypeDevelopment}
|
||||
out = p.IsDevelopment()
|
||||
if out != true {
|
||||
t.Fatal("didn't return expected value")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnvironmentShouldDeployDenyAssignment(t *testing.T) {
|
||||
p := &prod{envType: environmentTypeProduction}
|
||||
out := p.ShouldDeployDenyAssignment()
|
||||
if out != true {
|
||||
t.Fatal("didn't return expected value")
|
||||
}
|
||||
|
||||
p = &prod{envType: environmentTypeIntegration}
|
||||
out = p.ShouldDeployDenyAssignment()
|
||||
if out != false {
|
||||
t.Fatal("didn't return expected value")
|
||||
}
|
||||
|
||||
p = &prod{envType: environmentTypeDevelopment}
|
||||
out = p.ShouldDeployDenyAssignment()
|
||||
if out != false {
|
||||
t.Fatal("didn't return expected value")
|
||||
}
|
||||
}
|
|
@ -36,7 +36,6 @@ func newInt(ctx context.Context, log *logrus.Entry, instancemetadata instancemet
|
|||
p.e2eStorageAccountName = "arov4e2eint"
|
||||
p.e2eStorageAccountRGName = "global-infra"
|
||||
p.e2eStorageAccountSubID = "0cc1cafa-578f-4fa5-8d6b-ddfd8d82e6ea"
|
||||
p.envType = environmentTypeIntegration
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/documentdb"
|
||||
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/keyvault"
|
||||
"github.com/Azure/ARO-RP/pkg/util/clientauthorizer"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/instancemetadata"
|
||||
"github.com/Azure/ARO-RP/pkg/util/pem"
|
||||
"github.com/Azure/ARO-RP/pkg/util/refreshable"
|
||||
|
@ -34,6 +35,9 @@ import (
|
|||
|
||||
type prod struct {
|
||||
instancemetadata.InstanceMetadata
|
||||
|
||||
deploymentMode deployment.Mode
|
||||
|
||||
armClientAuthorizer clientauthorizer.ClientAuthorizer
|
||||
adminClientAuthorizer clientauthorizer.ClientAuthorizer
|
||||
|
||||
|
@ -60,21 +64,21 @@ type prod struct {
|
|||
e2eStorageAccountRGName string
|
||||
e2eStorageAccountSubID string
|
||||
|
||||
log *logrus.Entry
|
||||
envType environmentType
|
||||
log *logrus.Entry
|
||||
}
|
||||
|
||||
func newProd(ctx context.Context, log *logrus.Entry, instancemetadata instancemetadata.InstanceMetadata, rpAuthorizer, rpKVAuthorizer autorest.Authorizer) (*prod, error) {
|
||||
p := &prod{
|
||||
InstanceMetadata: instancemetadata,
|
||||
|
||||
deploymentMode: deployment.NewMode(),
|
||||
|
||||
keyvault: basekeyvault.New(rpKVAuthorizer),
|
||||
|
||||
clustersGenevaLoggingEnvironment: "DiagnosticsProd",
|
||||
clustersGenevaLoggingConfigVersion: "2.2",
|
||||
|
||||
log: log,
|
||||
envType: environmentTypeProduction,
|
||||
log: log,
|
||||
}
|
||||
|
||||
err := p.populateCosmosDB(ctx, rpAuthorizer)
|
||||
|
@ -131,6 +135,10 @@ func newProd(ctx context.Context, log *logrus.Entry, instancemetadata instanceme
|
|||
return p, nil
|
||||
}
|
||||
|
||||
func (p *prod) DeploymentMode() deployment.Mode {
|
||||
return p.deploymentMode
|
||||
}
|
||||
|
||||
func (p *prod) InitializeAuthorizers() error {
|
||||
p.armClientAuthorizer = clientauthorizer.NewARM(p.log)
|
||||
|
||||
|
@ -394,11 +402,3 @@ func (p *prod) E2EStorageAccountRGName() string {
|
|||
func (p *prod) E2EStorageAccountSubID() string {
|
||||
return p.e2eStorageAccountSubID
|
||||
}
|
||||
|
||||
func (p *prod) ShouldDeployDenyAssignment() bool {
|
||||
return p.envType == environmentTypeProduction
|
||||
}
|
||||
|
||||
func (p *prod) IsDevelopment() bool {
|
||||
return p.envType == environmentTypeDevelopment
|
||||
}
|
||||
|
|
|
@ -11,11 +11,13 @@ import (
|
|||
"net"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/util/clientauthorizer"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
"github.com/Azure/ARO-RP/pkg/util/refreshable"
|
||||
)
|
||||
|
||||
type Test struct {
|
||||
*prod
|
||||
deployment.Mode
|
||||
|
||||
L net.Listener
|
||||
|
||||
|
|
|
@ -253,7 +253,7 @@ func (f *frontend) setupRouter() *mux.Router {
|
|||
r.Use(middleware.Log(f.baseLog.WithField("component", "access")))
|
||||
r.Use(middleware.Metrics(f.m))
|
||||
r.Use(middleware.Panic)
|
||||
r.Use(middleware.Headers(f.env))
|
||||
r.Use(middleware.Headers(f.env.DeploymentMode()))
|
||||
r.Use(middleware.Validate(f.env, f.apis))
|
||||
r.Use(middleware.Body)
|
||||
|
||||
|
|
|
@ -14,12 +14,15 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/sirupsen/logrus"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
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"
|
||||
)
|
||||
|
||||
|
@ -166,8 +169,15 @@ func TestAdminReply(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRoutesAreNamedWithLowerCasePaths(t *testing.T) {
|
||||
controller := gomock.NewController(t)
|
||||
defer controller.Finish()
|
||||
|
||||
_env := mock_env.NewMockInterface(controller)
|
||||
_env.EXPECT().DeploymentMode().AnyTimes().Return(deployment.Production)
|
||||
|
||||
f := &frontend{
|
||||
baseLog: logrus.NewEntry(logrus.StandardLogger()),
|
||||
env: _env,
|
||||
}
|
||||
router := f.setupRouter()
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
func Headers(_env env.Interface) func(http.Handler) http.Handler {
|
||||
func Headers(deploymentMode deployment.Mode) 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 +19,7 @@ func Headers(_env env.Interface) func(http.Handler) http.Handler {
|
|||
w.Header().Set("X-Ms-Client-Request-Id", r.Header.Get("X-Ms-Client-Request-Id"))
|
||||
}
|
||||
|
||||
if _env.IsDevelopment() {
|
||||
if deploymentMode == deployment.Development {
|
||||
r.Header.Set("Referer", "https://localhost:8443"+r.URL.String())
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@ import (
|
|||
)
|
||||
|
||||
func (f *frontend) putOrPatchOpenShiftCluster(w http.ResponseWriter, r *http.Request) {
|
||||
developmentMode := f.env.IsDevelopment()
|
||||
|
||||
ctx := r.Context()
|
||||
log := ctx.Value(middleware.ContextKeyLog).(*logrus.Entry)
|
||||
vars := mux.Vars(r)
|
||||
|
@ -35,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, r, &header, f.apis[vars["api-version"]].OpenShiftClusterConverter(), f.apis[vars["api-version"]].OpenShiftClusterStaticValidator(f.env.Location(), f.env.Domain(), developmentMode, r.URL.Path))
|
||||
b, err = f._putOrPatchOpenShiftCluster(ctx, 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))
|
||||
return err
|
||||
})
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/database/cosmosdb"
|
||||
"github.com/Azure/ARO-RP/pkg/metrics/noop"
|
||||
"github.com/Azure/ARO-RP/pkg/util/bucket"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
mock_database "github.com/Azure/ARO-RP/pkg/util/mocks/database"
|
||||
"github.com/Azure/ARO-RP/test/util/matcher"
|
||||
)
|
||||
|
@ -49,7 +50,7 @@ func TestPutOrPatchOpenShiftClusterAdminAPI(t *testing.T) {
|
|||
apis := map[string]*api.Version{
|
||||
"admin": {
|
||||
OpenShiftClusterConverter: api.APIs["admin"].OpenShiftClusterConverter,
|
||||
OpenShiftClusterStaticValidator: func(string, string, bool, string) api.OpenShiftClusterStaticValidator {
|
||||
OpenShiftClusterStaticValidator: func(string, string, deployment.Mode, string) api.OpenShiftClusterStaticValidator {
|
||||
return &dummyOpenShiftClusterValidator{}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: api.APIs["admin"].OpenShiftClusterCredentialsConverter,
|
||||
|
@ -293,7 +294,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, bool, string) api.OpenShiftClusterStaticValidator {
|
||||
OpenShiftClusterStaticValidator: func(string, string, deployment.Mode, string) api.OpenShiftClusterStaticValidator {
|
||||
return &dummyOpenShiftClusterValidator{}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: api.APIs["2020-04-30"].OpenShiftClusterCredentialsConverter,
|
||||
|
|
|
@ -8,6 +8,7 @@ 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
|
||||
|
@ -15,7 +16,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.IsDevelopment() &&
|
||||
if f.env.DeploymentMode() != deployment.Development &&
|
||||
time.Now().Sub(f.startTime) < 2*time.Minute {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ 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"
|
||||
utiltls "github.com/Azure/ARO-RP/pkg/util/tls"
|
||||
"github.com/Azure/ARO-RP/test/util/listener"
|
||||
)
|
||||
|
@ -39,7 +40,8 @@ func TestSecurity(t *testing.T) {
|
|||
defer l.Close()
|
||||
|
||||
env := &env.Test{
|
||||
L: l,
|
||||
Mode: deployment.Production,
|
||||
L: l,
|
||||
}
|
||||
env.SetARMClientAuthorizer(clientauthorizer.NewOne(validclientcerts[0].Raw))
|
||||
env.SetAdminClientAuthorizer(clientauthorizer.NewOne(validadminclientcerts[0].Raw))
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/env"
|
||||
"github.com/Azure/ARO-RP/pkg/util/clientauthorizer"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
utiltls "github.com/Azure/ARO-RP/pkg/util/tls"
|
||||
testclusterdata "github.com/Azure/ARO-RP/test/util/clusterdata"
|
||||
"github.com/Azure/ARO-RP/test/util/listener"
|
||||
|
@ -61,6 +62,7 @@ func newTestInfra(t *testing.T) (*testInfra, error) {
|
|||
|
||||
env := &env.Test{
|
||||
L: l,
|
||||
Mode: deployment.Production,
|
||||
TestLocation: "eastus",
|
||||
TLSKey: serverkey,
|
||||
TLSCerts: servercerts,
|
||||
|
|
|
@ -15,6 +15,7 @@ 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"
|
||||
)
|
||||
|
||||
|
@ -129,7 +130,7 @@ func (s *statsd) write(m *metric) (err error) {
|
|||
if s.conn == nil {
|
||||
err = s.dial()
|
||||
if err != nil {
|
||||
if s.env.IsDevelopment() {
|
||||
if s.env.DeploymentMode() == deployment.Development {
|
||||
err = nil
|
||||
}
|
||||
return
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
arov1alpha1 "github.com/Azure/ARO-RP/pkg/operator/apis/aro.openshift.io/v1alpha1"
|
||||
aroclient "github.com/Azure/ARO-RP/pkg/operator/clientset/versioned/typed/aro.openshift.io/v1alpha1"
|
||||
"github.com/Azure/ARO-RP/pkg/operator/controllers"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
// CheckerController runs a number of checkers
|
||||
|
@ -27,11 +28,11 @@ type CheckerController struct {
|
|||
checkers []Checker
|
||||
}
|
||||
|
||||
func NewReconciler(log *logrus.Entry, clustercli clusterapi.Interface, arocli aroclient.AroV1alpha1Interface, role string, developmentMode bool) *CheckerController {
|
||||
func NewReconciler(log *logrus.Entry, clustercli clusterapi.Interface, arocli aroclient.AroV1alpha1Interface, role string, deploymentMode deployment.Mode) *CheckerController {
|
||||
checkers := []Checker{NewInternetChecker(log, arocli, role)}
|
||||
|
||||
if role == operator.RoleMaster {
|
||||
checkers = append(checkers, NewMachineChecker(log, clustercli, arocli, role, developmentMode))
|
||||
checkers = append(checkers, NewMachineChecker(log, clustercli, arocli, role, deploymentMode))
|
||||
}
|
||||
|
||||
return &CheckerController{
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
aro "github.com/Azure/ARO-RP/pkg/operator/apis/aro.openshift.io/v1alpha1"
|
||||
aroclient "github.com/Azure/ARO-RP/pkg/operator/clientset/versioned/typed/aro.openshift.io/v1alpha1"
|
||||
"github.com/Azure/ARO-RP/pkg/operator/controllers"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
_ "github.com/Azure/ARO-RP/pkg/util/scheme"
|
||||
)
|
||||
|
||||
|
@ -31,20 +32,20 @@ const (
|
|||
|
||||
// MachineChecker reconciles the alertmanager webhook
|
||||
type MachineChecker struct {
|
||||
clustercli clusterapi.Interface
|
||||
arocli aroclient.AroV1alpha1Interface
|
||||
log *logrus.Entry
|
||||
developmentMode bool
|
||||
role string
|
||||
clustercli clusterapi.Interface
|
||||
arocli aroclient.AroV1alpha1Interface
|
||||
log *logrus.Entry
|
||||
deploymentMode deployment.Mode
|
||||
role string
|
||||
}
|
||||
|
||||
func NewMachineChecker(log *logrus.Entry, clustercli clusterapi.Interface, arocli aroclient.AroV1alpha1Interface, role string, developmentMode bool) *MachineChecker {
|
||||
func NewMachineChecker(log *logrus.Entry, clustercli clusterapi.Interface, arocli aroclient.AroV1alpha1Interface, role string, deploymentMode deployment.Mode) *MachineChecker {
|
||||
return &MachineChecker{
|
||||
clustercli: clustercli,
|
||||
arocli: arocli,
|
||||
log: log,
|
||||
role: role,
|
||||
developmentMode: developmentMode,
|
||||
clustercli: clustercli,
|
||||
arocli: arocli,
|
||||
log: log,
|
||||
deploymentMode: deploymentMode,
|
||||
role: role,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +80,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.developmentMode, isMaster) {
|
||||
if !validate.VMSizeIsValid(api.VMSize(machineProviderSpec.VMSize), r.deploymentMode, isMaster) {
|
||||
errs = append(errs, fmt.Errorf("machine %s: invalid VM size '%s'", machine.Name, machineProviderSpec.VMSize))
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import (
|
|||
arov1alpha1 "github.com/Azure/ARO-RP/pkg/operator/apis/aro.openshift.io/v1alpha1"
|
||||
aroclient "github.com/Azure/ARO-RP/pkg/operator/clientset/versioned/typed/aro.openshift.io/v1alpha1"
|
||||
"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"
|
||||
|
@ -92,7 +93,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.IsDevelopment() {
|
||||
if o.env.DeploymentMode() == deployment.Development {
|
||||
d.Spec.Template.Spec.Containers[i].Env = append(d.Spec.Template.Spec.Containers[i].Env, corev1.EnvVar{
|
||||
Name: "RP_MODE",
|
||||
Value: "development",
|
||||
|
|
|
@ -7,12 +7,12 @@ import (
|
|||
"context"
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
// OpenShiftClustersClient is a minimal interface for azure OpenshiftClustersClient
|
||||
|
@ -31,7 +31,7 @@ var _ OpenShiftClustersClient = &openShiftClustersClient{}
|
|||
// NewOpenShiftClustersClient creates a new OpenShiftClustersClient
|
||||
func NewOpenShiftClustersClient(subscriptionID string, authorizer autorest.Authorizer) OpenShiftClustersClient {
|
||||
var client redhatopenshift.OpenShiftClustersClient
|
||||
if os.Getenv("RP_MODE") == "development" {
|
||||
if deployment.NewMode() == deployment.Development {
|
||||
client = redhatopenshift.NewOpenShiftClustersClientWithBaseURI("https://localhost:8443", subscriptionID)
|
||||
client.Sender = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
|
|
|
@ -6,11 +6,11 @@ package redhatopenshift
|
|||
import (
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/client/services/redhatopenshift/mgmt/2020-04-30/redhatopenshift"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
// OperationsClient is a minimal interface for azure OperationsClient
|
||||
|
@ -27,7 +27,7 @@ var _ OperationsClient = &operationsClient{}
|
|||
// NewOperationsClient creates a new OperationsClient
|
||||
func NewOperationsClient(subscriptionID string, authorizer autorest.Authorizer) OperationsClient {
|
||||
var client redhatopenshift.OperationsClient
|
||||
if os.Getenv("RP_MODE") == "development" {
|
||||
if deployment.NewMode() == deployment.Development {
|
||||
client = redhatopenshift.NewOperationsClientWithBaseURI("https://localhost:8443", subscriptionID)
|
||||
client.Sender = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
|
|
|
@ -19,6 +19,7 @@ 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"
|
||||
)
|
||||
|
||||
|
@ -48,7 +49,7 @@ type manager struct {
|
|||
func NewManager(_env env.Interface, billing database.Billing, sub database.Subscriptions, log *logrus.Entry) (Manager, error) {
|
||||
var storageClient *azstorage.Client
|
||||
|
||||
if !_env.IsDevelopment() {
|
||||
if _env.DeploymentMode() != deployment.Development {
|
||||
localFPAuthorizer, err := _env.FPAuthorizer(_env.TenantID(), azure.PublicCloud.ResourceManagerEndpoint)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -137,7 +138,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.IsDevelopment() {
|
||||
if m.env.DeploymentMode() == deployment.Development {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
"github.com/Azure/ARO-RP/pkg/database/cosmosdb"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
mock_database "github.com/Azure/ARO-RP/pkg/util/mocks/database"
|
||||
mock_env "github.com/Azure/ARO-RP/pkg/util/mocks/env"
|
||||
)
|
||||
|
@ -237,7 +238,7 @@ func TestDelete(t *testing.T) {
|
|||
defer controller.Finish()
|
||||
|
||||
_env := mock_env.NewMockInterface(controller)
|
||||
_env.EXPECT().IsDevelopment().AnyTimes().Return(false)
|
||||
_env.EXPECT().DeploymentMode().AnyTimes().Return(deployment.Production)
|
||||
|
||||
log := logrus.NewEntry(logrus.StandardLogger())
|
||||
|
||||
|
@ -403,7 +404,7 @@ func TestEnsure(t *testing.T) {
|
|||
defer controller.Finish()
|
||||
|
||||
_env := mock_env.NewMockInterface(controller)
|
||||
_env.EXPECT().IsDevelopment().AnyTimes().Return(false)
|
||||
_env.EXPECT().DeploymentMode().AnyTimes().Return(deployment.Production)
|
||||
|
||||
log := logrus.NewEntry(logrus.StandardLogger())
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
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
|
||||
)
|
||||
|
||||
func NewMode() Mode {
|
||||
switch strings.ToLower(os.Getenv("RP_MODE")) {
|
||||
case "development":
|
||||
return Development
|
||||
case "int":
|
||||
return Integration
|
||||
default:
|
||||
return Production
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ import (
|
|||
gomock "github.com/golang/mock/gomock"
|
||||
|
||||
clientauthorizer "github.com/Azure/ARO-RP/pkg/util/clientauthorizer"
|
||||
deployment "github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
refreshable "github.com/Azure/ARO-RP/pkg/util/refreshable"
|
||||
)
|
||||
|
||||
|
@ -210,6 +211,20 @@ func (mr *MockInterfaceMockRecorder) DatabaseName() *gomock.Call {
|
|||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DatabaseName", reflect.TypeOf((*MockInterface)(nil).DatabaseName))
|
||||
}
|
||||
|
||||
// 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()
|
||||
|
@ -341,20 +356,6 @@ func (mr *MockInterfaceMockRecorder) InitializeAuthorizers() *gomock.Call {
|
|||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitializeAuthorizers", reflect.TypeOf((*MockInterface)(nil).InitializeAuthorizers))
|
||||
}
|
||||
|
||||
// IsDevelopment mocks base method
|
||||
func (m *MockInterface) IsDevelopment() bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "IsDevelopment")
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// IsDevelopment indicates an expected call of IsDevelopment
|
||||
func (mr *MockInterfaceMockRecorder) IsDevelopment() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDevelopment", reflect.TypeOf((*MockInterface)(nil).IsDevelopment))
|
||||
}
|
||||
|
||||
// Listen mocks base method
|
||||
func (m *MockInterface) Listen() (net.Listener, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
@ -427,20 +428,6 @@ func (mr *MockInterfaceMockRecorder) ResourceGroup() *gomock.Call {
|
|||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ResourceGroup", reflect.TypeOf((*MockInterface)(nil).ResourceGroup))
|
||||
}
|
||||
|
||||
// ShouldDeployDenyAssignment mocks base method
|
||||
func (m *MockInterface) ShouldDeployDenyAssignment() bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ShouldDeployDenyAssignment")
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ShouldDeployDenyAssignment indicates an expected call of ShouldDeployDenyAssignment
|
||||
func (mr *MockInterfaceMockRecorder) ShouldDeployDenyAssignment() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ShouldDeployDenyAssignment", reflect.TypeOf((*MockInterface)(nil).ShouldDeployDenyAssignment))
|
||||
}
|
||||
|
||||
// SubscriptionID mocks base method
|
||||
func (m *MockInterface) SubscriptionID() string {
|
||||
m.ctrl.T.Helper()
|
||||
|
|
|
@ -12,15 +12,15 @@ import (
|
|||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api/admin"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
func adminRequest(ctx context.Context, method, path string, params url.Values, in, out interface{}) (*http.Response, error) {
|
||||
if os.Getenv("RP_MODE") != "development" {
|
||||
if deployment.NewMode() != deployment.Development {
|
||||
return nil, errors.New("only development RP mode is supported")
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/features"
|
||||
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/insights"
|
||||
"github.com/Azure/ARO-RP/pkg/util/azureclient/mgmt/redhatopenshift"
|
||||
"github.com/Azure/ARO-RP/pkg/util/deployment"
|
||||
)
|
||||
|
||||
type clientSet struct {
|
||||
|
@ -44,7 +45,7 @@ var (
|
|||
)
|
||||
|
||||
func skipIfNotInDevelopmentEnv() {
|
||||
if os.Getenv("RP_MODE") != "development" {
|
||||
if deployment.NewMode() != deployment.Development {
|
||||
Skip("skipping tests in non-development environment")
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче