зеркало из https://github.com/Azure/ARO-RP.git
Merge pull request #2387 from facchettos/putorpatchfix
putorpatch cleanup
This commit is contained in:
Коммит
e0d1a11e9e
|
@ -13,7 +13,7 @@ type openShiftClusterConverter struct{}
|
|||
// reading from the subset of the internal object's fields that appear in the
|
||||
// external representation. ToExternal does not modify its argument; there is
|
||||
// no pointer aliasing between the passed and returned objects
|
||||
func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
out := &OpenShiftCluster{
|
||||
ID: oc.ID,
|
||||
Name: oc.Name,
|
||||
|
@ -139,7 +139,7 @@ func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfa
|
|||
|
||||
// ToExternalList returns a slice of external representations of the internal
|
||||
// objects
|
||||
func (c *openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster, nextLink string) interface{} {
|
||||
func (c openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster, nextLink string) interface{} {
|
||||
l := &OpenShiftClusterList{
|
||||
OpenShiftClusters: make([]*OpenShiftCluster, 0, len(ocs)),
|
||||
NextLink: nextLink,
|
||||
|
@ -156,7 +156,7 @@ func (c *openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster,
|
|||
// all mapped fields from the external representation. ToInternal modifies its
|
||||
// argument; there is no pointer aliasing between the passed and returned
|
||||
// objects
|
||||
func (c *openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShiftCluster) {
|
||||
func (c openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShiftCluster) {
|
||||
oc := _oc.(*OpenShiftCluster)
|
||||
|
||||
out.ID = oc.ID
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
type openShiftClusterStaticValidator struct{}
|
||||
|
||||
// Validate validates an OpenShift cluster
|
||||
func (sv *openShiftClusterStaticValidator) Static(_oc interface{}, _current *api.OpenShiftCluster) error {
|
||||
func (sv openShiftClusterStaticValidator) Static(_oc interface{}, _current *api.OpenShiftCluster, location, domain string, requireD2sV3Workers bool, resourceID string) error {
|
||||
if _current == nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeRequestNotAllowed, "", "Admin API does not allow cluster creation.")
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ func (sv *openShiftClusterStaticValidator) Static(_oc interface{}, _current *api
|
|||
return sv.validateDelta(oc, (&openShiftClusterConverter{}).ToExternal(_current).(*OpenShiftCluster))
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateDelta(oc, current *OpenShiftCluster) error {
|
||||
func (sv openShiftClusterStaticValidator) validateDelta(oc, current *OpenShiftCluster) error {
|
||||
err := immutable.Validate("", oc, current)
|
||||
if err != nil {
|
||||
err := err.(*immutable.ValidationError)
|
||||
|
|
|
@ -703,7 +703,7 @@ func TestOpenShiftClusterStaticValidateDelta(t *testing.T) {
|
|||
(&openShiftClusterConverter{}).ToInternal(tt.oc(), current)
|
||||
|
||||
v := &openShiftClusterStaticValidator{}
|
||||
err := v.Static(oc, current)
|
||||
err := v.Static(oc, current, "", "", true, "")
|
||||
if err == nil {
|
||||
if tt.wantErr != "" {
|
||||
t.Error(err)
|
||||
|
|
|
@ -14,7 +14,7 @@ type openShiftVersionConverter struct{}
|
|||
// fields that appear in the external representation. ToExternal does not
|
||||
// modify its argument; there is no pointer aliasing between the passed and
|
||||
// returned objects.
|
||||
func (*openShiftVersionConverter) ToExternal(v *api.OpenShiftVersion) interface{} {
|
||||
func (openShiftVersionConverter) ToExternal(v *api.OpenShiftVersion) interface{} {
|
||||
out := &OpenShiftVersion{
|
||||
Version: v.Version,
|
||||
OpenShiftPullspec: v.OpenShiftPullspec,
|
||||
|
@ -27,7 +27,7 @@ func (*openShiftVersionConverter) ToExternal(v *api.OpenShiftVersion) interface{
|
|||
|
||||
// ToExternalList returns a slice of external representations of the internal
|
||||
// objects
|
||||
func (c *openShiftVersionConverter) ToExternalList(vers []*api.OpenShiftVersion) interface{} {
|
||||
func (c openShiftVersionConverter) ToExternalList(vers []*api.OpenShiftVersion) interface{} {
|
||||
l := &OpenShiftVersionList{
|
||||
OpenShiftVersions: make([]*OpenShiftVersion, 0, len(vers)),
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ func (c *openShiftVersionConverter) ToExternalList(vers []*api.OpenShiftVersion)
|
|||
// all mapped fields from the external representation. ToInternal modifies its
|
||||
// argument; there is no pointer aliasing between the passed and returned
|
||||
// objects
|
||||
func (c *openShiftVersionConverter) ToInternal(_new interface{}, out *api.OpenShiftVersion) {
|
||||
func (c openShiftVersionConverter) ToInternal(_new interface{}, out *api.OpenShiftVersion) {
|
||||
new := _new.(*OpenShiftVersion)
|
||||
|
||||
out.Enabled = new.Enabled
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
type openShiftVersionStaticValidator struct{}
|
||||
|
||||
// Validate validates an OpenShift cluster
|
||||
func (sv *openShiftVersionStaticValidator) Static(_new interface{}, _current *api.OpenShiftVersion) error {
|
||||
func (sv openShiftVersionStaticValidator) Static(_new interface{}, _current *api.OpenShiftVersion) error {
|
||||
new := _new.(*OpenShiftVersion)
|
||||
|
||||
var current *OpenShiftVersion
|
||||
|
@ -33,7 +33,7 @@ func (sv *openShiftVersionStaticValidator) Static(_new interface{}, _current *ap
|
|||
return sv.validateDelta(new, current)
|
||||
}
|
||||
|
||||
func (sv *openShiftVersionStaticValidator) validate(new *OpenShiftVersion, isCreate bool) error {
|
||||
func (sv openShiftVersionStaticValidator) validate(new *OpenShiftVersion, isCreate bool) error {
|
||||
if new.Version == "" {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "version", "Must be provided")
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func (sv *openShiftVersionStaticValidator) validate(new *OpenShiftVersion, isCre
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftVersionStaticValidator) validateDelta(new, current *OpenShiftVersion) error {
|
||||
func (sv openShiftVersionStaticValidator) validateDelta(new, current *OpenShiftVersion) error {
|
||||
err := immutable.Validate("", new, current)
|
||||
if err != nil {
|
||||
err := err.(*immutable.ValidationError)
|
||||
|
|
|
@ -12,17 +12,9 @@ const APIVersion = "admin"
|
|||
|
||||
func init() {
|
||||
api.APIs[APIVersion] = &api.Version{
|
||||
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {
|
||||
return &openShiftClusterConverter{}
|
||||
},
|
||||
OpenShiftClusterStaticValidator: func(string, string, bool, string) api.OpenShiftClusterStaticValidator {
|
||||
return &openShiftClusterStaticValidator{}
|
||||
},
|
||||
OpenShiftVersionConverter: func() api.OpenShiftVersionConverter {
|
||||
return &openShiftVersionConverter{}
|
||||
},
|
||||
OpenShiftVersionStaticValidator: func() api.OpenShiftVersionStaticValidator {
|
||||
return &openShiftVersionStaticValidator{}
|
||||
},
|
||||
OpenShiftClusterConverter: openShiftClusterConverter{},
|
||||
OpenShiftClusterStaticValidator: openShiftClusterStaticValidator{},
|
||||
OpenShiftVersionConverter: openShiftVersionConverter{},
|
||||
OpenShiftVersionStaticValidator: openShiftVersionStaticValidator{},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@ import (
|
|||
"encoding/json"
|
||||
)
|
||||
|
||||
func FromExternalBytes(body *[]byte) (*openShiftCluster, error) {
|
||||
func FromExternalBytes(body []byte) (*openShiftCluster, error) {
|
||||
r := &openShiftCluster{}
|
||||
|
||||
err := json.Unmarshal(*body, &r)
|
||||
err := json.Unmarshal(body, &r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ func TestParsePreInstallAPI(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ver, err := FromExternalBytes(&b)
|
||||
ver, err := FromExternalBytes(b)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ func TestParsePostInstallAPI(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ver, err := FromExternalBytes(&b)
|
||||
ver, err := FromExternalBytes(b)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ func TestParsePostInstallAPI(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ver, err = FromExternalBytes(&b)
|
||||
ver, err = FromExternalBytes(b)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ type OpenShiftClusterConverter interface {
|
|||
}
|
||||
|
||||
type OpenShiftClusterStaticValidator interface {
|
||||
Static(interface{}, *OpenShiftCluster) error
|
||||
Static(interface{}, *OpenShiftCluster, string, string, bool, string) error
|
||||
}
|
||||
|
||||
type OpenShiftClusterCredentialsConverter interface {
|
||||
|
@ -37,13 +37,13 @@ type OpenShiftVersionStaticValidator 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
|
||||
OpenShiftClusterCredentialsConverter func() OpenShiftClusterCredentialsConverter
|
||||
OpenShiftClusterAdminKubeconfigConverter func() OpenShiftClusterAdminKubeconfigConverter
|
||||
OpenShiftVersionConverter func() OpenShiftVersionConverter
|
||||
OpenShiftVersionStaticValidator func() OpenShiftVersionStaticValidator
|
||||
InstallVersionsConverter func() InstallVersionsConverter
|
||||
OpenShiftClusterConverter OpenShiftClusterConverter
|
||||
OpenShiftClusterStaticValidator OpenShiftClusterStaticValidator
|
||||
OpenShiftClusterCredentialsConverter OpenShiftClusterCredentialsConverter
|
||||
OpenShiftClusterAdminKubeconfigConverter OpenShiftClusterAdminKubeconfigConverter
|
||||
OpenShiftVersionConverter OpenShiftVersionConverter
|
||||
OpenShiftVersionStaticValidator OpenShiftVersionStaticValidator
|
||||
InstallVersionsConverter InstallVersionsConverter
|
||||
OperationList OperationList
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ type openShiftClusterConverter struct{}
|
|||
// reading from the subset of the internal object's fields that appear in the
|
||||
// external representation. ToExternal does not modify its argument; there is
|
||||
// no pointer aliasing between the passed and returned objects
|
||||
func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
out := &OpenShiftCluster{
|
||||
ID: oc.ID,
|
||||
Name: oc.Name,
|
||||
|
@ -86,7 +86,7 @@ func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfa
|
|||
|
||||
// ToExternalList returns a slice of external representations of the internal
|
||||
// objects
|
||||
func (c *openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster, nextLink string) interface{} {
|
||||
func (c openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster, nextLink string) interface{} {
|
||||
l := &OpenShiftClusterList{
|
||||
OpenShiftClusters: make([]*OpenShiftCluster, 0, len(ocs)),
|
||||
NextLink: nextLink,
|
||||
|
@ -103,7 +103,7 @@ func (c *openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster,
|
|||
// all mapped fields from the external representation. ToInternal modifies its
|
||||
// argument; there is no pointer aliasing between the passed and returned
|
||||
// objects
|
||||
func (c *openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShiftCluster) {
|
||||
func (c openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShiftCluster) {
|
||||
oc := _oc.(*OpenShiftCluster)
|
||||
|
||||
out.ID = oc.ID
|
||||
|
|
|
@ -31,7 +31,11 @@ type openShiftClusterStaticValidator struct {
|
|||
}
|
||||
|
||||
// Validate validates an OpenShift cluster
|
||||
func (sv *openShiftClusterStaticValidator) Static(_oc interface{}, _current *api.OpenShiftCluster) error {
|
||||
func (sv openShiftClusterStaticValidator) Static(_oc interface{}, _current *api.OpenShiftCluster, location, domain string, requireD2sV3Workers bool, resourceID string) error {
|
||||
sv.location = location
|
||||
sv.domain = domain
|
||||
sv.requireD2sV3Workers = requireD2sV3Workers
|
||||
sv.resourceID = resourceID
|
||||
oc := _oc.(*OpenShiftCluster)
|
||||
|
||||
var current *OpenShiftCluster
|
||||
|
@ -57,7 +61,7 @@ func (sv *openShiftClusterStaticValidator) Static(_oc interface{}, _current *api
|
|||
return sv.validateDelta(oc, current)
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCreate bool) error {
|
||||
if !strings.EqualFold(oc.ID, sv.resourceID) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeMismatchingResourceID, "id", "The provided resource ID '%s' did not match the name in the Url '%s'.", oc.ID, sv.resourceID)
|
||||
}
|
||||
|
@ -74,7 +78,7 @@ func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCrea
|
|||
return sv.validateProperties("properties", &oc.Properties, isCreate)
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateProperties(path string, p *OpenShiftClusterProperties, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validateProperties(path string, p *OpenShiftClusterProperties, isCreate bool) error {
|
||||
switch p.ProvisioningState {
|
||||
case ProvisioningStateCreating, ProvisioningStateUpdating,
|
||||
ProvisioningStateAdminUpdating, ProvisioningStateDeleting,
|
||||
|
@ -118,7 +122,7 @@ func (sv *openShiftClusterStaticValidator) validateProperties(path string, p *Op
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateClusterProfile(path string, cp *ClusterProfile, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validateClusterProfile(path string, cp *ClusterProfile, isCreate bool) error {
|
||||
if pullsecret.Validate(cp.PullSecret) != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".pullSecret", "The provided pull secret is invalid.")
|
||||
}
|
||||
|
@ -162,7 +166,7 @@ func (sv *openShiftClusterStaticValidator) validateClusterProfile(path string, c
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateConsoleProfile(path string, cp *ConsoleProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateConsoleProfile(path string, cp *ConsoleProfile) error {
|
||||
if cp.URL != "" {
|
||||
if _, err := url.Parse(cp.URL); err != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".url", "The provided console URL '%s' is invalid.", cp.URL)
|
||||
|
@ -172,7 +176,7 @@ func (sv *openShiftClusterStaticValidator) validateConsoleProfile(path string, c
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateServicePrincipalProfile(path string, spp *ServicePrincipalProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateServicePrincipalProfile(path string, spp *ServicePrincipalProfile) error {
|
||||
valid := uuid.IsValid(spp.ClientID)
|
||||
if !valid {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".clientId", "The provided client ID '%s' is invalid.", spp.ClientID)
|
||||
|
@ -184,7 +188,7 @@ func (sv *openShiftClusterStaticValidator) validateServicePrincipalProfile(path
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, np *NetworkProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateNetworkProfile(path string, np *NetworkProfile) error {
|
||||
_, pod, err := net.ParseCIDR(np.PodCIDR)
|
||||
if err != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".podCidr", "The provided pod CIDR '%s' is invalid: '%s'.", np.PodCIDR, err)
|
||||
|
@ -215,7 +219,7 @@ func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, n
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateMasterProfile(path string, mp *MasterProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateMasterProfile(path string, mp *MasterProfile) error {
|
||||
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.requireD2sV3Workers, true) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vmSize", "The provided master VM size '%s' is invalid.", mp.VMSize)
|
||||
}
|
||||
|
@ -233,7 +237,7 @@ func (sv *openShiftClusterStaticValidator) validateMasterProfile(path string, mp
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateWorkerProfile(path string, wp *WorkerProfile, mp *MasterProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateWorkerProfile(path string, wp *WorkerProfile, mp *MasterProfile) error {
|
||||
if wp.Name != "worker" {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".name", "The provided worker name '%s' is invalid.", wp.Name)
|
||||
}
|
||||
|
@ -267,7 +271,7 @@ func (sv *openShiftClusterStaticValidator) validateWorkerProfile(path string, wp
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateAPIServerProfile(path string, ap *APIServerProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateAPIServerProfile(path string, ap *APIServerProfile) error {
|
||||
switch ap.Visibility {
|
||||
case VisibilityPublic, VisibilityPrivate:
|
||||
default:
|
||||
|
@ -291,7 +295,7 @@ func (sv *openShiftClusterStaticValidator) validateAPIServerProfile(path string,
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateIngressProfile(path string, p *IngressProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateIngressProfile(path string, p *IngressProfile) error {
|
||||
if p.Name != "default" {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".name", "The provided ingress name '%s' is invalid.", p.Name)
|
||||
}
|
||||
|
@ -313,7 +317,7 @@ func (sv *openShiftClusterStaticValidator) validateIngressProfile(path string, p
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateDelta(oc, current *OpenShiftCluster) error {
|
||||
func (sv openShiftClusterStaticValidator) validateDelta(oc, current *OpenShiftCluster) error {
|
||||
err := immutable.Validate("", oc, current)
|
||||
if err != nil {
|
||||
err := err.(*immutable.ValidationError)
|
||||
|
|
|
@ -133,7 +133,7 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
|
|||
(&openShiftClusterConverter{}).ToInternal(validOCForTest(), current)
|
||||
}
|
||||
|
||||
err := v.Static(oc, current)
|
||||
err := v.Static(oc, current, v.location, v.domain, tt.requireD2sV3Workers, v.resourceID)
|
||||
if err == nil {
|
||||
if tt.wantErr != "" {
|
||||
t.Error(err)
|
||||
|
|
|
@ -14,7 +14,7 @@ type openShiftClusterCredentialsConverter struct{}
|
|||
// fields that appear in the external representation. ToExternal does not
|
||||
// modify its argument; there is no pointer aliasing between the passed and
|
||||
// returned objects.
|
||||
func (*openShiftClusterCredentialsConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
func (openShiftClusterCredentialsConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
out := &OpenShiftClusterCredentials{
|
||||
KubeadminUsername: "kubeadmin",
|
||||
KubeadminPassword: string(oc.Properties.KubeadminPassword),
|
||||
|
|
|
@ -17,20 +17,9 @@ const (
|
|||
|
||||
func init() {
|
||||
api.APIs[APIVersion] = &api.Version{
|
||||
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {
|
||||
return &openShiftClusterConverter{}
|
||||
},
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, requireD2sV3Workers bool, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
return &openShiftClusterStaticValidator{
|
||||
location: location,
|
||||
domain: domain,
|
||||
requireD2sV3Workers: requireD2sV3Workers,
|
||||
resourceID: resourceID,
|
||||
}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: func() api.OpenShiftClusterCredentialsConverter {
|
||||
return &openShiftClusterCredentialsConverter{}
|
||||
},
|
||||
OpenShiftClusterConverter: openShiftClusterConverter{},
|
||||
OpenShiftClusterStaticValidator: openShiftClusterStaticValidator{},
|
||||
OpenShiftClusterCredentialsConverter: openShiftClusterCredentialsConverter{},
|
||||
OperationList: api.OperationList{
|
||||
Operations: []api.Operation{
|
||||
api.OperationResultsRead,
|
||||
|
|
|
@ -13,7 +13,7 @@ type openShiftClusterConverter struct{}
|
|||
// reading from the subset of the internal object's fields that appear in the
|
||||
// external representation. ToExternal does not modify its argument; there is
|
||||
// no pointer aliasing between the passed and returned objects
|
||||
func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
out := &OpenShiftCluster{
|
||||
ID: oc.ID,
|
||||
Name: oc.Name,
|
||||
|
@ -86,7 +86,7 @@ func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfa
|
|||
|
||||
// ToExternalList returns a slice of external representations of the internal
|
||||
// objects
|
||||
func (c *openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster, nextLink string) interface{} {
|
||||
func (c openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster, nextLink string) interface{} {
|
||||
l := &OpenShiftClusterList{
|
||||
OpenShiftClusters: make([]*OpenShiftCluster, 0, len(ocs)),
|
||||
NextLink: nextLink,
|
||||
|
@ -103,7 +103,7 @@ func (c *openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster,
|
|||
// all mapped fields from the external representation. ToInternal modifies its
|
||||
// argument; there is no pointer aliasing between the passed and returned
|
||||
// objects
|
||||
func (c *openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShiftCluster) {
|
||||
func (c openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShiftCluster) {
|
||||
oc := _oc.(*OpenShiftCluster)
|
||||
|
||||
out.ID = oc.ID
|
||||
|
|
|
@ -31,7 +31,12 @@ type openShiftClusterStaticValidator struct {
|
|||
}
|
||||
|
||||
// Validate validates an OpenShift cluster
|
||||
func (sv *openShiftClusterStaticValidator) Static(_oc interface{}, _current *api.OpenShiftCluster) error {
|
||||
func (sv openShiftClusterStaticValidator) Static(_oc interface{}, _current *api.OpenShiftCluster, location, domain string, requireD2sV3Workers bool, resourceID string) error {
|
||||
sv.location = location
|
||||
sv.domain = domain
|
||||
sv.requireD2sV3Workers = requireD2sV3Workers
|
||||
sv.resourceID = resourceID
|
||||
|
||||
oc := _oc.(*OpenShiftCluster)
|
||||
|
||||
var current *OpenShiftCluster
|
||||
|
@ -57,7 +62,7 @@ func (sv *openShiftClusterStaticValidator) Static(_oc interface{}, _current *api
|
|||
return sv.validateDelta(oc, current)
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCreate bool) error {
|
||||
if !strings.EqualFold(oc.ID, sv.resourceID) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeMismatchingResourceID, "id", "The provided resource ID '%s' did not match the name in the Url '%s'.", oc.ID, sv.resourceID)
|
||||
}
|
||||
|
@ -74,7 +79,7 @@ func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCrea
|
|||
return sv.validateProperties("properties", &oc.Properties, isCreate)
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateProperties(path string, p *OpenShiftClusterProperties, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validateProperties(path string, p *OpenShiftClusterProperties, isCreate bool) error {
|
||||
switch p.ProvisioningState {
|
||||
case ProvisioningStateCreating, ProvisioningStateUpdating,
|
||||
ProvisioningStateAdminUpdating, ProvisioningStateDeleting,
|
||||
|
@ -120,7 +125,7 @@ func (sv *openShiftClusterStaticValidator) validateProperties(path string, p *Op
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateClusterProfile(path string, cp *ClusterProfile, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validateClusterProfile(path string, cp *ClusterProfile, isCreate bool) error {
|
||||
if pullsecret.Validate(cp.PullSecret) != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".pullSecret", "The provided pull secret is invalid.")
|
||||
}
|
||||
|
@ -164,7 +169,7 @@ func (sv *openShiftClusterStaticValidator) validateClusterProfile(path string, c
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateConsoleProfile(path string, cp *ConsoleProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateConsoleProfile(path string, cp *ConsoleProfile) error {
|
||||
if cp.URL != "" {
|
||||
if _, err := url.Parse(cp.URL); err != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".url", "The provided console URL '%s' is invalid.", cp.URL)
|
||||
|
@ -174,7 +179,7 @@ func (sv *openShiftClusterStaticValidator) validateConsoleProfile(path string, c
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateServicePrincipalProfile(path string, spp *ServicePrincipalProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateServicePrincipalProfile(path string, spp *ServicePrincipalProfile) error {
|
||||
valid := uuid.IsValid(spp.ClientID)
|
||||
if !valid {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".clientId", "The provided client ID '%s' is invalid.", spp.ClientID)
|
||||
|
@ -186,7 +191,7 @@ func (sv *openShiftClusterStaticValidator) validateServicePrincipalProfile(path
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, np *NetworkProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateNetworkProfile(path string, np *NetworkProfile) error {
|
||||
_, pod, err := net.ParseCIDR(np.PodCIDR)
|
||||
if err != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".podCidr", "The provided pod CIDR '%s' is invalid: '%s'.", np.PodCIDR, err)
|
||||
|
@ -217,7 +222,7 @@ func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, n
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateMasterProfile(path string, mp *MasterProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateMasterProfile(path string, mp *MasterProfile) error {
|
||||
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.requireD2sV3Workers, true) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vmSize", "The provided master VM size '%s' is invalid.", mp.VMSize)
|
||||
}
|
||||
|
@ -235,7 +240,7 @@ func (sv *openShiftClusterStaticValidator) validateMasterProfile(path string, mp
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateWorkerProfile(path string, wp *WorkerProfile, mp *MasterProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateWorkerProfile(path string, wp *WorkerProfile, mp *MasterProfile) error {
|
||||
if wp.Name != "worker" {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".name", "The provided worker name '%s' is invalid.", wp.Name)
|
||||
}
|
||||
|
@ -269,7 +274,7 @@ func (sv *openShiftClusterStaticValidator) validateWorkerProfile(path string, wp
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateAPIServerProfile(path string, ap *APIServerProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateAPIServerProfile(path string, ap *APIServerProfile) error {
|
||||
switch ap.Visibility {
|
||||
case VisibilityPublic, VisibilityPrivate:
|
||||
default:
|
||||
|
@ -293,7 +298,7 @@ func (sv *openShiftClusterStaticValidator) validateAPIServerProfile(path string,
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateIngressProfile(path string, p *IngressProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateIngressProfile(path string, p *IngressProfile) error {
|
||||
if p.Name != "default" {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".name", "The provided ingress name '%s' is invalid.", p.Name)
|
||||
}
|
||||
|
@ -315,7 +320,7 @@ func (sv *openShiftClusterStaticValidator) validateIngressProfile(path string, p
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateDelta(oc, current *OpenShiftCluster) error {
|
||||
func (sv openShiftClusterStaticValidator) validateDelta(oc, current *OpenShiftCluster) error {
|
||||
err := immutable.Validate("", oc, current)
|
||||
if err != nil {
|
||||
err := err.(*immutable.ValidationError)
|
||||
|
|
|
@ -133,7 +133,7 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
|
|||
(&openShiftClusterConverter{}).ToInternal(validOCForTest(), current)
|
||||
}
|
||||
|
||||
err := v.Static(oc, current)
|
||||
err := v.Static(oc, current, v.location, v.domain, tt.requireD2sV3Workers, v.resourceID)
|
||||
if err == nil {
|
||||
if tt.wantErr != "" {
|
||||
t.Error(err)
|
||||
|
|
|
@ -14,7 +14,7 @@ type openShiftClusterCredentialsConverter struct{}
|
|||
// fields that appear in the external representation. ToExternal does not
|
||||
// modify its argument; there is no pointer aliasing between the passed and
|
||||
// returned objects.
|
||||
func (*openShiftClusterCredentialsConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
func (openShiftClusterCredentialsConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
out := &OpenShiftClusterCredentials{
|
||||
KubeadminUsername: "kubeadmin",
|
||||
KubeadminPassword: string(oc.Properties.KubeadminPassword),
|
||||
|
|
|
@ -17,20 +17,9 @@ const (
|
|||
|
||||
func init() {
|
||||
api.APIs[APIVersion] = &api.Version{
|
||||
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {
|
||||
return &openShiftClusterConverter{}
|
||||
},
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, requireD2sV3Workers bool, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
return &openShiftClusterStaticValidator{
|
||||
location: location,
|
||||
domain: domain,
|
||||
requireD2sV3Workers: requireD2sV3Workers,
|
||||
resourceID: resourceID,
|
||||
}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: func() api.OpenShiftClusterCredentialsConverter {
|
||||
return &openShiftClusterCredentialsConverter{}
|
||||
},
|
||||
OpenShiftClusterConverter: openShiftClusterConverter{},
|
||||
OpenShiftClusterStaticValidator: openShiftClusterStaticValidator{},
|
||||
OpenShiftClusterCredentialsConverter: openShiftClusterCredentialsConverter{},
|
||||
OperationList: api.OperationList{
|
||||
Operations: []api.Operation{
|
||||
api.OperationResultsRead,
|
||||
|
|
|
@ -13,7 +13,7 @@ type openShiftClusterConverter struct{}
|
|||
// reading from the subset of the internal object's fields that appear in the
|
||||
// external representation. ToExternal does not modify its argument; there is
|
||||
// no pointer aliasing between the passed and returned objects
|
||||
func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
out := &OpenShiftCluster{
|
||||
ID: oc.ID,
|
||||
Name: oc.Name,
|
||||
|
@ -100,7 +100,7 @@ func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfa
|
|||
|
||||
// ToExternalList returns a slice of external representations of the internal
|
||||
// objects
|
||||
func (c *openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster, nextLink string) interface{} {
|
||||
func (c openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster, nextLink string) interface{} {
|
||||
l := &OpenShiftClusterList{
|
||||
OpenShiftClusters: make([]*OpenShiftCluster, 0, len(ocs)),
|
||||
NextLink: nextLink,
|
||||
|
@ -117,7 +117,7 @@ func (c *openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster,
|
|||
// all mapped fields from the external representation. ToInternal modifies its
|
||||
// argument; there is no pointer aliasing between the passed and returned
|
||||
// objects
|
||||
func (c *openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShiftCluster) {
|
||||
func (c openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShiftCluster) {
|
||||
oc := _oc.(*OpenShiftCluster)
|
||||
|
||||
out.ID = oc.ID
|
||||
|
|
|
@ -31,7 +31,12 @@ type openShiftClusterStaticValidator struct {
|
|||
}
|
||||
|
||||
// Validate validates an OpenShift cluster
|
||||
func (sv *openShiftClusterStaticValidator) Static(_oc interface{}, _current *api.OpenShiftCluster) error {
|
||||
func (sv openShiftClusterStaticValidator) Static(_oc interface{}, _current *api.OpenShiftCluster, location, domain string, requireD2sV3Workers bool, resourceID string) error {
|
||||
sv.location = location
|
||||
sv.domain = domain
|
||||
sv.requireD2sV3Workers = requireD2sV3Workers
|
||||
sv.resourceID = resourceID
|
||||
|
||||
oc := _oc.(*OpenShiftCluster)
|
||||
|
||||
var current *OpenShiftCluster
|
||||
|
@ -57,7 +62,7 @@ func (sv *openShiftClusterStaticValidator) Static(_oc interface{}, _current *api
|
|||
return sv.validateDelta(oc, current)
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCreate bool) error {
|
||||
if !strings.EqualFold(oc.ID, sv.resourceID) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeMismatchingResourceID, "id", "The provided resource ID '%s' did not match the name in the Url '%s'.", oc.ID, sv.resourceID)
|
||||
}
|
||||
|
@ -74,7 +79,7 @@ func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCrea
|
|||
return sv.validateProperties("properties", &oc.Properties, isCreate)
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateProperties(path string, p *OpenShiftClusterProperties, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validateProperties(path string, p *OpenShiftClusterProperties, isCreate bool) error {
|
||||
switch p.ProvisioningState {
|
||||
case ProvisioningStateCreating, ProvisioningStateUpdating,
|
||||
ProvisioningStateAdminUpdating, ProvisioningStateDeleting,
|
||||
|
@ -120,7 +125,7 @@ func (sv *openShiftClusterStaticValidator) validateProperties(path string, p *Op
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateClusterProfile(path string, cp *ClusterProfile, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validateClusterProfile(path string, cp *ClusterProfile, isCreate bool) error {
|
||||
if pullsecret.Validate(cp.PullSecret) != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".pullSecret", "The provided pull secret is invalid.")
|
||||
}
|
||||
|
@ -164,7 +169,7 @@ func (sv *openShiftClusterStaticValidator) validateClusterProfile(path string, c
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateConsoleProfile(path string, cp *ConsoleProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateConsoleProfile(path string, cp *ConsoleProfile) error {
|
||||
if cp.URL != "" {
|
||||
if _, err := url.Parse(cp.URL); err != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".url", "The provided console URL '%s' is invalid.", cp.URL)
|
||||
|
@ -174,7 +179,7 @@ func (sv *openShiftClusterStaticValidator) validateConsoleProfile(path string, c
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateServicePrincipalProfile(path string, spp *ServicePrincipalProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateServicePrincipalProfile(path string, spp *ServicePrincipalProfile) error {
|
||||
valid := uuid.IsValid(spp.ClientID)
|
||||
if !valid {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".clientId", "The provided client ID '%s' is invalid.", spp.ClientID)
|
||||
|
@ -186,7 +191,7 @@ func (sv *openShiftClusterStaticValidator) validateServicePrincipalProfile(path
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, np *NetworkProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateNetworkProfile(path string, np *NetworkProfile) error {
|
||||
_, pod, err := net.ParseCIDR(np.PodCIDR)
|
||||
if err != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".podCidr", "The provided pod CIDR '%s' is invalid: '%s'.", np.PodCIDR, err)
|
||||
|
@ -223,7 +228,7 @@ func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, n
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateMasterProfile(path string, mp *MasterProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateMasterProfile(path string, mp *MasterProfile) error {
|
||||
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.requireD2sV3Workers, true) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vmSize", "The provided master VM size '%s' is invalid.", mp.VMSize)
|
||||
}
|
||||
|
@ -258,7 +263,7 @@ func (sv *openShiftClusterStaticValidator) validateMasterProfile(path string, mp
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateWorkerProfile(path string, wp *WorkerProfile, mp *MasterProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateWorkerProfile(path string, wp *WorkerProfile, mp *MasterProfile) error {
|
||||
if wp.Name != "worker" {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".name", "The provided worker name '%s' is invalid.", wp.Name)
|
||||
}
|
||||
|
@ -300,7 +305,7 @@ func (sv *openShiftClusterStaticValidator) validateWorkerProfile(path string, wp
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateAPIServerProfile(path string, ap *APIServerProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateAPIServerProfile(path string, ap *APIServerProfile) error {
|
||||
switch ap.Visibility {
|
||||
case VisibilityPublic, VisibilityPrivate:
|
||||
default:
|
||||
|
@ -324,7 +329,7 @@ func (sv *openShiftClusterStaticValidator) validateAPIServerProfile(path string,
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateIngressProfile(path string, p *IngressProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateIngressProfile(path string, p *IngressProfile) error {
|
||||
if p.Name != "default" {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".name", "The provided ingress name '%s' is invalid.", p.Name)
|
||||
}
|
||||
|
@ -346,7 +351,7 @@ func (sv *openShiftClusterStaticValidator) validateIngressProfile(path string, p
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateDelta(oc, current *OpenShiftCluster) error {
|
||||
func (sv openShiftClusterStaticValidator) validateDelta(oc, current *OpenShiftCluster) error {
|
||||
err := immutable.Validate("", oc, current)
|
||||
if err != nil {
|
||||
err := err.(*immutable.ValidationError)
|
||||
|
|
|
@ -150,7 +150,7 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
|
|||
(&openShiftClusterConverter{}).ToInternal(validOCForTest(), current)
|
||||
}
|
||||
|
||||
err := v.Static(oc, current)
|
||||
err := v.Static(oc, current, v.location, v.domain, tt.requireD2sV3Workers, v.resourceID)
|
||||
if err == nil {
|
||||
if tt.wantErr != "" {
|
||||
t.Error(err)
|
||||
|
|
|
@ -14,7 +14,7 @@ type openShiftClusterAdminKubeconfigConverter struct{}
|
|||
// fields that appear in the external representation. ToExternal does not
|
||||
// modify its argument; there is no pointer aliasing between the passed and
|
||||
// returned objects.
|
||||
func (*openShiftClusterAdminKubeconfigConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
func (openShiftClusterAdminKubeconfigConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
return &OpenShiftClusterAdminKubeconfig{
|
||||
Kubeconfig: oc.Properties.UserAdminKubeconfig,
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ type openShiftClusterCredentialsConverter struct{}
|
|||
// fields that appear in the external representation. ToExternal does not
|
||||
// modify its argument; there is no pointer aliasing between the passed and
|
||||
// returned objects.
|
||||
func (*openShiftClusterCredentialsConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
func (openShiftClusterCredentialsConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
out := &OpenShiftClusterCredentials{
|
||||
KubeadminUsername: "kubeadmin",
|
||||
KubeadminPassword: string(oc.Properties.KubeadminPassword),
|
||||
|
|
|
@ -17,23 +17,10 @@ const (
|
|||
|
||||
func init() {
|
||||
api.APIs[APIVersion] = &api.Version{
|
||||
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {
|
||||
return &openShiftClusterConverter{}
|
||||
},
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, requireD2sV3Workers bool, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
return &openShiftClusterStaticValidator{
|
||||
location: location,
|
||||
domain: domain,
|
||||
requireD2sV3Workers: requireD2sV3Workers,
|
||||
resourceID: resourceID,
|
||||
}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: func() api.OpenShiftClusterCredentialsConverter {
|
||||
return &openShiftClusterCredentialsConverter{}
|
||||
},
|
||||
OpenShiftClusterAdminKubeconfigConverter: func() api.OpenShiftClusterAdminKubeconfigConverter {
|
||||
return &openShiftClusterAdminKubeconfigConverter{}
|
||||
},
|
||||
OpenShiftClusterConverter: openShiftClusterConverter{},
|
||||
OpenShiftClusterStaticValidator: openShiftClusterStaticValidator{},
|
||||
OpenShiftClusterCredentialsConverter: openShiftClusterCredentialsConverter{},
|
||||
OpenShiftClusterAdminKubeconfigConverter: openShiftClusterAdminKubeconfigConverter{},
|
||||
OperationList: api.OperationList{
|
||||
Operations: []api.Operation{
|
||||
api.OperationResultsRead,
|
||||
|
|
|
@ -13,7 +13,7 @@ type openShiftClusterConverter struct{}
|
|||
// reading from the subset of the internal object's fields that appear in the
|
||||
// external representation. ToExternal does not modify its argument; there is
|
||||
// no pointer aliasing between the passed and returned objects
|
||||
func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
out := &OpenShiftCluster{
|
||||
ID: oc.ID,
|
||||
Name: oc.Name,
|
||||
|
@ -100,7 +100,7 @@ func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfa
|
|||
|
||||
// ToExternalList returns a slice of external representations of the internal
|
||||
// objects
|
||||
func (c *openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster, nextLink string) interface{} {
|
||||
func (c openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster, nextLink string) interface{} {
|
||||
l := &OpenShiftClusterList{
|
||||
OpenShiftClusters: make([]*OpenShiftCluster, 0, len(ocs)),
|
||||
NextLink: nextLink,
|
||||
|
@ -117,7 +117,7 @@ func (c *openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster,
|
|||
// all mapped fields from the external representation. ToInternal modifies its
|
||||
// argument; there is no pointer aliasing between the passed and returned
|
||||
// objects
|
||||
func (c *openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShiftCluster) {
|
||||
func (c openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShiftCluster) {
|
||||
oc := _oc.(*OpenShiftCluster)
|
||||
|
||||
out.ID = oc.ID
|
||||
|
|
|
@ -31,7 +31,12 @@ type openShiftClusterStaticValidator struct {
|
|||
}
|
||||
|
||||
// Validate validates an OpenShift cluster
|
||||
func (sv *openShiftClusterStaticValidator) Static(_oc interface{}, _current *api.OpenShiftCluster) error {
|
||||
func (sv openShiftClusterStaticValidator) Static(_oc interface{}, _current *api.OpenShiftCluster, location, domain string, requireD2sV3Workers bool, resourceID string) error {
|
||||
sv.location = location
|
||||
sv.domain = domain
|
||||
sv.requireD2sV3Workers = requireD2sV3Workers
|
||||
sv.resourceID = resourceID
|
||||
|
||||
oc := _oc.(*OpenShiftCluster)
|
||||
|
||||
var current *OpenShiftCluster
|
||||
|
@ -57,7 +62,7 @@ func (sv *openShiftClusterStaticValidator) Static(_oc interface{}, _current *api
|
|||
return sv.validateDelta(oc, current)
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCreate bool) error {
|
||||
if !strings.EqualFold(oc.ID, sv.resourceID) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeMismatchingResourceID, "id", "The provided resource ID '%s' did not match the name in the Url '%s'.", oc.ID, sv.resourceID)
|
||||
}
|
||||
|
@ -74,7 +79,7 @@ func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCrea
|
|||
return sv.validateProperties("properties", &oc.Properties, isCreate)
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateProperties(path string, p *OpenShiftClusterProperties, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validateProperties(path string, p *OpenShiftClusterProperties, isCreate bool) error {
|
||||
switch p.ProvisioningState {
|
||||
case ProvisioningStateCreating, ProvisioningStateUpdating,
|
||||
ProvisioningStateAdminUpdating, ProvisioningStateDeleting,
|
||||
|
@ -120,7 +125,7 @@ func (sv *openShiftClusterStaticValidator) validateProperties(path string, p *Op
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateClusterProfile(path string, cp *ClusterProfile, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validateClusterProfile(path string, cp *ClusterProfile, isCreate bool) error {
|
||||
if pullsecret.Validate(cp.PullSecret) != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".pullSecret", "The provided pull secret is invalid.")
|
||||
}
|
||||
|
@ -170,7 +175,7 @@ func (sv *openShiftClusterStaticValidator) validateClusterProfile(path string, c
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateConsoleProfile(path string, cp *ConsoleProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateConsoleProfile(path string, cp *ConsoleProfile) error {
|
||||
if cp.URL != "" {
|
||||
if _, err := url.Parse(cp.URL); err != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".url", "The provided console URL '%s' is invalid.", cp.URL)
|
||||
|
@ -180,7 +185,7 @@ func (sv *openShiftClusterStaticValidator) validateConsoleProfile(path string, c
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateServicePrincipalProfile(path string, spp *ServicePrincipalProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateServicePrincipalProfile(path string, spp *ServicePrincipalProfile) error {
|
||||
valid := uuid.IsValid(spp.ClientID)
|
||||
if !valid {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".clientId", "The provided client ID '%s' is invalid.", spp.ClientID)
|
||||
|
@ -192,7 +197,7 @@ func (sv *openShiftClusterStaticValidator) validateServicePrincipalProfile(path
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, np *NetworkProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateNetworkProfile(path string, np *NetworkProfile) error {
|
||||
_, pod, err := net.ParseCIDR(np.PodCIDR)
|
||||
if err != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".podCidr", "The provided pod CIDR '%s' is invalid: '%s'.", np.PodCIDR, err)
|
||||
|
@ -223,7 +228,7 @@ func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, n
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateMasterProfile(path string, mp *MasterProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateMasterProfile(path string, mp *MasterProfile) error {
|
||||
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.requireD2sV3Workers, true) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vmSize", "The provided master VM size '%s' is invalid.", mp.VMSize)
|
||||
}
|
||||
|
@ -258,7 +263,7 @@ func (sv *openShiftClusterStaticValidator) validateMasterProfile(path string, mp
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateWorkerProfile(path string, wp *WorkerProfile, mp *MasterProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateWorkerProfile(path string, wp *WorkerProfile, mp *MasterProfile) error {
|
||||
if wp.Name != "worker" {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".name", "The provided worker name '%s' is invalid.", wp.Name)
|
||||
}
|
||||
|
@ -300,7 +305,7 @@ func (sv *openShiftClusterStaticValidator) validateWorkerProfile(path string, wp
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateAPIServerProfile(path string, ap *APIServerProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateAPIServerProfile(path string, ap *APIServerProfile) error {
|
||||
switch ap.Visibility {
|
||||
case VisibilityPublic, VisibilityPrivate:
|
||||
default:
|
||||
|
@ -324,7 +329,7 @@ func (sv *openShiftClusterStaticValidator) validateAPIServerProfile(path string,
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateIngressProfile(path string, p *IngressProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateIngressProfile(path string, p *IngressProfile) error {
|
||||
if p.Name != "default" {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".name", "The provided ingress name '%s' is invalid.", p.Name)
|
||||
}
|
||||
|
@ -346,7 +351,7 @@ func (sv *openShiftClusterStaticValidator) validateIngressProfile(path string, p
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateDelta(oc, current *OpenShiftCluster) error {
|
||||
func (sv openShiftClusterStaticValidator) validateDelta(oc, current *OpenShiftCluster) error {
|
||||
err := immutable.Validate("", oc, current)
|
||||
if err != nil {
|
||||
err := err.(*immutable.ValidationError)
|
||||
|
|
|
@ -150,7 +150,7 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
|
|||
(&openShiftClusterConverter{}).ToInternal(validOCForTest(), current)
|
||||
}
|
||||
|
||||
err := v.Static(oc, current)
|
||||
err := v.Static(oc, current, v.location, v.domain, tt.requireD2sV3Workers, v.resourceID)
|
||||
if err == nil {
|
||||
if tt.wantErr != "" {
|
||||
t.Error(err)
|
||||
|
|
|
@ -14,7 +14,7 @@ type openShiftClusterAdminKubeconfigConverter struct{}
|
|||
// fields that appear in the external representation. ToExternal does not
|
||||
// modify its argument; there is no pointer aliasing between the passed and
|
||||
// returned objects.
|
||||
func (*openShiftClusterAdminKubeconfigConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
func (openShiftClusterAdminKubeconfigConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
return &OpenShiftClusterAdminKubeconfig{
|
||||
Kubeconfig: oc.Properties.UserAdminKubeconfig,
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ type openShiftClusterCredentialsConverter struct{}
|
|||
// fields that appear in the external representation. ToExternal does not
|
||||
// modify its argument; there is no pointer aliasing between the passed and
|
||||
// returned objects.
|
||||
func (*openShiftClusterCredentialsConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
func (openShiftClusterCredentialsConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
out := &OpenShiftClusterCredentials{
|
||||
KubeadminUsername: "kubeadmin",
|
||||
KubeadminPassword: string(oc.Properties.KubeadminPassword),
|
||||
|
|
|
@ -17,23 +17,10 @@ const (
|
|||
|
||||
func init() {
|
||||
api.APIs[APIVersion] = &api.Version{
|
||||
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {
|
||||
return &openShiftClusterConverter{}
|
||||
},
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, requireD2sV3Workers bool, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
return &openShiftClusterStaticValidator{
|
||||
location: location,
|
||||
domain: domain,
|
||||
requireD2sV3Workers: requireD2sV3Workers,
|
||||
resourceID: resourceID,
|
||||
}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: func() api.OpenShiftClusterCredentialsConverter {
|
||||
return &openShiftClusterCredentialsConverter{}
|
||||
},
|
||||
OpenShiftClusterAdminKubeconfigConverter: func() api.OpenShiftClusterAdminKubeconfigConverter {
|
||||
return &openShiftClusterAdminKubeconfigConverter{}
|
||||
},
|
||||
OpenShiftClusterConverter: openShiftClusterConverter{},
|
||||
OpenShiftClusterStaticValidator: openShiftClusterStaticValidator{},
|
||||
OpenShiftClusterCredentialsConverter: openShiftClusterCredentialsConverter{},
|
||||
OpenShiftClusterAdminKubeconfigConverter: openShiftClusterAdminKubeconfigConverter{},
|
||||
OperationList: api.OperationList{
|
||||
Operations: []api.Operation{
|
||||
api.OperationResultsRead,
|
||||
|
|
|
@ -7,6 +7,6 @@ import "github.com/Azure/ARO-RP/pkg/api"
|
|||
|
||||
type installVersionsConverter struct{}
|
||||
|
||||
func (*installVersionsConverter) ToExternal(installVersions *api.InstallVersions) interface{} {
|
||||
func (installVersionsConverter) ToExternal(installVersions *api.InstallVersions) interface{} {
|
||||
return installVersions
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ type openShiftClusterConverter struct{}
|
|||
// reading from the subset of the internal object's fields that appear in the
|
||||
// external representation. ToExternal does not modify its argument; there is
|
||||
// no pointer aliasing between the passed and returned objects
|
||||
func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
func (c openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
out := &OpenShiftCluster{
|
||||
ID: oc.ID,
|
||||
Name: oc.Name,
|
||||
|
@ -100,7 +100,7 @@ func (c *openShiftClusterConverter) ToExternal(oc *api.OpenShiftCluster) interfa
|
|||
|
||||
// ToExternalList returns a slice of external representations of the internal
|
||||
// objects
|
||||
func (c *openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster, nextLink string) interface{} {
|
||||
func (c openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster, nextLink string) interface{} {
|
||||
l := &OpenShiftClusterList{
|
||||
OpenShiftClusters: make([]*OpenShiftCluster, 0, len(ocs)),
|
||||
NextLink: nextLink,
|
||||
|
@ -117,7 +117,7 @@ func (c *openShiftClusterConverter) ToExternalList(ocs []*api.OpenShiftCluster,
|
|||
// all mapped fields from the external representation. ToInternal modifies its
|
||||
// argument; there is no pointer aliasing between the passed and returned
|
||||
// objects
|
||||
func (c *openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShiftCluster) {
|
||||
func (c openShiftClusterConverter) ToInternal(_oc interface{}, out *api.OpenShiftCluster) {
|
||||
oc := _oc.(*OpenShiftCluster)
|
||||
|
||||
out.ID = oc.ID
|
||||
|
|
|
@ -30,7 +30,12 @@ type openShiftClusterStaticValidator struct {
|
|||
}
|
||||
|
||||
// Validate validates an OpenShift cluster
|
||||
func (sv *openShiftClusterStaticValidator) Static(_oc interface{}, _current *api.OpenShiftCluster) error {
|
||||
func (sv openShiftClusterStaticValidator) Static(_oc interface{}, _current *api.OpenShiftCluster, location, domain string, requireD2sV3Workers bool, resourceID string) error {
|
||||
sv.location = location
|
||||
sv.domain = domain
|
||||
sv.requireD2sV3Workers = requireD2sV3Workers
|
||||
sv.resourceID = resourceID
|
||||
|
||||
oc := _oc.(*OpenShiftCluster)
|
||||
|
||||
var current *OpenShiftCluster
|
||||
|
@ -56,7 +61,7 @@ func (sv *openShiftClusterStaticValidator) Static(_oc interface{}, _current *api
|
|||
return sv.validateDelta(oc, current)
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCreate bool) error {
|
||||
if !strings.EqualFold(oc.ID, sv.resourceID) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeMismatchingResourceID, "id", "The provided resource ID '%s' did not match the name in the Url '%s'.", oc.ID, sv.resourceID)
|
||||
}
|
||||
|
@ -73,7 +78,7 @@ func (sv *openShiftClusterStaticValidator) validate(oc *OpenShiftCluster, isCrea
|
|||
return sv.validateProperties("properties", &oc.Properties, isCreate)
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateProperties(path string, p *OpenShiftClusterProperties, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validateProperties(path string, p *OpenShiftClusterProperties, isCreate bool) error {
|
||||
switch p.ProvisioningState {
|
||||
case ProvisioningStateCreating, ProvisioningStateUpdating,
|
||||
ProvisioningStateAdminUpdating, ProvisioningStateDeleting,
|
||||
|
@ -119,7 +124,7 @@ func (sv *openShiftClusterStaticValidator) validateProperties(path string, p *Op
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateClusterProfile(path string, cp *ClusterProfile, isCreate bool) error {
|
||||
func (sv openShiftClusterStaticValidator) validateClusterProfile(path string, cp *ClusterProfile, isCreate bool) error {
|
||||
if pullsecret.Validate(cp.PullSecret) != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".pullSecret", "The provided pull secret is invalid.")
|
||||
}
|
||||
|
@ -169,7 +174,7 @@ func (sv *openShiftClusterStaticValidator) validateClusterProfile(path string, c
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateConsoleProfile(path string, cp *ConsoleProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateConsoleProfile(path string, cp *ConsoleProfile) error {
|
||||
if cp.URL != "" {
|
||||
if _, err := url.Parse(cp.URL); err != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".url", "The provided console URL '%s' is invalid.", cp.URL)
|
||||
|
@ -179,7 +184,7 @@ func (sv *openShiftClusterStaticValidator) validateConsoleProfile(path string, c
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateServicePrincipalProfile(path string, spp *ServicePrincipalProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateServicePrincipalProfile(path string, spp *ServicePrincipalProfile) error {
|
||||
valid := uuid.IsValid(spp.ClientID)
|
||||
if !valid {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".clientId", "The provided client ID '%s' is invalid.", spp.ClientID)
|
||||
|
@ -191,7 +196,7 @@ func (sv *openShiftClusterStaticValidator) validateServicePrincipalProfile(path
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, np *NetworkProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateNetworkProfile(path string, np *NetworkProfile) error {
|
||||
_, pod, err := net.ParseCIDR(np.PodCIDR)
|
||||
if err != nil {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".podCidr", "The provided pod CIDR '%s' is invalid: '%s'.", np.PodCIDR, err)
|
||||
|
@ -222,7 +227,7 @@ func (sv *openShiftClusterStaticValidator) validateNetworkProfile(path string, n
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateMasterProfile(path string, mp *MasterProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateMasterProfile(path string, mp *MasterProfile) error {
|
||||
if !validate.VMSizeIsValid(api.VMSize(mp.VMSize), sv.requireD2sV3Workers, true) {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vmSize", "The provided master VM size '%s' is invalid.", mp.VMSize)
|
||||
}
|
||||
|
@ -257,7 +262,7 @@ func (sv *openShiftClusterStaticValidator) validateMasterProfile(path string, mp
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateWorkerProfile(path string, wp *WorkerProfile, mp *MasterProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateWorkerProfile(path string, wp *WorkerProfile, mp *MasterProfile) error {
|
||||
if wp.Name != "worker" {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".name", "The provided worker name '%s' is invalid.", wp.Name)
|
||||
}
|
||||
|
@ -299,7 +304,7 @@ func (sv *openShiftClusterStaticValidator) validateWorkerProfile(path string, wp
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateAPIServerProfile(path string, ap *APIServerProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateAPIServerProfile(path string, ap *APIServerProfile) error {
|
||||
switch ap.Visibility {
|
||||
case VisibilityPublic, VisibilityPrivate:
|
||||
default:
|
||||
|
@ -323,7 +328,7 @@ func (sv *openShiftClusterStaticValidator) validateAPIServerProfile(path string,
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateIngressProfile(path string, p *IngressProfile) error {
|
||||
func (sv openShiftClusterStaticValidator) validateIngressProfile(path string, p *IngressProfile) error {
|
||||
if p.Name != "default" {
|
||||
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".name", "The provided ingress name '%s' is invalid.", p.Name)
|
||||
}
|
||||
|
@ -345,7 +350,7 @@ func (sv *openShiftClusterStaticValidator) validateIngressProfile(path string, p
|
|||
return nil
|
||||
}
|
||||
|
||||
func (sv *openShiftClusterStaticValidator) validateDelta(oc, current *OpenShiftCluster) error {
|
||||
func (sv openShiftClusterStaticValidator) validateDelta(oc, current *OpenShiftCluster) error {
|
||||
err := immutable.Validate("", oc, current)
|
||||
if err != nil {
|
||||
err := err.(*immutable.ValidationError)
|
||||
|
|
|
@ -165,7 +165,7 @@ func runTests(t *testing.T, mode testMode, tests []*validateTest) {
|
|||
(&openShiftClusterConverter{}).ToInternal(validOCForTest(), current)
|
||||
}
|
||||
|
||||
err := v.Static(oc, current)
|
||||
err := v.Static(oc, current, v.location, v.domain, tt.requireD2sV3Workers, v.resourceID)
|
||||
if err == nil {
|
||||
if tt.wantErr != "" {
|
||||
t.Error(err)
|
||||
|
|
|
@ -14,7 +14,7 @@ type openShiftClusterAdminKubeconfigConverter struct{}
|
|||
// fields that appear in the external representation. ToExternal does not
|
||||
// modify its argument; there is no pointer aliasing between the passed and
|
||||
// returned objects.
|
||||
func (*openShiftClusterAdminKubeconfigConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
func (openShiftClusterAdminKubeconfigConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
return &OpenShiftClusterAdminKubeconfig{
|
||||
Kubeconfig: oc.Properties.UserAdminKubeconfig,
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ type openShiftClusterCredentialsConverter struct{}
|
|||
// fields that appear in the external representation. ToExternal does not
|
||||
// modify its argument; there is no pointer aliasing between the passed and
|
||||
// returned objects.
|
||||
func (*openShiftClusterCredentialsConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
func (openShiftClusterCredentialsConverter) ToExternal(oc *api.OpenShiftCluster) interface{} {
|
||||
out := &OpenShiftClusterCredentials{
|
||||
KubeadminUsername: "kubeadmin",
|
||||
KubeadminPassword: string(oc.Properties.KubeadminPassword),
|
||||
|
|
|
@ -17,26 +17,11 @@ const (
|
|||
|
||||
func init() {
|
||||
api.APIs[APIVersion] = &api.Version{
|
||||
OpenShiftClusterConverter: func() api.OpenShiftClusterConverter {
|
||||
return &openShiftClusterConverter{}
|
||||
},
|
||||
OpenShiftClusterStaticValidator: func(location, domain string, requireD2sV3Workers bool, resourceID string) api.OpenShiftClusterStaticValidator {
|
||||
return &openShiftClusterStaticValidator{
|
||||
location: location,
|
||||
domain: domain,
|
||||
requireD2sV3Workers: requireD2sV3Workers,
|
||||
resourceID: resourceID,
|
||||
}
|
||||
},
|
||||
OpenShiftClusterCredentialsConverter: func() api.OpenShiftClusterCredentialsConverter {
|
||||
return &openShiftClusterCredentialsConverter{}
|
||||
},
|
||||
OpenShiftClusterAdminKubeconfigConverter: func() api.OpenShiftClusterAdminKubeconfigConverter {
|
||||
return &openShiftClusterAdminKubeconfigConverter{}
|
||||
},
|
||||
InstallVersionsConverter: func() api.InstallVersionsConverter {
|
||||
return &installVersionsConverter{}
|
||||
},
|
||||
OpenShiftClusterConverter: openShiftClusterConverter{},
|
||||
OpenShiftClusterStaticValidator: openShiftClusterStaticValidator{},
|
||||
OpenShiftClusterCredentialsConverter: openShiftClusterCredentialsConverter{},
|
||||
OpenShiftClusterAdminKubeconfigConverter: openShiftClusterAdminKubeconfigConverter{},
|
||||
InstallVersionsConverter: installVersionsConverter{},
|
||||
OperationList: api.OperationList{
|
||||
Operations: []api.Operation{
|
||||
api.OperationResultsRead,
|
||||
|
|
|
@ -19,7 +19,7 @@ func (f *frontend) getAdminOpenShiftClusters(w http.ResponseWriter, r *http.Requ
|
|||
log := ctx.Value(middleware.ContextKeyLog).(*logrus.Entry)
|
||||
r.URL.Path = filepath.Dir(r.URL.Path)
|
||||
|
||||
b, err := f._getOpenShiftClusters(ctx, log, r, f.apis[admin.APIVersion].OpenShiftClusterConverter(), func(skipToken string) (cosmosdb.OpenShiftClusterDocumentIterator, error) {
|
||||
b, err := f._getOpenShiftClusters(ctx, log, r, f.apis[admin.APIVersion].OpenShiftClusterConverter, func(skipToken string) (cosmosdb.OpenShiftClusterDocumentIterator, error) {
|
||||
return f.dbOpenShiftClusters.List(skipToken), nil
|
||||
})
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ func (f *frontend) getAdminOpenShiftVersions(w http.ResponseWriter, r *http.Requ
|
|||
log := ctx.Value(middleware.ContextKeyLog).(*logrus.Entry)
|
||||
r.URL.Path = filepath.Dir(r.URL.Path)
|
||||
|
||||
converter := f.apis[admin.APIVersion].OpenShiftVersionConverter()
|
||||
converter := f.apis[admin.APIVersion].OpenShiftVersionConverter
|
||||
|
||||
docs, err := f.dbOpenShiftVersions.ListAll(ctx)
|
||||
if err != nil {
|
||||
|
|
|
@ -20,8 +20,8 @@ func (f *frontend) putAdminOpenShiftVersion(w http.ResponseWriter, r *http.Reque
|
|||
log := ctx.Value(middleware.ContextKeyLog).(*logrus.Entry)
|
||||
r.URL.Path = filepath.Dir(r.URL.Path)
|
||||
|
||||
converter := f.apis[admin.APIVersion].OpenShiftVersionConverter()
|
||||
staticValidator := f.apis[admin.APIVersion].OpenShiftVersionStaticValidator()
|
||||
converter := f.apis[admin.APIVersion].OpenShiftVersionConverter
|
||||
staticValidator := f.apis[admin.APIVersion].OpenShiftVersionStaticValidator
|
||||
|
||||
body := r.Context().Value(middleware.ContextKeyBody).([]byte)
|
||||
if len(body) == 0 || !json.Valid(body) {
|
||||
|
|
|
@ -23,7 +23,7 @@ func (f *frontend) getAsyncOperationResult(w http.ResponseWriter, r *http.Reques
|
|||
vars := mux.Vars(r)
|
||||
|
||||
header := http.Header{}
|
||||
b, err := f._getAsyncOperationResult(ctx, r, header, f.apis[vars["api-version"]].OpenShiftClusterConverter())
|
||||
b, err := f._getAsyncOperationResult(ctx, r, header, f.apis[vars["api-version"]].OpenShiftClusterConverter)
|
||||
|
||||
reply(log, w, header, b, err)
|
||||
}
|
||||
|
|
|
@ -14,13 +14,13 @@ import (
|
|||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
)
|
||||
|
||||
func (f *frontend) newAsyncOperation(ctx context.Context, r *http.Request, doc *api.OpenShiftClusterDocument) (string, error) {
|
||||
func (f *frontend) newAsyncOperation(ctx context.Context, vars map[string]string, doc *api.OpenShiftClusterDocument) (string, error) {
|
||||
id := f.dbAsyncOperations.NewUUID()
|
||||
_, err := f.dbAsyncOperations.Create(ctx, &api.AsyncOperationDocument{
|
||||
ID: id,
|
||||
OpenShiftClusterKey: doc.Key,
|
||||
AsyncOperation: &api.AsyncOperation{
|
||||
ID: f.operationsPath(r, id),
|
||||
ID: f.operationsPath(vars, id),
|
||||
Name: id,
|
||||
InitialProvisioningState: doc.OpenShiftCluster.Properties.ProvisioningState,
|
||||
ProvisioningState: doc.OpenShiftCluster.Properties.ProvisioningState,
|
||||
|
@ -34,9 +34,7 @@ func (f *frontend) newAsyncOperation(ctx context.Context, r *http.Request, doc *
|
|||
return id, nil
|
||||
}
|
||||
|
||||
func (f *frontend) operationsPath(r *http.Request, id string) string {
|
||||
vars := mux.Vars(r)
|
||||
|
||||
func (f *frontend) operationsPath(vars map[string]string, id string) string {
|
||||
return "/subscriptions/" + vars["subscriptionId"] + "/providers/" + vars["resourceProviderNamespace"] + "/locations/" + strings.ToLower(f.env.Location()) + "/operationsstatus/" + id
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ func (f *frontend) listInstallVersions(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
converter := f.apis[vars["api-version"]].InstallVersionsConverter()
|
||||
converter := f.apis[vars["api-version"]].InstallVersionsConverter
|
||||
|
||||
b, err := json.Marshal(converter.ToExternal((*api.InstallVersions)(&versions)))
|
||||
reply(log, w, nil, b, err)
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/Azure/ARO-RP/pkg/api"
|
||||
|
@ -51,7 +52,7 @@ func (f *frontend) _deleteOpenShiftCluster(ctx context.Context, r *http.Request,
|
|||
doc.CorrelationData = correlationData
|
||||
doc.Dequeues = 0
|
||||
|
||||
doc.AsyncOperationID, err = f.newAsyncOperation(ctx, r, doc)
|
||||
doc.AsyncOperationID, err = f.newAsyncOperation(ctx, mux.Vars(r), doc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -66,7 +67,7 @@ func (f *frontend) _deleteOpenShiftCluster(ctx context.Context, r *http.Request,
|
|||
u.Path = f.operationResultsPath(r, doc.AsyncOperationID)
|
||||
(*header)["Location"] = []string{u.String()}
|
||||
|
||||
u.Path = f.operationsPath(r, doc.AsyncOperationID)
|
||||
u.Path = f.operationsPath(mux.Vars(r), doc.AsyncOperationID)
|
||||
(*header)["Azure-AsyncOperation"] = []string{u.String()}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -22,7 +22,7 @@ func (f *frontend) getOpenShiftCluster(w http.ResponseWriter, r *http.Request) {
|
|||
log := ctx.Value(middleware.ContextKeyLog).(*logrus.Entry)
|
||||
vars := mux.Vars(r)
|
||||
|
||||
b, err := f._getOpenShiftCluster(ctx, log, r, f.apis[vars["api-version"]].OpenShiftClusterConverter())
|
||||
b, err := f._getOpenShiftCluster(ctx, log, r, f.apis[vars["api-version"]].OpenShiftClusterConverter)
|
||||
|
||||
reply(log, w, nil, b, err)
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ func (f *frontend) getOpenShiftClusters(w http.ResponseWriter, r *http.Request)
|
|||
log := ctx.Value(middleware.ContextKeyLog).(*logrus.Entry)
|
||||
vars := mux.Vars(r)
|
||||
|
||||
b, err := f._getOpenShiftClusters(ctx, log, r, f.apis[vars["api-version"]].OpenShiftClusterConverter(), func(skipToken string) (cosmosdb.OpenShiftClusterDocumentIterator, error) {
|
||||
b, err := f._getOpenShiftClusters(ctx, log, r, f.apis[vars["api-version"]].OpenShiftClusterConverter, func(skipToken string) (cosmosdb.OpenShiftClusterDocumentIterator, error) {
|
||||
prefix := "/subscriptions/" + vars["subscriptionId"] + "/"
|
||||
if vars["resourceGroupName"] != "" {
|
||||
prefix += "resourcegroups/" + vars["resourceGroupName"] + "/"
|
||||
|
|
|
@ -31,26 +31,29 @@ func (f *frontend) putOrPatchOpenShiftCluster(w http.ResponseWriter, r *http.Req
|
|||
|
||||
var header http.Header
|
||||
var b []byte
|
||||
|
||||
body := r.Context().Value(middleware.ContextKeyBody).([]byte)
|
||||
correlationData := r.Context().Value(middleware.ContextKeyCorrelationData).(*api.CorrelationData)
|
||||
systemData, _ := r.Context().Value(middleware.ContextKeySystemData).(*api.SystemData) // don't panic
|
||||
originalPath := r.Context().Value(middleware.ContextKeyOriginalPath).(string)
|
||||
referer := r.Header.Get("Referer")
|
||||
|
||||
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.FeatureIsSet(env.FeatureRequireD2sV3Workers), r.URL.Path))
|
||||
b, err = f._putOrPatchOpenShiftCluster(ctx, log, body, correlationData, systemData, r.URL.Path, originalPath, r.Method, referer, &header, f.apis[vars["api-version"]].OpenShiftClusterConverter, f.apis[vars["api-version"]].OpenShiftClusterStaticValidator, mux.Vars(r))
|
||||
return err
|
||||
})
|
||||
|
||||
reply(log, w, header, b, err)
|
||||
}
|
||||
|
||||
func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.Entry, r *http.Request, header *http.Header, converter api.OpenShiftClusterConverter, staticValidator api.OpenShiftClusterStaticValidator) ([]byte, error) {
|
||||
body := r.Context().Value(middleware.ContextKeyBody).([]byte)
|
||||
correlationData := r.Context().Value(middleware.ContextKeyCorrelationData).(*api.CorrelationData)
|
||||
systemData, _ := r.Context().Value(middleware.ContextKeySystemData).(*api.SystemData) // don't panic
|
||||
|
||||
_, err := f.validateSubscriptionState(ctx, r.URL.Path, api.SubscriptionStateRegistered)
|
||||
func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.Entry, body []byte, correlationData *api.CorrelationData, systemData *api.SystemData, path, originalPath, method, referer string, header *http.Header, converter api.OpenShiftClusterConverter, staticValidator api.OpenShiftClusterStaticValidator, vars map[string]string) ([]byte, error) {
|
||||
_, err := f.validateSubscriptionState(ctx, path, api.SubscriptionStateRegistered)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
doc, err := f.dbOpenShiftClusters.Get(ctx, r.URL.Path)
|
||||
doc, err := f.dbOpenShiftClusters.Get(ctx, path)
|
||||
if err != nil && !cosmosdb.IsErrorStatusCode(err, http.StatusNotFound) {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -58,20 +61,19 @@ func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.
|
|||
isCreate := doc == nil
|
||||
|
||||
if isCreate {
|
||||
originalPath := r.Context().Value(middleware.ContextKeyOriginalPath).(string)
|
||||
originalR, err := azure.ParseResourceID(originalPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
installVersion, err := f.validateAndReturnInstallVersion(ctx, &body)
|
||||
installVersion, err := f.validateAndReturnInstallVersion(ctx, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
doc = &api.OpenShiftClusterDocument{
|
||||
ID: f.dbOpenShiftClusters.NewUUID(),
|
||||
Key: r.URL.Path,
|
||||
Key: path,
|
||||
OpenShiftCluster: &api.OpenShiftCluster{
|
||||
ID: originalPath,
|
||||
Name: originalR.ResourceName,
|
||||
|
@ -124,7 +126,7 @@ func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.
|
|||
}
|
||||
|
||||
var ext interface{}
|
||||
switch r.Method {
|
||||
switch method {
|
||||
// In case of PUT we will take customer request payload and store into database
|
||||
// Our base structure for unmarshal is skeleton document with values we
|
||||
// think is required. We expect payload to have everything else required.
|
||||
|
@ -160,9 +162,9 @@ func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.
|
|||
}
|
||||
|
||||
if isCreate {
|
||||
err = staticValidator.Static(ext, nil)
|
||||
err = staticValidator.Static(ext, nil, f.env.Location(), f.env.Domain(), f.env.FeatureIsSet(env.FeatureRequireD2sV3Workers), path)
|
||||
} else {
|
||||
err = staticValidator.Static(ext, doc.OpenShiftCluster)
|
||||
err = staticValidator.Static(ext, doc.OpenShiftCluster, f.env.Location(), f.env.Domain(), f.env.FeatureIsSet(env.FeatureRequireD2sV3Workers), path)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -193,7 +195,6 @@ func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.
|
|||
doc.OpenShiftCluster.Properties.LastProvisioningState = doc.OpenShiftCluster.Properties.ProvisioningState
|
||||
|
||||
// TODO: Get rid of the special case
|
||||
vars := mux.Vars(r)
|
||||
if vars["api-version"] == admin.APIVersion {
|
||||
doc.OpenShiftCluster.Properties.ProvisioningState = api.ProvisioningStateAdminUpdating
|
||||
doc.OpenShiftCluster.Properties.LastAdminUpdateError = ""
|
||||
|
@ -206,17 +207,17 @@ func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.
|
|||
// SetDefaults will set defaults on cluster document
|
||||
api.SetDefaults(doc)
|
||||
|
||||
doc.AsyncOperationID, err = f.newAsyncOperation(ctx, r, doc)
|
||||
doc.AsyncOperationID, err = f.newAsyncOperation(ctx, vars, doc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
u, err := url.Parse(r.Header.Get("Referer"))
|
||||
u, err := url.Parse(referer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
u.Path = f.operationsPath(r, doc.AsyncOperationID)
|
||||
u.Path = f.operationsPath(vars, doc.AsyncOperationID)
|
||||
*header = http.Header{
|
||||
"Azure-AsyncOperation": []string{u.String()},
|
||||
}
|
||||
|
@ -239,7 +240,7 @@ func (f *frontend) _putOrPatchOpenShiftCluster(ctx context.Context, log *logrus.
|
|||
doc.OpenShiftCluster.Properties.ClusterProfile.PullSecret = ""
|
||||
doc.OpenShiftCluster.Properties.ServicePrincipalProfile.ClientSecret = ""
|
||||
|
||||
b, err := json.MarshalIndent(converter.ToExternal(doc.OpenShiftCluster), "", " ")
|
||||
b, err := json.MarshalIndent(converter.ToExternal(doc.OpenShiftCluster), "", "\t")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import (
|
|||
|
||||
type dummyOpenShiftClusterValidator struct{}
|
||||
|
||||
func (*dummyOpenShiftClusterValidator) Static(interface{}, *api.OpenShiftCluster) error {
|
||||
func (*dummyOpenShiftClusterValidator) Static(interface{}, *api.OpenShiftCluster, string, string, bool, string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -645,10 +645,8 @@ 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 {
|
||||
return &dummyOpenShiftClusterValidator{}
|
||||
},
|
||||
OpenShiftClusterConverter: api.APIs["2020-04-30"].OpenShiftClusterConverter,
|
||||
OpenShiftClusterStaticValidator: &dummyOpenShiftClusterValidator{},
|
||||
OpenShiftClusterCredentialsConverter: api.APIs["2020-04-30"].OpenShiftClusterCredentialsConverter,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ func (f *frontend) postOpenShiftClusterCredentials(w http.ResponseWriter, r *htt
|
|||
|
||||
r.URL.Path = filepath.Dir(r.URL.Path)
|
||||
|
||||
b, err := f._postOpenShiftClusterCredentials(ctx, r, f.apis[vars["api-version"]].OpenShiftClusterCredentialsConverter())
|
||||
b, err := f._postOpenShiftClusterCredentials(ctx, r, f.apis[vars["api-version"]].OpenShiftClusterCredentialsConverter)
|
||||
|
||||
reply(log, w, nil, b, err)
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func (f *frontend) postOpenShiftClusterKubeConfigCredentials(w http.ResponseWrit
|
|||
|
||||
r.URL.Path = filepath.Dir(r.URL.Path)
|
||||
|
||||
b, err := f._postOpenShiftClusterKubeConfigCredentials(ctx, r, f.apis[vars["api-version"]].OpenShiftClusterAdminKubeconfigConverter())
|
||||
b, err := f._postOpenShiftClusterKubeConfigCredentials(ctx, r, f.apis[vars["api-version"]].OpenShiftClusterAdminKubeconfigConverter)
|
||||
|
||||
reply(log, w, nil, b, err)
|
||||
}
|
||||
|
|
|
@ -167,7 +167,7 @@ func validateAdminVMSize(vmSize string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (f *frontend) validateAndReturnInstallVersion(ctx context.Context, body *[]byte) (string, error) {
|
||||
func (f *frontend) validateAndReturnInstallVersion(ctx context.Context, body []byte) (string, error) {
|
||||
oc, err := installversion.FromExternalBytes(body)
|
||||
if err != nil {
|
||||
return "", api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidRequestContent, "", "The request content was invalid and could not be deserialized: %q.", err)
|
||||
|
|
|
@ -454,7 +454,7 @@ func (c *Cluster) createCluster(ctx context.Context, vnetResourceGroup, clusterN
|
|||
oc.Properties.WorkerProfiles[0].VMSize = api.VMSizeStandardD2sV3
|
||||
}
|
||||
|
||||
ext := api.APIs[v20220401.APIVersion].OpenShiftClusterConverter().ToExternal(&oc)
|
||||
ext := api.APIs[v20220401.APIVersion].OpenShiftClusterConverter.ToExternal(&oc)
|
||||
data, err := json.Marshal(ext)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Загрузка…
Ссылка в новой задаче