Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint errors staging/src/k8s.io #77751

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions hack/.golint_failures
Original file line number Diff line number Diff line change
Expand Up @@ -593,12 +593,8 @@ staging/src/k8s.io/sample-apiserver/pkg/admission/plugin/banflunder
staging/src/k8s.io/sample-apiserver/pkg/admission/wardleinitializer
staging/src/k8s.io/sample-apiserver/pkg/apis/wardle
staging/src/k8s.io/sample-apiserver/pkg/apis/wardle/v1alpha1
staging/src/k8s.io/sample-apiserver/pkg/apiserver
staging/src/k8s.io/sample-apiserver/pkg/cmd/server
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/fischer
staging/src/k8s.io/sample-apiserver/pkg/registry/wardle/flunder
staging/src/k8s.io/sample-controller/pkg/apis/samplecontroller
staging/src/k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1
test/e2e
test/e2e/auth
test/e2e/autoscaling
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ import (
)

var (
// Scheme defines methods for serializing and deserializing API objects.
Scheme = runtime.NewScheme()
// Codecs provides methods for retrieving codecs and serializers for specific
// versions and content types.
Codecs = serializer.NewCodecFactory(Scheme)
)

Expand All @@ -55,10 +58,12 @@ func init() {
)
}

// ExtraConfig holds custom apiserver config
type ExtraConfig struct {
// Place you custom config here.
}

// Config defines the config for the apiserver
type Config struct {
GenericConfig *genericapiserver.RecommendedConfig
ExtraConfig ExtraConfig
Expand All @@ -74,8 +79,8 @@ type completedConfig struct {
ExtraConfig *ExtraConfig
}

// CompletedConfig embeds a private pointer that cannot be instantiated outside of this package.
type CompletedConfig struct {
// Embed a private pointer that cannot be instantiated outside of this package.
*completedConfig
}

Expand Down
6 changes: 6 additions & 0 deletions staging/src/k8s.io/sample-apiserver/pkg/cmd/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (

const defaultEtcdPathPrefix = "/registry/wardle.kubernetes.io"

// WardleServerOptions contains state for master/api server
type WardleServerOptions struct {
RecommendedOptions *genericoptions.RecommendedOptions

Expand All @@ -49,6 +50,7 @@ type WardleServerOptions struct {
StdErr io.Writer
}

// NewWardleServerOptions returns a new WardleServerOptions
func NewWardleServerOptions(out, errOut io.Writer) *WardleServerOptions {
o := &WardleServerOptions{
RecommendedOptions: genericoptions.NewRecommendedOptions(
Expand Down Expand Up @@ -92,12 +94,14 @@ func NewCommandStartWardleServer(defaults *WardleServerOptions, stopCh <-chan st
return cmd
}

// Validate validates WardleServerOptions
func (o WardleServerOptions) Validate(args []string) error {
errors := []error{}
errors = append(errors, o.RecommendedOptions.Validate()...)
return utilerrors.NewAggregate(errors)
}

// Complete fills in fields required to have valid data
func (o *WardleServerOptions) Complete() error {
// register admission plugins
banflunder.Register(o.RecommendedOptions.Admission.Plugins)
Expand All @@ -108,6 +112,7 @@ func (o *WardleServerOptions) Complete() error {
return nil
}

// Config returns config for the api server given WardleServerOptions
func (o *WardleServerOptions) Config() (*apiserver.Config, error) {
// TODO have a "real" external address
if err := o.RecommendedOptions.SecureServing.MaybeDefaultWithSelfSignedCerts("localhost", nil, []net.IP{net.ParseIP("127.0.0.1")}); err != nil {
Expand Down Expand Up @@ -138,6 +143,7 @@ func (o *WardleServerOptions) Config() (*apiserver.Config, error) {
return config, nil
}

// RunWardleServer starts a new WardleServer given WardleServerOptions
func (o WardleServerOptions) RunWardleServer(stopCh <-chan struct{}) error {
config, err := o.Config()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.

package samplecontroller

// GroupName is the group name used in this package
const (
GroupName = "samplecontroller.k8s.io"
)
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ func Resource(resource string) schema.GroupResource {
}

var (
// SchemeBuilder initializes a scheme builder
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the comment be above SchemeBuilder here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the comment to the line just before.

AddToScheme = SchemeBuilder.AddToScheme
// AddToScheme is a global function that registers this API group & version to a scheme
AddToScheme = SchemeBuilder.AddToScheme
)

// Adds the list of known types to Scheme.
Expand Down