| 1 | /* |
| 2 | Copyright 2016 The Kubernetes Authors. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package remotecommand |
| 18 | |
| 19 | import ( |
| 20 | "time" |
| 21 | |
| 22 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 23 | ) |
| 24 | |
| 25 | const ( |
| 26 | DefaultStreamCreationTimeout = 30 * time.Second |
| 27 | |
| 28 | // The SPDY subprotocol "channel.k8s.io" is used for remote command |
| 29 | // attachment/execution. This represents the initial unversioned subprotocol, |
| 30 | // which has the known bugs https://issues.k8s.io/13394 and |
| 31 | // https://issues.k8s.io/13395. |
| 32 | StreamProtocolV1Name = "channel.k8s.io" |
| 33 | |
| 34 | // The SPDY subprotocol "v2.channel.k8s.io" is used for remote command |
| 35 | // attachment/execution. It is the second version of the subprotocol and |
| 36 | // resolves the issues present in the first version. |
| 37 | StreamProtocolV2Name = "v2.channel.k8s.io" |
| 38 | |
| 39 | // The SPDY subprotocol "v3.channel.k8s.io" is used for remote command |
| 40 | // attachment/execution. It is the third version of the subprotocol and |
| 41 | // adds support for resizing container terminals. |
| 42 | StreamProtocolV3Name = "v3.channel.k8s.io" |
| 43 | |
| 44 | // The SPDY subprotocol "v4.channel.k8s.io" is used for remote command |
| 45 | // attachment/execution. It is the 4th version of the subprotocol and |
| 46 | // adds support for exit codes. |
| 47 | StreamProtocolV4Name = "v4.channel.k8s.io" |
| 48 | |
| 49 | // The subprotocol "v5.channel.k8s.io" is used for remote command |
| 50 | // attachment/execution. It is the 5th version of the subprotocol and |
| 51 | // adds support for a CLOSE signal. |
| 52 | StreamProtocolV5Name = "v5.channel.k8s.io" |
| 53 | |
| 54 | NonZeroExitCodeReason = metav1.StatusReason("NonZeroExitCode") |
| 55 | ExitCodeCauseType = metav1.CauseType("ExitCode") |
| 56 | |
| 57 | // RemoteCommand stream identifiers. The first three identifiers (for STDIN, |
| 58 | // STDOUT, STDERR) are the same as their file descriptors. |
| 59 | StreamStdIn = 0 |
| 60 | StreamStdOut = 1 |
| 61 | StreamStdErr = 2 |
| 62 | StreamErr = 3 |
| 63 | StreamResize = 4 |
| 64 | StreamClose = 255 |
| 65 | ) |
| 66 | |
| 67 | var SupportedStreamingProtocols = []string{StreamProtocolV4Name, StreamProtocolV3Name, StreamProtocolV2Name, StreamProtocolV1Name} |