Dataset Viewer
Auto-converted to Parquet Duplicate
repository_name
stringlengths
5
48
func_path_in_repository
stringlengths
4
155
func_name
stringlengths
1
118
whole_func_string
stringlengths
52
3.87M
language
stringclasses
1 value
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
21
188k
func_documentation_string
stringlengths
31
26.3k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
252
kubernetes/kubernetes
staging/src/k8s.io/apimachinery/pkg/runtime/extension.go
MarshalJSON
func (re RawExtension) MarshalJSON() ([]byte, error) { if re.Raw == nil { // TODO: this is to support legacy behavior of JSONPrinter and YAMLPrinter, which // expect to call json.Marshal on arbitrary versioned objects (even those not in // the scheme). pkg/kubectl/resource#AsVersionedObjects and its interaction with // kubectl get on objects not in the scheme needs to be updated to ensure that the // objects that are not part of the scheme are correctly put into the right form. if re.Object != nil { return json.Marshal(re.Object) } return []byte("null"), nil } // TODO: Check whether ContentType is actually JSON before returning it. return re.Raw, nil }
go
func (re RawExtension) MarshalJSON() ([]byte, error) { if re.Raw == nil { // TODO: this is to support legacy behavior of JSONPrinter and YAMLPrinter, which // expect to call json.Marshal on arbitrary versioned objects (even those not in // the scheme). pkg/kubectl/resource#AsVersionedObjects and its interaction with // kubectl get on objects not in the scheme needs to be updated to ensure that the // objects that are not part of the scheme are correctly put into the right form. if re.Object != nil { return json.Marshal(re.Object) } return []byte("null"), nil } // TODO: Check whether ContentType is actually JSON before returning it. return re.Raw, nil }
[ "func", "(", "re", "RawExtension", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "re", ".", "Raw", "==", "nil", "{", "// TODO: this is to support legacy behavior of JSONPrinter and YAMLPrinter, which", "// expect to call json.Marsh...
// MarshalJSON may get called on pointers or values, so implement MarshalJSON on value. // http://stackoverflow.com/questions/21390979/custom-marshaljson-never-gets-called-in-go
[ "MarshalJSON", "may", "get", "called", "on", "pointers", "or", "values", "so", "implement", "MarshalJSON", "on", "value", ".", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "21390979", "/", "custom", "-", "marshaljson", "-", "never",...
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/apimachinery/pkg/runtime/extension.go#L37-L51
kubernetes/kubernetes
staging/src/k8s.io/client-go/tools/clientcmd/validation.go
IsContextNotFound
func IsContextNotFound(err error) bool { if err == nil { return false } if _, ok := err.(*errContextNotFound); ok || err == ErrNoContext { return true } return strings.Contains(err.Error(), "context was not found for specified context") }
go
func IsContextNotFound(err error) bool { if err == nil { return false } if _, ok := err.(*errContextNotFound); ok || err == ErrNoContext { return true } return strings.Contains(err.Error(), "context was not found for specified context") }
[ "func", "IsContextNotFound", "(", "err", "error", ")", "bool", "{", "if", "err", "==", "nil", "{", "return", "false", "\n", "}", "\n", "if", "_", ",", "ok", ":=", "err", ".", "(", "*", "errContextNotFound", ")", ";", "ok", "||", "err", "==", "ErrNo...
// IsContextNotFound returns a boolean indicating whether the error is known to // report that a context was not found
[ "IsContextNotFound", "returns", "a", "boolean", "indicating", "whether", "the", "error", "is", "known", "to", "report", "that", "a", "context", "was", "not", "found" ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/tools/clientcmd/validation.go#L48-L56
kubernetes/kubernetes
staging/src/k8s.io/client-go/tools/clientcmd/validation.go
IsEmptyConfig
func IsEmptyConfig(err error) bool { switch t := err.(type) { case errConfigurationInvalid: return len(t) == 1 && t[0] == ErrEmptyConfig } return err == ErrEmptyConfig }
go
func IsEmptyConfig(err error) bool { switch t := err.(type) { case errConfigurationInvalid: return len(t) == 1 && t[0] == ErrEmptyConfig } return err == ErrEmptyConfig }
[ "func", "IsEmptyConfig", "(", "err", "error", ")", "bool", "{", "switch", "t", ":=", "err", ".", "(", "type", ")", "{", "case", "errConfigurationInvalid", ":", "return", "len", "(", "t", ")", "==", "1", "&&", "t", "[", "0", "]", "==", "ErrEmptyConfig...
// IsEmptyConfig returns true if the provided error indicates the provided configuration // is empty.
[ "IsEmptyConfig", "returns", "true", "if", "the", "provided", "error", "indicates", "the", "provided", "configuration", "is", "empty", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/tools/clientcmd/validation.go#L60-L66
kubernetes/kubernetes
staging/src/k8s.io/client-go/tools/clientcmd/validation.go
IsConfigurationInvalid
func IsConfigurationInvalid(err error) bool { switch err.(type) { case *errContextNotFound, errConfigurationInvalid: return true } return IsContextNotFound(err) }
go
func IsConfigurationInvalid(err error) bool { switch err.(type) { case *errContextNotFound, errConfigurationInvalid: return true } return IsContextNotFound(err) }
[ "func", "IsConfigurationInvalid", "(", "err", "error", ")", "bool", "{", "switch", "err", ".", "(", "type", ")", "{", "case", "*", "errContextNotFound", ",", "errConfigurationInvalid", ":", "return", "true", "\n", "}", "\n", "return", "IsContextNotFound", "(",...
// IsConfigurationInvalid returns true if the provided error indicates the configuration is invalid.
[ "IsConfigurationInvalid", "returns", "true", "if", "the", "provided", "error", "indicates", "the", "configuration", "is", "invalid", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/tools/clientcmd/validation.go#L95-L101
kubernetes/kubernetes
staging/src/k8s.io/client-go/tools/clientcmd/validation.go
Validate
func Validate(config clientcmdapi.Config) error { validationErrors := make([]error, 0) if clientcmdapi.IsConfigEmpty(&config) { return newErrConfigurationInvalid([]error{ErrEmptyConfig}) } if len(config.CurrentContext) != 0 { if _, exists := config.Contexts[config.CurrentContext]; !exists { validationErrors = append(validationErrors, &errContextNotFound{config.CurrentContext}) } } for contextName, context := range config.Contexts { validationErrors = append(validationErrors, validateContext(contextName, *context, config)...) } for authInfoName, authInfo := range config.AuthInfos { validationErrors = append(validationErrors, validateAuthInfo(authInfoName, *authInfo)...) } for clusterName, clusterInfo := range config.Clusters { validationErrors = append(validationErrors, validateClusterInfo(clusterName, *clusterInfo)...) } return newErrConfigurationInvalid(validationErrors) }
go
func Validate(config clientcmdapi.Config) error { validationErrors := make([]error, 0) if clientcmdapi.IsConfigEmpty(&config) { return newErrConfigurationInvalid([]error{ErrEmptyConfig}) } if len(config.CurrentContext) != 0 { if _, exists := config.Contexts[config.CurrentContext]; !exists { validationErrors = append(validationErrors, &errContextNotFound{config.CurrentContext}) } } for contextName, context := range config.Contexts { validationErrors = append(validationErrors, validateContext(contextName, *context, config)...) } for authInfoName, authInfo := range config.AuthInfos { validationErrors = append(validationErrors, validateAuthInfo(authInfoName, *authInfo)...) } for clusterName, clusterInfo := range config.Clusters { validationErrors = append(validationErrors, validateClusterInfo(clusterName, *clusterInfo)...) } return newErrConfigurationInvalid(validationErrors) }
[ "func", "Validate", "(", "config", "clientcmdapi", ".", "Config", ")", "error", "{", "validationErrors", ":=", "make", "(", "[", "]", "error", ",", "0", ")", "\n\n", "if", "clientcmdapi", ".", "IsConfigEmpty", "(", "&", "config", ")", "{", "return", "new...
// Validate checks for errors in the Config. It does not return early so that it can find as many errors as possible.
[ "Validate", "checks", "for", "errors", "in", "the", "Config", ".", "It", "does", "not", "return", "early", "so", "that", "it", "can", "find", "as", "many", "errors", "as", "possible", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/tools/clientcmd/validation.go#L104-L130
kubernetes/kubernetes
staging/src/k8s.io/client-go/tools/clientcmd/validation.go
ConfirmUsable
func ConfirmUsable(config clientcmdapi.Config, passedContextName string) error { validationErrors := make([]error, 0) if clientcmdapi.IsConfigEmpty(&config) { return newErrConfigurationInvalid([]error{ErrEmptyConfig}) } var contextName string if len(passedContextName) != 0 { contextName = passedContextName } else { contextName = config.CurrentContext } if len(contextName) == 0 { return ErrNoContext } context, exists := config.Contexts[contextName] if !exists { validationErrors = append(validationErrors, &errContextNotFound{contextName}) } if exists { validationErrors = append(validationErrors, validateContext(contextName, *context, config)...) validationErrors = append(validationErrors, validateAuthInfo(context.AuthInfo, *config.AuthInfos[context.AuthInfo])...) validationErrors = append(validationErrors, validateClusterInfo(context.Cluster, *config.Clusters[context.Cluster])...) } return newErrConfigurationInvalid(validationErrors) }
go
func ConfirmUsable(config clientcmdapi.Config, passedContextName string) error { validationErrors := make([]error, 0) if clientcmdapi.IsConfigEmpty(&config) { return newErrConfigurationInvalid([]error{ErrEmptyConfig}) } var contextName string if len(passedContextName) != 0 { contextName = passedContextName } else { contextName = config.CurrentContext } if len(contextName) == 0 { return ErrNoContext } context, exists := config.Contexts[contextName] if !exists { validationErrors = append(validationErrors, &errContextNotFound{contextName}) } if exists { validationErrors = append(validationErrors, validateContext(contextName, *context, config)...) validationErrors = append(validationErrors, validateAuthInfo(context.AuthInfo, *config.AuthInfos[context.AuthInfo])...) validationErrors = append(validationErrors, validateClusterInfo(context.Cluster, *config.Clusters[context.Cluster])...) } return newErrConfigurationInvalid(validationErrors) }
[ "func", "ConfirmUsable", "(", "config", "clientcmdapi", ".", "Config", ",", "passedContextName", "string", ")", "error", "{", "validationErrors", ":=", "make", "(", "[", "]", "error", ",", "0", ")", "\n\n", "if", "clientcmdapi", ".", "IsConfigEmpty", "(", "&...
// ConfirmUsable looks a particular context and determines if that particular part of the config is useable. There might still be errors in the config, // but no errors in the sections requested or referenced. It does not return early so that it can find as many errors as possible.
[ "ConfirmUsable", "looks", "a", "particular", "context", "and", "determines", "if", "that", "particular", "part", "of", "the", "config", "is", "useable", ".", "There", "might", "still", "be", "errors", "in", "the", "config", "but", "no", "errors", "in", "the"...
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/tools/clientcmd/validation.go#L134-L164
kubernetes/kubernetes
staging/src/k8s.io/client-go/tools/clientcmd/validation.go
validateClusterInfo
func validateClusterInfo(clusterName string, clusterInfo clientcmdapi.Cluster) []error { validationErrors := make([]error, 0) emptyCluster := clientcmdapi.NewCluster() if reflect.DeepEqual(*emptyCluster, clusterInfo) { return []error{ErrEmptyCluster} } if len(clusterInfo.Server) == 0 { if len(clusterName) == 0 { validationErrors = append(validationErrors, fmt.Errorf("default cluster has no server defined")) } else { validationErrors = append(validationErrors, fmt.Errorf("no server found for cluster %q", clusterName)) } } // Make sure CA data and CA file aren't both specified if len(clusterInfo.CertificateAuthority) != 0 && len(clusterInfo.CertificateAuthorityData) != 0 { validationErrors = append(validationErrors, fmt.Errorf("certificate-authority-data and certificate-authority are both specified for %v. certificate-authority-data will override.", clusterName)) } if len(clusterInfo.CertificateAuthority) != 0 { clientCertCA, err := os.Open(clusterInfo.CertificateAuthority) defer clientCertCA.Close() if err != nil { validationErrors = append(validationErrors, fmt.Errorf("unable to read certificate-authority %v for %v due to %v", clusterInfo.CertificateAuthority, clusterName, err)) } } return validationErrors }
go
func validateClusterInfo(clusterName string, clusterInfo clientcmdapi.Cluster) []error { validationErrors := make([]error, 0) emptyCluster := clientcmdapi.NewCluster() if reflect.DeepEqual(*emptyCluster, clusterInfo) { return []error{ErrEmptyCluster} } if len(clusterInfo.Server) == 0 { if len(clusterName) == 0 { validationErrors = append(validationErrors, fmt.Errorf("default cluster has no server defined")) } else { validationErrors = append(validationErrors, fmt.Errorf("no server found for cluster %q", clusterName)) } } // Make sure CA data and CA file aren't both specified if len(clusterInfo.CertificateAuthority) != 0 && len(clusterInfo.CertificateAuthorityData) != 0 { validationErrors = append(validationErrors, fmt.Errorf("certificate-authority-data and certificate-authority are both specified for %v. certificate-authority-data will override.", clusterName)) } if len(clusterInfo.CertificateAuthority) != 0 { clientCertCA, err := os.Open(clusterInfo.CertificateAuthority) defer clientCertCA.Close() if err != nil { validationErrors = append(validationErrors, fmt.Errorf("unable to read certificate-authority %v for %v due to %v", clusterInfo.CertificateAuthority, clusterName, err)) } } return validationErrors }
[ "func", "validateClusterInfo", "(", "clusterName", "string", ",", "clusterInfo", "clientcmdapi", ".", "Cluster", ")", "[", "]", "error", "{", "validationErrors", ":=", "make", "(", "[", "]", "error", ",", "0", ")", "\n\n", "emptyCluster", ":=", "clientcmdapi",...
// validateClusterInfo looks for conflicts and errors in the cluster info
[ "validateClusterInfo", "looks", "for", "conflicts", "and", "errors", "in", "the", "cluster", "info" ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/tools/clientcmd/validation.go#L167-L195
kubernetes/kubernetes
staging/src/k8s.io/client-go/tools/clientcmd/validation.go
validateAuthInfo
func validateAuthInfo(authInfoName string, authInfo clientcmdapi.AuthInfo) []error { validationErrors := make([]error, 0) usingAuthPath := false methods := make([]string, 0, 3) if len(authInfo.Token) != 0 { methods = append(methods, "token") } if len(authInfo.Username) != 0 || len(authInfo.Password) != 0 { methods = append(methods, "basicAuth") } if len(authInfo.ClientCertificate) != 0 || len(authInfo.ClientCertificateData) != 0 { // Make sure cert data and file aren't both specified if len(authInfo.ClientCertificate) != 0 && len(authInfo.ClientCertificateData) != 0 { validationErrors = append(validationErrors, fmt.Errorf("client-cert-data and client-cert are both specified for %v. client-cert-data will override.", authInfoName)) } // Make sure key data and file aren't both specified if len(authInfo.ClientKey) != 0 && len(authInfo.ClientKeyData) != 0 { validationErrors = append(validationErrors, fmt.Errorf("client-key-data and client-key are both specified for %v; client-key-data will override", authInfoName)) } // Make sure a key is specified if len(authInfo.ClientKey) == 0 && len(authInfo.ClientKeyData) == 0 { validationErrors = append(validationErrors, fmt.Errorf("client-key-data or client-key must be specified for %v to use the clientCert authentication method.", authInfoName)) } if len(authInfo.ClientCertificate) != 0 { clientCertFile, err := os.Open(authInfo.ClientCertificate) defer clientCertFile.Close() if err != nil { validationErrors = append(validationErrors, fmt.Errorf("unable to read client-cert %v for %v due to %v", authInfo.ClientCertificate, authInfoName, err)) } } if len(authInfo.ClientKey) != 0 { clientKeyFile, err := os.Open(authInfo.ClientKey) defer clientKeyFile.Close() if err != nil { validationErrors = append(validationErrors, fmt.Errorf("unable to read client-key %v for %v due to %v", authInfo.ClientKey, authInfoName, err)) } } } if authInfo.Exec != nil { if authInfo.AuthProvider != nil { validationErrors = append(validationErrors, fmt.Errorf("authProvider cannot be provided in combination with an exec plugin for %s", authInfoName)) } if len(authInfo.Exec.Command) == 0 { validationErrors = append(validationErrors, fmt.Errorf("command must be specified for %v to use exec authentication plugin", authInfoName)) } if len(authInfo.Exec.APIVersion) == 0 { validationErrors = append(validationErrors, fmt.Errorf("apiVersion must be specified for %v to use exec authentication plugin", authInfoName)) } for _, v := range authInfo.Exec.Env { if len(v.Name) == 0 { validationErrors = append(validationErrors, fmt.Errorf("env variable name must be specified for %v to use exec authentication plugin", authInfoName)) } else if len(v.Value) == 0 { validationErrors = append(validationErrors, fmt.Errorf("env variable %s value must be specified for %v to use exec authentication plugin", v.Name, authInfoName)) } } } // authPath also provides information for the client to identify the server, so allow multiple auth methods in that case if (len(methods) > 1) && (!usingAuthPath) { validationErrors = append(validationErrors, fmt.Errorf("more than one authentication method found for %v; found %v, only one is allowed", authInfoName, methods)) } // ImpersonateGroups or ImpersonateUserExtra should be requested with a user if (len(authInfo.ImpersonateGroups) > 0 || len(authInfo.ImpersonateUserExtra) > 0) && (len(authInfo.Impersonate) == 0) { validationErrors = append(validationErrors, fmt.Errorf("requesting groups or user-extra for %v without impersonating a user", authInfoName)) } return validationErrors }
go
func validateAuthInfo(authInfoName string, authInfo clientcmdapi.AuthInfo) []error { validationErrors := make([]error, 0) usingAuthPath := false methods := make([]string, 0, 3) if len(authInfo.Token) != 0 { methods = append(methods, "token") } if len(authInfo.Username) != 0 || len(authInfo.Password) != 0 { methods = append(methods, "basicAuth") } if len(authInfo.ClientCertificate) != 0 || len(authInfo.ClientCertificateData) != 0 { // Make sure cert data and file aren't both specified if len(authInfo.ClientCertificate) != 0 && len(authInfo.ClientCertificateData) != 0 { validationErrors = append(validationErrors, fmt.Errorf("client-cert-data and client-cert are both specified for %v. client-cert-data will override.", authInfoName)) } // Make sure key data and file aren't both specified if len(authInfo.ClientKey) != 0 && len(authInfo.ClientKeyData) != 0 { validationErrors = append(validationErrors, fmt.Errorf("client-key-data and client-key are both specified for %v; client-key-data will override", authInfoName)) } // Make sure a key is specified if len(authInfo.ClientKey) == 0 && len(authInfo.ClientKeyData) == 0 { validationErrors = append(validationErrors, fmt.Errorf("client-key-data or client-key must be specified for %v to use the clientCert authentication method.", authInfoName)) } if len(authInfo.ClientCertificate) != 0 { clientCertFile, err := os.Open(authInfo.ClientCertificate) defer clientCertFile.Close() if err != nil { validationErrors = append(validationErrors, fmt.Errorf("unable to read client-cert %v for %v due to %v", authInfo.ClientCertificate, authInfoName, err)) } } if len(authInfo.ClientKey) != 0 { clientKeyFile, err := os.Open(authInfo.ClientKey) defer clientKeyFile.Close() if err != nil { validationErrors = append(validationErrors, fmt.Errorf("unable to read client-key %v for %v due to %v", authInfo.ClientKey, authInfoName, err)) } } } if authInfo.Exec != nil { if authInfo.AuthProvider != nil { validationErrors = append(validationErrors, fmt.Errorf("authProvider cannot be provided in combination with an exec plugin for %s", authInfoName)) } if len(authInfo.Exec.Command) == 0 { validationErrors = append(validationErrors, fmt.Errorf("command must be specified for %v to use exec authentication plugin", authInfoName)) } if len(authInfo.Exec.APIVersion) == 0 { validationErrors = append(validationErrors, fmt.Errorf("apiVersion must be specified for %v to use exec authentication plugin", authInfoName)) } for _, v := range authInfo.Exec.Env { if len(v.Name) == 0 { validationErrors = append(validationErrors, fmt.Errorf("env variable name must be specified for %v to use exec authentication plugin", authInfoName)) } else if len(v.Value) == 0 { validationErrors = append(validationErrors, fmt.Errorf("env variable %s value must be specified for %v to use exec authentication plugin", v.Name, authInfoName)) } } } // authPath also provides information for the client to identify the server, so allow multiple auth methods in that case if (len(methods) > 1) && (!usingAuthPath) { validationErrors = append(validationErrors, fmt.Errorf("more than one authentication method found for %v; found %v, only one is allowed", authInfoName, methods)) } // ImpersonateGroups or ImpersonateUserExtra should be requested with a user if (len(authInfo.ImpersonateGroups) > 0 || len(authInfo.ImpersonateUserExtra) > 0) && (len(authInfo.Impersonate) == 0) { validationErrors = append(validationErrors, fmt.Errorf("requesting groups or user-extra for %v without impersonating a user", authInfoName)) } return validationErrors }
[ "func", "validateAuthInfo", "(", "authInfoName", "string", ",", "authInfo", "clientcmdapi", ".", "AuthInfo", ")", "[", "]", "error", "{", "validationErrors", ":=", "make", "(", "[", "]", "error", ",", "0", ")", "\n\n", "usingAuthPath", ":=", "false", "\n", ...
// validateAuthInfo looks for conflicts and errors in the auth info
[ "validateAuthInfo", "looks", "for", "conflicts", "and", "errors", "in", "the", "auth", "info" ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/tools/clientcmd/validation.go#L198-L269
kubernetes/kubernetes
staging/src/k8s.io/client-go/tools/clientcmd/validation.go
validateContext
func validateContext(contextName string, context clientcmdapi.Context, config clientcmdapi.Config) []error { validationErrors := make([]error, 0) if len(contextName) == 0 { validationErrors = append(validationErrors, fmt.Errorf("empty context name for %#v is not allowed", context)) } if len(context.AuthInfo) == 0 { validationErrors = append(validationErrors, fmt.Errorf("user was not specified for context %q", contextName)) } else if _, exists := config.AuthInfos[context.AuthInfo]; !exists { validationErrors = append(validationErrors, fmt.Errorf("user %q was not found for context %q", context.AuthInfo, contextName)) } if len(context.Cluster) == 0 { validationErrors = append(validationErrors, fmt.Errorf("cluster was not specified for context %q", contextName)) } else if _, exists := config.Clusters[context.Cluster]; !exists { validationErrors = append(validationErrors, fmt.Errorf("cluster %q was not found for context %q", context.Cluster, contextName)) } if len(context.Namespace) != 0 { if len(validation.IsDNS1123Label(context.Namespace)) != 0 { validationErrors = append(validationErrors, fmt.Errorf("namespace %q for context %q does not conform to the kubernetes DNS_LABEL rules", context.Namespace, contextName)) } } return validationErrors }
go
func validateContext(contextName string, context clientcmdapi.Context, config clientcmdapi.Config) []error { validationErrors := make([]error, 0) if len(contextName) == 0 { validationErrors = append(validationErrors, fmt.Errorf("empty context name for %#v is not allowed", context)) } if len(context.AuthInfo) == 0 { validationErrors = append(validationErrors, fmt.Errorf("user was not specified for context %q", contextName)) } else if _, exists := config.AuthInfos[context.AuthInfo]; !exists { validationErrors = append(validationErrors, fmt.Errorf("user %q was not found for context %q", context.AuthInfo, contextName)) } if len(context.Cluster) == 0 { validationErrors = append(validationErrors, fmt.Errorf("cluster was not specified for context %q", contextName)) } else if _, exists := config.Clusters[context.Cluster]; !exists { validationErrors = append(validationErrors, fmt.Errorf("cluster %q was not found for context %q", context.Cluster, contextName)) } if len(context.Namespace) != 0 { if len(validation.IsDNS1123Label(context.Namespace)) != 0 { validationErrors = append(validationErrors, fmt.Errorf("namespace %q for context %q does not conform to the kubernetes DNS_LABEL rules", context.Namespace, contextName)) } } return validationErrors }
[ "func", "validateContext", "(", "contextName", "string", ",", "context", "clientcmdapi", ".", "Context", ",", "config", "clientcmdapi", ".", "Config", ")", "[", "]", "error", "{", "validationErrors", ":=", "make", "(", "[", "]", "error", ",", "0", ")", "\n...
// validateContext looks for errors in the context. It is not transitive, so errors in the reference authInfo or cluster configs are not included in this return
[ "validateContext", "looks", "for", "errors", "in", "the", "context", ".", "It", "is", "not", "transitive", "so", "errors", "in", "the", "reference", "authInfo", "or", "cluster", "configs", "are", "not", "included", "in", "this", "return" ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/client-go/tools/clientcmd/validation.go#L272-L298
kubernetes/kubernetes
pkg/kubectl/cmd/delete/delete_flags.go
NewDeleteCommandFlags
func NewDeleteCommandFlags(usage string) *DeleteFlags { cascade := true gracePeriod := -1 // setup command defaults all := false allNamespaces := false force := false ignoreNotFound := false now := false output := "" labelSelector := "" fieldSelector := "" timeout := time.Duration(0) wait := true filenames := []string{} recursive := false kustomize := "" return &DeleteFlags{ // Not using helpers.go since it provides function to add '-k' for FileNameOptions, but not FileNameFlags FileNameFlags: &genericclioptions.FileNameFlags{Usage: usage, Filenames: &filenames, Kustomize: &kustomize, Recursive: &recursive}, LabelSelector: &labelSelector, FieldSelector: &fieldSelector, Cascade: &cascade, GracePeriod: &gracePeriod, All: &all, AllNamespaces: &allNamespaces, Force: &force, IgnoreNotFound: &ignoreNotFound, Now: &now, Timeout: &timeout, Wait: &wait, Output: &output, } }
go
func NewDeleteCommandFlags(usage string) *DeleteFlags { cascade := true gracePeriod := -1 // setup command defaults all := false allNamespaces := false force := false ignoreNotFound := false now := false output := "" labelSelector := "" fieldSelector := "" timeout := time.Duration(0) wait := true filenames := []string{} recursive := false kustomize := "" return &DeleteFlags{ // Not using helpers.go since it provides function to add '-k' for FileNameOptions, but not FileNameFlags FileNameFlags: &genericclioptions.FileNameFlags{Usage: usage, Filenames: &filenames, Kustomize: &kustomize, Recursive: &recursive}, LabelSelector: &labelSelector, FieldSelector: &fieldSelector, Cascade: &cascade, GracePeriod: &gracePeriod, All: &all, AllNamespaces: &allNamespaces, Force: &force, IgnoreNotFound: &ignoreNotFound, Now: &now, Timeout: &timeout, Wait: &wait, Output: &output, } }
[ "func", "NewDeleteCommandFlags", "(", "usage", "string", ")", "*", "DeleteFlags", "{", "cascade", ":=", "true", "\n", "gracePeriod", ":=", "-", "1", "\n\n", "// setup command defaults", "all", ":=", "false", "\n", "allNamespaces", ":=", "false", "\n", "force", ...
// NewDeleteCommandFlags provides default flags and values for use with the "delete" command
[ "NewDeleteCommandFlags", "provides", "default", "flags", "and", "values", "for", "use", "with", "the", "delete", "command" ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubectl/cmd/delete/delete_flags.go#L141-L179
kubernetes/kubernetes
pkg/kubectl/cmd/delete/delete_flags.go
NewDeleteFlags
func NewDeleteFlags(usage string) *DeleteFlags { cascade := true gracePeriod := -1 force := false timeout := time.Duration(0) wait := false filenames := []string{} kustomize := "" recursive := false return &DeleteFlags{ FileNameFlags: &genericclioptions.FileNameFlags{Usage: usage, Filenames: &filenames, Kustomize: &kustomize, Recursive: &recursive}, Cascade: &cascade, GracePeriod: &gracePeriod, // add non-defaults Force: &force, Timeout: &timeout, Wait: &wait, } }
go
func NewDeleteFlags(usage string) *DeleteFlags { cascade := true gracePeriod := -1 force := false timeout := time.Duration(0) wait := false filenames := []string{} kustomize := "" recursive := false return &DeleteFlags{ FileNameFlags: &genericclioptions.FileNameFlags{Usage: usage, Filenames: &filenames, Kustomize: &kustomize, Recursive: &recursive}, Cascade: &cascade, GracePeriod: &gracePeriod, // add non-defaults Force: &force, Timeout: &timeout, Wait: &wait, } }
[ "func", "NewDeleteFlags", "(", "usage", "string", ")", "*", "DeleteFlags", "{", "cascade", ":=", "true", "\n", "gracePeriod", ":=", "-", "1", "\n\n", "force", ":=", "false", "\n", "timeout", ":=", "time", ".", "Duration", "(", "0", ")", "\n", "wait", "...
// NewDeleteFlags provides default flags and values for use in commands outside of "delete"
[ "NewDeleteFlags", "provides", "default", "flags", "and", "values", "for", "use", "in", "commands", "outside", "of", "delete" ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/kubectl/cmd/delete/delete_flags.go#L182-L205
kubernetes/kubernetes
pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go
ensureExternalLoadBalancer
func (g *Cloud) ensureExternalLoadBalancer(clusterName string, clusterID string, apiService *v1.Service, existingFwdRule *compute.ForwardingRule, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) { if len(nodes) == 0 { return nil, fmt.Errorf("Cannot EnsureLoadBalancer() with no hosts") } hostNames := nodeNames(nodes) supportsNodesHealthCheck := supportsNodesHealthCheck(nodes) hosts, err := g.getInstancesByNames(hostNames) if err != nil { return nil, err } loadBalancerName := g.GetLoadBalancerName(context.TODO(), clusterName, apiService) requestedIP := apiService.Spec.LoadBalancerIP ports := apiService.Spec.Ports portStr := []string{} for _, p := range apiService.Spec.Ports { portStr = append(portStr, fmt.Sprintf("%s/%d", p.Protocol, p.Port)) } serviceName := types.NamespacedName{Namespace: apiService.Namespace, Name: apiService.Name} lbRefStr := fmt.Sprintf("%v(%v)", loadBalancerName, serviceName) klog.V(2).Infof("ensureExternalLoadBalancer(%s, %v, %v, %v, %v, %v)", lbRefStr, g.region, requestedIP, portStr, hostNames, apiService.Annotations) // Check the current and the desired network tiers. If they do not match, // tear down the existing resources with the wrong tier. netTier, err := g.getServiceNetworkTier(apiService) if err != nil { klog.Errorf("ensureExternalLoadBalancer(%s): Failed to get the desired network tier: %v.", lbRefStr, err) return nil, err } klog.V(4).Infof("ensureExternalLoadBalancer(%s): Desired network tier %q.", lbRefStr, netTier) if g.AlphaFeatureGate.Enabled(AlphaFeatureNetworkTiers) { g.deleteWrongNetworkTieredResources(loadBalancerName, lbRefStr, netTier) } // Check if the forwarding rule exists, and if so, what its IP is. fwdRuleExists, fwdRuleNeedsUpdate, fwdRuleIP, err := g.forwardingRuleNeedsUpdate(loadBalancerName, g.region, requestedIP, ports) if err != nil { return nil, err } if !fwdRuleExists { klog.V(2).Infof("ensureExternalLoadBalancer(%s): Forwarding rule %v doesn't exist.", lbRefStr, loadBalancerName) } // Make sure we know which IP address will be used and have properly reserved // it as static before moving forward with the rest of our operations. // // We use static IP addresses when updating a load balancer to ensure that we // can replace the load balancer's other components without changing the // address its service is reachable on. We do it this way rather than always // keeping the static IP around even though this is more complicated because // it makes it less likely that we'll run into quota issues. Only 7 static // IP addresses are allowed per region by default. // // We could let an IP be allocated for us when the forwarding rule is created, // but we need the IP to set up the firewall rule, and we want to keep the // forwarding rule creation as the last thing that needs to be done in this // function in order to maintain the invariant that "if the forwarding rule // exists, the LB has been fully created". ipAddressToUse := "" // Through this process we try to keep track of whether it is safe to // release the IP that was allocated. If the user specifically asked for // an IP, we assume they are managing it themselves. Otherwise, we will // release the IP in case of early-terminating failure or upon successful // creating of the LB. // TODO(#36535): boil this logic down into a set of component functions // and key the flag values off of errors returned. isUserOwnedIP := false // if this is set, we never release the IP isSafeToReleaseIP := false defer func() { if isUserOwnedIP { return } if isSafeToReleaseIP { if err := g.DeleteRegionAddress(loadBalancerName, g.region); err != nil && !isNotFound(err) { klog.Errorf("ensureExternalLoadBalancer(%s): Failed to release static IP %s in region %v: %v.", lbRefStr, ipAddressToUse, g.region, err) } else if isNotFound(err) { klog.V(2).Infof("ensureExternalLoadBalancer(%s): IP address %s is not reserved.", lbRefStr, ipAddressToUse) } else { klog.Infof("ensureExternalLoadBalancer(%s): Released static IP %s.", lbRefStr, ipAddressToUse) } } else { klog.Warningf("ensureExternalLoadBalancer(%s): Orphaning static IP %s in region %v: %v.", lbRefStr, ipAddressToUse, g.region, err) } }() if requestedIP != "" { // If user requests a specific IP address, verify first. No mutation to // the GCE resources will be performed in the verification process. isUserOwnedIP, err = verifyUserRequestedIP(g, g.region, requestedIP, fwdRuleIP, lbRefStr, netTier) if err != nil { return nil, err } ipAddressToUse = requestedIP } if !isUserOwnedIP { // If we are not using the user-owned IP, either promote the // emphemeral IP used by the fwd rule, or create a new static IP. ipAddr, existed, err := ensureStaticIP(g, loadBalancerName, serviceName.String(), g.region, fwdRuleIP, netTier) if err != nil { return nil, fmt.Errorf("failed to ensure a static IP for load balancer (%s): %v", lbRefStr, err) } klog.Infof("ensureExternalLoadBalancer(%s): Ensured IP address %s (tier: %s).", lbRefStr, ipAddr, netTier) // If the IP was not owned by the user, but it already existed, it // could indicate that the previous update cycle failed. We can use // this IP and try to run through the process again, but we should // not release the IP unless it is explicitly flagged as OK. isSafeToReleaseIP = !existed ipAddressToUse = ipAddr } // Deal with the firewall next. The reason we do this here rather than last // is because the forwarding rule is used as the indicator that the load // balancer is fully created - it's what getLoadBalancer checks for. // Check if user specified the allow source range sourceRanges, err := servicehelpers.GetLoadBalancerSourceRanges(apiService) if err != nil { return nil, err } firewallExists, firewallNeedsUpdate, err := g.firewallNeedsUpdate(loadBalancerName, serviceName.String(), g.region, ipAddressToUse, ports, sourceRanges) if err != nil { return nil, err } if firewallNeedsUpdate { desc := makeFirewallDescription(serviceName.String(), ipAddressToUse) // Unlike forwarding rules and target pools, firewalls can be updated // without needing to be deleted and recreated. if firewallExists { klog.Infof("ensureExternalLoadBalancer(%s): Updating firewall.", lbRefStr) if err := g.updateFirewall(apiService, MakeFirewallName(loadBalancerName), g.region, desc, sourceRanges, ports, hosts); err != nil { return nil, err } klog.Infof("ensureExternalLoadBalancer(%s): Updated firewall.", lbRefStr) } else { klog.Infof("ensureExternalLoadBalancer(%s): Creating firewall.", lbRefStr) if err := g.createFirewall(apiService, MakeFirewallName(loadBalancerName), g.region, desc, sourceRanges, ports, hosts); err != nil { return nil, err } klog.Infof("ensureExternalLoadBalancer(%s): Created firewall.", lbRefStr) } } tpExists, tpNeedsRecreation, err := g.targetPoolNeedsRecreation(loadBalancerName, g.region, apiService.Spec.SessionAffinity) if err != nil { return nil, err } if !tpExists { klog.Infof("ensureExternalLoadBalancer(%s): Target pool for service doesn't exist.", lbRefStr) } // Check which health check needs to create and which health check needs to delete. // Health check management is coupled with target pool operation to prevent leaking. var hcToCreate, hcToDelete *compute.HttpHealthCheck hcLocalTrafficExisting, err := g.GetHTTPHealthCheck(loadBalancerName) if err != nil && !isHTTPErrorCode(err, http.StatusNotFound) { return nil, fmt.Errorf("error checking HTTP health check for load balancer (%s): %v", lbRefStr, err) } if path, healthCheckNodePort := servicehelpers.GetServiceHealthCheckPathPort(apiService); path != "" { klog.V(4).Infof("ensureExternalLoadBalancer(%s): Service needs local traffic health checks on: %d%s.", lbRefStr, healthCheckNodePort, path) if hcLocalTrafficExisting == nil { // This logic exists to detect a transition for non-OnlyLocal to OnlyLocal service // turn on the tpNeedsRecreation flag to delete/recreate fwdrule/tpool updating the // target pool to use local traffic health check. klog.V(2).Infof("ensureExternalLoadBalancer(%s): Updating from nodes health checks to local traffic health checks.", lbRefStr) if supportsNodesHealthCheck { hcToDelete = makeHTTPHealthCheck(MakeNodesHealthCheckName(clusterID), GetNodesHealthCheckPath(), GetNodesHealthCheckPort()) } tpNeedsRecreation = true } hcToCreate = makeHTTPHealthCheck(loadBalancerName, path, healthCheckNodePort) } else { klog.V(4).Infof("ensureExternalLoadBalancer(%s): Service needs nodes health checks.", lbRefStr) if hcLocalTrafficExisting != nil { // This logic exists to detect a transition from OnlyLocal to non-OnlyLocal service // and turn on the tpNeedsRecreation flag to delete/recreate fwdrule/tpool updating the // target pool to use nodes health check. klog.V(2).Infof("ensureExternalLoadBalancer(%s): Updating from local traffic health checks to nodes health checks.", lbRefStr) hcToDelete = hcLocalTrafficExisting tpNeedsRecreation = true } if supportsNodesHealthCheck { hcToCreate = makeHTTPHealthCheck(MakeNodesHealthCheckName(clusterID), GetNodesHealthCheckPath(), GetNodesHealthCheckPort()) } } // Now we get to some slightly more interesting logic. // First, neither target pools nor forwarding rules can be updated in place - // they have to be deleted and recreated. // Second, forwarding rules are layered on top of target pools in that you // can't delete a target pool that's currently in use by a forwarding rule. // Thus, we have to tear down the forwarding rule if either it or the target // pool needs to be updated. if fwdRuleExists && (fwdRuleNeedsUpdate || tpNeedsRecreation) { // Begin critical section. If we have to delete the forwarding rule, // and something should fail before we recreate it, don't release the // IP. That way we can come back to it later. isSafeToReleaseIP = false if err := g.DeleteRegionForwardingRule(loadBalancerName, g.region); err != nil && !isNotFound(err) { return nil, fmt.Errorf("failed to delete existing forwarding rule for load balancer (%s) update: %v", lbRefStr, err) } klog.Infof("ensureExternalLoadBalancer(%s): Deleted forwarding rule.", lbRefStr) } if err := g.ensureTargetPoolAndHealthCheck(tpExists, tpNeedsRecreation, apiService, loadBalancerName, clusterID, ipAddressToUse, hosts, hcToCreate, hcToDelete); err != nil { return nil, err } if tpNeedsRecreation || fwdRuleNeedsUpdate { klog.Infof("ensureExternalLoadBalancer(%s): Creating forwarding rule, IP %s (tier: %s).", lbRefStr, ipAddressToUse, netTier) if err := createForwardingRule(g, loadBalancerName, serviceName.String(), g.region, ipAddressToUse, g.targetPoolURL(loadBalancerName), ports, netTier); err != nil { return nil, fmt.Errorf("failed to create forwarding rule for load balancer (%s): %v", lbRefStr, err) } // End critical section. It is safe to release the static IP (which // just demotes it to ephemeral) now that it is attached. In the case // of a user-requested IP, the "is user-owned" flag will be set, // preventing it from actually being released. isSafeToReleaseIP = true klog.Infof("ensureExternalLoadBalancer(%s): Created forwarding rule, IP %s.", lbRefStr, ipAddressToUse) } status := &v1.LoadBalancerStatus{} status.Ingress = []v1.LoadBalancerIngress{{IP: ipAddressToUse}} return status, nil }
go
func (g *Cloud) ensureExternalLoadBalancer(clusterName string, clusterID string, apiService *v1.Service, existingFwdRule *compute.ForwardingRule, nodes []*v1.Node) (*v1.LoadBalancerStatus, error) { if len(nodes) == 0 { return nil, fmt.Errorf("Cannot EnsureLoadBalancer() with no hosts") } hostNames := nodeNames(nodes) supportsNodesHealthCheck := supportsNodesHealthCheck(nodes) hosts, err := g.getInstancesByNames(hostNames) if err != nil { return nil, err } loadBalancerName := g.GetLoadBalancerName(context.TODO(), clusterName, apiService) requestedIP := apiService.Spec.LoadBalancerIP ports := apiService.Spec.Ports portStr := []string{} for _, p := range apiService.Spec.Ports { portStr = append(portStr, fmt.Sprintf("%s/%d", p.Protocol, p.Port)) } serviceName := types.NamespacedName{Namespace: apiService.Namespace, Name: apiService.Name} lbRefStr := fmt.Sprintf("%v(%v)", loadBalancerName, serviceName) klog.V(2).Infof("ensureExternalLoadBalancer(%s, %v, %v, %v, %v, %v)", lbRefStr, g.region, requestedIP, portStr, hostNames, apiService.Annotations) // Check the current and the desired network tiers. If they do not match, // tear down the existing resources with the wrong tier. netTier, err := g.getServiceNetworkTier(apiService) if err != nil { klog.Errorf("ensureExternalLoadBalancer(%s): Failed to get the desired network tier: %v.", lbRefStr, err) return nil, err } klog.V(4).Infof("ensureExternalLoadBalancer(%s): Desired network tier %q.", lbRefStr, netTier) if g.AlphaFeatureGate.Enabled(AlphaFeatureNetworkTiers) { g.deleteWrongNetworkTieredResources(loadBalancerName, lbRefStr, netTier) } // Check if the forwarding rule exists, and if so, what its IP is. fwdRuleExists, fwdRuleNeedsUpdate, fwdRuleIP, err := g.forwardingRuleNeedsUpdate(loadBalancerName, g.region, requestedIP, ports) if err != nil { return nil, err } if !fwdRuleExists { klog.V(2).Infof("ensureExternalLoadBalancer(%s): Forwarding rule %v doesn't exist.", lbRefStr, loadBalancerName) } // Make sure we know which IP address will be used and have properly reserved // it as static before moving forward with the rest of our operations. // // We use static IP addresses when updating a load balancer to ensure that we // can replace the load balancer's other components without changing the // address its service is reachable on. We do it this way rather than always // keeping the static IP around even though this is more complicated because // it makes it less likely that we'll run into quota issues. Only 7 static // IP addresses are allowed per region by default. // // We could let an IP be allocated for us when the forwarding rule is created, // but we need the IP to set up the firewall rule, and we want to keep the // forwarding rule creation as the last thing that needs to be done in this // function in order to maintain the invariant that "if the forwarding rule // exists, the LB has been fully created". ipAddressToUse := "" // Through this process we try to keep track of whether it is safe to // release the IP that was allocated. If the user specifically asked for // an IP, we assume they are managing it themselves. Otherwise, we will // release the IP in case of early-terminating failure or upon successful // creating of the LB. // TODO(#36535): boil this logic down into a set of component functions // and key the flag values off of errors returned. isUserOwnedIP := false // if this is set, we never release the IP isSafeToReleaseIP := false defer func() { if isUserOwnedIP { return } if isSafeToReleaseIP { if err := g.DeleteRegionAddress(loadBalancerName, g.region); err != nil && !isNotFound(err) { klog.Errorf("ensureExternalLoadBalancer(%s): Failed to release static IP %s in region %v: %v.", lbRefStr, ipAddressToUse, g.region, err) } else if isNotFound(err) { klog.V(2).Infof("ensureExternalLoadBalancer(%s): IP address %s is not reserved.", lbRefStr, ipAddressToUse) } else { klog.Infof("ensureExternalLoadBalancer(%s): Released static IP %s.", lbRefStr, ipAddressToUse) } } else { klog.Warningf("ensureExternalLoadBalancer(%s): Orphaning static IP %s in region %v: %v.", lbRefStr, ipAddressToUse, g.region, err) } }() if requestedIP != "" { // If user requests a specific IP address, verify first. No mutation to // the GCE resources will be performed in the verification process. isUserOwnedIP, err = verifyUserRequestedIP(g, g.region, requestedIP, fwdRuleIP, lbRefStr, netTier) if err != nil { return nil, err } ipAddressToUse = requestedIP } if !isUserOwnedIP { // If we are not using the user-owned IP, either promote the // emphemeral IP used by the fwd rule, or create a new static IP. ipAddr, existed, err := ensureStaticIP(g, loadBalancerName, serviceName.String(), g.region, fwdRuleIP, netTier) if err != nil { return nil, fmt.Errorf("failed to ensure a static IP for load balancer (%s): %v", lbRefStr, err) } klog.Infof("ensureExternalLoadBalancer(%s): Ensured IP address %s (tier: %s).", lbRefStr, ipAddr, netTier) // If the IP was not owned by the user, but it already existed, it // could indicate that the previous update cycle failed. We can use // this IP and try to run through the process again, but we should // not release the IP unless it is explicitly flagged as OK. isSafeToReleaseIP = !existed ipAddressToUse = ipAddr } // Deal with the firewall next. The reason we do this here rather than last // is because the forwarding rule is used as the indicator that the load // balancer is fully created - it's what getLoadBalancer checks for. // Check if user specified the allow source range sourceRanges, err := servicehelpers.GetLoadBalancerSourceRanges(apiService) if err != nil { return nil, err } firewallExists, firewallNeedsUpdate, err := g.firewallNeedsUpdate(loadBalancerName, serviceName.String(), g.region, ipAddressToUse, ports, sourceRanges) if err != nil { return nil, err } if firewallNeedsUpdate { desc := makeFirewallDescription(serviceName.String(), ipAddressToUse) // Unlike forwarding rules and target pools, firewalls can be updated // without needing to be deleted and recreated. if firewallExists { klog.Infof("ensureExternalLoadBalancer(%s): Updating firewall.", lbRefStr) if err := g.updateFirewall(apiService, MakeFirewallName(loadBalancerName), g.region, desc, sourceRanges, ports, hosts); err != nil { return nil, err } klog.Infof("ensureExternalLoadBalancer(%s): Updated firewall.", lbRefStr) } else { klog.Infof("ensureExternalLoadBalancer(%s): Creating firewall.", lbRefStr) if err := g.createFirewall(apiService, MakeFirewallName(loadBalancerName), g.region, desc, sourceRanges, ports, hosts); err != nil { return nil, err } klog.Infof("ensureExternalLoadBalancer(%s): Created firewall.", lbRefStr) } } tpExists, tpNeedsRecreation, err := g.targetPoolNeedsRecreation(loadBalancerName, g.region, apiService.Spec.SessionAffinity) if err != nil { return nil, err } if !tpExists { klog.Infof("ensureExternalLoadBalancer(%s): Target pool for service doesn't exist.", lbRefStr) } // Check which health check needs to create and which health check needs to delete. // Health check management is coupled with target pool operation to prevent leaking. var hcToCreate, hcToDelete *compute.HttpHealthCheck hcLocalTrafficExisting, err := g.GetHTTPHealthCheck(loadBalancerName) if err != nil && !isHTTPErrorCode(err, http.StatusNotFound) { return nil, fmt.Errorf("error checking HTTP health check for load balancer (%s): %v", lbRefStr, err) } if path, healthCheckNodePort := servicehelpers.GetServiceHealthCheckPathPort(apiService); path != "" { klog.V(4).Infof("ensureExternalLoadBalancer(%s): Service needs local traffic health checks on: %d%s.", lbRefStr, healthCheckNodePort, path) if hcLocalTrafficExisting == nil { // This logic exists to detect a transition for non-OnlyLocal to OnlyLocal service // turn on the tpNeedsRecreation flag to delete/recreate fwdrule/tpool updating the // target pool to use local traffic health check. klog.V(2).Infof("ensureExternalLoadBalancer(%s): Updating from nodes health checks to local traffic health checks.", lbRefStr) if supportsNodesHealthCheck { hcToDelete = makeHTTPHealthCheck(MakeNodesHealthCheckName(clusterID), GetNodesHealthCheckPath(), GetNodesHealthCheckPort()) } tpNeedsRecreation = true } hcToCreate = makeHTTPHealthCheck(loadBalancerName, path, healthCheckNodePort) } else { klog.V(4).Infof("ensureExternalLoadBalancer(%s): Service needs nodes health checks.", lbRefStr) if hcLocalTrafficExisting != nil { // This logic exists to detect a transition from OnlyLocal to non-OnlyLocal service // and turn on the tpNeedsRecreation flag to delete/recreate fwdrule/tpool updating the // target pool to use nodes health check. klog.V(2).Infof("ensureExternalLoadBalancer(%s): Updating from local traffic health checks to nodes health checks.", lbRefStr) hcToDelete = hcLocalTrafficExisting tpNeedsRecreation = true } if supportsNodesHealthCheck { hcToCreate = makeHTTPHealthCheck(MakeNodesHealthCheckName(clusterID), GetNodesHealthCheckPath(), GetNodesHealthCheckPort()) } } // Now we get to some slightly more interesting logic. // First, neither target pools nor forwarding rules can be updated in place - // they have to be deleted and recreated. // Second, forwarding rules are layered on top of target pools in that you // can't delete a target pool that's currently in use by a forwarding rule. // Thus, we have to tear down the forwarding rule if either it or the target // pool needs to be updated. if fwdRuleExists && (fwdRuleNeedsUpdate || tpNeedsRecreation) { // Begin critical section. If we have to delete the forwarding rule, // and something should fail before we recreate it, don't release the // IP. That way we can come back to it later. isSafeToReleaseIP = false if err := g.DeleteRegionForwardingRule(loadBalancerName, g.region); err != nil && !isNotFound(err) { return nil, fmt.Errorf("failed to delete existing forwarding rule for load balancer (%s) update: %v", lbRefStr, err) } klog.Infof("ensureExternalLoadBalancer(%s): Deleted forwarding rule.", lbRefStr) } if err := g.ensureTargetPoolAndHealthCheck(tpExists, tpNeedsRecreation, apiService, loadBalancerName, clusterID, ipAddressToUse, hosts, hcToCreate, hcToDelete); err != nil { return nil, err } if tpNeedsRecreation || fwdRuleNeedsUpdate { klog.Infof("ensureExternalLoadBalancer(%s): Creating forwarding rule, IP %s (tier: %s).", lbRefStr, ipAddressToUse, netTier) if err := createForwardingRule(g, loadBalancerName, serviceName.String(), g.region, ipAddressToUse, g.targetPoolURL(loadBalancerName), ports, netTier); err != nil { return nil, fmt.Errorf("failed to create forwarding rule for load balancer (%s): %v", lbRefStr, err) } // End critical section. It is safe to release the static IP (which // just demotes it to ephemeral) now that it is attached. In the case // of a user-requested IP, the "is user-owned" flag will be set, // preventing it from actually being released. isSafeToReleaseIP = true klog.Infof("ensureExternalLoadBalancer(%s): Created forwarding rule, IP %s.", lbRefStr, ipAddressToUse) } status := &v1.LoadBalancerStatus{} status.Ingress = []v1.LoadBalancerIngress{{IP: ipAddressToUse}} return status, nil }
[ "func", "(", "g", "*", "Cloud", ")", "ensureExternalLoadBalancer", "(", "clusterName", "string", ",", "clusterID", "string", ",", "apiService", "*", "v1", ".", "Service", ",", "existingFwdRule", "*", "compute", ".", "ForwardingRule", ",", "nodes", "[", "]", ...
// ensureExternalLoadBalancer is the external implementation of LoadBalancer.EnsureLoadBalancer. // Our load balancers in GCE consist of four separate GCE resources - a static // IP address, a firewall rule, a target pool, and a forwarding rule. This // function has to manage all of them. // // Due to an interesting series of design decisions, this handles both creating // new load balancers and updating existing load balancers, recognizing when // each is needed.
[ "ensureExternalLoadBalancer", "is", "the", "external", "implementation", "of", "LoadBalancer", ".", "EnsureLoadBalancer", ".", "Our", "load", "balancers", "in", "GCE", "consist", "of", "four", "separate", "GCE", "resources", "-", "a", "static", "IP", "address", "a...
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go#L47-L275
kubernetes/kubernetes
pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go
updateExternalLoadBalancer
func (g *Cloud) updateExternalLoadBalancer(clusterName string, service *v1.Service, nodes []*v1.Node) error { hosts, err := g.getInstancesByNames(nodeNames(nodes)) if err != nil { return err } loadBalancerName := g.GetLoadBalancerName(context.TODO(), clusterName, service) return g.updateTargetPool(loadBalancerName, hosts) }
go
func (g *Cloud) updateExternalLoadBalancer(clusterName string, service *v1.Service, nodes []*v1.Node) error { hosts, err := g.getInstancesByNames(nodeNames(nodes)) if err != nil { return err } loadBalancerName := g.GetLoadBalancerName(context.TODO(), clusterName, service) return g.updateTargetPool(loadBalancerName, hosts) }
[ "func", "(", "g", "*", "Cloud", ")", "updateExternalLoadBalancer", "(", "clusterName", "string", ",", "service", "*", "v1", ".", "Service", ",", "nodes", "[", "]", "*", "v1", ".", "Node", ")", "error", "{", "hosts", ",", "err", ":=", "g", ".", "getIn...
// updateExternalLoadBalancer is the external implementation of LoadBalancer.UpdateLoadBalancer.
[ "updateExternalLoadBalancer", "is", "the", "external", "implementation", "of", "LoadBalancer", ".", "UpdateLoadBalancer", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go#L278-L286
kubernetes/kubernetes
pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go
ensureExternalLoadBalancerDeleted
func (g *Cloud) ensureExternalLoadBalancerDeleted(clusterName, clusterID string, service *v1.Service) error { loadBalancerName := g.GetLoadBalancerName(context.TODO(), clusterName, service) serviceName := types.NamespacedName{Namespace: service.Namespace, Name: service.Name} lbRefStr := fmt.Sprintf("%v(%v)", loadBalancerName, serviceName) var hcNames []string if path, _ := servicehelpers.GetServiceHealthCheckPathPort(service); path != "" { hcToDelete, err := g.GetHTTPHealthCheck(loadBalancerName) if err != nil && !isHTTPErrorCode(err, http.StatusNotFound) { klog.Infof("ensureExternalLoadBalancerDeleted(%s): Failed to retrieve health check:%v.", lbRefStr, err) return err } // If we got 'StatusNotFound' LB was already deleted and it's safe to ignore. if err == nil { hcNames = append(hcNames, hcToDelete.Name) } } else { // EnsureLoadBalancerDeleted() could be triggered by changing service from // LoadBalancer type to others. In this case we have no idea whether it was // using local traffic health check or nodes health check. Attempt to delete // both to prevent leaking. hcNames = append(hcNames, loadBalancerName) hcNames = append(hcNames, MakeNodesHealthCheckName(clusterID)) } errs := utilerrors.AggregateGoroutines( func() error { klog.Infof("ensureExternalLoadBalancerDeleted(%s): Deleting firewall rule.", lbRefStr) fwName := MakeFirewallName(loadBalancerName) err := ignoreNotFound(g.DeleteFirewall(fwName)) if isForbidden(err) && g.OnXPN() { klog.V(4).Infof("ensureExternalLoadBalancerDeleted(%s): Do not have permission to delete firewall rule %v (on XPN). Raising event.", lbRefStr, fwName) g.raiseFirewallChangeNeededEvent(service, FirewallToGCloudDeleteCmd(fwName, g.NetworkProjectID())) return nil } return err }, // Even though we don't hold on to static IPs for load balancers, it's // possible that EnsureLoadBalancer left one around in a failed // creation/update attempt, so make sure we clean it up here just in case. func() error { klog.Infof("ensureExternalLoadBalancerDeleted(%s): Deleting IP address.", lbRefStr) return ignoreNotFound(g.DeleteRegionAddress(loadBalancerName, g.region)) }, func() error { klog.Infof("ensureExternalLoadBalancerDeleted(%s): Deleting forwarding rule.", lbRefStr) // The forwarding rule must be deleted before either the target pool can, // unfortunately, so we have to do these two serially. if err := ignoreNotFound(g.DeleteRegionForwardingRule(loadBalancerName, g.region)); err != nil { return err } klog.Infof("ensureExternalLoadBalancerDeleted(%s): Deleting target pool.", lbRefStr) if err := g.DeleteExternalTargetPoolAndChecks(service, loadBalancerName, g.region, clusterID, hcNames...); err != nil { return err } return nil }, ) if errs != nil { return utilerrors.Flatten(errs) } return nil }
go
func (g *Cloud) ensureExternalLoadBalancerDeleted(clusterName, clusterID string, service *v1.Service) error { loadBalancerName := g.GetLoadBalancerName(context.TODO(), clusterName, service) serviceName := types.NamespacedName{Namespace: service.Namespace, Name: service.Name} lbRefStr := fmt.Sprintf("%v(%v)", loadBalancerName, serviceName) var hcNames []string if path, _ := servicehelpers.GetServiceHealthCheckPathPort(service); path != "" { hcToDelete, err := g.GetHTTPHealthCheck(loadBalancerName) if err != nil && !isHTTPErrorCode(err, http.StatusNotFound) { klog.Infof("ensureExternalLoadBalancerDeleted(%s): Failed to retrieve health check:%v.", lbRefStr, err) return err } // If we got 'StatusNotFound' LB was already deleted and it's safe to ignore. if err == nil { hcNames = append(hcNames, hcToDelete.Name) } } else { // EnsureLoadBalancerDeleted() could be triggered by changing service from // LoadBalancer type to others. In this case we have no idea whether it was // using local traffic health check or nodes health check. Attempt to delete // both to prevent leaking. hcNames = append(hcNames, loadBalancerName) hcNames = append(hcNames, MakeNodesHealthCheckName(clusterID)) } errs := utilerrors.AggregateGoroutines( func() error { klog.Infof("ensureExternalLoadBalancerDeleted(%s): Deleting firewall rule.", lbRefStr) fwName := MakeFirewallName(loadBalancerName) err := ignoreNotFound(g.DeleteFirewall(fwName)) if isForbidden(err) && g.OnXPN() { klog.V(4).Infof("ensureExternalLoadBalancerDeleted(%s): Do not have permission to delete firewall rule %v (on XPN). Raising event.", lbRefStr, fwName) g.raiseFirewallChangeNeededEvent(service, FirewallToGCloudDeleteCmd(fwName, g.NetworkProjectID())) return nil } return err }, // Even though we don't hold on to static IPs for load balancers, it's // possible that EnsureLoadBalancer left one around in a failed // creation/update attempt, so make sure we clean it up here just in case. func() error { klog.Infof("ensureExternalLoadBalancerDeleted(%s): Deleting IP address.", lbRefStr) return ignoreNotFound(g.DeleteRegionAddress(loadBalancerName, g.region)) }, func() error { klog.Infof("ensureExternalLoadBalancerDeleted(%s): Deleting forwarding rule.", lbRefStr) // The forwarding rule must be deleted before either the target pool can, // unfortunately, so we have to do these two serially. if err := ignoreNotFound(g.DeleteRegionForwardingRule(loadBalancerName, g.region)); err != nil { return err } klog.Infof("ensureExternalLoadBalancerDeleted(%s): Deleting target pool.", lbRefStr) if err := g.DeleteExternalTargetPoolAndChecks(service, loadBalancerName, g.region, clusterID, hcNames...); err != nil { return err } return nil }, ) if errs != nil { return utilerrors.Flatten(errs) } return nil }
[ "func", "(", "g", "*", "Cloud", ")", "ensureExternalLoadBalancerDeleted", "(", "clusterName", ",", "clusterID", "string", ",", "service", "*", "v1", ".", "Service", ")", "error", "{", "loadBalancerName", ":=", "g", ".", "GetLoadBalancerName", "(", "context", "...
// ensureExternalLoadBalancerDeleted is the external implementation of LoadBalancer.EnsureLoadBalancerDeleted
[ "ensureExternalLoadBalancerDeleted", "is", "the", "external", "implementation", "of", "LoadBalancer", ".", "EnsureLoadBalancerDeleted" ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go#L289-L351
kubernetes/kubernetes
pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go
DeleteExternalTargetPoolAndChecks
func (g *Cloud) DeleteExternalTargetPoolAndChecks(service *v1.Service, name, region, clusterID string, hcNames ...string) error { serviceName := types.NamespacedName{Namespace: service.Namespace, Name: service.Name} lbRefStr := fmt.Sprintf("%v(%v)", name, serviceName) if err := g.DeleteTargetPool(name, region); err != nil && isHTTPErrorCode(err, http.StatusNotFound) { klog.Infof("DeleteExternalTargetPoolAndChecks(%v): Target pool already deleted. Continuing to delete other resources.", lbRefStr) } else if err != nil { klog.Warningf("DeleteExternalTargetPoolAndChecks(%v): Failed to delete target pool, got error %s.", lbRefStr, err.Error()) return err } // Deletion of health checks is allowed only after the TargetPool reference is deleted for _, hcName := range hcNames { if err := func() error { // Check whether it is nodes health check, which has different name from the load-balancer. isNodesHealthCheck := hcName != name if isNodesHealthCheck { // Lock to prevent deleting necessary nodes health check before it gets attached // to target pool. g.sharedResourceLock.Lock() defer g.sharedResourceLock.Unlock() } klog.Infof("DeleteExternalTargetPoolAndChecks(%v): Deleting health check %v.", lbRefStr, hcName) if err := g.DeleteHTTPHealthCheck(hcName); err != nil { // Delete nodes health checks will fail if any other target pool is using it. if isInUsedByError(err) { klog.V(4).Infof("DeleteExternalTargetPoolAndChecks(%v): Health check %v is in used: %v.", lbRefStr, hcName, err) return nil } else if !isHTTPErrorCode(err, http.StatusNotFound) { klog.Warningf("DeleteExternalTargetPoolAndChecks(%v): Failed to delete health check %v: %v.", lbRefStr, hcName, err) return err } // StatusNotFound could happen when: // - This is the first attempt but we pass in a healthcheck that is already deleted // to prevent leaking. // - This is the first attempt but user manually deleted the heathcheck. // - This is a retry and in previous round we failed to delete the healthcheck firewall // after deleted the healthcheck. // We continue to delete the healthcheck firewall to prevent leaking. klog.V(4).Infof("DeleteExternalTargetPoolAndChecks(%v): Health check %v is already deleted.", lbRefStr, hcName) } // If health check is deleted without error, it means no load-balancer is using it. // So we should delete the health check firewall as well. fwName := MakeHealthCheckFirewallName(clusterID, hcName, isNodesHealthCheck) klog.Infof("DeleteExternalTargetPoolAndChecks(%v): Deleting health check firewall %v.", lbRefStr, fwName) if err := ignoreNotFound(g.DeleteFirewall(fwName)); err != nil { if isForbidden(err) && g.OnXPN() { klog.V(4).Infof("DeleteExternalTargetPoolAndChecks(%v): Do not have permission to delete firewall rule %v (on XPN). Raising event.", lbRefStr, fwName) g.raiseFirewallChangeNeededEvent(service, FirewallToGCloudDeleteCmd(fwName, g.NetworkProjectID())) return nil } return err } return nil }(); err != nil { return err } } return nil }
go
func (g *Cloud) DeleteExternalTargetPoolAndChecks(service *v1.Service, name, region, clusterID string, hcNames ...string) error { serviceName := types.NamespacedName{Namespace: service.Namespace, Name: service.Name} lbRefStr := fmt.Sprintf("%v(%v)", name, serviceName) if err := g.DeleteTargetPool(name, region); err != nil && isHTTPErrorCode(err, http.StatusNotFound) { klog.Infof("DeleteExternalTargetPoolAndChecks(%v): Target pool already deleted. Continuing to delete other resources.", lbRefStr) } else if err != nil { klog.Warningf("DeleteExternalTargetPoolAndChecks(%v): Failed to delete target pool, got error %s.", lbRefStr, err.Error()) return err } // Deletion of health checks is allowed only after the TargetPool reference is deleted for _, hcName := range hcNames { if err := func() error { // Check whether it is nodes health check, which has different name from the load-balancer. isNodesHealthCheck := hcName != name if isNodesHealthCheck { // Lock to prevent deleting necessary nodes health check before it gets attached // to target pool. g.sharedResourceLock.Lock() defer g.sharedResourceLock.Unlock() } klog.Infof("DeleteExternalTargetPoolAndChecks(%v): Deleting health check %v.", lbRefStr, hcName) if err := g.DeleteHTTPHealthCheck(hcName); err != nil { // Delete nodes health checks will fail if any other target pool is using it. if isInUsedByError(err) { klog.V(4).Infof("DeleteExternalTargetPoolAndChecks(%v): Health check %v is in used: %v.", lbRefStr, hcName, err) return nil } else if !isHTTPErrorCode(err, http.StatusNotFound) { klog.Warningf("DeleteExternalTargetPoolAndChecks(%v): Failed to delete health check %v: %v.", lbRefStr, hcName, err) return err } // StatusNotFound could happen when: // - This is the first attempt but we pass in a healthcheck that is already deleted // to prevent leaking. // - This is the first attempt but user manually deleted the heathcheck. // - This is a retry and in previous round we failed to delete the healthcheck firewall // after deleted the healthcheck. // We continue to delete the healthcheck firewall to prevent leaking. klog.V(4).Infof("DeleteExternalTargetPoolAndChecks(%v): Health check %v is already deleted.", lbRefStr, hcName) } // If health check is deleted without error, it means no load-balancer is using it. // So we should delete the health check firewall as well. fwName := MakeHealthCheckFirewallName(clusterID, hcName, isNodesHealthCheck) klog.Infof("DeleteExternalTargetPoolAndChecks(%v): Deleting health check firewall %v.", lbRefStr, fwName) if err := ignoreNotFound(g.DeleteFirewall(fwName)); err != nil { if isForbidden(err) && g.OnXPN() { klog.V(4).Infof("DeleteExternalTargetPoolAndChecks(%v): Do not have permission to delete firewall rule %v (on XPN). Raising event.", lbRefStr, fwName) g.raiseFirewallChangeNeededEvent(service, FirewallToGCloudDeleteCmd(fwName, g.NetworkProjectID())) return nil } return err } return nil }(); err != nil { return err } } return nil }
[ "func", "(", "g", "*", "Cloud", ")", "DeleteExternalTargetPoolAndChecks", "(", "service", "*", "v1", ".", "Service", ",", "name", ",", "region", ",", "clusterID", "string", ",", "hcNames", "...", "string", ")", "error", "{", "serviceName", ":=", "types", "...
// DeleteExternalTargetPoolAndChecks Deletes an external load balancer pool and verifies the operation
[ "DeleteExternalTargetPoolAndChecks", "Deletes", "an", "external", "load", "balancer", "pool", "and", "verifies", "the", "operation" ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go#L354-L414
kubernetes/kubernetes
pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go
verifyUserRequestedIP
func verifyUserRequestedIP(s CloudAddressService, region, requestedIP, fwdRuleIP, lbRef string, desiredNetTier cloud.NetworkTier) (isUserOwnedIP bool, err error) { if requestedIP == "" { return false, nil } // If a specific IP address has been requested, we have to respect the // user's request and use that IP. If the forwarding rule was already using // a different IP, it will be harmlessly abandoned because it was only an // ephemeral IP (or it was a different static IP owned by the user, in which // case we shouldn't delete it anyway). existingAddress, err := s.GetRegionAddressByIP(region, requestedIP) if err != nil && !isNotFound(err) { klog.Errorf("verifyUserRequestedIP: failed to check whether the requested IP %q for LB %s exists: %v", requestedIP, lbRef, err) return false, err } if err == nil { // The requested IP is a static IP, owned and managed by the user. // Check if the network tier of the static IP matches the desired // network tier. netTierStr, err := s.getNetworkTierFromAddress(existingAddress.Name, region) if err != nil { return false, fmt.Errorf("failed to check the network tier of the IP %q: %v", requestedIP, err) } netTier := cloud.NetworkTierGCEValueToType(netTierStr) if netTier != desiredNetTier { klog.Errorf("verifyUserRequestedIP: requested static IP %q (name: %s) for LB %s has network tier %s, need %s.", requestedIP, existingAddress.Name, lbRef, netTier, desiredNetTier) return false, fmt.Errorf("requrested IP %q belongs to the %s network tier; expected %s", requestedIP, netTier, desiredNetTier) } klog.V(4).Infof("verifyUserRequestedIP: the requested static IP %q (name: %s, tier: %s) for LB %s exists.", requestedIP, existingAddress.Name, netTier, lbRef) return true, nil } if requestedIP == fwdRuleIP { // The requested IP is not a static IP, but is currently assigned // to this forwarding rule, so we can just use it. klog.V(4).Infof("verifyUserRequestedIP: the requested IP %q is not static, but is currently in use by for LB %s", requestedIP, lbRef) return false, nil } // The requested IP is not static and it is not assigned to the // current forwarding rule. It might be attached to a different // rule or it might not be part of this project at all. Either // way, we can't use it. klog.Errorf("verifyUserRequestedIP: requested IP %q for LB %s is neither static nor assigned to the LB", requestedIP, lbRef) return false, fmt.Errorf("requested ip %q is neither static nor assigned to the LB", requestedIP) }
go
func verifyUserRequestedIP(s CloudAddressService, region, requestedIP, fwdRuleIP, lbRef string, desiredNetTier cloud.NetworkTier) (isUserOwnedIP bool, err error) { if requestedIP == "" { return false, nil } // If a specific IP address has been requested, we have to respect the // user's request and use that IP. If the forwarding rule was already using // a different IP, it will be harmlessly abandoned because it was only an // ephemeral IP (or it was a different static IP owned by the user, in which // case we shouldn't delete it anyway). existingAddress, err := s.GetRegionAddressByIP(region, requestedIP) if err != nil && !isNotFound(err) { klog.Errorf("verifyUserRequestedIP: failed to check whether the requested IP %q for LB %s exists: %v", requestedIP, lbRef, err) return false, err } if err == nil { // The requested IP is a static IP, owned and managed by the user. // Check if the network tier of the static IP matches the desired // network tier. netTierStr, err := s.getNetworkTierFromAddress(existingAddress.Name, region) if err != nil { return false, fmt.Errorf("failed to check the network tier of the IP %q: %v", requestedIP, err) } netTier := cloud.NetworkTierGCEValueToType(netTierStr) if netTier != desiredNetTier { klog.Errorf("verifyUserRequestedIP: requested static IP %q (name: %s) for LB %s has network tier %s, need %s.", requestedIP, existingAddress.Name, lbRef, netTier, desiredNetTier) return false, fmt.Errorf("requrested IP %q belongs to the %s network tier; expected %s", requestedIP, netTier, desiredNetTier) } klog.V(4).Infof("verifyUserRequestedIP: the requested static IP %q (name: %s, tier: %s) for LB %s exists.", requestedIP, existingAddress.Name, netTier, lbRef) return true, nil } if requestedIP == fwdRuleIP { // The requested IP is not a static IP, but is currently assigned // to this forwarding rule, so we can just use it. klog.V(4).Infof("verifyUserRequestedIP: the requested IP %q is not static, but is currently in use by for LB %s", requestedIP, lbRef) return false, nil } // The requested IP is not static and it is not assigned to the // current forwarding rule. It might be attached to a different // rule or it might not be part of this project at all. Either // way, we can't use it. klog.Errorf("verifyUserRequestedIP: requested IP %q for LB %s is neither static nor assigned to the LB", requestedIP, lbRef) return false, fmt.Errorf("requested ip %q is neither static nor assigned to the LB", requestedIP) }
[ "func", "verifyUserRequestedIP", "(", "s", "CloudAddressService", ",", "region", ",", "requestedIP", ",", "fwdRuleIP", ",", "lbRef", "string", ",", "desiredNetTier", "cloud", ".", "NetworkTier", ")", "(", "isUserOwnedIP", "bool", ",", "err", "error", ")", "{", ...
// verifyUserRequestedIP checks the user-provided IP to see whether it meets // all the expected attributes for the load balancer, and returns an error if // the verification failed. It also returns a boolean to indicate whether the // IP address is considered owned by the user (i.e., not managed by the // controller.
[ "verifyUserRequestedIP", "checks", "the", "user", "-", "provided", "IP", "to", "see", "whether", "it", "meets", "all", "the", "expected", "attributes", "for", "the", "load", "balancer", "and", "returns", "an", "error", "if", "the", "verification", "failed", "....
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go#L421-L464
kubernetes/kubernetes
pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go
mergeHTTPHealthChecks
func mergeHTTPHealthChecks(hc, newHC *compute.HttpHealthCheck) *compute.HttpHealthCheck { if hc.CheckIntervalSec > newHC.CheckIntervalSec { newHC.CheckIntervalSec = hc.CheckIntervalSec } if hc.TimeoutSec > newHC.TimeoutSec { newHC.TimeoutSec = hc.TimeoutSec } if hc.UnhealthyThreshold > newHC.UnhealthyThreshold { newHC.UnhealthyThreshold = hc.UnhealthyThreshold } if hc.HealthyThreshold > newHC.HealthyThreshold { newHC.HealthyThreshold = hc.HealthyThreshold } return newHC }
go
func mergeHTTPHealthChecks(hc, newHC *compute.HttpHealthCheck) *compute.HttpHealthCheck { if hc.CheckIntervalSec > newHC.CheckIntervalSec { newHC.CheckIntervalSec = hc.CheckIntervalSec } if hc.TimeoutSec > newHC.TimeoutSec { newHC.TimeoutSec = hc.TimeoutSec } if hc.UnhealthyThreshold > newHC.UnhealthyThreshold { newHC.UnhealthyThreshold = hc.UnhealthyThreshold } if hc.HealthyThreshold > newHC.HealthyThreshold { newHC.HealthyThreshold = hc.HealthyThreshold } return newHC }
[ "func", "mergeHTTPHealthChecks", "(", "hc", ",", "newHC", "*", "compute", ".", "HttpHealthCheck", ")", "*", "compute", ".", "HttpHealthCheck", "{", "if", "hc", ".", "CheckIntervalSec", ">", "newHC", ".", "CheckIntervalSec", "{", "newHC", ".", "CheckIntervalSec",...
// mergeHTTPHealthChecks reconciles HttpHealthCheck configures to be no smaller // than the default values. // E.g. old health check interval is 2s, new default is 8. // The HC interval will be reconciled to 8 seconds. // If the existing health check is larger than the default interval, // the configuration will be kept.
[ "mergeHTTPHealthChecks", "reconciles", "HttpHealthCheck", "configures", "to", "be", "no", "smaller", "than", "the", "default", "values", ".", "E", ".", "g", ".", "old", "health", "check", "interval", "is", "2s", "new", "default", "is", "8", ".", "The", "HC",...
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go#L639-L653
kubernetes/kubernetes
pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go
needToUpdateHTTPHealthChecks
func needToUpdateHTTPHealthChecks(hc, newHC *compute.HttpHealthCheck) bool { changed := hc.Port != newHC.Port || hc.RequestPath != newHC.RequestPath || hc.Description != newHC.Description changed = changed || hc.CheckIntervalSec < newHC.CheckIntervalSec || hc.TimeoutSec < newHC.TimeoutSec changed = changed || hc.UnhealthyThreshold < newHC.UnhealthyThreshold || hc.HealthyThreshold < newHC.HealthyThreshold return changed }
go
func needToUpdateHTTPHealthChecks(hc, newHC *compute.HttpHealthCheck) bool { changed := hc.Port != newHC.Port || hc.RequestPath != newHC.RequestPath || hc.Description != newHC.Description changed = changed || hc.CheckIntervalSec < newHC.CheckIntervalSec || hc.TimeoutSec < newHC.TimeoutSec changed = changed || hc.UnhealthyThreshold < newHC.UnhealthyThreshold || hc.HealthyThreshold < newHC.HealthyThreshold return changed }
[ "func", "needToUpdateHTTPHealthChecks", "(", "hc", ",", "newHC", "*", "compute", ".", "HttpHealthCheck", ")", "bool", "{", "changed", ":=", "hc", ".", "Port", "!=", "newHC", ".", "Port", "||", "hc", ".", "RequestPath", "!=", "newHC", ".", "RequestPath", "|...
// needToUpdateHTTPHealthChecks checks whether the http healthcheck needs to be // updated.
[ "needToUpdateHTTPHealthChecks", "checks", "whether", "the", "http", "healthcheck", "needs", "to", "be", "updated", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go#L657-L662
kubernetes/kubernetes
pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go
forwardingRuleNeedsUpdate
func (g *Cloud) forwardingRuleNeedsUpdate(name, region string, loadBalancerIP string, ports []v1.ServicePort) (exists bool, needsUpdate bool, ipAddress string, err error) { fwd, err := g.GetRegionForwardingRule(name, region) if err != nil { if isHTTPErrorCode(err, http.StatusNotFound) { return false, true, "", nil } // Err on the side of caution in case of errors. Caller should notice the error and retry. // We never want to end up recreating resources because g api flaked. return true, false, "", fmt.Errorf("error getting load balancer's forwarding rule: %v", err) } // If the user asks for a specific static ip through the Service spec, // check that we're actually using it. // TODO: we report loadbalancer IP through status, so we want to verify if // that matches the forwarding rule as well. if loadBalancerIP != "" && loadBalancerIP != fwd.IPAddress { klog.Infof("LoadBalancer ip for forwarding rule %v was expected to be %v, but was actually %v", fwd.Name, fwd.IPAddress, loadBalancerIP) return true, true, fwd.IPAddress, nil } portRange, err := loadBalancerPortRange(ports) if err != nil { // Err on the side of caution in case of errors. Caller should notice the error and retry. // We never want to end up recreating resources because g api flaked. return true, false, "", err } if portRange != fwd.PortRange { klog.Infof("LoadBalancer port range for forwarding rule %v was expected to be %v, but was actually %v", fwd.Name, fwd.PortRange, portRange) return true, true, fwd.IPAddress, nil } // The service controller verified all the protocols match on the ports, just check the first one if string(ports[0].Protocol) != fwd.IPProtocol { klog.Infof("LoadBalancer protocol for forwarding rule %v was expected to be %v, but was actually %v", fwd.Name, fwd.IPProtocol, string(ports[0].Protocol)) return true, true, fwd.IPAddress, nil } return true, false, fwd.IPAddress, nil }
go
func (g *Cloud) forwardingRuleNeedsUpdate(name, region string, loadBalancerIP string, ports []v1.ServicePort) (exists bool, needsUpdate bool, ipAddress string, err error) { fwd, err := g.GetRegionForwardingRule(name, region) if err != nil { if isHTTPErrorCode(err, http.StatusNotFound) { return false, true, "", nil } // Err on the side of caution in case of errors. Caller should notice the error and retry. // We never want to end up recreating resources because g api flaked. return true, false, "", fmt.Errorf("error getting load balancer's forwarding rule: %v", err) } // If the user asks for a specific static ip through the Service spec, // check that we're actually using it. // TODO: we report loadbalancer IP through status, so we want to verify if // that matches the forwarding rule as well. if loadBalancerIP != "" && loadBalancerIP != fwd.IPAddress { klog.Infof("LoadBalancer ip for forwarding rule %v was expected to be %v, but was actually %v", fwd.Name, fwd.IPAddress, loadBalancerIP) return true, true, fwd.IPAddress, nil } portRange, err := loadBalancerPortRange(ports) if err != nil { // Err on the side of caution in case of errors. Caller should notice the error and retry. // We never want to end up recreating resources because g api flaked. return true, false, "", err } if portRange != fwd.PortRange { klog.Infof("LoadBalancer port range for forwarding rule %v was expected to be %v, but was actually %v", fwd.Name, fwd.PortRange, portRange) return true, true, fwd.IPAddress, nil } // The service controller verified all the protocols match on the ports, just check the first one if string(ports[0].Protocol) != fwd.IPProtocol { klog.Infof("LoadBalancer protocol for forwarding rule %v was expected to be %v, but was actually %v", fwd.Name, fwd.IPProtocol, string(ports[0].Protocol)) return true, true, fwd.IPAddress, nil } return true, false, fwd.IPAddress, nil }
[ "func", "(", "g", "*", "Cloud", ")", "forwardingRuleNeedsUpdate", "(", "name", ",", "region", "string", ",", "loadBalancerIP", "string", ",", "ports", "[", "]", "v1", ".", "ServicePort", ")", "(", "exists", "bool", ",", "needsUpdate", "bool", ",", "ipAddre...
// Passing nil for requested IP is perfectly fine - it just means that no specific // IP is being requested. // Returns whether the forwarding rule exists, whether it needs to be updated, // what its IP address is (if it exists), and any error we encountered.
[ "Passing", "nil", "for", "requested", "IP", "is", "perfectly", "fine", "-", "it", "just", "means", "that", "no", "specific", "IP", "is", "being", "requested", ".", "Returns", "whether", "the", "forwarding", "rule", "exists", "whether", "it", "needs", "to", ...
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go#L702-L737
kubernetes/kubernetes
pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go
targetPoolNeedsRecreation
func (g *Cloud) targetPoolNeedsRecreation(name, region string, affinityType v1.ServiceAffinity) (exists bool, needsRecreation bool, err error) { tp, err := g.GetTargetPool(name, region) if err != nil { if isHTTPErrorCode(err, http.StatusNotFound) { return false, true, nil } // Err on the side of caution in case of errors. Caller should notice the error and retry. // We never want to end up recreating resources because g api flaked. return true, false, fmt.Errorf("error getting load balancer's target pool: %v", err) } // TODO: If the user modifies their Service's session affinity, it *should* // reflect in the associated target pool. However, currently not setting the // session affinity on a target pool defaults it to the empty string while // not setting in on a Service defaults it to None. There is a lack of // documentation around the default setting for the target pool, so if we // find it's the undocumented empty string, don't blindly recreate the // target pool (which results in downtime). Fix this when we have formally // defined the defaults on either side. if tp.SessionAffinity != "" && translateAffinityType(affinityType) != tp.SessionAffinity { klog.Infof("LoadBalancer target pool %v changed affinity from %v to %v", name, tp.SessionAffinity, affinityType) return true, true, nil } return true, false, nil }
go
func (g *Cloud) targetPoolNeedsRecreation(name, region string, affinityType v1.ServiceAffinity) (exists bool, needsRecreation bool, err error) { tp, err := g.GetTargetPool(name, region) if err != nil { if isHTTPErrorCode(err, http.StatusNotFound) { return false, true, nil } // Err on the side of caution in case of errors. Caller should notice the error and retry. // We never want to end up recreating resources because g api flaked. return true, false, fmt.Errorf("error getting load balancer's target pool: %v", err) } // TODO: If the user modifies their Service's session affinity, it *should* // reflect in the associated target pool. However, currently not setting the // session affinity on a target pool defaults it to the empty string while // not setting in on a Service defaults it to None. There is a lack of // documentation around the default setting for the target pool, so if we // find it's the undocumented empty string, don't blindly recreate the // target pool (which results in downtime). Fix this when we have formally // defined the defaults on either side. if tp.SessionAffinity != "" && translateAffinityType(affinityType) != tp.SessionAffinity { klog.Infof("LoadBalancer target pool %v changed affinity from %v to %v", name, tp.SessionAffinity, affinityType) return true, true, nil } return true, false, nil }
[ "func", "(", "g", "*", "Cloud", ")", "targetPoolNeedsRecreation", "(", "name", ",", "region", "string", ",", "affinityType", "v1", ".", "ServiceAffinity", ")", "(", "exists", "bool", ",", "needsRecreation", "bool", ",", "err", "error", ")", "{", "tp", ",",...
// Doesn't check whether the hosts have changed, since host updating is handled // separately.
[ "Doesn", "t", "check", "whether", "the", "hosts", "have", "changed", "since", "host", "updating", "is", "handled", "separately", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go#L741-L764
kubernetes/kubernetes
pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go
deleteFWDRuleWithWrongTier
func deleteFWDRuleWithWrongTier(s CloudForwardingRuleService, region, name, logPrefix string, desiredNetTier cloud.NetworkTier) error { tierStr, err := s.getNetworkTierFromForwardingRule(name, region) if isNotFound(err) { return nil } else if err != nil { return err } existingTier := cloud.NetworkTierGCEValueToType(tierStr) if existingTier == desiredNetTier { return nil } klog.V(2).Infof("%s: Network tiers do not match; existing forwarding rule: %q, desired: %q. Deleting the forwarding rule", logPrefix, existingTier, desiredNetTier) err = s.DeleteRegionForwardingRule(name, region) return ignoreNotFound(err) }
go
func deleteFWDRuleWithWrongTier(s CloudForwardingRuleService, region, name, logPrefix string, desiredNetTier cloud.NetworkTier) error { tierStr, err := s.getNetworkTierFromForwardingRule(name, region) if isNotFound(err) { return nil } else if err != nil { return err } existingTier := cloud.NetworkTierGCEValueToType(tierStr) if existingTier == desiredNetTier { return nil } klog.V(2).Infof("%s: Network tiers do not match; existing forwarding rule: %q, desired: %q. Deleting the forwarding rule", logPrefix, existingTier, desiredNetTier) err = s.DeleteRegionForwardingRule(name, region) return ignoreNotFound(err) }
[ "func", "deleteFWDRuleWithWrongTier", "(", "s", "CloudForwardingRuleService", ",", "region", ",", "name", ",", "logPrefix", "string", ",", "desiredNetTier", "cloud", ".", "NetworkTier", ")", "error", "{", "tierStr", ",", "err", ":=", "s", ".", "getNetworkTierFromF...
// deleteFWDRuleWithWrongTier checks the network tier of existing forwarding // rule and delete the rule if the tier does not matched the desired tier.
[ "deleteFWDRuleWithWrongTier", "checks", "the", "network", "tier", "of", "existing", "forwarding", "rule", "and", "delete", "the", "rule", "if", "the", "tier", "does", "not", "matched", "the", "desired", "tier", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go#L1083-L1098
kubernetes/kubernetes
pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go
deleteAddressWithWrongTier
func deleteAddressWithWrongTier(s CloudAddressService, region, name, logPrefix string, desiredNetTier cloud.NetworkTier) error { // We only check the IP address matching the reserved name that the // controller assigned to the LB. We make the assumption that an address of // such name is owned by the controller and is safe to release. Whether an // IP is owned by the user is not clearly defined in the current code, and // this assumption may not match some of the existing logic in the code. // However, this is okay since network tiering is still Alpha and will be // properly gated. // TODO(#51665): Re-evaluate the "ownership" of the IP address to ensure // we don't release IP unintentionally. tierStr, err := s.getNetworkTierFromAddress(name, region) if isNotFound(err) { return nil } else if err != nil { return err } existingTier := cloud.NetworkTierGCEValueToType(tierStr) if existingTier == desiredNetTier { return nil } klog.V(2).Infof("%s: Network tiers do not match; existing address: %q, desired: %q. Deleting the address", logPrefix, existingTier, desiredNetTier) err = s.DeleteRegionAddress(name, region) return ignoreNotFound(err) }
go
func deleteAddressWithWrongTier(s CloudAddressService, region, name, logPrefix string, desiredNetTier cloud.NetworkTier) error { // We only check the IP address matching the reserved name that the // controller assigned to the LB. We make the assumption that an address of // such name is owned by the controller and is safe to release. Whether an // IP is owned by the user is not clearly defined in the current code, and // this assumption may not match some of the existing logic in the code. // However, this is okay since network tiering is still Alpha and will be // properly gated. // TODO(#51665): Re-evaluate the "ownership" of the IP address to ensure // we don't release IP unintentionally. tierStr, err := s.getNetworkTierFromAddress(name, region) if isNotFound(err) { return nil } else if err != nil { return err } existingTier := cloud.NetworkTierGCEValueToType(tierStr) if existingTier == desiredNetTier { return nil } klog.V(2).Infof("%s: Network tiers do not match; existing address: %q, desired: %q. Deleting the address", logPrefix, existingTier, desiredNetTier) err = s.DeleteRegionAddress(name, region) return ignoreNotFound(err) }
[ "func", "deleteAddressWithWrongTier", "(", "s", "CloudAddressService", ",", "region", ",", "name", ",", "logPrefix", "string", ",", "desiredNetTier", "cloud", ".", "NetworkTier", ")", "error", "{", "// We only check the IP address matching the reserved name that the", "// c...
// deleteAddressWithWrongTier checks the network tier of existing address // and delete the address if the tier does not matched the desired tier.
[ "deleteAddressWithWrongTier", "checks", "the", "network", "tier", "of", "existing", "address", "and", "delete", "the", "address", "if", "the", "tier", "does", "not", "matched", "the", "desired", "tier", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/cloudprovider/providers/gce/gce_loadbalancer_external.go#L1102-L1126
kubernetes/kubernetes
pkg/volume/rbd/disk_manager.go
diskSetUp
func diskSetUp(manager diskManager, b rbdMounter, volPath string, mounter mount.Interface, fsGroup *int64) error { globalPDPath := manager.MakeGlobalPDName(*b.rbd) notMnt, err := mounter.IsLikelyNotMountPoint(globalPDPath) if err != nil && !os.IsNotExist(err) { klog.Errorf("cannot validate mountpoint: %s", globalPDPath) return err } if notMnt { return fmt.Errorf("no device is mounted at %s", globalPDPath) } notMnt, err = mounter.IsLikelyNotMountPoint(volPath) if err != nil && !os.IsNotExist(err) { klog.Errorf("cannot validate mountpoint: %s", volPath) return err } if !notMnt { return nil } if err := os.MkdirAll(volPath, 0750); err != nil { klog.Errorf("failed to mkdir:%s", volPath) return err } // Perform a bind mount to the full path to allow duplicate mounts of the same disk. options := []string{"bind"} if (&b).GetAttributes().ReadOnly { options = append(options, "ro") } mountOptions := util.JoinMountOptions(b.mountOptions, options) err = mounter.Mount(globalPDPath, volPath, "", mountOptions) if err != nil { klog.Errorf("failed to bind mount:%s", globalPDPath) return err } klog.V(3).Infof("rbd: successfully bind mount %s to %s with options %v", globalPDPath, volPath, mountOptions) if !b.ReadOnly { volume.SetVolumeOwnership(&b, fsGroup) } return nil }
go
func diskSetUp(manager diskManager, b rbdMounter, volPath string, mounter mount.Interface, fsGroup *int64) error { globalPDPath := manager.MakeGlobalPDName(*b.rbd) notMnt, err := mounter.IsLikelyNotMountPoint(globalPDPath) if err != nil && !os.IsNotExist(err) { klog.Errorf("cannot validate mountpoint: %s", globalPDPath) return err } if notMnt { return fmt.Errorf("no device is mounted at %s", globalPDPath) } notMnt, err = mounter.IsLikelyNotMountPoint(volPath) if err != nil && !os.IsNotExist(err) { klog.Errorf("cannot validate mountpoint: %s", volPath) return err } if !notMnt { return nil } if err := os.MkdirAll(volPath, 0750); err != nil { klog.Errorf("failed to mkdir:%s", volPath) return err } // Perform a bind mount to the full path to allow duplicate mounts of the same disk. options := []string{"bind"} if (&b).GetAttributes().ReadOnly { options = append(options, "ro") } mountOptions := util.JoinMountOptions(b.mountOptions, options) err = mounter.Mount(globalPDPath, volPath, "", mountOptions) if err != nil { klog.Errorf("failed to bind mount:%s", globalPDPath) return err } klog.V(3).Infof("rbd: successfully bind mount %s to %s with options %v", globalPDPath, volPath, mountOptions) if !b.ReadOnly { volume.SetVolumeOwnership(&b, fsGroup) } return nil }
[ "func", "diskSetUp", "(", "manager", "diskManager", ",", "b", "rbdMounter", ",", "volPath", "string", ",", "mounter", "mount", ".", "Interface", ",", "fsGroup", "*", "int64", ")", "error", "{", "globalPDPath", ":=", "manager", ".", "MakeGlobalPDName", "(", "...
// utility to mount a disk based filesystem
[ "utility", "to", "mount", "a", "disk", "based", "filesystem" ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/volume/rbd/disk_manager.go#L60-L102
kubernetes/kubernetes
pkg/volume/rbd/disk_manager.go
diskTearDown
func diskTearDown(manager diskManager, c rbdUnmounter, volPath string, mounter mount.Interface) error { notMnt, err := mounter.IsLikelyNotMountPoint(volPath) if err != nil && !os.IsNotExist(err) { klog.Errorf("cannot validate mountpoint: %s", volPath) return err } if notMnt { klog.V(3).Infof("volume path %s is not a mountpoint, deleting", volPath) return os.Remove(volPath) } // Unmount the bind-mount inside this pod. if err := mounter.Unmount(volPath); err != nil { klog.Errorf("failed to umount %s", volPath) return err } notMnt, mntErr := mounter.IsLikelyNotMountPoint(volPath) if mntErr != nil && !os.IsNotExist(mntErr) { klog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr) return mntErr } if notMnt { if err := os.Remove(volPath); err != nil { klog.V(2).Info("Error removing mountpoint ", volPath, ": ", err) return err } } return nil }
go
func diskTearDown(manager diskManager, c rbdUnmounter, volPath string, mounter mount.Interface) error { notMnt, err := mounter.IsLikelyNotMountPoint(volPath) if err != nil && !os.IsNotExist(err) { klog.Errorf("cannot validate mountpoint: %s", volPath) return err } if notMnt { klog.V(3).Infof("volume path %s is not a mountpoint, deleting", volPath) return os.Remove(volPath) } // Unmount the bind-mount inside this pod. if err := mounter.Unmount(volPath); err != nil { klog.Errorf("failed to umount %s", volPath) return err } notMnt, mntErr := mounter.IsLikelyNotMountPoint(volPath) if mntErr != nil && !os.IsNotExist(mntErr) { klog.Errorf("IsLikelyNotMountPoint check failed: %v", mntErr) return mntErr } if notMnt { if err := os.Remove(volPath); err != nil { klog.V(2).Info("Error removing mountpoint ", volPath, ": ", err) return err } } return nil }
[ "func", "diskTearDown", "(", "manager", "diskManager", ",", "c", "rbdUnmounter", ",", "volPath", "string", ",", "mounter", "mount", ".", "Interface", ")", "error", "{", "notMnt", ",", "err", ":=", "mounter", ".", "IsLikelyNotMountPoint", "(", "volPath", ")", ...
// utility to tear down a disk based filesystem
[ "utility", "to", "tear", "down", "a", "disk", "based", "filesystem" ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/volume/rbd/disk_manager.go#L105-L134
kubernetes/kubernetes
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/rules/rules.go
Matches
func (r *Matcher) Matches() bool { return r.scope() && r.operation() && r.group() && r.version() && r.resource() }
go
func (r *Matcher) Matches() bool { return r.scope() && r.operation() && r.group() && r.version() && r.resource() }
[ "func", "(", "r", "*", "Matcher", ")", "Matches", "(", ")", "bool", "{", "return", "r", ".", "scope", "(", ")", "&&", "r", ".", "operation", "(", ")", "&&", "r", ".", "group", "(", ")", "&&", "r", ".", "version", "(", ")", "&&", "r", ".", "...
// Matches returns if the Attr matches the Rule.
[ "Matches", "returns", "if", "the", "Attr", "matches", "the", "Rule", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/rules/rules.go#L35-L41
kubernetes/kubernetes
staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/rules/rules.go
IsWebhookConfigurationResource
func IsWebhookConfigurationResource(attr admission.Attributes) bool { gvk := attr.GetKind() if gvk.Group == "admissionregistration.k8s.io" { if gvk.Kind == "ValidatingWebhookConfiguration" || gvk.Kind == "MutatingWebhookConfiguration" { return true } } return false }
go
func IsWebhookConfigurationResource(attr admission.Attributes) bool { gvk := attr.GetKind() if gvk.Group == "admissionregistration.k8s.io" { if gvk.Kind == "ValidatingWebhookConfiguration" || gvk.Kind == "MutatingWebhookConfiguration" { return true } } return false }
[ "func", "IsWebhookConfigurationResource", "(", "attr", "admission", ".", "Attributes", ")", "bool", "{", "gvk", ":=", "attr", ".", "GetKind", "(", ")", "\n", "if", "gvk", ".", "Group", "==", "\"", "\"", "{", "if", "gvk", ".", "Kind", "==", "\"", "\"", ...
// IsWebhookConfigurationResource determines if an admission.Attributes object is describing // the admission of a ValidatingWebhookConfiguration or a MutatingWebhookConfiguration
[ "IsWebhookConfigurationResource", "determines", "if", "an", "admission", ".", "Attributes", "object", "is", "describing", "the", "admission", "of", "a", "ValidatingWebhookConfiguration", "or", "a", "MutatingWebhookConfiguration" ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/rules/rules.go#L121-L129
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopy
func (in *MutatingWebhookConfiguration) DeepCopy() *MutatingWebhookConfiguration { if in == nil { return nil } out := new(MutatingWebhookConfiguration) in.DeepCopyInto(out) return out }
go
func (in *MutatingWebhookConfiguration) DeepCopy() *MutatingWebhookConfiguration { if in == nil { return nil } out := new(MutatingWebhookConfiguration) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "MutatingWebhookConfiguration", ")", "DeepCopy", "(", ")", "*", "MutatingWebhookConfiguration", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "MutatingWebhookConfiguration", ")", "\n", "...
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MutatingWebhookConfiguration.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "MutatingWebhookConfiguration", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L44-L51
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopyObject
func (in *MutatingWebhookConfiguration) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } return nil }
go
func (in *MutatingWebhookConfiguration) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } return nil }
[ "func", "(", "in", "*", "MutatingWebhookConfiguration", ")", "DeepCopyObject", "(", ")", "runtime", ".", "Object", "{", "if", "c", ":=", "in", ".", "DeepCopy", "(", ")", ";", "c", "!=", "nil", "{", "return", "c", "\n", "}", "\n", "return", "nil", "\n...
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
[ "DeepCopyObject", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "runtime", ".", "Object", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L54-L59
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopyInto
func (in *MutatingWebhookConfigurationList) DeepCopyInto(out *MutatingWebhookConfigurationList) { *out = *in out.TypeMeta = in.TypeMeta out.ListMeta = in.ListMeta if in.Items != nil { in, out := &in.Items, &out.Items *out = make([]MutatingWebhookConfiguration, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } return }
go
func (in *MutatingWebhookConfigurationList) DeepCopyInto(out *MutatingWebhookConfigurationList) { *out = *in out.TypeMeta = in.TypeMeta out.ListMeta = in.ListMeta if in.Items != nil { in, out := &in.Items, &out.Items *out = make([]MutatingWebhookConfiguration, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } return }
[ "func", "(", "in", "*", "MutatingWebhookConfigurationList", ")", "DeepCopyInto", "(", "out", "*", "MutatingWebhookConfigurationList", ")", "{", "*", "out", "=", "*", "in", "\n", "out", ".", "TypeMeta", "=", "in", ".", "TypeMeta", "\n", "out", ".", "ListMeta"...
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
[ "DeepCopyInto", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "writing", "into", "out", ".", "in", "must", "be", "non", "-", "nil", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L62-L74
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopy
func (in *MutatingWebhookConfigurationList) DeepCopy() *MutatingWebhookConfigurationList { if in == nil { return nil } out := new(MutatingWebhookConfigurationList) in.DeepCopyInto(out) return out }
go
func (in *MutatingWebhookConfigurationList) DeepCopy() *MutatingWebhookConfigurationList { if in == nil { return nil } out := new(MutatingWebhookConfigurationList) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "MutatingWebhookConfigurationList", ")", "DeepCopy", "(", ")", "*", "MutatingWebhookConfigurationList", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "MutatingWebhookConfigurationList", ")",...
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MutatingWebhookConfigurationList.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "MutatingWebhookConfigurationList", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L77-L84
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopyObject
func (in *MutatingWebhookConfigurationList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } return nil }
go
func (in *MutatingWebhookConfigurationList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } return nil }
[ "func", "(", "in", "*", "MutatingWebhookConfigurationList", ")", "DeepCopyObject", "(", ")", "runtime", ".", "Object", "{", "if", "c", ":=", "in", ".", "DeepCopy", "(", ")", ";", "c", "!=", "nil", "{", "return", "c", "\n", "}", "\n", "return", "nil", ...
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
[ "DeepCopyObject", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "runtime", ".", "Object", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L87-L92
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopyInto
func (in *Rule) DeepCopyInto(out *Rule) { *out = *in if in.APIGroups != nil { in, out := &in.APIGroups, &out.APIGroups *out = make([]string, len(*in)) copy(*out, *in) } if in.APIVersions != nil { in, out := &in.APIVersions, &out.APIVersions *out = make([]string, len(*in)) copy(*out, *in) } if in.Resources != nil { in, out := &in.Resources, &out.Resources *out = make([]string, len(*in)) copy(*out, *in) } if in.Scope != nil { in, out := &in.Scope, &out.Scope *out = new(ScopeType) **out = **in } return }
go
func (in *Rule) DeepCopyInto(out *Rule) { *out = *in if in.APIGroups != nil { in, out := &in.APIGroups, &out.APIGroups *out = make([]string, len(*in)) copy(*out, *in) } if in.APIVersions != nil { in, out := &in.APIVersions, &out.APIVersions *out = make([]string, len(*in)) copy(*out, *in) } if in.Resources != nil { in, out := &in.Resources, &out.Resources *out = make([]string, len(*in)) copy(*out, *in) } if in.Scope != nil { in, out := &in.Scope, &out.Scope *out = new(ScopeType) **out = **in } return }
[ "func", "(", "in", "*", "Rule", ")", "DeepCopyInto", "(", "out", "*", "Rule", ")", "{", "*", "out", "=", "*", "in", "\n", "if", "in", ".", "APIGroups", "!=", "nil", "{", "in", ",", "out", ":=", "&", "in", ".", "APIGroups", ",", "&", "out", "....
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
[ "DeepCopyInto", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "writing", "into", "out", ".", "in", "must", "be", "non", "-", "nil", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L95-L118
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopy
func (in *Rule) DeepCopy() *Rule { if in == nil { return nil } out := new(Rule) in.DeepCopyInto(out) return out }
go
func (in *Rule) DeepCopy() *Rule { if in == nil { return nil } out := new(Rule) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "Rule", ")", "DeepCopy", "(", ")", "*", "Rule", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "Rule", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", "return",...
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Rule.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "Rule", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L121-L128
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopyInto
func (in *RuleWithOperations) DeepCopyInto(out *RuleWithOperations) { *out = *in if in.Operations != nil { in, out := &in.Operations, &out.Operations *out = make([]OperationType, len(*in)) copy(*out, *in) } in.Rule.DeepCopyInto(&out.Rule) return }
go
func (in *RuleWithOperations) DeepCopyInto(out *RuleWithOperations) { *out = *in if in.Operations != nil { in, out := &in.Operations, &out.Operations *out = make([]OperationType, len(*in)) copy(*out, *in) } in.Rule.DeepCopyInto(&out.Rule) return }
[ "func", "(", "in", "*", "RuleWithOperations", ")", "DeepCopyInto", "(", "out", "*", "RuleWithOperations", ")", "{", "*", "out", "=", "*", "in", "\n", "if", "in", ".", "Operations", "!=", "nil", "{", "in", ",", "out", ":=", "&", "in", ".", "Operations...
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
[ "DeepCopyInto", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "writing", "into", "out", ".", "in", "must", "be", "non", "-", "nil", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L131-L140
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopy
func (in *RuleWithOperations) DeepCopy() *RuleWithOperations { if in == nil { return nil } out := new(RuleWithOperations) in.DeepCopyInto(out) return out }
go
func (in *RuleWithOperations) DeepCopy() *RuleWithOperations { if in == nil { return nil } out := new(RuleWithOperations) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "RuleWithOperations", ")", "DeepCopy", "(", ")", "*", "RuleWithOperations", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "RuleWithOperations", ")", "\n", "in", ".", "DeepCopyInto", ...
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuleWithOperations.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "RuleWithOperations", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L143-L150
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopyInto
func (in *ServiceReference) DeepCopyInto(out *ServiceReference) { *out = *in if in.Path != nil { in, out := &in.Path, &out.Path *out = new(string) **out = **in } return }
go
func (in *ServiceReference) DeepCopyInto(out *ServiceReference) { *out = *in if in.Path != nil { in, out := &in.Path, &out.Path *out = new(string) **out = **in } return }
[ "func", "(", "in", "*", "ServiceReference", ")", "DeepCopyInto", "(", "out", "*", "ServiceReference", ")", "{", "*", "out", "=", "*", "in", "\n", "if", "in", ".", "Path", "!=", "nil", "{", "in", ",", "out", ":=", "&", "in", ".", "Path", ",", "&",...
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
[ "DeepCopyInto", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "writing", "into", "out", ".", "in", "must", "be", "non", "-", "nil", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L153-L161
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopy
func (in *ServiceReference) DeepCopy() *ServiceReference { if in == nil { return nil } out := new(ServiceReference) in.DeepCopyInto(out) return out }
go
func (in *ServiceReference) DeepCopy() *ServiceReference { if in == nil { return nil } out := new(ServiceReference) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "ServiceReference", ")", "DeepCopy", "(", ")", "*", "ServiceReference", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "ServiceReference", ")", "\n", "in", ".", "DeepCopyInto", "(",...
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceReference.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "ServiceReference", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L164-L171
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopyInto
func (in *ValidatingWebhookConfiguration) DeepCopyInto(out *ValidatingWebhookConfiguration) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) if in.Webhooks != nil { in, out := &in.Webhooks, &out.Webhooks *out = make([]Webhook, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } return }
go
func (in *ValidatingWebhookConfiguration) DeepCopyInto(out *ValidatingWebhookConfiguration) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) if in.Webhooks != nil { in, out := &in.Webhooks, &out.Webhooks *out = make([]Webhook, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } return }
[ "func", "(", "in", "*", "ValidatingWebhookConfiguration", ")", "DeepCopyInto", "(", "out", "*", "ValidatingWebhookConfiguration", ")", "{", "*", "out", "=", "*", "in", "\n", "out", ".", "TypeMeta", "=", "in", ".", "TypeMeta", "\n", "in", ".", "ObjectMeta", ...
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
[ "DeepCopyInto", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "writing", "into", "out", ".", "in", "must", "be", "non", "-", "nil", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L174-L186
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopy
func (in *ValidatingWebhookConfiguration) DeepCopy() *ValidatingWebhookConfiguration { if in == nil { return nil } out := new(ValidatingWebhookConfiguration) in.DeepCopyInto(out) return out }
go
func (in *ValidatingWebhookConfiguration) DeepCopy() *ValidatingWebhookConfiguration { if in == nil { return nil } out := new(ValidatingWebhookConfiguration) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "ValidatingWebhookConfiguration", ")", "DeepCopy", "(", ")", "*", "ValidatingWebhookConfiguration", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "ValidatingWebhookConfiguration", ")", "\n...
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ValidatingWebhookConfiguration.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "ValidatingWebhookConfiguration", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L189-L196
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopyObject
func (in *ValidatingWebhookConfiguration) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } return nil }
go
func (in *ValidatingWebhookConfiguration) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } return nil }
[ "func", "(", "in", "*", "ValidatingWebhookConfiguration", ")", "DeepCopyObject", "(", ")", "runtime", ".", "Object", "{", "if", "c", ":=", "in", ".", "DeepCopy", "(", ")", ";", "c", "!=", "nil", "{", "return", "c", "\n", "}", "\n", "return", "nil", "...
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
[ "DeepCopyObject", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "runtime", ".", "Object", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L199-L204
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopyInto
func (in *ValidatingWebhookConfigurationList) DeepCopyInto(out *ValidatingWebhookConfigurationList) { *out = *in out.TypeMeta = in.TypeMeta out.ListMeta = in.ListMeta if in.Items != nil { in, out := &in.Items, &out.Items *out = make([]ValidatingWebhookConfiguration, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } return }
go
func (in *ValidatingWebhookConfigurationList) DeepCopyInto(out *ValidatingWebhookConfigurationList) { *out = *in out.TypeMeta = in.TypeMeta out.ListMeta = in.ListMeta if in.Items != nil { in, out := &in.Items, &out.Items *out = make([]ValidatingWebhookConfiguration, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } return }
[ "func", "(", "in", "*", "ValidatingWebhookConfigurationList", ")", "DeepCopyInto", "(", "out", "*", "ValidatingWebhookConfigurationList", ")", "{", "*", "out", "=", "*", "in", "\n", "out", ".", "TypeMeta", "=", "in", ".", "TypeMeta", "\n", "out", ".", "ListM...
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
[ "DeepCopyInto", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "writing", "into", "out", ".", "in", "must", "be", "non", "-", "nil", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L207-L219
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopy
func (in *ValidatingWebhookConfigurationList) DeepCopy() *ValidatingWebhookConfigurationList { if in == nil { return nil } out := new(ValidatingWebhookConfigurationList) in.DeepCopyInto(out) return out }
go
func (in *ValidatingWebhookConfigurationList) DeepCopy() *ValidatingWebhookConfigurationList { if in == nil { return nil } out := new(ValidatingWebhookConfigurationList) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "ValidatingWebhookConfigurationList", ")", "DeepCopy", "(", ")", "*", "ValidatingWebhookConfigurationList", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "ValidatingWebhookConfigurationList", ...
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ValidatingWebhookConfigurationList.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "ValidatingWebhookConfigurationList", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L222-L229
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopyObject
func (in *ValidatingWebhookConfigurationList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } return nil }
go
func (in *ValidatingWebhookConfigurationList) DeepCopyObject() runtime.Object { if c := in.DeepCopy(); c != nil { return c } return nil }
[ "func", "(", "in", "*", "ValidatingWebhookConfigurationList", ")", "DeepCopyObject", "(", ")", "runtime", ".", "Object", "{", "if", "c", ":=", "in", ".", "DeepCopy", "(", ")", ";", "c", "!=", "nil", "{", "return", "c", "\n", "}", "\n", "return", "nil",...
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
[ "DeepCopyObject", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "runtime", ".", "Object", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L232-L237
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopyInto
func (in *Webhook) DeepCopyInto(out *Webhook) { *out = *in in.ClientConfig.DeepCopyInto(&out.ClientConfig) if in.Rules != nil { in, out := &in.Rules, &out.Rules *out = make([]RuleWithOperations, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } if in.FailurePolicy != nil { in, out := &in.FailurePolicy, &out.FailurePolicy *out = new(FailurePolicyType) **out = **in } if in.NamespaceSelector != nil { in, out := &in.NamespaceSelector, &out.NamespaceSelector *out = new(v1.LabelSelector) (*in).DeepCopyInto(*out) } if in.SideEffects != nil { in, out := &in.SideEffects, &out.SideEffects *out = new(SideEffectClass) **out = **in } if in.TimeoutSeconds != nil { in, out := &in.TimeoutSeconds, &out.TimeoutSeconds *out = new(int32) **out = **in } if in.AdmissionReviewVersions != nil { in, out := &in.AdmissionReviewVersions, &out.AdmissionReviewVersions *out = make([]string, len(*in)) copy(*out, *in) } return }
go
func (in *Webhook) DeepCopyInto(out *Webhook) { *out = *in in.ClientConfig.DeepCopyInto(&out.ClientConfig) if in.Rules != nil { in, out := &in.Rules, &out.Rules *out = make([]RuleWithOperations, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } if in.FailurePolicy != nil { in, out := &in.FailurePolicy, &out.FailurePolicy *out = new(FailurePolicyType) **out = **in } if in.NamespaceSelector != nil { in, out := &in.NamespaceSelector, &out.NamespaceSelector *out = new(v1.LabelSelector) (*in).DeepCopyInto(*out) } if in.SideEffects != nil { in, out := &in.SideEffects, &out.SideEffects *out = new(SideEffectClass) **out = **in } if in.TimeoutSeconds != nil { in, out := &in.TimeoutSeconds, &out.TimeoutSeconds *out = new(int32) **out = **in } if in.AdmissionReviewVersions != nil { in, out := &in.AdmissionReviewVersions, &out.AdmissionReviewVersions *out = make([]string, len(*in)) copy(*out, *in) } return }
[ "func", "(", "in", "*", "Webhook", ")", "DeepCopyInto", "(", "out", "*", "Webhook", ")", "{", "*", "out", "=", "*", "in", "\n", "in", ".", "ClientConfig", ".", "DeepCopyInto", "(", "&", "out", ".", "ClientConfig", ")", "\n", "if", "in", ".", "Rules...
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
[ "DeepCopyInto", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "writing", "into", "out", ".", "in", "must", "be", "non", "-", "nil", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L240-L276
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopy
func (in *Webhook) DeepCopy() *Webhook { if in == nil { return nil } out := new(Webhook) in.DeepCopyInto(out) return out }
go
func (in *Webhook) DeepCopy() *Webhook { if in == nil { return nil } out := new(Webhook) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "Webhook", ")", "DeepCopy", "(", ")", "*", "Webhook", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "Webhook", ")", "\n", "in", ".", "DeepCopyInto", "(", "out", ")", "\n", ...
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Webhook.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "Webhook", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L279-L286
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopyInto
func (in *WebhookClientConfig) DeepCopyInto(out *WebhookClientConfig) { *out = *in if in.URL != nil { in, out := &in.URL, &out.URL *out = new(string) **out = **in } if in.Service != nil { in, out := &in.Service, &out.Service *out = new(ServiceReference) (*in).DeepCopyInto(*out) } if in.CABundle != nil { in, out := &in.CABundle, &out.CABundle *out = make([]byte, len(*in)) copy(*out, *in) } return }
go
func (in *WebhookClientConfig) DeepCopyInto(out *WebhookClientConfig) { *out = *in if in.URL != nil { in, out := &in.URL, &out.URL *out = new(string) **out = **in } if in.Service != nil { in, out := &in.Service, &out.Service *out = new(ServiceReference) (*in).DeepCopyInto(*out) } if in.CABundle != nil { in, out := &in.CABundle, &out.CABundle *out = make([]byte, len(*in)) copy(*out, *in) } return }
[ "func", "(", "in", "*", "WebhookClientConfig", ")", "DeepCopyInto", "(", "out", "*", "WebhookClientConfig", ")", "{", "*", "out", "=", "*", "in", "\n", "if", "in", ".", "URL", "!=", "nil", "{", "in", ",", "out", ":=", "&", "in", ".", "URL", ",", ...
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
[ "DeepCopyInto", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "writing", "into", "out", ".", "in", "must", "be", "non", "-", "nil", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L289-L307
kubernetes/kubernetes
pkg/apis/admissionregistration/zz_generated.deepcopy.go
DeepCopy
func (in *WebhookClientConfig) DeepCopy() *WebhookClientConfig { if in == nil { return nil } out := new(WebhookClientConfig) in.DeepCopyInto(out) return out }
go
func (in *WebhookClientConfig) DeepCopy() *WebhookClientConfig { if in == nil { return nil } out := new(WebhookClientConfig) in.DeepCopyInto(out) return out }
[ "func", "(", "in", "*", "WebhookClientConfig", ")", "DeepCopy", "(", ")", "*", "WebhookClientConfig", "{", "if", "in", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "out", ":=", "new", "(", "WebhookClientConfig", ")", "\n", "in", ".", "DeepCopyInto...
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookClientConfig.
[ "DeepCopy", "is", "an", "autogenerated", "deepcopy", "function", "copying", "the", "receiver", "creating", "a", "new", "WebhookClientConfig", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/apis/admissionregistration/zz_generated.deepcopy.go#L310-L317
kubernetes/kubernetes
pkg/util/node/node.go
GetHostname
func GetHostname(hostnameOverride string) (string, error) { hostName := hostnameOverride if len(hostName) == 0 { nodeName, err := os.Hostname() if err != nil { return "", fmt.Errorf("couldn't determine hostname: %v", err) } hostName = nodeName } // Trim whitespaces first to avoid getting an empty hostname // For linux, the hostname is read from file /proc/sys/kernel/hostname directly hostName = strings.TrimSpace(hostName) if len(hostName) == 0 { return "", fmt.Errorf("empty hostname is invalid") } return strings.ToLower(hostName), nil }
go
func GetHostname(hostnameOverride string) (string, error) { hostName := hostnameOverride if len(hostName) == 0 { nodeName, err := os.Hostname() if err != nil { return "", fmt.Errorf("couldn't determine hostname: %v", err) } hostName = nodeName } // Trim whitespaces first to avoid getting an empty hostname // For linux, the hostname is read from file /proc/sys/kernel/hostname directly hostName = strings.TrimSpace(hostName) if len(hostName) == 0 { return "", fmt.Errorf("empty hostname is invalid") } return strings.ToLower(hostName), nil }
[ "func", "GetHostname", "(", "hostnameOverride", "string", ")", "(", "string", ",", "error", ")", "{", "hostName", ":=", "hostnameOverride", "\n", "if", "len", "(", "hostName", ")", "==", "0", "{", "nodeName", ",", "err", ":=", "os", ".", "Hostname", "(",...
// GetHostname returns OS's hostname if 'hostnameOverride' is empty; otherwise, return 'hostnameOverride'.
[ "GetHostname", "returns", "OS", "s", "hostname", "if", "hostnameOverride", "is", "empty", ";", "otherwise", "return", "hostnameOverride", "." ]
train
https://github.com/kubernetes/kubernetes/blob/6a8a3682919652ae668c389ed2f60efb770eed03/pkg/util/node/node.go#L47-L64
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
4