<commit_before>/*
Copyright 2017 Mirantis

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package criproxy

import (
	"context"
	"crypto/tls"
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"path"
	"strings"
	"time"

	"github.com/golang/glog"

	// TODO: switch to https://github.com/docker/docker/tree/master/client
	// Docker version used in k8s is too old for it
	dockerclient "github.com/docker/engine-api/client"
	dockertypes "github.com/docker/engine-api/types"
	dockercontainer "github.com/docker/engine-api/types/container"
	dockerfilters "github.com/docker/engine-api/types/filters"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/pkg/api/v1"
	"k8s.io/client-go/rest"
)

const (
	BusyboxImageName = "busybox:1.26.2"
	// TODO: use the same constant/setting in different parts of code
	proxyRuntimeEndpoint             = "/run/criproxy.sock"
	proxyStopTimeoutSeconds          = 5
	confFileMode                     = 0600
	confDirMode                      = 0700
	kubeletConfigPollInterval        = 1 * time.Second
	waitForCriProxySocketNumAttempts = 600
)

var kubeletSettingsForCriProxy map[string]interface{} = map[string]interface{}{
	"containerRuntime":      "remote",
	"remoteRuntimeEndpoint": proxyRuntimeEndpoint,
	"remoteImageEndpoint":   proxyRuntimeEndpoint,
	// NOTE: this setting is only needed by Virtlet to make flexvolume<commit_msg>Fix criproxy endpoint naming for bootstrap<commit_after>/*
Copyright 2017 Mirantis

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package criproxy

import (
	"context"
	"crypto/tls"
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"path"
	"strings"
	"time"

	"github.com/golang/glog"

	// TODO: switch to https://github.com/docker/docker/tree/master/client
	// Docker version used in k8s is too old for it
	dockerclient "github.com/docker/engine-api/client"
	dockertypes "github.com/docker/engine-api/types"
	dockercontainer "github.com/docker/engine-api/types/container"
	dockerfilters "github.com/docker/engine-api/types/filters"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/pkg/api/v1"
	"k8s.io/client-go/rest"
)

const (
	BusyboxImageName = "busybox:1.26.2"
	// TODO: use the same constant/setting in different parts of code
	proxyRuntimeEndpoint             = "unix:///run/criproxy.sock"
	proxyStopTimeoutSeconds          = 5
	confFileMode                     = 0600
	confDirMode                      = 0700
	kubeletConfigPollInterval        = 1 * time.Second
	waitForCriProxySocketNumAttempts = 600
)

var kubeletSettingsForCriProxy map[string]interface{} = map[string]interface{}{
	"containerRuntime":      "remote",
	"remoteRuntimeEndpoint": proxyRuntimeEndpoint,
	"remoteImageEndpoint":   proxyRuntimeEndpoint,
	// NOTE: this setting is only needed by Virtlet to make flexvolume
{'fraction_non_alphanumeric': 0.09932572614107883, 'fraction_numerical': 0.01711618257261411, 'mean_word_length': 3.7735148514851486, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4195250', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1214, 'n_words': 348}