Merge pull request #84723 from hypnoglow/fix-golint-kubeapiserver

Fix golint issues in pkg/kubeapiserver
This commit is contained in:
Kubernetes Prow Robot 2019-11-05 22:18:20 -08:00 committed by GitHub
commit 2aeacf025b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 6 deletions

View File

@ -429,7 +429,7 @@ func buildGenericConfig(
genericConfig.Version = &kubeVersion
storageFactoryConfig := kubeapiserver.NewStorageFactoryConfig()
storageFactoryConfig.ApiResourceConfig = genericConfig.MergedResourceConfig
storageFactoryConfig.APIResourceConfig = genericConfig.MergedResourceConfig
completedStorageFactoryConfig, err := storageFactoryConfig.Complete(s.Etcd)
if err != nil {
lastErr = err

View File

@ -49,6 +49,7 @@ var SpecialDefaultResourcePrefixes = map[schema.GroupResource]string{
{Group: "policy", Resource: "podsecuritypolicies"}: "podsecuritypolicy",
}
// NewStorageFactoryConfig returns a new StorageFactoryConfig set up with necessary resource overrides.
func NewStorageFactoryConfig() *StorageFactoryConfig {
resources := []schema.GroupVersionResource{
@ -66,9 +67,10 @@ func NewStorageFactoryConfig() *StorageFactoryConfig {
}
}
// StorageFactoryConfig is a configuration for creating storage factory.
type StorageFactoryConfig struct {
StorageConfig storagebackend.Config
ApiResourceConfig *serverstorage.ResourceConfig
APIResourceConfig *serverstorage.ResourceConfig
DefaultResourceEncoding *serverstorage.DefaultResourceEncodingConfig
DefaultStorageMediaType string
Serializer runtime.StorageSerializer
@ -77,6 +79,7 @@ type StorageFactoryConfig struct {
EncryptionProviderConfigFilepath string
}
// Complete completes the StorageFactoryConfig with provided etcdOptions returning completedStorageFactoryConfig.
func (c *StorageFactoryConfig) Complete(etcdOptions *serveroptions.EtcdOptions) (*completedStorageFactoryConfig, error) {
c.StorageConfig = etcdOptions.StorageConfig
c.DefaultStorageMediaType = etcdOptions.DefaultStorageMediaType
@ -85,10 +88,15 @@ func (c *StorageFactoryConfig) Complete(etcdOptions *serveroptions.EtcdOptions)
return &completedStorageFactoryConfig{c}, nil
}
// completedStorageFactoryConfig is a wrapper around StorageFactoryConfig completed with etcd options.
//
// Note: this struct is intentionally unexported so that it can only be constructed via a StorageFactoryConfig.Complete
// call. The implied consequence is that this does not comply with golint.
type completedStorageFactoryConfig struct {
*StorageFactoryConfig
}
// New returns a new storage factory created from the completed storage factory configuration.
func (c *completedStorageFactoryConfig) New() (*serverstorage.DefaultStorageFactory, error) {
resourceEncodingConfig := resourceconfig.MergeResourceEncodingConfigs(c.DefaultResourceEncoding, c.ResourceEncodingOverrides)
storageFactory := serverstorage.NewDefaultStorageFactory(
@ -96,7 +104,7 @@ func (c *completedStorageFactoryConfig) New() (*serverstorage.DefaultStorageFact
c.DefaultStorageMediaType,
c.Serializer,
resourceEncodingConfig,
c.ApiResourceConfig,
c.APIResourceConfig,
SpecialDefaultResourcePrefixes)
storageFactory.AddCohabitatingResources(networking.Resource("networkpolicies"), extensions.Resource("networkpolicies"))

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// The kubeapiserver package holds code that is common to both the kube-apiserver
// Package kubeapiserver holds code that is common to both the kube-apiserver
// and the federation-apiserver, but isn't part of a generic API server.
// For instance, the non-delegated authorization options are used by those two
// servers, but no generic API server is likely to use them.

View File

@ -44,7 +44,7 @@ func NewEtcdStorageForResource(t *testing.T, resource schema.GroupResource) (*st
if err != nil {
t.Fatal(err)
}
completedConfig.ApiResourceConfig = serverstorage.NewResourceConfig()
completedConfig.APIResourceConfig = serverstorage.NewResourceConfig()
factory, err := completedConfig.New()
if err != nil {
t.Fatal(err)

View File

@ -278,7 +278,7 @@ func NewMasterConfigWithOptions(opts *MasterConfigOptions) *master.Config {
}
storageConfig := kubeapiserver.NewStorageFactoryConfig()
storageConfig.ApiResourceConfig = serverstorage.NewResourceConfig()
storageConfig.APIResourceConfig = serverstorage.NewResourceConfig()
completedStorageConfig, err := storageConfig.Complete(etcdOptions)
if err != nil {
panic(err)