From 2bc8f61d9a06f6dfcad8de067fb0732022e49e6a Mon Sep 17 00:00:00 2001 From: Zexi Date: Fri, 6 Sep 2019 17:38:48 +0800 Subject: [PATCH] add extra componets command --- Makefile | 2 +- go.mod | 3 +- go.sum | 4 + hack/migrate.sh | 162 +++ pkg/cmd/cmd.go | 1 + pkg/cmd/component.go | 21 + pkg/cmd/config.go | 2 +- pkg/phases/component/cloudmon.go | 88 ++ pkg/phases/component/cloudwatcher.go | 168 +++ pkg/phases/component/cmd.go | 118 +++ pkg/phases/component/common.go | 508 +++++++++ pkg/phases/component/component.go | 351 +++++++ pkg/phases/component/config.go | 87 ++ pkg/phases/component/init.go | 40 + pkg/phases/component/itsm.go | 182 ++++ pkg/phases/component/meter.go | 194 ++++ pkg/phases/component/meter_alert.go | 165 +++ pkg/phases/component/meter_cloud.go | 131 +++ pkg/phases/component/meter_service.go | 192 ++++ pkg/phases/component/meter_traffic.go | 189 ++++ pkg/phases/component/type.go | 245 +++++ pkg/phases/component/web.go | 93 ++ vendor/github.com/ugorji/go/codec/xml.go | 502 --------- vendor/golang.org/x/sys/unix/mkasm_darwin.go | 61 -- vendor/golang.org/x/sys/unix/mkpost.go | 122 --- vendor/golang.org/x/sys/unix/mksyscall.go | 407 -------- .../x/sys/unix/mksyscall_aix_ppc.go | 415 -------- .../x/sys/unix/mksyscall_aix_ppc64.go | 614 ----------- .../x/sys/unix/mksyscall_solaris.go | 335 ------ .../golang.org/x/sys/unix/mksysctl_openbsd.go | 355 ------- vendor/golang.org/x/sys/unix/mksysnum.go | 190 ---- vendor/golang.org/x/sys/unix/types_aix.go | 237 ----- vendor/golang.org/x/sys/unix/types_darwin.go | 283 ----- .../golang.org/x/sys/unix/types_dragonfly.go | 263 ----- vendor/golang.org/x/sys/unix/types_freebsd.go | 356 ------- vendor/golang.org/x/sys/unix/types_netbsd.go | 290 ------ vendor/golang.org/x/sys/unix/types_openbsd.go | 283 ----- vendor/golang.org/x/sys/unix/types_solaris.go | 266 ----- vendor/golang.org/x/text/unicode/bidi/gen.go | 133 --- .../x/text/unicode/bidi/gen_ranges.go | 57 - .../x/text/unicode/bidi/gen_trieval.go | 64 -- .../x/text/unicode/norm/maketables.go | 986 ------------------ .../golang.org/x/text/unicode/norm/triegen.go | 117 --- vendor/golang.org/x/text/width/gen.go | 115 -- vendor/golang.org/x/text/width/gen_common.go | 96 -- vendor/golang.org/x/text/width/gen_trieval.go | 34 - vendor/modules.txt | 648 ++++++------ .../pkg/apis/constants/constants.go | 32 +- .../pkg/apis/onecloud/v1alpha1/defaults.go | 59 +- .../pkg/apis/onecloud/v1alpha1/types.go | 46 +- .../v1alpha1/zz_generated.deepcopy.go | 30 +- .../pkg/controller/ingress_control.go | 89 ++ .../pkg/controller/onecloud_cert.go | 2 + .../pkg/controller/onecloud_control.go | 45 +- .../x/onecloud-operator/pkg/label/label.go | 95 ++ .../pkg/manager/component/apigateway.go | 130 +++ .../pkg/manager/component/climc.go | 87 ++ .../pkg/manager/component/component.go | 653 ++++++++++++ .../pkg/manager/component/configer.go | 29 + .../pkg/manager/component/glance.go | 108 ++ .../pkg/manager/component/influxdb.go | 146 +++ .../pkg/manager/component/keystone.go | 136 +++ .../pkg/manager/component/kubeserver.go | 104 ++ .../pkg/manager/component/logger.go | 78 ++ .../pkg/manager/component/region.go | 83 ++ .../pkg/manager/component/regiondns.go | 37 + .../pkg/manager/component/scheduler.go | 67 ++ .../pkg/manager/component/sync.go | 115 ++ .../pkg/manager/component/utils.go | 419 ++++++++ .../pkg/manager/component/web.go | 334 ++++++ .../pkg/manager/component/webconsole.go | 81 ++ .../pkg/manager/component/yunionagent.go | 116 +++ .../pkg/manager/component/yunionconf.go | 79 ++ .../onecloud-operator/pkg/manager/manager.go | 23 + .../onecloud-operator/pkg/util/mysql/mysql.go | 189 ++++ .../pkg/util/onecloud/onecloud.go | 6 + .../x/onecloud/pkg/logger/options/doc.go | 15 + .../x/onecloud/pkg/logger/options/options.go | 29 + .../x/onecloud/pkg/scheduler/options/doc.go | 15 + .../onecloud/pkg/scheduler/options/options.go | 109 ++ .../x/onecloud/pkg/webconsole/options/doc.go | 15 + .../pkg/webconsole/options/options.go | 32 + .../x/onecloud/pkg/yunionconf/options/doc.go | 15 + .../pkg/yunionconf/options/options.go | 26 + 84 files changed, 6915 insertions(+), 6934 deletions(-) create mode 100755 hack/migrate.sh create mode 100644 pkg/cmd/component.go create mode 100644 pkg/phases/component/cloudmon.go create mode 100644 pkg/phases/component/cloudwatcher.go create mode 100644 pkg/phases/component/cmd.go create mode 100644 pkg/phases/component/common.go create mode 100644 pkg/phases/component/component.go create mode 100644 pkg/phases/component/config.go create mode 100644 pkg/phases/component/init.go create mode 100644 pkg/phases/component/itsm.go create mode 100644 pkg/phases/component/meter.go create mode 100644 pkg/phases/component/meter_alert.go create mode 100644 pkg/phases/component/meter_cloud.go create mode 100644 pkg/phases/component/meter_service.go create mode 100644 pkg/phases/component/meter_traffic.go create mode 100644 pkg/phases/component/type.go create mode 100644 pkg/phases/component/web.go delete mode 100644 vendor/github.com/ugorji/go/codec/xml.go delete mode 100644 vendor/golang.org/x/sys/unix/mkasm_darwin.go delete mode 100644 vendor/golang.org/x/sys/unix/mkpost.go delete mode 100644 vendor/golang.org/x/sys/unix/mksyscall.go delete mode 100644 vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go delete mode 100644 vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.go delete mode 100644 vendor/golang.org/x/sys/unix/mksyscall_solaris.go delete mode 100644 vendor/golang.org/x/sys/unix/mksysctl_openbsd.go delete mode 100644 vendor/golang.org/x/sys/unix/mksysnum.go delete mode 100644 vendor/golang.org/x/sys/unix/types_aix.go delete mode 100644 vendor/golang.org/x/sys/unix/types_darwin.go delete mode 100644 vendor/golang.org/x/sys/unix/types_dragonfly.go delete mode 100644 vendor/golang.org/x/sys/unix/types_freebsd.go delete mode 100644 vendor/golang.org/x/sys/unix/types_netbsd.go delete mode 100644 vendor/golang.org/x/sys/unix/types_openbsd.go delete mode 100644 vendor/golang.org/x/sys/unix/types_solaris.go delete mode 100644 vendor/golang.org/x/text/unicode/bidi/gen.go delete mode 100644 vendor/golang.org/x/text/unicode/bidi/gen_ranges.go delete mode 100644 vendor/golang.org/x/text/unicode/bidi/gen_trieval.go delete mode 100644 vendor/golang.org/x/text/unicode/norm/maketables.go delete mode 100644 vendor/golang.org/x/text/unicode/norm/triegen.go delete mode 100644 vendor/golang.org/x/text/width/gen.go delete mode 100644 vendor/golang.org/x/text/width/gen_common.go delete mode 100644 vendor/golang.org/x/text/width/gen_trieval.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/controller/ingress_control.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/label/label.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/apigateway.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/climc.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/component.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/configer.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/glance.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/influxdb.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/keystone.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/kubeserver.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/logger.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/region.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/regiondns.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/scheduler.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/sync.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/utils.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/web.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/webconsole.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/yunionagent.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/component/yunionconf.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/manager/manager.go create mode 100644 vendor/yunion.io/x/onecloud-operator/pkg/util/mysql/mysql.go create mode 100644 vendor/yunion.io/x/onecloud/pkg/logger/options/doc.go create mode 100644 vendor/yunion.io/x/onecloud/pkg/logger/options/options.go create mode 100644 vendor/yunion.io/x/onecloud/pkg/scheduler/options/doc.go create mode 100644 vendor/yunion.io/x/onecloud/pkg/scheduler/options/options.go create mode 100644 vendor/yunion.io/x/onecloud/pkg/webconsole/options/doc.go create mode 100644 vendor/yunion.io/x/onecloud/pkg/webconsole/options/options.go create mode 100644 vendor/yunion.io/x/onecloud/pkg/yunionconf/options/doc.go create mode 100644 vendor/yunion.io/x/onecloud/pkg/yunionconf/options/options.go diff --git a/Makefile b/Makefile index 88b6c15b..d4568b06 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ export GO111MODULE:=on build: - go build -o ./_output/bin/ocadm cmd/main.go + go build -mod vendor -o ./_output/bin/ocadm cmd/main.go generate: ./hack/codegen.sh diff --git a/go.mod b/go.mod index 1c4a7106..9c1890ef 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.4.0 // indirect github.com/evanphx/json-patch v4.5.0+incompatible // indirect + github.com/ghodss/yaml v1.0.0 github.com/go-logr/logr v0.1.0 // indirect github.com/go-logr/zapr v0.1.1 // indirect github.com/go-sql-driver/mysql v1.4.1 @@ -38,7 +39,7 @@ require ( sigs.k8s.io/testing_frameworks v0.1.1 // indirect yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051 yunion.io/x/onecloud v0.0.0-20190725062408-c88eae5261a2 - yunion.io/x/onecloud-operator v0.0.1-alpha2 + yunion.io/x/onecloud-operator v0.0.1-alpha2.0.20190919062109-f48871684b03 yunion.io/x/pkg v0.0.0-20190628082551-f4033ba2ea30 ) diff --git a/go.sum b/go.sum index 294505ad..f55c6987 100644 --- a/go.sum +++ b/go.sum @@ -858,6 +858,10 @@ yunion.io/x/onecloud-operator v0.0.1-alpha1 h1:DXF5obHcgC/pCxgDtPMmMoN6kFB/ZUJA4 yunion.io/x/onecloud-operator v0.0.1-alpha1/go.mod h1:1Y0lBz6YecMrLPUHo80qOoy+oyRsYK4HwNCM1uvFJ5w= yunion.io/x/onecloud-operator v0.0.1-alpha2 h1:Ll/joHtzVESvTj02NEg2l3EXb+WBe0xoUQFIGilS3G4= yunion.io/x/onecloud-operator v0.0.1-alpha2/go.mod h1:bxo6Vuns1t08MRBy4OeQtlDKcg9ghO0znmNi3iYaXRk= +yunion.io/x/onecloud-operator v0.0.1-alpha2.0.20190911123136-955e28308bd6 h1:GUQVMRmzt7g65wyQOQict5xbad00kpKSvADsu54Ab6U= +yunion.io/x/onecloud-operator v0.0.1-alpha2.0.20190911123136-955e28308bd6/go.mod h1:bxo6Vuns1t08MRBy4OeQtlDKcg9ghO0znmNi3iYaXRk= +yunion.io/x/onecloud-operator v0.0.1-alpha2.0.20190919062109-f48871684b03 h1:igpPcvA6M2uW1NJQqJaGUwMXX4o12fvxmHNdaayQEaw= +yunion.io/x/onecloud-operator v0.0.1-alpha2.0.20190919062109-f48871684b03/go.mod h1:bxo6Vuns1t08MRBy4OeQtlDKcg9ghO0znmNi3iYaXRk= yunion.io/x/pkg v0.0.0-20190620104149-945c25821dbf h1:OsKC+2ghZHwp+Ztm/MwKlLKKRiE7QcPG8eTp0GmsHbg= yunion.io/x/pkg v0.0.0-20190620104149-945c25821dbf/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E= yunion.io/x/pkg v0.0.0-20190628082551-f4033ba2ea30 h1:6CkrwtX4xeYFqqpdWtQPAVqEnD3aEivPLOLzNKNPAB0= diff --git a/hack/migrate.sh b/hack/migrate.sh new file mode 100755 index 00000000..70eaecb7 --- /dev/null +++ b/hack/migrate.sh @@ -0,0 +1,162 @@ +#!/bin/bash + +set -e + +GLOBALRC_FILE=${GLOBALRC_FILE:-/opt/cloud/workspace/globalrc} +VARS_FILE=${VARS_FILE:-/opt/yunionsetup/vars} + +error_exit() { + echo "Error: $1" + exit 1 +} + +check_file_exists() { + local file=$1 + if [ ! -f "$file" ]; then + error_exit "file $file not exists" + fi +} + +new_cluster_yaml() { + local rc_file=$GLOBALRC_FILE + local vars_file=$VARS_FILE + + check_file_exists $rc_file + check_file_exists $vars_file + + source $rc_file + source $vars_file + + cat <> 17:10 every day +#jobs.cron_demoSchedule=0 10 17 * * ? +# 2-statDataProcess>> 17:10 every day +jobs.cron_statDataProcess=0 30 0 * * ? +# 3-synchronizeData config +jobs.synchronizeData.pagesize=2000 +## 1000 * 60 +jobs.synchronizeData.initialDelay=60000 +## 1000 * 60 * 4 +jobs.synchronizeData.fixedDelay=240000 +# 4-etlProcessData config +## 1000 * 60 * 2 +jobs.etlProcessData.initialDelay=120000 +## 1000 * 60 * 4 +jobs.etlProcessData.fixedDelay=240000 + +# >> hourly every day=(xx:01) +jobs.synchronize.netio.data=0 18 * * * ? + +# >> 01:01 every day=(xx:01) +jobs.process.netio.result=0 1 1 * * ? + +# 1 minutes after tomcat is running +jobs.usesumlog.initialDelay=60000 +# 10 minutes interval +jobs.usesumlog.fixedDelay=3600000 +# 80 minutes for each time +yunionyun.usesum.hourInterval=80m +# 6 hours the first time +yunionyun.usesum.firsttimeInterval=2h + +# >> 01:01 every day=(xx:01) +jobs.fetch.aliyun.priceinfo=0 30 0 * * ? +` +) + +var MeterComponent IComponent = NewMeter() + +type Meter struct { + *BaseComponent +} + +func NewMeter() *Meter { + m := new(Meter) + m.BaseComponent = NewBaseComponent(onecloud.ComponentType("meter"), m) + return m +} + +func (c Meter) NewService(oc *onecloud.OnecloudCluster) *corev1.Service { + return NewNodePortService(c.GetComponentType(), oc, MeterPort) +} + +func (c Meter) NewDeployment(oc *onecloud.OnecloudCluster) (*apps.Deployment, error) { + cf := func(volMounts []corev1.VolumeMount) []corev1.Container { + volMounts = SetJavaConfigVolumeMounts(volMounts) + return []corev1.Container{ + { + Name: "meter", + //Image: GetImage(oc, c.GetComponentType(), ""), + Image: GetJavaAppImage(oc, ""), + Env: []corev1.EnvVar{ + { + Name: JAVA_APP_JAR, + Value: "meter.jar", + }, + }, + WorkingDir: JAVA_APP_WORKING_DIR, + VolumeMounts: volMounts, + }, + } + } + cType := c.GetComponentType() + deploy, err := NewDefaultDeployment(cType, oc, NewVolumeHelper(oc, cType), cf) + if err != nil { + return nil, err + } + podSpec := &deploy.Spec.Template.Spec + podSpec.Volumes = SetJavaConfigVolumes(podSpec.Volumes) + return deploy, nil +} + +func (c Meter) NewConfigMap(oc *onecloud.OnecloudCluster, cCfg *OnecloudComponentsConfig) (*corev1.ConfigMap, error) { + cfg := cCfg.MeterConfig + config := NewJavaDBConfig(oc, cfg) + return NewConfigMapByTemplate(c.GetComponentType(), oc, MeterConfigTemplate, config) +} + +func (c Meter) NewCloudUser(cfg *OnecloudComponentsConfig) *onecloud.CloudUser { + return &cfg.MeterConfig.CloudUser +} + +func (c Meter) NewDBConfig(cfg *OnecloudComponentsConfig) *onecloud.DBConfig { + return &cfg.MeterConfig.DB +} + +func (c Meter) NewCloudEndpoint() *CloudEndpoint { + return NewHTTPCloudEndpoint(ServiceNameMeter, ServiceTypeMeter, MeterPort, "api/v1") +} diff --git a/pkg/phases/component/meter_alert.go b/pkg/phases/component/meter_alert.go new file mode 100644 index 00000000..a6b48822 --- /dev/null +++ b/pkg/phases/component/meter_alert.go @@ -0,0 +1,165 @@ +package component + +import ( + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + onecloud "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" +) + +const ( + MeterAlertTemplate = ` +# ---------------------------------------- +# CORE PROPERTIES +# ---------------------------------------- +debug=false +trace=false + +# LOGGING +logging.level.com.yunion.meteralert=INFO + +# OUTPUT +spring.output.ansi.enabled=ALWAYS + +# ---------------------------------------- +# WEB PROPERTIES +# ---------------------------------------- + +# EMBEDDED SERVER CONFIGURATION (ServerProperties) +server.port={{.Port}} +server.session-timeout=180 +server.context-path=/ +server.tomcat.basedir=. +server.tomcat.uri-encoding=UTF-8 +server.tomcat.accesslog.enabled=true +server.tomcat.accesslog.dir=access_logs +server.tomcat.accesslog.file-date-format=.yyyy-MM-dd +server.tomcat.accesslog.prefix=access_log +server.tomcat.accesslog.suffix=.log +server.tomcat.accesslog.rotate=true + +# ---------------------------------------- +# DATA PROPERTIES +# ---------------------------------------- + +# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) +spring.datasource.url=jdbc:mysql://{{.DBHost}}:{{.DBPort}}/{{.DB}}?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&createDatabaseIfNotExist=true +spring.datasource.username={{.DBUser}} +spring.datasource.password={{.DBPassowrd}} +spring.datasource.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.initialize=false +spring.datasource.continue-on-error=false +spring.datasource.sql-script-encoding=utf-8 +spring.datasource.tomcat.default-auto-commit=true +spring.datasource.tomcat.initial-size=10 +spring.datasource.tomcat.max-active=25 +spring.datasource.tomcat.max-wait=30000 +spring.datasource.tomcat.test-on-borrow=true +spring.datasource.tomcat.test-while-idle=true +spring.datasource.tomcat.validation-query=SELECT 1 +spring.datasource.tomcat.validation-query-timeout=3 +spring.datasource.tomcat.time-between-eviction-runs-millis=10000 +spring.datasource.tomcat.min-evictable-idle-time-millis=120000 +spring.datasource.tomcat.remove-abandoned=true +spring.datasource.tomcat.remove-abandoned-timeout=300 +spring.liquibase.change-log=classpath:sql/master.xml + + + +# ---------------------------------------- +# Custom PROPERTIES +# ---------------------------------------- + +# OneCloud Authentication +yunionyun.auth.url={{.AuthURL}} +yunionyun.auth.domain={{.AuthDomain}} +yunionyun.auth.username={{.AuthUsername}} +yunionyun.auth.password={{.AuthPassword}} +yunionyun.auth.project={{.AuthProject}} +yunion.rc.auth.region={{.Region}} +yunion.rc.auth.cache-size=500 +yunion.rc.auth.timeout=1000 +yunion.rc.auth.debug=true +yunion.rc.auth.insecure=true +yunion.rc.auth.refresh-interval=300000 + +# Scheduled Task +yunion.rc.async-job.initial-delay=2000 +yunion.rc.async-job.fixed-rate=300000 +yunion.rc.async-job.fixed-thread-pool=10 + +# InfluxDB backend +yunion.rc.influxdb.database=meter_db +yunion.rc.influxdb.retention-policy=autogen + +# Alert +yunion.rc.alert.disable-link-url=http://office.yunion.io +yunion.rc.alert.statechangeonly-threshold=8h + +# Prepaid Alert +yunion.rc.alert.prepaid.enabled=true +yunion.rc.alert.prepaid.cron=0 0 8 * * * +` +) + +var MeterAlertComponent IComponent = NewMeterAlert() + +type MeterAlert struct { + *BaseComponent +} + +func NewMeterAlert() *MeterAlert { + m := new(MeterAlert) + m.BaseComponent = NewBaseComponent(onecloud.ComponentType("meteralert"), m) + return m +} + +func (m MeterAlert) NewService(oc *onecloud.OnecloudCluster) *corev1.Service { + return NewNodePortService(m.GetComponentType(), oc, MeterAlertPort) +} + +func (c MeterAlert) NewDeployment(oc *onecloud.OnecloudCluster) (*apps.Deployment, error) { + cf := func(volMounts []corev1.VolumeMount) []corev1.Container { + volMounts = SetJavaConfigVolumeMounts(volMounts) + return []corev1.Container{ + { + Name: "meteralert", + //Image: GetImage(oc, c.GetComponentType(), ""), + Image: GetJavaAppImage(oc, ""), + Env: []corev1.EnvVar{ + { + Name: JAVA_APP_JAR, + Value: "meteralert.jar", + }, + }, + VolumeMounts: volMounts, + }, + } + } + cType := c.GetComponentType() + deploy, err := NewDefaultDeployment(cType, oc, NewVolumeHelper(oc, cType), cf) + if err != nil { + return nil, err + } + podSpec := &deploy.Spec.Template.Spec + podSpec.Volumes = SetJavaConfigVolumes(podSpec.Volumes) + return deploy, nil +} + +func (c MeterAlert) NewConfigMap(oc *onecloud.OnecloudCluster, cCfg *OnecloudComponentsConfig) (*corev1.ConfigMap, error) { + cfg := cCfg.MeterAlertConfig + config := NewJavaDBConfig(oc, cfg) + return NewConfigMapByTemplate(c.GetComponentType(), oc, MeterAlertTemplate, config) +} + +func (c MeterAlert) NewCloudUser(cfg *OnecloudComponentsConfig) *onecloud.CloudUser { + return &cfg.MeterAlertConfig.CloudUser +} + +func (c MeterAlert) NewDBConfig(cfg *OnecloudComponentsConfig) *onecloud.DBConfig { + return &cfg.MeterAlertConfig.DB +} + +func (c MeterAlert) NewCloudEndpoint() *CloudEndpoint { + return NewHTTPCloudEndpoint(ServiceNameMeterAlert, ServiceTypeMeterAlert, MeterAlertPort, "api") +} diff --git a/pkg/phases/component/meter_cloud.go b/pkg/phases/component/meter_cloud.go new file mode 100644 index 00000000..c21fedbe --- /dev/null +++ b/pkg/phases/component/meter_cloud.go @@ -0,0 +1,131 @@ +package component + +import ( + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + onecloud "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" +) + +const ( + MeterCloudConfigTemplate = ` +banner.charset=UTF-8 +banner.location=classpath:config/banner.txt + +spring.main.banner-mode=console + +mybatis.type-aliases-package=com.yunion.apps +mybatis.mapper-locations=classpath:mappings/*/*.xml + + +debug=false + +spring.output.ansi.enabled=DETECT + +# LOGGING +logging.level.org.springframework=INFO +logging.level.com.yunion.apps=INFO +logging.level.com.yunionyun.mcp.mcclient=INFO +logging.level.org.apache.http.wire=INFO + +# EMBEDDED SERVER CONFIGURATION (ServerProperties) +server.port=9094 +server.session-timeout=180 +server.context-path=/ +server.tomcat.basedir=. +server.tomcat.uri-encoding=UTF-8 +server.tomcat.accesslog.dir=access_logs +server.tomcat.accesslog.enabled=true +server.tomcat.accesslog.file-date-format=.yyyy-MM-dd +server.tomcat.accesslog.prefix=access_log +server.tomcat.accesslog.suffix=.log +server.tomcat.accesslog.rotate=true + +# JACKSON (JacksonProperties) +spring.jackson.serialization.write_dates_as_timestamps=false + +spring.datasource.url=jdbc:mysql://{{.DBHost}}:{{.DBPort}}/{{.DB}}?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&createDatabaseIfNotExist=true +spring.datasource.username={{.DBUser}} +spring.datasource.password={{.DBPassowrd}} + +spring.datasource.driver-class-name=com.mysql.jdbc.Driver + +# Keystone Authentication & Authorization +yunionyun.auth.url={{.AuthURL}} +yunionyun.auth.domain={{.AuthDomain}} +yunionyun.auth.username={{.AuthUsername}} +yunionyun.auth.password={{.AuthPassword}} +yunionyun.auth.project={{.AuthProject}} +yunionyun.auth.region={{.Region}} +yunionyun.auth.session-region={{.Region}} +yunionyun.auth.cache-size=500 +yunionyun.auth.timeout=1000 +yunionyun.auth.debug=true +yunionyun.auth.insecure=true +yunionyun.auth.refresh-interval=900000 + +download.awsfilepath=/opt/yunion-meter/awsdatafile/ +` +) + +var MeterCloudComponent IComponent = NewMeterCloud() + +type MeterCloud struct { + *BaseComponent +} + +func NewMeterCloud() *MeterCloud { + m := new(MeterCloud) + m.BaseComponent = NewBaseComponent(onecloud.ComponentType("meter-cloud"), m) + return m +} + +func (m MeterCloud) NewService(oc *onecloud.OnecloudCluster) *corev1.Service { + return NewNodePortService(m.GetComponentType(), oc, MeterCloudPort) +} + +func (m MeterCloud) NewDeployment(oc *onecloud.OnecloudCluster) (*apps.Deployment, error) { + cf := func(volMounts []corev1.VolumeMount) []corev1.Container { + volMounts = SetJavaConfigVolumeMounts(volMounts) + return []corev1.Container{ + { + Name: "meter-cloud", + //Image: GetImage(oc, m.GetComponentType(), ""), + Image: GetJavaAppImage(oc, ""), + Env: []corev1.EnvVar{ + { + Name: JAVA_APP_JAR, + Value: "meter-cloud.jar", + }, + }, + VolumeMounts: volMounts, + }, + } + } + cType := m.GetComponentType() + deploy, err := NewDefaultDeployment(cType, oc, NewVolumeHelper(oc, cType), cf) + if err != nil { + return nil, err + } + podSpec := &deploy.Spec.Template.Spec + podSpec.Volumes = SetJavaConfigVolumes(podSpec.Volumes) + return deploy, nil +} + +func (m MeterCloud) NewConfigMap(oc *onecloud.OnecloudCluster, cCfg *OnecloudComponentsConfig) (*corev1.ConfigMap, error) { + cfg := cCfg.MeterConfig + config := NewJavaDBConfig(oc, cfg) + return NewConfigMapByTemplate(m.GetComponentType(), oc, MeterCloudConfigTemplate, config) +} + +func (m MeterCloud) NewCloudUser(cfg *OnecloudComponentsConfig) *onecloud.CloudUser { + return &cfg.MeterConfig.CloudUser +} + +func (m MeterCloud) NewDBConfig(cfg *OnecloudComponentsConfig) *onecloud.DBConfig { + return &cfg.MeterConfig.DB +} + +func (m MeterCloud) NewCloudEndpoint() *CloudEndpoint { + return NewHTTPCloudEndpoint(ServiceNameMeterCloud, ServiceTypeMeterCloud, MeterCloudPort, "api") +} diff --git a/pkg/phases/component/meter_service.go b/pkg/phases/component/meter_service.go new file mode 100644 index 00000000..348f49b6 --- /dev/null +++ b/pkg/phases/component/meter_service.go @@ -0,0 +1,192 @@ +package component + +import ( + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + onecloud "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" +) + +const ( + MeterServiceConfigTemplate = ` +# ---------------------------------------- +# CORE PROPERTIES +# ---------------------------------------- + +# BANNER +banner.charset=UTF-8 +banner.location=classpath:config/banner.txt + +# APPLICATION SETTINGS (SpringApplication) +# Mode used to display the banner when the application runs. +# console printed on System.out(console) +# log using the configured logger +# off not at all +spring.main.banner-mode=console + +mybatis.type-aliases-package=com.yunion.apps +mybatis.mapper-locations=classpath:mappings/*/*.xml + +# ---------------------------------------- +# CORE PROPERTIES +# ---------------------------------------- + +# DEBUG +debug=false + +# OUTPUT +# NEVER\uff1adisable ANSI-colored output (default) +# DETECT\uff1awill check whether the terminal supports ANSI, yes, then use the color output (recommend) +# ALWAYS\uff1aalways use ANSI-colored format output, if the terminal does not support, there will be a lot of interference information (not recommended) +spring.output.ansi.enabled=DETECT + +# LOGGING +logging.level.org.springframework=INFO +logging.level.com.yunion.apps=INFO +logging.level.com.yunionyun.mcp.mcclient=INFO + +# EMBEDDED SERVER CONFIGURATION (ServerProperties) +server.port=9091 +server.session-timeout=180 +server.context-path=/ +server.tomcat.basedir=. +server.tomcat.uri-encoding=UTF-8 +server.tomcat.accesslog.dir=access_logs +server.tomcat.accesslog.enabled=true +server.tomcat.accesslog.file-date-format=.yyyy-MM-dd +server.tomcat.accesslog.prefix=access_log +server.tomcat.accesslog.suffix=.log +server.tomcat.accesslog.rotate=true + +# JACKSON (JacksonProperties) +spring.jackson.serialization.write_dates_as_timestamps=false + +# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) +spring.datasource.url=jdbc:mysql://{{.DBHost}}:{{.DBPort}}/{{.DB}}?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&createDatabaseIfNotExist=true +spring.datasource.username={{.DBUser}} +spring.datasource.password={{.DBPassowrd}} +spring.datasource.driver-class-name=com.mysql.jdbc.Driver +liquibase.change-log=classpath:sql/master.xml + +# ---------------------------------------- +# INTEGRATION PROPERTIES +# ---------------------------------------- + +# Keystone Authentication & Authorization +yunionyun.auth.url={{.AuthURL}} +yunionyun.auth.domain={{.AuthDomain}} +yunionyun.auth.username={{.AuthUsername}} +yunionyun.auth.password={{.AuthPassword}} +yunionyun.auth.project={{.AuthProject}} +yunionyun.auth.cache-size=500 +yunionyun.auth.timeout=1000 +yunionyun.auth.debug=true +yunionyun.auth.insecure=true +yunionyun.auth.refresh-interval=900000 +yunionyun.auth.session-region={{.Region}} +##synchronize event-log region with && +yunionyun.auth.eventlog-region={{.Region}} + +default.platform=KVM +yunionyun.service.type=influxdb +yunionyun.influxdb.name=telegraf +yunionyun.hourly.hourInterval=1h +yunionyun.hourly.minuteInterval=5m + +# ### schedule timing setting +# 1-demo>> 17:10 every day +#jobs.cron_demoSchedule=0 10 17 * * ? +# 2-statDataProcess>> 17:10 every day +jobs.cron_statDataProcess=0 30 0 * * ? +# 3-synchronizeData config +jobs.synchronizeData.pagesize=2000 +## 1000 * 60 +jobs.synchronizeData.initialDelay=60000 +## 1000 * 60 * 4 +jobs.synchronizeData.fixedDelay=240000 +# 4-etlProcessData config +## 1000 * 60 * 2 +jobs.etlProcessData.initialDelay=120000 +## 1000 * 60 * 4 +jobs.etlProcessData.fixedDelay=240000 + +# >> hourly every day=(xx:01) +jobs.synchronize.netio.data=0 18 * * * ? + +# >> 01:01 every day=(xx:01) +jobs.process.netio.result=0 1 1 * * ? + +# 1 minutes after tomcat is running +jobs.usesumlog.initialDelay=60000 +# 10 minutes interval +jobs.usesumlog.fixedDelay=3600000 +# 80 minutes for each time +yunionyun.usesum.hourInterval=80m +# 6 hours the first time +yunionyun.usesum.firsttimeInterval=2h + +# >> 01:01 every day=(xx:01) +jobs.fetch.aliyun.priceinfo=0 30 0 * * ? + +download.awsfilepath=/opt/yunion-meter/awsdatafile/ +` +) + +var MeterServiceComponent IComponent = NewMeterService() + +type MeterService struct { + *BaseComponent +} + +func NewMeterService() *MeterService { + m := new(MeterService) + m.BaseComponent = NewBaseComponent(onecloud.ComponentType("meter-service"), m) + return m +} + +func (m MeterService) NewService(oc *onecloud.OnecloudCluster) *corev1.Service { + //return NewSinglePortService(m.GetComponentType(), oc, MeterServicePort) + return NewNodePortService(m.GetComponentType(), oc, MeterServicePort) +} + +func (m MeterService) NewDeployment(oc *onecloud.OnecloudCluster) (*apps.Deployment, error) { + cf := func(volMounts []corev1.VolumeMount) []corev1.Container { + volMounts = SetJavaConfigVolumeMounts(volMounts) + return []corev1.Container{ + { + Name: "meter-service", + //Image: GetImage(oc, m.GetComponentType(), ""), + Image: GetJavaAppImage(oc, ""), + Env: []corev1.EnvVar{ + { + Name: JAVA_APP_JAR, + Value: "meter-service.jar", + }, + }, + VolumeMounts: volMounts, + }, + } + } + cType := m.GetComponentType() + deploy, err := NewDefaultDeployment(cType, oc, NewVolumeHelper(oc, cType), cf) + if err != nil { + return nil, err + } + podSpec := &deploy.Spec.Template.Spec + podSpec.Volumes = SetJavaConfigVolumes(podSpec.Volumes) + return deploy, nil +} + +func (m MeterService) NewConfigMap(oc *onecloud.OnecloudCluster, cCfg *OnecloudComponentsConfig) (*corev1.ConfigMap, error) { + cfg := cCfg.MeterConfig + config := NewJavaDBConfig(oc, cfg) + return NewConfigMapByTemplate(m.GetComponentType(), oc, MeterServiceConfigTemplate, config) +} + +func (m MeterService) NewCloudUser(cfg *OnecloudComponentsConfig) *onecloud.CloudUser { + return &cfg.MeterConfig.CloudUser +} + +func (m MeterService) NewDBConfig(cfg *OnecloudComponentsConfig) *onecloud.DBConfig { + return &cfg.MeterConfig.DB +} diff --git a/pkg/phases/component/meter_traffic.go b/pkg/phases/component/meter_traffic.go new file mode 100644 index 00000000..05d4d56a --- /dev/null +++ b/pkg/phases/component/meter_traffic.go @@ -0,0 +1,189 @@ +package component + +import ( + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + onecloud "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" +) + +const ( + MeterTrafficConfigTemplate = ` +# ---------------------------------------- +# CORE PROPERTIES +# ---------------------------------------- + +# BANNER +banner.charset=UTF-8 +banner.location=classpath:config/banner.txt + +# APPLICATION SETTINGS (SpringApplication) +# Mode used to display the banner when the application runs. +# console printed on System.out(console) +# log using the configured logger +# off not at all +spring.main.banner-mode=console + +mybatis.type-aliases-package=com.yunion.apps +mybatis.mapper-locations=classpath:mappings/*/*.xml + +# ---------------------------------------- +# CORE PROPERTIES +# ---------------------------------------- + +# DEBUG +debug=false + +# OUTPUT +# NEVER\uff1adisable ANSI-colored output (default) +# DETECT\uff1awill check whether the terminal supports ANSI, yes, then use the color output (recommend) +# ALWAYS\uff1aalways use ANSI-colored format output, if the terminal does not support, there will be a lot of interference information (not recommended) +spring.output.ansi.enabled=DETECT + +# LOGGING +logging.level.org.springframework=INFO +logging.level.com.yunion.apps=DEBUG +logging.level.com.yunionyun.mcp.mcclient=INFO + +# EMBEDDED SERVER CONFIGURATION (ServerProperties) +server.port={{.Port}} +server.session-timeout=180 +server.context-path=/ +server.tomcat.basedir=. +server.tomcat.uri-encoding=UTF-8 +server.tomcat.accesslog.dir=access_logs +server.tomcat.accesslog.enabled=true +server.tomcat.accesslog.file-date-format=.yyyy-MM-dd +server.tomcat.accesslog.prefix=access_log +server.tomcat.accesslog.suffix=.log +server.tomcat.accesslog.rotate=true + +# JACKSON (JacksonProperties) +spring.jackson.serialization.write_dates_as_timestamps=false + +# DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) +spring.datasource.url=jdbc:mysql://{{.DBHost}}:{{.DBPort}}/{{.DB}}?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&createDatabaseIfNotExist=true +spring.datasource.username={{.DBUser}} +spring.datasource.password={{.DBPassowrd}} +spring.datasource.driver-class-name=com.mysql.jdbc.Driver +liquibase.change-log=classpath:sql/master.xml + +# ---------------------------------------- +# INTEGRATION PROPERTIES +# ---------------------------------------- + +# Keystone Authentication & Authorization +yunionyun.auth.url={{.AuthURL}} +yunionyun.auth.domain={{.AuthDomain}} +yunionyun.auth.username={{.AuthUsername}} +yunionyun.auth.password={{.AuthPassword}} +yunionyun.auth.project={{.AuthProject}} +yunionyun.auth.cache-size=500 +yunionyun.auth.timeout=1000 +yunionyun.auth.debug=true +yunionyun.auth.insecure=true +yunionyun.auth.refresh-interval=900000 +yunionyun.auth.session-region={{.Region}} +##synchronize event-log region with && +yunionyun.auth.eventlog-region={{.Region}} + +default.platform=KVM +yunionyun.service.type=influxdb +yunionyun.influxdb.name=telegraf +yunionyun.hourly.hourInterval=1h +yunionyun.hourly.minuteInterval=5m + +# ### schedule timing setting +# 1-demo>> 17:10 every day +#jobs.cron_demoSchedule=0 10 17 * * ? +# 2-statDataProcess>> 17:10 every day +jobs.cron_statDataProcess=0 30 0 * * ? +# 3-synchronizeData config +jobs.synchronizeData.pagesize=2000 +## 1000 * 60 +jobs.synchronizeData.initialDelay=60000 +## 1000 * 60 * 4 +jobs.synchronizeData.fixedDelay=240000 +# 4-etlProcessData config +## 1000 * 60 * 2 +jobs.etlProcessData.initialDelay=120000 +## 1000 * 60 * 4 +jobs.etlProcessData.fixedDelay=240000 + +# >> hourly every day=(xx:01) +jobs.synchronize.netio.data=0 18 * * * ? + +# >> 01:01 every day=(xx:01) +jobs.process.netio.result=0 1 1 * * ? + +# 1 minutes after tomcat is running +jobs.usesumlog.initialDelay=60000 +# 10 minutes interval +jobs.usesumlog.fixedDelay=3600000 +# 80 minutes for each time +yunionyun.usesum.hourInterval=80m +# 6 hours the first time +yunionyun.usesum.firsttimeInterval=2h + +# >> 01:01 every day=(xx:01) +jobs.fetch.aliyun.priceinfo=0 30 0 * * ? +` +) + +var MeterTrafficComponent IComponent = NewMeterTraffic() + +type MeterTraffic struct { + *BaseComponent +} + +func NewMeterTraffic() *MeterTraffic { + m := new(MeterTraffic) + m.BaseComponent = NewBaseComponent(onecloud.ComponentType("meter-traffic"), m) + return m +} + +func (m MeterTraffic) NewService(oc *onecloud.OnecloudCluster) *corev1.Service { + return NewNodePortService(m.GetComponentType(), oc, MeterTrafficPort) +} + +func (m MeterTraffic) NewDeployment(oc *onecloud.OnecloudCluster) (*apps.Deployment, error) { + cf := func(volMounts []corev1.VolumeMount) []corev1.Container { + volMounts = SetJavaConfigVolumeMounts(volMounts) + return []corev1.Container{ + { + Name: "meter-traffic", + //Image: GetImage(oc, m.GetComponentType(), ""), + Image: GetJavaAppImage(oc, ""), + Env: []corev1.EnvVar{ + { + Name: JAVA_APP_JAR, + Value: "meter-traffic.jar", + }, + }, + VolumeMounts: volMounts, + }, + } + } + cType := m.GetComponentType() + deploy, err := NewDefaultDeployment(cType, oc, NewVolumeHelper(oc, cType), cf) + if err != nil { + return nil, err + } + podSpec := &deploy.Spec.Template.Spec + podSpec.Volumes = SetJavaConfigVolumes(podSpec.Volumes) + return deploy, nil +} + +func (m MeterTraffic) NewConfigMap(oc *onecloud.OnecloudCluster, cCfg *OnecloudComponentsConfig) (*corev1.ConfigMap, error) { + cfg := cCfg.MeterConfig + config := NewJavaDBConfig(oc, cfg) + return NewConfigMapByTemplate(m.GetComponentType(), oc, MeterTrafficConfigTemplate, config) +} + +func (m MeterTraffic) NewCloudUser(cfg *OnecloudComponentsConfig) *onecloud.CloudUser { + return &cfg.MeterConfig.CloudUser +} + +func (m MeterTraffic) NewDBConfig(cfg *OnecloudComponentsConfig) *onecloud.DBConfig { + return &cfg.MeterConfig.DB +} diff --git a/pkg/phases/component/type.go b/pkg/phases/component/type.go new file mode 100644 index 00000000..001706cd --- /dev/null +++ b/pkg/phases/component/type.go @@ -0,0 +1,245 @@ +package component + +import ( + "fmt" + + "github.com/ghodss/yaml" + "github.com/pkg/errors" + corev1 "k8s.io/api/core/v1" + + "yunion.io/x/ocadm/pkg/apis/constants" + onecloud "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/util/passwd" +) + +const ( + OnecloudComponentsConfigKey = "OnecloudComponentsConfig" + + MeterAdminUser = "meter" + MeterPort = 9090 + MeterDB = "meter" + MeterDBUser = "meter" + ServiceNameMeter = "meter" + ServiceTypeMeter = "meter" + + MeterAlertAdminUser = "meteralert" + MeterAlertPort = 9494 + MeterAlertDB = "meteralert" + MeterAlertDBUser = "meteralert" + ServiceNameMeterAlert = "meteralert" + ServiceTypeMeterAlert = "meteralert" + + CloudmonAdminUser = "cloudmon" + + MeterServicePort = 9091 + MeterTrafficPort = 9093 + MeterCloudPort = 9094 + ServiceNameMeterCloud = "meter-cloud" + ServiceTypeMeterCloud = "meter-cloud" + + CloudWatcherAdminUser = "cloudwatcher" + CloudWatcherPort = 8787 + CloudWatcherDB = "cloudwatcher" + CloudWatcherDBUser = "cloudwatcher" + ServiceNameCloudWatcher = "cloudwatcher" + ServiceTypeCloudWatcher = "cloudwatcher" + + ItsmAdminUser = "itsm" + ItsmPort = 9595 + ItsmDB = "itsm" + ItsmDBUser = "itsm" + ServiceNameItsm = "itsm" + ServiceTypeItsm = "itsm" +) + +type ItsmConfigOptions struct { + onecloud.ServiceDBCommonOptions + SecondDatabase string `json:"secondDatabase"` + EncryptionKey string `json:"encryptionKey"` +} + +type OnecloudComponentsConfig struct { + MeterConfig onecloud.ServiceDBCommonOptions `json:"meter"` + MeterAlertConfig onecloud.ServiceDBCommonOptions `json:"meteralert"` + CloudmonConfig onecloud.ServiceCommonOptions `json:"cloudmon"` + CloudWatcherConfig onecloud.ServiceDBCommonOptions `json:"cloudwatcher"` + ItsmConfig ItsmConfigOptions `json:"itsm"` +} + +func NewOnecloudComponentsConfig(old *OnecloudComponentsConfig) (*OnecloudComponentsConfig, error) { + newObj := new(OnecloudComponentsConfig) + if old != nil { + bs, err := yaml.Marshal(old) + if err != nil { + return nil, err + } + if err := yaml.Unmarshal(bs, newObj); err != nil { + return nil, err + } + } + return FillOnecloudComponentsConfigDefault(newObj), nil +} + +func FillOnecloudComponentsConfigDefault(obj *OnecloudComponentsConfig) *OnecloudComponentsConfig { + type userDBPort struct { + user string + port int + db string + dbUser string + } + + for opt, tmp := range map[*onecloud.ServiceDBCommonOptions]userDBPort{ + &obj.MeterConfig: {MeterAdminUser, MeterPort, MeterDB, MeterDBUser}, + &obj.MeterAlertConfig: {MeterAlertAdminUser, MeterAlertPort, MeterAlertDB, MeterAlertDBUser}, + &obj.CloudWatcherConfig: {CloudWatcherAdminUser, CloudWatcherPort, CloudWatcherDB, CloudWatcherDBUser}, + &obj.ItsmConfig.ServiceDBCommonOptions: {ItsmAdminUser, ItsmPort, ItsmDB, ItsmDBUser}, + } { + onecloud.SetDefaults_ServiceDBCommonOptions(opt, tmp.db, tmp.dbUser, tmp.user, tmp.port) + } + + itsmConfig := &obj.ItsmConfig + if itsmConfig.SecondDatabase == "" { + itsmConfig.SecondDatabase = fmt.Sprintf("%s_engine", itsmConfig.DB.Database) + } + if itsmConfig.EncryptionKey == "" { + itsmConfig.EncryptionKey = passwd.GeneratePassword() + } + + type userPort struct { + user string + port int + } + for opt, up := range map[*onecloud.ServiceCommonOptions]userPort{ + &obj.CloudmonConfig: {CloudmonAdminUser, 0}, + } { + onecloud.SetDefaults_ServiceCommonOptions(opt, up.user, up.port) + } + + return obj +} + +func ComponentsConfigMapName(oc *onecloud.OnecloudCluster) string { + return fmt.Sprintf("%s-%s", oc.GetName(), "cluster-components-config") +} + +func NewOnecloudComponentsConfigFromYaml(data string) (*OnecloudComponentsConfig, error) { + cfg := &OnecloudComponentsConfig{} + if err := yaml.Unmarshal([]byte(data), cfg); err != nil { + return nil, errors.Wrap(err, "failed to decode onecloud cluster config data") + } + return cfg, nil +} + +func NewOnecloudComponentsConfigFromConfigMap(cfgMap *corev1.ConfigMap) (*OnecloudComponentsConfig, error) { + data, ok := cfgMap.Data[OnecloudComponentsConfigKey] + if !ok { + return nil, errors.Errorf("unexpected error when reading %s ConfigMap: %s key value pair missing", cfgMap.GetName(), OnecloudComponentsConfigKey) + } + cfg, err := NewOnecloudComponentsConfigFromYaml(data) + if err != nil { + return nil, err + } + return NewOnecloudComponentsConfig(cfg) +} + +func (obj *OnecloudComponentsConfig) ToYaml() (string, error) { + data, err := yaml.Marshal(obj) + if err != nil { + return "", err + } + return string(data), nil +} + +func (obj *OnecloudComponentsConfig) ToConfigMap(oc *onecloud.OnecloudCluster) (*corev1.ConfigMap, error) { + data, err := obj.ToYaml() + if err != nil { + return nil, err + } + cfgMapName := ComponentsConfigMapName(oc) + return &corev1.ConfigMap{ + ObjectMeta: GetObjectMeta(oc, cfgMapName, nil), + Data: map[string]string{ + OnecloudComponentsConfigKey: data, + }, + }, nil +} + +type JavaBaseConfig struct { + Port int + AuthURL string + AuthDomain string + AuthUsername string + AuthPassword string + AuthProject string + Region string +} + +func NewJavaBaseConfig(oc *onecloud.OnecloudCluster, port int, user, passwd string) *JavaBaseConfig { + return &JavaBaseConfig{ + AuthURL: controller.GetAuthURL(oc), + AuthProject: constants.SysAdminProject, + AuthDomain: constants.DefaultDomain, + AuthUsername: user, + AuthPassword: passwd, + Region: oc.Spec.Region, + Port: port, + } +} + +type JavaDBConfig struct { + JavaBaseConfig + DBHost string + DBPort int32 + DB string + DBUser string + DBPassowrd string +} + +func NewJavaDBConfig(oc *onecloud.OnecloudCluster, cfg onecloud.ServiceDBCommonOptions) *JavaDBConfig { + opt := NewJavaBaseConfig(oc, cfg.Port, cfg.CloudUser.Username, cfg.CloudUser.Password) + dbCfg := &JavaDBConfig{ + JavaBaseConfig: *opt, + DBHost: oc.Spec.Mysql.Host, + DBPort: oc.Spec.Mysql.Port, + DB: cfg.DB.Database, + DBUser: cfg.DB.Username, + DBPassowrd: cfg.DB.Password, + } + return dbCfg +} + +type CloudEndpoint struct { + Proto string + Region string + ServiceName string + ServiceType string + Port int + Prefix string +} + +func NewProtoCloudEndpoint(proto, svcName, svcType string, port int, prefix string) *CloudEndpoint { + return &CloudEndpoint{ + Proto: proto, + ServiceName: svcName, + ServiceType: svcType, + Port: port, + Prefix: prefix, + } +} + +func NewHTTPCloudEndpoint(svcName, svcType string, port int, prefix string) *CloudEndpoint { + return NewProtoCloudEndpoint("http", svcName, svcType, port, prefix) +} + +func NewHTTPSCloudEndpoint(svcName, svcType string, port int, prefix string) *CloudEndpoint { + return NewProtoCloudEndpoint("https", svcName, svcType, port, prefix) +} + +func (ep CloudEndpoint) GetUrl(address string) string { + url := fmt.Sprintf("%s://%s:%d", ep.Proto, address, ep.Port) + if ep.Prefix != "" { + url = fmt.Sprintf("%s/%s", url, ep.Prefix) + } + return url +} diff --git a/pkg/phases/component/web.go b/pkg/phases/component/web.go new file mode 100644 index 00000000..f58ae963 --- /dev/null +++ b/pkg/phases/component/web.go @@ -0,0 +1,93 @@ +package component + +import ( + "io" + "os" + + "github.com/spf13/cobra" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" + onecloud "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" +) + +const ( + WebCEImageName = "web" + APIGatewayCEImageName = "apigateway" + WebEEImageName = "web-ee" + APIGatewayEEImageName = "apigateway-ee" +) + +func NewCmdWeb() *cobra.Command { + cmd := &cobra.Command{ + Use: "web", + Short: "Manage web UI component", + } + NewWebCmd(cmd, os.Stdout).Bind() + return cmd +} + +type WebCmd struct { + *baseCmd +} + +func NewWebCmd(cmd *cobra.Command, out io.Writer) *WebCmd { + return &WebCmd{ + baseCmd: newBaseCmd(cmd, out), + } +} + +func (w *WebCmd) Bind() { + w.baseCmd.AddCmd(w.newSubCmd("use-ce", w.useCE)) + w.baseCmd.AddCmd(w.newSubCmd("use-ee", w.useEE)) +} + +func setEdition(spec *onecloud.DeploymentSpec, edition string) { + if spec.Annotations == nil { + spec.Annotations = map[string]string{} + } + spec.Annotations[constants.OnecloudEditionAnnotationKey] = edition +} + +func SetCEdition(spec *onecloud.DeploymentSpec) { + setEdition(spec, constants.OnecloudCommunityEdition) +} + +func SetEEdition(spec *onecloud.DeploymentSpec) { + setEdition(spec, constants.OnecloudEnterpriseEdition) +} + +func (w *WebCmd) useCE(data *componentsData, _ io.Writer) error { + // change onecloud web component image + // disable yunion-agent + return w.updateOnecloudCluster(func(oc *onecloud.OnecloudCluster) *onecloud.OnecloudCluster { + web := &oc.Spec.Web + SetCEdition(web) + web.ImageName = WebCEImageName + + apiGateway := &oc.Spec.APIGateway + apiGateway.ImageName = APIGatewayCEImageName + SetCEdition(apiGateway) + + yunionagent := &oc.Spec.Yunionagent + yunionagent.Disable = true + return oc + }) +} + +func (w *WebCmd) useEE(data *componentsData, _ io.Writer) error { + // change onecloud web component image to ee + // enable yunion-agent + return w.updateOnecloudCluster(func(oc *onecloud.OnecloudCluster) *onecloud.OnecloudCluster { + web := &oc.Spec.Web + web.ImageName = WebEEImageName + SetEEdition(web) + + apiGateway := &oc.Spec.APIGateway + apiGateway.ImageName = APIGatewayEEImageName + SetEEdition(apiGateway) + + yunionagent := &oc.Spec.Yunionagent + yunionagent.Disable = false + return oc + }) +} diff --git a/vendor/github.com/ugorji/go/codec/xml.go b/vendor/github.com/ugorji/go/codec/xml.go deleted file mode 100644 index 63fcdfca..00000000 --- a/vendor/github.com/ugorji/go/codec/xml.go +++ /dev/null @@ -1,502 +0,0 @@ -// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. -// Use of this source code is governed by a MIT license found in the LICENSE file. - -// +build ignore - -package codec - -/* - -A strict Non-validating namespace-aware XML 1.0 parser and (en|de)coder. - -We are attempting this due to perceived issues with encoding/xml: - - Complicated. It tried to do too much, and is not as simple to use as json. - - Due to over-engineering, reflection is over-used AND performance suffers: - java is 6X faster:http://fabsk.eu/blog/category/informatique/dev/golang/ - even PYTHON performs better: http://outgoing.typepad.com/outgoing/2014/07/exploring-golang.html - -codec framework will offer the following benefits - - VASTLY improved performance (when using reflection-mode or codecgen) - - simplicity and consistency: with the rest of the supported formats - - all other benefits of codec framework (streaming, codegeneration, etc) - -codec is not a drop-in replacement for encoding/xml. -It is a replacement, based on the simplicity and performance of codec. -Look at it like JAXB for Go. - -Challenges: - - Need to output XML preamble, with all namespaces at the right location in the output. - - Each "end" block is dynamic, so we need to maintain a context-aware stack - - How to decide when to use an attribute VS an element - - How to handle chardata, attr, comment EXPLICITLY. - - Should it output fragments? - e.g. encoding a bool should just output true OR false, which is not well-formed XML. - -Extend the struct tag. See representative example: - type X struct { - ID uint8 `codec:"http://ugorji.net/x-namespace xid id,omitempty,toarray,attr,cdata"` - // format: [namespace-uri ][namespace-prefix ]local-name, ... - } - -Based on this, we encode - - fields as elements, BUT - encode as attributes if struct tag contains ",attr" and is a scalar (bool, number or string) - - text as entity-escaped text, BUT encode as CDATA if struct tag contains ",cdata". - -To handle namespaces: - - XMLHandle is denoted as being namespace-aware. - Consequently, we WILL use the ns:name pair to encode and decode if defined, else use the plain name. - - *Encoder and *Decoder know whether the Handle "prefers" namespaces. - - add *Encoder.getEncName(*structFieldInfo). - No one calls *structFieldInfo.indexForEncName directly anymore - - OR better yet: indexForEncName is namespace-aware, and helper.go is all namespace-aware - indexForEncName takes a parameter of the form namespace:local-name OR local-name - - add *Decoder.getStructFieldInfo(encName string) // encName here is either like abc, or h1:nsabc - by being a method on *Decoder, or maybe a method on the Handle itself. - No one accesses .encName anymore - - let encode.go and decode.go use these (for consistency) - - only problem exists for gen.go, where we create a big switch on encName. - Now, we also have to add a switch on strings.endsWith(kName, encNsName) - - gen.go will need to have many more methods, and then double-on the 2 switch loops like: - switch k { - case "abc" : x.abc() - case "def" : x.def() - default { - switch { - case !nsAware: panic(...) - case strings.endsWith(":abc"): x.abc() - case strings.endsWith(":def"): x.def() - default: panic(...) - } - } - } - -The structure below accommodates this: - - type typeInfo struct { - sfi []*structFieldInfo // sorted by encName - sfins // sorted by namespace - sfia // sorted, to have those with attributes at the top. Needed to write XML appropriately. - sfip // unsorted - } - type structFieldInfo struct { - encName - nsEncName - ns string - attr bool - cdata bool - } - -indexForEncName is now an internal helper function that takes a sorted array -(one of ti.sfins or ti.sfi). It is only used by *Encoder.getStructFieldInfo(...) - -There will be a separate parser from the builder. -The parser will have a method: next() xmlToken method. It has lookahead support, -so you can pop multiple tokens, make a determination, and push them back in the order popped. -This will be needed to determine whether we are "nakedly" decoding a container or not. -The stack will be implemented using a slice and push/pop happens at the [0] element. - -xmlToken has fields: - - type uint8: 0 | ElementStart | ElementEnd | AttrKey | AttrVal | Text - - value string - - ns string - -SEE: http://www.xml.com/pub/a/98/10/guide0.html?page=3#ENTDECL - -The following are skipped when parsing: - - External Entities (from external file) - - Notation Declaration e.g. - - Entity Declarations & References - - XML Declaration (assume UTF-8) - - XML Directive i.e. - - Other Declarations: Notation, etc. - - Comment - - Processing Instruction - - schema / DTD for validation: - We are not a VALIDATING parser. Validation is done elsewhere. - However, some parts of the DTD internal subset are used (SEE BELOW). - For Attribute List Declarations e.g. - - We considered using the ATTLIST to get "default" value, but not to validate the contents. (VETOED) - -The following XML features are supported - - Namespace - - Element - - Attribute - - cdata - - Unicode escape - -The following DTD (when as an internal sub-set) features are supported: - - Internal Entities e.g. - AND entities for the set: [<>&"'] - - Parameter entities e.g. - - -At decode time, a structure containing the following is kept - - namespace mapping - - default attribute values - - all internal entities (<>&"' and others written in the document) - -When decode starts, it parses XML namespace declarations and creates a map in the -xmlDecDriver. While parsing, that map continuously gets updated. -The only problem happens when a namespace declaration happens on the node that it defines. -e.g. -To handle this, each Element must be fully parsed at a time, -even if it amounts to multiple tokens which are returned one at a time on request. - -xmlns is a special attribute name. - - It is used to define namespaces, including the default - - It is never returned as an AttrKey or AttrVal. - *We may decide later to allow user to use it e.g. you want to parse the xmlns mappings into a field.* - -Number, bool, null, mapKey, etc can all be decoded from any xmlToken. -This accommodates map[int]string for example. - -It should be possible to create a schema from the types, -or vice versa (generate types from schema with appropriate tags). -This is however out-of-scope from this parsing project. - -We should write all namespace information at the first point that it is referenced in the tree, -and use the mapping for all child nodes and attributes. This means that state is maintained -at a point in the tree. This also means that calls to Decode or MustDecode will reset some state. - -When decoding, it is important to keep track of entity references and default attribute values. -It seems these can only be stored in the DTD components. We should honor them when decoding. - -Configuration for XMLHandle will look like this: - - XMLHandle - DefaultNS string - // Encoding: - NS map[string]string // ns URI to key, used for encoding - // Decoding: in case ENTITY declared in external schema or dtd, store info needed here - Entities map[string]string // map of entity rep to character - - -During encode, if a namespace mapping is not defined for a namespace found on a struct, -then we create a mapping for it using nsN (where N is 1..1000000, and doesn't conflict -with any other namespace mapping). - -Note that different fields in a struct can have different namespaces. -However, all fields will default to the namespace on the _struct field (if defined). - -An XML document is a name, a map of attributes and a list of children. -Consequently, we cannot "DecodeNaked" into a map[string]interface{} (for example). -We have to "DecodeNaked" into something that resembles XML data. - -To support DecodeNaked (decode into nil interface{}), we have to define some "supporting" types: - type Name struct { // Preferred. Less allocations due to conversions. - Local string - Space string - } - type Element struct { - Name Name - Attrs map[Name]string - Children []interface{} // each child is either *Element or string - } -Only two "supporting" types are exposed for XML: Name and Element. - -// ------------------ - -We considered 'type Name string' where Name is like "Space Local" (space-separated). -We decided against it, because each creation of a name would lead to -double allocation (first convert []byte to string, then concatenate them into a string). -The benefit is that it is faster to read Attrs from a map. But given that Element is a value -object, we want to eschew methods and have public exposed variables. - -We also considered the following, where xml types were not value objects, and we used -intelligent accessor methods to extract information and for performance. -*** WE DECIDED AGAINST THIS. *** - type Attr struct { - Name Name - Value string - } - // Element is a ValueObject: There are no accessor methods. - // Make element self-contained. - type Element struct { - Name Name - attrsMap map[string]string // where key is "Space Local" - attrs []Attr - childrenT []string - childrenE []Element - childrenI []int // each child is a index into T or E. - } - func (x *Element) child(i) interface{} // returns string or *Element - -// ------------------ - -Per XML spec and our default handling, white space is always treated as -insignificant between elements, except in a text node. The xml:space='preserve' -attribute is ignored. - -**Note: there is no xml: namespace. The xml: attributes were defined before namespaces.** -**So treat them as just "directives" that should be interpreted to mean something**. - -On encoding, we support indenting aka prettifying markup in the same way we support it for json. - -A document or element can only be encoded/decoded from/to a struct. In this mode: - - struct name maps to element name (or tag-info from _struct field) - - fields are mapped to child elements or attributes - -A map is either encoded as attributes on current element, or as a set of child elements. -Maps are encoded as attributes iff their keys and values are primitives (number, bool, string). - -A list is encoded as a set of child elements. - -Primitives (number, bool, string) are encoded as an element, attribute or text -depending on the context. - -Extensions must encode themselves as a text string. - -Encoding is tough, specifically when encoding mappings, because we need to encode -as either attribute or element. To do this, we need to default to encoding as attributes, -and then let Encoder inform the Handle when to start encoding as nodes. -i.e. Encoder does something like: - - h.EncodeMapStart() - h.Encode(), h.Encode(), ... - h.EncodeMapNotAttrSignal() // this is not a bool, because it's a signal - h.Encode(), h.Encode(), ... - h.EncodeEnd() - -Only XMLHandle understands this, and will set itself to start encoding as elements. - -This support extends to maps. For example, if a struct field is a map, and it has -the struct tag signifying it should be attr, then all its fields are encoded as attributes. -e.g. - - type X struct { - M map[string]int `codec:"m,attr"` // encode keys as attributes named - } - -Question: - - if encoding a map, what if map keys have spaces in them??? - Then they cannot be attributes or child elements. Error. - -Options to consider adding later: - - For attribute values, normalize by trimming beginning and ending white space, - and converting every white space sequence to a single space. - - ATTLIST restrictions are enforced. - e.g. default value of xml:space, skipping xml:XYZ style attributes, etc. - - Consider supporting NON-STRICT mode (e.g. to handle HTML parsing). - Some elements e.g. br, hr, etc need not close and should be auto-closed - ... (see http://www.w3.org/TR/html4/loose.dtd) - An expansive set of entities are pre-defined. - - Have easy way to create a HTML parser: - add a HTML() method to XMLHandle, that will set Strict=false, specify AutoClose, - and add HTML Entities to the list. - - Support validating element/attribute XMLName before writing it. - Keep this behind a flag, which is set to false by default (for performance). - type XMLHandle struct { - CheckName bool - } - -Misc: - -ROADMAP (1 weeks): - - build encoder (1 day) - - build decoder (based off xmlParser) (1 day) - - implement xmlParser (2 days). - Look at encoding/xml for inspiration. - - integrate and TEST (1 days) - - write article and post it (1 day) - -// ---------- MORE NOTES FROM 2017-11-30 ------------ - -when parsing -- parse the attributes first -- then parse the nodes - -basically: -- if encoding a field: we use the field name for the wrapper -- if encoding a non-field, then just use the element type name - - map[string]string ==> abcval... or - val... OR - val1val2... <- PREFERED - []string ==> v1v2... - string v1 ==> v1 - bool true ==> true - float 1.0 ==> 1.0 - ... - - F1 map[string]string ==> abcval... OR - val... OR - val... <- PREFERED - F2 []string ==> v1v2... - F3 bool ==> true - ... - -- a scalar is encoded as: - (value) of type T ==> - (value) of field F ==> -- A kv-pair is encoded as: - (key,value) ==> OR - (key,value) of field F ==> OR -- A map or struct is just a list of kv-pairs -- A list is encoded as sequences of same node e.g. - - - value21 - value22 -- we may have to singularize the field name, when entering into xml, - and pluralize them when encoding. -- bi-directional encode->decode->encode is not a MUST. - even encoding/xml cannot decode correctly what was encoded: - - see https://play.golang.org/p/224V_nyhMS - func main() { - fmt.Println("Hello, playground") - v := []interface{}{"hello", 1, true, nil, time.Now()} - s, err := xml.Marshal(v) - fmt.Printf("err: %v, \ns: %s\n", err, s) - var v2 []interface{} - err = xml.Unmarshal(s, &v2) - fmt.Printf("err: %v, \nv2: %v\n", err, v2) - type T struct { - V []interface{} - } - v3 := T{V: v} - s, err = xml.Marshal(v3) - fmt.Printf("err: %v, \ns: %s\n", err, s) - var v4 T - err = xml.Unmarshal(s, &v4) - fmt.Printf("err: %v, \nv4: %v\n", err, v4) - } - Output: - err: , - s: hello1true - err: , - v2: [] - err: , - s: hello1true2009-11-10T23:00:00Z - err: , - v4: {[ ]} -- -*/ - -// ----------- PARSER ------------------- - -type xmlTokenType uint8 - -const ( - _ xmlTokenType = iota << 1 - xmlTokenElemStart - xmlTokenElemEnd - xmlTokenAttrKey - xmlTokenAttrVal - xmlTokenText -) - -type xmlToken struct { - Type xmlTokenType - Value string - Namespace string // blank for AttrVal and Text -} - -type xmlParser struct { - r decReader - toks []xmlToken // list of tokens. - ptr int // ptr into the toks slice - done bool // nothing else to parse. r now returns EOF. -} - -func (x *xmlParser) next() (t *xmlToken) { - // once x.done, or x.ptr == len(x.toks) == 0, then return nil (to signify finish) - if !x.done && len(x.toks) == 0 { - x.nextTag() - } - // parses one element at a time (into possible many tokens) - if x.ptr < len(x.toks) { - t = &(x.toks[x.ptr]) - x.ptr++ - if x.ptr == len(x.toks) { - x.ptr = 0 - x.toks = x.toks[:0] - } - } - return -} - -// nextTag will parses the next element and fill up toks. -// It set done flag if/once EOF is reached. -func (x *xmlParser) nextTag() { - // ... -} - -// ----------- ENCODER ------------------- - -type xmlEncDriver struct { - e *Encoder - w encWriter - h *XMLHandle - b [64]byte // scratch - bs []byte // scratch - // s jsonStack - noBuiltInTypes -} - -// ----------- DECODER ------------------- - -type xmlDecDriver struct { - d *Decoder - h *XMLHandle - r decReader // *bytesDecReader decReader - ct valueType // container type. one of unset, array or map. - bstr [8]byte // scratch used for string \UXXX parsing - b [64]byte // scratch - - // wsSkipped bool // whitespace skipped - - // s jsonStack - - noBuiltInTypes -} - -// DecodeNaked will decode into an XMLNode - -// XMLName is a value object representing a namespace-aware NAME -type XMLName struct { - Local string - Space string -} - -// XMLNode represents a "union" of the different types of XML Nodes. -// Only one of fields (Text or *Element) is set. -type XMLNode struct { - Element *Element - Text string -} - -// XMLElement is a value object representing an fully-parsed XML element. -type XMLElement struct { - Name Name - Attrs map[XMLName]string - // Children is a list of child nodes, each being a *XMLElement or string - Children []XMLNode -} - -// ----------- HANDLE ------------------- - -type XMLHandle struct { - BasicHandle - textEncodingType - - DefaultNS string - NS map[string]string // ns URI to key, for encoding - Entities map[string]string // entity representation to string, for encoding. -} - -func (h *XMLHandle) newEncDriver(e *Encoder) encDriver { - return &xmlEncDriver{e: e, w: e.w, h: h} -} - -func (h *XMLHandle) newDecDriver(d *Decoder) decDriver { - // d := xmlDecDriver{r: r.(*bytesDecReader), h: h} - hd := xmlDecDriver{d: d, r: d.r, h: h} - hd.n.bytes = d.b[:] - return &hd -} - -var _ decDriver = (*xmlDecDriver)(nil) -var _ encDriver = (*xmlEncDriver)(nil) diff --git a/vendor/golang.org/x/sys/unix/mkasm_darwin.go b/vendor/golang.org/x/sys/unix/mkasm_darwin.go deleted file mode 100644 index 4548b993..00000000 --- a/vendor/golang.org/x/sys/unix/mkasm_darwin.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// mkasm_darwin.go generates assembly trampolines to call libSystem routines from Go. -//This program must be run after mksyscall.go. -package main - -import ( - "bytes" - "fmt" - "io/ioutil" - "log" - "os" - "strings" -) - -func main() { - in1, err := ioutil.ReadFile("syscall_darwin.go") - if err != nil { - log.Fatalf("can't open syscall_darwin.go: %s", err) - } - arch := os.Args[1] - in2, err := ioutil.ReadFile(fmt.Sprintf("syscall_darwin_%s.go", arch)) - if err != nil { - log.Fatalf("can't open syscall_darwin_%s.go: %s", arch, err) - } - in3, err := ioutil.ReadFile(fmt.Sprintf("zsyscall_darwin_%s.go", arch)) - if err != nil { - log.Fatalf("can't open zsyscall_darwin_%s.go: %s", arch, err) - } - in := string(in1) + string(in2) + string(in3) - - trampolines := map[string]bool{} - - var out bytes.Buffer - - fmt.Fprintf(&out, "// go run mkasm_darwin.go %s\n", strings.Join(os.Args[1:], " ")) - fmt.Fprintf(&out, "// Code generated by the command above; DO NOT EDIT.\n") - fmt.Fprintf(&out, "\n") - fmt.Fprintf(&out, "// +build go1.12\n") - fmt.Fprintf(&out, "\n") - fmt.Fprintf(&out, "#include \"textflag.h\"\n") - for _, line := range strings.Split(in, "\n") { - if !strings.HasPrefix(line, "func ") || !strings.HasSuffix(line, "_trampoline()") { - continue - } - fn := line[5 : len(line)-13] - if !trampolines[fn] { - trampolines[fn] = true - fmt.Fprintf(&out, "TEXT ·%s_trampoline(SB),NOSPLIT,$0-0\n", fn) - fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn) - } - } - err = ioutil.WriteFile(fmt.Sprintf("zsyscall_darwin_%s.s", arch), out.Bytes(), 0644) - if err != nil { - log.Fatalf("can't write zsyscall_darwin_%s.s: %s", arch, err) - } -} diff --git a/vendor/golang.org/x/sys/unix/mkpost.go b/vendor/golang.org/x/sys/unix/mkpost.go deleted file mode 100644 index 4d5b531b..00000000 --- a/vendor/golang.org/x/sys/unix/mkpost.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// mkpost processes the output of cgo -godefs to -// modify the generated types. It is used to clean up -// the sys API in an architecture specific manner. -// -// mkpost is run after cgo -godefs; see README.md. -package main - -import ( - "bytes" - "fmt" - "go/format" - "io/ioutil" - "log" - "os" - "regexp" -) - -func main() { - // Get the OS and architecture (using GOARCH_TARGET if it exists) - goos := os.Getenv("GOOS") - goarch := os.Getenv("GOARCH_TARGET") - if goarch == "" { - goarch = os.Getenv("GOARCH") - } - // Check that we are using the Docker-based build system if we should be. - if goos == "linux" { - if os.Getenv("GOLANG_SYS_BUILD") != "docker" { - os.Stderr.WriteString("In the Docker-based build system, mkpost should not be called directly.\n") - os.Stderr.WriteString("See README.md\n") - os.Exit(1) - } - } - - b, err := ioutil.ReadAll(os.Stdin) - if err != nil { - log.Fatal(err) - } - - if goos == "aix" { - // Replace type of Atim, Mtim and Ctim by Timespec in Stat_t - // to avoid having both StTimespec and Timespec. - sttimespec := regexp.MustCompile(`_Ctype_struct_st_timespec`) - b = sttimespec.ReplaceAll(b, []byte("Timespec")) - } - - // Intentionally export __val fields in Fsid and Sigset_t - valRegex := regexp.MustCompile(`type (Fsid|Sigset_t) struct {(\s+)X__val(\s+\S+\s+)}`) - b = valRegex.ReplaceAll(b, []byte("type $1 struct {${2}Val$3}")) - - // Intentionally export __fds_bits field in FdSet - fdSetRegex := regexp.MustCompile(`type (FdSet) struct {(\s+)X__fds_bits(\s+\S+\s+)}`) - b = fdSetRegex.ReplaceAll(b, []byte("type $1 struct {${2}Bits$3}")) - - // If we have empty Ptrace structs, we should delete them. Only s390x emits - // nonempty Ptrace structs. - ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`) - b = ptraceRexexp.ReplaceAll(b, nil) - - // Replace the control_regs union with a blank identifier for now. - controlRegsRegex := regexp.MustCompile(`(Control_regs)\s+\[0\]uint64`) - b = controlRegsRegex.ReplaceAll(b, []byte("_ [0]uint64")) - - // Remove fields that are added by glibc - // Note that this is unstable as the identifers are private. - removeFieldsRegex := regexp.MustCompile(`X__glibc\S*`) - b = removeFieldsRegex.ReplaceAll(b, []byte("_")) - - // Convert [65]int8 to [65]byte in Utsname members to simplify - // conversion to string; see golang.org/issue/20753 - convertUtsnameRegex := regexp.MustCompile(`((Sys|Node|Domain)name|Release|Version|Machine)(\s+)\[(\d+)\]u?int8`) - b = convertUtsnameRegex.ReplaceAll(b, []byte("$1$3[$4]byte")) - - // Convert [1024]int8 to [1024]byte in Ptmget members - convertPtmget := regexp.MustCompile(`([SC]n)(\s+)\[(\d+)\]u?int8`) - b = convertPtmget.ReplaceAll(b, []byte("$1[$3]byte")) - - // Remove spare fields (e.g. in Statx_t) - spareFieldsRegex := regexp.MustCompile(`X__spare\S*`) - b = spareFieldsRegex.ReplaceAll(b, []byte("_")) - - // Remove cgo padding fields - removePaddingFieldsRegex := regexp.MustCompile(`Pad_cgo_\d+`) - b = removePaddingFieldsRegex.ReplaceAll(b, []byte("_")) - - // Remove padding, hidden, or unused fields - removeFieldsRegex = regexp.MustCompile(`\b(X_\S+|Padding)`) - b = removeFieldsRegex.ReplaceAll(b, []byte("_")) - - // Remove the first line of warning from cgo - b = b[bytes.IndexByte(b, '\n')+1:] - // Modify the command in the header to include: - // mkpost, our own warning, and a build tag. - replacement := fmt.Sprintf(`$1 | go run mkpost.go -// Code generated by the command above; see README.md. DO NOT EDIT. - -// +build %s,%s`, goarch, goos) - cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`) - b = cgoCommandRegex.ReplaceAll(b, []byte(replacement)) - - // Rename Stat_t time fields - if goos == "freebsd" && goarch == "386" { - // Hide Stat_t.[AMCB]tim_ext fields - renameStatTimeExtFieldsRegex := regexp.MustCompile(`[AMCB]tim_ext`) - b = renameStatTimeExtFieldsRegex.ReplaceAll(b, []byte("_")) - } - renameStatTimeFieldsRegex := regexp.MustCompile(`([AMCB])(?:irth)?time?(?:spec)?\s+(Timespec|StTimespec)`) - b = renameStatTimeFieldsRegex.ReplaceAll(b, []byte("${1}tim ${2}")) - - // gofmt - b, err = format.Source(b) - if err != nil { - log.Fatal(err) - } - - os.Stdout.Write(b) -} diff --git a/vendor/golang.org/x/sys/unix/mksyscall.go b/vendor/golang.org/x/sys/unix/mksyscall.go deleted file mode 100644 index e4af9424..00000000 --- a/vendor/golang.org/x/sys/unix/mksyscall.go +++ /dev/null @@ -1,407 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -/* -This program reads a file containing function prototypes -(like syscall_darwin.go) and generates system call bodies. -The prototypes are marked by lines beginning with "//sys" -and read like func declarations if //sys is replaced by func, but: - * The parameter lists must give a name for each argument. - This includes return parameters. - * The parameter lists must give a type for each argument: - the (x, y, z int) shorthand is not allowed. - * If the return parameter is an error number, it must be named errno. - -A line beginning with //sysnb is like //sys, except that the -goroutine will not be suspended during the execution of the system -call. This must only be used for system calls which can never -block, as otherwise the system call could cause all goroutines to -hang. -*/ -package main - -import ( - "bufio" - "flag" - "fmt" - "os" - "regexp" - "strings" -) - -var ( - b32 = flag.Bool("b32", false, "32bit big-endian") - l32 = flag.Bool("l32", false, "32bit little-endian") - plan9 = flag.Bool("plan9", false, "plan9") - openbsd = flag.Bool("openbsd", false, "openbsd") - netbsd = flag.Bool("netbsd", false, "netbsd") - dragonfly = flag.Bool("dragonfly", false, "dragonfly") - arm = flag.Bool("arm", false, "arm") // 64-bit value should use (even, odd)-pair - tags = flag.String("tags", "", "build tags") - filename = flag.String("output", "", "output file name (standard output if omitted)") -) - -// cmdLine returns this programs's commandline arguments -func cmdLine() string { - return "go run mksyscall.go " + strings.Join(os.Args[1:], " ") -} - -// buildTags returns build tags -func buildTags() string { - return *tags -} - -// Param is function parameter -type Param struct { - Name string - Type string -} - -// usage prints the program usage -func usage() { - fmt.Fprintf(os.Stderr, "usage: go run mksyscall.go [-b32 | -l32] [-tags x,y] [file ...]\n") - os.Exit(1) -} - -// parseParamList parses parameter list and returns a slice of parameters -func parseParamList(list string) []string { - list = strings.TrimSpace(list) - if list == "" { - return []string{} - } - return regexp.MustCompile(`\s*,\s*`).Split(list, -1) -} - -// parseParam splits a parameter into name and type -func parseParam(p string) Param { - ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p) - if ps == nil { - fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p) - os.Exit(1) - } - return Param{ps[1], ps[2]} -} - -func main() { - // Get the OS and architecture (using GOARCH_TARGET if it exists) - goos := os.Getenv("GOOS") - if goos == "" { - fmt.Fprintln(os.Stderr, "GOOS not defined in environment") - os.Exit(1) - } - goarch := os.Getenv("GOARCH_TARGET") - if goarch == "" { - goarch = os.Getenv("GOARCH") - } - - // Check that we are using the Docker-based build system if we should - if goos == "linux" { - if os.Getenv("GOLANG_SYS_BUILD") != "docker" { - fmt.Fprintf(os.Stderr, "In the Docker-based build system, mksyscall should not be called directly.\n") - fmt.Fprintf(os.Stderr, "See README.md\n") - os.Exit(1) - } - } - - flag.Usage = usage - flag.Parse() - if len(flag.Args()) <= 0 { - fmt.Fprintf(os.Stderr, "no files to parse provided\n") - usage() - } - - endianness := "" - if *b32 { - endianness = "big-endian" - } else if *l32 { - endianness = "little-endian" - } - - libc := false - if goos == "darwin" && strings.Contains(buildTags(), ",go1.12") { - libc = true - } - trampolines := map[string]bool{} - - text := "" - for _, path := range flag.Args() { - file, err := os.Open(path) - if err != nil { - fmt.Fprintf(os.Stderr, err.Error()) - os.Exit(1) - } - s := bufio.NewScanner(file) - for s.Scan() { - t := s.Text() - t = strings.TrimSpace(t) - t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `) - nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t) - if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil { - continue - } - - // Line must be of the form - // func Open(path string, mode int, perm int) (fd int, errno error) - // Split into name, in params, out params. - f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*((?i)SYS_[A-Z0-9_]+))?$`).FindStringSubmatch(t) - if f == nil { - fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t) - os.Exit(1) - } - funct, inps, outps, sysname := f[2], f[3], f[4], f[5] - - // ClockGettime doesn't have a syscall number on Darwin, only generate libc wrappers. - if goos == "darwin" && !libc && funct == "ClockGettime" { - continue - } - - // Split argument lists on comma. - in := parseParamList(inps) - out := parseParamList(outps) - - // Try in vain to keep people from editing this file. - // The theory is that they jump into the middle of the file - // without reading the header. - text += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n" - - // Go function header. - outDecl := "" - if len(out) > 0 { - outDecl = fmt.Sprintf(" (%s)", strings.Join(out, ", ")) - } - text += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outDecl) - - // Check if err return available - errvar := "" - for _, param := range out { - p := parseParam(param) - if p.Type == "error" { - errvar = p.Name - break - } - } - - // Prepare arguments to Syscall. - var args []string - n := 0 - for _, param := range in { - p := parseParam(param) - if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil { - args = append(args, "uintptr(unsafe.Pointer("+p.Name+"))") - } else if p.Type == "string" && errvar != "" { - text += fmt.Sprintf("\tvar _p%d *byte\n", n) - text += fmt.Sprintf("\t_p%d, %s = BytePtrFromString(%s)\n", n, errvar, p.Name) - text += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar) - args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n)) - n++ - } else if p.Type == "string" { - fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n") - text += fmt.Sprintf("\tvar _p%d *byte\n", n) - text += fmt.Sprintf("\t_p%d, _ = BytePtrFromString(%s)\n", n, p.Name) - args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n)) - n++ - } else if regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type) != nil { - // Convert slice into pointer, length. - // Have to be careful not to take address of &a[0] if len == 0: - // pass dummy pointer in that case. - // Used to pass nil, but some OSes or simulators reject write(fd, nil, 0). - text += fmt.Sprintf("\tvar _p%d unsafe.Pointer\n", n) - text += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = unsafe.Pointer(&%s[0])\n\t}", p.Name, n, p.Name) - text += fmt.Sprintf(" else {\n\t\t_p%d = unsafe.Pointer(&_zero)\n\t}\n", n) - args = append(args, fmt.Sprintf("uintptr(_p%d)", n), fmt.Sprintf("uintptr(len(%s))", p.Name)) - n++ - } else if p.Type == "int64" && (*openbsd || *netbsd) { - args = append(args, "0") - if endianness == "big-endian" { - args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name)) - } else if endianness == "little-endian" { - args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name)) - } else { - args = append(args, fmt.Sprintf("uintptr(%s)", p.Name)) - } - } else if p.Type == "int64" && *dragonfly { - if regexp.MustCompile(`^(?i)extp(read|write)`).FindStringSubmatch(funct) == nil { - args = append(args, "0") - } - if endianness == "big-endian" { - args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name)) - } else if endianness == "little-endian" { - args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name)) - } else { - args = append(args, fmt.Sprintf("uintptr(%s)", p.Name)) - } - } else if (p.Type == "int64" || p.Type == "uint64") && endianness != "" { - if len(args)%2 == 1 && *arm { - // arm abi specifies 64-bit argument uses - // (even, odd) pair - args = append(args, "0") - } - if endianness == "big-endian" { - args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name)) - } else { - args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name)) - } - } else { - args = append(args, fmt.Sprintf("uintptr(%s)", p.Name)) - } - } - - // Determine which form to use; pad args with zeros. - asm := "Syscall" - if nonblock != nil { - if errvar == "" && goos == "linux" { - asm = "RawSyscallNoError" - } else { - asm = "RawSyscall" - } - } else { - if errvar == "" && goos == "linux" { - asm = "SyscallNoError" - } - } - if len(args) <= 3 { - for len(args) < 3 { - args = append(args, "0") - } - } else if len(args) <= 6 { - asm += "6" - for len(args) < 6 { - args = append(args, "0") - } - } else if len(args) <= 9 { - asm += "9" - for len(args) < 9 { - args = append(args, "0") - } - } else { - fmt.Fprintf(os.Stderr, "%s:%s too many arguments to system call\n", path, funct) - } - - // System call number. - if sysname == "" { - sysname = "SYS_" + funct - sysname = regexp.MustCompile(`([a-z])([A-Z])`).ReplaceAllString(sysname, `${1}_$2`) - sysname = strings.ToUpper(sysname) - } - - var libcFn string - if libc { - asm = "syscall_" + strings.ToLower(asm[:1]) + asm[1:] // internal syscall call - sysname = strings.TrimPrefix(sysname, "SYS_") // remove SYS_ - sysname = strings.ToLower(sysname) // lowercase - if sysname == "getdirentries64" { - // Special case - libSystem name and - // raw syscall name don't match. - sysname = "__getdirentries64" - } - libcFn = sysname - sysname = "funcPC(libc_" + sysname + "_trampoline)" - } - - // Actual call. - arglist := strings.Join(args, ", ") - call := fmt.Sprintf("%s(%s, %s)", asm, sysname, arglist) - - // Assign return values. - body := "" - ret := []string{"_", "_", "_"} - doErrno := false - for i := 0; i < len(out); i++ { - p := parseParam(out[i]) - reg := "" - if p.Name == "err" && !*plan9 { - reg = "e1" - ret[2] = reg - doErrno = true - } else if p.Name == "err" && *plan9 { - ret[0] = "r0" - ret[2] = "e1" - break - } else { - reg = fmt.Sprintf("r%d", i) - ret[i] = reg - } - if p.Type == "bool" { - reg = fmt.Sprintf("%s != 0", reg) - } - if p.Type == "int64" && endianness != "" { - // 64-bit number in r1:r0 or r0:r1. - if i+2 > len(out) { - fmt.Fprintf(os.Stderr, "%s:%s not enough registers for int64 return\n", path, funct) - } - if endianness == "big-endian" { - reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i, i+1) - } else { - reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i+1, i) - } - ret[i] = fmt.Sprintf("r%d", i) - ret[i+1] = fmt.Sprintf("r%d", i+1) - } - if reg != "e1" || *plan9 { - body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg) - } - } - if ret[0] == "_" && ret[1] == "_" && ret[2] == "_" { - text += fmt.Sprintf("\t%s\n", call) - } else { - if errvar == "" && goos == "linux" { - // raw syscall without error on Linux, see golang.org/issue/22924 - text += fmt.Sprintf("\t%s, %s := %s\n", ret[0], ret[1], call) - } else { - text += fmt.Sprintf("\t%s, %s, %s := %s\n", ret[0], ret[1], ret[2], call) - } - } - text += body - - if *plan9 && ret[2] == "e1" { - text += "\tif int32(r0) == -1 {\n" - text += "\t\terr = e1\n" - text += "\t}\n" - } else if doErrno { - text += "\tif e1 != 0 {\n" - text += "\t\terr = errnoErr(e1)\n" - text += "\t}\n" - } - text += "\treturn\n" - text += "}\n\n" - - if libc && !trampolines[libcFn] { - // some system calls share a trampoline, like read and readlen. - trampolines[libcFn] = true - // Declare assembly trampoline. - text += fmt.Sprintf("func libc_%s_trampoline()\n", libcFn) - // Assembly trampoline calls the libc_* function, which this magic - // redirects to use the function from libSystem. - text += fmt.Sprintf("//go:linkname libc_%s libc_%s\n", libcFn, libcFn) - text += fmt.Sprintf("//go:cgo_import_dynamic libc_%s %s \"/usr/lib/libSystem.B.dylib\"\n", libcFn, libcFn) - text += "\n" - } - } - if err := s.Err(); err != nil { - fmt.Fprintf(os.Stderr, err.Error()) - os.Exit(1) - } - file.Close() - } - fmt.Printf(srcTemplate, cmdLine(), buildTags(), text) -} - -const srcTemplate = `// %s -// Code generated by the command above; see README.md. DO NOT EDIT. - -// +build %s - -package unix - -import ( - "syscall" - "unsafe" -) - -var _ syscall.Errno - -%s -` diff --git a/vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go b/vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go deleted file mode 100644 index 3be3cdfc..00000000 --- a/vendor/golang.org/x/sys/unix/mksyscall_aix_ppc.go +++ /dev/null @@ -1,415 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -/* -This program reads a file containing function prototypes -(like syscall_aix.go) and generates system call bodies. -The prototypes are marked by lines beginning with "//sys" -and read like func declarations if //sys is replaced by func, but: - * The parameter lists must give a name for each argument. - This includes return parameters. - * The parameter lists must give a type for each argument: - the (x, y, z int) shorthand is not allowed. - * If the return parameter is an error number, it must be named err. - * If go func name needs to be different than its libc name, - * or the function is not in libc, name could be specified - * at the end, after "=" sign, like - //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt -*/ -package main - -import ( - "bufio" - "flag" - "fmt" - "os" - "regexp" - "strings" -) - -var ( - b32 = flag.Bool("b32", false, "32bit big-endian") - l32 = flag.Bool("l32", false, "32bit little-endian") - aix = flag.Bool("aix", false, "aix") - tags = flag.String("tags", "", "build tags") -) - -// cmdLine returns this programs's commandline arguments -func cmdLine() string { - return "go run mksyscall_aix_ppc.go " + strings.Join(os.Args[1:], " ") -} - -// buildTags returns build tags -func buildTags() string { - return *tags -} - -// Param is function parameter -type Param struct { - Name string - Type string -} - -// usage prints the program usage -func usage() { - fmt.Fprintf(os.Stderr, "usage: go run mksyscall_aix_ppc.go [-b32 | -l32] [-tags x,y] [file ...]\n") - os.Exit(1) -} - -// parseParamList parses parameter list and returns a slice of parameters -func parseParamList(list string) []string { - list = strings.TrimSpace(list) - if list == "" { - return []string{} - } - return regexp.MustCompile(`\s*,\s*`).Split(list, -1) -} - -// parseParam splits a parameter into name and type -func parseParam(p string) Param { - ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p) - if ps == nil { - fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p) - os.Exit(1) - } - return Param{ps[1], ps[2]} -} - -func main() { - flag.Usage = usage - flag.Parse() - if len(flag.Args()) <= 0 { - fmt.Fprintf(os.Stderr, "no files to parse provided\n") - usage() - } - - endianness := "" - if *b32 { - endianness = "big-endian" - } else if *l32 { - endianness = "little-endian" - } - - pack := "" - text := "" - cExtern := "/*\n#include \n#include \n" - for _, path := range flag.Args() { - file, err := os.Open(path) - if err != nil { - fmt.Fprintf(os.Stderr, err.Error()) - os.Exit(1) - } - s := bufio.NewScanner(file) - for s.Scan() { - t := s.Text() - t = strings.TrimSpace(t) - t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `) - if p := regexp.MustCompile(`^package (\S+)$`).FindStringSubmatch(t); p != nil && pack == "" { - pack = p[1] - } - nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t) - if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil { - continue - } - - // Line must be of the form - // func Open(path string, mode int, perm int) (fd int, err error) - // Split into name, in params, out params. - f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$`).FindStringSubmatch(t) - if f == nil { - fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t) - os.Exit(1) - } - funct, inps, outps, modname, sysname := f[2], f[3], f[4], f[5], f[6] - - // Split argument lists on comma. - in := parseParamList(inps) - out := parseParamList(outps) - - inps = strings.Join(in, ", ") - outps = strings.Join(out, ", ") - - // Try in vain to keep people from editing this file. - // The theory is that they jump into the middle of the file - // without reading the header. - text += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n" - - // Check if value return, err return available - errvar := "" - retvar := "" - rettype := "" - for _, param := range out { - p := parseParam(param) - if p.Type == "error" { - errvar = p.Name - } else { - retvar = p.Name - rettype = p.Type - } - } - - // System call name. - if sysname == "" { - sysname = funct - } - sysname = regexp.MustCompile(`([a-z])([A-Z])`).ReplaceAllString(sysname, `${1}_$2`) - sysname = strings.ToLower(sysname) // All libc functions are lowercase. - - cRettype := "" - if rettype == "unsafe.Pointer" { - cRettype = "uintptr_t" - } else if rettype == "uintptr" { - cRettype = "uintptr_t" - } else if regexp.MustCompile(`^_`).FindStringSubmatch(rettype) != nil { - cRettype = "uintptr_t" - } else if rettype == "int" { - cRettype = "int" - } else if rettype == "int32" { - cRettype = "int" - } else if rettype == "int64" { - cRettype = "long long" - } else if rettype == "uint32" { - cRettype = "unsigned int" - } else if rettype == "uint64" { - cRettype = "unsigned long long" - } else { - cRettype = "int" - } - if sysname == "exit" { - cRettype = "void" - } - - // Change p.Types to c - var cIn []string - for _, param := range in { - p := parseParam(param) - if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil { - cIn = append(cIn, "uintptr_t") - } else if p.Type == "string" { - cIn = append(cIn, "uintptr_t") - } else if regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type) != nil { - cIn = append(cIn, "uintptr_t", "size_t") - } else if p.Type == "unsafe.Pointer" { - cIn = append(cIn, "uintptr_t") - } else if p.Type == "uintptr" { - cIn = append(cIn, "uintptr_t") - } else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil { - cIn = append(cIn, "uintptr_t") - } else if p.Type == "int" { - cIn = append(cIn, "int") - } else if p.Type == "int32" { - cIn = append(cIn, "int") - } else if p.Type == "int64" { - cIn = append(cIn, "long long") - } else if p.Type == "uint32" { - cIn = append(cIn, "unsigned int") - } else if p.Type == "uint64" { - cIn = append(cIn, "unsigned long long") - } else { - cIn = append(cIn, "int") - } - } - - if funct != "fcntl" && funct != "FcntlInt" && funct != "readlen" && funct != "writelen" { - if sysname == "select" { - // select is a keyword of Go. Its name is - // changed to c_select. - cExtern += "#define c_select select\n" - } - // Imports of system calls from libc - cExtern += fmt.Sprintf("%s %s", cRettype, sysname) - cIn := strings.Join(cIn, ", ") - cExtern += fmt.Sprintf("(%s);\n", cIn) - } - - // So file name. - if *aix { - if modname == "" { - modname = "libc.a/shr_64.o" - } else { - fmt.Fprintf(os.Stderr, "%s: only syscall using libc are available\n", funct) - os.Exit(1) - } - } - - strconvfunc := "C.CString" - - // Go function header. - if outps != "" { - outps = fmt.Sprintf(" (%s)", outps) - } - if text != "" { - text += "\n" - } - - text += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outps) - - // Prepare arguments to Syscall. - var args []string - n := 0 - argN := 0 - for _, param := range in { - p := parseParam(param) - if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil { - args = append(args, "C.uintptr_t(uintptr(unsafe.Pointer("+p.Name+")))") - } else if p.Type == "string" && errvar != "" { - text += fmt.Sprintf("\t_p%d := uintptr(unsafe.Pointer(%s(%s)))\n", n, strconvfunc, p.Name) - args = append(args, fmt.Sprintf("C.uintptr_t(_p%d)", n)) - n++ - } else if p.Type == "string" { - fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n") - text += fmt.Sprintf("\t_p%d := uintptr(unsafe.Pointer(%s(%s)))\n", n, strconvfunc, p.Name) - args = append(args, fmt.Sprintf("C.uintptr_t(_p%d)", n)) - n++ - } else if m := regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type); m != nil { - // Convert slice into pointer, length. - // Have to be careful not to take address of &a[0] if len == 0: - // pass nil in that case. - text += fmt.Sprintf("\tvar _p%d *%s\n", n, m[1]) - text += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = &%s[0]\n\t}\n", p.Name, n, p.Name) - args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(unsafe.Pointer(_p%d)))", n)) - n++ - text += fmt.Sprintf("\tvar _p%d int\n", n) - text += fmt.Sprintf("\t_p%d = len(%s)\n", n, p.Name) - args = append(args, fmt.Sprintf("C.size_t(_p%d)", n)) - n++ - } else if p.Type == "int64" && endianness != "" { - if endianness == "big-endian" { - args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name)) - } else { - args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name)) - } - n++ - } else if p.Type == "bool" { - text += fmt.Sprintf("\tvar _p%d uint32\n", n) - text += fmt.Sprintf("\tif %s {\n\t\t_p%d = 1\n\t} else {\n\t\t_p%d = 0\n\t}\n", p.Name, n, n) - args = append(args, fmt.Sprintf("_p%d", n)) - } else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil { - args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(%s))", p.Name)) - } else if p.Type == "unsafe.Pointer" { - args = append(args, fmt.Sprintf("C.uintptr_t(uintptr(%s))", p.Name)) - } else if p.Type == "int" { - if (argN == 2) && ((funct == "readlen") || (funct == "writelen")) { - args = append(args, fmt.Sprintf("C.size_t(%s)", p.Name)) - } else if argN == 0 && funct == "fcntl" { - args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name)) - } else if (argN == 2) && ((funct == "fcntl") || (funct == "FcntlInt")) { - args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name)) - } else { - args = append(args, fmt.Sprintf("C.int(%s)", p.Name)) - } - } else if p.Type == "int32" { - args = append(args, fmt.Sprintf("C.int(%s)", p.Name)) - } else if p.Type == "int64" { - args = append(args, fmt.Sprintf("C.longlong(%s)", p.Name)) - } else if p.Type == "uint32" { - args = append(args, fmt.Sprintf("C.uint(%s)", p.Name)) - } else if p.Type == "uint64" { - args = append(args, fmt.Sprintf("C.ulonglong(%s)", p.Name)) - } else if p.Type == "uintptr" { - args = append(args, fmt.Sprintf("C.uintptr_t(%s)", p.Name)) - } else { - args = append(args, fmt.Sprintf("C.int(%s)", p.Name)) - } - argN++ - } - - // Actual call. - arglist := strings.Join(args, ", ") - call := "" - if sysname == "exit" { - if errvar != "" { - call += "er :=" - } else { - call += "" - } - } else if errvar != "" { - call += "r0,er :=" - } else if retvar != "" { - call += "r0,_ :=" - } else { - call += "" - } - if sysname == "select" { - // select is a keyword of Go. Its name is - // changed to c_select. - call += fmt.Sprintf("C.c_%s(%s)", sysname, arglist) - } else { - call += fmt.Sprintf("C.%s(%s)", sysname, arglist) - } - - // Assign return values. - body := "" - for i := 0; i < len(out); i++ { - p := parseParam(out[i]) - reg := "" - if p.Name == "err" { - reg = "e1" - } else { - reg = "r0" - } - if reg != "e1" { - body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg) - } - } - - // verify return - if sysname != "exit" && errvar != "" { - if regexp.MustCompile(`^uintptr`).FindStringSubmatch(cRettype) != nil { - body += "\tif (uintptr(r0) ==^uintptr(0) && er != nil) {\n" - body += fmt.Sprintf("\t\t%s = er\n", errvar) - body += "\t}\n" - } else { - body += "\tif (r0 ==-1 && er != nil) {\n" - body += fmt.Sprintf("\t\t%s = er\n", errvar) - body += "\t}\n" - } - } else if errvar != "" { - body += "\tif (er != nil) {\n" - body += fmt.Sprintf("\t\t%s = er\n", errvar) - body += "\t}\n" - } - - text += fmt.Sprintf("\t%s\n", call) - text += body - - text += "\treturn\n" - text += "}\n" - } - if err := s.Err(); err != nil { - fmt.Fprintf(os.Stderr, err.Error()) - os.Exit(1) - } - file.Close() - } - imp := "" - if pack != "unix" { - imp = "import \"golang.org/x/sys/unix\"\n" - - } - fmt.Printf(srcTemplate, cmdLine(), buildTags(), pack, cExtern, imp, text) -} - -const srcTemplate = `// %s -// Code generated by the command above; see README.md. DO NOT EDIT. - -// +build %s - -package %s - - -%s -*/ -import "C" -import ( - "unsafe" -) - - -%s - -%s -` diff --git a/vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.go b/vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.go deleted file mode 100644 index c9600995..00000000 --- a/vendor/golang.org/x/sys/unix/mksyscall_aix_ppc64.go +++ /dev/null @@ -1,614 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -/* -This program reads a file containing function prototypes -(like syscall_aix.go) and generates system call bodies. -The prototypes are marked by lines beginning with "//sys" -and read like func declarations if //sys is replaced by func, but: - * The parameter lists must give a name for each argument. - This includes return parameters. - * The parameter lists must give a type for each argument: - the (x, y, z int) shorthand is not allowed. - * If the return parameter is an error number, it must be named err. - * If go func name needs to be different than its libc name, - * or the function is not in libc, name could be specified - * at the end, after "=" sign, like - //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt - - -This program will generate three files and handle both gc and gccgo implementation: - - zsyscall_aix_ppc64.go: the common part of each implementation (error handler, pointer creation) - - zsyscall_aix_ppc64_gc.go: gc part with //go_cgo_import_dynamic and a call to syscall6 - - zsyscall_aix_ppc64_gccgo.go: gccgo part with C function and conversion to C type. - - The generated code looks like this - -zsyscall_aix_ppc64.go -func asyscall(...) (n int, err error) { - // Pointer Creation - r1, e1 := callasyscall(...) - // Type Conversion - // Error Handler - return -} - -zsyscall_aix_ppc64_gc.go -//go:cgo_import_dynamic libc_asyscall asyscall "libc.a/shr_64.o" -//go:linkname libc_asyscall libc_asyscall -var asyscall syscallFunc - -func callasyscall(...) (r1 uintptr, e1 Errno) { - r1, _, e1 = syscall6(uintptr(unsafe.Pointer(&libc_asyscall)), "nb_args", ... ) - return -} - -zsyscall_aix_ppc64_ggcgo.go - -// int asyscall(...) - -import "C" - -func callasyscall(...) (r1 uintptr, e1 Errno) { - r1 = uintptr(C.asyscall(...)) - e1 = syscall.GetErrno() - return -} -*/ - -package main - -import ( - "bufio" - "flag" - "fmt" - "io/ioutil" - "os" - "regexp" - "strings" -) - -var ( - b32 = flag.Bool("b32", false, "32bit big-endian") - l32 = flag.Bool("l32", false, "32bit little-endian") - aix = flag.Bool("aix", false, "aix") - tags = flag.String("tags", "", "build tags") -) - -// cmdLine returns this programs's commandline arguments -func cmdLine() string { - return "go run mksyscall_aix_ppc64.go " + strings.Join(os.Args[1:], " ") -} - -// buildTags returns build tags -func buildTags() string { - return *tags -} - -// Param is function parameter -type Param struct { - Name string - Type string -} - -// usage prints the program usage -func usage() { - fmt.Fprintf(os.Stderr, "usage: go run mksyscall_aix_ppc64.go [-b32 | -l32] [-tags x,y] [file ...]\n") - os.Exit(1) -} - -// parseParamList parses parameter list and returns a slice of parameters -func parseParamList(list string) []string { - list = strings.TrimSpace(list) - if list == "" { - return []string{} - } - return regexp.MustCompile(`\s*,\s*`).Split(list, -1) -} - -// parseParam splits a parameter into name and type -func parseParam(p string) Param { - ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p) - if ps == nil { - fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p) - os.Exit(1) - } - return Param{ps[1], ps[2]} -} - -func main() { - flag.Usage = usage - flag.Parse() - if len(flag.Args()) <= 0 { - fmt.Fprintf(os.Stderr, "no files to parse provided\n") - usage() - } - - endianness := "" - if *b32 { - endianness = "big-endian" - } else if *l32 { - endianness = "little-endian" - } - - pack := "" - // GCCGO - textgccgo := "" - cExtern := "/*\n#include \n" - // GC - textgc := "" - dynimports := "" - linknames := "" - var vars []string - // COMMON - textcommon := "" - for _, path := range flag.Args() { - file, err := os.Open(path) - if err != nil { - fmt.Fprintf(os.Stderr, err.Error()) - os.Exit(1) - } - s := bufio.NewScanner(file) - for s.Scan() { - t := s.Text() - t = strings.TrimSpace(t) - t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `) - if p := regexp.MustCompile(`^package (\S+)$`).FindStringSubmatch(t); p != nil && pack == "" { - pack = p[1] - } - nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t) - if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil { - continue - } - - // Line must be of the form - // func Open(path string, mode int, perm int) (fd int, err error) - // Split into name, in params, out params. - f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$`).FindStringSubmatch(t) - if f == nil { - fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t) - os.Exit(1) - } - funct, inps, outps, modname, sysname := f[2], f[3], f[4], f[5], f[6] - - // Split argument lists on comma. - in := parseParamList(inps) - out := parseParamList(outps) - - inps = strings.Join(in, ", ") - outps = strings.Join(out, ", ") - - if sysname == "" { - sysname = funct - } - - onlyCommon := false - if funct == "readlen" || funct == "writelen" || funct == "FcntlInt" || funct == "FcntlFlock" { - // This function call another syscall which is already implemented. - // Therefore, the gc and gccgo part must not be generated. - onlyCommon = true - } - - // Try in vain to keep people from editing this file. - // The theory is that they jump into the middle of the file - // without reading the header. - - textcommon += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n" - if !onlyCommon { - textgccgo += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n" - textgc += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n" - } - - // Check if value return, err return available - errvar := "" - rettype := "" - for _, param := range out { - p := parseParam(param) - if p.Type == "error" { - errvar = p.Name - } else { - rettype = p.Type - } - } - - sysname = regexp.MustCompile(`([a-z])([A-Z])`).ReplaceAllString(sysname, `${1}_$2`) - sysname = strings.ToLower(sysname) // All libc functions are lowercase. - - // GCCGO Prototype return type - cRettype := "" - if rettype == "unsafe.Pointer" { - cRettype = "uintptr_t" - } else if rettype == "uintptr" { - cRettype = "uintptr_t" - } else if regexp.MustCompile(`^_`).FindStringSubmatch(rettype) != nil { - cRettype = "uintptr_t" - } else if rettype == "int" { - cRettype = "int" - } else if rettype == "int32" { - cRettype = "int" - } else if rettype == "int64" { - cRettype = "long long" - } else if rettype == "uint32" { - cRettype = "unsigned int" - } else if rettype == "uint64" { - cRettype = "unsigned long long" - } else { - cRettype = "int" - } - if sysname == "exit" { - cRettype = "void" - } - - // GCCGO Prototype arguments type - var cIn []string - for i, param := range in { - p := parseParam(param) - if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil { - cIn = append(cIn, "uintptr_t") - } else if p.Type == "string" { - cIn = append(cIn, "uintptr_t") - } else if regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type) != nil { - cIn = append(cIn, "uintptr_t", "size_t") - } else if p.Type == "unsafe.Pointer" { - cIn = append(cIn, "uintptr_t") - } else if p.Type == "uintptr" { - cIn = append(cIn, "uintptr_t") - } else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil { - cIn = append(cIn, "uintptr_t") - } else if p.Type == "int" { - if (i == 0 || i == 2) && funct == "fcntl" { - // These fcntl arguments needs to be uintptr to be able to call FcntlInt and FcntlFlock - cIn = append(cIn, "uintptr_t") - } else { - cIn = append(cIn, "int") - } - - } else if p.Type == "int32" { - cIn = append(cIn, "int") - } else if p.Type == "int64" { - cIn = append(cIn, "long long") - } else if p.Type == "uint32" { - cIn = append(cIn, "unsigned int") - } else if p.Type == "uint64" { - cIn = append(cIn, "unsigned long long") - } else { - cIn = append(cIn, "int") - } - } - - if !onlyCommon { - // GCCGO Prototype Generation - // Imports of system calls from libc - if sysname == "select" { - // select is a keyword of Go. Its name is - // changed to c_select. - cExtern += "#define c_select select\n" - } - cExtern += fmt.Sprintf("%s %s", cRettype, sysname) - cIn := strings.Join(cIn, ", ") - cExtern += fmt.Sprintf("(%s);\n", cIn) - } - // GC Library name - if modname == "" { - modname = "libc.a/shr_64.o" - } else { - fmt.Fprintf(os.Stderr, "%s: only syscall using libc are available\n", funct) - os.Exit(1) - } - sysvarname := fmt.Sprintf("libc_%s", sysname) - - if !onlyCommon { - // GC Runtime import of function to allow cross-platform builds. - dynimports += fmt.Sprintf("//go:cgo_import_dynamic %s %s \"%s\"\n", sysvarname, sysname, modname) - // GC Link symbol to proc address variable. - linknames += fmt.Sprintf("//go:linkname %s %s\n", sysvarname, sysvarname) - // GC Library proc address variable. - vars = append(vars, sysvarname) - } - - strconvfunc := "BytePtrFromString" - strconvtype := "*byte" - - // Go function header. - if outps != "" { - outps = fmt.Sprintf(" (%s)", outps) - } - if textcommon != "" { - textcommon += "\n" - } - - textcommon += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outps) - - // Prepare arguments tocall. - var argscommon []string // Arguments in the common part - var argscall []string // Arguments for call prototype - var argsgc []string // Arguments for gc call (with syscall6) - var argsgccgo []string // Arguments for gccgo call (with C.name_of_syscall) - n := 0 - argN := 0 - for _, param := range in { - p := parseParam(param) - if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil { - argscommon = append(argscommon, fmt.Sprintf("uintptr(unsafe.Pointer(%s))", p.Name)) - argscall = append(argscall, fmt.Sprintf("%s uintptr", p.Name)) - argsgc = append(argsgc, p.Name) - argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(%s)", p.Name)) - } else if p.Type == "string" && errvar != "" { - textcommon += fmt.Sprintf("\tvar _p%d %s\n", n, strconvtype) - textcommon += fmt.Sprintf("\t_p%d, %s = %s(%s)\n", n, errvar, strconvfunc, p.Name) - textcommon += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar) - - argscommon = append(argscommon, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n)) - argscall = append(argscall, fmt.Sprintf("_p%d uintptr ", n)) - argsgc = append(argsgc, fmt.Sprintf("_p%d", n)) - argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(_p%d)", n)) - n++ - } else if p.Type == "string" { - fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n") - textcommon += fmt.Sprintf("\tvar _p%d %s\n", n, strconvtype) - textcommon += fmt.Sprintf("\t_p%d, %s = %s(%s)\n", n, errvar, strconvfunc, p.Name) - textcommon += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar) - - argscommon = append(argscommon, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n)) - argscall = append(argscall, fmt.Sprintf("_p%d uintptr", n)) - argsgc = append(argsgc, fmt.Sprintf("_p%d", n)) - argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(_p%d)", n)) - n++ - } else if m := regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type); m != nil { - // Convert slice into pointer, length. - // Have to be careful not to take address of &a[0] if len == 0: - // pass nil in that case. - textcommon += fmt.Sprintf("\tvar _p%d *%s\n", n, m[1]) - textcommon += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = &%s[0]\n\t}\n", p.Name, n, p.Name) - argscommon = append(argscommon, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n), fmt.Sprintf("len(%s)", p.Name)) - argscall = append(argscall, fmt.Sprintf("_p%d uintptr", n), fmt.Sprintf("_lenp%d int", n)) - argsgc = append(argsgc, fmt.Sprintf("_p%d", n), fmt.Sprintf("uintptr(_lenp%d)", n)) - argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(_p%d)", n), fmt.Sprintf("C.size_t(_lenp%d)", n)) - n++ - } else if p.Type == "int64" && endianness != "" { - fmt.Fprintf(os.Stderr, path+":"+funct+" uses int64 with 32 bits mode. Case not yet implemented\n") - } else if p.Type == "bool" { - fmt.Fprintf(os.Stderr, path+":"+funct+" uses bool. Case not yet implemented\n") - } else if regexp.MustCompile(`^_`).FindStringSubmatch(p.Type) != nil || p.Type == "unsafe.Pointer" { - argscommon = append(argscommon, fmt.Sprintf("uintptr(%s)", p.Name)) - argscall = append(argscall, fmt.Sprintf("%s uintptr", p.Name)) - argsgc = append(argsgc, p.Name) - argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(%s)", p.Name)) - } else if p.Type == "int" { - if (argN == 0 || argN == 2) && ((funct == "fcntl") || (funct == "FcntlInt") || (funct == "FcntlFlock")) { - // These fcntl arguments need to be uintptr to be able to call FcntlInt and FcntlFlock - argscommon = append(argscommon, fmt.Sprintf("uintptr(%s)", p.Name)) - argscall = append(argscall, fmt.Sprintf("%s uintptr", p.Name)) - argsgc = append(argsgc, p.Name) - argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(%s)", p.Name)) - - } else { - argscommon = append(argscommon, p.Name) - argscall = append(argscall, fmt.Sprintf("%s int", p.Name)) - argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name)) - argsgccgo = append(argsgccgo, fmt.Sprintf("C.int(%s)", p.Name)) - } - } else if p.Type == "int32" { - argscommon = append(argscommon, p.Name) - argscall = append(argscall, fmt.Sprintf("%s int32", p.Name)) - argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name)) - argsgccgo = append(argsgccgo, fmt.Sprintf("C.int(%s)", p.Name)) - } else if p.Type == "int64" { - argscommon = append(argscommon, p.Name) - argscall = append(argscall, fmt.Sprintf("%s int64", p.Name)) - argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name)) - argsgccgo = append(argsgccgo, fmt.Sprintf("C.longlong(%s)", p.Name)) - } else if p.Type == "uint32" { - argscommon = append(argscommon, p.Name) - argscall = append(argscall, fmt.Sprintf("%s uint32", p.Name)) - argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name)) - argsgccgo = append(argsgccgo, fmt.Sprintf("C.uint(%s)", p.Name)) - } else if p.Type == "uint64" { - argscommon = append(argscommon, p.Name) - argscall = append(argscall, fmt.Sprintf("%s uint64", p.Name)) - argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name)) - argsgccgo = append(argsgccgo, fmt.Sprintf("C.ulonglong(%s)", p.Name)) - } else if p.Type == "uintptr" { - argscommon = append(argscommon, p.Name) - argscall = append(argscall, fmt.Sprintf("%s uintptr", p.Name)) - argsgc = append(argsgc, p.Name) - argsgccgo = append(argsgccgo, fmt.Sprintf("C.uintptr_t(%s)", p.Name)) - } else { - argscommon = append(argscommon, fmt.Sprintf("int(%s)", p.Name)) - argscall = append(argscall, fmt.Sprintf("%s int", p.Name)) - argsgc = append(argsgc, fmt.Sprintf("uintptr(%s)", p.Name)) - argsgccgo = append(argsgccgo, fmt.Sprintf("C.int(%s)", p.Name)) - } - argN++ - } - nargs := len(argsgc) - - // COMMON function generation - argscommonlist := strings.Join(argscommon, ", ") - callcommon := fmt.Sprintf("call%s(%s)", sysname, argscommonlist) - ret := []string{"_", "_"} - body := "" - doErrno := false - for i := 0; i < len(out); i++ { - p := parseParam(out[i]) - reg := "" - if p.Name == "err" { - reg = "e1" - ret[1] = reg - doErrno = true - } else { - reg = "r0" - ret[0] = reg - } - if p.Type == "bool" { - reg = fmt.Sprintf("%s != 0", reg) - } - if reg != "e1" { - body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg) - } - } - if ret[0] == "_" && ret[1] == "_" { - textcommon += fmt.Sprintf("\t%s\n", callcommon) - } else { - textcommon += fmt.Sprintf("\t%s, %s := %s\n", ret[0], ret[1], callcommon) - } - textcommon += body - - if doErrno { - textcommon += "\tif e1 != 0 {\n" - textcommon += "\t\terr = errnoErr(e1)\n" - textcommon += "\t}\n" - } - textcommon += "\treturn\n" - textcommon += "}\n" - - if onlyCommon { - continue - } - - // CALL Prototype - callProto := fmt.Sprintf("func call%s(%s) (r1 uintptr, e1 Errno) {\n", sysname, strings.Join(argscall, ", ")) - - // GC function generation - asm := "syscall6" - if nonblock != nil { - asm = "rawSyscall6" - } - - if len(argsgc) <= 6 { - for len(argsgc) < 6 { - argsgc = append(argsgc, "0") - } - } else { - fmt.Fprintf(os.Stderr, "%s: too many arguments to system call", funct) - os.Exit(1) - } - argsgclist := strings.Join(argsgc, ", ") - callgc := fmt.Sprintf("%s(uintptr(unsafe.Pointer(&%s)), %d, %s)", asm, sysvarname, nargs, argsgclist) - - textgc += callProto - textgc += fmt.Sprintf("\tr1, _, e1 = %s\n", callgc) - textgc += "\treturn\n}\n" - - // GCCGO function generation - argsgccgolist := strings.Join(argsgccgo, ", ") - var callgccgo string - if sysname == "select" { - // select is a keyword of Go. Its name is - // changed to c_select. - callgccgo = fmt.Sprintf("C.c_%s(%s)", sysname, argsgccgolist) - } else { - callgccgo = fmt.Sprintf("C.%s(%s)", sysname, argsgccgolist) - } - textgccgo += callProto - textgccgo += fmt.Sprintf("\tr1 = uintptr(%s)\n", callgccgo) - textgccgo += "\te1 = syscall.GetErrno()\n" - textgccgo += "\treturn\n}\n" - } - if err := s.Err(); err != nil { - fmt.Fprintf(os.Stderr, err.Error()) - os.Exit(1) - } - file.Close() - } - imp := "" - if pack != "unix" { - imp = "import \"golang.org/x/sys/unix\"\n" - - } - - // Print zsyscall_aix_ppc64.go - err := ioutil.WriteFile("zsyscall_aix_ppc64.go", - []byte(fmt.Sprintf(srcTemplate1, cmdLine(), buildTags(), pack, imp, textcommon)), - 0644) - if err != nil { - fmt.Fprintf(os.Stderr, err.Error()) - os.Exit(1) - } - - // Print zsyscall_aix_ppc64_gc.go - vardecls := "\t" + strings.Join(vars, ",\n\t") - vardecls += " syscallFunc" - err = ioutil.WriteFile("zsyscall_aix_ppc64_gc.go", - []byte(fmt.Sprintf(srcTemplate2, cmdLine(), buildTags(), pack, imp, dynimports, linknames, vardecls, textgc)), - 0644) - if err != nil { - fmt.Fprintf(os.Stderr, err.Error()) - os.Exit(1) - } - - // Print zsyscall_aix_ppc64_gccgo.go - err = ioutil.WriteFile("zsyscall_aix_ppc64_gccgo.go", - []byte(fmt.Sprintf(srcTemplate3, cmdLine(), buildTags(), pack, cExtern, imp, textgccgo)), - 0644) - if err != nil { - fmt.Fprintf(os.Stderr, err.Error()) - os.Exit(1) - } -} - -const srcTemplate1 = `// %s -// Code generated by the command above; see README.md. DO NOT EDIT. - -// +build %s - -package %s - -import ( - "unsafe" -) - - -%s - -%s -` -const srcTemplate2 = `// %s -// Code generated by the command above; see README.md. DO NOT EDIT. - -// +build %s -// +build !gccgo - -package %s - -import ( - "unsafe" -) -%s -%s -%s -type syscallFunc uintptr - -var ( -%s -) - -// Implemented in runtime/syscall_aix.go. -func rawSyscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) -func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) - -%s -` -const srcTemplate3 = `// %s -// Code generated by the command above; see README.md. DO NOT EDIT. - -// +build %s -// +build gccgo - -package %s - -%s -*/ -import "C" -import ( - "syscall" -) - - -%s - -%s -` diff --git a/vendor/golang.org/x/sys/unix/mksyscall_solaris.go b/vendor/golang.org/x/sys/unix/mksyscall_solaris.go deleted file mode 100644 index 3d864738..00000000 --- a/vendor/golang.org/x/sys/unix/mksyscall_solaris.go +++ /dev/null @@ -1,335 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -/* - This program reads a file containing function prototypes - (like syscall_solaris.go) and generates system call bodies. - The prototypes are marked by lines beginning with "//sys" - and read like func declarations if //sys is replaced by func, but: - * The parameter lists must give a name for each argument. - This includes return parameters. - * The parameter lists must give a type for each argument: - the (x, y, z int) shorthand is not allowed. - * If the return parameter is an error number, it must be named err. - * If go func name needs to be different than its libc name, - * or the function is not in libc, name could be specified - * at the end, after "=" sign, like - //sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error) = libsocket.getsockopt -*/ - -package main - -import ( - "bufio" - "flag" - "fmt" - "os" - "regexp" - "strings" -) - -var ( - b32 = flag.Bool("b32", false, "32bit big-endian") - l32 = flag.Bool("l32", false, "32bit little-endian") - tags = flag.String("tags", "", "build tags") -) - -// cmdLine returns this programs's commandline arguments -func cmdLine() string { - return "go run mksyscall_solaris.go " + strings.Join(os.Args[1:], " ") -} - -// buildTags returns build tags -func buildTags() string { - return *tags -} - -// Param is function parameter -type Param struct { - Name string - Type string -} - -// usage prints the program usage -func usage() { - fmt.Fprintf(os.Stderr, "usage: go run mksyscall_solaris.go [-b32 | -l32] [-tags x,y] [file ...]\n") - os.Exit(1) -} - -// parseParamList parses parameter list and returns a slice of parameters -func parseParamList(list string) []string { - list = strings.TrimSpace(list) - if list == "" { - return []string{} - } - return regexp.MustCompile(`\s*,\s*`).Split(list, -1) -} - -// parseParam splits a parameter into name and type -func parseParam(p string) Param { - ps := regexp.MustCompile(`^(\S*) (\S*)$`).FindStringSubmatch(p) - if ps == nil { - fmt.Fprintf(os.Stderr, "malformed parameter: %s\n", p) - os.Exit(1) - } - return Param{ps[1], ps[2]} -} - -func main() { - flag.Usage = usage - flag.Parse() - if len(flag.Args()) <= 0 { - fmt.Fprintf(os.Stderr, "no files to parse provided\n") - usage() - } - - endianness := "" - if *b32 { - endianness = "big-endian" - } else if *l32 { - endianness = "little-endian" - } - - pack := "" - text := "" - dynimports := "" - linknames := "" - var vars []string - for _, path := range flag.Args() { - file, err := os.Open(path) - if err != nil { - fmt.Fprintf(os.Stderr, err.Error()) - os.Exit(1) - } - s := bufio.NewScanner(file) - for s.Scan() { - t := s.Text() - t = strings.TrimSpace(t) - t = regexp.MustCompile(`\s+`).ReplaceAllString(t, ` `) - if p := regexp.MustCompile(`^package (\S+)$`).FindStringSubmatch(t); p != nil && pack == "" { - pack = p[1] - } - nonblock := regexp.MustCompile(`^\/\/sysnb `).FindStringSubmatch(t) - if regexp.MustCompile(`^\/\/sys `).FindStringSubmatch(t) == nil && nonblock == nil { - continue - } - - // Line must be of the form - // func Open(path string, mode int, perm int) (fd int, err error) - // Split into name, in params, out params. - f := regexp.MustCompile(`^\/\/sys(nb)? (\w+)\(([^()]*)\)\s*(?:\(([^()]+)\))?\s*(?:=\s*(?:(\w*)\.)?(\w*))?$`).FindStringSubmatch(t) - if f == nil { - fmt.Fprintf(os.Stderr, "%s:%s\nmalformed //sys declaration\n", path, t) - os.Exit(1) - } - funct, inps, outps, modname, sysname := f[2], f[3], f[4], f[5], f[6] - - // Split argument lists on comma. - in := parseParamList(inps) - out := parseParamList(outps) - - inps = strings.Join(in, ", ") - outps = strings.Join(out, ", ") - - // Try in vain to keep people from editing this file. - // The theory is that they jump into the middle of the file - // without reading the header. - text += "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n" - - // So file name. - if modname == "" { - modname = "libc" - } - - // System call name. - if sysname == "" { - sysname = funct - } - - // System call pointer variable name. - sysvarname := fmt.Sprintf("proc%s", sysname) - - strconvfunc := "BytePtrFromString" - strconvtype := "*byte" - - sysname = strings.ToLower(sysname) // All libc functions are lowercase. - - // Runtime import of function to allow cross-platform builds. - dynimports += fmt.Sprintf("//go:cgo_import_dynamic libc_%s %s \"%s.so\"\n", sysname, sysname, modname) - // Link symbol to proc address variable. - linknames += fmt.Sprintf("//go:linkname %s libc_%s\n", sysvarname, sysname) - // Library proc address variable. - vars = append(vars, sysvarname) - - // Go function header. - outlist := strings.Join(out, ", ") - if outlist != "" { - outlist = fmt.Sprintf(" (%s)", outlist) - } - if text != "" { - text += "\n" - } - text += fmt.Sprintf("func %s(%s)%s {\n", funct, strings.Join(in, ", "), outlist) - - // Check if err return available - errvar := "" - for _, param := range out { - p := parseParam(param) - if p.Type == "error" { - errvar = p.Name - continue - } - } - - // Prepare arguments to Syscall. - var args []string - n := 0 - for _, param := range in { - p := parseParam(param) - if regexp.MustCompile(`^\*`).FindStringSubmatch(p.Type) != nil { - args = append(args, "uintptr(unsafe.Pointer("+p.Name+"))") - } else if p.Type == "string" && errvar != "" { - text += fmt.Sprintf("\tvar _p%d %s\n", n, strconvtype) - text += fmt.Sprintf("\t_p%d, %s = %s(%s)\n", n, errvar, strconvfunc, p.Name) - text += fmt.Sprintf("\tif %s != nil {\n\t\treturn\n\t}\n", errvar) - args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n)) - n++ - } else if p.Type == "string" { - fmt.Fprintf(os.Stderr, path+":"+funct+" uses string arguments, but has no error return\n") - text += fmt.Sprintf("\tvar _p%d %s\n", n, strconvtype) - text += fmt.Sprintf("\t_p%d, _ = %s(%s)\n", n, strconvfunc, p.Name) - args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n)) - n++ - } else if s := regexp.MustCompile(`^\[\](.*)`).FindStringSubmatch(p.Type); s != nil { - // Convert slice into pointer, length. - // Have to be careful not to take address of &a[0] if len == 0: - // pass nil in that case. - text += fmt.Sprintf("\tvar _p%d *%s\n", n, s[1]) - text += fmt.Sprintf("\tif len(%s) > 0 {\n\t\t_p%d = &%s[0]\n\t}\n", p.Name, n, p.Name) - args = append(args, fmt.Sprintf("uintptr(unsafe.Pointer(_p%d))", n), fmt.Sprintf("uintptr(len(%s))", p.Name)) - n++ - } else if p.Type == "int64" && endianness != "" { - if endianness == "big-endian" { - args = append(args, fmt.Sprintf("uintptr(%s>>32)", p.Name), fmt.Sprintf("uintptr(%s)", p.Name)) - } else { - args = append(args, fmt.Sprintf("uintptr(%s)", p.Name), fmt.Sprintf("uintptr(%s>>32)", p.Name)) - } - } else if p.Type == "bool" { - text += fmt.Sprintf("\tvar _p%d uint32\n", n) - text += fmt.Sprintf("\tif %s {\n\t\t_p%d = 1\n\t} else {\n\t\t_p%d = 0\n\t}\n", p.Name, n, n) - args = append(args, fmt.Sprintf("uintptr(_p%d)", n)) - n++ - } else { - args = append(args, fmt.Sprintf("uintptr(%s)", p.Name)) - } - } - nargs := len(args) - - // Determine which form to use; pad args with zeros. - asm := "sysvicall6" - if nonblock != nil { - asm = "rawSysvicall6" - } - if len(args) <= 6 { - for len(args) < 6 { - args = append(args, "0") - } - } else { - fmt.Fprintf(os.Stderr, "%s: too many arguments to system call\n", path) - os.Exit(1) - } - - // Actual call. - arglist := strings.Join(args, ", ") - call := fmt.Sprintf("%s(uintptr(unsafe.Pointer(&%s)), %d, %s)", asm, sysvarname, nargs, arglist) - - // Assign return values. - body := "" - ret := []string{"_", "_", "_"} - doErrno := false - for i := 0; i < len(out); i++ { - p := parseParam(out[i]) - reg := "" - if p.Name == "err" { - reg = "e1" - ret[2] = reg - doErrno = true - } else { - reg = fmt.Sprintf("r%d", i) - ret[i] = reg - } - if p.Type == "bool" { - reg = fmt.Sprintf("%d != 0", reg) - } - if p.Type == "int64" && endianness != "" { - // 64-bit number in r1:r0 or r0:r1. - if i+2 > len(out) { - fmt.Fprintf(os.Stderr, "%s: not enough registers for int64 return\n", path) - os.Exit(1) - } - if endianness == "big-endian" { - reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i, i+1) - } else { - reg = fmt.Sprintf("int64(r%d)<<32 | int64(r%d)", i+1, i) - } - ret[i] = fmt.Sprintf("r%d", i) - ret[i+1] = fmt.Sprintf("r%d", i+1) - } - if reg != "e1" { - body += fmt.Sprintf("\t%s = %s(%s)\n", p.Name, p.Type, reg) - } - } - if ret[0] == "_" && ret[1] == "_" && ret[2] == "_" { - text += fmt.Sprintf("\t%s\n", call) - } else { - text += fmt.Sprintf("\t%s, %s, %s := %s\n", ret[0], ret[1], ret[2], call) - } - text += body - - if doErrno { - text += "\tif e1 != 0 {\n" - text += "\t\terr = e1\n" - text += "\t}\n" - } - text += "\treturn\n" - text += "}\n" - } - if err := s.Err(); err != nil { - fmt.Fprintf(os.Stderr, err.Error()) - os.Exit(1) - } - file.Close() - } - imp := "" - if pack != "unix" { - imp = "import \"golang.org/x/sys/unix\"\n" - - } - vardecls := "\t" + strings.Join(vars, ",\n\t") - vardecls += " syscallFunc" - fmt.Printf(srcTemplate, cmdLine(), buildTags(), pack, imp, dynimports, linknames, vardecls, text) -} - -const srcTemplate = `// %s -// Code generated by the command above; see README.md. DO NOT EDIT. - -// +build %s - -package %s - -import ( - "syscall" - "unsafe" -) -%s -%s -%s -var ( -%s -) - -%s -` diff --git a/vendor/golang.org/x/sys/unix/mksysctl_openbsd.go b/vendor/golang.org/x/sys/unix/mksysctl_openbsd.go deleted file mode 100644 index b6b40990..00000000 --- a/vendor/golang.org/x/sys/unix/mksysctl_openbsd.go +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright 2019 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// Parse the header files for OpenBSD and generate a Go usable sysctl MIB. -// -// Build a MIB with each entry being an array containing the level, type and -// a hash that will contain additional entries if the current entry is a node. -// We then walk this MIB and create a flattened sysctl name to OID hash. - -package main - -import ( - "bufio" - "fmt" - "os" - "path/filepath" - "regexp" - "sort" - "strings" -) - -var ( - goos, goarch string -) - -// cmdLine returns this programs's commandline arguments. -func cmdLine() string { - return "go run mksysctl_openbsd.go " + strings.Join(os.Args[1:], " ") -} - -// buildTags returns build tags. -func buildTags() string { - return fmt.Sprintf("%s,%s", goarch, goos) -} - -// reMatch performs regular expression match and stores the substring slice to value pointed by m. -func reMatch(re *regexp.Regexp, str string, m *[]string) bool { - *m = re.FindStringSubmatch(str) - if *m != nil { - return true - } - return false -} - -type nodeElement struct { - n int - t string - pE *map[string]nodeElement -} - -var ( - debugEnabled bool - mib map[string]nodeElement - node *map[string]nodeElement - nodeMap map[string]string - sysCtl []string -) - -var ( - ctlNames1RE = regexp.MustCompile(`^#define\s+(CTL_NAMES)\s+{`) - ctlNames2RE = regexp.MustCompile(`^#define\s+(CTL_(.*)_NAMES)\s+{`) - ctlNames3RE = regexp.MustCompile(`^#define\s+((.*)CTL_NAMES)\s+{`) - netInetRE = regexp.MustCompile(`^netinet/`) - netInet6RE = regexp.MustCompile(`^netinet6/`) - netRE = regexp.MustCompile(`^net/`) - bracesRE = regexp.MustCompile(`{.*}`) - ctlTypeRE = regexp.MustCompile(`{\s+"(\w+)",\s+(CTLTYPE_[A-Z]+)\s+}`) - fsNetKernRE = regexp.MustCompile(`^(fs|net|kern)_`) -) - -func debug(s string) { - if debugEnabled { - fmt.Fprintln(os.Stderr, s) - } -} - -// Walk the MIB and build a sysctl name to OID mapping. -func buildSysctl(pNode *map[string]nodeElement, name string, oid []int) { - lNode := pNode // local copy of pointer to node - var keys []string - for k := range *lNode { - keys = append(keys, k) - } - sort.Strings(keys) - - for _, key := range keys { - nodename := name - if name != "" { - nodename += "." - } - nodename += key - - nodeoid := append(oid, (*pNode)[key].n) - - if (*pNode)[key].t == `CTLTYPE_NODE` { - if _, ok := nodeMap[nodename]; ok { - lNode = &mib - ctlName := nodeMap[nodename] - for _, part := range strings.Split(ctlName, ".") { - lNode = ((*lNode)[part]).pE - } - } else { - lNode = (*pNode)[key].pE - } - buildSysctl(lNode, nodename, nodeoid) - } else if (*pNode)[key].t != "" { - oidStr := []string{} - for j := range nodeoid { - oidStr = append(oidStr, fmt.Sprintf("%d", nodeoid[j])) - } - text := "\t{ \"" + nodename + "\", []_C_int{ " + strings.Join(oidStr, ", ") + " } }, \n" - sysCtl = append(sysCtl, text) - } - } -} - -func main() { - // Get the OS (using GOOS_TARGET if it exist) - goos = os.Getenv("GOOS_TARGET") - if goos == "" { - goos = os.Getenv("GOOS") - } - // Get the architecture (using GOARCH_TARGET if it exists) - goarch = os.Getenv("GOARCH_TARGET") - if goarch == "" { - goarch = os.Getenv("GOARCH") - } - // Check if GOOS and GOARCH environment variables are defined - if goarch == "" || goos == "" { - fmt.Fprintf(os.Stderr, "GOARCH or GOOS not defined in environment\n") - os.Exit(1) - } - - mib = make(map[string]nodeElement) - headers := [...]string{ - `sys/sysctl.h`, - `sys/socket.h`, - `sys/tty.h`, - `sys/malloc.h`, - `sys/mount.h`, - `sys/namei.h`, - `sys/sem.h`, - `sys/shm.h`, - `sys/vmmeter.h`, - `uvm/uvmexp.h`, - `uvm/uvm_param.h`, - `uvm/uvm_swap_encrypt.h`, - `ddb/db_var.h`, - `net/if.h`, - `net/if_pfsync.h`, - `net/pipex.h`, - `netinet/in.h`, - `netinet/icmp_var.h`, - `netinet/igmp_var.h`, - `netinet/ip_ah.h`, - `netinet/ip_carp.h`, - `netinet/ip_divert.h`, - `netinet/ip_esp.h`, - `netinet/ip_ether.h`, - `netinet/ip_gre.h`, - `netinet/ip_ipcomp.h`, - `netinet/ip_ipip.h`, - `netinet/pim_var.h`, - `netinet/tcp_var.h`, - `netinet/udp_var.h`, - `netinet6/in6.h`, - `netinet6/ip6_divert.h`, - `netinet6/pim6_var.h`, - `netinet/icmp6.h`, - `netmpls/mpls.h`, - } - - ctls := [...]string{ - `kern`, - `vm`, - `fs`, - `net`, - //debug /* Special handling required */ - `hw`, - //machdep /* Arch specific */ - `user`, - `ddb`, - //vfs /* Special handling required */ - `fs.posix`, - `kern.forkstat`, - `kern.intrcnt`, - `kern.malloc`, - `kern.nchstats`, - `kern.seminfo`, - `kern.shminfo`, - `kern.timecounter`, - `kern.tty`, - `kern.watchdog`, - `net.bpf`, - `net.ifq`, - `net.inet`, - `net.inet.ah`, - `net.inet.carp`, - `net.inet.divert`, - `net.inet.esp`, - `net.inet.etherip`, - `net.inet.gre`, - `net.inet.icmp`, - `net.inet.igmp`, - `net.inet.ip`, - `net.inet.ip.ifq`, - `net.inet.ipcomp`, - `net.inet.ipip`, - `net.inet.mobileip`, - `net.inet.pfsync`, - `net.inet.pim`, - `net.inet.tcp`, - `net.inet.udp`, - `net.inet6`, - `net.inet6.divert`, - `net.inet6.ip6`, - `net.inet6.icmp6`, - `net.inet6.pim6`, - `net.inet6.tcp6`, - `net.inet6.udp6`, - `net.mpls`, - `net.mpls.ifq`, - `net.key`, - `net.pflow`, - `net.pfsync`, - `net.pipex`, - `net.rt`, - `vm.swapencrypt`, - //vfsgenctl /* Special handling required */ - } - - // Node name "fixups" - ctlMap := map[string]string{ - "ipproto": "net.inet", - "net.inet.ipproto": "net.inet", - "net.inet6.ipv6proto": "net.inet6", - "net.inet6.ipv6": "net.inet6.ip6", - "net.inet.icmpv6": "net.inet6.icmp6", - "net.inet6.divert6": "net.inet6.divert", - "net.inet6.tcp6": "net.inet.tcp", - "net.inet6.udp6": "net.inet.udp", - "mpls": "net.mpls", - "swpenc": "vm.swapencrypt", - } - - // Node mappings - nodeMap = map[string]string{ - "net.inet.ip.ifq": "net.ifq", - "net.inet.pfsync": "net.pfsync", - "net.mpls.ifq": "net.ifq", - } - - mCtls := make(map[string]bool) - for _, ctl := range ctls { - mCtls[ctl] = true - } - - for _, header := range headers { - debug("Processing " + header) - file, err := os.Open(filepath.Join("/usr/include", header)) - if err != nil { - fmt.Fprintf(os.Stderr, "%v\n", err) - os.Exit(1) - } - s := bufio.NewScanner(file) - for s.Scan() { - var sub []string - if reMatch(ctlNames1RE, s.Text(), &sub) || - reMatch(ctlNames2RE, s.Text(), &sub) || - reMatch(ctlNames3RE, s.Text(), &sub) { - if sub[1] == `CTL_NAMES` { - // Top level. - node = &mib - } else { - // Node. - nodename := strings.ToLower(sub[2]) - ctlName := "" - if reMatch(netInetRE, header, &sub) { - ctlName = "net.inet." + nodename - } else if reMatch(netInet6RE, header, &sub) { - ctlName = "net.inet6." + nodename - } else if reMatch(netRE, header, &sub) { - ctlName = "net." + nodename - } else { - ctlName = nodename - ctlName = fsNetKernRE.ReplaceAllString(ctlName, `$1.`) - } - - if val, ok := ctlMap[ctlName]; ok { - ctlName = val - } - if _, ok := mCtls[ctlName]; !ok { - debug("Ignoring " + ctlName + "...") - continue - } - - // Walk down from the top of the MIB. - node = &mib - for _, part := range strings.Split(ctlName, ".") { - if _, ok := (*node)[part]; !ok { - debug("Missing node " + part) - (*node)[part] = nodeElement{n: 0, t: "", pE: &map[string]nodeElement{}} - } - node = (*node)[part].pE - } - } - - // Populate current node with entries. - i := -1 - for !strings.HasPrefix(s.Text(), "}") { - s.Scan() - if reMatch(bracesRE, s.Text(), &sub) { - i++ - } - if !reMatch(ctlTypeRE, s.Text(), &sub) { - continue - } - (*node)[sub[1]] = nodeElement{n: i, t: sub[2], pE: &map[string]nodeElement{}} - } - } - } - err = s.Err() - if err != nil { - fmt.Fprintf(os.Stderr, "%v\n", err) - os.Exit(1) - } - file.Close() - } - buildSysctl(&mib, "", []int{}) - - sort.Strings(sysCtl) - text := strings.Join(sysCtl, "") - - fmt.Printf(srcTemplate, cmdLine(), buildTags(), text) -} - -const srcTemplate = `// %s -// Code generated by the command above; DO NOT EDIT. - -// +build %s - -package unix - -type mibentry struct { - ctlname string - ctloid []_C_int -} - -var sysctlMib = []mibentry { -%s -} -` diff --git a/vendor/golang.org/x/sys/unix/mksysnum.go b/vendor/golang.org/x/sys/unix/mksysnum.go deleted file mode 100644 index baa6ecd8..00000000 --- a/vendor/golang.org/x/sys/unix/mksysnum.go +++ /dev/null @@ -1,190 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// Generate system call table for DragonFly, NetBSD, -// FreeBSD, OpenBSD or Darwin from master list -// (for example, /usr/src/sys/kern/syscalls.master or -// sys/syscall.h). -package main - -import ( - "bufio" - "fmt" - "io" - "io/ioutil" - "net/http" - "os" - "regexp" - "strings" -) - -var ( - goos, goarch string -) - -// cmdLine returns this programs's commandline arguments -func cmdLine() string { - return "go run mksysnum.go " + strings.Join(os.Args[1:], " ") -} - -// buildTags returns build tags -func buildTags() string { - return fmt.Sprintf("%s,%s", goarch, goos) -} - -func checkErr(err error) { - if err != nil { - fmt.Fprintf(os.Stderr, "%v\n", err) - os.Exit(1) - } -} - -// source string and substring slice for regexp -type re struct { - str string // source string - sub []string // matched sub-string -} - -// Match performs regular expression match -func (r *re) Match(exp string) bool { - r.sub = regexp.MustCompile(exp).FindStringSubmatch(r.str) - if r.sub != nil { - return true - } - return false -} - -// fetchFile fetches a text file from URL -func fetchFile(URL string) io.Reader { - resp, err := http.Get(URL) - checkErr(err) - defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) - checkErr(err) - return strings.NewReader(string(body)) -} - -// readFile reads a text file from path -func readFile(path string) io.Reader { - file, err := os.Open(os.Args[1]) - checkErr(err) - return file -} - -func format(name, num, proto string) string { - name = strings.ToUpper(name) - // There are multiple entries for enosys and nosys, so comment them out. - nm := re{str: name} - if nm.Match(`^SYS_E?NOSYS$`) { - name = fmt.Sprintf("// %s", name) - } - if name == `SYS_SYS_EXIT` { - name = `SYS_EXIT` - } - return fmt.Sprintf(" %s = %s; // %s\n", name, num, proto) -} - -func main() { - // Get the OS (using GOOS_TARGET if it exist) - goos = os.Getenv("GOOS_TARGET") - if goos == "" { - goos = os.Getenv("GOOS") - } - // Get the architecture (using GOARCH_TARGET if it exists) - goarch = os.Getenv("GOARCH_TARGET") - if goarch == "" { - goarch = os.Getenv("GOARCH") - } - // Check if GOOS and GOARCH environment variables are defined - if goarch == "" || goos == "" { - fmt.Fprintf(os.Stderr, "GOARCH or GOOS not defined in environment\n") - os.Exit(1) - } - - file := strings.TrimSpace(os.Args[1]) - var syscalls io.Reader - if strings.HasPrefix(file, "https://") || strings.HasPrefix(file, "http://") { - // Download syscalls.master file - syscalls = fetchFile(file) - } else { - syscalls = readFile(file) - } - - var text, line string - s := bufio.NewScanner(syscalls) - for s.Scan() { - t := re{str: line} - if t.Match(`^(.*)\\$`) { - // Handle continuation - line = t.sub[1] - line += strings.TrimLeft(s.Text(), " \t") - } else { - // New line - line = s.Text() - } - t = re{str: line} - if t.Match(`\\$`) { - continue - } - t = re{str: line} - - switch goos { - case "dragonfly": - if t.Match(`^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$`) { - num, proto := t.sub[1], t.sub[2] - name := fmt.Sprintf("SYS_%s", t.sub[3]) - text += format(name, num, proto) - } - case "freebsd": - if t.Match(`^([0-9]+)\s+\S+\s+(?:(?:NO)?STD|COMPAT10)\s+({ \S+\s+(\w+).*)$`) { - num, proto := t.sub[1], t.sub[2] - name := fmt.Sprintf("SYS_%s", t.sub[3]) - text += format(name, num, proto) - } - case "openbsd": - if t.Match(`^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$`) { - num, proto, name := t.sub[1], t.sub[3], t.sub[4] - text += format(name, num, proto) - } - case "netbsd": - if t.Match(`^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$`) { - num, proto, compat := t.sub[1], t.sub[6], t.sub[8] - name := t.sub[7] + "_" + t.sub[9] - if t.sub[11] != "" { - name = t.sub[7] + "_" + t.sub[11] - } - name = strings.ToUpper(name) - if compat == "" || compat == "13" || compat == "30" || compat == "50" { - text += fmt.Sprintf(" %s = %s; // %s\n", name, num, proto) - } - } - case "darwin": - if t.Match(`^#define\s+SYS_(\w+)\s+([0-9]+)`) { - name, num := t.sub[1], t.sub[2] - name = strings.ToUpper(name) - text += fmt.Sprintf(" SYS_%s = %s;\n", name, num) - } - default: - fmt.Fprintf(os.Stderr, "unrecognized GOOS=%s\n", goos) - os.Exit(1) - - } - } - err := s.Err() - checkErr(err) - - fmt.Printf(template, cmdLine(), buildTags(), text) -} - -const template = `// %s -// Code generated by the command above; see README.md. DO NOT EDIT. - -// +build %s - -package unix - -const( -%s)` diff --git a/vendor/golang.org/x/sys/unix/types_aix.go b/vendor/golang.org/x/sys/unix/types_aix.go deleted file mode 100644 index 40d2beed..00000000 --- a/vendor/golang.org/x/sys/unix/types_aix.go +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore -// +build aix - -/* -Input to cgo -godefs. See also mkerrors.sh and mkall.sh -*/ - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package unix - -/* -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - - -#include -#include - -enum { - sizeofPtr = sizeof(void*), -}; - -union sockaddr_all { - struct sockaddr s1; // this one gets used for fields - struct sockaddr_in s2; // these pad it out - struct sockaddr_in6 s3; - struct sockaddr_un s4; - struct sockaddr_dl s5; -}; - -struct sockaddr_any { - struct sockaddr addr; - char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; -}; - -*/ -import "C" - -// Machine characteristics - -const ( - SizeofPtr = C.sizeofPtr - SizeofShort = C.sizeof_short - SizeofInt = C.sizeof_int - SizeofLong = C.sizeof_long - SizeofLongLong = C.sizeof_longlong - PathMax = C.PATH_MAX -) - -// Basic types - -type ( - _C_short C.short - _C_int C.int - _C_long C.long - _C_long_long C.longlong -) - -type off64 C.off64_t -type off C.off_t -type Mode_t C.mode_t - -// Time - -type Timespec C.struct_timespec - -type Timeval C.struct_timeval - -type Timeval32 C.struct_timeval32 - -type Timex C.struct_timex - -type Time_t C.time_t - -type Tms C.struct_tms - -type Utimbuf C.struct_utimbuf - -type Timezone C.struct_timezone - -// Processes - -type Rusage C.struct_rusage - -type Rlimit C.struct_rlimit64 - -type Pid_t C.pid_t - -type _Gid_t C.gid_t - -type dev_t C.dev_t - -// Files - -type Stat_t C.struct_stat - -type StatxTimestamp C.struct_statx_timestamp - -type Statx_t C.struct_statx - -type Dirent C.struct_dirent - -// Sockets - -type RawSockaddrInet4 C.struct_sockaddr_in - -type RawSockaddrInet6 C.struct_sockaddr_in6 - -type RawSockaddrUnix C.struct_sockaddr_un - -type RawSockaddrDatalink C.struct_sockaddr_dl - -type RawSockaddr C.struct_sockaddr - -type RawSockaddrAny C.struct_sockaddr_any - -type _Socklen C.socklen_t - -type Cmsghdr C.struct_cmsghdr - -type ICMPv6Filter C.struct_icmp6_filter - -type Iovec C.struct_iovec - -type IPMreq C.struct_ip_mreq - -type IPv6Mreq C.struct_ipv6_mreq - -type IPv6MTUInfo C.struct_ip6_mtuinfo - -type Linger C.struct_linger - -type Msghdr C.struct_msghdr - -const ( - SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in - SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - SizeofSockaddrAny = C.sizeof_struct_sockaddr_any - SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un - SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl - SizeofLinger = C.sizeof_struct_linger - SizeofIPMreq = C.sizeof_struct_ip_mreq - SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo - SizeofMsghdr = C.sizeof_struct_msghdr - SizeofCmsghdr = C.sizeof_struct_cmsghdr - SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -// Routing and interface messages - -const ( - SizeofIfMsghdr = C.sizeof_struct_if_msghdr -) - -type IfMsgHdr C.struct_if_msghdr - -// Misc - -type FdSet C.fd_set - -type Utsname C.struct_utsname - -type Ustat_t C.struct_ustat - -type Sigset_t C.sigset_t - -const ( - AT_FDCWD = C.AT_FDCWD - AT_REMOVEDIR = C.AT_REMOVEDIR - AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW -) - -// Terminal handling - -type Termios C.struct_termios - -type Termio C.struct_termio - -type Winsize C.struct_winsize - -//poll - -type PollFd struct { - Fd int32 - Events uint16 - Revents uint16 -} - -const ( - POLLERR = C.POLLERR - POLLHUP = C.POLLHUP - POLLIN = C.POLLIN - POLLNVAL = C.POLLNVAL - POLLOUT = C.POLLOUT - POLLPRI = C.POLLPRI - POLLRDBAND = C.POLLRDBAND - POLLRDNORM = C.POLLRDNORM - POLLWRBAND = C.POLLWRBAND - POLLWRNORM = C.POLLWRNORM -) - -//flock_t - -type Flock_t C.struct_flock64 - -// Statfs - -type Fsid_t C.struct_fsid_t -type Fsid64_t C.struct_fsid64_t - -type Statfs_t C.struct_statfs - -const RNDGETENTCNT = 0x80045200 diff --git a/vendor/golang.org/x/sys/unix/types_darwin.go b/vendor/golang.org/x/sys/unix/types_darwin.go deleted file mode 100644 index 155c2e69..00000000 --- a/vendor/golang.org/x/sys/unix/types_darwin.go +++ /dev/null @@ -1,283 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -/* -Input to cgo -godefs. See README.md -*/ - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package unix - -/* -#define __DARWIN_UNIX03 0 -#define KERNEL -#define _DARWIN_USE_64_BIT_INODE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -enum { - sizeofPtr = sizeof(void*), -}; - -union sockaddr_all { - struct sockaddr s1; // this one gets used for fields - struct sockaddr_in s2; // these pad it out - struct sockaddr_in6 s3; - struct sockaddr_un s4; - struct sockaddr_dl s5; -}; - -struct sockaddr_any { - struct sockaddr addr; - char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; -}; - -*/ -import "C" - -// Machine characteristics - -const ( - SizeofPtr = C.sizeofPtr - SizeofShort = C.sizeof_short - SizeofInt = C.sizeof_int - SizeofLong = C.sizeof_long - SizeofLongLong = C.sizeof_longlong -) - -// Basic types - -type ( - _C_short C.short - _C_int C.int - _C_long C.long - _C_long_long C.longlong -) - -// Time - -type Timespec C.struct_timespec - -type Timeval C.struct_timeval - -type Timeval32 C.struct_timeval32 - -// Processes - -type Rusage C.struct_rusage - -type Rlimit C.struct_rlimit - -type _Gid_t C.gid_t - -// Files - -type Stat_t C.struct_stat64 - -type Statfs_t C.struct_statfs64 - -type Flock_t C.struct_flock - -type Fstore_t C.struct_fstore - -type Radvisory_t C.struct_radvisory - -type Fbootstraptransfer_t C.struct_fbootstraptransfer - -type Log2phys_t C.struct_log2phys - -type Fsid C.struct_fsid - -type Dirent C.struct_dirent - -// Sockets - -type RawSockaddrInet4 C.struct_sockaddr_in - -type RawSockaddrInet6 C.struct_sockaddr_in6 - -type RawSockaddrUnix C.struct_sockaddr_un - -type RawSockaddrDatalink C.struct_sockaddr_dl - -type RawSockaddr C.struct_sockaddr - -type RawSockaddrAny C.struct_sockaddr_any - -type _Socklen C.socklen_t - -type Linger C.struct_linger - -type Iovec C.struct_iovec - -type IPMreq C.struct_ip_mreq - -type IPv6Mreq C.struct_ipv6_mreq - -type Msghdr C.struct_msghdr - -type Cmsghdr C.struct_cmsghdr - -type Inet4Pktinfo C.struct_in_pktinfo - -type Inet6Pktinfo C.struct_in6_pktinfo - -type IPv6MTUInfo C.struct_ip6_mtuinfo - -type ICMPv6Filter C.struct_icmp6_filter - -const ( - SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in - SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - SizeofSockaddrAny = C.sizeof_struct_sockaddr_any - SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un - SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl - SizeofLinger = C.sizeof_struct_linger - SizeofIPMreq = C.sizeof_struct_ip_mreq - SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - SizeofMsghdr = C.sizeof_struct_msghdr - SizeofCmsghdr = C.sizeof_struct_cmsghdr - SizeofInet4Pktinfo = C.sizeof_struct_in_pktinfo - SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo - SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -// Ptrace requests - -const ( - PTRACE_TRACEME = C.PT_TRACE_ME - PTRACE_CONT = C.PT_CONTINUE - PTRACE_KILL = C.PT_KILL -) - -// Events (kqueue, kevent) - -type Kevent_t C.struct_kevent - -// Select - -type FdSet C.fd_set - -// Routing and interface messages - -const ( - SizeofIfMsghdr = C.sizeof_struct_if_msghdr - SizeofIfData = C.sizeof_struct_if_data - SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr - SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr - SizeofIfmaMsghdr2 = C.sizeof_struct_ifma_msghdr2 - SizeofRtMsghdr = C.sizeof_struct_rt_msghdr - SizeofRtMetrics = C.sizeof_struct_rt_metrics -) - -type IfMsghdr C.struct_if_msghdr - -type IfData C.struct_if_data - -type IfaMsghdr C.struct_ifa_msghdr - -type IfmaMsghdr C.struct_ifma_msghdr - -type IfmaMsghdr2 C.struct_ifma_msghdr2 - -type RtMsghdr C.struct_rt_msghdr - -type RtMetrics C.struct_rt_metrics - -// Berkeley packet filter - -const ( - SizeofBpfVersion = C.sizeof_struct_bpf_version - SizeofBpfStat = C.sizeof_struct_bpf_stat - SizeofBpfProgram = C.sizeof_struct_bpf_program - SizeofBpfInsn = C.sizeof_struct_bpf_insn - SizeofBpfHdr = C.sizeof_struct_bpf_hdr -) - -type BpfVersion C.struct_bpf_version - -type BpfStat C.struct_bpf_stat - -type BpfProgram C.struct_bpf_program - -type BpfInsn C.struct_bpf_insn - -type BpfHdr C.struct_bpf_hdr - -// Terminal handling - -type Termios C.struct_termios - -type Winsize C.struct_winsize - -// fchmodat-like syscalls. - -const ( - AT_FDCWD = C.AT_FDCWD - AT_REMOVEDIR = C.AT_REMOVEDIR - AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW - AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW -) - -// poll - -type PollFd C.struct_pollfd - -const ( - POLLERR = C.POLLERR - POLLHUP = C.POLLHUP - POLLIN = C.POLLIN - POLLNVAL = C.POLLNVAL - POLLOUT = C.POLLOUT - POLLPRI = C.POLLPRI - POLLRDBAND = C.POLLRDBAND - POLLRDNORM = C.POLLRDNORM - POLLWRBAND = C.POLLWRBAND - POLLWRNORM = C.POLLWRNORM -) - -// uname - -type Utsname C.struct_utsname - -// Clockinfo - -const SizeofClockinfo = C.sizeof_struct_clockinfo - -type Clockinfo C.struct_clockinfo diff --git a/vendor/golang.org/x/sys/unix/types_dragonfly.go b/vendor/golang.org/x/sys/unix/types_dragonfly.go deleted file mode 100644 index 3365dd79..00000000 --- a/vendor/golang.org/x/sys/unix/types_dragonfly.go +++ /dev/null @@ -1,263 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -/* -Input to cgo -godefs. See README.md -*/ - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package unix - -/* -#define KERNEL -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -enum { - sizeofPtr = sizeof(void*), -}; - -union sockaddr_all { - struct sockaddr s1; // this one gets used for fields - struct sockaddr_in s2; // these pad it out - struct sockaddr_in6 s3; - struct sockaddr_un s4; - struct sockaddr_dl s5; -}; - -struct sockaddr_any { - struct sockaddr addr; - char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; -}; - -*/ -import "C" - -// Machine characteristics - -const ( - SizeofPtr = C.sizeofPtr - SizeofShort = C.sizeof_short - SizeofInt = C.sizeof_int - SizeofLong = C.sizeof_long - SizeofLongLong = C.sizeof_longlong -) - -// Basic types - -type ( - _C_short C.short - _C_int C.int - _C_long C.long - _C_long_long C.longlong -) - -// Time - -type Timespec C.struct_timespec - -type Timeval C.struct_timeval - -// Processes - -type Rusage C.struct_rusage - -type Rlimit C.struct_rlimit - -type _Gid_t C.gid_t - -// Files - -type Stat_t C.struct_stat - -type Statfs_t C.struct_statfs - -type Flock_t C.struct_flock - -type Dirent C.struct_dirent - -type Fsid C.struct_fsid - -// File system limits - -const ( - PathMax = C.PATH_MAX -) - -// Sockets - -type RawSockaddrInet4 C.struct_sockaddr_in - -type RawSockaddrInet6 C.struct_sockaddr_in6 - -type RawSockaddrUnix C.struct_sockaddr_un - -type RawSockaddrDatalink C.struct_sockaddr_dl - -type RawSockaddr C.struct_sockaddr - -type RawSockaddrAny C.struct_sockaddr_any - -type _Socklen C.socklen_t - -type Linger C.struct_linger - -type Iovec C.struct_iovec - -type IPMreq C.struct_ip_mreq - -type IPv6Mreq C.struct_ipv6_mreq - -type Msghdr C.struct_msghdr - -type Cmsghdr C.struct_cmsghdr - -type Inet6Pktinfo C.struct_in6_pktinfo - -type IPv6MTUInfo C.struct_ip6_mtuinfo - -type ICMPv6Filter C.struct_icmp6_filter - -const ( - SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in - SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - SizeofSockaddrAny = C.sizeof_struct_sockaddr_any - SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un - SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl - SizeofLinger = C.sizeof_struct_linger - SizeofIPMreq = C.sizeof_struct_ip_mreq - SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - SizeofMsghdr = C.sizeof_struct_msghdr - SizeofCmsghdr = C.sizeof_struct_cmsghdr - SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo - SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -// Ptrace requests - -const ( - PTRACE_TRACEME = C.PT_TRACE_ME - PTRACE_CONT = C.PT_CONTINUE - PTRACE_KILL = C.PT_KILL -) - -// Events (kqueue, kevent) - -type Kevent_t C.struct_kevent - -// Select - -type FdSet C.fd_set - -// Routing and interface messages - -const ( - SizeofIfMsghdr = C.sizeof_struct_if_msghdr - SizeofIfData = C.sizeof_struct_if_data - SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr - SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr - SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr - SizeofRtMsghdr = C.sizeof_struct_rt_msghdr - SizeofRtMetrics = C.sizeof_struct_rt_metrics -) - -type IfMsghdr C.struct_if_msghdr - -type IfData C.struct_if_data - -type IfaMsghdr C.struct_ifa_msghdr - -type IfmaMsghdr C.struct_ifma_msghdr - -type IfAnnounceMsghdr C.struct_if_announcemsghdr - -type RtMsghdr C.struct_rt_msghdr - -type RtMetrics C.struct_rt_metrics - -// Berkeley packet filter - -const ( - SizeofBpfVersion = C.sizeof_struct_bpf_version - SizeofBpfStat = C.sizeof_struct_bpf_stat - SizeofBpfProgram = C.sizeof_struct_bpf_program - SizeofBpfInsn = C.sizeof_struct_bpf_insn - SizeofBpfHdr = C.sizeof_struct_bpf_hdr -) - -type BpfVersion C.struct_bpf_version - -type BpfStat C.struct_bpf_stat - -type BpfProgram C.struct_bpf_program - -type BpfInsn C.struct_bpf_insn - -type BpfHdr C.struct_bpf_hdr - -// Terminal handling - -type Termios C.struct_termios - -type Winsize C.struct_winsize - -// fchmodat-like syscalls. - -const ( - AT_FDCWD = C.AT_FDCWD - AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW -) - -// poll - -type PollFd C.struct_pollfd - -const ( - POLLERR = C.POLLERR - POLLHUP = C.POLLHUP - POLLIN = C.POLLIN - POLLNVAL = C.POLLNVAL - POLLOUT = C.POLLOUT - POLLPRI = C.POLLPRI - POLLRDBAND = C.POLLRDBAND - POLLRDNORM = C.POLLRDNORM - POLLWRBAND = C.POLLWRBAND - POLLWRNORM = C.POLLWRNORM -) - -// Uname - -type Utsname C.struct_utsname diff --git a/vendor/golang.org/x/sys/unix/types_freebsd.go b/vendor/golang.org/x/sys/unix/types_freebsd.go deleted file mode 100644 index 74707989..00000000 --- a/vendor/golang.org/x/sys/unix/types_freebsd.go +++ /dev/null @@ -1,356 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -/* -Input to cgo -godefs. See README.md -*/ - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package unix - -/* -#define _WANT_FREEBSD11_STAT 1 -#define _WANT_FREEBSD11_STATFS 1 -#define _WANT_FREEBSD11_DIRENT 1 -#define _WANT_FREEBSD11_KEVENT 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -enum { - sizeofPtr = sizeof(void*), -}; - -union sockaddr_all { - struct sockaddr s1; // this one gets used for fields - struct sockaddr_in s2; // these pad it out - struct sockaddr_in6 s3; - struct sockaddr_un s4; - struct sockaddr_dl s5; -}; - -struct sockaddr_any { - struct sockaddr addr; - char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; -}; - -// This structure is a duplicate of if_data on FreeBSD 8-STABLE. -// See /usr/include/net/if.h. -struct if_data8 { - u_char ifi_type; - u_char ifi_physical; - u_char ifi_addrlen; - u_char ifi_hdrlen; - u_char ifi_link_state; - u_char ifi_spare_char1; - u_char ifi_spare_char2; - u_char ifi_datalen; - u_long ifi_mtu; - u_long ifi_metric; - u_long ifi_baudrate; - u_long ifi_ipackets; - u_long ifi_ierrors; - u_long ifi_opackets; - u_long ifi_oerrors; - u_long ifi_collisions; - u_long ifi_ibytes; - u_long ifi_obytes; - u_long ifi_imcasts; - u_long ifi_omcasts; - u_long ifi_iqdrops; - u_long ifi_noproto; - u_long ifi_hwassist; -// FIXME: these are now unions, so maybe need to change definitions? -#undef ifi_epoch - time_t ifi_epoch; -#undef ifi_lastchange - struct timeval ifi_lastchange; -}; - -// This structure is a duplicate of if_msghdr on FreeBSD 8-STABLE. -// See /usr/include/net/if.h. -struct if_msghdr8 { - u_short ifm_msglen; - u_char ifm_version; - u_char ifm_type; - int ifm_addrs; - int ifm_flags; - u_short ifm_index; - struct if_data8 ifm_data; -}; -*/ -import "C" - -// Machine characteristics - -const ( - SizeofPtr = C.sizeofPtr - SizeofShort = C.sizeof_short - SizeofInt = C.sizeof_int - SizeofLong = C.sizeof_long - SizeofLongLong = C.sizeof_longlong -) - -// Basic types - -type ( - _C_short C.short - _C_int C.int - _C_long C.long - _C_long_long C.longlong -) - -// Time - -type Timespec C.struct_timespec - -type Timeval C.struct_timeval - -// Processes - -type Rusage C.struct_rusage - -type Rlimit C.struct_rlimit - -type _Gid_t C.gid_t - -// Files - -const ( - _statfsVersion = C.STATFS_VERSION - _dirblksiz = C.DIRBLKSIZ -) - -type Stat_t C.struct_stat - -type stat_freebsd11_t C.struct_freebsd11_stat - -type Statfs_t C.struct_statfs - -type statfs_freebsd11_t C.struct_freebsd11_statfs - -type Flock_t C.struct_flock - -type Dirent C.struct_dirent - -type dirent_freebsd11 C.struct_freebsd11_dirent - -type Fsid C.struct_fsid - -// File system limits - -const ( - PathMax = C.PATH_MAX -) - -// Advice to Fadvise - -const ( - FADV_NORMAL = C.POSIX_FADV_NORMAL - FADV_RANDOM = C.POSIX_FADV_RANDOM - FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL - FADV_WILLNEED = C.POSIX_FADV_WILLNEED - FADV_DONTNEED = C.POSIX_FADV_DONTNEED - FADV_NOREUSE = C.POSIX_FADV_NOREUSE -) - -// Sockets - -type RawSockaddrInet4 C.struct_sockaddr_in - -type RawSockaddrInet6 C.struct_sockaddr_in6 - -type RawSockaddrUnix C.struct_sockaddr_un - -type RawSockaddrDatalink C.struct_sockaddr_dl - -type RawSockaddr C.struct_sockaddr - -type RawSockaddrAny C.struct_sockaddr_any - -type _Socklen C.socklen_t - -type Linger C.struct_linger - -type Iovec C.struct_iovec - -type IPMreq C.struct_ip_mreq - -type IPMreqn C.struct_ip_mreqn - -type IPv6Mreq C.struct_ipv6_mreq - -type Msghdr C.struct_msghdr - -type Cmsghdr C.struct_cmsghdr - -type Inet6Pktinfo C.struct_in6_pktinfo - -type IPv6MTUInfo C.struct_ip6_mtuinfo - -type ICMPv6Filter C.struct_icmp6_filter - -const ( - SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in - SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - SizeofSockaddrAny = C.sizeof_struct_sockaddr_any - SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un - SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl - SizeofLinger = C.sizeof_struct_linger - SizeofIPMreq = C.sizeof_struct_ip_mreq - SizeofIPMreqn = C.sizeof_struct_ip_mreqn - SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - SizeofMsghdr = C.sizeof_struct_msghdr - SizeofCmsghdr = C.sizeof_struct_cmsghdr - SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo - SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -// Ptrace requests - -const ( - PTRACE_TRACEME = C.PT_TRACE_ME - PTRACE_CONT = C.PT_CONTINUE - PTRACE_KILL = C.PT_KILL -) - -// Events (kqueue, kevent) - -type Kevent_t C.struct_kevent_freebsd11 - -// Select - -type FdSet C.fd_set - -// Routing and interface messages - -const ( - sizeofIfMsghdr = C.sizeof_struct_if_msghdr - SizeofIfMsghdr = C.sizeof_struct_if_msghdr8 - sizeofIfData = C.sizeof_struct_if_data - SizeofIfData = C.sizeof_struct_if_data8 - SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr - SizeofIfmaMsghdr = C.sizeof_struct_ifma_msghdr - SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr - SizeofRtMsghdr = C.sizeof_struct_rt_msghdr - SizeofRtMetrics = C.sizeof_struct_rt_metrics -) - -type ifMsghdr C.struct_if_msghdr - -type IfMsghdr C.struct_if_msghdr8 - -type ifData C.struct_if_data - -type IfData C.struct_if_data8 - -type IfaMsghdr C.struct_ifa_msghdr - -type IfmaMsghdr C.struct_ifma_msghdr - -type IfAnnounceMsghdr C.struct_if_announcemsghdr - -type RtMsghdr C.struct_rt_msghdr - -type RtMetrics C.struct_rt_metrics - -// Berkeley packet filter - -const ( - SizeofBpfVersion = C.sizeof_struct_bpf_version - SizeofBpfStat = C.sizeof_struct_bpf_stat - SizeofBpfZbuf = C.sizeof_struct_bpf_zbuf - SizeofBpfProgram = C.sizeof_struct_bpf_program - SizeofBpfInsn = C.sizeof_struct_bpf_insn - SizeofBpfHdr = C.sizeof_struct_bpf_hdr - SizeofBpfZbufHeader = C.sizeof_struct_bpf_zbuf_header -) - -type BpfVersion C.struct_bpf_version - -type BpfStat C.struct_bpf_stat - -type BpfZbuf C.struct_bpf_zbuf - -type BpfProgram C.struct_bpf_program - -type BpfInsn C.struct_bpf_insn - -type BpfHdr C.struct_bpf_hdr - -type BpfZbufHeader C.struct_bpf_zbuf_header - -// Terminal handling - -type Termios C.struct_termios - -type Winsize C.struct_winsize - -// fchmodat-like syscalls. - -const ( - AT_FDCWD = C.AT_FDCWD - AT_REMOVEDIR = C.AT_REMOVEDIR - AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW - AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW -) - -// poll - -type PollFd C.struct_pollfd - -const ( - POLLERR = C.POLLERR - POLLHUP = C.POLLHUP - POLLIN = C.POLLIN - POLLINIGNEOF = C.POLLINIGNEOF - POLLNVAL = C.POLLNVAL - POLLOUT = C.POLLOUT - POLLPRI = C.POLLPRI - POLLRDBAND = C.POLLRDBAND - POLLRDNORM = C.POLLRDNORM - POLLWRBAND = C.POLLWRBAND - POLLWRNORM = C.POLLWRNORM -) - -// Capabilities - -type CapRights C.struct_cap_rights - -// Uname - -type Utsname C.struct_utsname diff --git a/vendor/golang.org/x/sys/unix/types_netbsd.go b/vendor/golang.org/x/sys/unix/types_netbsd.go deleted file mode 100644 index 4a96d72c..00000000 --- a/vendor/golang.org/x/sys/unix/types_netbsd.go +++ /dev/null @@ -1,290 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -/* -Input to cgo -godefs. See README.md -*/ - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package unix - -/* -#define KERNEL -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -enum { - sizeofPtr = sizeof(void*), -}; - -union sockaddr_all { - struct sockaddr s1; // this one gets used for fields - struct sockaddr_in s2; // these pad it out - struct sockaddr_in6 s3; - struct sockaddr_un s4; - struct sockaddr_dl s5; -}; - -struct sockaddr_any { - struct sockaddr addr; - char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; -}; - -*/ -import "C" - -// Machine characteristics - -const ( - SizeofPtr = C.sizeofPtr - SizeofShort = C.sizeof_short - SizeofInt = C.sizeof_int - SizeofLong = C.sizeof_long - SizeofLongLong = C.sizeof_longlong -) - -// Basic types - -type ( - _C_short C.short - _C_int C.int - _C_long C.long - _C_long_long C.longlong -) - -// Time - -type Timespec C.struct_timespec - -type Timeval C.struct_timeval - -// Processes - -type Rusage C.struct_rusage - -type Rlimit C.struct_rlimit - -type _Gid_t C.gid_t - -// Files - -type Stat_t C.struct_stat - -type Statfs_t C.struct_statfs - -type Flock_t C.struct_flock - -type Dirent C.struct_dirent - -type Fsid C.fsid_t - -// File system limits - -const ( - PathMax = C.PATH_MAX -) - -// Advice to Fadvise - -const ( - FADV_NORMAL = C.POSIX_FADV_NORMAL - FADV_RANDOM = C.POSIX_FADV_RANDOM - FADV_SEQUENTIAL = C.POSIX_FADV_SEQUENTIAL - FADV_WILLNEED = C.POSIX_FADV_WILLNEED - FADV_DONTNEED = C.POSIX_FADV_DONTNEED - FADV_NOREUSE = C.POSIX_FADV_NOREUSE -) - -// Sockets - -type RawSockaddrInet4 C.struct_sockaddr_in - -type RawSockaddrInet6 C.struct_sockaddr_in6 - -type RawSockaddrUnix C.struct_sockaddr_un - -type RawSockaddrDatalink C.struct_sockaddr_dl - -type RawSockaddr C.struct_sockaddr - -type RawSockaddrAny C.struct_sockaddr_any - -type _Socklen C.socklen_t - -type Linger C.struct_linger - -type Iovec C.struct_iovec - -type IPMreq C.struct_ip_mreq - -type IPv6Mreq C.struct_ipv6_mreq - -type Msghdr C.struct_msghdr - -type Cmsghdr C.struct_cmsghdr - -type Inet6Pktinfo C.struct_in6_pktinfo - -type IPv6MTUInfo C.struct_ip6_mtuinfo - -type ICMPv6Filter C.struct_icmp6_filter - -const ( - SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in - SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - SizeofSockaddrAny = C.sizeof_struct_sockaddr_any - SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un - SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl - SizeofLinger = C.sizeof_struct_linger - SizeofIPMreq = C.sizeof_struct_ip_mreq - SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - SizeofMsghdr = C.sizeof_struct_msghdr - SizeofCmsghdr = C.sizeof_struct_cmsghdr - SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo - SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -// Ptrace requests - -const ( - PTRACE_TRACEME = C.PT_TRACE_ME - PTRACE_CONT = C.PT_CONTINUE - PTRACE_KILL = C.PT_KILL -) - -// Events (kqueue, kevent) - -type Kevent_t C.struct_kevent - -// Select - -type FdSet C.fd_set - -// Routing and interface messages - -const ( - SizeofIfMsghdr = C.sizeof_struct_if_msghdr - SizeofIfData = C.sizeof_struct_if_data - SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr - SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr - SizeofRtMsghdr = C.sizeof_struct_rt_msghdr - SizeofRtMetrics = C.sizeof_struct_rt_metrics -) - -type IfMsghdr C.struct_if_msghdr - -type IfData C.struct_if_data - -type IfaMsghdr C.struct_ifa_msghdr - -type IfAnnounceMsghdr C.struct_if_announcemsghdr - -type RtMsghdr C.struct_rt_msghdr - -type RtMetrics C.struct_rt_metrics - -type Mclpool C.struct_mclpool - -// Berkeley packet filter - -const ( - SizeofBpfVersion = C.sizeof_struct_bpf_version - SizeofBpfStat = C.sizeof_struct_bpf_stat - SizeofBpfProgram = C.sizeof_struct_bpf_program - SizeofBpfInsn = C.sizeof_struct_bpf_insn - SizeofBpfHdr = C.sizeof_struct_bpf_hdr -) - -type BpfVersion C.struct_bpf_version - -type BpfStat C.struct_bpf_stat - -type BpfProgram C.struct_bpf_program - -type BpfInsn C.struct_bpf_insn - -type BpfHdr C.struct_bpf_hdr - -type BpfTimeval C.struct_bpf_timeval - -// Terminal handling - -type Termios C.struct_termios - -type Winsize C.struct_winsize - -type Ptmget C.struct_ptmget - -// fchmodat-like syscalls. - -const ( - AT_FDCWD = C.AT_FDCWD - AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW - AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW -) - -// poll - -type PollFd C.struct_pollfd - -const ( - POLLERR = C.POLLERR - POLLHUP = C.POLLHUP - POLLIN = C.POLLIN - POLLNVAL = C.POLLNVAL - POLLOUT = C.POLLOUT - POLLPRI = C.POLLPRI - POLLRDBAND = C.POLLRDBAND - POLLRDNORM = C.POLLRDNORM - POLLWRBAND = C.POLLWRBAND - POLLWRNORM = C.POLLWRNORM -) - -// Sysctl - -type Sysctlnode C.struct_sysctlnode - -// Uname - -type Utsname C.struct_utsname - -// Clockinfo - -const SizeofClockinfo = C.sizeof_struct_clockinfo - -type Clockinfo C.struct_clockinfo diff --git a/vendor/golang.org/x/sys/unix/types_openbsd.go b/vendor/golang.org/x/sys/unix/types_openbsd.go deleted file mode 100644 index 775cb57d..00000000 --- a/vendor/golang.org/x/sys/unix/types_openbsd.go +++ /dev/null @@ -1,283 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -/* -Input to cgo -godefs. See README.md -*/ - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package unix - -/* -#define KERNEL -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -enum { - sizeofPtr = sizeof(void*), -}; - -union sockaddr_all { - struct sockaddr s1; // this one gets used for fields - struct sockaddr_in s2; // these pad it out - struct sockaddr_in6 s3; - struct sockaddr_un s4; - struct sockaddr_dl s5; -}; - -struct sockaddr_any { - struct sockaddr addr; - char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; -}; - -*/ -import "C" - -// Machine characteristics - -const ( - SizeofPtr = C.sizeofPtr - SizeofShort = C.sizeof_short - SizeofInt = C.sizeof_int - SizeofLong = C.sizeof_long - SizeofLongLong = C.sizeof_longlong -) - -// Basic types - -type ( - _C_short C.short - _C_int C.int - _C_long C.long - _C_long_long C.longlong -) - -// Time - -type Timespec C.struct_timespec - -type Timeval C.struct_timeval - -// Processes - -type Rusage C.struct_rusage - -type Rlimit C.struct_rlimit - -type _Gid_t C.gid_t - -// Files - -type Stat_t C.struct_stat - -type Statfs_t C.struct_statfs - -type Flock_t C.struct_flock - -type Dirent C.struct_dirent - -type Fsid C.fsid_t - -// File system limits - -const ( - PathMax = C.PATH_MAX -) - -// Sockets - -type RawSockaddrInet4 C.struct_sockaddr_in - -type RawSockaddrInet6 C.struct_sockaddr_in6 - -type RawSockaddrUnix C.struct_sockaddr_un - -type RawSockaddrDatalink C.struct_sockaddr_dl - -type RawSockaddr C.struct_sockaddr - -type RawSockaddrAny C.struct_sockaddr_any - -type _Socklen C.socklen_t - -type Linger C.struct_linger - -type Iovec C.struct_iovec - -type IPMreq C.struct_ip_mreq - -type IPv6Mreq C.struct_ipv6_mreq - -type Msghdr C.struct_msghdr - -type Cmsghdr C.struct_cmsghdr - -type Inet6Pktinfo C.struct_in6_pktinfo - -type IPv6MTUInfo C.struct_ip6_mtuinfo - -type ICMPv6Filter C.struct_icmp6_filter - -const ( - SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in - SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - SizeofSockaddrAny = C.sizeof_struct_sockaddr_any - SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un - SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl - SizeofLinger = C.sizeof_struct_linger - SizeofIPMreq = C.sizeof_struct_ip_mreq - SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - SizeofMsghdr = C.sizeof_struct_msghdr - SizeofCmsghdr = C.sizeof_struct_cmsghdr - SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo - SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -// Ptrace requests - -const ( - PTRACE_TRACEME = C.PT_TRACE_ME - PTRACE_CONT = C.PT_CONTINUE - PTRACE_KILL = C.PT_KILL -) - -// Events (kqueue, kevent) - -type Kevent_t C.struct_kevent - -// Select - -type FdSet C.fd_set - -// Routing and interface messages - -const ( - SizeofIfMsghdr = C.sizeof_struct_if_msghdr - SizeofIfData = C.sizeof_struct_if_data - SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr - SizeofIfAnnounceMsghdr = C.sizeof_struct_if_announcemsghdr - SizeofRtMsghdr = C.sizeof_struct_rt_msghdr - SizeofRtMetrics = C.sizeof_struct_rt_metrics -) - -type IfMsghdr C.struct_if_msghdr - -type IfData C.struct_if_data - -type IfaMsghdr C.struct_ifa_msghdr - -type IfAnnounceMsghdr C.struct_if_announcemsghdr - -type RtMsghdr C.struct_rt_msghdr - -type RtMetrics C.struct_rt_metrics - -type Mclpool C.struct_mclpool - -// Berkeley packet filter - -const ( - SizeofBpfVersion = C.sizeof_struct_bpf_version - SizeofBpfStat = C.sizeof_struct_bpf_stat - SizeofBpfProgram = C.sizeof_struct_bpf_program - SizeofBpfInsn = C.sizeof_struct_bpf_insn - SizeofBpfHdr = C.sizeof_struct_bpf_hdr -) - -type BpfVersion C.struct_bpf_version - -type BpfStat C.struct_bpf_stat - -type BpfProgram C.struct_bpf_program - -type BpfInsn C.struct_bpf_insn - -type BpfHdr C.struct_bpf_hdr - -type BpfTimeval C.struct_bpf_timeval - -// Terminal handling - -type Termios C.struct_termios - -type Winsize C.struct_winsize - -// fchmodat-like syscalls. - -const ( - AT_FDCWD = C.AT_FDCWD - AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW - AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW -) - -// poll - -type PollFd C.struct_pollfd - -const ( - POLLERR = C.POLLERR - POLLHUP = C.POLLHUP - POLLIN = C.POLLIN - POLLNVAL = C.POLLNVAL - POLLOUT = C.POLLOUT - POLLPRI = C.POLLPRI - POLLRDBAND = C.POLLRDBAND - POLLRDNORM = C.POLLRDNORM - POLLWRBAND = C.POLLWRBAND - POLLWRNORM = C.POLLWRNORM -) - -// Signal Sets - -type Sigset_t C.sigset_t - -// Uname - -type Utsname C.struct_utsname - -// Uvmexp - -const SizeofUvmexp = C.sizeof_struct_uvmexp - -type Uvmexp C.struct_uvmexp - -// Clockinfo - -const SizeofClockinfo = C.sizeof_struct_clockinfo - -type Clockinfo C.struct_clockinfo diff --git a/vendor/golang.org/x/sys/unix/types_solaris.go b/vendor/golang.org/x/sys/unix/types_solaris.go deleted file mode 100644 index 2b716f93..00000000 --- a/vendor/golang.org/x/sys/unix/types_solaris.go +++ /dev/null @@ -1,266 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -/* -Input to cgo -godefs. See README.md -*/ - -// +godefs map struct_in_addr [4]byte /* in_addr */ -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package unix - -/* -#define KERNEL -// These defines ensure that builds done on newer versions of Solaris are -// backwards-compatible with older versions of Solaris and -// OpenSolaris-based derivatives. -#define __USE_SUNOS_SOCKETS__ // msghdr -#define __USE_LEGACY_PROTOTYPES__ // iovec -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -enum { - sizeofPtr = sizeof(void*), -}; - -union sockaddr_all { - struct sockaddr s1; // this one gets used for fields - struct sockaddr_in s2; // these pad it out - struct sockaddr_in6 s3; - struct sockaddr_un s4; - struct sockaddr_dl s5; -}; - -struct sockaddr_any { - struct sockaddr addr; - char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)]; -}; - -*/ -import "C" - -// Machine characteristics - -const ( - SizeofPtr = C.sizeofPtr - SizeofShort = C.sizeof_short - SizeofInt = C.sizeof_int - SizeofLong = C.sizeof_long - SizeofLongLong = C.sizeof_longlong - PathMax = C.PATH_MAX - MaxHostNameLen = C.MAXHOSTNAMELEN -) - -// Basic types - -type ( - _C_short C.short - _C_int C.int - _C_long C.long - _C_long_long C.longlong -) - -// Time - -type Timespec C.struct_timespec - -type Timeval C.struct_timeval - -type Timeval32 C.struct_timeval32 - -type Tms C.struct_tms - -type Utimbuf C.struct_utimbuf - -// Processes - -type Rusage C.struct_rusage - -type Rlimit C.struct_rlimit - -type _Gid_t C.gid_t - -// Files - -type Stat_t C.struct_stat - -type Flock_t C.struct_flock - -type Dirent C.struct_dirent - -// Filesystems - -type _Fsblkcnt_t C.fsblkcnt_t - -type Statvfs_t C.struct_statvfs - -// Sockets - -type RawSockaddrInet4 C.struct_sockaddr_in - -type RawSockaddrInet6 C.struct_sockaddr_in6 - -type RawSockaddrUnix C.struct_sockaddr_un - -type RawSockaddrDatalink C.struct_sockaddr_dl - -type RawSockaddr C.struct_sockaddr - -type RawSockaddrAny C.struct_sockaddr_any - -type _Socklen C.socklen_t - -type Linger C.struct_linger - -type Iovec C.struct_iovec - -type IPMreq C.struct_ip_mreq - -type IPv6Mreq C.struct_ipv6_mreq - -type Msghdr C.struct_msghdr - -type Cmsghdr C.struct_cmsghdr - -type Inet6Pktinfo C.struct_in6_pktinfo - -type IPv6MTUInfo C.struct_ip6_mtuinfo - -type ICMPv6Filter C.struct_icmp6_filter - -const ( - SizeofSockaddrInet4 = C.sizeof_struct_sockaddr_in - SizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - SizeofSockaddrAny = C.sizeof_struct_sockaddr_any - SizeofSockaddrUnix = C.sizeof_struct_sockaddr_un - SizeofSockaddrDatalink = C.sizeof_struct_sockaddr_dl - SizeofLinger = C.sizeof_struct_linger - SizeofIPMreq = C.sizeof_struct_ip_mreq - SizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - SizeofMsghdr = C.sizeof_struct_msghdr - SizeofCmsghdr = C.sizeof_struct_cmsghdr - SizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - SizeofIPv6MTUInfo = C.sizeof_struct_ip6_mtuinfo - SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -// Select - -type FdSet C.fd_set - -// Misc - -type Utsname C.struct_utsname - -type Ustat_t C.struct_ustat - -const ( - AT_FDCWD = C.AT_FDCWD - AT_SYMLINK_NOFOLLOW = C.AT_SYMLINK_NOFOLLOW - AT_SYMLINK_FOLLOW = C.AT_SYMLINK_FOLLOW - AT_REMOVEDIR = C.AT_REMOVEDIR - AT_EACCESS = C.AT_EACCESS -) - -// Routing and interface messages - -const ( - SizeofIfMsghdr = C.sizeof_struct_if_msghdr - SizeofIfData = C.sizeof_struct_if_data - SizeofIfaMsghdr = C.sizeof_struct_ifa_msghdr - SizeofRtMsghdr = C.sizeof_struct_rt_msghdr - SizeofRtMetrics = C.sizeof_struct_rt_metrics -) - -type IfMsghdr C.struct_if_msghdr - -type IfData C.struct_if_data - -type IfaMsghdr C.struct_ifa_msghdr - -type RtMsghdr C.struct_rt_msghdr - -type RtMetrics C.struct_rt_metrics - -// Berkeley packet filter - -const ( - SizeofBpfVersion = C.sizeof_struct_bpf_version - SizeofBpfStat = C.sizeof_struct_bpf_stat - SizeofBpfProgram = C.sizeof_struct_bpf_program - SizeofBpfInsn = C.sizeof_struct_bpf_insn - SizeofBpfHdr = C.sizeof_struct_bpf_hdr -) - -type BpfVersion C.struct_bpf_version - -type BpfStat C.struct_bpf_stat - -type BpfProgram C.struct_bpf_program - -type BpfInsn C.struct_bpf_insn - -type BpfTimeval C.struct_bpf_timeval - -type BpfHdr C.struct_bpf_hdr - -// Terminal handling - -type Termios C.struct_termios - -type Termio C.struct_termio - -type Winsize C.struct_winsize - -// poll - -type PollFd C.struct_pollfd - -const ( - POLLERR = C.POLLERR - POLLHUP = C.POLLHUP - POLLIN = C.POLLIN - POLLNVAL = C.POLLNVAL - POLLOUT = C.POLLOUT - POLLPRI = C.POLLPRI - POLLRDBAND = C.POLLRDBAND - POLLRDNORM = C.POLLRDNORM - POLLWRBAND = C.POLLWRBAND - POLLWRNORM = C.POLLWRNORM -) diff --git a/vendor/golang.org/x/text/unicode/bidi/gen.go b/vendor/golang.org/x/text/unicode/bidi/gen.go deleted file mode 100644 index 987fc169..00000000 --- a/vendor/golang.org/x/text/unicode/bidi/gen.go +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package main - -import ( - "flag" - "log" - - "golang.org/x/text/internal/gen" - "golang.org/x/text/internal/triegen" - "golang.org/x/text/internal/ucd" -) - -var outputFile = flag.String("out", "tables.go", "output file") - -func main() { - gen.Init() - gen.Repackage("gen_trieval.go", "trieval.go", "bidi") - gen.Repackage("gen_ranges.go", "ranges_test.go", "bidi") - - genTables() -} - -// bidiClass names and codes taken from class "bc" in -// https://www.unicode.org/Public/8.0.0/ucd/PropertyValueAliases.txt -var bidiClass = map[string]Class{ - "AL": AL, // ArabicLetter - "AN": AN, // ArabicNumber - "B": B, // ParagraphSeparator - "BN": BN, // BoundaryNeutral - "CS": CS, // CommonSeparator - "EN": EN, // EuropeanNumber - "ES": ES, // EuropeanSeparator - "ET": ET, // EuropeanTerminator - "L": L, // LeftToRight - "NSM": NSM, // NonspacingMark - "ON": ON, // OtherNeutral - "R": R, // RightToLeft - "S": S, // SegmentSeparator - "WS": WS, // WhiteSpace - - "FSI": Control, - "PDF": Control, - "PDI": Control, - "LRE": Control, - "LRI": Control, - "LRO": Control, - "RLE": Control, - "RLI": Control, - "RLO": Control, -} - -func genTables() { - if numClass > 0x0F { - log.Fatalf("Too many Class constants (%#x > 0x0F).", numClass) - } - w := gen.NewCodeWriter() - defer w.WriteVersionedGoFile(*outputFile, "bidi") - - gen.WriteUnicodeVersion(w) - - t := triegen.NewTrie("bidi") - - // Build data about bracket mapping. These bits need to be or-ed with - // any other bits. - orMask := map[rune]uint64{} - - xorMap := map[rune]int{} - xorMasks := []rune{0} // First value is no-op. - - ucd.Parse(gen.OpenUCDFile("BidiBrackets.txt"), func(p *ucd.Parser) { - r1 := p.Rune(0) - r2 := p.Rune(1) - xor := r1 ^ r2 - if _, ok := xorMap[xor]; !ok { - xorMap[xor] = len(xorMasks) - xorMasks = append(xorMasks, xor) - } - entry := uint64(xorMap[xor]) << xorMaskShift - switch p.String(2) { - case "o": - entry |= openMask - case "c", "n": - default: - log.Fatalf("Unknown bracket class %q.", p.String(2)) - } - orMask[r1] = entry - }) - - w.WriteComment(` - xorMasks contains masks to be xor-ed with brackets to get the reverse - version.`) - w.WriteVar("xorMasks", xorMasks) - - done := map[rune]bool{} - - insert := func(r rune, c Class) { - if !done[r] { - t.Insert(r, orMask[r]|uint64(c)) - done[r] = true - } - } - - // Insert the derived BiDi properties. - ucd.Parse(gen.OpenUCDFile("extracted/DerivedBidiClass.txt"), func(p *ucd.Parser) { - r := p.Rune(0) - class, ok := bidiClass[p.String(1)] - if !ok { - log.Fatalf("%U: Unknown BiDi class %q", r, p.String(1)) - } - insert(r, class) - }) - visitDefaults(insert) - - // TODO: use sparse blocks. This would reduce table size considerably - // from the looks of it. - - sz, err := t.Gen(w) - if err != nil { - log.Fatal(err) - } - w.Size += sz -} - -// dummy values to make methods in gen_common compile. The real versions -// will be generated by this file to tables.go. -var ( - xorMasks []rune -) diff --git a/vendor/golang.org/x/text/unicode/bidi/gen_ranges.go b/vendor/golang.org/x/text/unicode/bidi/gen_ranges.go deleted file mode 100644 index 02c3b505..00000000 --- a/vendor/golang.org/x/text/unicode/bidi/gen_ranges.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package main - -import ( - "unicode" - - "golang.org/x/text/internal/gen" - "golang.org/x/text/internal/ucd" - "golang.org/x/text/unicode/rangetable" -) - -// These tables are hand-extracted from: -// https://www.unicode.org/Public/8.0.0/ucd/extracted/DerivedBidiClass.txt -func visitDefaults(fn func(r rune, c Class)) { - // first write default values for ranges listed above. - visitRunes(fn, AL, []rune{ - 0x0600, 0x07BF, // Arabic - 0x08A0, 0x08FF, // Arabic Extended-A - 0xFB50, 0xFDCF, // Arabic Presentation Forms - 0xFDF0, 0xFDFF, - 0xFE70, 0xFEFF, - 0x0001EE00, 0x0001EEFF, // Arabic Mathematical Alpha Symbols - }) - visitRunes(fn, R, []rune{ - 0x0590, 0x05FF, // Hebrew - 0x07C0, 0x089F, // Nko et al. - 0xFB1D, 0xFB4F, - 0x00010800, 0x00010FFF, // Cypriot Syllabary et. al. - 0x0001E800, 0x0001EDFF, - 0x0001EF00, 0x0001EFFF, - }) - visitRunes(fn, ET, []rune{ // European Terminator - 0x20A0, 0x20Cf, // Currency symbols - }) - rangetable.Visit(unicode.Noncharacter_Code_Point, func(r rune) { - fn(r, BN) // Boundary Neutral - }) - ucd.Parse(gen.OpenUCDFile("DerivedCoreProperties.txt"), func(p *ucd.Parser) { - if p.String(1) == "Default_Ignorable_Code_Point" { - fn(p.Rune(0), BN) // Boundary Neutral - } - }) -} - -func visitRunes(fn func(r rune, c Class), c Class, runes []rune) { - for i := 0; i < len(runes); i += 2 { - lo, hi := runes[i], runes[i+1] - for j := lo; j <= hi; j++ { - fn(j, c) - } - } -} diff --git a/vendor/golang.org/x/text/unicode/bidi/gen_trieval.go b/vendor/golang.org/x/text/unicode/bidi/gen_trieval.go deleted file mode 100644 index 9cb99428..00000000 --- a/vendor/golang.org/x/text/unicode/bidi/gen_trieval.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package main - -// Class is the Unicode BiDi class. Each rune has a single class. -type Class uint - -const ( - L Class = iota // LeftToRight - R // RightToLeft - EN // EuropeanNumber - ES // EuropeanSeparator - ET // EuropeanTerminator - AN // ArabicNumber - CS // CommonSeparator - B // ParagraphSeparator - S // SegmentSeparator - WS // WhiteSpace - ON // OtherNeutral - BN // BoundaryNeutral - NSM // NonspacingMark - AL // ArabicLetter - Control // Control LRO - PDI - - numClass - - LRO // LeftToRightOverride - RLO // RightToLeftOverride - LRE // LeftToRightEmbedding - RLE // RightToLeftEmbedding - PDF // PopDirectionalFormat - LRI // LeftToRightIsolate - RLI // RightToLeftIsolate - FSI // FirstStrongIsolate - PDI // PopDirectionalIsolate - - unknownClass = ^Class(0) -) - -var controlToClass = map[rune]Class{ - 0x202D: LRO, // LeftToRightOverride, - 0x202E: RLO, // RightToLeftOverride, - 0x202A: LRE, // LeftToRightEmbedding, - 0x202B: RLE, // RightToLeftEmbedding, - 0x202C: PDF, // PopDirectionalFormat, - 0x2066: LRI, // LeftToRightIsolate, - 0x2067: RLI, // RightToLeftIsolate, - 0x2068: FSI, // FirstStrongIsolate, - 0x2069: PDI, // PopDirectionalIsolate, -} - -// A trie entry has the following bits: -// 7..5 XOR mask for brackets -// 4 1: Bracket open, 0: Bracket close -// 3..0 Class type - -const ( - openMask = 0x10 - xorMaskShift = 5 -) diff --git a/vendor/golang.org/x/text/unicode/norm/maketables.go b/vendor/golang.org/x/text/unicode/norm/maketables.go deleted file mode 100644 index 30a3aa93..00000000 --- a/vendor/golang.org/x/text/unicode/norm/maketables.go +++ /dev/null @@ -1,986 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// Normalization table generator. -// Data read from the web. -// See forminfo.go for a description of the trie values associated with each rune. - -package main - -import ( - "bytes" - "encoding/binary" - "flag" - "fmt" - "io" - "log" - "sort" - "strconv" - "strings" - - "golang.org/x/text/internal/gen" - "golang.org/x/text/internal/triegen" - "golang.org/x/text/internal/ucd" -) - -func main() { - gen.Init() - loadUnicodeData() - compactCCC() - loadCompositionExclusions() - completeCharFields(FCanonical) - completeCharFields(FCompatibility) - computeNonStarterCounts() - verifyComputed() - printChars() - testDerived() - printTestdata() - makeTables() -} - -var ( - tablelist = flag.String("tables", - "all", - "comma-separated list of which tables to generate; "+ - "can be 'decomp', 'recomp', 'info' and 'all'") - test = flag.Bool("test", - false, - "test existing tables against DerivedNormalizationProps and generate test data for regression testing") - verbose = flag.Bool("verbose", - false, - "write data to stdout as it is parsed") -) - -const MaxChar = 0x10FFFF // anything above this shouldn't exist - -// Quick Check properties of runes allow us to quickly -// determine whether a rune may occur in a normal form. -// For a given normal form, a rune may be guaranteed to occur -// verbatim (QC=Yes), may or may not combine with another -// rune (QC=Maybe), or may not occur (QC=No). -type QCResult int - -const ( - QCUnknown QCResult = iota - QCYes - QCNo - QCMaybe -) - -func (r QCResult) String() string { - switch r { - case QCYes: - return "Yes" - case QCNo: - return "No" - case QCMaybe: - return "Maybe" - } - return "***UNKNOWN***" -} - -const ( - FCanonical = iota // NFC or NFD - FCompatibility // NFKC or NFKD - FNumberOfFormTypes -) - -const ( - MComposed = iota // NFC or NFKC - MDecomposed // NFD or NFKD - MNumberOfModes -) - -// This contains only the properties we're interested in. -type Char struct { - name string - codePoint rune // if zero, this index is not a valid code point. - ccc uint8 // canonical combining class - origCCC uint8 - excludeInComp bool // from CompositionExclusions.txt - compatDecomp bool // it has a compatibility expansion - - nTrailingNonStarters uint8 - nLeadingNonStarters uint8 // must be equal to trailing if non-zero - - forms [FNumberOfFormTypes]FormInfo // For FCanonical and FCompatibility - - state State -} - -var chars = make([]Char, MaxChar+1) -var cccMap = make(map[uint8]uint8) - -func (c Char) String() string { - buf := new(bytes.Buffer) - - fmt.Fprintf(buf, "%U [%s]:\n", c.codePoint, c.name) - fmt.Fprintf(buf, " ccc: %v\n", c.ccc) - fmt.Fprintf(buf, " excludeInComp: %v\n", c.excludeInComp) - fmt.Fprintf(buf, " compatDecomp: %v\n", c.compatDecomp) - fmt.Fprintf(buf, " state: %v\n", c.state) - fmt.Fprintf(buf, " NFC:\n") - fmt.Fprint(buf, c.forms[FCanonical]) - fmt.Fprintf(buf, " NFKC:\n") - fmt.Fprint(buf, c.forms[FCompatibility]) - - return buf.String() -} - -// In UnicodeData.txt, some ranges are marked like this: -// 3400;;Lo;0;L;;;;;N;;;;; -// 4DB5;;Lo;0;L;;;;;N;;;;; -// parseCharacter keeps a state variable indicating the weirdness. -type State int - -const ( - SNormal State = iota // known to be zero for the type - SFirst - SLast - SMissing -) - -var lastChar = rune('\u0000') - -func (c Char) isValid() bool { - return c.codePoint != 0 && c.state != SMissing -} - -type FormInfo struct { - quickCheck [MNumberOfModes]QCResult // index: MComposed or MDecomposed - verified [MNumberOfModes]bool // index: MComposed or MDecomposed - - combinesForward bool // May combine with rune on the right - combinesBackward bool // May combine with rune on the left - isOneWay bool // Never appears in result - inDecomp bool // Some decompositions result in this char. - decomp Decomposition - expandedDecomp Decomposition -} - -func (f FormInfo) String() string { - buf := bytes.NewBuffer(make([]byte, 0)) - - fmt.Fprintf(buf, " quickCheck[C]: %v\n", f.quickCheck[MComposed]) - fmt.Fprintf(buf, " quickCheck[D]: %v\n", f.quickCheck[MDecomposed]) - fmt.Fprintf(buf, " cmbForward: %v\n", f.combinesForward) - fmt.Fprintf(buf, " cmbBackward: %v\n", f.combinesBackward) - fmt.Fprintf(buf, " isOneWay: %v\n", f.isOneWay) - fmt.Fprintf(buf, " inDecomp: %v\n", f.inDecomp) - fmt.Fprintf(buf, " decomposition: %X\n", f.decomp) - fmt.Fprintf(buf, " expandedDecomp: %X\n", f.expandedDecomp) - - return buf.String() -} - -type Decomposition []rune - -func parseDecomposition(s string, skipfirst bool) (a []rune, err error) { - decomp := strings.Split(s, " ") - if len(decomp) > 0 && skipfirst { - decomp = decomp[1:] - } - for _, d := range decomp { - point, err := strconv.ParseUint(d, 16, 64) - if err != nil { - return a, err - } - a = append(a, rune(point)) - } - return a, nil -} - -func loadUnicodeData() { - f := gen.OpenUCDFile("UnicodeData.txt") - defer f.Close() - p := ucd.New(f) - for p.Next() { - r := p.Rune(ucd.CodePoint) - char := &chars[r] - - char.ccc = uint8(p.Uint(ucd.CanonicalCombiningClass)) - decmap := p.String(ucd.DecompMapping) - - exp, err := parseDecomposition(decmap, false) - isCompat := false - if err != nil { - if len(decmap) > 0 { - exp, err = parseDecomposition(decmap, true) - if err != nil { - log.Fatalf(`%U: bad decomp |%v|: "%s"`, r, decmap, err) - } - isCompat = true - } - } - - char.name = p.String(ucd.Name) - char.codePoint = r - char.forms[FCompatibility].decomp = exp - if !isCompat { - char.forms[FCanonical].decomp = exp - } else { - char.compatDecomp = true - } - if len(decmap) > 0 { - char.forms[FCompatibility].decomp = exp - } - } - if err := p.Err(); err != nil { - log.Fatal(err) - } -} - -// compactCCC converts the sparse set of CCC values to a continguous one, -// reducing the number of bits needed from 8 to 6. -func compactCCC() { - m := make(map[uint8]uint8) - for i := range chars { - c := &chars[i] - m[c.ccc] = 0 - } - cccs := []int{} - for v, _ := range m { - cccs = append(cccs, int(v)) - } - sort.Ints(cccs) - for i, c := range cccs { - cccMap[uint8(i)] = uint8(c) - m[uint8(c)] = uint8(i) - } - for i := range chars { - c := &chars[i] - c.origCCC = c.ccc - c.ccc = m[c.ccc] - } - if len(m) >= 1<<6 { - log.Fatalf("too many difference CCC values: %d >= 64", len(m)) - } -} - -// CompositionExclusions.txt has form: -// 0958 # ... -// See https://unicode.org/reports/tr44/ for full explanation -func loadCompositionExclusions() { - f := gen.OpenUCDFile("CompositionExclusions.txt") - defer f.Close() - p := ucd.New(f) - for p.Next() { - c := &chars[p.Rune(0)] - if c.excludeInComp { - log.Fatalf("%U: Duplicate entry in exclusions.", c.codePoint) - } - c.excludeInComp = true - } - if e := p.Err(); e != nil { - log.Fatal(e) - } -} - -// hasCompatDecomp returns true if any of the recursive -// decompositions contains a compatibility expansion. -// In this case, the character may not occur in NFK*. -func hasCompatDecomp(r rune) bool { - c := &chars[r] - if c.compatDecomp { - return true - } - for _, d := range c.forms[FCompatibility].decomp { - if hasCompatDecomp(d) { - return true - } - } - return false -} - -// Hangul related constants. -const ( - HangulBase = 0xAC00 - HangulEnd = 0xD7A4 // hangulBase + Jamo combinations (19 * 21 * 28) - - JamoLBase = 0x1100 - JamoLEnd = 0x1113 - JamoVBase = 0x1161 - JamoVEnd = 0x1176 - JamoTBase = 0x11A8 - JamoTEnd = 0x11C3 - - JamoLVTCount = 19 * 21 * 28 - JamoTCount = 28 -) - -func isHangul(r rune) bool { - return HangulBase <= r && r < HangulEnd -} - -func isHangulWithoutJamoT(r rune) bool { - if !isHangul(r) { - return false - } - r -= HangulBase - return r < JamoLVTCount && r%JamoTCount == 0 -} - -func ccc(r rune) uint8 { - return chars[r].ccc -} - -// Insert a rune in a buffer, ordered by Canonical Combining Class. -func insertOrdered(b Decomposition, r rune) Decomposition { - n := len(b) - b = append(b, 0) - cc := ccc(r) - if cc > 0 { - // Use bubble sort. - for ; n > 0; n-- { - if ccc(b[n-1]) <= cc { - break - } - b[n] = b[n-1] - } - } - b[n] = r - return b -} - -// Recursively decompose. -func decomposeRecursive(form int, r rune, d Decomposition) Decomposition { - dcomp := chars[r].forms[form].decomp - if len(dcomp) == 0 { - return insertOrdered(d, r) - } - for _, c := range dcomp { - d = decomposeRecursive(form, c, d) - } - return d -} - -func completeCharFields(form int) { - // Phase 0: pre-expand decomposition. - for i := range chars { - f := &chars[i].forms[form] - if len(f.decomp) == 0 { - continue - } - exp := make(Decomposition, 0) - for _, c := range f.decomp { - exp = decomposeRecursive(form, c, exp) - } - f.expandedDecomp = exp - } - - // Phase 1: composition exclusion, mark decomposition. - for i := range chars { - c := &chars[i] - f := &c.forms[form] - - // Marks script-specific exclusions and version restricted. - f.isOneWay = c.excludeInComp - - // Singletons - f.isOneWay = f.isOneWay || len(f.decomp) == 1 - - // Non-starter decompositions - if len(f.decomp) > 1 { - chk := c.ccc != 0 || chars[f.decomp[0]].ccc != 0 - f.isOneWay = f.isOneWay || chk - } - - // Runes that decompose into more than two runes. - f.isOneWay = f.isOneWay || len(f.decomp) > 2 - - if form == FCompatibility { - f.isOneWay = f.isOneWay || hasCompatDecomp(c.codePoint) - } - - for _, r := range f.decomp { - chars[r].forms[form].inDecomp = true - } - } - - // Phase 2: forward and backward combining. - for i := range chars { - c := &chars[i] - f := &c.forms[form] - - if !f.isOneWay && len(f.decomp) == 2 { - f0 := &chars[f.decomp[0]].forms[form] - f1 := &chars[f.decomp[1]].forms[form] - if !f0.isOneWay { - f0.combinesForward = true - } - if !f1.isOneWay { - f1.combinesBackward = true - } - } - if isHangulWithoutJamoT(rune(i)) { - f.combinesForward = true - } - } - - // Phase 3: quick check values. - for i := range chars { - c := &chars[i] - f := &c.forms[form] - - switch { - case len(f.decomp) > 0: - f.quickCheck[MDecomposed] = QCNo - case isHangul(rune(i)): - f.quickCheck[MDecomposed] = QCNo - default: - f.quickCheck[MDecomposed] = QCYes - } - switch { - case f.isOneWay: - f.quickCheck[MComposed] = QCNo - case (i & 0xffff00) == JamoLBase: - f.quickCheck[MComposed] = QCYes - if JamoLBase <= i && i < JamoLEnd { - f.combinesForward = true - } - if JamoVBase <= i && i < JamoVEnd { - f.quickCheck[MComposed] = QCMaybe - f.combinesBackward = true - f.combinesForward = true - } - if JamoTBase <= i && i < JamoTEnd { - f.quickCheck[MComposed] = QCMaybe - f.combinesBackward = true - } - case !f.combinesBackward: - f.quickCheck[MComposed] = QCYes - default: - f.quickCheck[MComposed] = QCMaybe - } - } -} - -func computeNonStarterCounts() { - // Phase 4: leading and trailing non-starter count - for i := range chars { - c := &chars[i] - - runes := []rune{rune(i)} - // We always use FCompatibility so that the CGJ insertion points do not - // change for repeated normalizations with different forms. - if exp := c.forms[FCompatibility].expandedDecomp; len(exp) > 0 { - runes = exp - } - // We consider runes that combine backwards to be non-starters for the - // purpose of Stream-Safe Text Processing. - for _, r := range runes { - if cr := &chars[r]; cr.ccc == 0 && !cr.forms[FCompatibility].combinesBackward { - break - } - c.nLeadingNonStarters++ - } - for i := len(runes) - 1; i >= 0; i-- { - if cr := &chars[runes[i]]; cr.ccc == 0 && !cr.forms[FCompatibility].combinesBackward { - break - } - c.nTrailingNonStarters++ - } - if c.nTrailingNonStarters > 3 { - log.Fatalf("%U: Decomposition with more than 3 (%d) trailing modifiers (%U)", i, c.nTrailingNonStarters, runes) - } - - if isHangul(rune(i)) { - c.nTrailingNonStarters = 2 - if isHangulWithoutJamoT(rune(i)) { - c.nTrailingNonStarters = 1 - } - } - - if l, t := c.nLeadingNonStarters, c.nTrailingNonStarters; l > 0 && l != t { - log.Fatalf("%U: number of leading and trailing non-starters should be equal (%d vs %d)", i, l, t) - } - if t := c.nTrailingNonStarters; t > 3 { - log.Fatalf("%U: number of trailing non-starters is %d > 3", t) - } - } -} - -func printBytes(w io.Writer, b []byte, name string) { - fmt.Fprintf(w, "// %s: %d bytes\n", name, len(b)) - fmt.Fprintf(w, "var %s = [...]byte {", name) - for i, c := range b { - switch { - case i%64 == 0: - fmt.Fprintf(w, "\n// Bytes %x - %x\n", i, i+63) - case i%8 == 0: - fmt.Fprintf(w, "\n") - } - fmt.Fprintf(w, "0x%.2X, ", c) - } - fmt.Fprint(w, "\n}\n\n") -} - -// See forminfo.go for format. -func makeEntry(f *FormInfo, c *Char) uint16 { - e := uint16(0) - if r := c.codePoint; HangulBase <= r && r < HangulEnd { - e |= 0x40 - } - if f.combinesForward { - e |= 0x20 - } - if f.quickCheck[MDecomposed] == QCNo { - e |= 0x4 - } - switch f.quickCheck[MComposed] { - case QCYes: - case QCNo: - e |= 0x10 - case QCMaybe: - e |= 0x18 - default: - log.Fatalf("Illegal quickcheck value %v.", f.quickCheck[MComposed]) - } - e |= uint16(c.nTrailingNonStarters) - return e -} - -// decompSet keeps track of unique decompositions, grouped by whether -// the decomposition is followed by a trailing and/or leading CCC. -type decompSet [7]map[string]bool - -const ( - normalDecomp = iota - firstMulti - firstCCC - endMulti - firstLeadingCCC - firstCCCZeroExcept - firstStarterWithNLead - lastDecomp -) - -var cname = []string{"firstMulti", "firstCCC", "endMulti", "firstLeadingCCC", "firstCCCZeroExcept", "firstStarterWithNLead", "lastDecomp"} - -func makeDecompSet() decompSet { - m := decompSet{} - for i := range m { - m[i] = make(map[string]bool) - } - return m -} -func (m *decompSet) insert(key int, s string) { - m[key][s] = true -} - -func printCharInfoTables(w io.Writer) int { - mkstr := func(r rune, f *FormInfo) (int, string) { - d := f.expandedDecomp - s := string([]rune(d)) - if max := 1 << 6; len(s) >= max { - const msg = "%U: too many bytes in decomposition: %d >= %d" - log.Fatalf(msg, r, len(s), max) - } - head := uint8(len(s)) - if f.quickCheck[MComposed] != QCYes { - head |= 0x40 - } - if f.combinesForward { - head |= 0x80 - } - s = string([]byte{head}) + s - - lccc := ccc(d[0]) - tccc := ccc(d[len(d)-1]) - cc := ccc(r) - if cc != 0 && lccc == 0 && tccc == 0 { - log.Fatalf("%U: trailing and leading ccc are 0 for non-zero ccc %d", r, cc) - } - if tccc < lccc && lccc != 0 { - const msg = "%U: lccc (%d) must be <= tcc (%d)" - log.Fatalf(msg, r, lccc, tccc) - } - index := normalDecomp - nTrail := chars[r].nTrailingNonStarters - nLead := chars[r].nLeadingNonStarters - if tccc > 0 || lccc > 0 || nTrail > 0 { - tccc <<= 2 - tccc |= nTrail - s += string([]byte{tccc}) - index = endMulti - for _, r := range d[1:] { - if ccc(r) == 0 { - index = firstCCC - } - } - if lccc > 0 || nLead > 0 { - s += string([]byte{lccc}) - if index == firstCCC { - log.Fatalf("%U: multi-segment decomposition not supported for decompositions with leading CCC != 0", r) - } - index = firstLeadingCCC - } - if cc != lccc { - if cc != 0 { - log.Fatalf("%U: for lccc != ccc, expected ccc to be 0; was %d", r, cc) - } - index = firstCCCZeroExcept - } - } else if len(d) > 1 { - index = firstMulti - } - return index, s - } - - decompSet := makeDecompSet() - const nLeadStr = "\x00\x01" // 0-byte length and tccc with nTrail. - decompSet.insert(firstStarterWithNLead, nLeadStr) - - // Store the uniqued decompositions in a byte buffer, - // preceded by their byte length. - for _, c := range chars { - for _, f := range c.forms { - if len(f.expandedDecomp) == 0 { - continue - } - if f.combinesBackward { - log.Fatalf("%U: combinesBackward and decompose", c.codePoint) - } - index, s := mkstr(c.codePoint, &f) - decompSet.insert(index, s) - } - } - - decompositions := bytes.NewBuffer(make([]byte, 0, 10000)) - size := 0 - positionMap := make(map[string]uint16) - decompositions.WriteString("\000") - fmt.Fprintln(w, "const (") - for i, m := range decompSet { - sa := []string{} - for s := range m { - sa = append(sa, s) - } - sort.Strings(sa) - for _, s := range sa { - p := decompositions.Len() - decompositions.WriteString(s) - positionMap[s] = uint16(p) - } - if cname[i] != "" { - fmt.Fprintf(w, "%s = 0x%X\n", cname[i], decompositions.Len()) - } - } - fmt.Fprintln(w, "maxDecomp = 0x8000") - fmt.Fprintln(w, ")") - b := decompositions.Bytes() - printBytes(w, b, "decomps") - size += len(b) - - varnames := []string{"nfc", "nfkc"} - for i := 0; i < FNumberOfFormTypes; i++ { - trie := triegen.NewTrie(varnames[i]) - - for r, c := range chars { - f := c.forms[i] - d := f.expandedDecomp - if len(d) != 0 { - _, key := mkstr(c.codePoint, &f) - trie.Insert(rune(r), uint64(positionMap[key])) - if c.ccc != ccc(d[0]) { - // We assume the lead ccc of a decomposition !=0 in this case. - if ccc(d[0]) == 0 { - log.Fatalf("Expected leading CCC to be non-zero; ccc is %d", c.ccc) - } - } - } else if c.nLeadingNonStarters > 0 && len(f.expandedDecomp) == 0 && c.ccc == 0 && !f.combinesBackward { - // Handle cases where it can't be detected that the nLead should be equal - // to nTrail. - trie.Insert(c.codePoint, uint64(positionMap[nLeadStr])) - } else if v := makeEntry(&f, &c)<<8 | uint16(c.ccc); v != 0 { - trie.Insert(c.codePoint, uint64(0x8000|v)) - } - } - sz, err := trie.Gen(w, triegen.Compact(&normCompacter{name: varnames[i]})) - if err != nil { - log.Fatal(err) - } - size += sz - } - return size -} - -func contains(sa []string, s string) bool { - for _, a := range sa { - if a == s { - return true - } - } - return false -} - -func makeTables() { - w := &bytes.Buffer{} - - size := 0 - if *tablelist == "" { - return - } - list := strings.Split(*tablelist, ",") - if *tablelist == "all" { - list = []string{"recomp", "info"} - } - - // Compute maximum decomposition size. - max := 0 - for _, c := range chars { - if n := len(string(c.forms[FCompatibility].expandedDecomp)); n > max { - max = n - } - } - fmt.Fprintln(w, `import "sync"`) - fmt.Fprintln(w) - - fmt.Fprintln(w, "const (") - fmt.Fprintln(w, "\t// Version is the Unicode edition from which the tables are derived.") - fmt.Fprintf(w, "\tVersion = %q\n", gen.UnicodeVersion()) - fmt.Fprintln(w) - fmt.Fprintln(w, "\t// MaxTransformChunkSize indicates the maximum number of bytes that Transform") - fmt.Fprintln(w, "\t// may need to write atomically for any Form. Making a destination buffer at") - fmt.Fprintln(w, "\t// least this size ensures that Transform can always make progress and that") - fmt.Fprintln(w, "\t// the user does not need to grow the buffer on an ErrShortDst.") - fmt.Fprintf(w, "\tMaxTransformChunkSize = %d+maxNonStarters*4\n", len(string(0x034F))+max) - fmt.Fprintln(w, ")\n") - - // Print the CCC remap table. - size += len(cccMap) - fmt.Fprintf(w, "var ccc = [%d]uint8{", len(cccMap)) - for i := 0; i < len(cccMap); i++ { - if i%8 == 0 { - fmt.Fprintln(w) - } - fmt.Fprintf(w, "%3d, ", cccMap[uint8(i)]) - } - fmt.Fprintln(w, "\n}\n") - - if contains(list, "info") { - size += printCharInfoTables(w) - } - - if contains(list, "recomp") { - // Note that we use 32 bit keys, instead of 64 bit. - // This clips the bits of three entries, but we know - // this won't cause a collision. The compiler will catch - // any changes made to UnicodeData.txt that introduces - // a collision. - // Note that the recomposition map for NFC and NFKC - // are identical. - - // Recomposition map - nrentries := 0 - for _, c := range chars { - f := c.forms[FCanonical] - if !f.isOneWay && len(f.decomp) > 0 { - nrentries++ - } - } - sz := nrentries * 8 - size += sz - fmt.Fprintf(w, "// recompMap: %d bytes (entries only)\n", sz) - fmt.Fprintln(w, "var recompMap map[uint32]rune") - fmt.Fprintln(w, "var recompMapOnce sync.Once\n") - fmt.Fprintln(w, `const recompMapPacked = "" +`) - var buf [8]byte - for i, c := range chars { - f := c.forms[FCanonical] - d := f.decomp - if !f.isOneWay && len(d) > 0 { - key := uint32(uint16(d[0]))<<16 + uint32(uint16(d[1])) - binary.BigEndian.PutUint32(buf[:4], key) - binary.BigEndian.PutUint32(buf[4:], uint32(i)) - fmt.Fprintf(w, "\t\t%q + // 0x%.8X: 0x%.8X\n", string(buf[:]), key, uint32(i)) - } - } - // hack so we don't have to special case the trailing plus sign - fmt.Fprintf(w, ` ""`) - fmt.Fprintln(w) - } - - fmt.Fprintf(w, "// Total size of tables: %dKB (%d bytes)\n", (size+512)/1024, size) - gen.WriteVersionedGoFile("tables.go", "norm", w.Bytes()) -} - -func printChars() { - if *verbose { - for _, c := range chars { - if !c.isValid() || c.state == SMissing { - continue - } - fmt.Println(c) - } - } -} - -// verifyComputed does various consistency tests. -func verifyComputed() { - for i, c := range chars { - for _, f := range c.forms { - isNo := (f.quickCheck[MDecomposed] == QCNo) - if (len(f.decomp) > 0) != isNo && !isHangul(rune(i)) { - log.Fatalf("%U: NF*D QC must be No if rune decomposes", i) - } - - isMaybe := f.quickCheck[MComposed] == QCMaybe - if f.combinesBackward != isMaybe { - log.Fatalf("%U: NF*C QC must be Maybe if combinesBackward", i) - } - if len(f.decomp) > 0 && f.combinesForward && isMaybe { - log.Fatalf("%U: NF*C QC must be Yes or No if combinesForward and decomposes", i) - } - - if len(f.expandedDecomp) != 0 { - continue - } - if a, b := c.nLeadingNonStarters > 0, (c.ccc > 0 || f.combinesBackward); a != b { - // We accept these runes to be treated differently (it only affects - // segment breaking in iteration, most likely on improper use), but - // reconsider if more characters are added. - // U+FF9E HALFWIDTH KATAKANA VOICED SOUND MARK;Lm;0;L; 3099;;;;N;;;;; - // U+FF9F HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK;Lm;0;L; 309A;;;;N;;;;; - // U+3133 HANGUL LETTER KIYEOK-SIOS;Lo;0;L; 11AA;;;;N;HANGUL LETTER GIYEOG SIOS;;;; - // U+318E HANGUL LETTER ARAEAE;Lo;0;L; 11A1;;;;N;HANGUL LETTER ALAE AE;;;; - // U+FFA3 HALFWIDTH HANGUL LETTER KIYEOK-SIOS;Lo;0;L; 3133;;;;N;HALFWIDTH HANGUL LETTER GIYEOG SIOS;;;; - // U+FFDC HALFWIDTH HANGUL LETTER I;Lo;0;L; 3163;;;;N;;;;; - if i != 0xFF9E && i != 0xFF9F && !(0x3133 <= i && i <= 0x318E) && !(0xFFA3 <= i && i <= 0xFFDC) { - log.Fatalf("%U: nLead was %v; want %v", i, a, b) - } - } - } - nfc := c.forms[FCanonical] - nfkc := c.forms[FCompatibility] - if nfc.combinesBackward != nfkc.combinesBackward { - log.Fatalf("%U: Cannot combine combinesBackward\n", c.codePoint) - } - } -} - -// Use values in DerivedNormalizationProps.txt to compare against the -// values we computed. -// DerivedNormalizationProps.txt has form: -// 00C0..00C5 ; NFD_QC; N # ... -// 0374 ; NFD_QC; N # ... -// See https://unicode.org/reports/tr44/ for full explanation -func testDerived() { - f := gen.OpenUCDFile("DerivedNormalizationProps.txt") - defer f.Close() - p := ucd.New(f) - for p.Next() { - r := p.Rune(0) - c := &chars[r] - - var ftype, mode int - qt := p.String(1) - switch qt { - case "NFC_QC": - ftype, mode = FCanonical, MComposed - case "NFD_QC": - ftype, mode = FCanonical, MDecomposed - case "NFKC_QC": - ftype, mode = FCompatibility, MComposed - case "NFKD_QC": - ftype, mode = FCompatibility, MDecomposed - default: - continue - } - var qr QCResult - switch p.String(2) { - case "Y": - qr = QCYes - case "N": - qr = QCNo - case "M": - qr = QCMaybe - default: - log.Fatalf(`Unexpected quick check value "%s"`, p.String(2)) - } - if got := c.forms[ftype].quickCheck[mode]; got != qr { - log.Printf("%U: FAILED %s (was %v need %v)\n", r, qt, got, qr) - } - c.forms[ftype].verified[mode] = true - } - if err := p.Err(); err != nil { - log.Fatal(err) - } - // Any unspecified value must be QCYes. Verify this. - for i, c := range chars { - for j, fd := range c.forms { - for k, qr := range fd.quickCheck { - if !fd.verified[k] && qr != QCYes { - m := "%U: FAIL F:%d M:%d (was %v need Yes) %s\n" - log.Printf(m, i, j, k, qr, c.name) - } - } - } - } -} - -var testHeader = `const ( - Yes = iota - No - Maybe -) - -type formData struct { - qc uint8 - combinesForward bool - decomposition string -} - -type runeData struct { - r rune - ccc uint8 - nLead uint8 - nTrail uint8 - f [2]formData // 0: canonical; 1: compatibility -} - -func f(qc uint8, cf bool, dec string) [2]formData { - return [2]formData{{qc, cf, dec}, {qc, cf, dec}} -} - -func g(qc, qck uint8, cf, cfk bool, d, dk string) [2]formData { - return [2]formData{{qc, cf, d}, {qck, cfk, dk}} -} - -var testData = []runeData{ -` - -func printTestdata() { - type lastInfo struct { - ccc uint8 - nLead uint8 - nTrail uint8 - f string - } - - last := lastInfo{} - w := &bytes.Buffer{} - fmt.Fprintf(w, testHeader) - for r, c := range chars { - f := c.forms[FCanonical] - qc, cf, d := f.quickCheck[MComposed], f.combinesForward, string(f.expandedDecomp) - f = c.forms[FCompatibility] - qck, cfk, dk := f.quickCheck[MComposed], f.combinesForward, string(f.expandedDecomp) - s := "" - if d == dk && qc == qck && cf == cfk { - s = fmt.Sprintf("f(%s, %v, %q)", qc, cf, d) - } else { - s = fmt.Sprintf("g(%s, %s, %v, %v, %q, %q)", qc, qck, cf, cfk, d, dk) - } - current := lastInfo{c.ccc, c.nLeadingNonStarters, c.nTrailingNonStarters, s} - if last != current { - fmt.Fprintf(w, "\t{0x%x, %d, %d, %d, %s},\n", r, c.origCCC, c.nLeadingNonStarters, c.nTrailingNonStarters, s) - last = current - } - } - fmt.Fprintln(w, "}") - gen.WriteVersionedGoFile("data_test.go", "norm", w.Bytes()) -} diff --git a/vendor/golang.org/x/text/unicode/norm/triegen.go b/vendor/golang.org/x/text/unicode/norm/triegen.go deleted file mode 100644 index 45d71190..00000000 --- a/vendor/golang.org/x/text/unicode/norm/triegen.go +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// Trie table generator. -// Used by make*tables tools to generate a go file with trie data structures -// for mapping UTF-8 to a 16-bit value. All but the last byte in a UTF-8 byte -// sequence are used to lookup offsets in the index table to be used for the -// next byte. The last byte is used to index into a table with 16-bit values. - -package main - -import ( - "fmt" - "io" -) - -const maxSparseEntries = 16 - -type normCompacter struct { - sparseBlocks [][]uint64 - sparseOffset []uint16 - sparseCount int - name string -} - -func mostFrequentStride(a []uint64) int { - counts := make(map[int]int) - var v int - for _, x := range a { - if stride := int(x) - v; v != 0 && stride >= 0 { - counts[stride]++ - } - v = int(x) - } - var maxs, maxc int - for stride, cnt := range counts { - if cnt > maxc || (cnt == maxc && stride < maxs) { - maxs, maxc = stride, cnt - } - } - return maxs -} - -func countSparseEntries(a []uint64) int { - stride := mostFrequentStride(a) - var v, count int - for _, tv := range a { - if int(tv)-v != stride { - if tv != 0 { - count++ - } - } - v = int(tv) - } - return count -} - -func (c *normCompacter) Size(v []uint64) (sz int, ok bool) { - if n := countSparseEntries(v); n <= maxSparseEntries { - return (n+1)*4 + 2, true - } - return 0, false -} - -func (c *normCompacter) Store(v []uint64) uint32 { - h := uint32(len(c.sparseOffset)) - c.sparseBlocks = append(c.sparseBlocks, v) - c.sparseOffset = append(c.sparseOffset, uint16(c.sparseCount)) - c.sparseCount += countSparseEntries(v) + 1 - return h -} - -func (c *normCompacter) Handler() string { - return c.name + "Sparse.lookup" -} - -func (c *normCompacter) Print(w io.Writer) (retErr error) { - p := func(f string, x ...interface{}) { - if _, err := fmt.Fprintf(w, f, x...); retErr == nil && err != nil { - retErr = err - } - } - - ls := len(c.sparseBlocks) - p("// %sSparseOffset: %d entries, %d bytes\n", c.name, ls, ls*2) - p("var %sSparseOffset = %#v\n\n", c.name, c.sparseOffset) - - ns := c.sparseCount - p("// %sSparseValues: %d entries, %d bytes\n", c.name, ns, ns*4) - p("var %sSparseValues = [%d]valueRange {", c.name, ns) - for i, b := range c.sparseBlocks { - p("\n// Block %#x, offset %#x", i, c.sparseOffset[i]) - var v int - stride := mostFrequentStride(b) - n := countSparseEntries(b) - p("\n{value:%#04x,lo:%#02x},", stride, uint8(n)) - for i, nv := range b { - if int(nv)-v != stride { - if v != 0 { - p(",hi:%#02x},", 0x80+i-1) - } - if nv != 0 { - p("\n{value:%#04x,lo:%#02x", nv, 0x80+i) - } - } - v = int(nv) - } - if v != 0 { - p(",hi:%#02x},", 0x80+len(b)-1) - } - } - p("\n}\n\n") - return -} diff --git a/vendor/golang.org/x/text/width/gen.go b/vendor/golang.org/x/text/width/gen.go deleted file mode 100644 index 092277e1..00000000 --- a/vendor/golang.org/x/text/width/gen.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// This program generates the trie for width operations. The generated table -// includes width category information as well as the normalization mappings. -package main - -import ( - "bytes" - "fmt" - "io" - "log" - "math" - "unicode/utf8" - - "golang.org/x/text/internal/gen" - "golang.org/x/text/internal/triegen" -) - -// See gen_common.go for flags. - -func main() { - gen.Init() - genTables() - genTests() - gen.Repackage("gen_trieval.go", "trieval.go", "width") - gen.Repackage("gen_common.go", "common_test.go", "width") -} - -func genTables() { - t := triegen.NewTrie("width") - // fold and inverse mappings. See mapComment for a description of the format - // of each entry. Add dummy value to make an index of 0 mean no mapping. - inverse := [][4]byte{{}} - mapping := map[[4]byte]int{[4]byte{}: 0} - - getWidthData(func(r rune, tag elem, alt rune) { - idx := 0 - if alt != 0 { - var buf [4]byte - buf[0] = byte(utf8.EncodeRune(buf[1:], alt)) - s := string(r) - buf[buf[0]] ^= s[len(s)-1] - var ok bool - if idx, ok = mapping[buf]; !ok { - idx = len(mapping) - if idx > math.MaxUint8 { - log.Fatalf("Index %d does not fit in a byte.", idx) - } - mapping[buf] = idx - inverse = append(inverse, buf) - } - } - t.Insert(r, uint64(tag|elem(idx))) - }) - - w := &bytes.Buffer{} - gen.WriteUnicodeVersion(w) - - sz, err := t.Gen(w) - if err != nil { - log.Fatal(err) - } - - sz += writeMappings(w, inverse) - - fmt.Fprintf(w, "// Total table size %d bytes (%dKiB)\n", sz, sz/1024) - - gen.WriteVersionedGoFile(*outputFile, "width", w.Bytes()) -} - -const inverseDataComment = ` -// inverseData contains 4-byte entries of the following format: -// <0 padding> -// The last byte of the UTF-8-encoded rune is xor-ed with the last byte of the -// UTF-8 encoding of the original rune. Mappings often have the following -// pattern: -// A -> A (U+FF21 -> U+0041) -// B -> B (U+FF22 -> U+0042) -// ... -// By xor-ing the last byte the same entry can be shared by many mappings. This -// reduces the total number of distinct entries by about two thirds. -// The resulting entry for the aforementioned mappings is -// { 0x01, 0xE0, 0x00, 0x00 } -// Using this entry to map U+FF21 (UTF-8 [EF BC A1]), we get -// E0 ^ A1 = 41. -// Similarly, for U+FF22 (UTF-8 [EF BC A2]), we get -// E0 ^ A2 = 42. -// Note that because of the xor-ing, the byte sequence stored in the entry is -// not valid UTF-8.` - -func writeMappings(w io.Writer, data [][4]byte) int { - fmt.Fprintln(w, inverseDataComment) - fmt.Fprintf(w, "var inverseData = [%d][4]byte{\n", len(data)) - for _, x := range data { - fmt.Fprintf(w, "{ 0x%02x, 0x%02x, 0x%02x, 0x%02x },\n", x[0], x[1], x[2], x[3]) - } - fmt.Fprintln(w, "}") - return len(data) * 4 -} - -func genTests() { - w := &bytes.Buffer{} - fmt.Fprintf(w, "\nvar mapRunes = map[rune]struct{r rune; e elem}{\n") - getWidthData(func(r rune, tag elem, alt rune) { - if alt != 0 { - fmt.Fprintf(w, "\t0x%X: {0x%X, 0x%X},\n", r, alt, tag) - } - }) - fmt.Fprintln(w, "}") - gen.WriteGoFile("runes_test.go", "width", w.Bytes()) -} diff --git a/vendor/golang.org/x/text/width/gen_common.go b/vendor/golang.org/x/text/width/gen_common.go deleted file mode 100644 index 601e7526..00000000 --- a/vendor/golang.org/x/text/width/gen_common.go +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package main - -// This code is shared between the main code generator and the test code. - -import ( - "flag" - "log" - "strconv" - "strings" - - "golang.org/x/text/internal/gen" - "golang.org/x/text/internal/ucd" -) - -var ( - outputFile = flag.String("out", "tables.go", "output file") -) - -var typeMap = map[string]elem{ - "A": tagAmbiguous, - "N": tagNeutral, - "Na": tagNarrow, - "W": tagWide, - "F": tagFullwidth, - "H": tagHalfwidth, -} - -// getWidthData calls f for every entry for which it is defined. -// -// f may be called multiple times for the same rune. The last call to f is the -// correct value. f is not called for all runes. The default tag type is -// Neutral. -func getWidthData(f func(r rune, tag elem, alt rune)) { - // Set the default values for Unified Ideographs. In line with Annex 11, - // we encode full ranges instead of the defined runes in Unified_Ideograph. - for _, b := range []struct{ lo, hi rune }{ - {0x4E00, 0x9FFF}, // the CJK Unified Ideographs block, - {0x3400, 0x4DBF}, // the CJK Unified Ideographs Externsion A block, - {0xF900, 0xFAFF}, // the CJK Compatibility Ideographs block, - {0x20000, 0x2FFFF}, // the Supplementary Ideographic Plane, - {0x30000, 0x3FFFF}, // the Tertiary Ideographic Plane, - } { - for r := b.lo; r <= b.hi; r++ { - f(r, tagWide, 0) - } - } - - inverse := map[rune]rune{} - maps := map[string]bool{ - "": true, - "": true, - } - - // We cannot reuse package norm's decomposition, as we need an unexpanded - // decomposition. We make use of the opportunity to verify that the - // decomposition type is as expected. - ucd.Parse(gen.OpenUCDFile("UnicodeData.txt"), func(p *ucd.Parser) { - r := p.Rune(0) - s := strings.SplitN(p.String(ucd.DecompMapping), " ", 2) - if !maps[s[0]] { - return - } - x, err := strconv.ParseUint(s[1], 16, 32) - if err != nil { - log.Fatalf("Error parsing rune %q", s[1]) - } - if inverse[r] != 0 || inverse[rune(x)] != 0 { - log.Fatalf("Circular dependency in mapping between %U and %U", r, x) - } - inverse[r] = rune(x) - inverse[rune(x)] = r - }) - - // ; - ucd.Parse(gen.OpenUCDFile("EastAsianWidth.txt"), func(p *ucd.Parser) { - tag, ok := typeMap[p.String(1)] - if !ok { - log.Fatalf("Unknown width type %q", p.String(1)) - } - r := p.Rune(0) - alt, ok := inverse[r] - if tag == tagFullwidth || tag == tagHalfwidth && r != wonSign { - tag |= tagNeedsFold - if !ok { - log.Fatalf("Narrow or wide rune %U has no decomposition", r) - } - } - f(r, tag, alt) - }) -} diff --git a/vendor/golang.org/x/text/width/gen_trieval.go b/vendor/golang.org/x/text/width/gen_trieval.go deleted file mode 100644 index c17334aa..00000000 --- a/vendor/golang.org/x/text/width/gen_trieval.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package main - -// elem is an entry of the width trie. The high byte is used to encode the type -// of the rune. The low byte is used to store the index to a mapping entry in -// the inverseData array. -type elem uint16 - -const ( - tagNeutral elem = iota << typeShift - tagAmbiguous - tagWide - tagNarrow - tagFullwidth - tagHalfwidth -) - -const ( - numTypeBits = 3 - typeShift = 16 - numTypeBits - - // tagNeedsFold is true for all fullwidth and halfwidth runes except for - // the Won sign U+20A9. - tagNeedsFold = 0x1000 - - // The Korean Won sign is halfwidth, but SHOULD NOT be mapped to a wide - // variant. - wonSign rune = 0x20A9 -) diff --git a/vendor/modules.txt b/vendor/modules.txt index 29b04650..d3402ca4 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -11,36 +11,36 @@ github.com/beorn7/perks/quantile # github.com/blang/semver v3.5.1+incompatible github.com/blang/semver # github.com/coreos/etcd v3.3.13+incompatible -github.com/coreos/etcd/clientv3 -github.com/coreos/etcd/pkg/transport github.com/coreos/etcd/auth/authpb +github.com/coreos/etcd/clientv3 github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes github.com/coreos/etcd/etcdserver/etcdserverpb github.com/coreos/etcd/mvcc/mvccpb -github.com/coreos/etcd/pkg/types github.com/coreos/etcd/pkg/tlsutil +github.com/coreos/etcd/pkg/transport +github.com/coreos/etcd/pkg/types # github.com/davecgh/go-spew v1.1.1 github.com/davecgh/go-spew/spew # github.com/docker/distribution v2.7.1+incompatible -github.com/docker/distribution/reference github.com/docker/distribution/digestset +github.com/docker/distribution/reference # github.com/docker/docker v1.13.1 github.com/docker/docker/api/types -github.com/docker/docker/client +github.com/docker/docker/api/types/blkiodev github.com/docker/docker/api/types/container +github.com/docker/docker/api/types/events github.com/docker/docker/api/types/filters github.com/docker/docker/api/types/mount github.com/docker/docker/api/types/network +github.com/docker/docker/api/types/reference github.com/docker/docker/api/types/registry +github.com/docker/docker/api/types/strslice github.com/docker/docker/api/types/swarm -github.com/docker/docker/api/types/events -github.com/docker/docker/api/types/reference github.com/docker/docker/api/types/time github.com/docker/docker/api/types/versions github.com/docker/docker/api/types/volume +github.com/docker/docker/client github.com/docker/docker/pkg/tlsconfig -github.com/docker/docker/api/types/blkiodev -github.com/docker/docker/api/types/strslice # github.com/docker/go-connections v0.4.0 github.com/docker/go-connections/nat github.com/docker/go-connections/sockets @@ -67,10 +67,10 @@ github.com/go-sql-driver/mysql # github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55 github.com/godbus/dbus # github.com/gogo/protobuf v1.2.0 -github.com/gogo/protobuf/proto -github.com/gogo/protobuf/sortkeys github.com/gogo/protobuf/gogoproto +github.com/gogo/protobuf/proto github.com/gogo/protobuf/protoc-gen-gogo/descriptor +github.com/gogo/protobuf/sortkeys # github.com/golang-plus/errors v1.0.0 github.com/golang-plus/errors # github.com/golang-plus/uuid v1.0.0 @@ -86,8 +86,8 @@ github.com/golang-plus/uuid/internal/timebased github.com/golang/groupcache/lru # github.com/golang/protobuf v1.3.1 github.com/golang/protobuf/proto -github.com/golang/protobuf/ptypes/any github.com/golang/protobuf/ptypes +github.com/golang/protobuf/ptypes/any github.com/golang/protobuf/ptypes/duration github.com/golang/protobuf/ptypes/timestamp # github.com/google/go-cmp v0.3.0 @@ -147,8 +147,8 @@ github.com/prometheus/client_golang/prometheus/internal github.com/prometheus/client_model/go # github.com/prometheus/common v0.4.1 github.com/prometheus/common/expfmt -github.com/prometheus/common/model github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg +github.com/prometheus/common/model # github.com/prometheus/procfs v0.0.2 github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs @@ -163,9 +163,9 @@ github.com/spf13/pflag # github.com/texttheater/golang-levenshtein v0.0.0-20180516184445-d188e65d659e github.com/texttheater/golang-levenshtein/levenshtein # github.com/tredoe/osutil v0.0.0-20161130133508-7d3ee1afa71c -github.com/tredoe/osutil/user/crypt/sha512_crypt github.com/tredoe/osutil/user/crypt github.com/tredoe/osutil/user/crypt/common +github.com/tredoe/osutil/user/crypt/sha512_crypt # github.com/ugorji/go/codec v1.1.7 github.com/ugorji/go/codec # github.com/vishvananda/netlink v0.0.0-20171020171820-b2de5d10e38e @@ -174,72 +174,72 @@ github.com/vishvananda/netlink/nl # github.com/vishvananda/netns v0.0.0-20171111001504-be1fbeda1936 github.com/vishvananda/netns # golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 -golang.org/x/crypto/ssh/terminal golang.org/x/crypto/bcrypt -golang.org/x/crypto/ssh golang.org/x/crypto/blowfish golang.org/x/crypto/curve25519 golang.org/x/crypto/ed25519 -golang.org/x/crypto/internal/chacha20 -golang.org/x/crypto/poly1305 -golang.org/x/crypto/pbkdf2 golang.org/x/crypto/ed25519/internal/edwards25519 +golang.org/x/crypto/internal/chacha20 golang.org/x/crypto/internal/subtle +golang.org/x/crypto/pbkdf2 +golang.org/x/crypto/poly1305 +golang.org/x/crypto/ssh +golang.org/x/crypto/ssh/terminal # golang.org/x/net v0.0.0-20190603091049-60506f45cf65 -golang.org/x/net/http2 -golang.org/x/net/idna -golang.org/x/net/http/httpguts -golang.org/x/net/http2/hpack golang.org/x/net/context golang.org/x/net/context/ctxhttp -golang.org/x/net/proxy -golang.org/x/net/trace +golang.org/x/net/http/httpguts +golang.org/x/net/http2 +golang.org/x/net/http2/hpack +golang.org/x/net/idna golang.org/x/net/internal/socks golang.org/x/net/internal/timeseries +golang.org/x/net/proxy +golang.org/x/net/trace # golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 golang.org/x/oauth2 golang.org/x/oauth2/internal # golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 golang.org/x/sync/errgroup # golang.org/x/sys v0.0.0-20190620070143-6f217b454f45 +golang.org/x/sys/cpu golang.org/x/sys/unix golang.org/x/sys/windows golang.org/x/sys/windows/svc golang.org/x/sys/windows/svc/mgr -golang.org/x/sys/cpu # golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db -golang.org/x/text/unicode/norm -golang.org/x/text/width golang.org/x/text/secure/bidirule -golang.org/x/text/unicode/bidi golang.org/x/text/transform +golang.org/x/text/unicode/bidi +golang.org/x/text/unicode/norm +golang.org/x/text/width # golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 golang.org/x/time/rate # google.golang.org/appengine v1.5.0 google.golang.org/appengine/cloudsql -google.golang.org/appengine/urlfetch google.golang.org/appengine/internal -google.golang.org/appengine/internal/urlfetch google.golang.org/appengine/internal/base google.golang.org/appengine/internal/datastore google.golang.org/appengine/internal/log google.golang.org/appengine/internal/remote_api +google.golang.org/appengine/internal/urlfetch +google.golang.org/appengine/urlfetch # google.golang.org/genproto v0.0.0-20181218023534-67d6565462c5 google.golang.org/genproto/googleapis/rpc/status # google.golang.org/grpc v1.21.1 google.golang.org/grpc -google.golang.org/grpc/codes -google.golang.org/grpc/credentials -google.golang.org/grpc/grpclog -google.golang.org/grpc/health/grpc_health_v1 -google.golang.org/grpc/keepalive -google.golang.org/grpc/metadata -google.golang.org/grpc/status google.golang.org/grpc/balancer +google.golang.org/grpc/balancer/base google.golang.org/grpc/balancer/roundrobin +google.golang.org/grpc/binarylog/grpc_binarylog_v1 +google.golang.org/grpc/codes google.golang.org/grpc/connectivity +google.golang.org/grpc/credentials +google.golang.org/grpc/credentials/internal google.golang.org/grpc/encoding google.golang.org/grpc/encoding/proto +google.golang.org/grpc/grpclog +google.golang.org/grpc/health/grpc_health_v1 google.golang.org/grpc/internal google.golang.org/grpc/internal/backoff google.golang.org/grpc/internal/balancerload @@ -248,18 +248,18 @@ google.golang.org/grpc/internal/channelz google.golang.org/grpc/internal/envconfig google.golang.org/grpc/internal/grpcrand google.golang.org/grpc/internal/grpcsync +google.golang.org/grpc/internal/syscall google.golang.org/grpc/internal/transport +google.golang.org/grpc/keepalive +google.golang.org/grpc/metadata google.golang.org/grpc/naming google.golang.org/grpc/peer google.golang.org/grpc/resolver google.golang.org/grpc/resolver/dns google.golang.org/grpc/resolver/passthrough google.golang.org/grpc/stats +google.golang.org/grpc/status google.golang.org/grpc/tap -google.golang.org/grpc/credentials/internal -google.golang.org/grpc/balancer/base -google.golang.org/grpc/binarylog/grpc_binarylog_v1 -google.golang.org/grpc/internal/syscall # gopkg.in/go-playground/validator.v8 v8.18.2 gopkg.in/go-playground/validator.v8 # gopkg.in/inf.v0 v0.9.1 @@ -272,11 +272,8 @@ gopkg.in/square/go-jose.v2/jwt # gopkg.in/yaml.v2 v2.2.2 gopkg.in/yaml.v2 # k8s.io/api v0.0.0 => k8s.io/api v0.0.0-20190620084959-7cf5895f2711 -k8s.io/api/core/v1 -k8s.io/api/rbac/v1 -k8s.io/api/apps/v1 k8s.io/api/admissionregistration/v1beta1 -k8s.io/api/autoscaling/v1 +k8s.io/api/apps/v1 k8s.io/api/apps/v1beta1 k8s.io/api/apps/v1beta2 k8s.io/api/auditregistration/v1alpha1 @@ -284,6 +281,7 @@ k8s.io/api/authentication/v1 k8s.io/api/authentication/v1beta1 k8s.io/api/authorization/v1 k8s.io/api/authorization/v1beta1 +k8s.io/api/autoscaling/v1 k8s.io/api/autoscaling/v2beta1 k8s.io/api/autoscaling/v2beta2 k8s.io/api/batch/v1 @@ -292,13 +290,15 @@ k8s.io/api/batch/v2alpha1 k8s.io/api/certificates/v1beta1 k8s.io/api/coordination/v1 k8s.io/api/coordination/v1beta1 -k8s.io/api/policy/v1beta1 +k8s.io/api/core/v1 k8s.io/api/events/v1beta1 k8s.io/api/extensions/v1beta1 k8s.io/api/networking/v1 k8s.io/api/networking/v1beta1 k8s.io/api/node/v1alpha1 k8s.io/api/node/v1beta1 +k8s.io/api/policy/v1beta1 +k8s.io/api/rbac/v1 k8s.io/api/rbac/v1alpha1 k8s.io/api/rbac/v1beta1 k8s.io/api/scheduling/v1 @@ -311,225 +311,194 @@ k8s.io/api/storage/v1beta1 # k8s.io/apiextensions-apiserver v0.0.0 => k8s.io/apiextensions-apiserver v0.0.0-20190620085554-14e95df34f1f k8s.io/apiextensions-apiserver/pkg/features # k8s.io/apimachinery v0.0.0 => k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719 -k8s.io/apimachinery/pkg/apis/meta/v1 -k8s.io/apimachinery/pkg/runtime -k8s.io/apimachinery/pkg/runtime/schema -k8s.io/apimachinery/pkg/runtime/serializer -k8s.io/apimachinery/pkg/util/runtime -k8s.io/apimachinery/pkg/util/sets +k8s.io/apimachinery/pkg/api/equality k8s.io/apimachinery/pkg/api/errors -k8s.io/apimachinery/pkg/util/wait -k8s.io/apimachinery/pkg/util/validation -k8s.io/apimachinery/pkg/util/version +k8s.io/apimachinery/pkg/api/meta k8s.io/apimachinery/pkg/api/resource +k8s.io/apimachinery/pkg/api/validation +k8s.io/apimachinery/pkg/apis/meta/internalversion +k8s.io/apimachinery/pkg/apis/meta/v1 +k8s.io/apimachinery/pkg/apis/meta/v1/unstructured +k8s.io/apimachinery/pkg/apis/meta/v1/validation +k8s.io/apimachinery/pkg/apis/meta/v1beta1 k8s.io/apimachinery/pkg/conversion +k8s.io/apimachinery/pkg/conversion/queryparams k8s.io/apimachinery/pkg/fields k8s.io/apimachinery/pkg/labels -k8s.io/apimachinery/pkg/selection -k8s.io/apimachinery/pkg/types -k8s.io/apimachinery/pkg/util/intstr -k8s.io/apimachinery/pkg/watch -k8s.io/apimachinery/pkg/conversion/queryparams -k8s.io/apimachinery/pkg/util/errors -k8s.io/apimachinery/pkg/util/json -k8s.io/apimachinery/pkg/util/naming +k8s.io/apimachinery/pkg/runtime +k8s.io/apimachinery/pkg/runtime/schema +k8s.io/apimachinery/pkg/runtime/serializer k8s.io/apimachinery/pkg/runtime/serializer/json k8s.io/apimachinery/pkg/runtime/serializer/protobuf k8s.io/apimachinery/pkg/runtime/serializer/recognizer -k8s.io/apimachinery/pkg/runtime/serializer/versioning -k8s.io/apimachinery/pkg/util/validation/field -k8s.io/apimachinery/pkg/util/duration -k8s.io/apimachinery/pkg/version -k8s.io/apimachinery/pkg/util/net -k8s.io/apimachinery/pkg/util/yaml -k8s.io/apimachinery/pkg/util/strategicpatch -k8s.io/apimachinery/pkg/util/rand -k8s.io/apimachinery/pkg/api/equality -k8s.io/apimachinery/pkg/apis/meta/v1/unstructured -k8s.io/apimachinery/third_party/forked/golang/reflect -k8s.io/apimachinery/pkg/util/framer k8s.io/apimachinery/pkg/runtime/serializer/streaming +k8s.io/apimachinery/pkg/runtime/serializer/versioning +k8s.io/apimachinery/pkg/selection +k8s.io/apimachinery/pkg/types +k8s.io/apimachinery/pkg/util/cache k8s.io/apimachinery/pkg/util/clock -k8s.io/apimachinery/pkg/api/validation -k8s.io/apimachinery/pkg/apis/meta/v1/validation k8s.io/apimachinery/pkg/util/diff +k8s.io/apimachinery/pkg/util/duration +k8s.io/apimachinery/pkg/util/errors +k8s.io/apimachinery/pkg/util/framer +k8s.io/apimachinery/pkg/util/intstr +k8s.io/apimachinery/pkg/util/json k8s.io/apimachinery/pkg/util/mergepatch +k8s.io/apimachinery/pkg/util/naming +k8s.io/apimachinery/pkg/util/net +k8s.io/apimachinery/pkg/util/rand +k8s.io/apimachinery/pkg/util/runtime +k8s.io/apimachinery/pkg/util/sets +k8s.io/apimachinery/pkg/util/strategicpatch +k8s.io/apimachinery/pkg/util/validation +k8s.io/apimachinery/pkg/util/validation/field +k8s.io/apimachinery/pkg/util/version +k8s.io/apimachinery/pkg/util/wait +k8s.io/apimachinery/pkg/util/yaml +k8s.io/apimachinery/pkg/version +k8s.io/apimachinery/pkg/watch k8s.io/apimachinery/third_party/forked/golang/json -k8s.io/apimachinery/pkg/api/meta -k8s.io/apimachinery/pkg/apis/meta/internalversion -k8s.io/apimachinery/pkg/util/cache -k8s.io/apimachinery/pkg/apis/meta/v1beta1 +k8s.io/apimachinery/third_party/forked/golang/reflect # k8s.io/apiserver v0.0.0 => k8s.io/apiserver v0.0.0-20190620085212-47dc9a115b18 -k8s.io/apiserver/pkg/util/feature +k8s.io/apiserver/pkg/authentication/authenticator +k8s.io/apiserver/pkg/authentication/serviceaccount k8s.io/apiserver/pkg/authentication/user k8s.io/apiserver/pkg/features -k8s.io/apiserver/pkg/authentication/serviceaccount -k8s.io/apiserver/pkg/authentication/authenticator +k8s.io/apiserver/pkg/util/feature # k8s.io/client-go v12.0.0+incompatible => k8s.io/client-go v0.0.0-20190620085101-78d2af792bab -k8s.io/client-go/kubernetes -k8s.io/client-go/tools/clientcmd -k8s.io/client-go/tools/clientcmd/api -k8s.io/client-go/util/cert -k8s.io/client-go/util/keyutil k8s.io/client-go/discovery +k8s.io/client-go/discovery/fake +k8s.io/client-go/dynamic +k8s.io/client-go/dynamic/dynamicinformer +k8s.io/client-go/dynamic/dynamiclister +k8s.io/client-go/informers +k8s.io/client-go/informers/admissionregistration +k8s.io/client-go/informers/admissionregistration/v1beta1 +k8s.io/client-go/informers/apps +k8s.io/client-go/informers/apps/v1 +k8s.io/client-go/informers/apps/v1beta1 +k8s.io/client-go/informers/apps/v1beta2 +k8s.io/client-go/informers/auditregistration +k8s.io/client-go/informers/auditregistration/v1alpha1 +k8s.io/client-go/informers/autoscaling +k8s.io/client-go/informers/autoscaling/v1 +k8s.io/client-go/informers/autoscaling/v2beta1 +k8s.io/client-go/informers/autoscaling/v2beta2 +k8s.io/client-go/informers/batch +k8s.io/client-go/informers/batch/v1 +k8s.io/client-go/informers/batch/v1beta1 +k8s.io/client-go/informers/batch/v2alpha1 +k8s.io/client-go/informers/certificates +k8s.io/client-go/informers/certificates/v1beta1 +k8s.io/client-go/informers/coordination +k8s.io/client-go/informers/coordination/v1 +k8s.io/client-go/informers/coordination/v1beta1 +k8s.io/client-go/informers/core +k8s.io/client-go/informers/core/v1 +k8s.io/client-go/informers/events +k8s.io/client-go/informers/events/v1beta1 +k8s.io/client-go/informers/extensions +k8s.io/client-go/informers/extensions/v1beta1 +k8s.io/client-go/informers/internalinterfaces +k8s.io/client-go/informers/networking +k8s.io/client-go/informers/networking/v1 +k8s.io/client-go/informers/networking/v1beta1 +k8s.io/client-go/informers/node +k8s.io/client-go/informers/node/v1alpha1 +k8s.io/client-go/informers/node/v1beta1 +k8s.io/client-go/informers/policy +k8s.io/client-go/informers/policy/v1beta1 +k8s.io/client-go/informers/rbac +k8s.io/client-go/informers/rbac/v1 +k8s.io/client-go/informers/rbac/v1alpha1 +k8s.io/client-go/informers/rbac/v1beta1 +k8s.io/client-go/informers/scheduling +k8s.io/client-go/informers/scheduling/v1 +k8s.io/client-go/informers/scheduling/v1alpha1 +k8s.io/client-go/informers/scheduling/v1beta1 +k8s.io/client-go/informers/settings +k8s.io/client-go/informers/settings/v1alpha1 +k8s.io/client-go/informers/storage +k8s.io/client-go/informers/storage/v1 +k8s.io/client-go/informers/storage/v1alpha1 +k8s.io/client-go/informers/storage/v1beta1 +k8s.io/client-go/kubernetes +k8s.io/client-go/kubernetes/fake +k8s.io/client-go/kubernetes/scheme k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1 +k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/fake k8s.io/client-go/kubernetes/typed/apps/v1 +k8s.io/client-go/kubernetes/typed/apps/v1/fake k8s.io/client-go/kubernetes/typed/apps/v1beta1 +k8s.io/client-go/kubernetes/typed/apps/v1beta1/fake k8s.io/client-go/kubernetes/typed/apps/v1beta2 +k8s.io/client-go/kubernetes/typed/apps/v1beta2/fake k8s.io/client-go/kubernetes/typed/auditregistration/v1alpha1 +k8s.io/client-go/kubernetes/typed/auditregistration/v1alpha1/fake k8s.io/client-go/kubernetes/typed/authentication/v1 +k8s.io/client-go/kubernetes/typed/authentication/v1/fake k8s.io/client-go/kubernetes/typed/authentication/v1beta1 +k8s.io/client-go/kubernetes/typed/authentication/v1beta1/fake k8s.io/client-go/kubernetes/typed/authorization/v1 +k8s.io/client-go/kubernetes/typed/authorization/v1/fake k8s.io/client-go/kubernetes/typed/authorization/v1beta1 +k8s.io/client-go/kubernetes/typed/authorization/v1beta1/fake k8s.io/client-go/kubernetes/typed/autoscaling/v1 +k8s.io/client-go/kubernetes/typed/autoscaling/v1/fake k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1 +k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1/fake k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2 +k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2/fake k8s.io/client-go/kubernetes/typed/batch/v1 +k8s.io/client-go/kubernetes/typed/batch/v1/fake k8s.io/client-go/kubernetes/typed/batch/v1beta1 +k8s.io/client-go/kubernetes/typed/batch/v1beta1/fake k8s.io/client-go/kubernetes/typed/batch/v2alpha1 +k8s.io/client-go/kubernetes/typed/batch/v2alpha1/fake k8s.io/client-go/kubernetes/typed/certificates/v1beta1 +k8s.io/client-go/kubernetes/typed/certificates/v1beta1/fake k8s.io/client-go/kubernetes/typed/coordination/v1 +k8s.io/client-go/kubernetes/typed/coordination/v1/fake k8s.io/client-go/kubernetes/typed/coordination/v1beta1 +k8s.io/client-go/kubernetes/typed/coordination/v1beta1/fake k8s.io/client-go/kubernetes/typed/core/v1 +k8s.io/client-go/kubernetes/typed/core/v1/fake k8s.io/client-go/kubernetes/typed/events/v1beta1 +k8s.io/client-go/kubernetes/typed/events/v1beta1/fake k8s.io/client-go/kubernetes/typed/extensions/v1beta1 +k8s.io/client-go/kubernetes/typed/extensions/v1beta1/fake k8s.io/client-go/kubernetes/typed/networking/v1 +k8s.io/client-go/kubernetes/typed/networking/v1/fake k8s.io/client-go/kubernetes/typed/networking/v1beta1 +k8s.io/client-go/kubernetes/typed/networking/v1beta1/fake k8s.io/client-go/kubernetes/typed/node/v1alpha1 -k8s.io/client-go/kubernetes/typed/node/v1beta1 -k8s.io/client-go/kubernetes/typed/policy/v1beta1 -k8s.io/client-go/kubernetes/typed/rbac/v1 -k8s.io/client-go/kubernetes/typed/rbac/v1alpha1 -k8s.io/client-go/kubernetes/typed/rbac/v1beta1 -k8s.io/client-go/kubernetes/typed/scheduling/v1 -k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1 -k8s.io/client-go/kubernetes/typed/scheduling/v1beta1 -k8s.io/client-go/kubernetes/typed/settings/v1alpha1 -k8s.io/client-go/kubernetes/typed/storage/v1 -k8s.io/client-go/kubernetes/typed/storage/v1alpha1 -k8s.io/client-go/kubernetes/typed/storage/v1beta1 -k8s.io/client-go/rest -k8s.io/client-go/util/flowcontrol -k8s.io/client-go/tools/auth -k8s.io/client-go/tools/clientcmd/api/latest -k8s.io/client-go/util/homedir -k8s.io/client-go/kubernetes/scheme -k8s.io/client-go/dynamic -k8s.io/client-go/kubernetes/fake -k8s.io/client-go/testing -k8s.io/client-go/util/retry -k8s.io/client-go/listers/apps/v1 -k8s.io/client-go/listers/core/v1 -k8s.io/client-go/tools/record -k8s.io/client-go/tools/reference -k8s.io/client-go/pkg/version -k8s.io/client-go/plugin/pkg/client/auth/exec -k8s.io/client-go/rest/watch -k8s.io/client-go/tools/metrics -k8s.io/client-go/transport -k8s.io/client-go/tools/clientcmd/api/v1 -k8s.io/client-go/discovery/fake -k8s.io/client-go/kubernetes/typed/admissionregistration/v1beta1/fake -k8s.io/client-go/kubernetes/typed/apps/v1/fake -k8s.io/client-go/kubernetes/typed/apps/v1beta1/fake -k8s.io/client-go/kubernetes/typed/apps/v1beta2/fake -k8s.io/client-go/kubernetes/typed/auditregistration/v1alpha1/fake -k8s.io/client-go/kubernetes/typed/authentication/v1/fake -k8s.io/client-go/kubernetes/typed/authentication/v1beta1/fake -k8s.io/client-go/kubernetes/typed/authorization/v1/fake -k8s.io/client-go/kubernetes/typed/authorization/v1beta1/fake -k8s.io/client-go/kubernetes/typed/autoscaling/v1/fake -k8s.io/client-go/kubernetes/typed/autoscaling/v2beta1/fake -k8s.io/client-go/kubernetes/typed/autoscaling/v2beta2/fake -k8s.io/client-go/kubernetes/typed/batch/v1/fake -k8s.io/client-go/kubernetes/typed/batch/v1beta1/fake -k8s.io/client-go/kubernetes/typed/batch/v2alpha1/fake -k8s.io/client-go/kubernetes/typed/certificates/v1beta1/fake -k8s.io/client-go/kubernetes/typed/coordination/v1/fake -k8s.io/client-go/kubernetes/typed/coordination/v1beta1/fake -k8s.io/client-go/kubernetes/typed/core/v1/fake -k8s.io/client-go/kubernetes/typed/events/v1beta1/fake -k8s.io/client-go/kubernetes/typed/extensions/v1beta1/fake -k8s.io/client-go/kubernetes/typed/networking/v1/fake -k8s.io/client-go/kubernetes/typed/networking/v1beta1/fake k8s.io/client-go/kubernetes/typed/node/v1alpha1/fake +k8s.io/client-go/kubernetes/typed/node/v1beta1 k8s.io/client-go/kubernetes/typed/node/v1beta1/fake +k8s.io/client-go/kubernetes/typed/policy/v1beta1 k8s.io/client-go/kubernetes/typed/policy/v1beta1/fake +k8s.io/client-go/kubernetes/typed/rbac/v1 k8s.io/client-go/kubernetes/typed/rbac/v1/fake +k8s.io/client-go/kubernetes/typed/rbac/v1alpha1 k8s.io/client-go/kubernetes/typed/rbac/v1alpha1/fake +k8s.io/client-go/kubernetes/typed/rbac/v1beta1 k8s.io/client-go/kubernetes/typed/rbac/v1beta1/fake +k8s.io/client-go/kubernetes/typed/scheduling/v1 k8s.io/client-go/kubernetes/typed/scheduling/v1/fake +k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1 k8s.io/client-go/kubernetes/typed/scheduling/v1alpha1/fake +k8s.io/client-go/kubernetes/typed/scheduling/v1beta1 k8s.io/client-go/kubernetes/typed/scheduling/v1beta1/fake +k8s.io/client-go/kubernetes/typed/settings/v1alpha1 k8s.io/client-go/kubernetes/typed/settings/v1alpha1/fake +k8s.io/client-go/kubernetes/typed/storage/v1 k8s.io/client-go/kubernetes/typed/storage/v1/fake +k8s.io/client-go/kubernetes/typed/storage/v1alpha1 k8s.io/client-go/kubernetes/typed/storage/v1alpha1/fake +k8s.io/client-go/kubernetes/typed/storage/v1beta1 k8s.io/client-go/kubernetes/typed/storage/v1beta1/fake -k8s.io/client-go/tools/cache -k8s.io/client-go/tools/record/util -k8s.io/client-go/pkg/apis/clientauthentication -k8s.io/client-go/pkg/apis/clientauthentication/v1alpha1 -k8s.io/client-go/pkg/apis/clientauthentication/v1beta1 -k8s.io/client-go/util/connrotation -k8s.io/client-go/util/certificate/csr -k8s.io/client-go/informers/core/v1 -k8s.io/client-go/util/workqueue -k8s.io/client-go/tools/pager -k8s.io/client-go/restmapper -k8s.io/client-go/tools/watch -k8s.io/client-go/informers/internalinterfaces -k8s.io/client-go/dynamic/dynamicinformer -k8s.io/client-go/informers -k8s.io/client-go/dynamic/dynamiclister -k8s.io/client-go/informers/admissionregistration -k8s.io/client-go/informers/apps -k8s.io/client-go/informers/auditregistration -k8s.io/client-go/informers/autoscaling -k8s.io/client-go/informers/batch -k8s.io/client-go/informers/certificates -k8s.io/client-go/informers/coordination -k8s.io/client-go/informers/core -k8s.io/client-go/informers/events -k8s.io/client-go/informers/extensions -k8s.io/client-go/informers/networking -k8s.io/client-go/informers/node -k8s.io/client-go/informers/policy -k8s.io/client-go/informers/rbac -k8s.io/client-go/informers/scheduling -k8s.io/client-go/informers/settings -k8s.io/client-go/informers/storage -k8s.io/client-go/informers/admissionregistration/v1beta1 -k8s.io/client-go/informers/apps/v1 -k8s.io/client-go/informers/apps/v1beta1 -k8s.io/client-go/informers/apps/v1beta2 -k8s.io/client-go/informers/auditregistration/v1alpha1 -k8s.io/client-go/informers/autoscaling/v1 -k8s.io/client-go/informers/autoscaling/v2beta1 -k8s.io/client-go/informers/autoscaling/v2beta2 -k8s.io/client-go/informers/batch/v1 -k8s.io/client-go/informers/batch/v1beta1 -k8s.io/client-go/informers/batch/v2alpha1 -k8s.io/client-go/informers/certificates/v1beta1 -k8s.io/client-go/informers/coordination/v1 -k8s.io/client-go/informers/coordination/v1beta1 -k8s.io/client-go/informers/events/v1beta1 -k8s.io/client-go/informers/extensions/v1beta1 -k8s.io/client-go/informers/networking/v1 -k8s.io/client-go/informers/networking/v1beta1 -k8s.io/client-go/informers/node/v1alpha1 -k8s.io/client-go/informers/node/v1beta1 -k8s.io/client-go/informers/policy/v1beta1 -k8s.io/client-go/informers/rbac/v1 -k8s.io/client-go/informers/rbac/v1alpha1 -k8s.io/client-go/informers/rbac/v1beta1 -k8s.io/client-go/informers/scheduling/v1 -k8s.io/client-go/informers/scheduling/v1alpha1 -k8s.io/client-go/informers/scheduling/v1beta1 -k8s.io/client-go/informers/settings/v1alpha1 -k8s.io/client-go/informers/storage/v1 -k8s.io/client-go/informers/storage/v1alpha1 -k8s.io/client-go/informers/storage/v1beta1 k8s.io/client-go/listers/admissionregistration/v1beta1 +k8s.io/client-go/listers/apps/v1 k8s.io/client-go/listers/apps/v1beta1 k8s.io/client-go/listers/apps/v1beta2 k8s.io/client-go/listers/auditregistration/v1alpha1 @@ -542,6 +511,7 @@ k8s.io/client-go/listers/batch/v2alpha1 k8s.io/client-go/listers/certificates/v1beta1 k8s.io/client-go/listers/coordination/v1 k8s.io/client-go/listers/coordination/v1beta1 +k8s.io/client-go/listers/core/v1 k8s.io/client-go/listers/events/v1beta1 k8s.io/client-go/listers/extensions/v1beta1 k8s.io/client-go/listers/networking/v1 @@ -559,14 +529,44 @@ k8s.io/client-go/listers/settings/v1alpha1 k8s.io/client-go/listers/storage/v1 k8s.io/client-go/listers/storage/v1alpha1 k8s.io/client-go/listers/storage/v1beta1 +k8s.io/client-go/pkg/apis/clientauthentication +k8s.io/client-go/pkg/apis/clientauthentication/v1alpha1 +k8s.io/client-go/pkg/apis/clientauthentication/v1beta1 +k8s.io/client-go/pkg/version +k8s.io/client-go/plugin/pkg/client/auth/exec +k8s.io/client-go/rest +k8s.io/client-go/rest/watch +k8s.io/client-go/restmapper +k8s.io/client-go/testing +k8s.io/client-go/tools/auth +k8s.io/client-go/tools/cache +k8s.io/client-go/tools/clientcmd +k8s.io/client-go/tools/clientcmd/api +k8s.io/client-go/tools/clientcmd/api/latest +k8s.io/client-go/tools/clientcmd/api/v1 +k8s.io/client-go/tools/metrics +k8s.io/client-go/tools/pager +k8s.io/client-go/tools/record +k8s.io/client-go/tools/record/util +k8s.io/client-go/tools/reference +k8s.io/client-go/tools/watch +k8s.io/client-go/transport +k8s.io/client-go/util/cert +k8s.io/client-go/util/certificate/csr +k8s.io/client-go/util/connrotation +k8s.io/client-go/util/flowcontrol +k8s.io/client-go/util/homedir +k8s.io/client-go/util/keyutil +k8s.io/client-go/util/retry +k8s.io/client-go/util/workqueue # k8s.io/cluster-bootstrap v0.0.0 => k8s.io/cluster-bootstrap v0.0.0-20190620090013-c9a0fc045dc1 k8s.io/cluster-bootstrap/token/api k8s.io/cluster-bootstrap/token/util # k8s.io/component-base v0.0.0 => k8s.io/component-base v0.0.0-20190620085130-185d68e6e6ea k8s.io/component-base/cli/flag -k8s.io/component-base/featuregate k8s.io/component-base/config k8s.io/component-base/config/v1alpha1 +k8s.io/component-base/featuregate # k8s.io/klog v0.3.3 k8s.io/klog # k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208 @@ -576,138 +576,138 @@ k8s.io/kube-proxy/config/v1alpha1 # k8s.io/kubelet v0.0.0 => k8s.io/kubelet v0.0.0-20190620085838-f1cb295a73c9 k8s.io/kubelet/config/v1beta1 # k8s.io/kubernetes v1.15.1 -k8s.io/kubernetes/cmd/kubeadm/app/constants k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/scheme +k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1 k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2 k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/validation k8s.io/kubernetes/cmd/kubeadm/app/cmd +k8s.io/kubernetes/cmd/kubeadm/app/cmd/alpha k8s.io/kubernetes/cmd/kubeadm/app/cmd/options +k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/init k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/join k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/reset +k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/upgrade/node k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow +k8s.io/kubernetes/cmd/kubeadm/app/cmd/upgrade k8s.io/kubernetes/cmd/kubeadm/app/cmd/util +k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs +k8s.io/kubernetes/cmd/kubeadm/app/constants k8s.io/kubernetes/cmd/kubeadm/app/discovery +k8s.io/kubernetes/cmd/kubeadm/app/discovery/file +k8s.io/kubernetes/cmd/kubeadm/app/discovery/https +k8s.io/kubernetes/cmd/kubeadm/app/discovery/token k8s.io/kubernetes/cmd/kubeadm/app/features -k8s.io/kubernetes/cmd/kubeadm/app/phases/certs -k8s.io/kubernetes/cmd/kubeadm/app/phases/kubeconfig -k8s.io/kubernetes/cmd/kubeadm/app/util -k8s.io/kubernetes/cmd/kubeadm/app/util/apiclient -k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig -k8s.io/kubernetes/cmd/kubeadm/app/util/runtime -k8s.io/kubernetes/cmd/kubeadm/app/util/pubkeypin k8s.io/kubernetes/cmd/kubeadm/app/images -k8s.io/kubernetes/cmd/kubeadm/app/phases/bootstraptoken/node -k8s.io/kubernetes/cmd/kubeadm/app/phases/copycerts -k8s.io/kubernetes/cmd/kubeadm/app/util/crypto -k8s.io/kubernetes/pkg/util/normalizer -k8s.io/kubernetes/cmd/kubeadm/app/phases/uploadconfig -k8s.io/kubernetes/pkg/apis/rbac/v1 -k8s.io/kubernetes/cmd/kubeadm/app/preflight -k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta1 -k8s.io/kubernetes/cmd/kubeadm/app/util/config -k8s.io/kubernetes/cmd/kubeadm/app/util/pkiutil -k8s.io/kubernetes/pkg/registry/core/service/ipallocator -k8s.io/kubernetes/cmd/kubeadm/app/util/staticpod -k8s.io/kubernetes/pkg/kubelet/apis/config -k8s.io/kubernetes/pkg/proxy/apis/config -k8s.io/kubernetes/cmd/kubeadm/app/componentconfigs -k8s.io/kubernetes/pkg/apis/core/validation -k8s.io/kubernetes/cmd/kubeadm/app/cmd/alpha -k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases -k8s.io/kubernetes/cmd/kubeadm/app/cmd/upgrade -k8s.io/kubernetes/pkg/version k8s.io/kubernetes/cmd/kubeadm/app/phases/addons/dns k8s.io/kubernetes/cmd/kubeadm/app/phases/addons/proxy k8s.io/kubernetes/cmd/kubeadm/app/phases/bootstraptoken/clusterinfo +k8s.io/kubernetes/cmd/kubeadm/app/phases/bootstraptoken/node +k8s.io/kubernetes/cmd/kubeadm/app/phases/certs +k8s.io/kubernetes/cmd/kubeadm/app/phases/certs/renewal k8s.io/kubernetes/cmd/kubeadm/app/phases/controlplane +k8s.io/kubernetes/cmd/kubeadm/app/phases/copycerts k8s.io/kubernetes/cmd/kubeadm/app/phases/etcd +k8s.io/kubernetes/cmd/kubeadm/app/phases/kubeconfig k8s.io/kubernetes/cmd/kubeadm/app/phases/kubelet k8s.io/kubernetes/cmd/kubeadm/app/phases/markcontrolplane k8s.io/kubernetes/cmd/kubeadm/app/phases/patchnode +k8s.io/kubernetes/cmd/kubeadm/app/phases/selfhosting +k8s.io/kubernetes/cmd/kubeadm/app/phases/upgrade +k8s.io/kubernetes/cmd/kubeadm/app/phases/uploadconfig +k8s.io/kubernetes/cmd/kubeadm/app/preflight +k8s.io/kubernetes/cmd/kubeadm/app/util +k8s.io/kubernetes/cmd/kubeadm/app/util/apiclient +k8s.io/kubernetes/cmd/kubeadm/app/util/config +k8s.io/kubernetes/cmd/kubeadm/app/util/config/strict +k8s.io/kubernetes/cmd/kubeadm/app/util/crypto k8s.io/kubernetes/cmd/kubeadm/app/util/dryrun -k8s.io/kubernetes/pkg/util/initsystem -k8s.io/kubernetes/cmd/kubeadm/app/discovery/file -k8s.io/kubernetes/cmd/kubeadm/app/discovery/https -k8s.io/kubernetes/cmd/kubeadm/app/discovery/token -k8s.io/kubernetes/pkg/kubelet/types -k8s.io/kubernetes/pkg/apis/rbac +k8s.io/kubernetes/cmd/kubeadm/app/util/etcd +k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig +k8s.io/kubernetes/cmd/kubeadm/app/util/pkiutil +k8s.io/kubernetes/cmd/kubeadm/app/util/pubkeypin +k8s.io/kubernetes/cmd/kubeadm/app/util/runtime +k8s.io/kubernetes/cmd/kubeadm/app/util/staticpod k8s.io/kubernetes/cmd/kubeadm/app/util/system -k8s.io/kubernetes/pkg/master/ports -k8s.io/kubernetes/pkg/proxy/ipvs -k8s.io/kubernetes/pkg/util/ipset -k8s.io/kubernetes/pkg/util/ipvs -k8s.io/kubernetes/cmd/kubeadm/app/util/config/strict -k8s.io/kubernetes/pkg/util/node -k8s.io/kubernetes/pkg/apis/core -k8s.io/kubernetes/pkg/registry/core/service/allocator -k8s.io/kubernetes/pkg/kubelet/apis/config/v1beta1 -k8s.io/kubernetes/pkg/kubelet/apis/config/validation -k8s.io/kubernetes/pkg/proxy/apis/config/v1alpha1 -k8s.io/kubernetes/pkg/proxy/apis/config/validation +k8s.io/kubernetes/pkg/api/legacyscheme k8s.io/kubernetes/pkg/api/service +k8s.io/kubernetes/pkg/api/v1/pod +k8s.io/kubernetes/pkg/api/v1/service +k8s.io/kubernetes/pkg/apis/apps +k8s.io/kubernetes/pkg/apis/autoscaling +k8s.io/kubernetes/pkg/apis/core k8s.io/kubernetes/pkg/apis/core/helper +k8s.io/kubernetes/pkg/apis/core/install k8s.io/kubernetes/pkg/apis/core/pods k8s.io/kubernetes/pkg/apis/core/v1 k8s.io/kubernetes/pkg/apis/core/v1/helper +k8s.io/kubernetes/pkg/apis/core/v1/helper/qos +k8s.io/kubernetes/pkg/apis/core/validation +k8s.io/kubernetes/pkg/apis/rbac +k8s.io/kubernetes/pkg/apis/rbac/v1 +k8s.io/kubernetes/pkg/apis/scheduling k8s.io/kubernetes/pkg/capabilities +k8s.io/kubernetes/pkg/controller +k8s.io/kubernetes/pkg/controller/bootstrap k8s.io/kubernetes/pkg/features k8s.io/kubernetes/pkg/fieldpath -k8s.io/kubernetes/pkg/security/apparmor -k8s.io/kubernetes/cmd/kubeadm/app/phases/certs/renewal -k8s.io/kubernetes/cmd/kubeadm/app/phases/selfhosting -k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/upgrade/node -k8s.io/kubernetes/cmd/kubeadm/app/phases/upgrade -k8s.io/kubernetes/cmd/kubeadm/app/util/etcd k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes -k8s.io/kubernetes/pkg/util/procfs -k8s.io/kubernetes/pkg/controller/bootstrap -k8s.io/kubernetes/pkg/apis/scheduling +k8s.io/kubernetes/pkg/kubelet/apis/config +k8s.io/kubernetes/pkg/kubelet/apis/config/v1beta1 +k8s.io/kubernetes/pkg/kubelet/apis/config/validation +k8s.io/kubernetes/pkg/kubelet/qos +k8s.io/kubernetes/pkg/kubelet/types +k8s.io/kubernetes/pkg/master/ports k8s.io/kubernetes/pkg/proxy +k8s.io/kubernetes/pkg/proxy/apis/config +k8s.io/kubernetes/pkg/proxy/apis/config/v1alpha1 +k8s.io/kubernetes/pkg/proxy/apis/config/validation +k8s.io/kubernetes/pkg/proxy/config k8s.io/kubernetes/pkg/proxy/healthcheck +k8s.io/kubernetes/pkg/proxy/ipvs k8s.io/kubernetes/pkg/proxy/metrics k8s.io/kubernetes/pkg/proxy/util +k8s.io/kubernetes/pkg/registry/core/service/allocator +k8s.io/kubernetes/pkg/registry/core/service/ipallocator +k8s.io/kubernetes/pkg/security/apparmor +k8s.io/kubernetes/pkg/serviceaccount k8s.io/kubernetes/pkg/util/async k8s.io/kubernetes/pkg/util/conntrack -k8s.io/kubernetes/pkg/util/iptables -k8s.io/kubernetes/pkg/util/sysctl -k8s.io/kubernetes/pkg/kubelet/qos -k8s.io/kubernetes/pkg/apis/apps -k8s.io/kubernetes/pkg/util/parsers -k8s.io/kubernetes/pkg/controller -k8s.io/kubernetes/pkg/util/metrics -k8s.io/kubernetes/pkg/api/v1/service -k8s.io/kubernetes/pkg/proxy/config k8s.io/kubernetes/pkg/util/dbus -k8s.io/kubernetes/pkg/apis/core/v1/helper/qos -k8s.io/kubernetes/pkg/apis/autoscaling -k8s.io/kubernetes/pkg/api/legacyscheme -k8s.io/kubernetes/pkg/api/v1/pod -k8s.io/kubernetes/pkg/apis/core/install -k8s.io/kubernetes/pkg/serviceaccount k8s.io/kubernetes/pkg/util/hash +k8s.io/kubernetes/pkg/util/initsystem +k8s.io/kubernetes/pkg/util/ipset +k8s.io/kubernetes/pkg/util/iptables +k8s.io/kubernetes/pkg/util/ipvs +k8s.io/kubernetes/pkg/util/metrics +k8s.io/kubernetes/pkg/util/node +k8s.io/kubernetes/pkg/util/normalizer +k8s.io/kubernetes/pkg/util/parsers +k8s.io/kubernetes/pkg/util/procfs +k8s.io/kubernetes/pkg/util/sysctl k8s.io/kubernetes/pkg/util/taints +k8s.io/kubernetes/pkg/version # k8s.io/utils v0.0.0-20190607212802-c55fbcfc754a +k8s.io/utils/buffer k8s.io/utils/exec k8s.io/utils/integer -k8s.io/utils/pointer k8s.io/utils/net k8s.io/utils/path -k8s.io/utils/buffer +k8s.io/utils/pointer k8s.io/utils/trace # sigs.k8s.io/cluster-api v0.1.4 sigs.k8s.io/cluster-api/cmd/clusterctl/clientcmd -sigs.k8s.io/cluster-api/pkg/util -sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset -sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1 -sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1 sigs.k8s.io/cluster-api/pkg/apis/cluster/common +sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1 +sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/scheme +sigs.k8s.io/cluster-api/pkg/client/clientset_generated/clientset/typed/cluster/v1alpha1 +sigs.k8s.io/cluster-api/pkg/util # sigs.k8s.io/controller-runtime v0.1.11 sigs.k8s.io/controller-runtime/pkg/client -sigs.k8s.io/controller-runtime/pkg/runtime/scheme sigs.k8s.io/controller-runtime/pkg/client/apiutil +sigs.k8s.io/controller-runtime/pkg/runtime/scheme # sigs.k8s.io/yaml v1.1.0 sigs.k8s.io/yaml # yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051 @@ -716,59 +716,67 @@ yunion.io/x/jsonutils yunion.io/x/log yunion.io/x/log/hooks # yunion.io/x/onecloud v0.0.0-20190725062408-c88eae5261a2 => yunion.io/x/onecloud v0.0.0-20190725062408-c88eae5261a2 -yunion.io/x/onecloud/pkg/mcclient +yunion.io/x/onecloud/pkg/apis +yunion.io/x/onecloud/pkg/apis/compute +yunion.io/x/onecloud/pkg/apis/identity +yunion.io/x/onecloud/pkg/apis/scheduler +yunion.io/x/onecloud/pkg/appctx +yunion.io/x/onecloud/pkg/appsrv yunion.io/x/onecloud/pkg/baremetal/options +yunion.io/x/onecloud/pkg/cloudcommon/consts +yunion.io/x/onecloud/pkg/cloudcommon/options +yunion.io/x/onecloud/pkg/cloudcommon/pending_delete yunion.io/x/onecloud/pkg/compute/options +yunion.io/x/onecloud/pkg/httperrors yunion.io/x/onecloud/pkg/image/options yunion.io/x/onecloud/pkg/keystone/options +yunion.io/x/onecloud/pkg/logger/options +yunion.io/x/onecloud/pkg/mcclient +yunion.io/x/onecloud/pkg/mcclient/auth yunion.io/x/onecloud/pkg/mcclient/modules +yunion.io/x/onecloud/pkg/proxy +yunion.io/x/onecloud/pkg/scheduler/options +yunion.io/x/onecloud/pkg/util/ansible +yunion.io/x/onecloud/pkg/util/atexit +yunion.io/x/onecloud/pkg/util/choices +yunion.io/x/onecloud/pkg/util/hashcache yunion.io/x/onecloud/pkg/util/httputils -yunion.io/x/onecloud/pkg/apis/identity yunion.io/x/onecloud/pkg/util/rbacutils yunion.io/x/onecloud/pkg/util/seclib2 -yunion.io/x/onecloud/pkg/cloudcommon/options -yunion.io/x/onecloud/pkg/cloudcommon/pending_delete yunion.io/x/onecloud/pkg/util/stringutils2 -yunion.io/x/onecloud/pkg/apis/compute -yunion.io/x/onecloud/pkg/apis/scheduler -yunion.io/x/onecloud/pkg/httperrors -yunion.io/x/onecloud/pkg/mcclient/auth -yunion.io/x/onecloud/pkg/appctx -yunion.io/x/onecloud/pkg/cloudcommon/consts -yunion.io/x/onecloud/pkg/util/atexit -yunion.io/x/onecloud/pkg/apis -yunion.io/x/onecloud/pkg/util/ansible -yunion.io/x/onecloud/pkg/util/choices -yunion.io/x/onecloud/pkg/appsrv -yunion.io/x/onecloud/pkg/proxy -yunion.io/x/onecloud/pkg/util/hashcache -# yunion.io/x/onecloud-operator v0.0.1-alpha2 +yunion.io/x/onecloud/pkg/webconsole/options +yunion.io/x/onecloud/pkg/yunionconf/options +# yunion.io/x/onecloud-operator v0.0.1-alpha2.0.20190919062109-f48871684b03 +yunion.io/x/onecloud-operator/pkg/apis/constants yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1 yunion.io/x/onecloud-operator/pkg/client/clientset/versioned -yunion.io/x/onecloud-operator/pkg/controller -yunion.io/x/onecloud-operator/pkg/apis/constants -yunion.io/x/onecloud-operator/pkg/util/passwd +yunion.io/x/onecloud-operator/pkg/client/clientset/versioned/scheme yunion.io/x/onecloud-operator/pkg/client/clientset/versioned/typed/onecloud/v1alpha1 yunion.io/x/onecloud-operator/pkg/client/listers/onecloud/v1alpha1 +yunion.io/x/onecloud-operator/pkg/controller +yunion.io/x/onecloud-operator/pkg/label +yunion.io/x/onecloud-operator/pkg/manager +yunion.io/x/onecloud-operator/pkg/manager/component +yunion.io/x/onecloud-operator/pkg/util/mysql yunion.io/x/onecloud-operator/pkg/util/onecloud +yunion.io/x/onecloud-operator/pkg/util/passwd yunion.io/x/onecloud-operator/pkg/util/pkiutil -yunion.io/x/onecloud-operator/pkg/client/clientset/versioned/scheme # yunion.io/x/pkg v0.0.0-20190628082551-f4033ba2ea30 -yunion.io/x/pkg/util/seclib +yunion.io/x/pkg/errors yunion.io/x/pkg/gotypes -yunion.io/x/pkg/utils +yunion.io/x/pkg/trace yunion.io/x/pkg/tristate +yunion.io/x/pkg/util/cache +yunion.io/x/pkg/util/clock +yunion.io/x/pkg/util/errors +yunion.io/x/pkg/util/netutils yunion.io/x/pkg/util/reflectutils yunion.io/x/pkg/util/regutils -yunion.io/x/pkg/util/timeutils -yunion.io/x/pkg/errors -yunion.io/x/pkg/trace -yunion.io/x/pkg/util/netutils -yunion.io/x/pkg/util/version +yunion.io/x/pkg/util/seclib yunion.io/x/pkg/util/sets -yunion.io/x/pkg/util/cache -yunion.io/x/pkg/util/errors yunion.io/x/pkg/util/signalutils -yunion.io/x/pkg/util/clock +yunion.io/x/pkg/util/timeutils +yunion.io/x/pkg/util/version +yunion.io/x/pkg/utils # yunion.io/x/structarg v0.0.0-20190717142057-5caf182cbb4d yunion.io/x/structarg diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/apis/constants/constants.go b/vendor/yunion.io/x/onecloud-operator/pkg/apis/constants/constants.go index 0645c594..00c8e13f 100644 --- a/vendor/yunion.io/x/onecloud-operator/pkg/apis/constants/constants.go +++ b/vendor/yunion.io/x/onecloud-operator/pkg/apis/constants/constants.go @@ -35,6 +35,12 @@ const ( InstanceLabelKey string = "app.kubernetes.io/instance" ) +const ( + OnecloudEditionAnnotationKey string = "onecloud.yunion.io/edition" + OnecloudCommunityEdition string = "ce" + OnecloudEnterpriseEdition string = "ee" +) + const ( OnecloudClusterKind = "OnecloudCluster" OnecloudClusterConfigKind = "OnecloudClusterConfig" @@ -77,6 +83,11 @@ const ( BaremetalAdminProject = SysAdminProject BaremetalPort = 8879 + KubeServerAdminUser = "kubeserver" + KubeServerPort = 8443 + KubeServerDB = "kubeserver" + KubeServerDBUser = "kubeserver" + WebconsoleAdminUser = "webconsole" WebconsoleAdminProject = SysAdminProject WebconsolePort = 8899 @@ -86,11 +97,19 @@ const ( LoggerDB = "yunionlogger" LoggerDBUser = "yunionlogger" - YunionAPIAdminUser = "yunionapi" - YunionAPIPort = 53000 + APIGatewayAdminUser = "yunionapi" + APIGatewayPort = 9300 + APIWebsocketPort = 10443 YunionAgentAdminUser = "yunionagent" YunionAgentPort = 9899 + YunionAgentDB = "yunionagent" + YunionAgentDBUser = "yunionagent" + + YunionConfAdminUser = "yunionconf" + YunionConfPort = 9889 + YunionConfDB = "yunionconf" + YunionConfDBUser = "yunionconf" InfluxdbPort = 8086 InfluxdbDataStore = "/var/lib/influxdb" @@ -123,9 +142,18 @@ const ( ServiceNameLogger = "log" ServiceTypeLogger = "log" + ServiceNameYunionConf = "yunionconf" + ServiceTypeYunionConf = "yunionconf" + + ServiceNameYunionAgent = "yunionagent" + ServiceTypeYunionAgent = "yunionagent" + ServiceNameInfluxdb = "influxdb" ServiceTypeInfluxdb = "influxdb" + ServiceNameKubeServer = "k8s" + ServiceTypeKubeServer = "k8s" + ServiceURLCloudmeta = "https://meta.yunion.cn" ServiceNameCloudmeta = "cloudmeta" ServiceTypeCloudmeta = "cloudmeta" diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1/defaults.go b/vendor/yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1/defaults.go index a6a3a68d..78a5d7a1 100644 --- a/vendor/yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1/defaults.go +++ b/vendor/yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1/defaults.go @@ -73,8 +73,19 @@ func SetDefaults_OnecloudClusterSpec(obj *OnecloudClusterSpec) { WebconsoleComponentType: &obj.Webconsole, SchedulerComponentType: &obj.Scheduler, LoggerComponentType: &obj.Logger, + YunionconfComponentType: &obj.Yunionconf, + APIGatewayComponentType: &obj.APIGateway, + WebComponentType: &obj.Web, + KubeServerComponentType: &obj.KubeServer, } { - SetDefaults_DeploymentSpec(spec, getImage(obj.ImageRepository, cType, obj.Version)) + SetDefaults_DeploymentSpec(spec, getImage(obj.ImageRepository, spec.Repository, cType, spec.ImageName, obj.Version, spec.Tag)) + } + + for cType, spec := range map[ComponentType]*DeploymentSpec{ + APIGatewayComponentType: &obj.APIGateway, + WebComponentType: &obj.Web, + } { + SetDefaults_DeploymentSpecEdition(spec, cType) } type stateDeploy struct { @@ -83,8 +94,9 @@ func SetDefaults_OnecloudClusterSpec(obj *OnecloudClusterSpec) { version string } for cType, spec := range map[ComponentType]*stateDeploy{ - GlanceComponentType: &stateDeploy{&obj.Glance, DefaultGlanceStoreageSize, obj.Version}, - InfluxdbComponentType: &stateDeploy{&obj.Influxdb, DefaultInfluxdbStorageSize, DefaultInfluxdbImageVersion}, + GlanceComponentType: {&obj.Glance, DefaultGlanceStoreageSize, obj.Version}, + InfluxdbComponentType: {&obj.Influxdb, DefaultInfluxdbStorageSize, DefaultInfluxdbImageVersion}, + YunionagentComponentType: {&obj.Yunionagent, "1G", obj.Version}, } { SetDefaults_StatefulDeploymentSpec(cType, spec.obj, spec.size, obj.ImageRepository, spec.version) } @@ -99,19 +111,30 @@ func SetDefaults_Mysql(obj *Mysql) { } } -func getImage(repo string, componentType ComponentType, version string) string { - return fmt.Sprintf("%s/%s:%s", repo, componentType, version) +func getImage(globalRepo, specRepo string, componentType ComponentType, componentName string, globalVersion, tag string) string { + repo := specRepo + if specRepo == "" { + repo = globalRepo + } + version := tag + if version == "" { + version = globalVersion + } + if componentName == "" { + componentName = componentType.String() + } + return fmt.Sprintf("%s/%s:%s", repo, componentName, version) } func SetDefaults_KeystoneSpec(obj *KeystoneSpec, imageRepo, version string) { - SetDefaults_DeploymentSpec(&obj.DeploymentSpec, getImage(imageRepo, KeystoneComponentType, version)) + SetDefaults_DeploymentSpec(&obj.DeploymentSpec, getImage(imageRepo, obj.Repository, KeystoneComponentType, obj.ImageName, version, obj.Tag)) if obj.BootstrapPassword == "" { obj.BootstrapPassword = passwd.GeneratePassword() } } func SetDefaults_RegionSpec(obj *RegionSpec, imageRepo, version string) { - SetDefaults_DeploymentSpec(&obj.DeploymentSpec, getImage(imageRepo, RegionComponentType, version)) + SetDefaults_DeploymentSpec(&obj.DeploymentSpec, getImage(imageRepo, obj.Repository, RegionComponentType, obj.ImageName, version, obj.Tag)) } func setPVCStoreage(obj *ContainerSpec, size string) { @@ -124,7 +147,7 @@ func setPVCStoreage(obj *ContainerSpec, size string) { } func SetDefaults_StatefulDeploymentSpec(ctype ComponentType, obj *StatefulDeploymentSpec, defaultSize string, imageRepo, version string) { - SetDefaults_DeploymentSpec(&obj.DeploymentSpec, getImage(imageRepo, ctype, version)) + SetDefaults_DeploymentSpec(&obj.DeploymentSpec, getImage(imageRepo, obj.Repository, ctype, obj.ImageName, version, obj.Tag)) if obj.StorageClassName == "" { obj.StorageClassName = DefaultStorageClass } @@ -132,12 +155,13 @@ func SetDefaults_StatefulDeploymentSpec(ctype ComponentType, obj *StatefulDeploy } func SetDefaults_DeploymentSpec(obj *DeploymentSpec, image string) { - if obj.Replicas == 0 { + if obj.Replicas <= 0 { obj.Replicas = 1 } - if obj.Image == "" { - obj.Image = image + if obj.Disable { + obj.Replicas = 0 } + obj.Image = image // add tolerations if len(obj.Tolerations) == 0 { obj.Tolerations = append(obj.Tolerations, []corev1.Toleration{ @@ -153,6 +177,15 @@ func SetDefaults_DeploymentSpec(obj *DeploymentSpec, image string) { } } +func SetDefaults_DeploymentSpecEdition(obj *DeploymentSpec, cType ComponentType) { + if obj.Annotations == nil { + obj.Annotations = map[string]string{} + } + if _, ok := obj.Annotations[constants.OnecloudEditionAnnotationKey]; !ok { + obj.Annotations[constants.OnecloudEditionAnnotationKey] = constants.OnecloudCommunityEdition + } +} + func SetDefaults_OnecloudClusterConfig(obj *OnecloudClusterConfig) { SetDefaults_KeystoneConfig(&obj.Keystone) @@ -163,6 +196,7 @@ func SetDefaults_OnecloudClusterConfig(obj *OnecloudClusterConfig) { for opt, userPort := range map[*ServiceCommonOptions]userPort{ &obj.Webconsole: {constants.WebconsoleAdminUser, constants.WebconsolePort}, + &obj.APIGateway: {constants.APIGatewayAdminUser, constants.APIGatewayPort}, } { SetDefaults_ServiceCommonOptions(opt, userPort.user, userPort.port) } @@ -178,6 +212,9 @@ func SetDefaults_OnecloudClusterConfig(obj *OnecloudClusterConfig) { &obj.RegionServer.ServiceDBCommonOptions: {constants.RegionAdminUser, constants.RegionPort, constants.RegionDB, constants.RegionDBUser}, &obj.Glance.ServiceDBCommonOptions: {constants.GlanceAdminUser, constants.GlanceAPIPort, constants.GlanceDB, constants.GlanceDBUser}, &obj.Logger: {constants.LoggerAdminUser, constants.LoggerPort, constants.LoggerDB, constants.LoggerDBUser}, + &obj.Yunionagent: {constants.YunionAgentAdminUser, constants.YunionAgentPort, constants.YunionAgentDB, constants.YunionAgentDBUser}, + &obj.Yunionconf: {constants.YunionConfAdminUser, constants.YunionConfPort, constants.YunionConfDB, constants.YunionConfDBUser}, + &obj.KubeServer: {constants.KubeServerAdminUser, constants.KubeServerPort, constants.KubeServerDB, constants.KubeServerDBUser}, } { SetDefaults_ServiceDBCommonOptions(opt, tmp.db, tmp.dbUser, tmp.user, tmp.port) } diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1/types.go b/vendor/yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1/types.go index 90d54c45..a6994cb8 100644 --- a/vendor/yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1/types.go +++ b/vendor/yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1/types.go @@ -49,6 +49,13 @@ const ( LoggerComponentType ComponentType = "logger" // InfluxdbComponentType is influxdb component type InfluxdbComponentType ComponentType = "influxdb" + // APIGatewayComponentType is apiGateway component type + APIGatewayComponentType ComponentType = "apigateway" + // WebComponentType is web frontent component type + WebComponentType ComponentType = "web" + YunionagentComponentType ComponentType = "yunionagent" + YunionconfComponentType ComponentType = "yunionconf" + KubeServerComponentType ComponentType = "kubeserver" ) // ComponentPhase is the current state of component @@ -93,6 +100,10 @@ type OnecloudClusterSpec struct { Mysql Mysql `json:"mysql"` // Version is onecloud components version Version string `json:"version"` + // CertSANs sets extra Subject Alternative Names for the Cluster signing cert. + CertSANs []string + // Services list non-headless services type used in OnecloudCluster + Services []Service `json:"services,omitempty"` // ImageRepository defines default image registry ImageRepository string `json:"imageRepository"` // Region is cluster region @@ -113,14 +124,20 @@ type OnecloudClusterSpec struct { Webconsole DeploymentSpec `json:"webconsole"` // Logger holds configuration for log service Logger DeploymentSpec `json:"logger"` + // Yunionconf holds configuration for yunionconf service + Yunionconf DeploymentSpec `json:"yunionconf"` + // Yunionagent holds configuration for yunionagent service + Yunionagent StatefulDeploymentSpec `json:"yunionagent"` // Influxdb holds configuration for influxdb Influxdb StatefulDeploymentSpec `json:"influxdb"` // LoadBalancerEndpoint is upstream loadbalancer virtual ip address or DNS domain LoadBalancerEndpoint string `json:"loadBalancerEndpoint"` - // CertSANs sets extra Subject Alternative Names for the Cluster signing cert. - CertSANs []string - // Services list non-headless services type used in OnecloudCluster - Services []Service `json:"services,omitempty"` + // APIGateway holds configuration for yunoinapi + APIGateway DeploymentSpec `json:"apiGateway"` + // Web holds configuration for web + Web DeploymentSpec `json:"web"` + // KubeServer holds configuration for kube-server service + KubeServer DeploymentSpec `json:"kubeserver"` } // OnecloudClusterStatus @@ -133,18 +150,23 @@ type OnecloudClusterStatus struct { Webconsole DeploymentStatus `json:"webconsole,omitempty"` Influxdb DeploymentStatus `json:"influxdb,omitempty"` Logger DeploymentStatus `json:"logger,omitempty"` + APIGateway DeploymentStatus `json:"apiGateway,omitempty"` + Web DeploymentStatus `json:"web,omitempty"` + Yunionconf DeploymentStatus `json:"yunionconf,omitempty"` + Yunionagent DeploymentStatus `json:"yunionagent,omitempty"` + KubeServer DeploymentStatus `json:"kubeserver,omitempty"` } // Etcd describes an etcd cluster type Etcd struct { // Endpoints of etcd members - Endpoints []string + Endpoints []string `json:"endpoints"` // CA is an SSL Certificate Authority data used to secure etcd communication - CA string + CA string `json:"ca"` // CertFile is an SSL certification data used to secure etcd communication - Cert string + Cert string `json:"cert"` // Key is an SSL key data used to secure etcd communication - Key string + Key string `json:"key"` } // Mysql describes an mysql server @@ -162,6 +184,7 @@ type Mysql struct { // DeploymentSpec constains defails of deployment resource service type DeploymentSpec struct { ContainerSpec + Disable bool `json:"disable"` Replicas int32 `json:"replicas"` Affinity *corev1.Affinity `json:"affinity,omitempty"` NodeSelector map[string]string `json:"nodeSelector,omitempty"` @@ -209,6 +232,9 @@ type RegionSpec struct { // ContainerSpec is the container spec of a pod type ContainerSpec struct { Image string `json:"image"` + Repository string `json:"repository,omitempty"` + ImageName string `json:"imageName,omitempty"` + Tag string `json:"tag,omitempty"` ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` Requests *ResourceRequirement `json:"requests,omitempty"` Limits *ResourceRequirement `json:"limits,omitempty"` @@ -280,4 +306,8 @@ type OnecloudClusterConfig struct { Glance GlanceConfig `json:"glance"` Webconsole ServiceCommonOptions `json:"webconsole"` Logger ServiceDBCommonOptions `json:"logger"` + Yunionconf ServiceDBCommonOptions `json:"yunionconf"` + Yunionagent ServiceDBCommonOptions `json:"yunionagent"` + KubeServer ServiceDBCommonOptions `json:"kubeserver"` + APIGateway ServiceCommonOptions `json:"apiGateway"` } diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1/zz_generated.deepcopy.go b/vendor/yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1/zz_generated.deepcopy.go index 4f81cf31..d96650bc 100644 --- a/vendor/yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1/zz_generated.deepcopy.go @@ -308,6 +308,10 @@ func (in *OnecloudClusterConfig) DeepCopyInto(out *OnecloudClusterConfig) { out.Glance = in.Glance out.Webconsole = in.Webconsole out.Logger = in.Logger + out.Yunionconf = in.Yunionconf + out.Yunionagent = in.Yunionagent + out.KubeServer = in.KubeServer + out.APIGateway = in.APIGateway return } @@ -367,14 +371,6 @@ func (in *OnecloudClusterSpec) DeepCopyInto(out *OnecloudClusterSpec) { *out = *in in.Etcd.DeepCopyInto(&out.Etcd) out.Mysql = in.Mysql - in.Keystone.DeepCopyInto(&out.Keystone) - in.RegionServer.DeepCopyInto(&out.RegionServer) - in.Scheduler.DeepCopyInto(&out.Scheduler) - in.Glance.DeepCopyInto(&out.Glance) - in.Climc.DeepCopyInto(&out.Climc) - in.Webconsole.DeepCopyInto(&out.Webconsole) - in.Logger.DeepCopyInto(&out.Logger) - in.Influxdb.DeepCopyInto(&out.Influxdb) if in.CertSANs != nil { in, out := &in.CertSANs, &out.CertSANs *out = make([]string, len(*in)) @@ -385,6 +381,19 @@ func (in *OnecloudClusterSpec) DeepCopyInto(out *OnecloudClusterSpec) { *out = make([]Service, len(*in)) copy(*out, *in) } + in.Keystone.DeepCopyInto(&out.Keystone) + in.RegionServer.DeepCopyInto(&out.RegionServer) + in.Scheduler.DeepCopyInto(&out.Scheduler) + in.Glance.DeepCopyInto(&out.Glance) + in.Climc.DeepCopyInto(&out.Climc) + in.Webconsole.DeepCopyInto(&out.Webconsole) + in.Logger.DeepCopyInto(&out.Logger) + in.Yunionconf.DeepCopyInto(&out.Yunionconf) + in.Yunionagent.DeepCopyInto(&out.Yunionagent) + in.Influxdb.DeepCopyInto(&out.Influxdb) + in.APIGateway.DeepCopyInto(&out.APIGateway) + in.Web.DeepCopyInto(&out.Web) + in.KubeServer.DeepCopyInto(&out.KubeServer) return } @@ -408,6 +417,11 @@ func (in *OnecloudClusterStatus) DeepCopyInto(out *OnecloudClusterStatus) { in.Webconsole.DeepCopyInto(&out.Webconsole) in.Influxdb.DeepCopyInto(&out.Influxdb) in.Logger.DeepCopyInto(&out.Logger) + in.APIGateway.DeepCopyInto(&out.APIGateway) + in.Web.DeepCopyInto(&out.Web) + in.Yunionconf.DeepCopyInto(&out.Yunionconf) + in.Yunionagent.DeepCopyInto(&out.Yunionagent) + in.KubeServer.DeepCopyInto(&out.KubeServer) return } diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/controller/ingress_control.go b/vendor/yunion.io/x/onecloud-operator/pkg/controller/ingress_control.go new file mode 100644 index 00000000..a087bdee --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/controller/ingress_control.go @@ -0,0 +1,89 @@ +// Copyright 2019 Yunion +// +// 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 controller + +import ( + "fmt" + extensions "k8s.io/api/extensions/v1beta1" + apierrors "k8s.io/apimachinery/pkg/api/errors" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/client-go/kubernetes" + listers "k8s.io/client-go/listers/extensions/v1beta1" + "k8s.io/client-go/tools/record" + "k8s.io/client-go/util/retry" + "k8s.io/klog" + + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" +) + +// IngressControlInterface defines the interface that uses to create, update and delete Ingress +type IngressControlInterface interface { + CreateIngress(*v1alpha1.OnecloudCluster, *extensions.Ingress) error + UpdateIngress(*v1alpha1.OnecloudCluster, *extensions.Ingress) (*extensions.Ingress, error) + DeleteIngress(*v1alpha1.OnecloudCluster, *extensions.Ingress) error +} + +type realIngressControl struct { + *baseControl + kubeCli kubernetes.Interface + ingressLister listers.IngressLister +} + +func NewIngressControl(kubeCli kubernetes.Interface, ingressLister listers.IngressLister, recorder record.EventRecorder) IngressControlInterface { + return &realIngressControl{newBaseControl("Ingress", recorder), kubeCli, ingressLister} +} + +func (c *realIngressControl) CreateIngress(oc *v1alpha1.OnecloudCluster, ing *extensions.Ingress) error { + _, err := c.kubeCli.ExtensionsV1beta1().Ingresses(oc.Namespace).Create(ing) + if apierrors.IsAlreadyExists(err) { + return err + } + c.RecordCreateEvent(oc, ing, err) + return err +} + +func (c *realIngressControl) UpdateIngress(oc *v1alpha1.OnecloudCluster, ing *extensions.Ingress) (*extensions.Ingress, error) { + ns := oc.GetNamespace() + ocName := oc.GetName() + ingName := ing.GetName() + ingSpec := ing.Spec.DeepCopy() + var updatedIng *extensions.Ingress + err := retry.RetryOnConflict(retry.DefaultBackoff, func() error { + var updateErr error + updatedIng, updateErr = c.kubeCli.ExtensionsV1beta1().Ingresses(ns).Update(ing) + if updateErr == nil { + klog.Infof("OnecloudCluster: [%s/%s]'s Ingress: [%s/%s] updated successfully", ns, ocName, ns, ingName) + return nil + } + klog.Errorf("failed to update OnecloudCluster: [%s/%s]'s Ingress: [%s/%s], error: %v", ns, ocName, ns, ingName, updateErr) + + if updated, err := c.ingressLister.Ingresses(ns).Get(ingName); err == nil { + ing = updated.DeepCopy() + ing.Spec = *ingSpec + } else { + utilruntime.HandleError(fmt.Errorf("error getting updated Ingress %s/%s from lister: %v", ns, ingName, err)) + } + return updateErr + }) + + c.RecordUpdateEvent(oc, ing, err) + return updatedIng, err +} + +func (c *realIngressControl) DeleteIngress(oc *v1alpha1.OnecloudCluster, ing *extensions.Ingress) error { + err := c.kubeCli.ExtensionsV1beta1().Ingresses(oc.GetNamespace()).Delete(ing.Name, nil) + c.RecordDeleteEvent(oc, ing, err) + return err +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/controller/onecloud_cert.go b/vendor/yunion.io/x/onecloud-operator/pkg/controller/onecloud_cert.go index 9827e4c8..17a17bcc 100644 --- a/vendor/yunion.io/x/onecloud-operator/pkg/controller/onecloud_cert.go +++ b/vendor/yunion.io/x/onecloud-operator/pkg/controller/onecloud_cert.go @@ -76,6 +76,8 @@ func (c *realOnecloudCertControl) CreateCert(oc *v1alpha1.OnecloudCluster) error return err } store.WriteCertAndKey(svcCerts.BaseName, svcCert, svcKey) + // for web ingress + store.WriteCertAndKey("tls", svcCert, svcKey) certSecret := newSecretFromStore(oc, store) _, err = c.kubeCli.CoreV1().Secrets(oc.GetNamespace()).Create(certSecret) return err diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/controller/onecloud_control.go b/vendor/yunion.io/x/onecloud-operator/pkg/controller/onecloud_control.go index e313b056..0db81149 100644 --- a/vendor/yunion.io/x/onecloud-operator/pkg/controller/onecloud_control.go +++ b/vendor/yunion.io/x/onecloud-operator/pkg/controller/onecloud_control.go @@ -90,7 +90,7 @@ func NewOnecloudClientToken(oc *v1alpha1.OnecloudCluster) (*mcclient.Client, mcc config.DomainName, config.ProjectName, config.ProjectDomain, - mcclient.AuthSourceCli, + "operator", ) return cli, token, err } @@ -161,6 +161,7 @@ type ComponentManager interface { Keystone() PhaseControl Region() PhaseControl Glance() PhaseControl + YunionAgent() PhaseControl } func (w *OnecloudControl) Components(oc *v1alpha1.OnecloudCluster) ComponentManager { @@ -207,6 +208,10 @@ func (c *realComponent) Glance() PhaseControl { return &glanceComponent{newBaseComponent(c)} } +func (c *realComponent) YunionAgent() PhaseControl { + return &yunionagentComponent{newBaseComponent(c)} +} + type baseComponent struct { manager ComponentManager } @@ -595,3 +600,41 @@ func NewRegisterEndpointComponent( func (c *registerEndpointComponent) Setup() error { return c.RegisterCloudServiceEndpoint(c.cType, c.serviceName, c.serviceType, c.port, c.prefix) } + +type yunionagentComponent struct { + *baseComponent +} + +func (c yunionagentComponent) Setup() error { + return c.RegisterCloudServiceEndpoint( + v1alpha1.YunionagentComponentType, + constants.ServiceNameYunionAgent, constants.ServiceTypeYunionAgent, + constants.YunionAgentPort, "") +} + +func (c yunionagentComponent) SystemInit() error { + if err := c.addWelcomeNotice(); err != nil { + klog.Errorf("yunion agent add notices error: %v", err) + } + return nil +} + +func (c yunionagentComponent) addWelcomeNotice() error { + s, err := c.GetSession() + if err != nil { + return err + } + ret, err := modules.Notice.List(s, nil) + if err != nil { + return err + } + if ret.Total > 0 { + return nil + } + params := jsonutils.NewDict() + params.Add(jsonutils.NewString("欢迎使用云管平台"), "title") + params.Add(jsonutils.NewString("欢迎使用OneCloud多云云管平台。这里告栏。您可以在这里发布需要告知所有用户的消息。"), "content") + + _, err = modules.Notice.Create(s, params) + return err +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/label/label.go b/vendor/yunion.io/x/onecloud-operator/pkg/label/label.go new file mode 100644 index 00000000..ebe97af3 --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/label/label.go @@ -0,0 +1,95 @@ +// Copyright 2019 Yunion +// +// 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 label + +import ( + "fmt" + "strings" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/labels" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" +) + +const ( + // The following labels are recommended by kubernetes https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/ + + // ManagedByLabelKey is Kubernetes recommended label key, it represents the tool being used to manage the operation of an application + // For resources managed by OneCloud Operator, its value is always onecloud-operator + ManagedByLabelKey string = constants.ManagedByLabelKey + // ComponentLabelKey is Kubernetes recommended label key, it represents the component within the architecture + ComponentLabelKey string = constants.ComponentLabelKey + // NameLabelKey is Kubernetes recommended label key, it represents the name of the application + // It should always be onecloud-cluster in our case. + NameLabelKey string = constants.NameLabelKey + // InstanceLabelKey is Kubernetes recommended label key, it represents a unique name identifying the instance of an application + // It's set by helm when installing a release + InstanceLabelKey string = constants.InstanceLabelKey +) + +// Label is the label field in metadata +type Label map[string]string + +// New initialize a new Label +func New() Label { + return Label{ + NameLabelKey: "onecloud-cluster", + ManagedByLabelKey: "onecloud-operator", + } +} + +// Instance adds instance kv pair to label +func (l Label) Instance(name string) Label { + l[InstanceLabelKey] = name + return l +} + +// Component adds component kv pair to label +func (l Label) Component(name string) Label { + l[ComponentLabelKey] = name + return l +} + +// ComponentType returns component type +func (l Label) ComponentType() string { + return l[ComponentLabelKey] +} + +// Selector gets labels.Selector from label +func (l Label) Selector() (labels.Selector, error) { + return metav1.LabelSelectorAsSelector(l.LabelSelector()) +} + +// LabelSelector gets LabelSelector from label +func (l Label) LabelSelector() *metav1.LabelSelector { + return &metav1.LabelSelector{MatchLabels: l} +} + +// Labels converts label to map[string]string +func (l Label) Labels() map[string]string { + return l +} + +// String converts label to a string +func (l Label) String() string { + var arr []string + + for k, v := range l { + arr = append(arr, fmt.Sprintf("%s=%s", k, v)) + } + + return strings.Join(arr, ",") +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/apigateway.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/apigateway.go new file mode 100644 index 00000000..dd3a6bba --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/apigateway.go @@ -0,0 +1,130 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + "yunion.io/x/onecloud/pkg/cloudcommon/options" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/manager" +) + +type apiGatewayManager struct { + *ComponentManager +} + +func newAPIGatewayManager(man *ComponentManager) manager.Manager { + return &apiGatewayManager{man} +} + +func (m *apiGatewayManager) Sync(oc *v1alpha1.OnecloudCluster) error { + return syncComponent(m, oc) +} + +type apiOptions struct { + options.CommonOptions + WsPort int `default:"10443"` + ShowCaptcha bool `default:"true"` + EnableTotp bool `default:"false"` +} + +func (m *apiGatewayManager) getCloudUser(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.CloudUser { + return &cfg.APIGateway.CloudUser +} + +func (m *apiGatewayManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error) { + opt := &apiOptions{} + if err := SetOptionsDefault(opt, "apigateway"); err != nil { + return nil, err + } + SetOptionsServiceTLS(&opt.BaseOptions) + SetServiceCommonOptions(&opt.CommonOptions, oc, cfg.APIGateway) + opt.WsPort = constants.APIWebsocketPort + + return m.newServiceConfigMap(v1alpha1.APIGatewayComponentType, oc, opt), nil +} + +func (m *apiGatewayManager) getService(oc *v1alpha1.OnecloudCluster) *corev1.Service { + ports := []corev1.ServicePort{ + NewServiceNodePort("api", constants.APIGatewayPort), + NewServiceNodePort("ws", constants.APIWebsocketPort), + } + return m.newNodePortService(v1alpha1.APIGatewayComponentType, oc, ports) +} + +func (m *apiGatewayManager) getDeployment(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error) { + spec := &oc.Spec.APIGateway + isEE := IsEnterpriseEdition(spec) + cf := func(volMounts []corev1.VolumeMount) []corev1.Container { + cmd := "/opt/yunion/bin/apigateway" + if isEE { + cmd = "/opt/yunion/bin/yunionapi" + } + cs := []corev1.Container{ + { + Name: "api", + Image: oc.Spec.APIGateway.Image, + Command: []string{cmd, "--config", "/etc/yunion/apigateway.conf"}, + VolumeMounts: volMounts, + }, + } + if isEE { + cs = append(cs, corev1.Container{ + Name: "ws", + Image: oc.Spec.APIGateway.Image, + Command: []string{"/opt/yunion/bin/ws", "--config", "/etc/yunion/apigateway.conf"}, + VolumeMounts: volMounts, + }) + } + return cs + } + deploy, err := m.newDefaultDeploymentNoInit(v1alpha1.APIGatewayComponentType, oc, + NewVolumeHelper(oc, controller.ComponentConfigMapName(oc, v1alpha1.APIGatewayComponentType), v1alpha1.APIGatewayComponentType), + oc.Spec.APIGateway, cf) + if err != nil { + return nil, err + } + podSpec := &deploy.Spec.Template.Spec + apiContainer := &podSpec.Containers[0] + podSpec.Volumes = append(podSpec.Volumes, corev1.Volume{ + Name: "data", + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{}, + }, + }) + apiContainer.VolumeMounts = append(apiContainer.VolumeMounts, corev1.VolumeMount{ + Name: "data", + ReadOnly: false, + MountPath: "/etc/yunion/data/", + }) + if isEE { + wsContainer := &podSpec.Containers[1] + wsContainer.VolumeMounts = append(wsContainer.VolumeMounts, corev1.VolumeMount{ + Name: "data", + ReadOnly: false, + MountPath: "/etc/yunion/data/", + }) + } + return deploy, nil +} + +func (m *apiGatewayManager) getDeploymentStatus(oc *v1alpha1.OnecloudCluster) *v1alpha1.DeploymentStatus { + return &oc.Status.APIGateway +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/climc.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/climc.go new file mode 100644 index 00000000..d686f33c --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/climc.go @@ -0,0 +1,87 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "yunion.io/x/onecloud-operator/pkg/apis/constants" + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/manager" +) + +type climcManager struct { + *ComponentManager +} + +func newClimcComponentManager(base *ComponentManager) manager.Manager { + return &climcManager{ + ComponentManager: base, + } +} + +func (m *climcManager) Sync(oc *v1alpha1.OnecloudCluster) error { + return syncComponent(m, oc) +} + +func (m *climcManager) getDeployment(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error) { + containersF := func(volMounts []corev1.VolumeMount) []corev1.Container { + return []corev1.Container{ + { + Name: "climc", + Image: oc.Spec.Climc.Image, + Command: []string{"tail", "-f", "/dev/null"}, + Env: []corev1.EnvVar{ + { + Name: "OS_USERNAME", + Value: constants.SysAdminUsername, + }, + { + Name: "OS_USERNAME", + Value: constants.SysAdminUsername, + }, + { + Name: "OS_PASSWORD", + Value: oc.Spec.Keystone.BootstrapPassword, + }, + { + Name: "OS_REGION_NAME", + Value: oc.Spec.Region, + }, + { + Name: "OS_AUTH_URL", + Value: controller.GetAuthURL(oc), + }, + { + Name: "OS_PROJECT_NAME", + Value: constants.SysAdminProject, + }, + { + Name: "YUNION_INSECURE", + Value: "true", + }, + }, + VolumeMounts: volMounts, + }, + } + } + return m.newDefaultDeploymentNoInit( + v1alpha1.ClimcComponentType, oc, + NewVolumeHelper(oc, "", v1alpha1.ClimcComponentType), + oc.Spec.Climc, + containersF, + ) +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/component.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/component.go new file mode 100644 index 00000000..bd7662cf --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/component.go @@ -0,0 +1,653 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + "fmt" + + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + extensions "k8s.io/api/extensions/v1beta1" + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + appv1 "k8s.io/client-go/listers/apps/v1" + corelisters "k8s.io/client-go/listers/core/v1" + extensionlisters "k8s.io/client-go/listers/extensions/v1beta1" + + "yunion.io/x/jsonutils" + "yunion.io/x/onecloud-operator/pkg/label" + + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/manager" +) + +type ComponentManager struct { + deployControl controller.DeploymentControlInterface + deployLister appv1.DeploymentLister + svcControl controller.ServiceControlInterface + svcLister corelisters.ServiceLister + pvcControl controller.PVCControlInterface + pvcLister corelisters.PersistentVolumeClaimLister + ingControl controller.IngressControlInterface + ingLister extensionlisters.IngressLister + + configer Configer + onecloudControl *controller.OnecloudControl +} + +// NewComponentManager return *BaseComponentManager +func NewComponentManager( + deployCtrol controller.DeploymentControlInterface, + deployLister appv1.DeploymentLister, + svcControl controller.ServiceControlInterface, + svcLister corelisters.ServiceLister, + pvcControl controller.PVCControlInterface, + pvcLister corelisters.PersistentVolumeClaimLister, + ingControl controller.IngressControlInterface, + ingLister extensionlisters.IngressLister, + configer Configer, + onecloudControl *controller.OnecloudControl, +) *ComponentManager { + return &ComponentManager{ + deployControl: deployCtrol, + deployLister: deployLister, + svcControl: svcControl, + svcLister: svcLister, + pvcControl: pvcControl, + pvcLister: pvcLister, + ingControl: ingControl, + ingLister: ingLister, + configer: configer, + onecloudControl: onecloudControl, + } +} + +func (m *ComponentManager) syncService( + oc *v1alpha1.OnecloudCluster, + svcFactory func(*v1alpha1.OnecloudCluster) *corev1.Service, +) error { + ns := oc.GetNamespace() + newSvc := svcFactory(oc) + if newSvc == nil { + return nil + } + oldSvcTmp, err := m.svcLister.Services(ns).Get(newSvc.GetName()) + if errors.IsNotFound(err) { + err = SetServiceLastAppliedConfigAnnotation(newSvc) + if err != nil { + return err + } + return m.svcControl.CreateService(oc, newSvc) + } + if err != nil { + return err + } + + oldSvc := oldSvcTmp.DeepCopy() + + equal, err := serviceEqual(newSvc, oldSvc) + if err != nil { + return err + } + if !equal { + svc := *oldSvc + svc.Spec = newSvc.Spec + svc.Spec.ClusterIP = oldSvc.Spec.ClusterIP + err = SetServiceLastAppliedConfigAnnotation(&svc) + if err != nil { + return err + } + _, err = m.svcControl.UpdateService(oc, &svc) + return err + } + + return nil +} + +func (m *ComponentManager) syncIngress( + oc *v1alpha1.OnecloudCluster, + ingFactory func(*v1alpha1.OnecloudCluster) *extensions.Ingress, +) error { + ns := oc.GetNamespace() + newIng := ingFactory(oc) + if newIng == nil { + return nil + } + oldIngTmp, err := m.ingLister.Ingresses(ns).Get(newIng.GetName()) + if errors.IsNotFound(err) { + err = SetIngressLastAppliedConfigAnnotation(newIng) + if err != nil { + return err + } + return m.ingControl.CreateIngress(oc, newIng) + } + if err != nil { + return err + } + + oldIng := oldIngTmp.DeepCopy() + + equal, err := ingressEqual(newIng, oldIng) + if err != nil { + return err + } + if !equal { + ing := *oldIng + ing.Spec = newIng.Spec + err = SetIngressLastAppliedConfigAnnotation(&ing) + if err != nil { + return err + } + _, err = m.ingControl.UpdateIngress(oc, &ing) + return err + } + return nil +} + +func (m *ComponentManager) syncConfigMap( + oc *v1alpha1.OnecloudCluster, + dbConfigFactory func(*v1alpha1.OnecloudClusterConfig) *v1alpha1.DBConfig, + svcAccountFactory func(*v1alpha1.OnecloudClusterConfig) *v1alpha1.CloudUser, + cfgMapFactory func(*v1alpha1.OnecloudCluster, *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error), +) error { + clustercfg, err := m.configer.GetClusterConfig(oc) + if err != nil { + return err + } + if dbConfigFactory != nil { + dbConfig := dbConfigFactory(clustercfg) + if dbConfig != nil { + if err := EnsureClusterDBUser(oc, *dbConfig); err != nil { + return err + } + } + } + if svcAccountFactory != nil { + account := svcAccountFactory(clustercfg) + if account != nil { + s, err := m.onecloudControl.GetSession(oc) + if err != nil { + return err + } + if err := EnsureServiceAccount(s, *account); err != nil { + return err + } + } + } + cfgMap, err := cfgMapFactory(oc, clustercfg) + if err != nil { + return err + } + if cfgMap == nil { + return nil + } + if err := SetConfigMapLastAppliedConfigAnnotation(cfgMap); err != nil { + return err + } + oldCfgMap, _ := m.configer.Lister().ConfigMaps(oc.GetNamespace()).Get(cfgMap.GetName()) + if oldCfgMap != nil { + if equal, err := configMapEqual(cfgMap, oldCfgMap); err != nil { + return err + } else if equal { + return nil + } + } + return m.configer.CreateOrUpdateConfigMap(oc, cfgMap) +} + +func (m *ComponentManager) syncDeployment( + oc *v1alpha1.OnecloudCluster, + deploymentFactory func(*v1alpha1.OnecloudCluster, *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error), + postSyncFunc func(*v1alpha1.OnecloudCluster, *apps.Deployment) error, +) error { + ocName := oc.GetName() + ns := oc.GetNamespace() + cfg, err := m.configer.GetClusterConfig(oc) + if err != nil { + return err + } + newDeploy, err := deploymentFactory(oc, cfg) + if err != nil { + return err + } + + oldDeployTmp, err := m.deployLister.Deployments(ns).Get(newDeploy.GetName()) + if err != nil && !errors.IsNotFound(err) { + return err + } + if errors.IsNotFound(err) { + err = SetDeploymentLastAppliedConfigAnnotation(newDeploy) + if err != nil { + return err + } + if err := m.deployControl.CreateDeployment(oc, newDeploy); err != nil { + return err + } + oc.Status.Keystone.Deployment = &apps.DeploymentStatus{} + return controller.RequeueErrorf("OnecloudCluster: [%s/%s], waiting for keystone running", ns, ocName) + } + + oldDeploy := oldDeployTmp.DeepCopy() + + if !templateEqual(newDeploy.Spec.Template, oldDeploy.Spec.Template) || oc.Status.Keystone.Phase == v1alpha1.UpgradePhase { + /* if err := m.ksUpgrader.Upgrade(oc, oldKsDeploy, newKsDeploy); err != nil { + return err + }*/ + } + + if err = m.updateDeployment(oc, newDeploy, oldDeploy); err != nil { + return err + } + if postSyncFunc != nil { + if err := postSyncFunc(oc, oldDeploy); err != nil { + return err + } + } + return nil +} + +func (m *ComponentManager) updateDeployment(oc *v1alpha1.OnecloudCluster, newDeploy, oldDeploy *apps.Deployment) error { + if !deploymentEqual(*newDeploy, *oldDeploy) { + deploy := *oldDeploy + deploy.Spec.Template = newDeploy.Spec.Template + *deploy.Spec.Replicas = *newDeploy.Spec.Replicas + deploy.Spec.Strategy = newDeploy.Spec.Strategy + err := SetDeploymentLastAppliedConfigAnnotation(&deploy) + if err != nil { + return err + } + _, err = m.deployControl.UpdateDeployment(oc, &deploy) + return err + } + return nil +} + +func (m *ComponentManager) newDefaultDeployment( + componentType v1alpha1.ComponentType, + oc *v1alpha1.OnecloudCluster, + volHelper *VolumeHelper, + spec v1alpha1.DeploymentSpec, + initContainersFactory func([]corev1.VolumeMount) []corev1.Container, + containersFactory func([]corev1.VolumeMount) []corev1.Container, +) (*apps.Deployment, error) { + return m.newDeployment(componentType, oc, volHelper, spec, initContainersFactory, containersFactory, false, corev1.DNSClusterFirst) +} + +func (m *ComponentManager) newDefaultDeploymentNoInit( + componentType v1alpha1.ComponentType, + oc *v1alpha1.OnecloudCluster, + volHelper *VolumeHelper, + spec v1alpha1.DeploymentSpec, + containersFactory func([]corev1.VolumeMount) []corev1.Container, +) (*apps.Deployment, error) { + return m.newDeployment(componentType, oc, volHelper, spec, nil, containersFactory, false, corev1.DNSClusterFirst) +} + +func (m *ComponentManager) getObjectMeta(oc *v1alpha1.OnecloudCluster, name string, labels map[string]string) metav1.ObjectMeta { + return metav1.ObjectMeta{ + Name: name, + Namespace: oc.GetNamespace(), + Labels: labels, + OwnerReferences: []metav1.OwnerReference{controller.GetOwnerRef(oc)}, + } +} + +func (m *ComponentManager) getComponentLabel(oc *v1alpha1.OnecloudCluster, componentType v1alpha1.ComponentType) label.Label { + instanceName := oc.GetLabels()[label.InstanceLabelKey] + return label.New().Instance(instanceName).Component(componentType.String()) +} + +func (m *ComponentManager) newConfigMap(componentType v1alpha1.ComponentType, oc *v1alpha1.OnecloudCluster, config string) *corev1.ConfigMap { + name := controller.ComponentConfigMapName(oc, componentType) + return &corev1.ConfigMap{ + ObjectMeta: m.getObjectMeta(oc, name, m.getComponentLabel(oc, componentType).Labels()), + Data: map[string]string{ + "config": config, + }, + } +} + +func (m *ComponentManager) newServiceConfigMap(cType v1alpha1.ComponentType, oc *v1alpha1.OnecloudCluster, opt interface{}) *corev1.ConfigMap { + configYaml := jsonutils.Marshal(opt).YAMLString() + return m.newConfigMap(cType, oc, configYaml) +} + +func (m *ComponentManager) newService( + componentType v1alpha1.ComponentType, + oc *v1alpha1.OnecloudCluster, + serviceType corev1.ServiceType, + ports []corev1.ServicePort, +) *corev1.Service { + ocName := oc.GetName() + svcName := controller.NewClusterComponentName(ocName, componentType) + appLabel := m.getComponentLabel(oc, componentType) + + svc := &corev1.Service{ + ObjectMeta: m.getObjectMeta(oc, svcName, appLabel), + Spec: corev1.ServiceSpec{ + Type: serviceType, + Selector: appLabel, + Ports: ports, + }, + } + return svc +} + +func (m *ComponentManager) newNodePortService(cType v1alpha1.ComponentType, oc *v1alpha1.OnecloudCluster, ports []corev1.ServicePort) *corev1.Service { + return m.newService(cType, oc, corev1.ServiceTypeNodePort, ports) +} + +func (m *ComponentManager) newSingleNodePortService(cType v1alpha1.ComponentType, oc *v1alpha1.OnecloudCluster, port int32) *corev1.Service { + ports := []corev1.ServicePort{ + NewServiceNodePort("api", port), + } + return m.newNodePortService(cType, oc, ports) +} + +func (m *ComponentManager) newDeployment( + componentType v1alpha1.ComponentType, + oc *v1alpha1.OnecloudCluster, + volHelper *VolumeHelper, + spec v1alpha1.DeploymentSpec, + initContainersFactory func([]corev1.VolumeMount) []corev1.Container, + containersFactory func([]corev1.VolumeMount) []corev1.Container, + hostNetwork bool, + dnsPolicy corev1.DNSPolicy, +) (*apps.Deployment, error) { + ns := oc.GetNamespace() + ocName := oc.GetName() + + appLabel := m.getComponentLabel(oc, componentType) + + vols := volHelper.GetVolumes() + volMounts := volHelper.GetVolumeMounts() + + podAnnotations := spec.Annotations + + deployName := controller.NewClusterComponentName(ocName, componentType) + + appDeploy := &apps.Deployment{ + ObjectMeta: metav1.ObjectMeta{ + Name: deployName, + Namespace: ns, + Labels: appLabel.Labels(), + OwnerReferences: []metav1.OwnerReference{controller.GetOwnerRef(oc)}, + }, + Spec: apps.DeploymentSpec{ + Replicas: &spec.Replicas, + Strategy: apps.DeploymentStrategy{Type: apps.RecreateDeploymentStrategyType}, + Selector: appLabel.LabelSelector(), + Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: appLabel.Labels(), + Annotations: podAnnotations, + }, + Spec: corev1.PodSpec{ + Affinity: spec.Affinity, + NodeSelector: spec.NodeSelector, + Containers: containersFactory(volMounts), + RestartPolicy: corev1.RestartPolicyAlways, + Tolerations: spec.Tolerations, + Volumes: vols, + HostNetwork: hostNetwork, + DNSPolicy: dnsPolicy, + }, + }, + }, + } + templateSpec := &appDeploy.Spec.Template.Spec + if initContainersFactory != nil { + templateSpec.InitContainers = initContainersFactory(volMounts) + } + if containersFactory != nil { + templateSpec.Containers = containersFactory(volMounts) + } + return appDeploy, nil +} + +func (m *ComponentManager) newCloudServiceDeployment( + cType v1alpha1.ComponentType, + oc *v1alpha1.OnecloudCluster, + deployCfg v1alpha1.DeploymentSpec, + initContainersF func([]corev1.VolumeMount) []corev1.Container, + ports []corev1.ContainerPort, +) (*apps.Deployment, error) { + configMap := controller.ComponentConfigMapName(oc, cType) + containersF := func(volMounts []corev1.VolumeMount) []corev1.Container { + return []corev1.Container{ + { + Name: cType.String(), + Image: deployCfg.Image, + Command: []string{ + fmt.Sprintf("/opt/yunion/bin/%s", cType.String()), + "--config", + fmt.Sprintf("/etc/yunion/%s.conf", cType.String()), + }, + ImagePullPolicy: oc.Spec.Keystone.ImagePullPolicy, + Ports: ports, + VolumeMounts: volMounts, + }, + } + } + + return m.newDefaultDeployment(cType, oc, NewVolumeHelper(oc, configMap, cType), + deployCfg, initContainersF, containersF) +} + +func (m *ComponentManager) newCloudServiceDeploymentWithInit( + cType v1alpha1.ComponentType, + oc *v1alpha1.OnecloudCluster, + deployCfg v1alpha1.DeploymentSpec, + ports []corev1.ContainerPort, +) (*apps.Deployment, error) { + initContainersF := func(volMounts []corev1.VolumeMount) []corev1.Container { + return []corev1.Container{ + { + Name: "init", + Image: deployCfg.Image, + Command: []string{ + fmt.Sprintf("/opt/yunion/bin/%s", cType.String()), + "--config", + fmt.Sprintf("/etc/yunion/%s.conf", cType.String()), + "--auto-sync-table", + "--exit-after-db-init", + }, + VolumeMounts: volMounts, + }, + } + } + return m.newCloudServiceDeployment(cType, oc, deployCfg, initContainersF, ports) +} + +func (m *ComponentManager) newCloudServiceDeploymentNoInit( + cType v1alpha1.ComponentType, + oc *v1alpha1.OnecloudCluster, + deployCfg v1alpha1.DeploymentSpec, + ports []corev1.ContainerPort, +) (*apps.Deployment, error) { + return m.newCloudServiceDeployment(cType, oc, deployCfg, nil, ports) +} + +func (m *ComponentManager) newCloudServiceSinglePortDeployment( + cType v1alpha1.ComponentType, + oc *v1alpha1.OnecloudCluster, + deployCfg v1alpha1.DeploymentSpec, + port int32, + doInit bool, +) (*apps.Deployment, error) { + ports := []corev1.ContainerPort{ + { + Name: "api", + ContainerPort: port, + Protocol: corev1.ProtocolTCP, + }, + } + f := m.newCloudServiceDeploymentNoInit + if doInit { + f = m.newCloudServiceDeploymentWithInit + } + return f(cType, oc, deployCfg, ports) +} + +func (m *ComponentManager) deploymentIsUpgrading(deploy *apps.Deployment, oc *v1alpha1.OnecloudCluster) (bool, error) { + if deploymentIsUpgrading(deploy) { + return true, nil + } + return false, nil +} + +func (m *ComponentManager) newPVC(cType v1alpha1.ComponentType, oc *v1alpha1.OnecloudCluster, spec v1alpha1.StatefulDeploymentSpec) (*corev1.PersistentVolumeClaim, error) { + ocName := oc.GetName() + pvcName := controller.NewClusterComponentName(ocName, cType) + + storageClass := spec.StorageClassName + size := spec.Requests.Storage + sizeQ, err := resource.ParseQuantity(size) + if err != nil { + return nil, err + } + + pvc := &corev1.PersistentVolumeClaim{ + ObjectMeta: metav1.ObjectMeta{ + Name: pvcName, + Namespace: oc.GetNamespace(), + }, + Spec: corev1.PersistentVolumeClaimSpec{ + AccessModes: []corev1.PersistentVolumeAccessMode{ + corev1.ReadWriteOnce, + }, + Resources: corev1.ResourceRequirements{ + Requests: corev1.ResourceList{ + corev1.ResourceStorage: sizeQ, + }, + }, + }, + } + if storageClass != "" { + pvc.Spec.StorageClassName = &storageClass + } + return pvc, nil +} + +func (m *ComponentManager) syncPVC(oc *v1alpha1.OnecloudCluster, + pvcFactory func(*v1alpha1.OnecloudCluster) (*corev1.PersistentVolumeClaim, error)) error { + ns := oc.GetNamespace() + newPvc, err := pvcFactory(oc) + if err != nil { + return err + } + if newPvc == nil { + return nil + } + _, err = m.pvcLister.PersistentVolumeClaims(ns).Get(newPvc.GetName()) + if errors.IsNotFound(err) { + return m.pvcControl.CreatePVC(oc, newPvc) + } + if err != nil { + return err + } + // Not update pvc + return nil +} + +func (m *ComponentManager) getDBConfig(_ *v1alpha1.OnecloudClusterConfig) *v1alpha1.DBConfig { + return nil +} + +func (m *ComponentManager) getCloudUser(_ *v1alpha1.OnecloudClusterConfig) *v1alpha1.CloudUser { + return nil +} + +func (m *ComponentManager) getPhaseControl(_ controller.ComponentManager) controller.PhaseControl { + return nil +} + +func (m *ComponentManager) getDeploymentStatus(_ *v1alpha1.OnecloudCluster) *v1alpha1.DeploymentStatus { + return nil +} + +func (m *ComponentManager) getService(_ *v1alpha1.OnecloudCluster) *corev1.Service { + return nil +} + +func (m *ComponentManager) getIngress(_ *v1alpha1.OnecloudCluster) *extensions.Ingress { + return nil +} + +func (m *ComponentManager) getConfigMap(_ *v1alpha1.OnecloudCluster, _ *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error) { + return nil, nil +} + +func (m *ComponentManager) getComponentManager() *ComponentManager { + return m +} + +func (m *ComponentManager) getPVC(_ *v1alpha1.OnecloudCluster) (*corev1.PersistentVolumeClaim, error) { + return nil, nil +} + +func (m *ComponentManager) Keystone() manager.Manager { + return newKeystoneComponentManager(m) +} + +func (m *ComponentManager) Logger() manager.Manager { + return newLoggerManager(m) +} + +func (m *ComponentManager) Region() manager.Manager { + return newRegionManager(m) +} + +func (m *ComponentManager) Climc() manager.Manager { + return newClimcComponentManager(m) +} + +func (m *ComponentManager) Glance() manager.Manager { + return newGlanceManager(m) +} + +func (m *ComponentManager) Webconsole() manager.Manager { + return newWebconsoleManager(m) +} + +func (m *ComponentManager) Scheduler() manager.Manager { + return newSchedulerManager(m) +} + +func (m *ComponentManager) Influxdb() manager.Manager { + return newInfluxdbManager(m) +} + +func (m *ComponentManager) Yunionagent() manager.Manager { + return newYunionagentManager(m) +} + +func (m *ComponentManager) Yunionconf() manager.Manager { + return newYunionconfManager(m) +} + +func (m *ComponentManager) KubeServer() manager.Manager { + return newKubeManager(m) +} + +func (m *ComponentManager) APIGateway() manager.Manager { + return newAPIGatewayManager(m) +} + +func (m *ComponentManager) Web() manager.Manager { + return newWebManager(m) +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/configer.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/configer.go new file mode 100644 index 00000000..af27fd01 --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/configer.go @@ -0,0 +1,29 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + corev1 "k8s.io/api/core/v1" + corelisters "k8s.io/client-go/listers/core/v1" + + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" +) + +// Configer implements the logic to get cluster config. +type Configer interface { + GetClusterConfig(cluster *v1alpha1.OnecloudCluster) (*v1alpha1.OnecloudClusterConfig, error) + CreateOrUpdateConfigMap(cluster *v1alpha1.OnecloudCluster, newCfgMap *corev1.ConfigMap) error + Lister() corelisters.ConfigMapLister +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/glance.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/glance.go new file mode 100644 index 00000000..83393e11 --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/glance.go @@ -0,0 +1,108 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/manager" + "yunion.io/x/onecloud/pkg/image/options" +) + +type glanceManager struct { + *ComponentManager +} + +func newGlanceManager(man *ComponentManager) manager.Manager { + return &glanceManager{man} +} + +func (m *glanceManager) Sync(oc *v1alpha1.OnecloudCluster) error { + return syncComponent(m, oc) +} + +func (m *glanceManager) getDBConfig(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.DBConfig { + return &cfg.Glance.DB +} + +func (m *glanceManager) getCloudUser(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.CloudUser { + return &cfg.Glance.CloudUser +} + +func (m *glanceManager) getPhaseControl(man controller.ComponentManager) controller.PhaseControl { + return man.Glance() +} + +func (m *glanceManager) getService(oc *v1alpha1.OnecloudCluster) *corev1.Service { + return m.newSingleNodePortService(v1alpha1.GlanceComponentType, oc, constants.GlanceAPIPort) +} + +func (m *glanceManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error) { + opt := &options.Options + if err := SetOptionsDefault(opt, constants.ServiceTypeGlance); err != nil { + return nil, err + } + config := cfg.Glance + SetDBOptions(&opt.DBOptions, oc.Spec.Mysql, config.DB) + SetOptionsServiceTLS(&opt.BaseOptions) + SetServiceCommonOptions(&opt.CommonOptions, oc, config.ServiceDBCommonOptions.ServiceCommonOptions) + + opt.FilesystemStoreDatadir = constants.GlanceFileStoreDir + //opt.TorrentStoreDir = constants.GlanceTorrentStoreDir + opt.EnableTorrentService = false + // TODO: fix this + opt.AutoSyncTable = true + + return m.newServiceConfigMap(v1alpha1.GlanceComponentType, oc, opt), nil +} + +func (m *glanceManager) getPVC(oc *v1alpha1.OnecloudCluster) (*corev1.PersistentVolumeClaim, error) { + cfg := oc.Spec.Glance + return m.ComponentManager.newPVC(v1alpha1.GlanceComponentType, oc, cfg) +} + +func (m *glanceManager) getDeployment(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error) { + deploy, err := m.newCloudServiceSinglePortDeployment(v1alpha1.GlanceComponentType, oc, oc.Spec.Glance.DeploymentSpec, constants.GlanceAPIPort, true) + if err != nil { + return nil, err + } + podTemplate := &deploy.Spec.Template.Spec + podVols := podTemplate.Volumes + podVols = append(podVols, corev1.Volume{ + Name: "data", + VolumeSource: corev1.VolumeSource{ + PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ + ClaimName: controller.NewClusterComponentName(oc.GetName(), v1alpha1.GlanceComponentType), + ReadOnly: false, + }, + }, + }) + volMounts := podTemplate.Containers[0].VolumeMounts + volMounts = append(volMounts, corev1.VolumeMount{ + Name: "data", + MountPath: constants.GlanceDataStore, + }) + podTemplate.Containers[0].VolumeMounts = volMounts + podTemplate.Volumes = podVols + return deploy, nil +} + +func (m *glanceManager) getDeploymentStatus(oc *v1alpha1.OnecloudCluster) *v1alpha1.DeploymentStatus { + return &oc.Status.Glance.DeploymentStatus +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/influxdb.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/influxdb.go new file mode 100644 index 00000000..4ab13dfe --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/influxdb.go @@ -0,0 +1,146 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + "path" + + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/manager" +) + +const ( + InfluxDBConfigTemplate = ` +[meta] + # Where the metadata/raft database is stored + dir = "/var/lib/influxdb/meta" + + # Automatically create a default retention policy when creating a database. + retention-autocreate = true + + # If log messages are printed for the meta service + # logging-enabled = true + # default-retention-policy-name = "default" + default-retention-policy-name = "30day_only" + +[data] + # The directory where the TSM storage engine stores TSM files. + dir = "/var/lib/influxdb/data" + + # The directory where the TSM storage engine stores WAL files. + wal-dir = "/var/lib/influxdb/wal" + +[http] + https-enabled = true + https-certificate = "{{.CertPath}}" + https-private-key = "{{.KeyPath}}" + +[subscriber] + insecure-skip-verify = true +` +) + +type InfluxdbConfig struct { + CertPath string + KeyPath string +} + +func (c InfluxdbConfig) GetContent() (string, error) { + return CompileTemplateFromMap(InfluxDBConfigTemplate, c) +} + +type influxdbManager struct { + *ComponentManager +} + +func newInfluxdbManager(man *ComponentManager) manager.Manager { + return &influxdbManager{man} +} + +func (m *influxdbManager) Sync(oc *v1alpha1.OnecloudCluster) error { + return syncComponent(m, oc) +} + +func (m *influxdbManager) getPhaseControl(man controller.ComponentManager) controller.PhaseControl { + return controller.NewRegisterEndpointComponent( + man, v1alpha1.InfluxdbComponentType, + constants.ServiceNameInfluxdb, constants.ServiceTypeInfluxdb, + constants.InfluxdbPort, "") +} + +func (m *influxdbManager) getService(oc *v1alpha1.OnecloudCluster) *corev1.Service { + return m.newSingleNodePortService(v1alpha1.InfluxdbComponentType, oc, constants.InfluxdbPort) +} + +func (m *influxdbManager) getPVC(oc *v1alpha1.OnecloudCluster) (*corev1.PersistentVolumeClaim, error) { + cfg := oc.Spec.Influxdb + return m.ComponentManager.newPVC(v1alpha1.InfluxdbComponentType, oc, cfg) +} + +func (m *influxdbManager) getConfigMap(oc *v1alpha1.OnecloudCluster, clusterCfg *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error) { + config := InfluxdbConfig{ + CertPath: path.Join(constants.CertDir, constants.ServiceCertName), + KeyPath: path.Join(constants.CertDir, constants.ServiceKeyName), + } + content, err := config.GetContent() + if err != nil { + return nil, err + } + return m.newConfigMap(v1alpha1.InfluxdbComponentType, oc, content), nil +} + +func (m *influxdbManager) getDeployment(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error) { + configMap := controller.ComponentConfigMapName(oc, v1alpha1.InfluxdbComponentType) + containersF := func(volMounts []corev1.VolumeMount) []corev1.Container { + volMounts = append(volMounts, corev1.VolumeMount{ + Name: "data", + MountPath: constants.InfluxdbDataStore, + }) + return []corev1.Container{ + { + Name: v1alpha1.InfluxdbComponentType.String(), + Image: oc.Spec.Influxdb.Image, + Command: []string{"influxd", "-config", "/etc/yunion/influxdb.conf"}, + VolumeMounts: volMounts, + }, + } + } + deploy, err := m.newDefaultDeploymentNoInit(v1alpha1.InfluxdbComponentType, oc, + NewVolumeHelper(oc, configMap, v1alpha1.InfluxdbComponentType), + oc.Spec.Influxdb.DeploymentSpec, containersF) + if err != nil { + return nil, err + } + pod := &deploy.Spec.Template.Spec + pod.Volumes = append(pod.Volumes, corev1.Volume{ + Name: "data", + VolumeSource: corev1.VolumeSource{ + PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ + ClaimName: controller.NewClusterComponentName(oc.GetName(), v1alpha1.InfluxdbComponentType), + ReadOnly: false, + }, + }, + }) + return deploy, nil +} + +func (m *influxdbManager) getDeploymentStatus(oc *v1alpha1.OnecloudCluster) *v1alpha1.DeploymentStatus { + return &oc.Status.Influxdb +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/keystone.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/keystone.go new file mode 100644 index 00000000..0a8876ae --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/keystone.go @@ -0,0 +1,136 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "yunion.io/x/onecloud/pkg/keystone/options" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/manager" +) + +type keystoneManager struct { + *ComponentManager +} + +// newKeystoneComponentManager return *keystoneManager +func newKeystoneComponentManager(baseMan *ComponentManager) manager.Manager { + return &keystoneManager{ + ComponentManager: baseMan, + } +} + +func (m *keystoneManager) Sync(oc *v1alpha1.OnecloudCluster) error { + return syncComponent(m, oc) +} + +func (m *keystoneManager) getDBConfig(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.DBConfig { + return &cfg.Keystone.DB +} + +func (m *keystoneManager) getPhaseControl(man controller.ComponentManager) controller.PhaseControl { + return man.Keystone() +} + +func (m *keystoneManager) getDeploymentStatus(oc *v1alpha1.OnecloudCluster) *v1alpha1.DeploymentStatus { + return &oc.Status.Keystone.DeploymentStatus +} + +func (m *keystoneManager) getService(oc *v1alpha1.OnecloudCluster) *corev1.Service { + ports := []corev1.ServicePort{ + NewServiceNodePort("public", constants.KeystonePublicPort), + NewServiceNodePort("admin", constants.KeystoneAdminPort), + } + + return m.newNodePortService(v1alpha1.KeystoneComponentType, oc, ports) +} + +func (m *keystoneManager) getConfigMap(oc *v1alpha1.OnecloudCluster, clusterCfg *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error) { + opt := &options.Options + if err := SetOptionsDefault(opt, constants.ServiceTypeIdentity); err != nil { + return nil, err + } + config := clusterCfg.Keystone + SetDBOptions(&opt.DBOptions, oc.Spec.Mysql, config.DB) + SetOptionsServiceTLS(&opt.BaseOptions) + SetServiceBaseOptions(&opt.BaseOptions, oc.Spec.Region, config.ServiceBaseConfig) + + opt.BootstrapAdminUserPassword = oc.Spec.Keystone.BootstrapPassword + opt.AdminPort = constants.KeystoneAdminPort + + return m.newServiceConfigMap(v1alpha1.KeystoneComponentType, oc, opt), nil +} + +func (m *keystoneManager) getDeployment(oc *v1alpha1.OnecloudCluster, _ *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error) { + ksConfigMap := controller.ComponentConfigMapName(oc, v1alpha1.KeystoneComponentType) + + initContainersF := func(volMounts []corev1.VolumeMount) []corev1.Container { + return []corev1.Container{ + { + Name: "init", + Image: oc.Spec.Keystone.Image, + Command: []string{ + "/opt/yunion/bin/keystone", + "--config", + "/etc/yunion/keystone.conf", + "--auto-sync-table", + "--reset-admin-user-password", + "--exit-after-db-init", + }, + VolumeMounts: volMounts, + }, + } + } + + containersF := func(volMounts []corev1.VolumeMount) []corev1.Container { + return []corev1.Container{ + { + Name: v1alpha1.KeystoneComponentType.String(), + Image: oc.Spec.Keystone.Image, + Command: []string{ + "/opt/yunion/bin/keystone", + "--config", + "/etc/yunion/keystone.conf", + }, + ImagePullPolicy: oc.Spec.Keystone.ImagePullPolicy, + Ports: []corev1.ContainerPort{ + { + Name: "public", + ContainerPort: int32(5000), + Protocol: corev1.ProtocolTCP, + }, + { + Name: "admin", + ContainerPort: int32(35357), + Protocol: corev1.ProtocolTCP, + }, + }, + VolumeMounts: volMounts, + }, + } + } + + return m.newDefaultDeployment( + v1alpha1.KeystoneComponentType, oc, + NewVolumeHelper(oc, ksConfigMap, v1alpha1.KeystoneComponentType), + oc.Spec.Keystone.DeploymentSpec, + initContainersF, + containersF, + ) +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/kubeserver.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/kubeserver.go new file mode 100644 index 00000000..559a8fdc --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/kubeserver.go @@ -0,0 +1,104 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "path" + + "yunion.io/x/onecloud/pkg/cloudcommon/options" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/manager" +) + +type kubeManager struct { + *ComponentManager +} + +func newKubeManager(man *ComponentManager) manager.Manager { + return &kubeManager{man} +} + +type kubeOptions struct { + options.CommonOptions + options.DBOptions + + HttpsPort int + TlsCertFile string + TlsPrivateKeyFile string +} + +func (m *kubeManager) Sync(oc *v1alpha1.OnecloudCluster) error { + return syncComponent(m, oc) +} + +func (m *kubeManager) getDBConfig(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.DBConfig { + return &cfg.KubeServer.DB +} + +func (m *kubeManager) getCloudUser(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.CloudUser { + return &cfg.KubeServer.CloudUser +} + +func (m *kubeManager) getPhaseControl(man controller.ComponentManager) controller.PhaseControl { + return controller.NewRegisterEndpointComponent(man, v1alpha1.KubeServerComponentType, + constants.ServiceNameKubeServer, constants.ServiceTypeKubeServer, + constants.KubeServerPort, "api") +} + +func (m *kubeManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error) { + opt := &kubeOptions{} + if err := SetOptionsDefault(opt, constants.ServiceTypeKubeServer); err != nil { + return nil, err + } + config := cfg.KubeServer + SetDBOptions(&opt.DBOptions, oc.Spec.Mysql, config.DB) + SetOptionsServiceTLS(&opt.BaseOptions) + SetServiceCommonOptions(&opt.CommonOptions, oc, config.ServiceCommonOptions) + opt.AutoSyncTable = true + opt.TlsCertFile = path.Join(constants.CertDir, constants.ServiceCertName) + opt.TlsPrivateKeyFile = path.Join(constants.CertDir, constants.ServiceKeyName) + opt.HttpsPort = constants.KubeServerPort + return m.newServiceConfigMap(v1alpha1.KubeServerComponentType, oc, opt), nil +} + +func (m *kubeManager) getService(oc *v1alpha1.OnecloudCluster) *corev1.Service { + return m.newSingleNodePortService(v1alpha1.KubeServerComponentType, oc, constants.KubeServerPort) +} + +func (m *kubeManager) getDeployment(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error) { + cf := func(volMounts []corev1.VolumeMount) []corev1.Container { + return []corev1.Container{ + { + Name: "server", + Image: oc.Spec.KubeServer.Image, + Command: []string{"/opt/yunion/bin/kube-server", "--config", "/etc/yunion/kubeserver.conf"}, + VolumeMounts: volMounts, + }, + } + } + return m.newDefaultDeploymentNoInit( + v1alpha1.KubeServerComponentType, oc, + NewVolumeHelper(oc, controller.ComponentConfigMapName(oc, v1alpha1.KubeServerComponentType), v1alpha1.KubeServerComponentType), + oc.Spec.KubeServer, cf) +} + +func (m *kubeManager) getDeploymentStatus(oc *v1alpha1.OnecloudCluster) *v1alpha1.DeploymentStatus { + return &oc.Status.KubeServer +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/logger.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/logger.go new file mode 100644 index 00000000..bb5849e1 --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/logger.go @@ -0,0 +1,78 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + "yunion.io/x/onecloud/pkg/logger/options" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/manager" +) + +type loggerManager struct { + *ComponentManager +} + +func newLoggerManager(man *ComponentManager) manager.Manager { + return &loggerManager{man} +} + +func (m *loggerManager) Sync(oc *v1alpha1.OnecloudCluster) error { + return syncComponent(m, oc) +} + +func (m *loggerManager) getDBConfig(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.DBConfig { + return &cfg.Logger.DB +} + +func (m *loggerManager) getCloudUser(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.CloudUser { + return &cfg.Logger.CloudUser +} + +func (m *loggerManager) getPhaseControl(man controller.ComponentManager) controller.PhaseControl { + return controller.NewRegisterEndpointComponent(man, v1alpha1.LoggerComponentType, + constants.ServiceNameLogger, constants.ServiceTypeLogger, + constants.LoggerPort, "") +} + +func (m *loggerManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error) { + opt := &options.Options + if err := SetOptionsDefault(opt, constants.ServiceTypeLogger); err != nil { + return nil, err + } + config := cfg.Logger + SetDBOptions(&opt.DBOptions, oc.Spec.Mysql, config.DB) + SetOptionsServiceTLS(&opt.BaseOptions) + SetServiceCommonOptions(&opt.CommonOptions, oc, config.ServiceCommonOptions) + + return m.newServiceConfigMap(v1alpha1.LoggerComponentType, oc, opt), nil +} + +func (m *loggerManager) getService(oc *v1alpha1.OnecloudCluster) *corev1.Service { + return m.newSingleNodePortService(v1alpha1.LoggerComponentType, oc, constants.LoggerPort) +} + +func (m *loggerManager) getDeployment(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error) { + return m.newCloudServiceSinglePortDeployment(v1alpha1.LoggerComponentType, oc, oc.Spec.Logger, constants.LoggerPort, true) +} + +func (m *loggerManager) getDeploymentStatus(oc *v1alpha1.OnecloudCluster) *v1alpha1.DeploymentStatus { + return &oc.Status.Logger +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/region.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/region.go new file mode 100644 index 00000000..4cc4a022 --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/region.go @@ -0,0 +1,83 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + "yunion.io/x/onecloud/pkg/compute/options" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/manager" +) + +type regionManager struct { + *ComponentManager +} + +// newRegionManager return *regionManager +func newRegionManager(man *ComponentManager) manager.Manager { + return ®ionManager{man} +} + +func (m *regionManager) Sync(oc *v1alpha1.OnecloudCluster) error { + return syncComponent(m, oc) +} + +func (m *regionManager) getDBConfig(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.DBConfig { + return &cfg.RegionServer.DB +} + +func (m *regionManager) getCloudUser(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.CloudUser { + return &cfg.RegionServer.CloudUser +} + +func (m *regionManager) getPhaseControl(man controller.ComponentManager) controller.PhaseControl { + return man.Region() +} + +func (m *regionManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error) { + opt := &options.Options + if err := SetOptionsDefault(opt, constants.ServiceTypeComputeV2); err != nil { + return nil, err + } + config := cfg.RegionServer + SetDBOptions(&opt.DBOptions, oc.Spec.Mysql, config.DB) + SetOptionsServiceTLS(&opt.BaseOptions) + SetServiceCommonOptions(&opt.CommonOptions, oc, config.ServiceDBCommonOptions.ServiceCommonOptions) + // TODO: fix this, currently init container can't sync table + opt.AutoSyncTable = true + + opt.PortV2 = constants.RegionPort + return m.newServiceConfigMap(v1alpha1.RegionComponentType, oc, opt), nil +} + +func (m *regionManager) getService(oc *v1alpha1.OnecloudCluster) *corev1.Service { + ports := []corev1.ServicePort{ + NewServiceNodePort("api", constants.RegionPort), + } + return m.newNodePortService(v1alpha1.RegionComponentType, oc, ports) +} + +func (m *regionManager) getDeployment(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error) { + return m.newCloudServiceSinglePortDeployment(v1alpha1.RegionComponentType, oc, oc.Spec.RegionServer.DeploymentSpec, constants.RegionPort, true) +} + +func (m *regionManager) getDeploymentStatus(oc *v1alpha1.OnecloudCluster) *v1alpha1.DeploymentStatus { + return &oc.Status.RegionServer.DeploymentStatus +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/regiondns.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/regiondns.go new file mode 100644 index 00000000..df369dde --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/regiondns.go @@ -0,0 +1,37 @@ +// Copyright 2019 Yunion +// +// 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 component + +const ( + RegionDNSConfigTemplate = ` +.:53 { + cache 30 + yunion . { + sql_connection mysql+pymysql://{{.DBUser}}:{{.DBPassword}}@{{.DBHost}}:{{.DBPort}}/{{.DBName}}?charset=utf8 + dns_domain {{.Domain}} + region {{.Region}} + auth_url {{.AuthURL}} + admin_project system + admin_user {{.AdminUser}} + admin_password {{.AdminPassword}} + fallthrough . + } + proxy . {{.ProxyServer}}:53 + log { + class error + } +} +` +) diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/scheduler.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/scheduler.go new file mode 100644 index 00000000..71240eb0 --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/scheduler.go @@ -0,0 +1,67 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + "yunion.io/x/onecloud/pkg/scheduler/options" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/manager" +) + +type schedulerManager struct { + *ComponentManager +} + +func newSchedulerManager(man *ComponentManager) manager.Manager { + return &schedulerManager{man} +} + +func (m *schedulerManager) Sync(oc *v1alpha1.OnecloudCluster) error { + return syncComponent(m, oc) +} + +func (m *schedulerManager) getPhaseControl(man controller.ComponentManager) controller.PhaseControl { + return controller.NewRegisterEndpointComponent(man, v1alpha1.SchedulerComponentType, + constants.ServiceNameScheduler, constants.ServiceTypeScheduler, constants.SchedulerPort, "") +} + +func (m *schedulerManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error) { + opt := options.GetOptions() + if err := SetOptionsDefault(opt, constants.ServiceTypeScheduler); err != nil { + return nil, err + } + // scheduler use region config directly + config := cfg.RegionServer + SetDBOptions(&opt.DBOptions, oc.Spec.Mysql, config.DB) + SetOptionsServiceTLS(&opt.BaseOptions) + SetServiceCommonOptions(&opt.CommonOptions, oc, config.ServiceDBCommonOptions.ServiceCommonOptions) + + opt.SchedulerPort = constants.SchedulerPort + return m.newServiceConfigMap(v1alpha1.SchedulerComponentType, oc, opt), nil +} + +func (m *schedulerManager) getService(oc *v1alpha1.OnecloudCluster) *corev1.Service { + return m.newSingleNodePortService(v1alpha1.SchedulerComponentType, oc, constants.SchedulerPort) +} + +func (m *schedulerManager) getDeployment(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error) { + return m.newCloudServiceSinglePortDeployment(v1alpha1.SchedulerComponentType, oc, oc.Spec.Scheduler, constants.SchedulerPort, false) +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/sync.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/sync.go new file mode 100644 index 00000000..119a096d --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/sync.go @@ -0,0 +1,115 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + "github.com/pkg/errors" + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + extensions "k8s.io/api/extensions/v1beta1" + + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" +) + +type syncManager interface { + getComponentManager() *ComponentManager + getDBConfig(*v1alpha1.OnecloudClusterConfig) *v1alpha1.DBConfig + getCloudUser(*v1alpha1.OnecloudClusterConfig) *v1alpha1.CloudUser + getPhaseControl(controller.ComponentManager) controller.PhaseControl + getDeploymentStatus(*v1alpha1.OnecloudCluster) *v1alpha1.DeploymentStatus +} + +type serviceFactory interface { + getService(*v1alpha1.OnecloudCluster) *corev1.Service +} + +type ingressFactory interface { + getIngress(*v1alpha1.OnecloudCluster) *extensions.Ingress +} + +type configMapFactory interface { + getConfigMap(*v1alpha1.OnecloudCluster, *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error) +} + +type pvcFactory interface { + getPVC(*v1alpha1.OnecloudCluster) (*corev1.PersistentVolumeClaim, error) +} + +type deploymentFactory interface { + getDeployment(*v1alpha1.OnecloudCluster, *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error) +} + +type cloudComponentFactory interface { + syncManager + serviceFactory + ingressFactory + configMapFactory + deploymentFactory + pvcFactory +} + +func syncComponent(factory cloudComponentFactory, oc *v1alpha1.OnecloudCluster) error { + m := factory.getComponentManager() + if err := m.syncService(oc, factory.getService); err != nil { + return err + } + if err := m.syncIngress(oc, factory.getIngress); err != nil { + return err + } + if err := m.syncConfigMap(oc, factory.getDBConfig, factory.getCloudUser, factory.getConfigMap); err != nil { + return err + } + if err := m.syncPVC(oc, factory.getPVC); err != nil { + return err + } + return m.syncDeployment(oc, factory.getDeployment, newPostSyncComponent(factory)) +} + +func newPostSyncComponent(f cloudComponentFactory) func(*v1alpha1.OnecloudCluster, *apps.Deployment) error { + return func(oc *v1alpha1.OnecloudCluster, deploy *apps.Deployment) error { + m := f.getComponentManager() + + deployStatus := f.getDeploymentStatus(oc) + if deployStatus != nil { + deployStatus.Deployment = &deploy.Status + upgrading, err := m.deploymentIsUpgrading(deploy, oc) + if err != nil { + return err + } + if upgrading { + deployStatus.Phase = v1alpha1.UpgradePhase + } else { + deployStatus.Phase = v1alpha1.NormalPhase + } + } + + if _, err := m.onecloudControl.GetSession(oc); err != nil { + return errors.Wrapf(err, "get cluster %s session", oc.GetName()) + } + + phase := f.getPhaseControl(m.onecloudControl.Components(oc)) + if phase == nil { + return nil + } + if err := phase.Setup(); err != nil { + return err + } + if err := phase.SystemInit(); err != nil { + return err + } + return nil + } +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/utils.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/utils.go new file mode 100644 index 00000000..1f0f118a --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/utils.go @@ -0,0 +1,419 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + "bytes" + "encoding/json" + "fmt" + "path" + "reflect" + "text/template" + + "github.com/pkg/errors" + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + extensions "k8s.io/api/extensions/v1beta1" + apiequality "k8s.io/apimachinery/pkg/api/equality" + "k8s.io/apimachinery/pkg/util/intstr" + clientset "k8s.io/client-go/kubernetes" + "k8s.io/klog" + "k8s.io/kubernetes/cmd/kubeadm/app/util/apiclient" + + "yunion.io/x/onecloud/pkg/cloudcommon/options" + "yunion.io/x/onecloud/pkg/mcclient" + "yunion.io/x/pkg/util/reflectutils" + "yunion.io/x/structarg" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/util/mysql" + "yunion.io/x/onecloud-operator/pkg/util/onecloud" +) + +const ( + // LastAppliedConfigAnnotation is annotation key of last applied configuration + LastAppliedConfigAnnotation = "onecloud.yunion.io/last-applied-configuration" + // ImagePullBackOff is the pod state of image pull failed + ImagePullBackOff = "ImagePullBackOff" + // ErrImagePull is the pod state of image pull failed + ErrImagePull = "ErrImagePull" +) + +// templateEqual compares the new podTemplateSpec's spec with old podTemplateSpec's last applied config +func templateEqual(new corev1.PodTemplateSpec, old corev1.PodTemplateSpec) bool { + oldConfig := corev1.PodSpec{} + if lastAppliedConfig, ok := old.Annotations[LastAppliedConfigAnnotation]; ok { + err := json.Unmarshal([]byte(lastAppliedConfig), &oldConfig) + if err != nil { + klog.Errorf("unmarshal PodTemplate: [%s/%s]'s applied config failed,error: %v", old.GetNamespace(), old.GetName(), err) + return false + } + return apiequality.Semantic.DeepEqual(oldConfig, new.Spec) + } + return false +} + +// SetServiceLastAppliedConfigAnnotation set last applied config info to Service's annotation +func SetServiceLastAppliedConfigAnnotation(svc *corev1.Service) error { + svcApply, err := encode(svc.Spec) + if err != nil { + return err + } + if svc.Annotations == nil { + svc.Annotations = map[string]string{} + } + svc.Annotations[LastAppliedConfigAnnotation] = svcApply + return nil +} + +func SetIngressLastAppliedConfigAnnotation(ing *extensions.Ingress) error { + ingApply, err := encode(ing.Spec) + if err != nil { + return err + } + if ing.Annotations == nil { + ing.Annotations = map[string]string{} + } + ing.Annotations[LastAppliedConfigAnnotation] = ingApply + return nil +} + +func SetConfigMapLastAppliedConfigAnnotation(cfg *corev1.ConfigMap) error { + cfgApply, err := encode(cfg.Data) + if err != nil { + return err + } + if cfg.Annotations == nil { + cfg.Annotations = map[string]string{} + } + cfg.Annotations[LastAppliedConfigAnnotation] = cfgApply + return nil +} + +func SetDeploymentLastAppliedConfigAnnotation(deploy *apps.Deployment) error { + deployApply, err := encode(deploy.Spec) + if err != nil { + return err + } + if deploy.Annotations == nil { + deploy.Annotations = map[string]string{} + } + deploy.Annotations[LastAppliedConfigAnnotation] = deployApply + + templateApply, err := encode(deploy.Spec.Template.Spec) + if err != nil { + return err + } + if deploy.Spec.Template.Annotations == nil { + deploy.Spec.Template.Annotations = map[string]string{} + } + deploy.Spec.Template.Annotations[LastAppliedConfigAnnotation] = templateApply + return nil +} + +// serviceEqual compares the new Service's spec with old Service's last applied config +func serviceEqual(new, old *corev1.Service) (bool, error) { + oldSpec := corev1.ServiceSpec{} + if lastAppliedConfig, ok := old.Annotations[LastAppliedConfigAnnotation]; ok { + err := json.Unmarshal([]byte(lastAppliedConfig), &oldSpec) + if err != nil { + klog.Errorf("unmarshal ServiceSpec: [%s/%s]'s applied config failed,error: %v", old.GetNamespace(), old.GetName(), err) + return false, err + } + return apiequality.Semantic.DeepEqual(oldSpec, new.Spec), nil + } + return false, nil +} + +func ingressEqual(new, old *extensions.Ingress) (bool, error) { + oldSpec := extensions.IngressSpec{} + if lastAppliedConfig, ok := old.Annotations[LastAppliedConfigAnnotation]; ok { + err := json.Unmarshal([]byte(lastAppliedConfig), &oldSpec) + if err != nil { + return false, err + } + return apiequality.Semantic.DeepEqual(oldSpec, new.Spec), nil + } + return false, nil +} + +func configMapEqual(new, old *corev1.ConfigMap) (bool, error) { + oldData := map[string]string{} + if lastAppliedConfig, ok := old.Annotations[LastAppliedConfigAnnotation]; ok { + err := json.Unmarshal([]byte(lastAppliedConfig), &oldData) + if err != nil { + return false, err + } + return reflect.DeepEqual(oldData, new.Data), nil + } + return false, nil +} + +func deploymentEqual(new apps.Deployment, old apps.Deployment) bool { + oldConfig := apps.DeploymentSpec{} + if lastAppliedConfig, ok := old.Annotations[LastAppliedConfigAnnotation]; ok { + err := json.Unmarshal([]byte(lastAppliedConfig), &oldConfig) + if err != nil { + klog.Errorf("unmarshal Deployment: [%s/%s]'s applied config failed, error: %v", old.GetNamespace(), old.GetName(), err) + return false + } + return apiequality.Semantic.DeepEqual(oldConfig.Replicas, new.Spec.Replicas) && + apiequality.Semantic.DeepEqual(oldConfig.Template, new.Spec.Template) && + apiequality.Semantic.DeepEqual(oldConfig.Strategy, new.Spec.Strategy) + } + return false +} + +func encode(obj interface{}) (string, error) { + b, err := json.Marshal(obj) + if err != nil { + return "", err + } + return string(b), nil +} + +func deploymentIsUpgrading(deploy *apps.Deployment) bool { + if deploy.Status.ObservedGeneration == 0 { + return false + } + if deploy.Generation > deploy.Status.ObservedGeneration && *deploy.Spec.Replicas == deploy.Status.Replicas { + return true + } + return false +} + +// CombineAnnotations merges two annotations maps +func CombineAnnotations(a, b map[string]string) map[string]string { + if a == nil { + a = make(map[string]string) + } + for k, v := range b { + a[k] = v + } + return a +} + +func CreateOrUpdateConfigMap(client clientset.Interface, cm *corev1.ConfigMap) error { + return apiclient.CreateOrUpdateConfigMap(client, cm) +} + +func GetDBConnectionByCluster(oc *v1alpha1.OnecloudCluster) (*mysql.Connection, error) { + return mysql.NewConnection(&oc.Spec.Mysql) +} + +func EnsureClusterDBUser(oc *v1alpha1.OnecloudCluster, dbConfig v1alpha1.DBConfig) error { + dbName := dbConfig.Database + username := dbConfig.Username + password := dbConfig.Password + conn, err := GetDBConnectionByCluster(oc) + if err != nil { + return err + } + defer conn.Close() + if err := EnsureDBUser(conn, dbName, username, password); err != nil { + return err + } + return nil +} + +func EnsureDBUser(conn *mysql.Connection, dbName string, username string, password string) error { + dbExists, err := conn.IsDatabaseExists(dbName) + if err != nil { + return errors.Wrap(err, "check db exists") + } + if !dbExists { + if err := conn.CreateDatabase(dbName); err != nil { + return errors.Wrapf(err, "create database %q", dbName) + } + } + if err := conn.CreateUser(username, password, dbName); err != nil { + return errors.Wrapf(err, "create user %q for database %q", username, dbName) + } + return nil +} + +func LoginByServiceAccount(s *mcclient.ClientSession, account v1alpha1.CloudUser) (mcclient.TokenCredential, error) { + return s.GetClient().AuthenticateWithSource(account.Username, account.Password, constants.DefaultDomain, constants.SysAdminProject, "", "operator") +} + +func EnsureServiceAccount(s *mcclient.ClientSession, account v1alpha1.CloudUser) error { + username := account.Username + password := account.Password + obj, exists, err := onecloud.IsUserExists(s, username) + if err != nil { + return err + } + if exists { + // password not change + if _, err := LoginByServiceAccount(s, account); err == nil { + return nil + } + id, _ := obj.GetString("id") + if _, err := onecloud.ChangeUserPassword(s, id, password); err != nil { + return errors.Wrapf(err, "user %s already exists, update password", username) + } + return nil + } + obj, err = onecloud.CreateUser(s, username, password) + if err != nil { + return errors.Wrapf(err, "create user %s", username) + } + userId, _ := obj.GetString("id") + return onecloud.ProjectAddUser(s, constants.SysAdminProject, userId, constants.RoleAdmin) +} + +func SetOptionsDefault(opt interface{}, serviceType string) error { + parser, err := structarg.NewArgumentParser(opt, serviceType, "", "") + if err != nil { + return err + } + parser.SetDefault() + + var optionsRef *options.BaseOptions + if err := reflectutils.FindAnonymouStructPointer(opt, &optionsRef); err != nil { + return err + } + if len(optionsRef.ApplicationID) == 0 { + optionsRef.ApplicationID = serviceType + } + return nil +} + +type VolumeHelper struct { + cluster *v1alpha1.OnecloudCluster + optionCfgMap string + component v1alpha1.ComponentType + volumes []corev1.Volume + volumeMounts []corev1.VolumeMount +} + +func NewVolumeHelper(oc *v1alpha1.OnecloudCluster, optCfgMap string, component v1alpha1.ComponentType) *VolumeHelper { + h := &VolumeHelper{ + cluster: oc, + optionCfgMap: optCfgMap, + component: component, + volumes: make([]corev1.Volume, 0), + volumeMounts: make([]corev1.VolumeMount, 0), + } + h.volumes = []corev1.Volume{ + { + Name: constants.VolumeCertsName, + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + SecretName: controller.ClustercertSecretName(h.cluster), + Items: []corev1.KeyToPath{ + {Key: constants.CACertName, Path: constants.CACertName}, + {Key: constants.ServiceCertName, Path: constants.ServiceCertName}, + {Key: constants.ServiceKeyName, Path: constants.ServiceKeyName}, + }, + }, + }, + }, + } + h.volumeMounts = append(h.volumeMounts, corev1.VolumeMount{Name: constants.VolumeCertsName, ReadOnly: true, MountPath: constants.CertDir}) + + if h.optionCfgMap != "" { + cfgVol := corev1.Volume{ + Name: constants.VolumeConfigName, + VolumeSource: corev1.VolumeSource{ + ConfigMap: &corev1.ConfigMapVolumeSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: h.optionCfgMap, + }, + Items: []corev1.KeyToPath{ + {Key: constants.VolumeConfigName, Path: fmt.Sprintf("%s.conf", h.component)}, + }, + }, + }, + } + h.volumes = append(h.volumes, cfgVol) + h.volumeMounts = append(h.volumeMounts, corev1.VolumeMount{Name: constants.VolumeConfigName, ReadOnly: true, MountPath: constants.ConfigDir}) + } + return h +} + +func (h *VolumeHelper) GetVolumes() []corev1.Volume { + return h.volumes +} + +func (h *VolumeHelper) GetVolumeMounts() []corev1.VolumeMount { + return h.volumeMounts +} + +func NewServiceNodePort(name string, port int32) corev1.ServicePort { + return corev1.ServicePort{ + Name: name, + Protocol: corev1.ProtocolTCP, + Port: port, + TargetPort: intstr.FromInt(int(port)), + NodePort: port, + } +} + +func SetOptionsServiceTLS(config *options.BaseOptions) { + enableConfigTLS(config, constants.CertDir, constants.CACertName, constants.ServiceCertName, constants.ServiceKeyName) +} + +func enableConfigTLS(config *options.BaseOptions, certDir string, ca string, cert string, key string) { + config.EnableSsl = true + config.SslCaCerts = path.Join(certDir, ca) + config.SslCertfile = path.Join(certDir, cert) + config.SslKeyfile = path.Join(certDir, key) +} + +func SetServiceBaseOptions(opt *options.BaseOptions, region string, input v1alpha1.ServiceBaseConfig) { + opt.Region = region + opt.Port = input.Port +} + +func SetServiceCommonOptions(opt *options.CommonOptions, oc *v1alpha1.OnecloudCluster, input v1alpha1.ServiceCommonOptions) { + SetServiceBaseOptions(&opt.BaseOptions, oc.Spec.Region, input.ServiceBaseConfig) + opt.AuthURL = controller.GetAuthURL(oc) + opt.AdminUser = input.CloudUser.Username + opt.AdminDomain = constants.DefaultDomain + opt.AdminPassword = input.CloudUser.Password + opt.AdminProject = constants.SysAdminProject +} + +func SetDBOptions(opt *options.DBOptions, mysql v1alpha1.Mysql, input v1alpha1.DBConfig) { + opt.SqlConnection = fmt.Sprintf("mysql+pymysql://%s:%s@%s:%d/%s?charset=utf8", input.Username, input.Password, mysql.Host, mysql.Port, input.Database) +} + +func CompileTemplateFromMap(tmplt string, configMap interface{}) (string, error) { + out := new(bytes.Buffer) + t := template.Must(template.New("compiled_template").Parse(tmplt)) + if err := t.Execute(out, configMap); err != nil { + return "", err + } + return out.String(), nil +} + +func GetEdition(spec *v1alpha1.DeploymentSpec) string { + edition := constants.OnecloudCommunityEdition + if spec.Annotations == nil { + return edition + } + curEdition := spec.Annotations[constants.OnecloudEditionAnnotationKey] + if curEdition == constants.OnecloudEnterpriseEdition { + return curEdition + } + return edition +} + +func IsEnterpriseEdition(spec *v1alpha1.DeploymentSpec) bool { + return GetEdition(spec) == constants.OnecloudEnterpriseEdition +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/web.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/web.go new file mode 100644 index 00000000..5d85d577 --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/web.go @@ -0,0 +1,334 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + "fmt" + + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + extensions "k8s.io/api/extensions/v1beta1" + "k8s.io/apimachinery/pkg/util/intstr" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/manager" +) + +const ( + WebNginxConfigTemplate = ` +server { + location / { + root /usr/share/nginx/html/web; + index index.html; + add_header Cache-Control no-cache; + expires 1s; + if (!-e $request_filename) { + rewrite ^/(.*) /index.html last; + break; + } + } + + location /static/ { + # Some basic cache-control for static files to be sent to the browser + root /usr/share/nginx/html/web; + expires max; + add_header Pragma public; + add_header Cache-Control "public, must-revalidate, proxy-revalidate"; + } + + location /auth { + alias /usr/share/nginx/html/login; + index index.html; + add_header Cache-Control no-cache; + expires 1s; + if (!-e $request_filename) { + rewrite ^/(.*) /auth/index.html last; + break; + } + } + + # location ~* ^static-auth/.*(?:js|css|png|jpg|jpeg|gif|ico|swf|woff|tff|ttf|json|txt)$ { + location /static-auth/ { + root /usr/share/nginx/html/login; + expires max; + add_header Pragma public; + add_header Cache-Control "public, must-revalidate, proxy-revalidate"; + } + + location /servicetree { + alias /usr/share/nginx/html/servicetree; + index index.html; + add_header Cache-Control no-cache; + expires 1s; + if (!-e $request_filename) { + rewrite ^/(.*) /servicetree/index.html last; + break; + } + } + + location /static-servicetree/ { + root /usr/share/nginx/html/servicetree; + expires max; + add_header Pragma public; + add_header Cache-Control "public, must-revalidate, proxy-revalidate"; + } + + location /itsm { + alias /usr/share/nginx/html/itsm; + index index.html; + add_header Cache-Control no-cache; + expires 1s; + if (!-e $request_filename) { + rewrite ^/(.*) /itsm/index.html last; + break; + } + } + + location /static-itsm/ { + root /usr/share/nginx/html/itsm; + expires max; + add_header Pragma public; + add_header Cache-Control "public, must-revalidate, proxy-revalidate"; + } + + location ~* /static/images/favicon.* { + root /usr/share/nginx/html/login; + expires max; + add_header Pragma public; + add_header Cache-Control "public, must-revalidate, proxy-revalidate"; + } + + location /api { + proxy_pass {{.APIGatewayURL}}; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_buffer_size 16k; + proxy_buffers 32 16k; + proxy_busy_buffers_size 16k; + proxy_temp_file_write_size 16k; + } + + location /api/v1/imageutils/upload { + proxy_pass {{.APIGatewayURL}}; + client_max_body_size 0; + proxy_http_version 1.1; + proxy_request_buffering off; + proxy_buffering off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + } + + location /query { + proxy_pass {{.APIGatewayURL}}; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location ~ ^/(vnc|spice|wmks|sol) { + proxy_pass {{.WebconsoleURL}}; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location ~ ^/(websockify|wsproxy|connect) { + proxy_pass {{.WebconsoleURL}}; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + + proxy_read_timeout 86400; + } + + location /bi { + alias /usr/share/nginx/html/bi; + index index.html; + if (!-e $request_filename) { + rewrite ^/(.*) /bi/index.html last; + break; + } + } + + location /static-bi/ { + root /usr/share/nginx/html/bi; + expires max; + add_header Pragma public; + add_header Cache-Control "public, must-revalidate, proxy-revalidate"; + } + + location /web-console { + alias /usr/share/nginx/html/web-console; + index index.html; + if (!-e $request_filename) { + rewrite ^/(.*) /web-console/index.html last; + break; + } + } + + location /ws { + proxy_pass {{.APIGatewayWsURL}}; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + + proxy_read_timeout 86400; + } +} +` +) + +type WebNginxConfig struct { + WebconsoleURL string + APIGatewayWsURL string + APIGatewayURL string +} + +func (c WebNginxConfig) GetContent() (string, error) { + return CompileTemplateFromMap(WebNginxConfigTemplate, c) +} + +type webManager struct { + *ComponentManager +} + +func newWebManager(man *ComponentManager) manager.Manager { + return &webManager{man} +} + +func (m *webManager) Sync(oc *v1alpha1.OnecloudCluster) error { + return syncComponent(m, oc) +} + +func (m *webManager) getService(oc *v1alpha1.OnecloudCluster) *corev1.Service { + ports := []corev1.ServicePort{ + { + Name: "http", + Protocol: corev1.ProtocolTCP, + Port: 80, + TargetPort: intstr.FromInt(80), + }, + } + return m.newService(v1alpha1.WebComponentType, oc, corev1.ServiceTypeClusterIP, ports) +} + +func (m *webManager) getIngress(oc *v1alpha1.OnecloudCluster) *extensions.Ingress { + svc := m.getService(oc) + ocName := oc.GetName() + svcName := controller.NewClusterComponentName(ocName, v1alpha1.WebComponentType) + appLabel := m.getComponentLabel(oc, v1alpha1.WebComponentType) + secretName := controller.ClustercertSecretName(oc) + + ing := &extensions.Ingress{ + ObjectMeta: m.getObjectMeta(oc, svcName, appLabel), + Spec: extensions.IngressSpec{ + TLS: []extensions.IngressTLS{ + { + SecretName: secretName, + }, + }, + Rules: []extensions.IngressRule{ + { + IngressRuleValue: extensions.IngressRuleValue{ + HTTP: &extensions.HTTPIngressRuleValue{ + Paths: []extensions.HTTPIngressPath{ + { + Path: "/", + Backend: extensions.IngressBackend{ + ServiceName: svc.GetName(), + ServicePort: intstr.FromInt(80), + }, + }, + }, + }, + }, + }, + }, + }, + } + return ing +} + +func (m *webManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error) { + urlF := func(ct v1alpha1.ComponentType, port int) string { + return fmt.Sprintf("https://%s:%d", controller.NewClusterComponentName(oc.GetName(), ct), port) + } + config := WebNginxConfig{ + WebconsoleURL: urlF(v1alpha1.WebconsoleComponentType, constants.WebconsolePort), + APIGatewayWsURL: urlF(v1alpha1.APIGatewayComponentType, constants.APIWebsocketPort), + APIGatewayURL: urlF(v1alpha1.APIGatewayComponentType, constants.APIGatewayPort), + } + content, err := config.GetContent() + if err != nil { + return nil, err + } + return m.newConfigMap(v1alpha1.WebComponentType, oc, content), nil +} + +func (m *webManager) getDeployment(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error) { + cf := func(volMounts []corev1.VolumeMount) []corev1.Container { + confVol := volMounts[len(volMounts)-1] + confVol.MountPath = "/etc/nginx/conf.d" + volMounts[len(volMounts)-1] = confVol + return []corev1.Container{ + { + Name: "web", + Image: oc.Spec.Web.Image, + Ports: []corev1.ContainerPort{ + { + Name: "web", + ContainerPort: 80, + Protocol: corev1.ProtocolTCP, + }, + }, + VolumeMounts: volMounts, + }, + } + } + deploy, err := m.newDefaultDeploymentNoInit( + v1alpha1.WebComponentType, oc, + NewVolumeHelper(oc, controller.ComponentConfigMapName(oc, v1alpha1.WebComponentType), v1alpha1.WebComponentType), + oc.Spec.Web, cf) + if err != nil { + return nil, err + } + podSpec := &deploy.Spec.Template.Spec + config := podSpec.Volumes[len(podSpec.Volumes)-1] + config.ConfigMap.Items[0].Path = "default.conf" + podSpec.Volumes[len(podSpec.Volumes)-1] = config + return deploy, nil +} + +func (m *webManager) getDeploymentStatus(oc *v1alpha1.OnecloudCluster) *v1alpha1.DeploymentStatus { + return &oc.Status.Web +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/webconsole.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/webconsole.go new file mode 100644 index 00000000..821a369c --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/webconsole.go @@ -0,0 +1,81 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + "fmt" + + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + "yunion.io/x/onecloud/pkg/webconsole/options" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/manager" +) + +type webconsoleManager struct { + *ComponentManager +} + +func newWebconsoleManager(man *ComponentManager) manager.Manager { + return &webconsoleManager{man} +} + +func (m *webconsoleManager) Sync(oc *v1alpha1.OnecloudCluster) error { + return syncComponent(m, oc) +} + +func (m *webconsoleManager) getCloudUser(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.CloudUser { + return &cfg.Webconsole.CloudUser +} + +func (m *webconsoleManager) getPhaseControl(man controller.ComponentManager) controller.PhaseControl { + return controller.NewRegisterEndpointComponent( + man, v1alpha1.WebconsoleComponentType, + constants.ServiceNameWebconsole, constants.ServiceTypeWebconsole, + constants.WebconsolePort, "") +} + +func (m *webconsoleManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error) { + opt := &options.Options + if err := SetOptionsDefault(opt, constants.ServiceTypeWebconsole); err != nil { + return nil, err + } + config := cfg.Webconsole + SetOptionsServiceTLS(&opt.BaseOptions) + SetServiceCommonOptions(&opt.CommonOptions, oc, config) + + opt.IpmitoolPath = "/usr/sbin/ipmitool" + opt.EnableAutoLogin = true + address := oc.Spec.LoadBalancerEndpoint + opt.ApiServer = fmt.Sprintf("https://%s:%d", address, constants.WebconsolePort) + + return m.newServiceConfigMap(v1alpha1.WebconsoleComponentType, oc, opt), nil +} + +func (m *webconsoleManager) getService(oc *v1alpha1.OnecloudCluster) *corev1.Service { + return m.newSingleNodePortService(v1alpha1.WebconsoleComponentType, oc, constants.WebconsolePort) +} + +func (m *webconsoleManager) getDeployment(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error) { + return m.newCloudServiceSinglePortDeployment(v1alpha1.WebconsoleComponentType, oc, oc.Spec.Webconsole, constants.WebconsolePort, false) +} + +func (m *webconsoleManager) getDeploymentStatus(oc *v1alpha1.OnecloudCluster) *v1alpha1.DeploymentStatus { + return &oc.Status.Webconsole +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/yunionagent.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/yunionagent.go new file mode 100644 index 00000000..efce388f --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/yunionagent.go @@ -0,0 +1,116 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + "yunion.io/x/onecloud/pkg/cloudcommon/options" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/manager" +) + +type yunionagentManager struct { + *ComponentManager +} + +func newYunionagentManager(man *ComponentManager) manager.Manager { + return &yunionagentManager{man} +} + +type yunionagentOptions struct { + options.CommonOptions + options.DBOptions +} + +func (m *yunionagentManager) Sync(oc *v1alpha1.OnecloudCluster) error { + return syncComponent(m, oc) +} + +func (m *yunionagentManager) getDBConfig(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.DBConfig { + return &cfg.Yunionagent.DB +} + +func (m *yunionagentManager) getCloudUser(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.CloudUser { + return &cfg.Yunionagent.CloudUser +} + +func (m *yunionagentManager) getPhaseControl(man controller.ComponentManager) controller.PhaseControl { + return man.YunionAgent() +} + +func (m *yunionagentManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error) { + opt := &yunionagentOptions{} + if err := SetOptionsDefault(opt, constants.ServiceTypeYunionAgent); err != nil { + return nil, err + } + config := cfg.Yunionagent + SetDBOptions(&opt.DBOptions, oc.Spec.Mysql, config.DB) + SetOptionsServiceTLS(&opt.BaseOptions) + SetServiceCommonOptions(&opt.CommonOptions, oc, config.ServiceCommonOptions) + opt.AutoSyncTable = true + + return m.newServiceConfigMap(v1alpha1.YunionagentComponentType, oc, opt), nil +} + +func (m *yunionagentManager) getService(oc *v1alpha1.OnecloudCluster) *corev1.Service { + // use headless service + svcName := controller.NewClusterComponentName(oc.GetName(), v1alpha1.YunionagentComponentType) + appLabel := m.getComponentLabel(oc, v1alpha1.YunionagentComponentType) + svc := &corev1.Service{ + ObjectMeta: m.getObjectMeta(oc, svcName, appLabel), + Spec: corev1.ServiceSpec{ + ClusterIP: corev1.ClusterIPNone, + Selector: appLabel, + }, + } + return svc +} + +// use local volume pvc avoid pod migrate +func (m *yunionagentManager) getPVC(oc *v1alpha1.OnecloudCluster) (*corev1.PersistentVolumeClaim, error) { + cfg := oc.Spec.Yunionagent + return m.newPVC(v1alpha1.YunionagentComponentType, oc, cfg) +} + +func (m *yunionagentManager) getDeployment(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error) { + deploy, err := m.newCloudServiceSinglePortDeployment(v1alpha1.YunionagentComponentType, oc, oc.Spec.Yunionagent.DeploymentSpec, constants.YunionAgentPort, false) + if err != nil { + return nil, err + } + podSpec := &deploy.Spec.Template.Spec + podSpec.HostNetwork = true + podSpec.DNSPolicy = corev1.DNSClusterFirstWithHostNet + podSpec.Volumes = append(podSpec.Volumes, corev1.Volume{ + Name: "data", + VolumeSource: corev1.VolumeSource{ + PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{ + ClaimName: controller.NewClusterComponentName(oc.GetName(), v1alpha1.YunionagentComponentType), + ReadOnly: false, + }, + }, + }) + volMounts := podSpec.Containers[0].VolumeMounts + volMounts = append(volMounts, corev1.VolumeMount{ + Name: "data", + MountPath: "/mnt", + }) + podSpec.Containers[0].VolumeMounts = volMounts + return deploy, nil +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/yunionconf.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/yunionconf.go new file mode 100644 index 00000000..649462c8 --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/component/yunionconf.go @@ -0,0 +1,79 @@ +// Copyright 2019 Yunion +// +// 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 component + +import ( + apps "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + + "yunion.io/x/onecloud-operator/pkg/apis/constants" + "yunion.io/x/onecloud/pkg/yunionconf/options" + + "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + "yunion.io/x/onecloud-operator/pkg/controller" + "yunion.io/x/onecloud-operator/pkg/manager" +) + +type yunoinconfManager struct { + *ComponentManager +} + +func newYunionconfManager(man *ComponentManager) manager.Manager { + return &yunoinconfManager{man} +} + +func (m *yunoinconfManager) Sync(oc *v1alpha1.OnecloudCluster) error { + return syncComponent(m, oc) +} + +func (m *yunoinconfManager) getDBConfig(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.DBConfig { + return &cfg.Yunionconf.DB +} + +func (m *yunoinconfManager) getCloudUser(cfg *v1alpha1.OnecloudClusterConfig) *v1alpha1.CloudUser { + return &cfg.Yunionconf.CloudUser +} + +func (m *yunoinconfManager) getPhaseControl(man controller.ComponentManager) controller.PhaseControl { + return controller.NewRegisterEndpointComponent(man, v1alpha1.YunionconfComponentType, + constants.ServiceNameYunionConf, constants.ServiceTypeYunionConf, + constants.YunionConfPort, "") +} + +func (m *yunoinconfManager) getConfigMap(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*corev1.ConfigMap, error) { + opt := &options.Options + if err := SetOptionsDefault(opt, constants.ServiceTypeYunionConf); err != nil { + return nil, err + } + config := cfg.Yunionconf + SetDBOptions(&opt.DBOptions, oc.Spec.Mysql, config.DB) + SetOptionsServiceTLS(&opt.BaseOptions) + SetServiceCommonOptions(&opt.CommonOptions, oc, config.ServiceCommonOptions) + opt.AutoSyncTable = true + + return m.newServiceConfigMap(v1alpha1.YunionconfComponentType, oc, opt), nil +} + +func (m *yunoinconfManager) getService(oc *v1alpha1.OnecloudCluster) *corev1.Service { + return m.newSingleNodePortService(v1alpha1.YunionconfComponentType, oc, constants.YunionConfPort) +} + +func (m *yunoinconfManager) getDeployment(oc *v1alpha1.OnecloudCluster, cfg *v1alpha1.OnecloudClusterConfig) (*apps.Deployment, error) { + return m.newCloudServiceSinglePortDeployment(v1alpha1.YunionconfComponentType, oc, oc.Spec.Yunionconf, constants.YunionConfPort, false) +} + +func (m *yunoinconfManager) getDeploymentStatus(oc *v1alpha1.OnecloudCluster) *v1alpha1.DeploymentStatus { + return &oc.Status.Yunionconf +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/manager/manager.go b/vendor/yunion.io/x/onecloud-operator/pkg/manager/manager.go new file mode 100644 index 00000000..ed0aeb46 --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/manager/manager.go @@ -0,0 +1,23 @@ +// Copyright 2019 Yunion +// +// 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 manager + +import "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + +// Manager implements the logic for syncing onecloud cluster. +type Manager interface { + // Sync implements the logic for syncing onecloud cluster. + Sync(cluster *v1alpha1.OnecloudCluster) error +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/util/mysql/mysql.go b/vendor/yunion.io/x/onecloud-operator/pkg/util/mysql/mysql.go new file mode 100644 index 00000000..ddb98e36 --- /dev/null +++ b/vendor/yunion.io/x/onecloud-operator/pkg/util/mysql/mysql.go @@ -0,0 +1,189 @@ +// Copyright 2019 Yunion +// +// 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 mysql + +import ( + "database/sql" + "fmt" + "strings" + + "github.com/pkg/errors" + + apis "yunion.io/x/onecloud-operator/pkg/apis/onecloud/v1alpha1" + + _ "github.com/go-sql-driver/mysql" +) + +var ( + AllHosts = []string{"%", "127.0.0.1"} +) + +type Connection struct { + db *sql.DB + Host string + Port int + Username string + Password string +} + +func NewConnection(info *apis.Mysql) (*Connection, error) { + host := info.Host + port := info.Port + username := info.Username + password := info.Password + db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:%d)/", username, password, host, port)) + if err != nil { + return nil, errors.Wrap(err, "Connect to database") + } + return &Connection{ + db: db, + Host: host, + Port: int(port), + Username: username, + Password: password, + }, nil +} + +func (conn *Connection) CheckHealth() error { + _, err := conn.db.Exec("SHOW MASTER STATUS") + return err +} + +func (conn *Connection) IsDatabaseExists(db string) (bool, error) { + var dbName string + err := conn.db. + QueryRow("SELECT `SCHEMA_NAME` AS `database` FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = ?", db). + Scan(&dbName) + if err != nil { + if err == sql.ErrNoRows { + return false, nil + } + return false, errors.Wrap(err, "do query") + } + if dbName == db { + return true, nil + } + return false, nil +} + +func (conn *Connection) IsUserExists(username string, host string) (bool, error) { + var count int + q := fmt.Sprintf("SELECT COUNT(*) FROM mysql.user WHERE user = '%s'", username) + if len(host) != 0 { + q = fmt.Sprintf("%s and host = '%s'", q, host) + } + if err := conn.db.QueryRow(q).Scan(&count); err != nil { + return false, errors.Wrapf(err, "check user %s@%s exists", username, host) + } + if count > 0 { + return true, nil + } + return false, nil +} + +func (conn *Connection) DropUserByHosts(username string, hosts []string) error { + for _, host := range hosts { + if err := conn.DropUserByHost(username, host); err != nil { + return errors.Wrapf(err, "drop user %s@%s", username, host) + } + } + return nil +} + +func (conn *Connection) DropUser(username string) error { + return conn.DropUserByHosts(username, AllHosts) +} + +func (conn *Connection) DropUserByHost(username string, address string) error { + exists, err := conn.IsUserExists(username, address) + if err != nil { + return errors.Wrapf(err, "drop user %s@%s check exists", username, address) + } + if !exists { + return nil + } + userIdx := fmt.Sprintf("'%s'", username) + if len(address) > 0 { + userIdx = fmt.Sprintf("%s@'%s'", userIdx, address) + } + q := fmt.Sprintf("DROP USER %s", userIdx) + _, err = conn.db.Exec(q) + return err +} + +func (conn *Connection) Grant(username string, password string, database string, address string) error { + if address == "" { + address = "%" + } + if database == "" { + database = "*" + } + _, err := conn.db.Exec(fmt.Sprintf("GRANT ALL ON `%s`.* to '%s'@'%s' IDENTIFIED BY '%s'", database, username, address, password)) + return err +} + +func (conn *Connection) CreateUser(username string, password string, database string) error { + if database == "" { + database = "*" + } + addrs := AllHosts + if err := conn.DropUser(username); err != nil { + return errors.Wrapf(err, "Delete user %s", username) + } + for _, addr := range addrs { + if err := conn.Grant(username, password, database, addr); err != nil { + return errors.Wrapf(err, "Grant user %s@%s to database %s", username, addr, database) + } + } + return nil +} + +func (conn *Connection) CreateDatabase(db string) error { + _, err := conn.db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS `%s`", db)) + return err +} + +func (conn *Connection) DropDatabase(db string) error { + _, err := conn.db.Exec(fmt.Sprintf("DROP DATABASE IF EXISTS `%s`", db)) + return err +} + +func (conn *Connection) IsGrantPrivUser(user string, host string) (bool, error) { + grant, err := conn.ShowGrants(user, host) + if err != nil { + return false, err + } + if strings.Contains(grant, "WITH GRANT OPTION") { + return true, nil + } + return false, nil +} + +func (conn *Connection) ShowGrants(user string, host string) (string, error) { + if host == "" { + host = "%" + } + q := fmt.Sprintf("SHOW GRANTS FOR '%s'@'%s'", user, host) + var ret string + if err := conn.db.QueryRow(q).Scan(&ret); err != nil { + return "", errors.Wrapf(err, "show grants for %s@%s", user, host) + } + return ret, nil + +} + +func (conn *Connection) Close() error { + return conn.db.Close() +} diff --git a/vendor/yunion.io/x/onecloud-operator/pkg/util/onecloud/onecloud.go b/vendor/yunion.io/x/onecloud-operator/pkg/util/onecloud/onecloud.go index 32dd7e63..b20da68a 100644 --- a/vendor/yunion.io/x/onecloud-operator/pkg/util/onecloud/onecloud.go +++ b/vendor/yunion.io/x/onecloud-operator/pkg/util/onecloud/onecloud.go @@ -159,6 +159,12 @@ func EnsureEndpoint(s *mcclient.ClientSession, svcId, regionId, interfaceType, u if err != nil { return nil, err } + epUrl, _ := ep.GetString("url") + enabled, _ := ep.Bool("enabled") + if epUrl == url && enabled { + // same endpoint exists and already exists + return ep, nil + } updateParams := jsonutils.NewDict() updateParams.Add(jsonutils.NewString(url), "url") updateParams.Add(jsonutils.JSONTrue, "enabled") diff --git a/vendor/yunion.io/x/onecloud/pkg/logger/options/doc.go b/vendor/yunion.io/x/onecloud/pkg/logger/options/doc.go new file mode 100644 index 00000000..d9c1eb55 --- /dev/null +++ b/vendor/yunion.io/x/onecloud/pkg/logger/options/doc.go @@ -0,0 +1,15 @@ +// Copyright 2019 Yunion +// +// 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 options // import "yunion.io/x/onecloud/pkg/logger/options" diff --git a/vendor/yunion.io/x/onecloud/pkg/logger/options/options.go b/vendor/yunion.io/x/onecloud/pkg/logger/options/options.go new file mode 100644 index 00000000..b3da8004 --- /dev/null +++ b/vendor/yunion.io/x/onecloud/pkg/logger/options/options.go @@ -0,0 +1,29 @@ +// Copyright 2019 Yunion +// +// 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 options + +import ( + common_options "yunion.io/x/onecloud/pkg/cloudcommon/options" +) + +type SLoggerOptions struct { + common_options.CommonOptions + + common_options.DBOptions +} + +var ( + Options SLoggerOptions +) diff --git a/vendor/yunion.io/x/onecloud/pkg/scheduler/options/doc.go b/vendor/yunion.io/x/onecloud/pkg/scheduler/options/doc.go new file mode 100644 index 00000000..beefb703 --- /dev/null +++ b/vendor/yunion.io/x/onecloud/pkg/scheduler/options/doc.go @@ -0,0 +1,15 @@ +// Copyright 2019 Yunion +// +// 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 options // import "yunion.io/x/onecloud/pkg/scheduler/options" diff --git a/vendor/yunion.io/x/onecloud/pkg/scheduler/options/options.go b/vendor/yunion.io/x/onecloud/pkg/scheduler/options/options.go new file mode 100644 index 00000000..526d4111 --- /dev/null +++ b/vendor/yunion.io/x/onecloud/pkg/scheduler/options/options.go @@ -0,0 +1,109 @@ +// Copyright 2019 Yunion +// +// 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 options + +import ( + "os" + + common_optoins "yunion.io/x/onecloud/pkg/cloudcommon/options" + "yunion.io/x/onecloud/pkg/compute/options" +) + +type SchedulerOptions struct { + options.ComputeOptions + + SchedOptions + + // gin http framework mode + GinMode string `help:"gin http framework work mode" default:"debug" choices:"debug|release"` +} + +type SchedOptions struct { + SchedulerPort int `help:"The port that the scheduler's http service runs on" default:"8897"` + IgnoreFakeDeletedGuests bool `help:"Ignore fake deleted guests when build host memory and cpu size" default:"false"` + + AlwaysCheckAllPredicates bool `help:"Excute all predicates when scheduling" default:"false"` + DisableBaremetalPredicates bool `help:"Switch to trigger baremetal related predicates" default:"false"` + SchedulerTestLimit int `help:"Scheduler test items' limitations" default:"100"` + SchedulerHistoryLimit int `help:"Scheduler history items' limitations" default:"1000"` + SchedulerHistoryCleanPeriod string `help:"Scheduler history cleanup period" default:"60s"` + + // per isolated device default reserverd resource + MemoryReservedPerIsolatedDevice int64 `help:"Per isolated device default reserverd memory size in MB" default:"8192"` // 8G + CpuReservedPerIsolatedDevice int64 `help:"Per isolated device default reserverd CPU count" default:"8"` // 8 core + StorageReservedPerIsolatedDevice int64 `help:"Per isolated device default reserverd storage size in MB" default:"102400"` // 100G + + // parallelization options + HostBuildParallelizeSize int `help:"Number of host description build parallelization" default:"14"` + PredicateParallelizeSize int `help:"Number of execute predicates parallelization" default:"14"` + PriorityParallelizeSize int `help:"Number of execute priority parallelization" default:"14"` + + // expire queue options + ExpireQueueConsumptionPeriod string `help:"Expire queue consumption period" default:"3s"` + ExpireQueueConsumptionTimeout string `help:"Expire queue consumption timeout" default:"10s"` + ExpireQueueMaxLength int `help:"Expire queue max length" default:"1000"` + ExpireQueueDealLength int `help:"Expire queue deal length" default:"100"` + + // completed queue options + CompletedQueueConsumptionPeriod string `help:"Completed queue consumption period" default:"30s"` + CompletedQueueConsumptionTimeout string `help:"Completed queue consumption timeout" default:"30s"` + CompletedQueueMaxLength int `help:"Completed queue max length" default:"100"` + CompletedQueueDealLength int `help:"Completed queue deal length" default:"10"` + + // cache options + HostCandidateCacheTTL string `help:"Build host description candidate cache TTL" default:"0s"` + HostCandidateCacheReloadCount int `help:"Build host description candidate cache reload times count" default:"20"` + HostCandidateCachePeriod string `help:"Build host description candidate cache period" default:"30s"` + + BaremetalCandidateCacheTTL string `help:"Build Baremetal description candidate cache TTL" default:"0s"` + BaremetalCandidateCacheReloadCount int `help:"Build Baremetal description candidate cache reload times count" default:"20"` + BaremetalCandidateCachePeriod string `help:"Build Baremetal description candidate cache period" default:"30s"` + + NetworkCacheTTL string `help:"Build network info from database to cache TTL" default:"0s"` + NetworkCachePeriod string `help:"Build network info from database to cache TTL" default:"1m"` + + BaremetalAgentDBCacheTTL string `help:"BaremetalAgent database cache TTL" default:"0s"` + BaremetalAgentDBCachePeriod string `help:"BaremetalAgent database cache period" default:"5m"` + + AggregateDBCacheTTL string `help:"Aggregate database cache TTL" default:"0s"` + AggregateDBCachePeriod string `help:"Aggregate database cache period" default:"30s"` + + AggregateHostDBCacheTTL string `help:"AggregateHost database cache TTL" default:"0s"` + AggregateHostDBCachePeriod string `help:"AggregateHost database cache period" default:"30s"` + + NetworksDBCacheTTL string `help:"Networks database cache TTL" default:"0s"` + NetworksDBCachePeriod string `help:"Networks database cache period" default:"5m"` + + NetinterfaceDBCacheTTL string `help:"Netinterfaces database cache TTL" default:"0s"` + NetinterfaceDBCachePeriod string `help:"Netinterfaces database cache period" default:"5m"` + + WireDBCacheTTL string `help:"Wire database cache TTL" default:"0s"` + WireDBCachePeriod string `help:"Wire database cache period" default:"5m"` + + SkuRefreshInterval string `help:"Server SKU refresh interval" default:"12h"` +} + +var ( + opt SchedulerOptions +) + +func GetOptions() *SchedulerOptions { + return &opt +} + +func Init() { + common_optoins.ParseOptions(&opt, os.Args, "region.conf", "scheduler") + options.Options = opt.ComputeOptions +} diff --git a/vendor/yunion.io/x/onecloud/pkg/webconsole/options/doc.go b/vendor/yunion.io/x/onecloud/pkg/webconsole/options/doc.go new file mode 100644 index 00000000..0ff031d8 --- /dev/null +++ b/vendor/yunion.io/x/onecloud/pkg/webconsole/options/doc.go @@ -0,0 +1,15 @@ +// Copyright 2019 Yunion +// +// 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 options // import "yunion.io/x/onecloud/pkg/webconsole/options" diff --git a/vendor/yunion.io/x/onecloud/pkg/webconsole/options/options.go b/vendor/yunion.io/x/onecloud/pkg/webconsole/options/options.go new file mode 100644 index 00000000..e5d33335 --- /dev/null +++ b/vendor/yunion.io/x/onecloud/pkg/webconsole/options/options.go @@ -0,0 +1,32 @@ +// Copyright 2019 Yunion +// +// 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 options + +import common_options "yunion.io/x/onecloud/pkg/cloudcommon/options" + +var ( + Options WebConsoleOptions +) + +type WebConsoleOptions struct { + common_options.CommonOptions + + ApiServer string `help:"API server url to handle websocket connection, usually with public access" default:"http://webconsole.yunion.io"` + KubectlPath string `help:"kubectl binary path used to connect k8s cluster" default:"/usr/bin/kubectl"` + IpmitoolPath string `help:"ipmitool binary path used to connect baremetal sol" default:"/usr/bin/ipmitool"` + SshToolPath string `help:"sshtool binary path used to connect server sol" default:"/usr/bin/ssh"` + SshpassToolPath string `help:"sshpass tool binary path used to connect server sol" default:"/usr/bin/sshpass"` + EnableAutoLogin bool `help:"allow webconsole to log in directly with the cloudroot public key" default:"false"` +} diff --git a/vendor/yunion.io/x/onecloud/pkg/yunionconf/options/doc.go b/vendor/yunion.io/x/onecloud/pkg/yunionconf/options/doc.go new file mode 100644 index 00000000..d693813c --- /dev/null +++ b/vendor/yunion.io/x/onecloud/pkg/yunionconf/options/doc.go @@ -0,0 +1,15 @@ +// Copyright 2019 Yunion +// +// 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 options // import "yunion.io/x/onecloud/pkg/yunionconf/options" diff --git a/vendor/yunion.io/x/onecloud/pkg/yunionconf/options/options.go b/vendor/yunion.io/x/onecloud/pkg/yunionconf/options/options.go new file mode 100644 index 00000000..c9782abb --- /dev/null +++ b/vendor/yunion.io/x/onecloud/pkg/yunionconf/options/options.go @@ -0,0 +1,26 @@ +// Copyright 2019 Yunion +// +// 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 options + +import common_options "yunion.io/x/onecloud/pkg/cloudcommon/options" + +type YunionConfOptions struct { + common_options.CommonOptions + common_options.DBOptions +} + +var ( + Options YunionConfOptions +)