mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Fix Operation names for subresources
This commit is contained in:
		@@ -577,6 +577,14 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		routes := []*restful.RouteBuilder{}
 | 
							routes := []*restful.RouteBuilder{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// If there is a subresource, kind should be the parent's kind.
 | 
				
			||||||
 | 
							if hasSubresource {
 | 
				
			||||||
 | 
								fqParentKind, err := a.getResourceKind(resource, a.group.Storage[resource])
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return nil, err
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								kind = fqParentKind.Kind
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		switch action.Verb {
 | 
							switch action.Verb {
 | 
				
			||||||
		case "GET": // Get a resource.
 | 
							case "GET": // Get a resource.
 | 
				
			||||||
			var handler restful.RouteFunction
 | 
								var handler restful.RouteFunction
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -63,10 +63,6 @@ func GetOperationIDAndTags(r *restful.Route) (string, []string, error) {
 | 
				
			|||||||
	op := r.Operation
 | 
						op := r.Operation
 | 
				
			||||||
	path := r.Path
 | 
						path := r.Path
 | 
				
			||||||
	var tags []string
 | 
						var tags []string
 | 
				
			||||||
	// TODO: This is hacky, figure out where this name conflict is created and fix it at the root.
 | 
					 | 
				
			||||||
	if strings.HasPrefix(path, "/apis/extensions/v1beta1/namespaces/{namespace}/") && strings.HasSuffix(op, "ScaleScale") {
 | 
					 | 
				
			||||||
		op = op[:len(op)-10] + strings.Title(strings.Split(path[48:], "/")[0]) + "Scale"
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	prefix, exists := verbs.GetPrefix(op)
 | 
						prefix, exists := verbs.GetPrefix(op)
 | 
				
			||||||
	if !exists {
 | 
						if !exists {
 | 
				
			||||||
		return op, tags, fmt.Errorf("operation names should start with a verb. Cannot determine operation verb from %v", op)
 | 
							return op, tags, fmt.Errorf("operation names should start with a verb. Cannot determine operation verb from %v", op)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user