From 21716cefb52d1f9bf84eedc35529f987be7e6960 Mon Sep 17 00:00:00 2001 From: Jian Qiu Date: Tue, 27 Dec 2022 01:21:26 +0800 Subject: [PATCH] fix: remove mutual dependency of cloudmux on onecloud (#15621) Co-authored-by: Qiu Jian --- cmd/climc/entry/climc.go | 2 +- cmd/climc/shell/ansible/common.go | 3 +- cmd/climc/shell/cloudevent/common.go | 3 +- cmd/climc/shell/cloudid/common.go | 3 +- cmd/climc/shell/cloudnet/common.go | 3 +- cmd/climc/shell/compute/baremetalnetworks.go | 4 +- cmd/climc/shell/compute/baremetalstorages.go | 4 +- cmd/climc/shell/compute/buckets.go | 4 +- .../shell/compute/cloudproviderregions.go | 4 +- cmd/climc/shell/compute/cloudregions.go | 8 +- cmd/climc/shell/compute/common.go | 3 +- cmd/climc/shell/compute/dbinstances.go | 5 +- cmd/climc/shell/compute/disks.go | 2 +- cmd/climc/shell/compute/hostcachedimages.go | 4 +- cmd/climc/shell/compute/hosts.go | 2 +- cmd/climc/shell/compute/hoststorages.go | 4 +- cmd/climc/shell/compute/hostwires.go | 4 +- cmd/climc/shell/compute/loadbalanceracls.go | 4 +- .../shell/compute/loadbalancercachedacls.go | 4 +- .../shell/compute/loadbalancerlisteners.go | 4 +- .../shell/compute/loadbalancernetworks.go | 4 +- cmd/climc/shell/compute/metadata.go | 4 +- .../shell/compute/networkinterfacenetworks.go | 4 +- cmd/climc/shell/compute/networks.go | 4 +- cmd/climc/shell/compute/schedtagresources.go | 4 +- cmd/climc/shell/compute/serverdisks.go | 4 +- cmd/climc/shell/compute/servernetworks.go | 4 +- cmd/climc/shell/compute/servers.go | 5 +- cmd/climc/shell/compute/serversecgroups.go | 4 +- cmd/climc/shell/compute/specs.go | 6 +- .../shell/compute/storagecachedimages.go | 4 +- cmd/climc/shell/compute/zones.go | 4 +- cmd/climc/shell/devtool/common.go | 3 +- cmd/climc/shell/devtool/devtoolcronjob.go | 4 +- cmd/climc/shell/devtool/devtooltemplate.go | 4 +- cmd/climc/shell/etcd/service_registries.go | 3 +- cmd/climc/shell/events/common.go | 3 +- cmd/climc/shell/helper.go | 8 +- cmd/climc/shell/identity/common.go | 3 +- .../shell/identity/credential_aes_key.go | 4 +- cmd/climc/shell/identity/credentials.go | 6 +- cmd/climc/shell/identity/identityproviders.go | 2 +- cmd/climc/shell/identity/policies.go | 15 +- cmd/climc/shell/identity/services.go | 2 +- cmd/climc/shell/image/common.go | 3 +- cmd/climc/shell/image/images.go | 4 +- cmd/climc/shell/k8s/clusters.go | 2 +- cmd/climc/shell/k8s/k8s.go | 2 +- cmd/climc/shell/k8s/list.go | 6 +- cmd/climc/shell/logger/common.go | 3 +- cmd/climc/shell/misc/common.go | 3 +- cmd/climc/shell/misc/version.go | 3 +- cmd/climc/shell/monitor/alertnotification.go | 5 +- cmd/climc/shell/monitor/common.go | 3 +- cmd/climc/shell/notifyv2/common.go | 3 +- cmd/climc/shell/quota/common.go | 3 +- .../shell/scheduledtask/scheduledtask.go | 2 +- cmd/climc/shell/scheduler/common.go | 3 +- cmd/climc/shell/shell.go | 5 +- cmd/climc/shell/utils.go | 9 +- cmd/climc/shell/yunionconf/common.go | 3 +- cmd/climc/shell/yunionconf/parameters.go | 6 +- cmd/cloudpodscli/main.go | 153 + cmd/cryptool/main.go | 2 +- cmd/cryptool/shell/decrypt.go | 3 +- cmd/cryptool/shell/fernet.go | 2 +- cmd/cryptool/shell/zeroclean.go | 3 +- cmd/fetcherfs/fs.go | 2 +- cmd/ipmicli/main.go | 2 +- cmd/ldapcli/main.go | 2 +- cmd/ldapcli/shell/search.go | 3 +- cmd/raidcli/main.go | 2 +- cmd/raidcli/shell/raid.go | 2 +- cmd/redfishcli/main.go | 2 +- cmd/redfishcli/shell/chassis.go | 5 +- cmd/redfishcli/shell/manager.go | 4 +- cmd/redfishcli/shell/shell.go | 3 +- cmd/redfishcli/shell/system.go | 2 +- cmd/region/main.go | 1 + cmd/telegraf-raid-plugin/main.go | 2 +- go.mod | 40 +- go.sum | 84 +- .../models/ansibleplaybook_instance.go | 2 +- .../models/ansibleplaybookreference.go | 6 +- pkg/apigateway/handler/auth.go | 47 +- pkg/apigateway/handler/auth_totp.go | 2 +- pkg/apigateway/handler/backendproxy.go | 2 +- pkg/apigateway/handler/csrfexempt.go | 2 +- pkg/apigateway/handler/idp.go | 4 +- pkg/apigateway/handler/k8s.go | 2 +- pkg/apigateway/handler/middleware.go | 2 +- pkg/apigateway/handler/misc.go | 4 +- pkg/apigateway/handler/oidc.go | 2 +- pkg/apigateway/handler/request.go | 2 +- pkg/apigateway/handler/resource.go | 7 +- pkg/apigateway/handler/rpc.go | 7 +- pkg/apigateway/report/report.go | 2 +- pkg/apihelper/apihelper.go | 2 +- pkg/apihelper/reflect.go | 3 +- pkg/apis/identity/input.go | 6 +- pkg/apis/identity/role.go | 5 +- pkg/apis/identity/rolepolicy.go | 5 +- pkg/apis/share.go | 45 +- pkg/apis/share_test.go | 48 +- pkg/apis/yunionconf/input.go | 6 +- pkg/appsrv/appparams.go | 2 +- pkg/appsrv/appsrv.go | 4 +- pkg/appsrv/context.go | 3 +- pkg/appsrv/dispatcher/dispatcher.go | 2 +- pkg/appsrv/dispatcher/handlers.go | 12 +- pkg/appsrv/dispatcher/jointdispatcher.go | 5 +- pkg/baremetal/agent.go | 2 +- pkg/baremetal/manager.go | 2 +- pkg/baremetal/pxe/dhcp.go | 6 +- pkg/baremetal/tasks/base.go | 2 +- pkg/baremetal/tasks/cdrom.go | 2 +- pkg/cloudcommon/agent/agent.go | 4 +- pkg/cloudcommon/app/options.go | 3 +- pkg/cloudcommon/cronman/cronman.go | 2 +- pkg/cloudcommon/db/apply_manager_method.go | 6 +- pkg/cloudcommon/db/database.go | 2 +- pkg/cloudcommon/db/db_dispatcher.go | 29 +- pkg/cloudcommon/db/db_joint_dispatcher.go | 8 +- pkg/cloudcommon/db/domain.go | 16 +- pkg/cloudcommon/db/fetch.go | 47 +- pkg/cloudcommon/db/infraresource.go | 12 +- pkg/cloudcommon/db/interface.go | 14 +- pkg/cloudcommon/db/jointbase.go | 8 +- pkg/cloudcommon/db/lock.go | 7 +- pkg/cloudcommon/db/metadata.go | 18 +- pkg/cloudcommon/db/metadataresource.go | 5 +- pkg/cloudcommon/db/modelbase.go | 18 +- pkg/cloudcommon/db/opslog.go | 14 +- pkg/cloudcommon/db/project.go | 12 +- pkg/cloudcommon/db/proxy/proxysetting.go | 10 +- pkg/cloudcommon/db/query.go | 6 +- pkg/cloudcommon/db/quotas/context.go | 2 +- pkg/cloudcommon/db/quotas/errors.go | 5 +- pkg/cloudcommon/db/quotas/handler.go | 70 +- pkg/cloudcommon/db/quotas/interface.go | 6 +- pkg/cloudcommon/db/quotas/models.go | 16 +- pkg/cloudcommon/db/quotas/quotakeys.go | 23 +- pkg/cloudcommon/db/quotas/quotas.go | 4 +- pkg/cloudcommon/db/quotas/stores.go | 6 +- pkg/cloudcommon/db/rbac.go | 127 +- pkg/cloudcommon/db/resourcebase_test.go | 3 +- pkg/cloudcommon/db/rolecache.go | 2 +- pkg/cloudcommon/db/scoperesource.go | 80 +- pkg/cloudcommon/db/sharablebase.go | 116 +- pkg/cloudcommon/db/sharablevirtual.go | 12 +- pkg/cloudcommon/db/sharedresource.go | 18 +- pkg/cloudcommon/db/standalone_anon.go | 6 +- .../db/statusinfrasuserresource.go | 8 +- pkg/cloudcommon/db/taskman/tasks.go | 12 +- pkg/cloudcommon/db/tenantcache.go | 2 +- pkg/cloudcommon/db/tenantcachesync.go | 6 +- pkg/cloudcommon/db/usercache.go | 2 +- pkg/cloudcommon/db/userresources.go | 16 +- pkg/cloudcommon/db/virtualjointbase.go | 8 +- pkg/cloudcommon/db/virtualresource.go | 14 +- pkg/cloudcommon/etcd/handler/dispatcher.go | 8 +- .../etcd/models/base/basemanager.go | 2 +- pkg/cloudcommon/etcd/models/base/basemodel.go | 2 +- .../notifyclient/notify_internal.go | 4 +- pkg/cloudcommon/options/options.go | 2 +- pkg/cloudcommon/policy/defaults.go | 8 +- pkg/cloudcommon/policy/policy.go | 109 +- pkg/cloudcommon/policy/token.go | 5 +- pkg/cloudcommon/validators/errors.go | 3 +- pkg/cloudcommon/workmanager/manager.go | 2 +- pkg/cloudevent/models/cloudevents.go | 12 +- pkg/cloudevent/models/cloudproviders.go | 2 +- pkg/cloudid/models/cloudaccount.go | 4 +- pkg/cloudid/models/cloudgroupcaches.go | 8 +- pkg/cloudid/models/huawei_driver.go | 2 +- pkg/cloudid/models/saml_provider.go | 2 +- pkg/cloudid/models/samldriver.go | 4 +- pkg/cloudid/policy/defaults.go | 10 +- pkg/cloudid/saml/init.go | 2 +- pkg/cloudid/saml/initidp.go | 4 +- pkg/cloudid/saml/providers/aliyun/driver.go | 2 +- pkg/cloudid/saml/providers/aws/driver.go | 2 +- pkg/cloudid/saml/providers/awscn/driver.go | 2 +- pkg/cloudid/saml/providers/azure/driver.go | 2 +- pkg/cloudid/saml/providers/google/driver.go | 3 +- pkg/cloudid/saml/providers/qcloud/driver.go | 2 +- pkg/cloudmon/misc/pinger.go | 4 +- pkg/cloudmon/misc/system.go | 2 +- pkg/cloudnet/models/routers_realize.go | 2 +- pkg/cloudnet/models/routes.go | 2 +- pkg/cloudnet/models/rules.go | 2 +- pkg/compute/guestdrivers/aliyun.go | 6 +- pkg/compute/guestdrivers/apsara.go | 7 +- pkg/compute/guestdrivers/aws.go | 6 +- pkg/compute/guestdrivers/azure.go | 6 +- pkg/compute/guestdrivers/baremetals.go | 4 +- pkg/compute/guestdrivers/base.go | 2 +- pkg/compute/guestdrivers/bingocloud.go | 4 +- pkg/compute/guestdrivers/cloudpods.go | 4 +- pkg/compute/guestdrivers/container.go | 6 +- pkg/compute/guestdrivers/ctyun.go | 4 +- pkg/compute/guestdrivers/ecloud.go | 4 +- pkg/compute/guestdrivers/esxi.go | 8 +- pkg/compute/guestdrivers/google.go | 6 +- pkg/compute/guestdrivers/hcs.go | 6 +- pkg/compute/guestdrivers/hcsop.go | 6 +- pkg/compute/guestdrivers/huawei.go | 6 +- pkg/compute/guestdrivers/huaweistack.go | 6 +- pkg/compute/guestdrivers/incloudsphere.go | 4 +- pkg/compute/guestdrivers/jdcloud.go | 6 +- pkg/compute/guestdrivers/kvm.go | 6 +- pkg/compute/guestdrivers/managedvirtual.go | 6 +- pkg/compute/guestdrivers/nutanix.go | 6 +- pkg/compute/guestdrivers/openstack.go | 6 +- pkg/compute/guestdrivers/proxmox.go | 4 +- pkg/compute/guestdrivers/qcloud.go | 6 +- pkg/compute/guestdrivers/remotefile.go | 4 +- pkg/compute/guestdrivers/ucloud.go | 4 +- pkg/compute/guestdrivers/zstack.go | 6 +- pkg/compute/hostdrivers/esxi.go | 2 +- pkg/compute/hostdrivers/kvm.go | 2 +- pkg/compute/models/access_group_caches.go | 10 +- pkg/compute/models/access_group_rules.go | 8 +- pkg/compute/models/billingresource.go | 2 +- pkg/compute/models/buckets.go | 7 +- pkg/compute/models/cachedimages.go | 10 +- pkg/compute/models/capabilities.go | 30 +- pkg/compute/models/cdn_domains.go | 6 +- pkg/compute/models/cloudaccount_saml.go | 2 +- pkg/compute/models/cloudaccounts.go | 36 +- pkg/compute/models/cloudaccounts_prepare.go | 10 +- pkg/compute/models/cloudproviders.go | 24 +- pkg/compute/models/cloudregions.go | 4 +- pkg/compute/models/dbinstance_accounts.go | 12 +- pkg/compute/models/dbinstance_databases.go | 12 +- pkg/compute/models/dbinstances.go | 9 +- pkg/compute/models/disks.go | 24 +- pkg/compute/models/dns_recordsets.go | 8 +- pkg/compute/models/dns_zonecaches.go | 8 +- pkg/compute/models/dns_zones.go | 6 +- pkg/compute/models/domainquota.go | 8 +- pkg/compute/models/elastic_search.go | 3 +- pkg/compute/models/elasticcache_accounts.go | 8 +- pkg/compute/models/elasticcache_acls.go | 8 +- pkg/compute/models/elasticcache_backups.go | 8 +- pkg/compute/models/elasticcache_instances.go | 17 +- pkg/compute/models/elasticcache_parameters.go | 8 +- pkg/compute/models/elasticips.go | 19 +- pkg/compute/models/external_projects.go | 20 +- pkg/compute/models/filesystem.go | 2 +- pkg/compute/models/filters.go | 10 +- pkg/compute/models/globalvpcs.go | 6 +- pkg/compute/models/groups.go | 4 +- pkg/compute/models/guest_actions.go | 6 +- pkg/compute/models/guest_sshable.go | 2 +- pkg/compute/models/guest_template.go | 10 +- pkg/compute/models/guestdrivers.go | 6 +- pkg/compute/models/guestnetworks.go | 12 +- pkg/compute/models/guests.go | 25 +- pkg/compute/models/host_recycle.go | 2 +- pkg/compute/models/hostnameresource.go | 2 +- pkg/compute/models/hosts.go | 21 +- pkg/compute/models/infrasquota.go | 7 +- pkg/compute/models/instance_snapshots.go | 11 +- pkg/compute/models/ipv6_gateways.go | 4 +- pkg/compute/models/isolated_devices.go | 23 +- pkg/compute/models/kafka.go | 3 +- pkg/compute/models/keypairs.go | 6 +- pkg/compute/models/kube_clusters.go | 4 +- pkg/compute/models/kube_node_pools.go | 10 +- pkg/compute/models/kube_nodes.go | 10 +- .../models/loadbalancerbackendgroups.go | 12 +- pkg/compute/models/loadbalancerbackends.go | 14 +- pkg/compute/models/loadbalancercachedacls.go | 14 +- .../models/loadbalancercachedcertificates.go | 14 +- .../models/loadbalancerlistenerrules.go | 12 +- pkg/compute/models/loadbalancerlisteners.go | 12 +- pkg/compute/models/loadbalancernetworks.go | 10 +- pkg/compute/models/loadbalancers.go | 9 +- pkg/compute/models/managedresource.go | 8 +- pkg/compute/models/mongodb.go | 7 +- pkg/compute/models/mount_targets.go | 10 +- pkg/compute/models/natgateways.go | 2 +- pkg/compute/models/netinterfaces.go | 4 +- pkg/compute/models/networkaddresses.go | 8 +- pkg/compute/models/networks.go | 45 +- .../models/networks_used_addresses_query.go | 4 +- pkg/compute/models/projectquota.go | 12 +- pkg/compute/models/purge.go | 4 +- pkg/compute/models/quotas.go | 19 +- pkg/compute/models/regiondrivers.go | 6 +- pkg/compute/models/regionquota.go | 11 +- pkg/compute/models/reservedips.go | 16 +- pkg/compute/models/scaling_activity.go | 14 +- pkg/compute/models/schedtags.go | 12 +- pkg/compute/models/secgroupcache.go | 14 +- pkg/compute/models/secgrouprules.go | 8 +- pkg/compute/models/secgroups.go | 20 +- pkg/compute/models/skus_tools.go | 2 +- pkg/compute/models/snapshotpolicycache.go | 6 +- pkg/compute/models/snapshots.go | 11 +- pkg/compute/models/storagecaches.go | 2 +- pkg/compute/models/storages.go | 29 +- pkg/compute/models/tablestores.go | 4 +- pkg/compute/models/vpcs.go | 28 +- pkg/compute/models/waf_rules.go | 8 +- pkg/compute/models/wires.go | 53 +- pkg/compute/models/zonequota.go | 8 +- pkg/compute/models/zones.go | 4 +- pkg/compute/policy/defaults.go | 10 +- pkg/compute/regiondrivers/aliyun.go | 2 +- pkg/compute/regiondrivers/aws.go | 2 +- pkg/compute/regiondrivers/azure.go | 2 +- pkg/compute/regiondrivers/base.go | 10 +- pkg/compute/regiondrivers/ecloud.go | 3 +- pkg/compute/regiondrivers/google.go | 2 +- pkg/compute/regiondrivers/huawei.go | 2 +- pkg/compute/regiondrivers/kvm.go | 4 +- pkg/compute/regiondrivers/managedvirtual.go | 10 +- pkg/compute/regiondrivers/openstack.go | 6 +- pkg/compute/regiondrivers/qcloud.go | 10 +- pkg/compute/specs/handler.go | 2 +- pkg/compute/sshkeys/handler.go | 8 +- pkg/compute/storagedrivers/rbd.go | 2 +- pkg/compute/tasks/baremetal_delete_task.go | 2 +- .../tasks/cloud_account_sync_vmware_net.go | 8 +- pkg/compute/tasks/dbinstance_renew_task.go | 2 +- .../tasks/dbinstance_set_auto_renew_task.go | 2 +- pkg/compute/tasks/disk_backup_create_task.go | 2 +- pkg/compute/tasks/elasticcache_renew_task.go | 2 +- .../tasks/guest_convert_esxi_to_kvm_task.go | 2 +- pkg/compute/tasks/guest_create_task.go | 2 +- pkg/compute/tasks/guest_delete_backup_task.go | 2 +- pkg/compute/tasks/guest_live_migrate_task.go | 2 +- pkg/compute/tasks/guest_renew_task.go | 2 +- pkg/compute/tasks/guest_undeploy_task.go | 2 +- pkg/compute/tasks/nat_create_task.go | 2 +- pkg/compute/tasks/nat_renew_task.go | 2 +- pkg/compute/tasks/nat_set_auto_renew_task.go | 2 +- .../tasks/networks_under_wire_merge_task.go | 4 +- pkg/compute/tasks/storage_update_task.go | 2 +- pkg/compute/usages/cache.go | 12 +- pkg/compute/usages/handler.go | 249 +- pkg/controller/autoscaling/controller.go | 2 +- pkg/devtool/models/script_apply_record.go | 14 +- pkg/devtool/utils/service_url.go | 2 +- pkg/esxi/handler/handlers.go | 2 +- pkg/hostimage/host_image_service.go | 2 +- pkg/hostman/diskutils/nbd/driver.go | 2 +- pkg/hostman/guestfs/fsdriver/windows.go | 2 +- pkg/hostman/guestman/guesttasks.go | 4 +- pkg/hostman/guestman/qemu-kvm.go | 4 +- pkg/hostman/hostmetrics/hostmetrics.go | 2 +- pkg/hostman/hostutils/hostutils.go | 2 +- .../backupstorage/backup_storage.go | 6 +- .../backupstorage/backup_storage_nfs.go | 9 +- pkg/hostman/storageman/disk_agent.go | 29 +- pkg/hostman/storageman/disk_local.go | 5 +- pkg/hostman/storageman/disk_rbd.go | 2 +- .../storageman/remotefile/remotefile.go | 2 +- pkg/hostman/storageman/storage_agent.go | 3 +- pkg/hostman/storageman/storage_base.go | 3 +- pkg/hostman/storageman/storage_local.go | 5 +- pkg/hostman/storageman/storage_rbd.go | 13 +- pkg/hostman/system_service/telegraf.go | 3 +- pkg/httperrors/consts.go | 4 +- pkg/httperrors/errors.go | 3 +- pkg/httperrors/general.go | 3 +- pkg/httperrors/httperrors.go | 4 +- pkg/i18n/table.go | 2 +- pkg/image/models/image_guest.go | 13 +- pkg/image/models/images.go | 48 +- pkg/image/models/quotas.go | 11 +- pkg/image/models/storage.go | 6 +- pkg/image/policy/defaults.go | 6 +- pkg/image/tasks/image_copy_from_url_task.go | 2 +- pkg/image/usages/handler.go | 20 +- pkg/keystone/cronjobs/project_resources.go | 2 +- pkg/keystone/driver/base.go | 3 +- pkg/keystone/driver/cas/cas.go | 2 +- .../driver/oauth2/dingtalk/dingtalk.go | 2 +- pkg/keystone/driver/oauth2/feishu/feishu.go | 2 +- .../driver/oauth2/qywechat/qywechat.go | 2 +- pkg/keystone/driver/oauth2/wechat/wechat.go | 2 +- pkg/keystone/driver/saml/saml.go | 4 +- pkg/keystone/locale/genpolicy.go | 29 +- pkg/keystone/locale/predefined_policies.go | 50 +- pkg/keystone/locale/predefined_yaml.go | 17 +- pkg/keystone/models/assignments.go | 24 +- pkg/keystone/models/credentials.go | 10 +- pkg/keystone/models/groups.go | 10 +- pkg/keystone/models/identity_provider.go | 4 +- pkg/keystone/models/identitybase.go | 6 +- pkg/keystone/models/identityquota.go | 8 +- pkg/keystone/models/policies.go | 33 +- pkg/keystone/models/projects.go | 6 +- pkg/keystone/models/rolepolicies.go | 23 +- pkg/keystone/models/roles.go | 6 +- pkg/keystone/models/users.go | 12 +- pkg/keystone/policy/defaults.go | 12 +- pkg/keystone/saml/init.go | 2 +- pkg/keystone/saml/metadata.go | 3 +- pkg/keystone/tokens/auth.go | 2 +- pkg/keystone/tokens/handlers.go | 4 +- pkg/keystone/tokens/token.go | 8 +- pkg/keystone/usages/handler.go | 4 +- pkg/logger/models/baremetalevents.go | 6 +- pkg/logger/policy/defaults.go | 4 +- pkg/mcclient/aksk.go | 2 +- pkg/mcclient/auth/aksk.go | 2 +- pkg/mcclient/auth/middleware.go | 2 +- .../mcclient}/cloudpods/cloudpods.go | 17 +- .../mcclient}/cloudpods/disk.go | 5 +- .../object => mcclient/cloudpods}/doc.go | 2 +- .../mcclient}/cloudpods/eip.go | 5 +- .../mcclient}/cloudpods/host.go | 5 +- .../mcclient}/cloudpods/image.go | 11 +- .../mcclient}/cloudpods/instance.go | 5 +- .../mcclient}/cloudpods/instancenic.go | 5 +- .../mcclient}/cloudpods/keypair.go | 0 .../mcclient}/cloudpods/network.go | 11 +- .../mcclient}/cloudpods/project.go | 6 +- .../mcclient}/cloudpods/provider/doc.go | 0 .../mcclient}/cloudpods/provider/provider.go | 8 +- .../mcclient}/cloudpods/region.go | 5 +- .../mcclient}/cloudpods/secgroup.go | 5 +- pkg/mcclient/cloudpods/shell/disk.go | 36 + .../cloudpods/shell}/doc.go | 2 +- pkg/mcclient/cloudpods/shell/hosts.go | 35 + pkg/mcclient/cloudpods/shell/image.go | 48 + pkg/mcclient/cloudpods/shell/instance.go | 82 + pkg/mcclient/cloudpods/shell/network.go | 35 + .../cloudpods/shell/printutils.go} | 12 +- pkg/mcclient/cloudpods/shell/region.go | 34 + pkg/mcclient/cloudpods/shell/secgroup.go | 47 + .../cloudpods/shell/vpc.go} | 28 +- pkg/mcclient/cloudpods/shell/wire.go | 36 + pkg/mcclient/cloudpods/shell/zones.go | 34 + .../mcclient}/cloudpods/sku.go | 6 +- .../mcclient}/cloudpods/snapshot.go | 5 +- .../mcclient}/cloudpods/storage.go | 5 +- .../mcclient}/cloudpods/storagecache.go | 5 +- .../mcclient}/cloudpods/tag_base.go | 3 +- .../mcclient}/cloudpods/vpc.go | 5 +- .../mcclient}/cloudpods/wire.go | 5 +- .../mcclient}/cloudpods/zone.go | 5 +- pkg/mcclient/mcclient.go | 5 +- pkg/mcclient/modulebase/base.go | 57 +- pkg/mcclient/modulebase/filter.go | 3 +- pkg/mcclient/modulebase/joint.go | 19 +- pkg/mcclient/modulebase/misc.go | 5 +- pkg/mcclient/modulebase/modules.go | 71 +- pkg/mcclient/modulebase/resource.go | 73 +- pkg/mcclient/modulebase/utils.go | 5 +- pkg/mcclient/modules/compute/mod_buckets.go | 2 +- .../modules/compute/mod_capabilities.go | 5 +- .../modules/compute/mod_cloudproviders.go | 2 +- pkg/mcclient/modules/compute/mod_hosts.go | 17 +- pkg/mcclient/modules/compute/mod_metadatas.go | 3 +- pkg/mcclient/modules/compute/mod_skus.go | 7 +- .../modules/compute/mod_sshkeypairs.go | 5 +- pkg/mcclient/modules/compute/mod_tasks.go | 3 +- pkg/mcclient/modules/compute/mod_workers.go | 3 +- pkg/mcclient/modules/identity/mod_groups.go | 5 +- pkg/mcclient/modules/identity/mod_roles.go | 7 +- pkg/mcclient/modules/identity/mod_users.go | 7 +- pkg/mcclient/modules/image/mod_images.go | 19 +- pkg/mcclient/modules/k8s/raw.go | 2 +- pkg/mcclient/modules/misc.go | 4 +- pkg/mcclient/modules/pprof.go | 2 +- pkg/mcclient/modules/quota/mod_quotas.go | 2 +- pkg/mcclient/session.go | 4 +- pkg/mcclient/token.go | 11 +- pkg/mcclient/token2.go | 7 +- pkg/mcclient/token3.go | 7 +- pkg/mcclient/tokensimple.go | 7 +- pkg/mcclient/utils/fetchnames.go | 6 +- pkg/monitor/alerting/notifiers/onecloud.go | 8 +- pkg/monitor/models/alert.go | 6 +- pkg/monitor/models/alertdashboard.go | 14 +- pkg/monitor/models/alertpannel.go | 6 +- pkg/monitor/models/alertrecord.go | 10 +- pkg/monitor/models/commonalert.go | 16 +- pkg/monitor/models/metric.go | 6 +- pkg/monitor/models/metric_field.go | 6 +- pkg/monitor/models/monitor_resource.go | 4 +- pkg/monitor/models/monitor_resource_alert.go | 10 +- pkg/monitor/models/monitorscoperesource.go | 18 +- pkg/monitor/models/nodealert.go | 4 +- pkg/monitor/models/unifiedmonitor.go | 8 +- pkg/monitor/notifydrivers/feishu/client.go | 3 +- pkg/monitor/service/dispatcher.go | 2 +- pkg/notify/models/config.go | 12 +- pkg/notify/models/notification.go | 24 +- pkg/notify/models/receiver.go | 26 +- pkg/notify/models/robot.go | 4 +- pkg/notify/models/subscriber.go | 10 +- pkg/notify/models/template.go | 4 +- pkg/notify/policy/defaults.go | 10 +- pkg/proxy/http.go | 2 +- pkg/s3gateway/handlers/errors.go | 2 +- pkg/s3gateway/handlers/middelware.go | 2 +- pkg/s3gateway/models/cloudproviders.go | 2 +- pkg/scheduledtask/models/scheduled_tasks.go | 2 +- .../models/scheduledtask_activity.go | 14 +- .../predicates/class_metadata_predicate.go | 4 +- .../predicates/disk_schedtag_predicate.go | 6 +- .../algorithm/predicates/domain_predicate.go | 6 +- .../algorithm/predicates/network_predicate.go | 8 +- pkg/util/alipayclient/alipay.go | 2 +- pkg/util/billing/billingcycle_test.go | 102 - pkg/util/cloudinit/cloudconfig_test.go | 64 - pkg/util/encode/encode_test.go | 57 - pkg/util/fileutils2/exists.go | 20 +- pkg/util/fileutils2/seeker_test.go | 49 - pkg/util/fileutils2/sparse_test.go | 96 - pkg/util/httputils/doc.go | 15 - pkg/util/httputils/error_test.go | 103 - pkg/util/httputils/httputils_test.go | 309 - pkg/util/imagetools/doc.go | 15 - pkg/util/imagetools/image_test.go | 133 - pkg/util/influxdb/influxdb.go | 2 +- pkg/util/ipmitool/shell/boot.go | 5 +- pkg/util/ipmitool/shell/lan.go | 5 +- pkg/util/ipmitool/shell/shell.go | 5 +- pkg/util/ipmitool/shell/status.go | 3 +- pkg/util/logclient/logclient.go | 2 +- pkg/util/multipart/doc.go | 15 - pkg/util/netutils2/netutils.go | 39 +- pkg/util/netutils2/netutils_test.go | 34 - pkg/util/oidcutils/client/client.go | 2 +- pkg/util/pinyinutils/doc.go | 15 - pkg/util/printutils/doc.go | 15 - pkg/util/printutils/printjson_test.go | 68 - pkg/util/qemuimg/consts.go | 54 - pkg/util/qemuimg/init.go | 2 +- pkg/util/qemuimg/qemuimg.go | 69 +- pkg/util/qemutils/qemutils.go | 2 +- pkg/util/rand/rand_test.go | 128 - pkg/util/rbacutils/policy.go | 15 +- pkg/util/rbacutils/policygroup.go | 19 +- pkg/util/rbacutils/rbac.go | 50 +- pkg/util/redfish/bmconsole/bmconsole.go | 3 +- pkg/util/redfish/bmconsole/idrac.go | 2 +- pkg/util/redfish/bmconsole/idrac6.go | 2 +- pkg/util/redfish/bmconsole/idrac9.go | 3 +- pkg/util/redfish/bmconsole/ilo.go | 3 +- pkg/util/redfish/bmconsole/lenovo.go | 2 +- pkg/util/redfish/bmconsole/supermicro.go | 3 +- pkg/util/redfish/idrac/idrac.go | 2 +- pkg/util/redfish/ilo/ilo.go | 2 +- pkg/util/redfish/redfish.go | 4 +- pkg/util/redfish/supermicro/supermicro.go | 2 +- pkg/util/s3auth/v4_test.go | 68 - pkg/util/samlutils/demo/service.go | 4 +- pkg/util/samlutils/doc.go | 15 - pkg/util/samlutils/idp/idp.go | 6 +- pkg/util/samlutils/idp/sp.go | 2 +- pkg/util/samlutils/metadata_test.go | 670 - pkg/util/samlutils/response_test.go | 207 - pkg/util/samlutils/sp/idp.go | 2 +- pkg/util/samlutils/sp/sp.go | 4 +- pkg/util/seclib2/certfile.go | 24 +- pkg/util/seclib2/passwd.go | 8 +- pkg/util/seclib2/seclib.go | 112 +- pkg/util/seclib2/seclib_test.go | 3 +- pkg/util/shellutils/doc.go | 15 - pkg/util/streamutils/doc.go | 15 - pkg/util/version/doc.go | 15 - pkg/util/version/version_test.go | 54 - pkg/util/vmdkutils/doc.go | 15 - pkg/util/vmdkutils/vmdkutils_test.go | 58 - pkg/vpcagent/ovn/worker.go | 2 +- pkg/vpcagent/service/service.go | 2 +- pkg/webconsole/server/server.go | 2 +- pkg/yunionconf/models/parameters.go | 16 +- pkg/yunionconf/models/scopedpolicies.go | 8 +- pkg/yunionconf/models/scopedpolicybindings.go | 26 +- pkg/yunionconf/policy/defaults.go | 8 +- .../mozillazg/go-pinyin/.travis.yml | 28 - .../mozillazg/go-pinyin/CHANGELOG.md | 25 + .../github.com/mozillazg/go-pinyin/README.md | 10 +- vendor/github.com/mozillazg/go-pinyin/TODO.md | 4 + .../github.com/mozillazg/go-pinyin/pinyin.go | 8 +- .../mozillazg/go-pinyin/pinyin_dict.go | 572 +- .../smartystreets/assertions/.gitignore | 7 +- .../smartystreets/assertions/.travis.yml | 20 +- .../smartystreets/assertions/Makefile | 14 + .../smartystreets/assertions/README.md | 615 +- .../smartystreets/assertions/doc.go | 12 +- .../smartystreets/assertions/equality.go | 47 +- .../smartystreets/assertions/equality_diff.go | 37 + .../smartystreets/assertions/filter.go | 2 +- .../assertions/internal/go-diff/AUTHORS | 25 + .../assertions/internal/go-diff/CONTRIBUTORS | 32 + .../assertions/internal/go-diff/LICENSE | 20 + .../internal/go-diff/diffmatchpatch/diff.go | 1345 ++ .../go-diff/diffmatchpatch/diffmatchpatch.go | 46 + .../internal/go-diff/diffmatchpatch/match.go | 160 + .../go-diff/diffmatchpatch/mathutil.go | 23 + .../diffmatchpatch/operation_string.go | 17 + .../internal/go-diff/diffmatchpatch/patch.go | 556 + .../go-diff/diffmatchpatch/stringutil.go | 88 + .../smartystreets/assertions/messages.go | 133 +- .../smartystreets/assertions/panic.go | 19 +- .../smartystreets/assertions/serializer.go | 7 + .../smartystreets/assertions/time.go | 18 +- .../smartystreets/assertions/type.go | 20 + .../goconvey/convey/assertions.go | 2 + .../smartystreets/goconvey/convey/context.go | 22 +- .../goconvey/convey/discovery.go | 15 +- .../smartystreets/goconvey/convey/doc.go | 54 +- .../goconvey/convey/reporting/init.go | 3 +- .../goconvey/convey/reporting/problems.go | 5 +- .../goconvey/convey/reporting/reports.go | 6 +- vendor/github.com/tredoe/osutil/AUTHORS.md | 16 - .../github.com/tredoe/osutil/CONTRIBUTORS.md | 22 - .../github.com/tredoe/osutil/LICENSE-MPL.txt | 374 - .../{user => v2/userutil}/crypt/AUTHORS.md | 0 .../{user => v2/userutil}/crypt/LICENSE | 0 .../{user => v2/userutil}/crypt/README.md | 0 .../userutil}/crypt/common/base64.go | 0 .../{user => v2/userutil}/crypt/common/doc.go | 0 .../userutil}/crypt/common/salt.go | 0 .../{user => v2/userutil}/crypt/crypt.go | 10 +- .../crypt/sha512_crypt/sha512_crypt.go | 4 +- vendor/golang.org/x/crypto/AUTHORS | 3 - vendor/golang.org/x/crypto/CONTRIBUTORS | 3 - .../x/crypto/chacha20/chacha_generic.go | 4 +- .../x/crypto/curve25519/curve25519.go | 9 +- .../{subtle/aliasing.go => alias/alias.go} | 5 +- .../alias_purego.go} | 5 +- vendor/golang.org/x/crypto/pkcs12/crypto.go | 2 +- vendor/golang.org/x/crypto/ssh/certs.go | 4 +- vendor/golang.org/x/crypto/ssh/cipher.go | 11 +- vendor/golang.org/x/crypto/ssh/common.go | 4 +- vendor/golang.org/x/crypto/ssh/connection.go | 2 +- vendor/golang.org/x/crypto/ssh/keys.go | 2 +- vendor/golang.org/x/crypto/ssh/server.go | 14 +- vendor/golang.org/x/crypto/ssh/session.go | 7 +- .../x/mod/internal/lazyregexp/lazyre.go | 78 + vendor/golang.org/x/mod/module/module.go | 69 +- vendor/golang.org/x/mod/module/pseudo.go | 250 + vendor/golang.org/x/mod/semver/semver.go | 30 +- vendor/golang.org/x/net/AUTHORS | 3 - vendor/golang.org/x/net/CONTRIBUTORS | 3 - .../golang.org/x/net/bpf/vm_instructions.go | 4 +- vendor/golang.org/x/net/context/go17.go | 4 +- vendor/golang.org/x/net/html/parse.go | 2 +- vendor/golang.org/x/net/html/render.go | 4 +- vendor/golang.org/x/net/html/token.go | 4 +- .../golang.org/x/net/http/httpproxy/proxy.go | 3 +- .../x/net/http2/client_conn_pool.go | 3 +- vendor/golang.org/x/net/http2/frame.go | 22 +- vendor/golang.org/x/net/http2/hpack/encode.go | 2 +- vendor/golang.org/x/net/http2/hpack/hpack.go | 16 +- .../golang.org/x/net/http2/hpack/huffman.go | 87 +- vendor/golang.org/x/net/http2/http2.go | 8 +- vendor/golang.org/x/net/http2/server.go | 173 +- vendor/golang.org/x/net/http2/transport.go | 128 +- .../x/net/http2/writesched_priority.go | 9 +- .../x/net/internal/socket/mmsghdr_unix.go | 18 +- .../x/net/internal/socket/msghdr_linux.go | 3 - .../x/net/internal/socket/rawconn_msg.go | 48 +- .../x/net/internal/socket/sys_stub.go | 6 +- .../x/net/internal/socket/sys_unix.go | 101 +- .../x/net/internal/socket/sys_windows.go | 7 +- .../x/net/internal/socket/sys_zos_s390x.go | 38 +- .../x/net/internal/socket/zsys_darwin_386.go | 30 - ..._darwin_arm.go => zsys_freebsd_riscv64.go} | 8 +- .../net/internal/socket/zsys_openbsd_ppc64.go | 30 + .../internal/socket/zsys_openbsd_riscv64.go | 30 + .../x/net/ipv4/zsys_freebsd_riscv64.go | 52 + .../x/net/ipv6/zsys_freebsd_riscv64.go | 64 + vendor/golang.org/x/net/publicsuffix/list.go | 13 +- vendor/golang.org/x/net/publicsuffix/table.go | 18709 ++++++++-------- vendor/golang.org/x/net/trace/trace.go | 2 +- vendor/golang.org/x/sync/AUTHORS | 3 - vendor/golang.org/x/sync/CONTRIBUTORS | 3 - vendor/golang.org/x/sync/errgroup/errgroup.go | 76 +- .../golang.org/x/sys/cpu/cpu_other_ppc64x.go | 15 + vendor/golang.org/x/sys/plan9/mkerrors.sh | 4 +- vendor/golang.org/x/sys/plan9/syscall.go | 10 +- vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s | 31 + vendor/golang.org/x/sys/unix/dirent.go | 4 +- vendor/golang.org/x/sys/unix/mkall.sh | 23 +- vendor/golang.org/x/sys/unix/mkerrors.sh | 4 +- vendor/golang.org/x/sys/unix/syscall.go | 10 +- .../x/sys/unix/syscall_darwin.1_12.go | 32 - .../x/sys/unix/syscall_darwin.1_13.go | 108 - .../golang.org/x/sys/unix/syscall_darwin.go | 90 + .../x/sys/unix/syscall_freebsd_386.go | 2 +- .../x/sys/unix/syscall_freebsd_amd64.go | 2 +- .../x/sys/unix/syscall_freebsd_arm.go | 2 +- .../x/sys/unix/syscall_freebsd_arm64.go | 2 +- .../x/sys/unix/syscall_freebsd_riscv64.go | 2 +- .../golang.org/x/sys/unix/syscall_illumos.go | 106 - vendor/golang.org/x/sys/unix/syscall_linux.go | 40 +- .../x/sys/unix/syscall_linux_386.go | 4 - .../x/sys/unix/syscall_linux_amd64.go | 4 - .../x/sys/unix/syscall_linux_arm.go | 4 - .../x/sys/unix/syscall_linux_arm64.go | 4 - .../x/sys/unix/syscall_linux_loong64.go | 4 - .../x/sys/unix/syscall_linux_mips64x.go | 4 - .../x/sys/unix/syscall_linux_mipsx.go | 4 - .../x/sys/unix/syscall_linux_ppc.go | 4 - .../x/sys/unix/syscall_linux_ppc64x.go | 4 - .../x/sys/unix/syscall_linux_riscv64.go | 4 - .../x/sys/unix/syscall_linux_s390x.go | 4 - .../x/sys/unix/syscall_linux_sparc64.go | 4 - .../x/sys/unix/syscall_openbsd_libc.go | 4 +- .../x/sys/unix/syscall_openbsd_ppc64.go | 42 + .../x/sys/unix/syscall_openbsd_riscv64.go | 42 + .../golang.org/x/sys/unix/syscall_solaris.go | 215 +- vendor/golang.org/x/sys/unix/syscall_unix.go | 20 +- .../golang.org/x/sys/unix/syscall_unix_gc.go | 6 +- .../x/sys/unix/syscall_zos_s390x.go | 173 +- vendor/golang.org/x/sys/unix/sysvshm_unix.go | 13 +- vendor/golang.org/x/sys/unix/xattr_bsd.go | 95 +- .../x/sys/unix/zerrors_openbsd_ppc64.go | 1905 ++ .../x/sys/unix/zerrors_openbsd_riscv64.go | 1904 ++ .../x/sys/unix/zsyscall_darwin_amd64.1_13.go | 40 - .../x/sys/unix/zsyscall_darwin_amd64.1_13.s | 25 - .../x/sys/unix/zsyscall_darwin_amd64.go | 32 +- .../x/sys/unix/zsyscall_darwin_amd64.s | 21 +- .../x/sys/unix/zsyscall_darwin_arm64.1_13.go | 40 - .../x/sys/unix/zsyscall_darwin_arm64.1_13.s | 25 - .../x/sys/unix/zsyscall_darwin_arm64.go | 32 +- .../x/sys/unix/zsyscall_darwin_arm64.s | 21 +- .../x/sys/unix/zsyscall_illumos_amd64.go | 28 +- .../golang.org/x/sys/unix/zsyscall_linux.go | 10 + .../x/sys/unix/zsyscall_linux_386.go | 40 - .../x/sys/unix/zsyscall_linux_amd64.go | 40 - .../x/sys/unix/zsyscall_linux_arm.go | 40 - .../x/sys/unix/zsyscall_linux_arm64.go | 40 - .../x/sys/unix/zsyscall_linux_loong64.go | 40 - .../x/sys/unix/zsyscall_linux_mips.go | 40 - .../x/sys/unix/zsyscall_linux_mips64.go | 40 - .../x/sys/unix/zsyscall_linux_mips64le.go | 40 - .../x/sys/unix/zsyscall_linux_mipsle.go | 40 - .../x/sys/unix/zsyscall_linux_ppc.go | 40 - .../x/sys/unix/zsyscall_linux_ppc64.go | 40 - .../x/sys/unix/zsyscall_linux_ppc64le.go | 40 - .../x/sys/unix/zsyscall_linux_riscv64.go | 40 - .../x/sys/unix/zsyscall_linux_s390x.go | 40 - .../x/sys/unix/zsyscall_linux_sparc64.go | 40 - .../x/sys/unix/zsyscall_openbsd_ppc64.go | 2221 ++ .../x/sys/unix/zsyscall_openbsd_ppc64.s | 796 + .../x/sys/unix/zsyscall_openbsd_riscv64.go | 2221 ++ .../x/sys/unix/zsyscall_openbsd_riscv64.s | 796 + .../x/sys/unix/zsyscall_solaris_amd64.go | 28 +- .../x/sys/unix/zsysctl_openbsd_ppc64.go | 281 + .../x/sys/unix/zsysctl_openbsd_riscv64.go | 282 + .../x/sys/unix/zsysnum_openbsd_ppc64.go | 218 + .../x/sys/unix/zsysnum_openbsd_riscv64.go | 219 + .../x/sys/unix/ztypes_freebsd_386.go | 17 +- .../x/sys/unix/ztypes_freebsd_amd64.go | 18 +- .../x/sys/unix/ztypes_freebsd_arm.go | 18 +- .../x/sys/unix/ztypes_freebsd_arm64.go | 18 +- .../x/sys/unix/ztypes_freebsd_riscv64.go | 18 +- .../x/sys/unix/ztypes_illumos_amd64.go | 42 - .../golang.org/x/sys/unix/ztypes_linux_386.go | 6 + .../x/sys/unix/ztypes_linux_amd64.go | 6 + .../golang.org/x/sys/unix/ztypes_linux_arm.go | 6 + .../x/sys/unix/ztypes_linux_arm64.go | 6 + .../x/sys/unix/ztypes_linux_loong64.go | 6 + .../x/sys/unix/ztypes_linux_mips.go | 6 + .../x/sys/unix/ztypes_linux_mips64.go | 6 + .../x/sys/unix/ztypes_linux_mips64le.go | 6 + .../x/sys/unix/ztypes_linux_mipsle.go | 6 + .../golang.org/x/sys/unix/ztypes_linux_ppc.go | 6 + .../x/sys/unix/ztypes_linux_ppc64.go | 6 + .../x/sys/unix/ztypes_linux_ppc64le.go | 6 + .../x/sys/unix/ztypes_linux_riscv64.go | 6 + .../x/sys/unix/ztypes_linux_s390x.go | 6 + .../x/sys/unix/ztypes_linux_sparc64.go | 6 + .../x/sys/unix/ztypes_openbsd_ppc64.go | 571 + .../x/sys/unix/ztypes_openbsd_riscv64.go | 571 + .../x/sys/unix/ztypes_solaris_amd64.go | 35 + .../golang.org/x/sys/unix/ztypes_zos_s390x.go | 11 +- vendor/golang.org/x/sys/windows/syscall.go | 10 +- .../x/sys/windows/syscall_windows.go | 35 +- .../golang.org/x/sys/windows/types_windows.go | 45 + .../x/sys/windows/zsyscall_windows.go | 88 + vendor/golang.org/x/term/AUTHORS | 3 - vendor/golang.org/x/term/CONTRIBUTORS | 3 - vendor/golang.org/x/term/term.go | 10 +- vendor/golang.org/x/term/terminal.go | 2 +- vendor/golang.org/x/text/AUTHORS | 3 - vendor/golang.org/x/text/CONTRIBUTORS | 3 - .../x/text/encoding/htmlindex/tables.go | 9 + .../text/encoding/internal/identifier/mib.go | 8 + .../x/text/encoding/simplifiedchinese/gbk.go | 6 +- .../x/text/feature/plural/message.go | 18 +- .../x/text/feature/plural/plural.go | 51 +- .../x/text/internal/catmsg/catmsg.go | 50 +- .../text/internal/language/compact/tables.go | 6 +- .../x/text/internal/language/lookup.go | 4 +- .../x/text/internal/language/parse.go | 24 +- .../x/text/internal/language/tables.go | 868 +- .../x/text/internal/number/decimal.go | 48 +- .../internal/utf8internal/utf8internal.go | 2 +- vendor/golang.org/x/text/language/doc.go | 44 +- vendor/golang.org/x/text/language/go1_1.go | 39 - vendor/golang.org/x/text/language/go1_2.go | 12 - vendor/golang.org/x/text/language/match.go | 2 +- vendor/golang.org/x/text/language/parse.go | 8 +- vendor/golang.org/x/text/language/tables.go | 18 +- .../x/text/message/catalog/catalog.go | 85 +- vendor/golang.org/x/text/message/doc.go | 50 +- vendor/golang.org/x/text/runes/runes.go | 2 +- vendor/golang.org/x/text/unicode/bidi/core.go | 26 +- .../x/text/unicode/norm/forminfo.go | 9 +- .../x/text/unicode/norm/normalize.go | 11 +- .../x/text/unicode/norm/tables13.0.0.go | 4 +- vendor/golang.org/x/tools/AUTHORS | 3 - vendor/golang.org/x/tools/CONTRIBUTORS | 3 - .../golang.org/x/tools/cmd/goimports/doc.go | 25 +- .../x/tools/go/ast/astutil/enclosing.go | 49 +- .../x/tools/go/ast/astutil/imports.go | 7 +- .../x/tools/go/ast/astutil/rewrite.go | 17 +- .../x/tools/go/gcexportdata/gcexportdata.go | 72 +- .../x/tools/go/gcexportdata/importer.go | 2 + .../x/tools/go/internal/gcimporter/bexport.go | 43 +- .../x/tools/go/internal/gcimporter/bimport.go | 52 +- .../go/internal/gcimporter/exportdata.go | 16 +- .../go/internal/gcimporter/gcimporter.go | 171 +- .../x/tools/go/internal/gcimporter/iexport.go | 323 +- .../x/tools/go/internal/gcimporter/iimport.go | 342 +- .../go/internal/gcimporter/support_go117.go | 16 + .../go/internal/gcimporter/support_go118.go | 23 + .../go/internal/gcimporter/unified_no.go | 10 + .../go/internal/gcimporter/unified_yes.go | 10 + .../go/internal/gcimporter/ureader_no.go | 19 + .../go/internal/gcimporter/ureader_yes.go | 612 + .../x/tools/go/internal/pkgbits/codes.go | 77 + .../x/tools/go/internal/pkgbits/decoder.go | 433 + .../x/tools/go/internal/pkgbits/doc.go | 32 + .../x/tools/go/internal/pkgbits/encoder.go | 379 + .../x/tools/go/internal/pkgbits/flags.go | 9 + .../x/tools/go/internal/pkgbits/frames_go1.go | 21 + .../tools/go/internal/pkgbits/frames_go17.go | 28 + .../x/tools/go/internal/pkgbits/reloc.go | 42 + .../x/tools/go/internal/pkgbits/support.go | 17 + .../x/tools/go/internal/pkgbits/sync.go | 113 + .../go/internal/pkgbits/syncmarker_string.go | 89 + .../x/tools/internal/fastwalk/fastwalk.go | 6 +- .../x/tools/internal/gocommand/invoke.go | 22 +- .../x/tools/internal/gocommand/vendor.go | 22 +- .../x/tools/internal/gocommand/version.go | 2 +- .../x/tools/internal/gopathwalk/walk.go | 20 +- .../x/tools/internal/imports/fix.go | 4 +- .../x/tools/internal/imports/imports.go | 29 +- .../x/tools/internal/imports/mod.go | 37 +- .../x/tools/internal/imports/sortimports.go | 48 +- .../x/tools/internal/imports/zstdlib.go | 84 +- .../x/tools/internal/typeparams/common.go | 179 + .../x/tools/internal/typeparams/coretype.go | 122 + .../internal/typeparams/enabled_go117.go | 12 + .../internal/typeparams/enabled_go118.go | 15 + .../x/tools/internal/typeparams/normalize.go | 218 + .../x/tools/internal/typeparams/termlist.go | 163 + .../internal/typeparams/typeparams_go117.go | 197 + .../internal/typeparams/typeparams_go118.go | 151 + .../x/tools/internal/typeparams/typeterm.go | 170 + .../wireguard/wgctrl/LICENSE.md | 2 +- .../wireguard/wgctrl/wgtypes/errors.go | 10 + .../wireguard/wgctrl/wgtypes/types.go | 10 + vendor/gopkg.in/ini.v1/.travis.yml | 18 - vendor/gopkg.in/ini.v1/Makefile | 2 +- vendor/gopkg.in/ini.v1/README.md | 19 +- vendor/gopkg.in/ini.v1/codecov.yml | 9 + vendor/gopkg.in/ini.v1/data_source.go | 76 + vendor/gopkg.in/ini.v1/deprecated.go | 25 + vendor/gopkg.in/ini.v1/file.go | 177 +- vendor/gopkg.in/ini.v1/helper.go | 24 + vendor/gopkg.in/ini.v1/ini.go | 113 +- vendor/gopkg.in/ini.v1/key.go | 156 +- vendor/gopkg.in/ini.v1/parser.go | 84 +- vendor/gopkg.in/ini.v1/section.go | 14 +- vendor/gopkg.in/ini.v1/struct.go | 327 +- vendor/modules.txt | 84 +- vendor/yunion.io/x/cloudmux/pkg/apis/const.go | 4 + .../yunion.io/x/cloudmux/pkg/apis/metadata.go | 1 - .../pkg/cloudprovider/cloudprovider.go | 3 +- .../cloudmux/pkg/cloudprovider/dbinstance.go | 2 +- .../pkg/cloudprovider/elasticcache.go | 2 +- .../x/cloudmux/pkg/cloudprovider/instance.go | 12 +- .../pkg/cloudprovider/loadbalancer.go | 2 +- .../x/cloudmux/pkg/cloudprovider/nas.go | 2 +- .../x/cloudmux/pkg/cloudprovider/nat.go | 2 +- .../x/cloudmux/pkg/cloudprovider/resources.go | 11 +- .../x/cloudmux/pkg/cloudprovider/saml.go | 2 +- .../cloudmux/pkg/multicloud/aliyun/aliyun.go | 3 +- .../pkg/multicloud/aliyun/dbinstance.go | 4 +- .../aliyun/elasticcache_instance.go | 2 +- .../x/cloudmux/pkg/multicloud/aliyun/host.go | 2 +- .../x/cloudmux/pkg/multicloud/aliyun/image.go | 2 +- .../pkg/multicloud/aliyun/instance.go | 4 +- .../pkg/multicloud/aliyun/saml_provider.go | 4 +- .../pkg/multicloud/aliyun/storagecache.go | 4 +- .../cloudmux/pkg/multicloud/aliyun/vswitch.go | 6 +- .../cloudmux/pkg/multicloud/apsara/apsara.go | 2 +- .../pkg/multicloud/apsara/dbinstance.go | 4 +- .../apsara/elasticcache_instance.go | 2 +- .../x/cloudmux/pkg/multicloud/apsara/host.go | 2 +- .../x/cloudmux/pkg/multicloud/apsara/image.go | 2 +- .../pkg/multicloud/apsara/instance.go | 4 +- .../pkg/multicloud/apsara/storagecache.go | 4 +- .../cloudmux/pkg/multicloud/apsara/vswitch.go | 6 +- .../x/cloudmux/pkg/multicloud/aws/bucket.go | 6 +- .../multicloud/aws/elasticache_instance.go | 2 +- .../x/cloudmux/pkg/multicloud/aws/image.go | 2 +- .../x/cloudmux/pkg/multicloud/aws/instance.go | 4 +- .../x/cloudmux/pkg/multicloud/aws/network.go | 6 +- .../pkg/multicloud/aws/saml_provider.go | 4 +- .../pkg/multicloud/aws/storagecache.go | 6 +- .../x/cloudmux/pkg/multicloud/azure/azure.go | 2 +- .../pkg/multicloud/azure/classic_instance.go | 2 +- .../pkg/multicloud/azure/classic_network.go | 6 +- .../pkg/multicloud/azure/clouduser.go | 2 +- .../x/cloudmux/pkg/multicloud/azure/host.go | 4 +- .../cloudmux/pkg/multicloud/azure/instance.go | 4 +- .../pkg/multicloud/azure/loganalytics.go | 2 +- .../cloudmux/pkg/multicloud/azure/monitor.go | 2 +- .../cloudmux/pkg/multicloud/azure/network.go | 6 +- .../pkg/multicloud/azure/saml_provider.go | 4 +- .../pkg/multicloud/azure/storagecache.go | 8 +- .../x/cloudmux/pkg/multicloud/billing_base.go | 2 +- .../pkg/multicloud/bingocloud/bingo.go | 2 +- .../pkg/multicloud/bingocloud/image.go | 10 +- .../pkg/multicloud/bingocloud/network.go | 6 +- .../cloudmux/pkg/multicloud/cloudpods/doc.go | 15 - .../x/cloudmux/pkg/multicloud/ctyun/ctyun.go | 2 +- .../x/cloudmux/pkg/multicloud/ctyun/image.go | 2 +- .../cloudmux/pkg/multicloud/ctyun/instance.go | 2 +- .../cloudmux/pkg/multicloud/ctyun/network.go | 6 +- .../pkg/multicloud/dbinstance_base.go | 2 +- .../cloudmux/pkg/multicloud/ecloud/client.go | 2 +- .../x/cloudmux/pkg/multicloud/ecloud/image.go | 2 +- .../pkg/multicloud/ecloud/instance.go | 2 +- .../cloudmux/pkg/multicloud/ecloud/network.go | 6 +- .../cloudmux/pkg/multicloud/ecloud/request.go | 4 +- .../x/cloudmux/pkg/multicloud/esxi/image.go | 3 +- .../x/cloudmux/pkg/multicloud/esxi/manager.go | 2 +- .../x/cloudmux/pkg/multicloud/esxi/storage.go | 2 +- .../x/cloudmux/pkg/multicloud/esxi/vdisk.go | 7 +- .../pkg/multicloud/esxi/virtualmachine.go | 65 +- .../pkg/multicloud/google/dbinstance.go | 2 +- .../cloudmux/pkg/multicloud/google/google.go | 2 +- .../x/cloudmux/pkg/multicloud/google/image.go | 2 +- .../pkg/multicloud/google/instance.go | 10 +- .../cloudmux/pkg/multicloud/google/network.go | 6 +- .../pkg/multicloud/google/storagecache.go | 4 +- .../pkg/multicloud/google/tag_base.go | 2 +- .../cloudmux/pkg/multicloud/hcs/dbinstance.go | 4 +- .../pkg/multicloud/hcs/external_network.go | 6 +- .../x/cloudmux/pkg/multicloud/hcs/hcs.go | 2 +- .../x/cloudmux/pkg/multicloud/hcs/host.go | 2 +- .../x/cloudmux/pkg/multicloud/hcs/image.go | 2 +- .../x/cloudmux/pkg/multicloud/hcs/instance.go | 6 +- .../x/cloudmux/pkg/multicloud/hcs/monitor.go | 2 +- .../x/cloudmux/pkg/multicloud/hcs/network.go | 6 +- .../x/cloudmux/pkg/multicloud/hcs/redis.go | 2 +- .../pkg/multicloud/hcs/storagecache.go | 5 +- .../hcso/client/modules/manager_base.go | 2 +- .../pkg/multicloud/hcso/dbinstance.go | 2 +- .../multicloud/hcso/elasticcache_instance.go | 2 +- .../x/cloudmux/pkg/multicloud/hcso/hcso.go | 2 +- .../x/cloudmux/pkg/multicloud/hcso/host.go | 2 +- .../x/cloudmux/pkg/multicloud/hcso/image.go | 2 +- .../cloudmux/pkg/multicloud/hcso/instance.go | 6 +- .../cloudmux/pkg/multicloud/hcso/modelarts.go | 2 +- .../x/cloudmux/pkg/multicloud/hcso/network.go | 6 +- .../pkg/multicloud/hcso/saml_provider.go | 2 +- .../pkg/multicloud/hcso/storagecache.go | 4 +- .../x/cloudmux/pkg/multicloud/hcso/utils.go | 3 +- .../huawei/client/modules/manager_base.go | 2 +- .../pkg/multicloud/huawei/dbinstance.go | 2 +- .../huawei/elasticcache_instance.go | 2 +- .../x/cloudmux/pkg/multicloud/huawei/host.go | 2 +- .../cloudmux/pkg/multicloud/huawei/huawei.go | 3 +- .../x/cloudmux/pkg/multicloud/huawei/image.go | 2 +- .../pkg/multicloud/huawei/instance.go | 4 +- .../pkg/multicloud/huawei/modelarts_pool.go | 2 +- .../cloudmux/pkg/multicloud/huawei/network.go | 6 +- .../pkg/multicloud/huawei/saml_provider.go | 2 +- .../pkg/multicloud/huawei/storagecache.go | 4 +- .../x/cloudmux/pkg/multicloud/huawei/utils.go | 2 +- .../x/cloudmux/pkg/multicloud/image_base.go | 7 +- .../pkg/multicloud/incloudsphere/image.go | 3 +- .../pkg/multicloud/incloudsphere/instance.go | 2 +- .../pkg/multicloud/incloudsphere/network.go | 6 +- .../pkg/multicloud/incloudsphere/sphere.go | 2 +- .../cloudmux/pkg/multicloud/jdcloud/image.go | 2 +- .../pkg/multicloud/jdcloud/instance.go | 2 +- .../pkg/multicloud/jdcloud/network.go | 6 +- .../cloudmux/pkg/multicloud/loader/loader.go | 2 +- .../cloudmux/pkg/multicloud/nutanix/image.go | 2 +- .../pkg/multicloud/nutanix/network.go | 6 +- .../pkg/multicloud/nutanix/nutanix.go | 2 +- .../pkg/multicloud/nutanix/storagecache.go | 4 +- .../multicloud/objectstore/ceph/adminapi.go | 6 +- .../pkg/multicloud/objectstore/ceph/ceph.go | 2 +- .../pkg/multicloud/objectstore/objectstore.go | 4 +- .../pkg/multicloud/objectstore/shell.go | 12 +- .../multicloud/objectstore/xsky/adminapi.go | 3 +- .../pkg/multicloud/objectstore/xsky/xsky.go | 2 +- .../cloudmux/pkg/multicloud/openstack/disk.go | 2 +- .../pkg/multicloud/openstack/image.go | 14 +- .../pkg/multicloud/openstack/instance.go | 2 +- .../pkg/multicloud/openstack/keypaire.go | 2 +- .../pkg/multicloud/openstack/network.go | 8 +- .../pkg/multicloud/openstack/openstack.go | 12 +- .../pkg/multicloud/openstack/oscli/const.go | 19 + .../pkg/multicloud/openstack/oscli/oscli.go | 26 +- .../pkg/multicloud/openstack/oscli/session.go | 19 +- .../pkg/multicloud/openstack/oscli/token.go | 13 +- .../pkg/multicloud/openstack/oscli/token2.go | 24 +- .../pkg/multicloud/openstack/oscli/token3.go | 20 +- .../multicloud/openstack/oscli/tokensimple.go | 20 +- .../pkg/multicloud/openstack/project.go | 3 +- .../pkg/multicloud/openstack/region.go | 2 +- .../pkg/multicloud/openstack/roles.go | 2 +- .../pkg/multicloud/openstack/securitygroup.go | 2 +- .../pkg/multicloud/openstack/storagecache.go | 4 +- .../cloudmux/pkg/multicloud/proxmox/image.go | 2 +- .../pkg/multicloud/proxmox/network.go | 6 +- .../pkg/multicloud/proxmox/proxmox.go | 2 +- .../qcloud/elasticcache_instance.go | 2 +- .../x/cloudmux/pkg/multicloud/qcloud/host.go | 2 +- .../x/cloudmux/pkg/multicloud/qcloud/image.go | 2 +- .../pkg/multicloud/qcloud/instance.go | 4 +- .../pkg/multicloud/qcloud/loadbalancer.go | 1 + .../pkg/multicloud/qcloud/memcached.go | 2 +- .../cloudmux/pkg/multicloud/qcloud/network.go | 6 +- .../cloudmux/pkg/multicloud/qcloud/qcloud.go | 2 +- .../pkg/multicloud/qcloud/rds_mysql.go | 2 +- .../pkg/multicloud/qcloud/saml_provider.go | 2 +- .../pkg/multicloud/qcloud/storagecache.go | 4 +- .../cloudmux/pkg/multicloud/remotefile/doc.go | 14 + .../cloudmux/pkg/multicloud/remotefile/eip.go | 3 +- .../pkg/multicloud/remotefile/instance.go | 3 +- .../pkg/multicloud/remotefile/network.go | 7 +- .../pkg/multicloud/remotefile/remotefile.go | 2 +- .../cloudmux/pkg/multicloud/ucloud/client.go | 2 +- .../x/cloudmux/pkg/multicloud/ucloud/host.go | 2 +- .../x/cloudmux/pkg/multicloud/ucloud/image.go | 2 +- .../pkg/multicloud/ucloud/instance.go | 4 +- .../cloudmux/pkg/multicloud/ucloud/network.go | 6 +- .../pkg/multicloud/ucloud/storagecache.go | 6 +- .../x/cloudmux/pkg/multicloud/ucloud/ufile.go | 2 +- .../x/cloudmux/pkg/multicloud/zstack/image.go | 6 +- .../pkg/multicloud/zstack/instance.go | 6 +- .../cloudmux/pkg/multicloud/zstack/network.go | 6 +- .../pkg/multicloud/zstack/storagecache.go | 7 +- .../cloudmux/pkg/multicloud/zstack/zstack.go | 5 +- .../yunion.io/x/pkg}/appctx/appctx.go | 0 .../yunion.io/x/pkg}/appctx/context.go | 0 {pkg => vendor/yunion.io/x/pkg}/appctx/doc.go | 2 +- .../yunion.io/x/pkg}/appctx/i18n.go | 0 vendor/yunion.io/x/pkg/errors/consts.go | 4 + .../yunion.io/x/pkg/object}/doc.go | 2 +- .../yunion.io/x/pkg}/object/object.go | 0 .../x/pkg}/util/billing/billingcycle.go | 0 .../yunion.io/x/pkg/util/billing}/doc.go | 2 +- .../x/pkg}/util/cloudinit/cloudconfig.go | 5 +- .../yunion.io/x/pkg/util/cloudinit}/doc.go | 2 +- vendor/yunion.io/x/pkg/util/encode/doc.go | 15 + .../yunion.io/x/pkg}/util/encode/encode.go | 0 .../x/pkg/util/fileutils/fileutils.go | 35 + .../yunion.io/x/pkg/util/fileutils}/seeker.go | 2 +- .../yunion.io/x/pkg/util/fileutils}/sparse.go | 2 +- .../x/pkg}/util/httputils/delegate.go | 0 vendor/yunion.io/x/pkg/util/httputils/doc.go | 15 + .../yunion.io/x/pkg}/util/httputils/error.go | 0 .../yunion.io/x/pkg}/util/httputils/fs.go | 0 .../x/pkg}/util/httputils/httputils.go | 3 +- vendor/yunion.io/x/pkg/util/imagetools/doc.go | 15 + .../x/pkg}/util/imagetools/imagetools.go | 28 +- vendor/yunion.io/x/pkg/util/multipart/doc.go | 15 + .../yunion.io/x/pkg}/util/multipart/reader.go | 0 .../yunion.io/x/pkg/util/netutils/netutils.go | 42 + vendor/yunion.io/x/pkg/util/osprofile/arch.go | 51 + .../yunion.io/x/pkg/util/pinyinutils/doc.go | 15 + .../x/pkg}/util/pinyinutils/pinyin.go | 0 vendor/yunion.io/x/pkg/util/printutils/doc.go | 15 + .../x/pkg}/util/printutils/printgetter.go | 4 +- .../x/pkg}/util/printutils/printjson.go | 12 +- .../x/pkg}/util/printutils/printobj.go | 4 +- .../yunion.io/x/pkg/util/printutils/struct.go | 29 +- .../x/pkg}/util/printutils/termwidth_unix.go | 0 .../pkg}/util/printutils/termwidth_windows.go | 3 +- vendor/yunion.io/x/pkg/util/qemuimgfmt/doc.go | 15 + vendor/yunion.io/x/pkg/util/qemuimgfmt/fmt.go | 68 + vendor/yunion.io/x/pkg/util/rand/doc.go | 15 + .../yunion.io/x/pkg}/util/rand/rand.go | 0 vendor/yunion.io/x/pkg/util/rbacscope/doc.go | 15 + .../yunion.io/x/pkg/util/rbacscope/scope.go | 69 + vendor/yunion.io/x/pkg/util/s3auth/doc.go | 15 + .../yunion.io/x/pkg}/util/s3auth/interface.go | 0 .../yunion.io/x/pkg}/util/s3auth/utils.go | 0 .../yunion.io/x/pkg}/util/s3auth/v2.go | 0 .../yunion.io/x/pkg}/util/s3auth/v4.go | 3 +- .../yunion.io/x/pkg}/util/samlutils/consts.go | 0 vendor/yunion.io/x/pkg/util/samlutils/doc.go | 15 + .../x/pkg}/util/samlutils/encrypt.go | 13 +- .../x/pkg}/util/samlutils/instance.go | 0 .../x/pkg}/util/samlutils/metadata.go | 0 .../x/pkg}/util/samlutils/request.go | 0 .../x/pkg}/util/samlutils/response.go | 0 .../yunion.io/x/pkg}/util/samlutils/types.go | 0 .../yunion.io/x/pkg}/util/samlutils/util.go | 0 vendor/yunion.io/x/pkg/util/seclib/certs.go | 46 + vendor/yunion.io/x/pkg/util/seclib/seclib.go | 116 +- vendor/yunion.io/x/pkg/util/shellutils/doc.go | 15 + .../yunion.io/x/pkg}/util/shellutils/edit.go | 0 .../yunion.io/x/pkg}/util/shellutils/shell.go | 0 .../yunion.io/x/pkg/util/streamutils/doc.go | 15 + .../x/pkg}/util/streamutils/streamutils.go | 0 .../yunion.io/x/pkg/util/version/compare.go | 0 vendor/yunion.io/x/pkg/util/vmdkutils/doc.go | 15 + .../x/pkg}/util/vmdkutils/vmdkutils.go | 0 1123 files changed, 36590 insertions(+), 19291 deletions(-) create mode 100644 cmd/cloudpodscli/main.go rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/cloudpods.go (98%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/disk.go (99%) rename pkg/{cloudcommon/object => mcclient/cloudpods}/doc.go (88%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/eip.go (99%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/host.go (99%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/image.go (97%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/instance.go (99%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/instancenic.go (99%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/keypair.go (100%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/network.go (95%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/project.go (100%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/provider/doc.go (100%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/provider/provider.go (98%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/region.go (99%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/secgroup.go (99%) create mode 100644 pkg/mcclient/cloudpods/shell/disk.go rename pkg/{util/cloudinit => mcclient/cloudpods/shell}/doc.go (88%) create mode 100644 pkg/mcclient/cloudpods/shell/hosts.go create mode 100644 pkg/mcclient/cloudpods/shell/image.go create mode 100644 pkg/mcclient/cloudpods/shell/instance.go create mode 100644 pkg/mcclient/cloudpods/shell/network.go rename pkg/{util/billing/doc.go => mcclient/cloudpods/shell/printutils.go} (67%) create mode 100644 pkg/mcclient/cloudpods/shell/region.go create mode 100644 pkg/mcclient/cloudpods/shell/secgroup.go rename pkg/{util/pinyinutils/pinyin_test.go => mcclient/cloudpods/shell/vpc.go} (62%) create mode 100644 pkg/mcclient/cloudpods/shell/wire.go create mode 100644 pkg/mcclient/cloudpods/shell/zones.go rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/sku.go (100%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/snapshot.go (99%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/storage.go (99%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/storagecache.go (99%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/tag_base.go (99%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/vpc.go (99%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/wire.go (99%) rename {vendor/yunion.io/x/cloudmux/pkg/multicloud => pkg/mcclient}/cloudpods/zone.go (99%) delete mode 100644 pkg/util/billing/billingcycle_test.go delete mode 100644 pkg/util/cloudinit/cloudconfig_test.go delete mode 100644 pkg/util/encode/encode_test.go delete mode 100644 pkg/util/fileutils2/seeker_test.go delete mode 100644 pkg/util/fileutils2/sparse_test.go delete mode 100644 pkg/util/httputils/doc.go delete mode 100644 pkg/util/httputils/error_test.go delete mode 100644 pkg/util/httputils/httputils_test.go delete mode 100644 pkg/util/imagetools/doc.go delete mode 100644 pkg/util/imagetools/image_test.go delete mode 100644 pkg/util/multipart/doc.go delete mode 100644 pkg/util/pinyinutils/doc.go delete mode 100644 pkg/util/printutils/doc.go delete mode 100644 pkg/util/printutils/printjson_test.go delete mode 100644 pkg/util/rand/rand_test.go delete mode 100644 pkg/util/s3auth/v4_test.go delete mode 100644 pkg/util/samlutils/doc.go delete mode 100644 pkg/util/samlutils/metadata_test.go delete mode 100644 pkg/util/samlutils/response_test.go delete mode 100644 pkg/util/shellutils/doc.go delete mode 100644 pkg/util/streamutils/doc.go delete mode 100644 pkg/util/version/doc.go delete mode 100644 pkg/util/version/version_test.go delete mode 100644 pkg/util/vmdkutils/doc.go delete mode 100644 pkg/util/vmdkutils/vmdkutils_test.go delete mode 100644 vendor/github.com/mozillazg/go-pinyin/.travis.yml create mode 100644 vendor/github.com/mozillazg/go-pinyin/TODO.md create mode 100644 vendor/github.com/smartystreets/assertions/Makefile create mode 100644 vendor/github.com/smartystreets/assertions/equality_diff.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/go-diff/AUTHORS create mode 100644 vendor/github.com/smartystreets/assertions/internal/go-diff/CONTRIBUTORS create mode 100644 vendor/github.com/smartystreets/assertions/internal/go-diff/LICENSE create mode 100644 vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/diff.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/diffmatchpatch.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/match.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/mathutil.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/operation_string.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/patch.go create mode 100644 vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/stringutil.go delete mode 100644 vendor/github.com/tredoe/osutil/AUTHORS.md delete mode 100644 vendor/github.com/tredoe/osutil/CONTRIBUTORS.md delete mode 100644 vendor/github.com/tredoe/osutil/LICENSE-MPL.txt rename vendor/github.com/tredoe/osutil/{user => v2/userutil}/crypt/AUTHORS.md (100%) rename vendor/github.com/tredoe/osutil/{user => v2/userutil}/crypt/LICENSE (100%) rename vendor/github.com/tredoe/osutil/{user => v2/userutil}/crypt/README.md (100%) rename vendor/github.com/tredoe/osutil/{user => v2/userutil}/crypt/common/base64.go (100%) rename vendor/github.com/tredoe/osutil/{user => v2/userutil}/crypt/common/doc.go (100%) rename vendor/github.com/tredoe/osutil/{user => v2/userutil}/crypt/common/salt.go (100%) rename vendor/github.com/tredoe/osutil/{user => v2/userutil}/crypt/crypt.go (88%) rename vendor/github.com/tredoe/osutil/{user => v2/userutil}/crypt/sha512_crypt/sha512_crypt.go (98%) delete mode 100644 vendor/golang.org/x/crypto/AUTHORS delete mode 100644 vendor/golang.org/x/crypto/CONTRIBUTORS rename vendor/golang.org/x/crypto/internal/{subtle/aliasing.go => alias/alias.go} (84%) rename vendor/golang.org/x/crypto/internal/{subtle/aliasing_purego.go => alias/alias_purego.go} (86%) create mode 100644 vendor/golang.org/x/mod/internal/lazyregexp/lazyre.go create mode 100644 vendor/golang.org/x/mod/module/pseudo.go delete mode 100644 vendor/golang.org/x/net/AUTHORS delete mode 100644 vendor/golang.org/x/net/CONTRIBUTORS delete mode 100644 vendor/golang.org/x/net/internal/socket/zsys_darwin_386.go rename vendor/golang.org/x/net/internal/socket/{zsys_darwin_arm.go => zsys_freebsd_riscv64.go} (79%) create mode 100644 vendor/golang.org/x/net/internal/socket/zsys_openbsd_ppc64.go create mode 100644 vendor/golang.org/x/net/internal/socket/zsys_openbsd_riscv64.go create mode 100644 vendor/golang.org/x/net/ipv4/zsys_freebsd_riscv64.go create mode 100644 vendor/golang.org/x/net/ipv6/zsys_freebsd_riscv64.go delete mode 100644 vendor/golang.org/x/sync/AUTHORS delete mode 100644 vendor/golang.org/x/sync/CONTRIBUTORS create mode 100644 vendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go create mode 100644 vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s delete mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin.1_12.go delete mode 100644 vendor/golang.org/x/sys/unix/syscall_darwin.1_13.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_openbsd_ppc64.go create mode 100644 vendor/golang.org/x/sys/unix/syscall_openbsd_riscv64.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_openbsd_ppc64.go create mode 100644 vendor/golang.org/x/sys/unix/zerrors_openbsd_riscv64.go delete mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.go delete mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.s delete mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go delete mode 100644 vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.s create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go create mode 100644 vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s create mode 100644 vendor/golang.org/x/sys/unix/zsysctl_openbsd_ppc64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysctl_openbsd_riscv64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_openbsd_ppc64.go create mode 100644 vendor/golang.org/x/sys/unix/zsysnum_openbsd_riscv64.go delete mode 100644 vendor/golang.org/x/sys/unix/ztypes_illumos_amd64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_openbsd_ppc64.go create mode 100644 vendor/golang.org/x/sys/unix/ztypes_openbsd_riscv64.go delete mode 100644 vendor/golang.org/x/term/AUTHORS delete mode 100644 vendor/golang.org/x/term/CONTRIBUTORS delete mode 100644 vendor/golang.org/x/text/AUTHORS delete mode 100644 vendor/golang.org/x/text/CONTRIBUTORS delete mode 100644 vendor/golang.org/x/text/language/go1_1.go delete mode 100644 vendor/golang.org/x/text/language/go1_2.go delete mode 100644 vendor/golang.org/x/tools/AUTHORS delete mode 100644 vendor/golang.org/x/tools/CONTRIBUTORS create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/support_go117.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/support_go118.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/unified_no.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/unified_yes.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/ureader_no.go create mode 100644 vendor/golang.org/x/tools/go/internal/gcimporter/ureader_yes.go create mode 100644 vendor/golang.org/x/tools/go/internal/pkgbits/codes.go create mode 100644 vendor/golang.org/x/tools/go/internal/pkgbits/decoder.go create mode 100644 vendor/golang.org/x/tools/go/internal/pkgbits/doc.go create mode 100644 vendor/golang.org/x/tools/go/internal/pkgbits/encoder.go create mode 100644 vendor/golang.org/x/tools/go/internal/pkgbits/flags.go create mode 100644 vendor/golang.org/x/tools/go/internal/pkgbits/frames_go1.go create mode 100644 vendor/golang.org/x/tools/go/internal/pkgbits/frames_go17.go create mode 100644 vendor/golang.org/x/tools/go/internal/pkgbits/reloc.go create mode 100644 vendor/golang.org/x/tools/go/internal/pkgbits/support.go create mode 100644 vendor/golang.org/x/tools/go/internal/pkgbits/sync.go create mode 100644 vendor/golang.org/x/tools/go/internal/pkgbits/syncmarker_string.go create mode 100644 vendor/golang.org/x/tools/internal/typeparams/common.go create mode 100644 vendor/golang.org/x/tools/internal/typeparams/coretype.go create mode 100644 vendor/golang.org/x/tools/internal/typeparams/enabled_go117.go create mode 100644 vendor/golang.org/x/tools/internal/typeparams/enabled_go118.go create mode 100644 vendor/golang.org/x/tools/internal/typeparams/normalize.go create mode 100644 vendor/golang.org/x/tools/internal/typeparams/termlist.go create mode 100644 vendor/golang.org/x/tools/internal/typeparams/typeparams_go117.go create mode 100644 vendor/golang.org/x/tools/internal/typeparams/typeparams_go118.go create mode 100644 vendor/golang.org/x/tools/internal/typeparams/typeterm.go create mode 100644 vendor/golang.zx2c4.com/wireguard/wgctrl/wgtypes/errors.go delete mode 100644 vendor/gopkg.in/ini.v1/.travis.yml create mode 100644 vendor/gopkg.in/ini.v1/codecov.yml create mode 100644 vendor/gopkg.in/ini.v1/data_source.go create mode 100644 vendor/gopkg.in/ini.v1/deprecated.go create mode 100644 vendor/gopkg.in/ini.v1/helper.go delete mode 100644 vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/doc.go create mode 100644 vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/const.go rename {pkg => vendor/yunion.io/x/pkg}/appctx/appctx.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/appctx/context.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/appctx/doc.go (90%) rename {pkg => vendor/yunion.io/x/pkg}/appctx/i18n.go (100%) rename {pkg/util/rand => vendor/yunion.io/x/pkg/object}/doc.go (90%) rename {pkg/cloudcommon => vendor/yunion.io/x/pkg}/object/object.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/util/billing/billingcycle.go (100%) rename {pkg/util/encode => vendor/yunion.io/x/pkg/util/billing}/doc.go (90%) rename {pkg => vendor/yunion.io/x/pkg}/util/cloudinit/cloudconfig.go (99%) rename {pkg/util/s3auth => vendor/yunion.io/x/pkg/util/cloudinit}/doc.go (90%) create mode 100644 vendor/yunion.io/x/pkg/util/encode/doc.go rename {pkg => vendor/yunion.io/x/pkg}/util/encode/encode.go (100%) create mode 100644 vendor/yunion.io/x/pkg/util/fileutils/fileutils.go rename {pkg/util/fileutils2 => vendor/yunion.io/x/pkg/util/fileutils}/seeker.go (99%) rename {pkg/util/fileutils2 => vendor/yunion.io/x/pkg/util/fileutils}/sparse.go (98%) rename {pkg => vendor/yunion.io/x/pkg}/util/httputils/delegate.go (100%) create mode 100644 vendor/yunion.io/x/pkg/util/httputils/doc.go rename {pkg => vendor/yunion.io/x/pkg}/util/httputils/error.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/util/httputils/fs.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/util/httputils/httputils.go (99%) create mode 100644 vendor/yunion.io/x/pkg/util/imagetools/doc.go rename {pkg => vendor/yunion.io/x/pkg}/util/imagetools/imagetools.go (93%) create mode 100644 vendor/yunion.io/x/pkg/util/multipart/doc.go rename {pkg => vendor/yunion.io/x/pkg}/util/multipart/reader.go (100%) create mode 100644 vendor/yunion.io/x/pkg/util/osprofile/arch.go create mode 100644 vendor/yunion.io/x/pkg/util/pinyinutils/doc.go rename {pkg => vendor/yunion.io/x/pkg}/util/pinyinutils/pinyin.go (100%) create mode 100644 vendor/yunion.io/x/pkg/util/printutils/doc.go rename {pkg => vendor/yunion.io/x/pkg}/util/printutils/printgetter.go (96%) rename {pkg => vendor/yunion.io/x/pkg}/util/printutils/printjson.go (94%) rename {pkg => vendor/yunion.io/x/pkg}/util/printutils/printobj.go (93%) rename pkg/util/multipart/reader_test.go => vendor/yunion.io/x/pkg/util/printutils/struct.go (65%) rename {pkg => vendor/yunion.io/x/pkg}/util/printutils/termwidth_unix.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/util/printutils/termwidth_windows.go (97%) create mode 100644 vendor/yunion.io/x/pkg/util/qemuimgfmt/doc.go create mode 100644 vendor/yunion.io/x/pkg/util/qemuimgfmt/fmt.go create mode 100644 vendor/yunion.io/x/pkg/util/rand/doc.go rename {pkg => vendor/yunion.io/x/pkg}/util/rand/rand.go (100%) create mode 100644 vendor/yunion.io/x/pkg/util/rbacscope/doc.go create mode 100644 vendor/yunion.io/x/pkg/util/rbacscope/scope.go create mode 100644 vendor/yunion.io/x/pkg/util/s3auth/doc.go rename {pkg => vendor/yunion.io/x/pkg}/util/s3auth/interface.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/util/s3auth/utils.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/util/s3auth/v2.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/util/s3auth/v4.go (99%) rename {pkg => vendor/yunion.io/x/pkg}/util/samlutils/consts.go (100%) create mode 100644 vendor/yunion.io/x/pkg/util/samlutils/doc.go rename {pkg => vendor/yunion.io/x/pkg}/util/samlutils/encrypt.go (85%) rename {pkg => vendor/yunion.io/x/pkg}/util/samlutils/instance.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/util/samlutils/metadata.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/util/samlutils/request.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/util/samlutils/response.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/util/samlutils/types.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/util/samlutils/util.go (100%) create mode 100644 vendor/yunion.io/x/pkg/util/seclib/certs.go create mode 100644 vendor/yunion.io/x/pkg/util/shellutils/doc.go rename {pkg => vendor/yunion.io/x/pkg}/util/shellutils/edit.go (100%) rename {pkg => vendor/yunion.io/x/pkg}/util/shellutils/shell.go (100%) create mode 100644 vendor/yunion.io/x/pkg/util/streamutils/doc.go rename {pkg => vendor/yunion.io/x/pkg}/util/streamutils/streamutils.go (100%) rename pkg/util/version/version.go => vendor/yunion.io/x/pkg/util/version/compare.go (100%) create mode 100644 vendor/yunion.io/x/pkg/util/vmdkutils/doc.go rename {pkg => vendor/yunion.io/x/pkg}/util/vmdkutils/vmdkutils.go (100%) diff --git a/cmd/climc/entry/climc.go b/cmd/climc/entry/climc.go index 17f4c5efc3..f986fc7430 100644 --- a/cmd/climc/entry/climc.go +++ b/cmd/climc/entry/climc.go @@ -33,13 +33,13 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/version" "yunion.io/x/structarg" "yunion.io/x/onecloud/cmd/climc/promputils" "yunion.io/x/onecloud/cmd/climc/shell" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" ) type BaseOptions struct { diff --git a/cmd/climc/shell/ansible/common.go b/cmd/climc/shell/ansible/common.go index 9f3cf162c8..543ee07a3e 100644 --- a/cmd/climc/shell/ansible/common.go +++ b/cmd/climc/shell/ansible/common.go @@ -15,8 +15,9 @@ package ansible import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/cloudevent/common.go b/cmd/climc/shell/cloudevent/common.go index 3550993e99..4b48788ba8 100644 --- a/cmd/climc/shell/cloudevent/common.go +++ b/cmd/climc/shell/cloudevent/common.go @@ -15,8 +15,9 @@ package cloudevent import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/cloudid/common.go b/cmd/climc/shell/cloudid/common.go index 4e6a42505d..c7eae89061 100644 --- a/cmd/climc/shell/cloudid/common.go +++ b/cmd/climc/shell/cloudid/common.go @@ -15,8 +15,9 @@ package cloudid import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/cloudnet/common.go b/cmd/climc/shell/cloudnet/common.go index 2e1ad2e489..04990f458e 100644 --- a/cmd/climc/shell/cloudnet/common.go +++ b/cmd/climc/shell/cloudnet/common.go @@ -15,8 +15,9 @@ package cloudnet import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/compute/baremetalnetworks.go b/cmd/climc/shell/compute/baremetalnetworks.go index 1183c4281c..841069c7a0 100644 --- a/cmd/climc/shell/compute/baremetalnetworks.go +++ b/cmd/climc/shell/compute/baremetalnetworks.go @@ -16,9 +16,9 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -42,7 +42,7 @@ func init() { if len(args.Network) > 0 { params.Add(jsonutils.NewString(args.Network), "network_id") } - var result *modulebase.ListResult + var result *printutils.ListResult var err error if len(args.Host) > 0 { result, err = modules.Baremetalnetworks.ListDescendent(s, args.Host, params) diff --git a/cmd/climc/shell/compute/baremetalstorages.go b/cmd/climc/shell/compute/baremetalstorages.go index db15fd9722..748d960d14 100644 --- a/cmd/climc/shell/compute/baremetalstorages.go +++ b/cmd/climc/shell/compute/baremetalstorages.go @@ -16,9 +16,9 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -38,7 +38,7 @@ func init() { } } - var result *modulebase.ListResult + var result *printutils.ListResult var err error if len(args.Host) > 0 { result, err = modules.Baremetalstorages.ListDescendent(s, args.Host, params) diff --git a/cmd/climc/shell/compute/buckets.go b/cmd/climc/shell/compute/buckets.go index 92721cb060..9056e19c95 100644 --- a/cmd/climc/shell/compute/buckets.go +++ b/cmd/climc/shell/compute/buckets.go @@ -21,10 +21,10 @@ import ( "yunion.io/x/cloudmux/pkg/multicloud/objectstore" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -142,7 +142,7 @@ func init() { return err } - listResult := modulebase.ListResult{} + listResult := printutils.ListResult{} err = result.Unmarshal(&listResult) if err != nil { return err diff --git a/cmd/climc/shell/compute/cloudproviderregions.go b/cmd/climc/shell/compute/cloudproviderregions.go index b58cf82677..95c5fe9810 100644 --- a/cmd/climc/shell/compute/cloudproviderregions.go +++ b/cmd/climc/shell/compute/cloudproviderregions.go @@ -16,9 +16,9 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -40,7 +40,7 @@ func init() { } } - var result *modulebase.ListResult + var result *printutils.ListResult var err error if len(args.Manager) > 0 { result, err = modules.CloudproviderregionManager.ListDescendent(s, args.Manager, params) diff --git a/cmd/climc/shell/compute/cloudregions.go b/cmd/climc/shell/compute/cloudregions.go index 4adbbe9ff6..9030b25207 100644 --- a/cmd/climc/shell/compute/cloudregions.go +++ b/cmd/climc/shell/compute/cloudregions.go @@ -18,10 +18,10 @@ import ( "fmt" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/cmd/climc/shell" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -104,7 +104,7 @@ func init() { if err != nil { return err } - listResult := modulebase.ListResult{} + listResult := printutils.ListResult{} listResult.Data, err = results.GetArray() if err != nil { return err @@ -122,7 +122,7 @@ func init() { if err != nil { return err } - listResult := modulebase.ListResult{} + listResult := printutils.ListResult{} listResult.Data, err = results.GetArray() if err != nil { return err @@ -140,7 +140,7 @@ func init() { if err != nil { return err } - listResult := modulebase.ListResult{} + listResult := printutils.ListResult{} listResult.Data, err = results.GetArray() if err != nil { return err diff --git a/cmd/climc/shell/compute/common.go b/cmd/climc/shell/compute/common.go index bbe61bd8ee..77bfc7409e 100644 --- a/cmd/climc/shell/compute/common.go +++ b/cmd/climc/shell/compute/common.go @@ -15,8 +15,9 @@ package compute import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/compute/dbinstances.go b/cmd/climc/shell/compute/dbinstances.go index aff1de9963..26f3b832f4 100644 --- a/cmd/climc/shell/compute/dbinstances.go +++ b/cmd/climc/shell/compute/dbinstances.go @@ -15,9 +15,10 @@ package compute import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" "yunion.io/x/onecloud/pkg/mcclient/options/compute" @@ -55,7 +56,7 @@ func init() { return err } - var result *modulebase.ListResult + var result *printutils.ListResult if len(opts.DBInstance) > 0 { result, err = modules.DBInstanceNetworks.ListDescendent(s, opts.DBInstance, params) } else if len(opts.Network) > 0 { diff --git a/cmd/climc/shell/compute/disks.go b/cmd/climc/shell/compute/disks.go index 4001a7e7e7..1405c08112 100644 --- a/cmd/climc/shell/compute/disks.go +++ b/cmd/climc/shell/compute/disks.go @@ -29,13 +29,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/cmd/climc/shell" "yunion.io/x/onecloud/pkg/mcclient" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" compute_options "yunion.io/x/onecloud/pkg/mcclient/options/compute" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/sparsefile" ) diff --git a/cmd/climc/shell/compute/hostcachedimages.go b/cmd/climc/shell/compute/hostcachedimages.go index 4c67c6dcaf..b1cf13a392 100644 --- a/cmd/climc/shell/compute/hostcachedimages.go +++ b/cmd/climc/shell/compute/hostcachedimages.go @@ -16,9 +16,9 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -39,7 +39,7 @@ func init() { } } - var result *modulebase.ListResult + var result *printutils.ListResult var err error if len(args.Host) > 0 { result, err = modules.Hostcachedimages.ListDescendent(s, args.Host, params) diff --git a/cmd/climc/shell/compute/hosts.go b/cmd/climc/shell/compute/hosts.go index 68da5506a3..9a3fefa661 100644 --- a/cmd/climc/shell/compute/hosts.go +++ b/cmd/climc/shell/compute/hosts.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/cmd/climc/shell" "yunion.io/x/onecloud/pkg/mcclient" @@ -29,7 +30,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/options" "yunion.io/x/onecloud/pkg/mcclient/options/compute" "yunion.io/x/onecloud/pkg/util/fileutils2" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/ssh" ) diff --git a/cmd/climc/shell/compute/hoststorages.go b/cmd/climc/shell/compute/hoststorages.go index 9c51a9ca8f..a9d5223785 100644 --- a/cmd/climc/shell/compute/hoststorages.go +++ b/cmd/climc/shell/compute/hoststorages.go @@ -16,9 +16,9 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -39,7 +39,7 @@ func init() { } } - var result *modulebase.ListResult + var result *printutils.ListResult var err error // if len(args.Storage) > 0 { // params.Add(jsonutils.NewString(args.Storage), "storage") diff --git a/cmd/climc/shell/compute/hostwires.go b/cmd/climc/shell/compute/hostwires.go index f22a91bfd3..58e888545b 100644 --- a/cmd/climc/shell/compute/hostwires.go +++ b/cmd/climc/shell/compute/hostwires.go @@ -16,9 +16,9 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -39,7 +39,7 @@ func init() { } } - var result *modulebase.ListResult + var result *printutils.ListResult var err error if len(args.Host) > 0 { result, err = modules.Hostwires.ListDescendent(s, args.Host, params) diff --git a/cmd/climc/shell/compute/loadbalanceracls.go b/cmd/climc/shell/compute/loadbalanceracls.go index 6194cc9268..fba369558b 100644 --- a/cmd/climc/shell/compute/loadbalanceracls.go +++ b/cmd/climc/shell/compute/loadbalanceracls.go @@ -16,9 +16,9 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" baseoptions "yunion.io/x/onecloud/pkg/mcclient/options" options "yunion.io/x/onecloud/pkg/mcclient/options/compute" @@ -53,7 +53,7 @@ func init() { } printObject(jd) } - printLbAclList := func(list *modulebase.ListResult, columns []string) { + printLbAclList := func(list *printutils.ListResult, columns []string) { data := list.Data for _, jsonObj := range data { jd := jsonObj.(*jsonutils.JSONDict) diff --git a/cmd/climc/shell/compute/loadbalancercachedacls.go b/cmd/climc/shell/compute/loadbalancercachedacls.go index 8abc0dbeb4..0885812686 100644 --- a/cmd/climc/shell/compute/loadbalancercachedacls.go +++ b/cmd/climc/shell/compute/loadbalancercachedacls.go @@ -16,9 +16,9 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" options "yunion.io/x/onecloud/pkg/mcclient/options/compute" ) @@ -52,7 +52,7 @@ func init() { } printObject(jd) } - printLbAclList := func(list *modulebase.ListResult, columns []string) { + printLbAclList := func(list *printutils.ListResult, columns []string) { data := list.Data for _, jsonObj := range data { jd := jsonObj.(*jsonutils.JSONDict) diff --git a/cmd/climc/shell/compute/loadbalancerlisteners.go b/cmd/climc/shell/compute/loadbalancerlisteners.go index 16dc96151b..5fac3b9521 100644 --- a/cmd/climc/shell/compute/loadbalancerlisteners.go +++ b/cmd/climc/shell/compute/loadbalancerlisteners.go @@ -18,9 +18,9 @@ import ( "fmt" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" options "yunion.io/x/onecloud/pkg/mcclient/options/compute" ) @@ -34,7 +34,7 @@ func printLbBackendStatus(backendStatus jsonutils.JSONObject) error { if err != nil { return err } - listResult := &modulebase.ListResult{ + listResult := &printutils.ListResult{ Data: objList, } columns := []string{ diff --git a/cmd/climc/shell/compute/loadbalancernetworks.go b/cmd/climc/shell/compute/loadbalancernetworks.go index 2ee680915e..fc023a2410 100644 --- a/cmd/climc/shell/compute/loadbalancernetworks.go +++ b/cmd/climc/shell/compute/loadbalancernetworks.go @@ -16,9 +16,9 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -43,7 +43,7 @@ func init() { if len(args.Ip) > 0 { params.Add(jsonutils.NewString(args.Ip), "ip_addr") } - var result *modulebase.ListResult + var result *printutils.ListResult var err error if len(args.Loadbalancer) > 0 { result, err = modules.Loadbalancernetworks.ListDescendent(s, args.Loadbalancer, params) diff --git a/cmd/climc/shell/compute/metadata.go b/cmd/climc/shell/compute/metadata.go index c2cdb8a5bc..10217ff8d6 100644 --- a/cmd/climc/shell/compute/metadata.go +++ b/cmd/climc/shell/compute/metadata.go @@ -15,6 +15,8 @@ package compute import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" @@ -55,7 +57,7 @@ func init() { if err != nil { return err } - listResult := modulebase.ListResult{} + listResult := printutils.ListResult{} err = result.Unmarshal(&listResult) if err != nil { return err diff --git a/cmd/climc/shell/compute/networkinterfacenetworks.go b/cmd/climc/shell/compute/networkinterfacenetworks.go index f46cb59325..d810490656 100644 --- a/cmd/climc/shell/compute/networkinterfacenetworks.go +++ b/cmd/climc/shell/compute/networkinterfacenetworks.go @@ -16,9 +16,9 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" ) @@ -30,7 +30,7 @@ func init() { } R(&NetworkinterfaceNetworkListOptions{}, "networkinterface-network-list", "List server network pairs", func(s *mcclient.ClientSession, args *NetworkinterfaceNetworkListOptions) error { params := jsonutils.NewDict() - var result *modulebase.ListResult + var result *printutils.ListResult var err error if len(args.Networkinterface) > 0 { result, err = modules.Networkinterfacenetworks.ListDescendent(s, args.Networkinterface, params) diff --git a/cmd/climc/shell/compute/networks.go b/cmd/climc/shell/compute/networks.go index 3daf349c37..0bb6754b20 100644 --- a/cmd/climc/shell/compute/networks.go +++ b/cmd/climc/shell/compute/networks.go @@ -18,11 +18,11 @@ import ( "fmt" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/cmd/climc/shell" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -226,7 +226,7 @@ func init() { fmt.Println("no result") return nil } - listResult := modulebase.ListResult{Data: addrList} + listResult := printutils.ListResult{Data: addrList} printList(&listResult, nil) return nil }) diff --git a/cmd/climc/shell/compute/schedtagresources.go b/cmd/climc/shell/compute/schedtagresources.go index 1f1854756d..ad0ff76175 100644 --- a/cmd/climc/shell/compute/schedtagresources.go +++ b/cmd/climc/shell/compute/schedtagresources.go @@ -17,6 +17,8 @@ package compute import ( "fmt" + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" @@ -54,7 +56,7 @@ func (h *schedtagModelHelper) list(slave modulebase.Manager, kw string) { if err != nil { return err } - var result *modulebase.ListResult + var result *printutils.ListResult if len(args.Schedtag) > 0 { result, err = mod.ListDescendent(s, args.Schedtag, params) } else { diff --git a/cmd/climc/shell/compute/serverdisks.go b/cmd/climc/shell/compute/serverdisks.go index db58c638da..d8bb8c488a 100644 --- a/cmd/climc/shell/compute/serverdisks.go +++ b/cmd/climc/shell/compute/serverdisks.go @@ -18,9 +18,9 @@ import ( "fmt" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -45,7 +45,7 @@ func init() { if args.Index >= 0 { params.Add(jsonutils.NewInt(args.Index), "index") } - var result *modulebase.ListResult + var result *printutils.ListResult var err error if len(args.Server) > 0 { result, err = modules.Serverdisks.ListDescendent(s, args.Server, params) diff --git a/cmd/climc/shell/compute/servernetworks.go b/cmd/climc/shell/compute/servernetworks.go index 83ccb48248..d5e96c9fa5 100644 --- a/cmd/climc/shell/compute/servernetworks.go +++ b/cmd/climc/shell/compute/servernetworks.go @@ -19,12 +19,12 @@ import ( "strconv" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/pkg/util/regutils" "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/cmdline" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -53,7 +53,7 @@ func init() { if len(args.Ip) > 0 { params.Add(jsonutils.NewString(args.Ip), "ip_addr") } - var result *modulebase.ListResult + var result *printutils.ListResult var err error if len(args.Server) > 0 { result, err = modules.Servernetworks.ListDescendent(s, args.Server, params) diff --git a/cmd/climc/shell/compute/servers.go b/cmd/climc/shell/compute/servers.go index c641713697..5e73293411 100644 --- a/cmd/climc/shell/compute/servers.go +++ b/cmd/climc/shell/compute/servers.go @@ -27,6 +27,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/cmd/climc/shell" "yunion.io/x/onecloud/pkg/apis/compute" @@ -162,7 +163,7 @@ func init() { if err != nil { return err } - listResult := modulebase.ListResult{} + listResult := printutils.ListResult{} listResult.Data = tasks printList(&listResult, nil) return nil @@ -621,7 +622,7 @@ func init() { if err != nil { return err } - listResult := modulebase.ListResult{} + listResult := printutils.ListResult{} listResult.Data, _ = result.GetArray() printList(&listResult, nil) return nil diff --git a/cmd/climc/shell/compute/serversecgroups.go b/cmd/climc/shell/compute/serversecgroups.go index baffcd5b8a..b82765f50a 100644 --- a/cmd/climc/shell/compute/serversecgroups.go +++ b/cmd/climc/shell/compute/serversecgroups.go @@ -16,9 +16,9 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -39,7 +39,7 @@ func init() { } } - var result *modulebase.ListResult + var result *printutils.ListResult var err error if len(args.Server) > 0 { result, err = modules.Serversecgroups.ListDescendent(s, args.Server, params) diff --git a/cmd/climc/shell/compute/specs.go b/cmd/climc/shell/compute/specs.go index 20cdef709e..36f54a7d93 100644 --- a/cmd/climc/shell/compute/specs.go +++ b/cmd/climc/shell/compute/specs.go @@ -18,9 +18,9 @@ import ( "fmt" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -130,7 +130,7 @@ func init() { if err != nil { return err } - data := &modulebase.ListResult{Data: hosts, Total: len(hosts)} + data := &printutils.ListResult{Data: hosts, Total: len(hosts)} printList(data, []string{"ID", "Name", "Mem", "CPU", "Storage_Info"}) return nil }) @@ -168,7 +168,7 @@ func init() { if err != nil { return err } - data := &modulebase.ListResult{Data: devs, Total: len(devs)} + data := &printutils.ListResult{Data: devs, Total: len(devs)} printList(data, []string{"ID", "Addr", "Dev_Type", "Model", "Vendor_Device_Id"}) return nil }) diff --git a/cmd/climc/shell/compute/storagecachedimages.go b/cmd/climc/shell/compute/storagecachedimages.go index 33f202f96c..cff8a12cea 100644 --- a/cmd/climc/shell/compute/storagecachedimages.go +++ b/cmd/climc/shell/compute/storagecachedimages.go @@ -16,9 +16,9 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -39,7 +39,7 @@ func init() { } } - var result *modulebase.ListResult + var result *printutils.ListResult var err error if len(args.Storagecache) > 0 { result, err = modules.Storagecachedimages.ListDescendent(s, args.Storagecache, params) diff --git a/cmd/climc/shell/compute/zones.go b/cmd/climc/shell/compute/zones.go index 8c84ba8742..2baf35fc20 100644 --- a/cmd/climc/shell/compute/zones.go +++ b/cmd/climc/shell/compute/zones.go @@ -16,9 +16,9 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -36,7 +36,7 @@ func init() { if err != nil { return err } - var result *modulebase.ListResult + var result *printutils.ListResult if len(args.Region) > 0 { result, err = modules.Zones.ListInContext(s, params, &modules.Cloudregions, args.Region) } else { diff --git a/cmd/climc/shell/devtool/common.go b/cmd/climc/shell/devtool/common.go index f16ff7021b..a51180fb04 100644 --- a/cmd/climc/shell/devtool/common.go +++ b/cmd/climc/shell/devtool/common.go @@ -15,8 +15,9 @@ package devtool import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/devtool/devtoolcronjob.go b/cmd/climc/shell/devtool/devtoolcronjob.go index 8dba08f5cd..2692315bf9 100644 --- a/cmd/climc/shell/devtool/devtoolcronjob.go +++ b/cmd/climc/shell/devtool/devtoolcronjob.go @@ -19,9 +19,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules/ansible" modules "yunion.io/x/onecloud/pkg/mcclient/modules/devtool" "yunion.io/x/onecloud/pkg/mcclient/options" @@ -55,7 +55,7 @@ func init() { if err != nil { return err } - var result *modulebase.ListResult + var result *printutils.ListResult result, err = modules.DevToolCronjobs.List(s, params) printList(result, modules.DevToolCronjobs.GetColumns(s)) return nil diff --git a/cmd/climc/shell/devtool/devtooltemplate.go b/cmd/climc/shell/devtool/devtooltemplate.go index 8a9c09a43e..190b3b33b7 100644 --- a/cmd/climc/shell/devtool/devtooltemplate.go +++ b/cmd/climc/shell/devtool/devtooltemplate.go @@ -17,9 +17,9 @@ package devtool import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/devtool" "yunion.io/x/onecloud/pkg/mcclient/options" ) @@ -48,7 +48,7 @@ func init() { if err != nil { return err } - var result *modulebase.ListResult + var result *printutils.ListResult result, err = modules.DevToolTemplates.List(s, params) printList(result, modules.DevToolTemplates.GetColumns(s)) return nil diff --git a/cmd/climc/shell/etcd/service_registries.go b/cmd/climc/shell/etcd/service_registries.go index 7503f3471d..dc0bc3e8fb 100644 --- a/cmd/climc/shell/etcd/service_registries.go +++ b/cmd/climc/shell/etcd/service_registries.go @@ -15,10 +15,11 @@ package etcd import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules/etcd" - "yunion.io/x/onecloud/pkg/util/printutils" ) func init() { diff --git a/cmd/climc/shell/events/common.go b/cmd/climc/shell/events/common.go index bbc6ace49c..ac3e1a7713 100644 --- a/cmd/climc/shell/events/common.go +++ b/cmd/climc/shell/events/common.go @@ -15,8 +15,9 @@ package events import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/helper.go b/cmd/climc/shell/helper.go index a655b4b5aa..f2e9ec2f78 100644 --- a/cmd/climc/shell/helper.go +++ b/cmd/climc/shell/helper.go @@ -20,11 +20,11 @@ import ( "strings" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modulebase" - "yunion.io/x/onecloud/pkg/util/printutils" ) type ResourceCmd struct { @@ -142,7 +142,7 @@ func (cmd ResourceCmd) List(args IListOpt) { if err != nil { return err } - var result *modulebase.ListResult + var result *printutils.ListResult contextId := args.GetContextId() if cmd.contextManager != nil && len(contextId) > 0 { result, err = man.(modulebase.Manager).ListInContext(s, params, cmd.contextManager.(modulebase.Manager), contextId) @@ -242,7 +242,7 @@ func (cmd ResourceCmd) GetProperty(args IPropertyOpt) { } if _, ok := ret.(*jsonutils.JSONArray); ok { data, _ := ret.GetArray() - PrintList(&modulebase.ListResult{ + PrintList(&printutils.ListResult{ Data: data, }, nil) } else { @@ -634,7 +634,7 @@ func (cmd JointCmd) List(args IJointListOpt) { if err != nil { return err } - var result *modulebase.ListResult + var result *printutils.ListResult if len(args.GetMasterOpt()) > 0 { result, err = man.ListDescendent(s, args.GetMasterOpt(), params) } else if len(args.GetSlaveOpt()) > 0 { diff --git a/cmd/climc/shell/identity/common.go b/cmd/climc/shell/identity/common.go index a3e92abbfc..8c7f0d7ebd 100644 --- a/cmd/climc/shell/identity/common.go +++ b/cmd/climc/shell/identity/common.go @@ -15,8 +15,9 @@ package identity import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/identity/credential_aes_key.go b/cmd/climc/shell/identity/credential_aes_key.go index d0a518e2a5..e1e5c4ebb0 100644 --- a/cmd/climc/shell/identity/credential_aes_key.go +++ b/cmd/climc/shell/identity/credential_aes_key.go @@ -18,9 +18,9 @@ import ( "fmt" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" ) @@ -65,7 +65,7 @@ func init() { if err != nil { return err } - result := modulebase.ListResult{} + result := printutils.ListResult{} result.Data = make([]jsonutils.JSONObject, len(secrets)) for i := range secrets { result.Data[i] = secrets[i].Marshal() diff --git a/cmd/climc/shell/identity/credentials.go b/cmd/climc/shell/identity/credentials.go index c98d42fff7..9a6b01f4db 100644 --- a/cmd/climc/shell/identity/credentials.go +++ b/cmd/climc/shell/identity/credentials.go @@ -19,9 +19,9 @@ import ( "time" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" ) @@ -207,7 +207,7 @@ func init() { if err != nil { return err } - result := modulebase.ListResult{} + result := printutils.ListResult{} result.Data = make([]jsonutils.JSONObject, len(secrets)) for i := range secrets { result.Data[i] = jsonutils.Marshal(secrets[i]) @@ -294,7 +294,7 @@ func init() { if err != nil { return err } - result := modulebase.ListResult{} + result := printutils.ListResult{} result.Data = make([]jsonutils.JSONObject, len(secrets)) for i := range secrets { result.Data[i] = jsonutils.Marshal(secrets[i]) diff --git a/cmd/climc/shell/identity/identityproviders.go b/cmd/climc/shell/identity/identityproviders.go index dd8331c46a..cc9d560cd4 100644 --- a/cmd/climc/shell/identity/identityproviders.go +++ b/cmd/climc/shell/identity/identityproviders.go @@ -19,6 +19,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/shellutils" api "yunion.io/x/onecloud/pkg/apis/identity" "yunion.io/x/onecloud/pkg/httperrors" @@ -26,7 +27,6 @@ import ( modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" "yunion.io/x/onecloud/pkg/mcclient/options" "yunion.io/x/onecloud/pkg/util/fileutils2" - "yunion.io/x/onecloud/pkg/util/shellutils" ) func init() { diff --git a/cmd/climc/shell/identity/policies.go b/cmd/climc/shell/identity/policies.go index 67ed2f513a..5cc6140434 100644 --- a/cmd/climc/shell/identity/policies.go +++ b/cmd/climc/shell/identity/policies.go @@ -23,6 +23,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/rbacscope" + "yunion.io/x/pkg/util/shellutils" "yunion.io/x/onecloud/cmd/climc/shell" api "yunion.io/x/onecloud/pkg/apis/identity" @@ -35,7 +37,6 @@ import ( options "yunion.io/x/onecloud/pkg/mcclient/options/identity" "yunion.io/x/onecloud/pkg/util/fileutils2" "yunion.io/x/onecloud/pkg/util/rbacutils" - "yunion.io/x/onecloud/pkg/util/shellutils" "yunion.io/x/onecloud/pkg/util/tagutils" ) @@ -420,12 +421,12 @@ func init() { fmt.Println("Token", token) - for _, scope := range []rbacutils.TRbacScope{ - rbacutils.ScopeSystem, - rbacutils.ScopeDomain, - rbacutils.ScopeProject, - rbacutils.ScopeUser, - rbacutils.ScopeNone, + for _, scope := range []rbacscope.TRbacScope{ + rbacscope.ScopeSystem, + rbacscope.ScopeDomain, + rbacscope.ScopeProject, + rbacscope.ScopeUser, + rbacscope.ScopeNone, } { fmt.Printf("%s: ", scope) capable := policy.PolicyManager.IsScopeCapable(token, scope) diff --git a/cmd/climc/shell/identity/services.go b/cmd/climc/shell/identity/services.go index a44581f58f..7bc5cad091 100644 --- a/cmd/climc/shell/identity/services.go +++ b/cmd/climc/shell/identity/services.go @@ -19,11 +19,11 @@ import ( "strings" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/shellutils" "yunion.io/x/onecloud/pkg/mcclient" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" "yunion.io/x/onecloud/pkg/util/fileutils2" - "yunion.io/x/onecloud/pkg/util/shellutils" ) func init() { diff --git a/cmd/climc/shell/image/common.go b/cmd/climc/shell/image/common.go index c734ebb760..4b3fc8a3e9 100644 --- a/cmd/climc/shell/image/common.go +++ b/cmd/climc/shell/image/common.go @@ -15,8 +15,9 @@ package image import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/image/images.go b/cmd/climc/shell/image/images.go index 226f20e439..053666a3cc 100644 --- a/cmd/climc/shell/image/images.go +++ b/cmd/climc/shell/image/images.go @@ -23,10 +23,10 @@ import ( "github.com/cheggaaa/pb/v3" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/cmd/climc/shell" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules/identity" modules "yunion.io/x/onecloud/pkg/mcclient/modules/image" "yunion.io/x/onecloud/pkg/mcclient/options" @@ -412,7 +412,7 @@ func init() { continue } arrays, _ := result.(*jsonutils.JSONArray).GetArray() - listResult := modulebase.ListResult{Data: arrays} + listResult := printutils.ListResult{Data: arrays} printList(&listResult, []string{}) } return nil diff --git a/cmd/climc/shell/k8s/clusters.go b/cmd/climc/shell/k8s/clusters.go index b7abbc4d79..5f73415b9e 100644 --- a/cmd/climc/shell/k8s/clusters.go +++ b/cmd/climc/shell/k8s/clusters.go @@ -23,12 +23,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/shellutils" "yunion.io/x/onecloud/cmd/climc/shell" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules/k8s" o "yunion.io/x/onecloud/pkg/mcclient/options/k8s" - "yunion.io/x/onecloud/pkg/util/shellutils" ) func initKubeCluster() { diff --git a/cmd/climc/shell/k8s/k8s.go b/cmd/climc/shell/k8s/k8s.go index 3b68685a6f..83e4628685 100644 --- a/cmd/climc/shell/k8s/k8s.go +++ b/cmd/climc/shell/k8s/k8s.go @@ -18,12 +18,12 @@ import ( "fmt" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/cmd/climc/shell" "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules/k8s" o "yunion.io/x/onecloud/pkg/mcclient/options/k8s" - "yunion.io/x/onecloud/pkg/util/printutils" ) func init() { diff --git a/cmd/climc/shell/k8s/list.go b/cmd/climc/shell/k8s/list.go index 3012b0c6e6..961b7a991e 100644 --- a/cmd/climc/shell/k8s/list.go +++ b/cmd/climc/shell/k8s/list.go @@ -23,9 +23,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules/k8s" ) @@ -56,7 +56,7 @@ func getPrinterRowValues(printer k8s.ListPrinter, obj jsonutils.JSONObject, cols return ret } -func ListerTable(res *modulebase.ListResult, printer k8s.ListPrinter, s *mcclient.ClientSession) *uitable.Table { +func ListerTable(res *printutils.ListResult, printer k8s.ListPrinter, s *mcclient.ClientSession) *uitable.Table { min := func(x, y int) int { if x < y { return x @@ -78,7 +78,7 @@ func ListerTable(res *modulebase.ListResult, printer k8s.ListPrinter, s *mcclien return table } -func PrintListResultTable(res *modulebase.ListResult, printer k8s.ListPrinter, s *mcclient.ClientSession) { +func PrintListResultTable(res *printutils.ListResult, printer k8s.ListPrinter, s *mcclient.ClientSession) { fmt.Println(ListerTable(res, printer, s)) table := uitable.New() diff --git a/cmd/climc/shell/logger/common.go b/cmd/climc/shell/logger/common.go index ac669f1bb9..b49671c784 100644 --- a/cmd/climc/shell/logger/common.go +++ b/cmd/climc/shell/logger/common.go @@ -15,8 +15,9 @@ package logger import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/misc/common.go b/cmd/climc/shell/misc/common.go index 760ee9382f..7b8102b073 100644 --- a/cmd/climc/shell/misc/common.go +++ b/cmd/climc/shell/misc/common.go @@ -15,8 +15,9 @@ package misc import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/misc/version.go b/cmd/climc/shell/misc/version.go index c502c6ae9f..6f9449879b 100644 --- a/cmd/climc/shell/misc/version.go +++ b/cmd/climc/shell/misc/version.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/mcclient" @@ -67,7 +68,7 @@ func init() { return err } data, _ := body.GetArray("workers") - printList(&modulebase.ListResult{Data: data}, nil) + printList(&printutils.ListResult{Data: data}, nil) return nil }) diff --git a/cmd/climc/shell/monitor/alertnotification.go b/cmd/climc/shell/monitor/alertnotification.go index faaba63f8e..ee5f51cca2 100644 --- a/cmd/climc/shell/monitor/alertnotification.go +++ b/cmd/climc/shell/monitor/alertnotification.go @@ -15,9 +15,10 @@ package monitor import ( + "yunion.io/x/pkg/util/printutils" + monitorapi "yunion.io/x/onecloud/pkg/apis/monitor" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules/monitor" options "yunion.io/x/onecloud/pkg/mcclient/options/monitor" ) @@ -34,7 +35,7 @@ func initAlertNotification() { if err != nil { return err } - var result *modulebase.ListResult + var result *printutils.ListResult if len(args.Alert) > 0 { result, err = monitor.Alertnotification.ListDescendent(s, args.Alert, params) } else if len(args.Notification) > 0 { diff --git a/cmd/climc/shell/monitor/common.go b/cmd/climc/shell/monitor/common.go index 9894da898d..a0c1057a72 100644 --- a/cmd/climc/shell/monitor/common.go +++ b/cmd/climc/shell/monitor/common.go @@ -15,9 +15,10 @@ package monitor import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" "yunion.io/x/onecloud/pkg/mcclient/modulebase" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/notifyv2/common.go b/cmd/climc/shell/notifyv2/common.go index 235bc49899..8ffa66fef0 100644 --- a/cmd/climc/shell/notifyv2/common.go +++ b/cmd/climc/shell/notifyv2/common.go @@ -15,8 +15,9 @@ package notifyv2 import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/quota/common.go b/cmd/climc/shell/quota/common.go index 7546abcb82..0485df8523 100644 --- a/cmd/climc/shell/quota/common.go +++ b/cmd/climc/shell/quota/common.go @@ -15,8 +15,9 @@ package quota import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/scheduledtask/scheduledtask.go b/cmd/climc/shell/scheduledtask/scheduledtask.go index 0dcfcdc69d..2579e8030d 100644 --- a/cmd/climc/shell/scheduledtask/scheduledtask.go +++ b/cmd/climc/shell/scheduledtask/scheduledtask.go @@ -19,13 +19,13 @@ import ( "time" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/cmd/climc/shell" apis "yunion.io/x/onecloud/pkg/apis/scheduledtask" "yunion.io/x/onecloud/pkg/mcclient" modules "yunion.io/x/onecloud/pkg/mcclient/modules/scheduledtask" "yunion.io/x/onecloud/pkg/mcclient/options" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/scheduler/common.go b/cmd/climc/shell/scheduler/common.go index f9a3f8e17b..4da810460c 100644 --- a/cmd/climc/shell/scheduler/common.go +++ b/cmd/climc/shell/scheduler/common.go @@ -15,8 +15,9 @@ package scheduler import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/shell.go b/cmd/climc/shell/shell.go index 008eb7ad29..c6597f4b00 100644 --- a/cmd/climc/shell/shell.go +++ b/cmd/climc/shell/shell.go @@ -16,6 +16,8 @@ package shell import ( "errors" + + "yunion.io/x/pkg/util/shellutils" ) type CMD struct { @@ -30,7 +32,8 @@ var CommandTable []CMD = make([]CMD, 0) var ErrEmtptyUpdate = errors.New("No valid update data") func R(options interface{}, command string, desc string, callback interface{}) { - CommandTable = append(CommandTable, CMD{options, command, desc, callback}) + shellutils.R(options, command, desc, callback) + // CommandTable = append(CommandTable, CMD{options, command, desc, callback}) } func InvalidUpdateError() error { diff --git a/cmd/climc/shell/utils.go b/cmd/climc/shell/utils.go index 7bea7c16c1..85badf6ec8 100644 --- a/cmd/climc/shell/utils.go +++ b/cmd/climc/shell/utils.go @@ -21,10 +21,9 @@ import ( "strings" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/util/excelutils" - "yunion.io/x/onecloud/pkg/util/printutils" ) const ( @@ -41,7 +40,7 @@ func OutputFormat(s string) { outputFormat = s } -func PrintList(list *modulebase.ListResult, columns []string) { +func PrintList(list *printutils.ListResult, columns []string) { switch outputFormat { case OUTPUT_FORMAT_TABLE: printutils.PrintJSONList(list, columns) @@ -103,11 +102,11 @@ func printObjectRecursiveEx(obj jsonutils.JSONObject, cb printutils.PrintJSONObj printutils.PrintJSONObjectRecursiveEx(obj, cb) } -func printBatchResults(results []modulebase.SubmitResult, columns []string) { +func printBatchResults(results []printutils.SubmitResult, columns []string) { printutils.PrintJSONBatchResults(results, columns) } -func ExportList(list *modulebase.ListResult, file string, exportKeys string, exportTexts string, columns []string) { +func ExportList(list *printutils.ListResult, file string, exportKeys string, exportTexts string, columns []string) { var keys []string var texts []string if len(exportKeys) > 0 { diff --git a/cmd/climc/shell/yunionconf/common.go b/cmd/climc/shell/yunionconf/common.go index ff09111778..a8168224db 100644 --- a/cmd/climc/shell/yunionconf/common.go +++ b/cmd/climc/shell/yunionconf/common.go @@ -15,8 +15,9 @@ package yunionconf import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/cmd/climc/shell" - "yunion.io/x/onecloud/pkg/util/printutils" ) var ( diff --git a/cmd/climc/shell/yunionconf/parameters.go b/cmd/climc/shell/yunionconf/parameters.go index 9d2750a2e6..2a010881f6 100644 --- a/cmd/climc/shell/yunionconf/parameters.go +++ b/cmd/climc/shell/yunionconf/parameters.go @@ -16,13 +16,13 @@ package yunionconf import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/pkg/util/shellutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules/identity" "yunion.io/x/onecloud/pkg/mcclient/modules/yunionconf" "yunion.io/x/onecloud/pkg/mcclient/options" - "yunion.io/x/onecloud/pkg/util/shellutils" ) func init() { @@ -44,7 +44,7 @@ func init() { params.Add(jsonutils.NewString(args.Name), "name") } - var result *modulebase.ListResult + var result *printutils.ListResult if len(args.NamespaceId) > 0 { params.Add(jsonutils.NewString(args.NamespaceId), "namespace_id") params.Add(jsonutils.NewString("system"), "scope") diff --git a/cmd/cloudpodscli/main.go b/cmd/cloudpodscli/main.go new file mode 100644 index 0000000000..01c7e90751 --- /dev/null +++ b/cmd/cloudpodscli/main.go @@ -0,0 +1,153 @@ +// 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 main + +import ( + "fmt" + "net/http" + "net/url" + "os" + + "golang.org/x/net/http/httpproxy" + + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/util/shellutils" + "yunion.io/x/structarg" + + "yunion.io/x/onecloud/pkg/mcclient/cloudpods" + _ "yunion.io/x/onecloud/pkg/mcclient/cloudpods/shell" +) + +type BaseOptions struct { + Debug bool `help:"debug mode"` + AuthURL string `help:"Auth URL" default:"$CLOUDPODS_AUTH_URL" metavar:"CLOUDPODS_AUTH_URL"` + AccessKey string `help:"AccessKey" default:"$CLOUDPODS_ACCESS_KEY" metavar:"CLOUDPODS_ACCESS_KEY"` + AccessSecret string `help:"AccessSecret" default:"$CLOUDPODS_ACCESS_SECRET" metavar:"CLOUDPODS_ACCESS_SECRET"` + RegionId string `help:"RegionId" default:"$CLOUDPODS_REGION_ID|default" metavar:"CLOUDPODS_REGION_ID"` + SUBCOMMAND string `help:"cloudpodscli subcommand" subcommand:"true"` +} + +func getSubcommandParser() (*structarg.ArgumentParser, error) { + parse, err := structarg.NewArgumentParserWithHelp(&BaseOptions{}, + "cloudpodscli", + "Command-line interface to cloudpods API.", + `See "cloudpodscli COMMAND --help" for help on a specific command.`) + + if err != nil { + return nil, err + } + + subcmd := parse.GetSubcommand() + if subcmd == nil { + return nil, fmt.Errorf("No subcommand argument.") + } + for _, v := range shellutils.CommandTable { + _, err = subcmd.AddSubParserWithHelp(v.Options, v.Command, v.Desc, v.Callback) + if err != nil { + return nil, err + } + } + return parse, nil +} + +func showErrorAndExit(e error) { + fmt.Fprintf(os.Stderr, "%s", e) + fmt.Fprintln(os.Stderr) + os.Exit(1) +} + +func newClient(options *BaseOptions) (*cloudpods.SRegion, error) { + if len(options.AuthURL) == 0 { + return nil, fmt.Errorf("Missing AuthURL") + } + + if len(options.AccessKey) == 0 { + return nil, fmt.Errorf("Missing access key") + } + + if len(options.AccessSecret) == 0 { + return nil, fmt.Errorf("Missing access secret") + } + + cfg := &httpproxy.Config{ + HTTPProxy: os.Getenv("HTTP_PROXY"), + HTTPSProxy: os.Getenv("HTTPS_PROXY"), + NoProxy: os.Getenv("NO_PROXY"), + } + cfgProxyFunc := cfg.ProxyFunc() + proxyFunc := func(req *http.Request) (*url.URL, error) { + return cfgProxyFunc(req.URL) + } + + cli, err := cloudpods.NewCloudpodsClient( + cloudpods.NewCloudpodsClientConfig( + options.AuthURL, + options.AccessKey, + options.AccessSecret, + ).Debug(options.Debug). + CloudproviderConfig( + cloudprovider.ProviderConfig{ + ProxyFunc: proxyFunc, + }, + ), + ) + if err != nil { + return nil, err + } + region, err := cli.GetRegion(options.RegionId) + if err != nil { + return nil, err + } + return region, nil +} + +func main() { + parser, err := getSubcommandParser() + if err != nil { + showErrorAndExit(err) + } + err = parser.ParseArgs(os.Args[1:], false) + options := parser.Options().(*BaseOptions) + + if parser.IsHelpSet() { + fmt.Print(parser.HelpString()) + return + } + subcmd := parser.GetSubcommand() + subparser := subcmd.GetSubParser() + if err != nil || subparser == nil { + if subparser != nil { + fmt.Print(subparser.Usage()) + } else { + fmt.Print(parser.Usage()) + } + showErrorAndExit(err) + return + } + suboptions := subparser.Options() + if subparser.IsHelpSet() { + fmt.Print(subparser.HelpString()) + return + } + var region *cloudpods.SRegion + region, err = newClient(options) + if err != nil { + showErrorAndExit(err) + } + err = subcmd.Invoke(region, suboptions) + if err != nil { + showErrorAndExit(err) + } +} diff --git a/cmd/cryptool/main.go b/cmd/cryptool/main.go index f3950297eb..b091014bf3 100644 --- a/cmd/cryptool/main.go +++ b/cmd/cryptool/main.go @@ -18,10 +18,10 @@ import ( "fmt" "os" + "yunion.io/x/pkg/util/shellutils" "yunion.io/x/structarg" _ "yunion.io/x/onecloud/cmd/cryptool/shell" - "yunion.io/x/onecloud/pkg/util/shellutils" ) type BaseOptions struct { diff --git a/cmd/cryptool/shell/decrypt.go b/cmd/cryptool/shell/decrypt.go index 7da266e687..b89617b943 100644 --- a/cmd/cryptool/shell/decrypt.go +++ b/cmd/cryptool/shell/decrypt.go @@ -17,9 +17,8 @@ package shell import ( "fmt" + "yunion.io/x/pkg/util/shellutils" "yunion.io/x/pkg/utils" - - "yunion.io/x/onecloud/pkg/util/shellutils" ) func init() { diff --git a/cmd/cryptool/shell/fernet.go b/cmd/cryptool/shell/fernet.go index 6ebd0b99fd..73b9ada832 100644 --- a/cmd/cryptool/shell/fernet.go +++ b/cmd/cryptool/shell/fernet.go @@ -17,11 +17,11 @@ package shell import ( "fmt" + "yunion.io/x/pkg/util/shellutils" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/onecloud/pkg/keystone/tokens" "yunion.io/x/onecloud/pkg/util/fernetool" - "yunion.io/x/onecloud/pkg/util/shellutils" ) func init() { diff --git a/cmd/cryptool/shell/zeroclean.go b/cmd/cryptool/shell/zeroclean.go index 6909f90d4b..2fb1604e82 100644 --- a/cmd/cryptool/shell/zeroclean.go +++ b/cmd/cryptool/shell/zeroclean.go @@ -15,7 +15,8 @@ package shell import ( - "yunion.io/x/onecloud/pkg/util/shellutils" + "yunion.io/x/pkg/util/shellutils" + "yunion.io/x/onecloud/pkg/util/zeroclean" ) diff --git a/cmd/fetcherfs/fs.go b/cmd/fetcherfs/fs.go index e2b9a8f9ba..011bec291e 100644 --- a/cmd/fetcherfs/fs.go +++ b/cmd/fetcherfs/fs.go @@ -32,9 +32,9 @@ import ( "github.com/pkg/errors" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/bitmap" - "yunion.io/x/onecloud/pkg/util/httputils" ) // FetcherFs implements the feteher file system. diff --git a/cmd/ipmicli/main.go b/cmd/ipmicli/main.go index 626d044730..e2d94347e0 100644 --- a/cmd/ipmicli/main.go +++ b/cmd/ipmicli/main.go @@ -18,11 +18,11 @@ import ( "fmt" "os" + "yunion.io/x/pkg/util/shellutils" "yunion.io/x/structarg" "yunion.io/x/onecloud/pkg/baremetal/utils/ipmitool" _ "yunion.io/x/onecloud/pkg/util/ipmitool/shell" - "yunion.io/x/onecloud/pkg/util/shellutils" "yunion.io/x/onecloud/pkg/util/ssh" ) diff --git a/cmd/ldapcli/main.go b/cmd/ldapcli/main.go index 7106f051e0..a107db2aa2 100644 --- a/cmd/ldapcli/main.go +++ b/cmd/ldapcli/main.go @@ -19,11 +19,11 @@ import ( "os" "yunion.io/x/log" + "yunion.io/x/pkg/util/shellutils" "yunion.io/x/structarg" _ "yunion.io/x/onecloud/cmd/ldapcli/shell" "yunion.io/x/onecloud/pkg/util/ldaputils" - "yunion.io/x/onecloud/pkg/util/shellutils" ) type BaseOptions struct { diff --git a/cmd/ldapcli/shell/search.go b/cmd/ldapcli/shell/search.go index 18b39b41e3..ff3252444d 100644 --- a/cmd/ldapcli/shell/search.go +++ b/cmd/ldapcli/shell/search.go @@ -20,9 +20,10 @@ import ( "gopkg.in/ldap.v3" + "yunion.io/x/pkg/util/shellutils" + api "yunion.io/x/onecloud/pkg/apis/identity" "yunion.io/x/onecloud/pkg/util/ldaputils" - "yunion.io/x/onecloud/pkg/util/shellutils" ) func queryScope(scope string) int { diff --git a/cmd/raidcli/main.go b/cmd/raidcli/main.go index a74f565c30..021c88fe09 100644 --- a/cmd/raidcli/main.go +++ b/cmd/raidcli/main.go @@ -18,12 +18,12 @@ import ( "fmt" "os" + "yunion.io/x/pkg/util/shellutils" "yunion.io/x/structarg" _ "yunion.io/x/onecloud/cmd/raidcli/shell" "yunion.io/x/onecloud/pkg/baremetal/utils/raid" "yunion.io/x/onecloud/pkg/baremetal/utils/raid/drivers" - "yunion.io/x/onecloud/pkg/util/shellutils" "yunion.io/x/onecloud/pkg/util/ssh" ) diff --git a/cmd/raidcli/shell/raid.go b/cmd/raidcli/shell/raid.go index 7cf7266f32..e5d8f35396 100644 --- a/cmd/raidcli/shell/raid.go +++ b/cmd/raidcli/shell/raid.go @@ -18,9 +18,9 @@ import ( "fmt" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/shellutils" "yunion.io/x/onecloud/pkg/baremetal/utils/raid" - "yunion.io/x/onecloud/pkg/util/shellutils" ) func init() { diff --git a/cmd/redfishcli/main.go b/cmd/redfishcli/main.go index 1426d28537..719aa3330d 100644 --- a/cmd/redfishcli/main.go +++ b/cmd/redfishcli/main.go @@ -21,6 +21,7 @@ import ( "os" "strings" + "yunion.io/x/pkg/util/shellutils" "yunion.io/x/structarg" _ "yunion.io/x/onecloud/cmd/redfishcli/shell" @@ -28,7 +29,6 @@ import ( "yunion.io/x/onecloud/pkg/util/redfish" "yunion.io/x/onecloud/pkg/util/redfish/bmconsole" _ "yunion.io/x/onecloud/pkg/util/redfish/loader" - "yunion.io/x/onecloud/pkg/util/shellutils" ) type BaseOptions struct { diff --git a/cmd/redfishcli/shell/chassis.go b/cmd/redfishcli/shell/chassis.go index ab135915f1..e1cc138183 100644 --- a/cmd/redfishcli/shell/chassis.go +++ b/cmd/redfishcli/shell/chassis.go @@ -18,9 +18,10 @@ import ( "context" "fmt" - "yunion.io/x/onecloud/pkg/util/printutils" + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/pkg/util/shellutils" + "yunion.io/x/onecloud/pkg/util/redfish" - "yunion.io/x/onecloud/pkg/util/shellutils" ) func init() { diff --git a/cmd/redfishcli/shell/manager.go b/cmd/redfishcli/shell/manager.go index 30b31e9090..c12c23b70e 100644 --- a/cmd/redfishcli/shell/manager.go +++ b/cmd/redfishcli/shell/manager.go @@ -20,12 +20,12 @@ import ( "time" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/pkg/util/shellutils" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/onecloud/pkg/util/fileutils2" - "yunion.io/x/onecloud/pkg/util/printutils" "yunion.io/x/onecloud/pkg/util/redfish" - "yunion.io/x/onecloud/pkg/util/shellutils" ) func init() { diff --git a/cmd/redfishcli/shell/shell.go b/cmd/redfishcli/shell/shell.go index 969c8571af..033abe60e5 100644 --- a/cmd/redfishcli/shell/shell.go +++ b/cmd/redfishcli/shell/shell.go @@ -18,8 +18,9 @@ import ( "context" "fmt" + "yunion.io/x/pkg/util/shellutils" + "yunion.io/x/onecloud/pkg/util/redfish" - "yunion.io/x/onecloud/pkg/util/shellutils" ) func init() { diff --git a/cmd/redfishcli/shell/system.go b/cmd/redfishcli/shell/system.go index 84b00f4381..46c8ae220d 100644 --- a/cmd/redfishcli/shell/system.go +++ b/cmd/redfishcli/shell/system.go @@ -19,9 +19,9 @@ import ( "fmt" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/shellutils" "yunion.io/x/onecloud/pkg/util/redfish" - "yunion.io/x/onecloud/pkg/util/shellutils" ) func init() { diff --git a/cmd/region/main.go b/cmd/region/main.go index 836a99d932..5a33cf050d 100644 --- a/cmd/region/main.go +++ b/cmd/region/main.go @@ -18,6 +18,7 @@ import ( _ "yunion.io/x/cloudmux/pkg/multicloud/loader" "yunion.io/x/onecloud/pkg/compute/service" + _ "yunion.io/x/onecloud/pkg/mcclient/cloudpods/provider" "yunion.io/x/onecloud/pkg/util/atexit" ) diff --git a/cmd/telegraf-raid-plugin/main.go b/cmd/telegraf-raid-plugin/main.go index 612898ad30..0ed413b511 100644 --- a/cmd/telegraf-raid-plugin/main.go +++ b/cmd/telegraf-raid-plugin/main.go @@ -28,11 +28,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/baremetal/utils/detect_storages" "yunion.io/x/onecloud/pkg/baremetal/utils/raid/drivers" "yunion.io/x/onecloud/pkg/compute/baremetal" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/procutils" ) diff --git a/go.mod b/go.mod index ebe6cb5417..8063e37cb0 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,6 @@ require ( github.com/coredns/coredns v1.3.0 github.com/coreos/go-iptables v0.6.0 github.com/creack/pty v1.1.11 - github.com/fatih/color v1.13.0 github.com/fernet/fernet-go v0.0.0-20180830025343-9eac43b88a5e github.com/fsnotify/fsnotify v1.4.9 github.com/ghodss/yaml v1.0.0 @@ -37,7 +36,6 @@ require ( github.com/lestrrat-go/jwx v1.0.2 github.com/lestrrat/go-jwx v0.0.0-20180221005942-b7d4802280ae github.com/libvirt/libvirt-go-xml v5.2.0+incompatible - github.com/ma314smith/signedxml v0.0.0-20210628192057-abc5b481ae1c github.com/mattn/go-sqlite3 v1.14.12 github.com/mdlayher/arp v0.0.0-20190313224443-98a83c8a2717 github.com/mdlayher/ethernet v0.0.0-20190606142754-0394541c37b7 @@ -45,7 +43,6 @@ require ( github.com/mholt/caddy v0.10.11 github.com/miekg/dns v1.1.25 github.com/minio/minio-go v6.0.14+incompatible - github.com/mozillazg/go-pinyin v0.15.0 github.com/pierrec/lz4/v4 v4.1.15 github.com/pkg/errors v0.9.1 github.com/pquerna/otp v1.2.0 @@ -55,24 +52,24 @@ require ( github.com/shirou/gopsutil v3.21.11+incompatible github.com/shirou/gopsutil/v3 v3.22.10 github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9 - github.com/smartystreets/goconvey v1.6.4 + github.com/smartystreets/goconvey v1.7.2 github.com/stretchr/testify v1.8.1 github.com/tatsushid/go-fastping v0.0.0-20160109021039-d7bb493dee3e github.com/tjfoc/gmsm v1.4.1 - github.com/tredoe/osutil v1.0.6 + github.com/tredoe/osutil/v2 v2.0.0-rc.16 github.com/vishvananda/netlink v1.1.0 github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 github.com/vmihailenco/msgpack v4.0.4+incompatible go.etcd.io/etcd/api/v3 v3.5.0 go.etcd.io/etcd/client/v3 v3.5.0 - golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 - golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2 - golang.org/x/sync v0.0.0-20210220032951-036812b2e83c - golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 - golang.org/x/text v0.3.7 + golang.org/x/crypto v0.1.0 + golang.org/x/net v0.1.0 + golang.org/x/sync v0.1.0 + golang.org/x/sys v0.1.0 + golang.org/x/text v0.4.0 golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 - golang.zx2c4.com/wireguard/wgctrl v0.0.0-20191008142428-8d021180e987 + golang.zx2c4.com/wireguard/wgctrl v0.0.0-20221104135756-97bc4ad4a1cb google.golang.org/grpc v1.38.0 google.golang.org/protobuf v1.27.1 gopkg.in/fatih/set.v0 v0.2.1 @@ -84,12 +81,12 @@ require ( k8s.io/client-go v0.19.3 k8s.io/cluster-bootstrap v0.19.3 moul.io/http2curl/v2 v2.3.0 - yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221221074003-215a6ca48a2a + yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221226041034-c7119501d505 yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656 yunion.io/x/jsonutils v1.0.1-0.20220819091305-3bab322ab4fd yunion.io/x/log v1.0.0 yunion.io/x/ovsdb v0.0.0-20200526071744-27bf0940cbc7 - yunion.io/x/pkg v1.0.1-0.20221031045951-0b770b490c45 + yunion.io/x/pkg v1.0.1-0.20221226030310-a8727011fc76 yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e yunion.io/x/sqlchemy v1.1.2-0.20220923040147-ddd3e96868af yunion.io/x/structarg v0.0.0-20220312084958-9c6c79c7d1c6 @@ -99,12 +96,12 @@ require ( cloud.google.com/go v0.65.0 // indirect cloud.google.com/go/storage v1.10.0 // indirect github.com/Azure/azure-sdk-for-go v36.1.0+incompatible // indirect + github.com/Azure/go-autorest v14.2.0+incompatible // indirect github.com/Azure/go-autorest/autorest v0.9.6 // indirect github.com/Azure/go-autorest/autorest/adal v0.8.2 // indirect github.com/Azure/go-autorest/autorest/azure/auth v0.4.2 // indirect github.com/Azure/go-autorest/autorest/azure/cli v0.3.1 // indirect github.com/Azure/go-autorest/autorest/date v0.2.0 // indirect - github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect github.com/Azure/go-autorest/logger v0.1.0 // indirect github.com/Azure/go-autorest/tracing v0.5.0 // indirect github.com/ClickHouse/clickhouse-go v1.5.4 // indirect @@ -130,7 +127,6 @@ require ( github.com/aokoli/goutils v1.0.1 // indirect github.com/apache/thrift v0.12.0 // indirect github.com/aws/aws-sdk-go v1.39.0 // indirect - github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect github.com/basgys/goxml2json v1.1.1-0.20181031222924-996d9fc8d313 // indirect github.com/beevik/etree v1.1.0 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -145,7 +141,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect github.com/dimchansky/utfbom v1.1.0 // indirect - github.com/dnaeon/go-vcr v1.1.0 // indirect github.com/dnstap/golang-dnstap v0.0.0-20170829151710-2cf77a2b5e11 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/eapache/go-resiliency v1.1.0 // indirect @@ -154,6 +149,7 @@ require ( github.com/edsrzf/mmap-go v1.0.0 // indirect github.com/elgatito/upnp v0.0.0-20180711183757-2f244d205f9a // indirect github.com/farsightsec/golang-framestream v0.0.0-20181102145529-8a0cb8ba8710 // indirect + github.com/fatih/color v1.13.0 // indirect github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect github.com/frankban/quicktest v1.14.3 // indirect github.com/gin-contrib/sse v0.1.0 // indirect @@ -192,6 +188,7 @@ require ( github.com/lestrrat-go/pdebug v0.0.0-20200204225717-4d6bd78da58d // indirect github.com/lestrrat/go-pdebug v0.0.0-20180220043741-569c97477ae8 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect + github.com/ma314smith/signedxml v0.0.0-20210628192057-abc5b481ae1c // indirect github.com/mattn/go-colorable v0.1.9 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect @@ -206,6 +203,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/mozillazg/go-httpheader v0.2.1 // indirect + github.com/mozillazg/go-pinyin v0.19.0 // indirect github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae // indirect github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 // indirect github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492 // indirect @@ -225,7 +223,7 @@ require ( github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46 // indirect github.com/satori/go.uuid v1.2.0 // indirect github.com/sirupsen/logrus v1.9.0 // indirect - github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect + github.com/smartystreets/assertions v1.2.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.5.0 // indirect @@ -246,10 +244,10 @@ require ( go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.17.0 // indirect golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect - golang.org/x/mod v0.4.2 // indirect + golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect - golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect - golang.org/x/tools v0.1.2 // indirect + golang.org/x/term v0.1.0 // indirect + golang.org/x/tools v0.1.12 // indirect google.golang.org/api v0.30.0 // indirect google.golang.org/appengine v1.6.6 // indirect google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect @@ -257,7 +255,7 @@ require ( gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/ini.v1 v1.44.0 // indirect + gopkg.in/ini.v1 v1.62.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect k8s.io/klog/v2 v2.2.0 // indirect k8s.io/utils v0.0.0-20200729134348-d5654de09c73 // indirect diff --git a/go.sum b/go.sum index b9b09e8ede..c91f0a7650 100644 --- a/go.sum +++ b/go.sum @@ -64,7 +64,6 @@ github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxB github.com/Azure/go-autorest/autorest/mocks v0.3.0 h1:qJumjCaCudz+OcqE9/XtEPfvtOjOmKaui4EOpFI6zZc= github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= github.com/Azure/go-autorest/autorest/to v0.4.0 h1:oXVqrxakqqV1UZdSazDOPOLvOIz+XA683u8EctwboHk= -github.com/Azure/go-autorest/autorest/to v0.4.0/go.mod h1:fE8iZBn7LQR7zH/9XU2NcPR4o9jEImooCeWJcYV/zLE= github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k= @@ -154,7 +153,6 @@ github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb github.com/aws/aws-sdk-go v1.39.0 h1:74BBwkEmiqBbi2CGflEh34l0YNtIibTjZsibGarkNjo= github.com/aws/aws-sdk-go v1.39.0/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f h1:ZNv7On9kyUzm7fvRZumSyy/IUiSC7AzL0I1jKKtwooA= -github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= github.com/basgys/goxml2json v1.1.1-0.20181031222924-996d9fc8d313 h1:fKPpQHBQgt4dQuG6x+yH4gdgtodFDgN9rvHzwJzTKeg= github.com/basgys/goxml2json v1.1.1-0.20181031222924-996d9fc8d313/go.mod h1:wH7a5Np/Q4QoECFIU8zTQlZwZkrilY0itPfecMw41Dw= github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs= @@ -211,8 +209,7 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumC github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dimchansky/utfbom v1.1.0 h1:FcM3g+nofKgUteL8dm/UpdRXNC9KmADgTpLKsu0TRo4= github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnstap/golang-dnstap v0.0.0-20170829151710-2cf77a2b5e11 h1:m8nX8hsUghn853BJ5qB0lX+VvS6LTJPksWyILFZRYN4= github.com/dnstap/golang-dnstap v0.0.0-20170829151710-2cf77a2b5e11/go.mod h1:s1PfVYYVmTMgCSPtho4LKBDecEHJWtiVDPNv78Z985U= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= @@ -438,7 +435,6 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGw github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/jsimonetti/rtnetlink v0.0.0-20190606172950-9527aa82566a/go.mod h1:Oz+70psSo5OFh8DBl0Zv2ACw7Esh6pPUphlvZG9x7uw= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -522,10 +518,6 @@ github.com/mdlayher/arp v0.0.0-20190313224443-98a83c8a2717/go.mod h1:eOj1DDj3NAZ github.com/mdlayher/ethernet v0.0.0-20190313224307-5b5fc417d966/go.mod h1:5s5p/sMJ6sNsFl6uCh85lkFGV8kLuIYJCRJLavVJwvg= github.com/mdlayher/ethernet v0.0.0-20190606142754-0394541c37b7 h1:lez6TS6aAau+8wXUP3G9I3TGlmPFEq2CTxBaRqY6AGE= github.com/mdlayher/ethernet v0.0.0-20190606142754-0394541c37b7/go.mod h1:U6ZQobyTjI/tJyq2HG+i/dfSoFUt8/aZCM+GKtmFk/Y= -github.com/mdlayher/genetlink v0.0.0-20191004171646-5cf585d3b847/go.mod h1:LNhNWFVJapYK8zEjVHUIle4gy+Oahfc3UtcaqZ8Dz98= -github.com/mdlayher/netlink v0.0.0-20190409211403-11939a169225/go.mod h1:eQB3mZE4aiYnlUsyGGCOpPETfdQq4Jhsgf1fk3cwQaA= -github.com/mdlayher/netlink v0.0.0-20191004170026-3c8695cb0643/go.mod h1:KxeJAFOFLG6AjpyDkQ/iIhxygIUKD+vcwqcnu43w/+M= -github.com/mdlayher/netlink v0.0.0-20191008140946-2a17fd90af51/go.mod h1:KxeJAFOFLG6AjpyDkQ/iIhxygIUKD+vcwqcnu43w/+M= github.com/mdlayher/raw v0.0.0-20190313224157-43dbcdd7739d/go.mod h1:r1fbeITl2xL/zLbVnNHFyOzQJTgr/3fpf1lJX/cjzR8= github.com/mdlayher/raw v0.0.0-20190606142536-fef19f00fc18/go.mod h1:7EpbotpCmVZcu+KCX4g9WaRNuu11uyhiW7+Le1dKawg= github.com/mdlayher/raw v0.0.0-20190606144222-a54781e5f38f h1:Xjvm7UTnKTwrlhbs+8qA6I0v1iX77rY3QxftSgvOVRk= @@ -536,7 +528,6 @@ github.com/mholt/caddy v0.10.11 h1:s8X+R8DuBbrrMuUTcWSxlDe567B0s5EDmiDBKSYsioY= github.com/mholt/caddy v0.10.11/go.mod h1:Wb1PlT4DAYSqOEd03MsqkdkXnTxA8v9pKjdpxbqM1kY= github.com/miekg/dns v1.1.25 h1:dFwPR6SfLtrSwgDcIq2bcU/gVutB4sNApq2HBdqcakg= github.com/miekg/dns v1.1.25/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= -github.com/mikioh/ipaddr v0.0.0-20190404000644-d465c8ab6721/go.mod h1:Ickgr2WtCLZ2MDGd4Gr0geeCH5HybhRJbonOgQpvSxc= github.com/minio/cli v1.20.0/go.mod h1:bYxnK0uS629N3Bq+AOZZ+6lwF77Sodk4+UL9vNuXhOY= github.com/minio/minio-go v6.0.14+incompatible h1:fnV+GD28LeqdN6vT2XdGKW8Qe/IfjJDswNVuni6km9o= github.com/minio/minio-go v6.0.14+incompatible/go.mod h1:7guKYtitv8dktvNUGrhzmNlA5wrAABTQXCoesZdFQO8= @@ -556,13 +547,12 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ= github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60= -github.com/mozillazg/go-pinyin v0.15.0 h1:sSwlnsogK/WMzcf0HnjgxyAI4GU6LFqwXnhr77q1Z80= -github.com/mozillazg/go-pinyin v0.15.0/go.mod h1:bO+dztNW6O2lSJdYLha7LO3bujXzjjU3UvKb2IGANfg= +github.com/mozillazg/go-pinyin v0.19.0 h1:p+J8/kjJ558KPvVGYLvqBhxf8jbZA2exSLCs2uUVN8c= +github.com/mozillazg/go-pinyin v0.19.0/go.mod h1:iR4EnMMRXkfpFVV5FMi4FNB6wGq9NV6uDWbUuPhP4Yc= github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae h1:VeRdUYdCw49yizlSbMEn2SZ+gT+3IUKx8BqxyQdz+BY= github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= @@ -657,12 +647,14 @@ github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9 h1:lpEzuenPuO1XNTeikEmvqYFcU37GVLl8SRNblzyvGBE= github.com/skip2/go-qrcode v0.0.0-20190110000554-dc11ecdae0a9/go.mod h1:PLPIyL7ikehBD1OAjmKKiOEhbvWyHGaNDjquXMcYABo= github.com/smartystreets/assertions v0.0.0-20180607162144-eb5b59917fa2/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs= +github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg= +github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM= github.com/smartystreets/gunit v0.0.0-20180314194857-6f0d6275bdcd/go.mod h1:XUKj4gbqj2QvJk/OdLWzyZ3FYli0f+MdpngyryX0gcw= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= @@ -707,10 +699,8 @@ github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03O github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o= github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= -github.com/tredoe/fileutil v1.0.5/go.mod h1:HFzzpvg+3Q8LgmZgo1mVF5epHc/CVkWKEb3hja+/1Zo= -github.com/tredoe/goutil v1.0.0/go.mod h1:Qhf75QLcNEChimbl4wb8nROzw9PCFCPYTEUmTnoszXY= -github.com/tredoe/osutil v1.0.6 h1:KJvG9AFmUPLe3hsNKyPMIjNx77CkAJtMKVS4ugAT7vM= -github.com/tredoe/osutil v1.0.6/go.mod h1:zNq93p2DLHJWkHi2/+zi3xOjZl8xxiv3tiI2A6zcB3w= +github.com/tredoe/osutil/v2 v2.0.0-rc.16 h1:5A2SKvyB2c3lhPYUIHyFtu6jbaXlaA3Hu5gWIam8Pik= +github.com/tredoe/osutil/v2 v2.0.0-rc.16/go.mod h1:uLRVx/3pb7Y4RQhG8cQFbPE9ha5r81e6MXpBsxbTAYc= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= @@ -763,15 +753,13 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= -golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA= -golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= +golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -805,8 +793,9 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20180524181706-dfa909b99c79/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -826,10 +815,7 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191003171128-d98b1b443823/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191007182048-72f939374954/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -849,8 +835,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2 h1:6mzvA99KwZxbOrxww4EvWVQUnN1+xEu9tafK5ZxkYeA= -golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -868,8 +854,9 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180724212812-e072cadbbdc8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -880,7 +867,6 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190411185658-b44545bcd369/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190418153312-f0ce4c0180be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -891,15 +877,11 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190830023255-19e00faab6ad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191003212358-c178f38b412c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -938,11 +920,11 @@ golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY= -golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0 h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -950,8 +932,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1006,16 +988,16 @@ golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.2 h1:kRBLX7v7Af8W7Gdbbc908OJcdgtK8bOz9Uaj8/F1ACA= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.zx2c4.com/wireguard v0.0.20190908/go.mod h1:LhfXh5z6bLC2lW2ve6BzYZFwnnsXK3OQjySR0Yh2dO8= -golang.zx2c4.com/wireguard/wgctrl v0.0.0-20191008142428-8d021180e987 h1:26OAgqBTufVr8WKonCEhhjO1oKsYhHv0iM5Dg92G1TM= -golang.zx2c4.com/wireguard/wgctrl v0.0.0-20191008142428-8d021180e987/go.mod h1:7hq1rEDsx7/FWl8IEEnfH2Xhs6M2MNnjUfN0PeI8Rm0= +golang.zx2c4.com/wireguard/wgctrl v0.0.0-20221104135756-97bc4ad4a1cb h1:9aqVcYEDHmSNb0uOWukxV5lHV09WqiSiCuhEgWNETLY= +golang.zx2c4.com/wireguard/wgctrl v0.0.0-20221104135756-97bc4ad4a1cb/go.mod h1:mQqgjkW8GQQcJQsbBvK890TKqUK1DfKWkuBGbOkuMHQ= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -1119,8 +1101,8 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.44.0 h1:YRJzTUp0kSYWUVFF5XAbDFfyiqwsl0Vb9R8TVP5eRi0= -gopkg.in/ini.v1 v1.44.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= +gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ldap.v3 v3.0.3 h1:YKRHW/2sIl05JsCtx/5ZuUueFuJyoj/6+DGXe3wp6ro= gopkg.in/ldap.v3 v3.0.3/go.mod h1:oxD7NyBuxchC+SgJDE1Q5Od05eGt29SDQVBmV+HYbzw= gopkg.in/mail.v2 v2.3.1 h1:WYFn/oANrAGP2C0dcV6/pbkPzv8yGzqTjPmTeO7qoXk= @@ -1176,8 +1158,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221221074003-215a6ca48a2a h1:Bb9jP8uWbWDpJBLbHnT/6QPE/wGE1HgfriCrsfxr6V8= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221221074003-215a6ca48a2a/go.mod h1:drc/WDD65r6wI1tSejk19xcl9QwmzZlgJGXN7a9o2KQ= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221226041034-c7119501d505 h1:CvEQdksWw/DTC6GPIBCjTjW4ZryojUzw+PGmRtLCETM= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221226041034-c7119501d505/go.mod h1:yEMFtIKPyIdIfPzsw7oTcH41JXc8G5StUAQw3ZoGj5I= yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656 h1:0zlZD5uhZoIHgLVAWCz2aHaYk2ZrNsACCYD7R6EIBII= yunion.io/x/executor v0.0.0-20211018100936-39a2cd966656/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws= yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634= @@ -1194,8 +1176,8 @@ yunion.io/x/pkg v0.0.0-20190620104149-945c25821dbf/go.mod h1:t6rEGG2sQ4J7DhFxSZV yunion.io/x/pkg v0.0.0-20190628082551-f4033ba2ea30/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E= yunion.io/x/pkg v0.0.0-20200814072949-4f1b541857d6/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E= yunion.io/x/pkg v1.0.1-0.20220819080140-55b265a8658e/go.mod h1:nYOMflWG1wQC6301rGVglQva9bYbJxHThEJUxRAgMFc= -yunion.io/x/pkg v1.0.1-0.20221031045951-0b770b490c45 h1:IHnBCHsL/6SquvVq84YP+aVewZ490SOazCbUjOg2Lr0= -yunion.io/x/pkg v1.0.1-0.20221031045951-0b770b490c45/go.mod h1:nYOMflWG1wQC6301rGVglQva9bYbJxHThEJUxRAgMFc= +yunion.io/x/pkg v1.0.1-0.20221226030310-a8727011fc76 h1:Kg/4ZcA4Cnac3KclHmD2OiaHaQdyRJZ3KWJKUfqFQfY= +yunion.io/x/pkg v1.0.1-0.20221226030310-a8727011fc76/go.mod h1:ksCJVQ+DwKrJ5QBEoU8pzrDFfDaZVAFH/iJ6yQCYxJk= yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e h1:v+EzIadodSwkdZ/7bremd7J8J50Cise/HCylsOJngmo= yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e/go.mod h1:0iFKpOs1y4lbCxeOmq3Xx/0AcQoewVPwj62eRluioEo= yunion.io/x/sqlchemy v1.0.1/go.mod h1:FTdwPdGhMgh4E+UFXc9klI1Ok34fMuybTT+jLhOaIjI= diff --git a/pkg/ansibleserver/models/ansibleplaybook_instance.go b/pkg/ansibleserver/models/ansibleplaybook_instance.go index 99988aafa5..5c9521ac27 100644 --- a/pkg/ansibleserver/models/ansibleplaybook_instance.go +++ b/pkg/ansibleserver/models/ansibleplaybook_instance.go @@ -21,12 +21,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/ansibleserver/options" api "yunion.io/x/onecloud/pkg/apis/ansible" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/workmanager" "yunion.io/x/onecloud/pkg/mcclient" diff --git a/pkg/ansibleserver/models/ansibleplaybookreference.go b/pkg/ansibleserver/models/ansibleplaybookreference.go index e771dc4bfb..9bcfc43188 100644 --- a/pkg/ansibleserver/models/ansibleplaybookreference.go +++ b/pkg/ansibleserver/models/ansibleplaybookreference.go @@ -20,12 +20,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/ansible" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SAnsiblePlaybookReference struct { @@ -54,8 +54,8 @@ func init() { AnsiblePlaybookReferenceManager.SetVirtualObject(AnsiblePlaybookReferenceManager) } -func (arm *SAnsiblePlaybookReferenceManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (arm *SAnsiblePlaybookReferenceManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } var ( diff --git a/pkg/apigateway/handler/auth.go b/pkg/apigateway/handler/auth.go index 81d18b1769..a6d772e7f3 100644 --- a/pkg/apigateway/handler/auth.go +++ b/pkg/apigateway/handler/auth.go @@ -25,6 +25,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/apigateway/clientman" "yunion.io/x/onecloud/pkg/apigateway/constants" @@ -40,10 +43,8 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/modulebase" compute_modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" "yunion.io/x/onecloud/pkg/util/netutils2" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/seclib2" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -404,14 +405,14 @@ func (h *AuthHandlers) doCredentialLogin(ctx context.Context, req *http.Request, if len(tenant) == 0 { token3, ok := token.(*mcclient.TokenCredentialV3) if ok { - targetLevel := rbacutils.ScopeProject + targetLevel := rbacscope.ScopeProject targetProjId := "" for _, r := range token3.Token.RoleAssignments { - level := rbacutils.ScopeProject + level := rbacscope.ScopeProject if len(r.Policies.System) > 0 { - level = rbacutils.ScopeSystem + level = rbacscope.ScopeSystem } else if len(r.Policies.Domain) > 0 { - level = rbacutils.ScopeDomain + level = rbacscope.ScopeDomain } if len(targetProjId) == 0 || level.HigherThan(targetLevel) { targetProjId = r.Scope.Project.Id @@ -603,15 +604,15 @@ func (h *AuthHandlers) doLogin(ctx context.Context, w http.ResponseWriter, req * if len(token.GetProjectId()) > 0 { if body.Contains("isadmin") { adminVal := "false" - if policy.PolicyManager.IsScopeCapable(token, rbacutils.ScopeSystem) { + if policy.PolicyManager.IsScopeCapable(token, rbacscope.ScopeSystem) { adminVal, _ = body.GetString("isadmin") } saveCookie(w, "isadmin", adminVal, "", token.GetExpires(), false) } if body.Contains("scope") { scopeStr, _ := body.GetString("scope") - if !policy.PolicyManager.IsScopeCapable(token, rbacutils.TRbacScope(scopeStr)) { - scopeStr = string(rbacutils.ScopeProject) + if !policy.PolicyManager.IsScopeCapable(token, rbacscope.TRbacScope(scopeStr)) { + scopeStr = string(rbacscope.ScopeProject) } saveCookie(w, "scope", scopeStr, "", token.GetExpires(), false) } @@ -748,10 +749,10 @@ func (this *projectRoles) json(s *mcclient.ClientSession, user, userId, domain, obj.Add(roles, "roles") policies, _ := modules.RolePolicies.FetchMatchedPolicies(s, roleIds, this.id, ip) - for _, scope := range []rbacutils.TRbacScope{ - rbacutils.ScopeProject, - rbacutils.ScopeDomain, - rbacutils.ScopeSystem, + for _, scope := range []rbacscope.TRbacScope{ + rbacscope.ScopeProject, + rbacscope.ScopeDomain, + rbacscope.ScopeSystem, } { if matches, ok := policies[string(scope)]; ok { obj.Add(jsonutils.NewStringArray(matches), fmt.Sprintf("%s_policies", scope)) @@ -761,7 +762,7 @@ func (this *projectRoles) json(s *mcclient.ClientSession, user, userId, domain, obj.Add(jsonutils.JSONFalse, fmt.Sprintf("%s_capable", scope)) } // backward compatible - if scope == rbacutils.ScopeSystem { + if scope == rbacscope.ScopeSystem { if len(matches) > 0 { obj.Add(jsonutils.JSONTrue, "admin_capable") } else { @@ -963,16 +964,16 @@ func getUserInfo2(s *mcclient.ClientSession, uid string, pid string, loginIp str data.Add(projJson, "projects") if len(pid) > 0 { - for _, scope := range []rbacutils.TRbacScope{ - rbacutils.ScopeSystem, - rbacutils.ScopeDomain, - rbacutils.ScopeProject, + for _, scope := range []rbacscope.TRbacScope{ + rbacscope.ScopeSystem, + rbacscope.ScopeDomain, + rbacscope.ScopeProject, } { if p, ok := policies[string(scope)]; ok { data.Add(jsonutils.NewStringArray(p), fmt.Sprintf("%s_policies", scope)) - if scope == rbacutils.ScopeSystem { + if scope == rbacscope.ScopeSystem { data.Add(jsonutils.NewStringArray(p), "admin_policies") - } else if scope == rbacutils.ScopeProject { + } else if scope == rbacscope.ScopeProject { data.Add(jsonutils.NewStringArray(p), "policies") } } @@ -1163,17 +1164,17 @@ func (h *AuthHandlers) doDeletePolicies(ctx context.Context, w http.ResponseWrit return } idStrList := jsonutils.JSONArray2StringArray(idlist) - ret := make([]modulebase.SubmitResult, len(idStrList)) + ret := make([]printutils.SubmitResult, len(idStrList)) for i := range idStrList { err := policytool.PolicyDelete(s, idStrList[i]) if err != nil { - ret[i] = modulebase.SubmitResult{ + ret[i] = printutils.SubmitResult{ Status: 400, Id: idStrList[i], Data: jsonutils.NewString(err.Error()), } } else { - ret[i] = modulebase.SubmitResult{ + ret[i] = printutils.SubmitResult{ Status: 200, Id: idStrList[i], Data: jsonutils.NewDict(), diff --git a/pkg/apigateway/handler/auth_totp.go b/pkg/apigateway/handler/auth_totp.go index 05156255c8..86c166a5b7 100644 --- a/pkg/apigateway/handler/auth_totp.go +++ b/pkg/apigateway/handler/auth_totp.go @@ -26,6 +26,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/apigateway/options" "yunion.io/x/onecloud/pkg/appsrv" @@ -33,7 +34,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - "yunion.io/x/onecloud/pkg/util/httputils" ) // 转换成base64编码qrcode。 diff --git a/pkg/apigateway/handler/backendproxy.go b/pkg/apigateway/handler/backendproxy.go index d50f115538..71e65c601f 100644 --- a/pkg/apigateway/handler/backendproxy.go +++ b/pkg/apigateway/handler/backendproxy.go @@ -23,8 +23,8 @@ import ( "time" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient/auth" diff --git a/pkg/apigateway/handler/csrfexempt.go b/pkg/apigateway/handler/csrfexempt.go index e03416fcbe..7b3220f30e 100644 --- a/pkg/apigateway/handler/csrfexempt.go +++ b/pkg/apigateway/handler/csrfexempt.go @@ -21,9 +21,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/util/sets" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" diff --git a/pkg/apigateway/handler/idp.go b/pkg/apigateway/handler/idp.go index 14faa2138a..1b912c19db 100644 --- a/pkg/apigateway/handler/idp.go +++ b/pkg/apigateway/handler/idp.go @@ -25,18 +25,18 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/apigateway/options" api "yunion.io/x/onecloud/pkg/apis/identity" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/netutils2" ) diff --git a/pkg/apigateway/handler/k8s.go b/pkg/apigateway/handler/k8s.go index cfda4daa42..a5d8c0aea1 100644 --- a/pkg/apigateway/handler/k8s.go +++ b/pkg/apigateway/handler/k8s.go @@ -21,8 +21,8 @@ import ( "path" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/appctx" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" diff --git a/pkg/apigateway/handler/middleware.go b/pkg/apigateway/handler/middleware.go index fdf5505164..ec04d25c76 100644 --- a/pkg/apigateway/handler/middleware.go +++ b/pkg/apigateway/handler/middleware.go @@ -21,11 +21,11 @@ import ( "strings" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" "yunion.io/x/onecloud/pkg/apigateway/clientman" "yunion.io/x/onecloud/pkg/apigateway/constants" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" ) diff --git a/pkg/apigateway/handler/misc.go b/pkg/apigateway/handler/misc.go index 94101f707e..8dcbcf848c 100644 --- a/pkg/apigateway/handler/misc.go +++ b/pkg/apigateway/handler/misc.go @@ -29,10 +29,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/apigateway/options" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" @@ -40,7 +41,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - "yunion.io/x/onecloud/pkg/util/httputils" ) const contentTypeSpreadsheet = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" diff --git a/pkg/apigateway/handler/oidc.go b/pkg/apigateway/handler/oidc.go index 8b1591d020..e9963e60cf 100644 --- a/pkg/apigateway/handler/oidc.go +++ b/pkg/apigateway/handler/oidc.go @@ -31,6 +31,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/netutils" "yunion.io/x/onecloud/pkg/apigateway/clientman" @@ -40,7 +41,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/netutils2" "yunion.io/x/onecloud/pkg/util/oidcutils" ) diff --git a/pkg/apigateway/handler/request.go b/pkg/apigateway/handler/request.go index 69a3278685..13a3ece3be 100644 --- a/pkg/apigateway/handler/request.go +++ b/pkg/apigateway/handler/request.go @@ -21,9 +21,9 @@ import ( "github.com/pkg/errors" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/utils" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" diff --git a/pkg/apigateway/handler/resource.go b/pkg/apigateway/handler/resource.go index e4ed52ef8d..7995494c62 100644 --- a/pkg/apigateway/handler/resource.go +++ b/pkg/apigateway/handler/resource.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/appsrv" @@ -326,7 +327,7 @@ func (f *ResourceHandlers) getSpecHandler(ctx context.Context, w http.ResponseWr return } jmod, e := modulebase.GetJointModule2(session, module, module2) - var ret *modulebase.ListResult + var ret *printutils.ListResult if e == nil { // joint module ret, e = jmod.ListDescendent(session, req.ResID(), query) } else { @@ -553,7 +554,7 @@ func (f *ResourceHandlers) batchUpdateHandler(ctx context.Context, w http.Respon return } - var ret []modulebase.SubmitResult + var ret []printutils.SubmitResult if jsonutils.QueryBoolean(query, "batch_params", false) { bodys, err := body.GetArray() if err != nil { @@ -821,7 +822,7 @@ func (f *ResourceHandlers) batchDetachHandler(ctx context.Context, w http.Respon module := req.Mod1() module2 := req.Mod2() jmod, e := modulebase.GetJointModule2(session, module, module2) - var ret []modulebase.SubmitResult + var ret []printutils.SubmitResult if e == nil { ret = jmod.BatchDetach(session, req.ResID(), idlist) } else { diff --git a/pkg/apigateway/handler/rpc.go b/pkg/apigateway/handler/rpc.go index de9d91dde3..de4a63872a 100644 --- a/pkg/apigateway/handler/rpc.go +++ b/pkg/apigateway/handler/rpc.go @@ -22,14 +22,15 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/pkg/utils" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modulebase" - "yunion.io/x/onecloud/pkg/util/httputils" ) type RPCHandlers struct { @@ -120,7 +121,7 @@ func RpcHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) { return } - v2, ok := retobj.Interface().([]modulebase.SubmitResult) + v2, ok := retobj.Interface().([]printutils.SubmitResult) if ok { w.WriteHeader(207) appsrv.SendJSON(w, modulebase.SubmitResults2JSON(v2)) diff --git a/pkg/apigateway/report/report.go b/pkg/apigateway/report/report.go index f55f5365b2..2015de6016 100644 --- a/pkg/apigateway/report/report.go +++ b/pkg/apigateway/report/report.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/version" "yunion.io/x/pkg/utils" @@ -32,7 +33,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - "yunion.io/x/onecloud/pkg/util/httputils" ) type sReport struct { diff --git a/pkg/apihelper/apihelper.go b/pkg/apihelper/apihelper.go index ba1da24808..0d94dcc92a 100644 --- a/pkg/apihelper/apihelper.go +++ b/pkg/apihelper/apihelper.go @@ -22,11 +22,11 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/pkg/apihelper/reflect.go b/pkg/apihelper/reflect.go index 04151d96be..726093d7b6 100644 --- a/pkg/apihelper/reflect.go +++ b/pkg/apihelper/reflect.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/onecloud/pkg/cloudcommon/db" @@ -55,7 +56,7 @@ func GetModels(opts *GetModelsOptions) error { tstr := timeutils.MysqlTime(time) return fmt.Sprintf("updated_at.ge('%s')", tstr) } - setNextListParams := func(params *jsonutils.JSONDict, lastUpdatedAt time.Time, lastResult *mcclient_modulebase.ListResult) (time.Time, error) { + setNextListParams := func(params *jsonutils.JSONDict, lastUpdatedAt time.Time, lastResult *printutils.ListResult) (time.Time, error) { // NOTE: the updated_at field has second-level resolution. // If they all have the same date... var max time.Time diff --git a/pkg/apis/identity/input.go b/pkg/apis/identity/input.go index 06c6de218f..c56eb45559 100644 --- a/pkg/apis/identity/input.go +++ b/pkg/apis/identity/input.go @@ -17,9 +17,9 @@ package identity import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/apis" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/tagutils" ) @@ -440,7 +440,7 @@ type PolicyUpdateInput struct { Blob jsonutils.JSONObject `json:"blob"` // 生效范围,project|domain|system - Scope rbacutils.TRbacScope `json:"scope"` + Scope rbacscope.TRbacScope `json:"scope"` // 是否为系统权限 IsSystem *bool `json:"is_system"` @@ -542,7 +542,7 @@ type PolicyCreateInput struct { Blob jsonutils.JSONObject `json:"blob"` // 生效范围,project|domain|system - Scope rbacutils.TRbacScope `json:"scope"` + Scope rbacscope.TRbacScope `json:"scope"` // 是否为系统权限 IsSystem *bool `json:"is_system"` diff --git a/pkg/apis/identity/role.go b/pkg/apis/identity/role.go index 17770755ef..e86ecec2e9 100644 --- a/pkg/apis/identity/role.go +++ b/pkg/apis/identity/role.go @@ -15,8 +15,9 @@ package identity import ( + "yunion.io/x/pkg/util/rbacscope" + "yunion.io/x/onecloud/pkg/apis" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type RoleDetails struct { @@ -36,5 +37,5 @@ type RoleDetails struct { MatchPolicies []string `json:"match_policies"` // 不同级别的权限的名称列表 - Policies map[rbacutils.TRbacScope][]string `json:"policies"` + Policies map[rbacscope.TRbacScope][]string `json:"policies"` } diff --git a/pkg/apis/identity/rolepolicy.go b/pkg/apis/identity/rolepolicy.go index fe2f712a22..3757d3fed2 100644 --- a/pkg/apis/identity/rolepolicy.go +++ b/pkg/apis/identity/rolepolicy.go @@ -17,8 +17,9 @@ package identity import ( "time" + "yunion.io/x/pkg/util/rbacscope" + "yunion.io/x/onecloud/pkg/apis" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type RolePolicyListInput struct { @@ -46,7 +47,7 @@ type RolePolicyDetails struct { Policy string `json:"policy"` - Scope rbacutils.TRbacScope `json:"scope"` + Scope rbacscope.TRbacScope `json:"scope"` Description string `json:"description"` diff --git a/pkg/apis/share.go b/pkg/apis/share.go index 31f0bfda5f..8bf6c9e050 100644 --- a/pkg/apis/share.go +++ b/pkg/apis/share.go @@ -15,7 +15,8 @@ package apis import ( - "yunion.io/x/onecloud/pkg/util/rbacutils" + "yunion.io/x/pkg/util/rbacscope" + "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -27,14 +28,14 @@ const ( type SAccountShareInfo struct { IsPublic bool - PublicScope rbacutils.TRbacScope + PublicScope rbacscope.TRbacScope ShareMode string SharedDomains []string } type SShareInfo struct { IsPublic bool - PublicScope rbacutils.TRbacScope + PublicScope rbacscope.TRbacScope SharedDomains []string SharedProjects []string } @@ -44,16 +45,16 @@ func (i SAccountShareInfo) GetProjectShareInfo() SShareInfo { switch i.ShareMode { case CLOUD_ACCOUNT_SHARE_MODE_ACCOUNT_DOMAIN: ret.IsPublic = true - ret.PublicScope = rbacutils.ScopeDomain + ret.PublicScope = rbacscope.ScopeDomain case CLOUD_ACCOUNT_SHARE_MODE_PROVIDER_DOMAIN: ret.IsPublic = true - ret.PublicScope = rbacutils.ScopeDomain + ret.PublicScope = rbacscope.ScopeDomain case CLOUD_ACCOUNT_SHARE_MODE_SYSTEM: ret.IsPublic = true - if i.IsPublic && i.PublicScope == rbacutils.ScopeSystem { - ret.PublicScope = rbacutils.ScopeSystem + if i.IsPublic && i.PublicScope == rbacscope.ScopeSystem { + ret.PublicScope = rbacscope.ScopeSystem } else { - ret.PublicScope = rbacutils.ScopeDomain + ret.PublicScope = rbacscope.ScopeDomain ret.SharedDomains = i.SharedDomains } } @@ -65,21 +66,21 @@ func (i SAccountShareInfo) GetDomainShareInfo() SShareInfo { switch i.ShareMode { case CLOUD_ACCOUNT_SHARE_MODE_ACCOUNT_DOMAIN: ret.IsPublic = false - ret.PublicScope = rbacutils.ScopeNone + ret.PublicScope = rbacscope.ScopeNone case CLOUD_ACCOUNT_SHARE_MODE_PROVIDER_DOMAIN: ret.IsPublic = false - ret.PublicScope = rbacutils.ScopeNone + ret.PublicScope = rbacscope.ScopeNone case CLOUD_ACCOUNT_SHARE_MODE_SYSTEM: - if i.IsPublic && i.PublicScope == rbacutils.ScopeSystem { + if i.IsPublic && i.PublicScope == rbacscope.ScopeSystem { ret.IsPublic = true - ret.PublicScope = rbacutils.ScopeSystem + ret.PublicScope = rbacscope.ScopeSystem } else if len(i.SharedDomains) > 0 { ret.IsPublic = true - ret.PublicScope = rbacutils.ScopeDomain + ret.PublicScope = rbacscope.ScopeDomain ret.SharedDomains = i.SharedDomains } else { ret.IsPublic = false - ret.PublicScope = rbacutils.ScopeNone + ret.PublicScope = rbacscope.ScopeNone } } return ret @@ -135,9 +136,9 @@ func (i SShareInfo) Intersect(i2 SShareInfo) SShareInfo { SharedDomains: domains, SharedProjects: projs, } - if ret.PublicScope == rbacutils.ScopeProject && len(ret.SharedProjects) == 0 { + if ret.PublicScope == rbacscope.ScopeProject && len(ret.SharedProjects) == 0 { ret.IsPublic = false - ret.PublicScope = rbacutils.ScopeNone + ret.PublicScope = rbacscope.ScopeNone } return ret } @@ -151,19 +152,19 @@ func (i SShareInfo) Equals(i2 SShareInfo) bool { } func (i *SShareInfo) FixProjectShare() { - if i.PublicScope == rbacutils.ScopeProject && len(i.SharedProjects) == 0 { + if i.PublicScope == rbacscope.ScopeProject && len(i.SharedProjects) == 0 { i.IsPublic = false - i.PublicScope = rbacutils.ScopeNone + i.PublicScope = rbacscope.ScopeNone } } func (i *SShareInfo) FixDomainShare() { - if i.PublicScope == rbacutils.ScopeProject { + if i.PublicScope == rbacscope.ScopeProject { i.IsPublic = false - i.PublicScope = rbacutils.ScopeNone + i.PublicScope = rbacscope.ScopeNone i.SharedProjects = nil - } else if i.PublicScope == rbacutils.ScopeDomain && len(i.SharedDomains) == 0 { + } else if i.PublicScope == rbacscope.ScopeDomain && len(i.SharedDomains) == 0 { i.IsPublic = false - i.PublicScope = rbacutils.ScopeNone + i.PublicScope = rbacscope.ScopeNone } } diff --git a/pkg/apis/share_test.go b/pkg/apis/share_test.go index 4deeb17c5f..9162b1ca93 100644 --- a/pkg/apis/share_test.go +++ b/pkg/apis/share_test.go @@ -17,7 +17,7 @@ package apis import ( "testing" - "yunion.io/x/onecloud/pkg/util/rbacutils" + "yunion.io/x/pkg/util/rbacscope" ) func TestSShareInfo_IsViolate(t *testing.T) { @@ -32,11 +32,11 @@ func TestSShareInfo_IsViolate(t *testing.T) { name: "case1", s1: SShareInfo{ IsPublic: false, - PublicScope: rbacutils.ScopeNone, + PublicScope: rbacscope.ScopeNone, }, s2: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeSystem, + PublicScope: rbacscope.ScopeSystem, }, violate1: false, violate2: true, @@ -45,12 +45,12 @@ func TestSShareInfo_IsViolate(t *testing.T) { name: "case2", s1: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeProject, + PublicScope: rbacscope.ScopeProject, SharedProjects: []string{"p1"}, }, s2: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeProject, + PublicScope: rbacscope.ScopeProject, SharedProjects: []string{"p2"}, }, violate1: true, @@ -60,12 +60,12 @@ func TestSShareInfo_IsViolate(t *testing.T) { name: "case3", s1: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeDomain, + PublicScope: rbacscope.ScopeDomain, SharedDomains: []string{"p1"}, }, s2: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeProject, + PublicScope: rbacscope.ScopeProject, SharedProjects: []string{"p2"}, }, violate1: true, @@ -75,12 +75,12 @@ func TestSShareInfo_IsViolate(t *testing.T) { name: "case4", s1: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeDomain, + PublicScope: rbacscope.ScopeDomain, SharedDomains: []string{"p1", "p2"}, }, s2: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeDomain, + PublicScope: rbacscope.ScopeDomain, SharedDomains: []string{"p1", "p2"}, }, violate1: false, @@ -107,49 +107,49 @@ func TestSShareInfo_Intersect(t *testing.T) { name: "case1", s1: SShareInfo{ IsPublic: false, - PublicScope: rbacutils.ScopeNone, + PublicScope: rbacscope.ScopeNone, }, s2: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeSystem, + PublicScope: rbacscope.ScopeSystem, }, want: SShareInfo{ IsPublic: false, - PublicScope: rbacutils.ScopeNone, + PublicScope: rbacscope.ScopeNone, }, }, { name: "case2", s1: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeProject, + PublicScope: rbacscope.ScopeProject, SharedProjects: []string{"p1"}, }, s2: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeProject, + PublicScope: rbacscope.ScopeProject, SharedProjects: []string{"p2"}, }, want: SShareInfo{ IsPublic: false, - PublicScope: rbacutils.ScopeNone, + PublicScope: rbacscope.ScopeNone, }, }, { name: "case3", s1: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeDomain, + PublicScope: rbacscope.ScopeDomain, SharedDomains: []string{"p1"}, }, s2: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeProject, + PublicScope: rbacscope.ScopeProject, SharedProjects: []string{"p2"}, }, want: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeProject, + PublicScope: rbacscope.ScopeProject, SharedProjects: []string{"p2"}, }, }, @@ -157,17 +157,17 @@ func TestSShareInfo_Intersect(t *testing.T) { name: "case4", s1: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeDomain, + PublicScope: rbacscope.ScopeDomain, SharedDomains: []string{"p1", "p2"}, }, s2: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeDomain, + PublicScope: rbacscope.ScopeDomain, SharedDomains: []string{"p1", "p2"}, }, want: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeDomain, + PublicScope: rbacscope.ScopeDomain, SharedDomains: []string{"p1", "p2"}, }, }, @@ -175,17 +175,17 @@ func TestSShareInfo_Intersect(t *testing.T) { name: "case5", s1: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeDomain, + PublicScope: rbacscope.ScopeDomain, SharedDomains: []string{"p1", "p2", "p4"}, }, s2: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeDomain, + PublicScope: rbacscope.ScopeDomain, SharedDomains: []string{"p1", "p2", "p3"}, }, want: SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeDomain, + PublicScope: rbacscope.ScopeDomain, SharedDomains: []string{"p1", "p2"}, }, }, diff --git a/pkg/apis/yunionconf/input.go b/pkg/apis/yunionconf/input.go index bc6fd62f38..c5ecaa6cf0 100644 --- a/pkg/apis/yunionconf/input.go +++ b/pkg/apis/yunionconf/input.go @@ -16,9 +16,9 @@ package yunionconf import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/apis" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type ParameterListInput struct { @@ -89,7 +89,7 @@ type ScopedPolicyBindingListInput struct { Effective *bool `json:"effective"` - Scope rbacutils.TRbacScope `json:"scope"` + Scope rbacscope.TRbacScope `json:"scope"` OrderByScopedpolicy string `json:"order_by_scopedpolicy"` } @@ -114,7 +114,7 @@ type ScopedPolicyBindingDetails struct { type ScopedPolicyBindInput struct { // 绑定范围 - Scope rbacutils.TRbacScope `json:"scope"` + Scope rbacscope.TRbacScope `json:"scope"` // 绑定的目标ID(域或者项目ID) TargetIds []string `json:"target_ids"` } diff --git a/pkg/appsrv/appparams.go b/pkg/appsrv/appparams.go index 2b3a53afc8..c6db1658c5 100644 --- a/pkg/appsrv/appparams.go +++ b/pkg/appsrv/appparams.go @@ -18,7 +18,7 @@ import ( "context" "net/http" - "yunion.io/x/onecloud/pkg/appctx" + "yunion.io/x/pkg/appctx" ) const ( diff --git a/pkg/appsrv/appsrv.go b/pkg/appsrv/appsrv.go index 7bb4d6b737..4896585259 100644 --- a/pkg/appsrv/appsrv.go +++ b/pkg/appsrv/appsrv.go @@ -32,15 +32,15 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/trace" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/signalutils" "yunion.io/x/pkg/utils" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/proxy" "yunion.io/x/onecloud/pkg/util/ctx" - "yunion.io/x/onecloud/pkg/util/httputils" ) type Application struct { diff --git a/pkg/appsrv/context.go b/pkg/appsrv/context.go index f9377de191..45ef1dbeba 100644 --- a/pkg/appsrv/context.go +++ b/pkg/appsrv/context.go @@ -18,7 +18,8 @@ import ( "context" "database/sql" - "yunion.io/x/onecloud/pkg/appctx" + "yunion.io/x/pkg/appctx" + "yunion.io/x/onecloud/pkg/util/hashcache" ) diff --git a/pkg/appsrv/dispatcher/dispatcher.go b/pkg/appsrv/dispatcher/dispatcher.go index 192ce0cc8b..efb7c14cda 100644 --- a/pkg/appsrv/dispatcher/dispatcher.go +++ b/pkg/appsrv/dispatcher/dispatcher.go @@ -22,9 +22,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/utils" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/httperrors" diff --git a/pkg/appsrv/dispatcher/handlers.go b/pkg/appsrv/dispatcher/handlers.go index 031c7cf069..63c4439c79 100644 --- a/pkg/appsrv/dispatcher/handlers.go +++ b/pkg/appsrv/dispatcher/handlers.go @@ -19,9 +19,9 @@ import ( "net/http" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/appsrv" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" ) type IMiddlewareFilter interface { @@ -40,12 +40,12 @@ type IModelDispatchHandler interface { KeywordPlural() string ContextKeywordPlurals() [][]string - List(ctx context.Context, query jsonutils.JSONObject, ctxIds []SResourceContext) (*modulebase.ListResult, error) + List(ctx context.Context, query jsonutils.JSONObject, ctxIds []SResourceContext) (*printutils.ListResult, error) Get(ctx context.Context, idstr string, query jsonutils.JSONObject, isHead bool) (jsonutils.JSONObject, error) GetSpecific(ctx context.Context, idstr string, spec string, query jsonutils.JSONObject) (jsonutils.JSONObject, error) Create(ctx context.Context, query jsonutils.JSONObject, data jsonutils.JSONObject, ctxIds []SResourceContext) (jsonutils.JSONObject, error) - BatchCreate(ctx context.Context, query jsonutils.JSONObject, data jsonutils.JSONObject, count int, ctxIds []SResourceContext) ([]modulebase.SubmitResult, error) + BatchCreate(ctx context.Context, query jsonutils.JSONObject, data jsonutils.JSONObject, count int, ctxIds []SResourceContext) ([]printutils.SubmitResult, error) PerformClassAction(ctx context.Context, action string, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) PerformAction(ctx context.Context, idstr string, action string, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) @@ -71,9 +71,9 @@ type IJointModelDispatchHandler interface { MasterKeywordPlural() string SlaveKeywordPlural() string - List(ctx context.Context, query jsonutils.JSONObject, ctxIds []SResourceContext) (*modulebase.ListResult, error) - ListMasterDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*modulebase.ListResult, error) - ListSlaveDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*modulebase.ListResult, error) + List(ctx context.Context, query jsonutils.JSONObject, ctxIds []SResourceContext) (*printutils.ListResult, error) + ListMasterDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*printutils.ListResult, error) + ListSlaveDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*printutils.ListResult, error) Get(ctx context.Context, id1 string, id2 string, query jsonutils.JSONObject) (jsonutils.JSONObject, error) Attach(ctx context.Context, id1 string, id2 string, query jsonutils.JSONObject, body jsonutils.JSONObject) (jsonutils.JSONObject, error) Update(ctx context.Context, id1 string, id2 string, query jsonutils.JSONObject, body jsonutils.JSONObject) (jsonutils.JSONObject, error) diff --git a/pkg/appsrv/dispatcher/jointdispatcher.go b/pkg/appsrv/dispatcher/jointdispatcher.go index 0284b0d157..7603400529 100644 --- a/pkg/appsrv/dispatcher/jointdispatcher.go +++ b/pkg/appsrv/dispatcher/jointdispatcher.go @@ -21,8 +21,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" + "yunion.io/x/pkg/util/printutils" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient/modulebase" @@ -126,7 +127,7 @@ func jointListHandler(ctx context.Context, w http.ResponseWriter, r *http.Reques func jointListDescendentHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { manager, params, query, _ := fetchJointEnv(ctx, w, r) - var listResult *modulebase.ListResult + var listResult *printutils.ListResult var err error if _, ok := params[""]; ok { listResult, err = manager.ListMasterDescendent(ctx, params[""], mergeQueryParams(params, query, "")) diff --git a/pkg/baremetal/agent.go b/pkg/baremetal/agent.go index ad178c8129..888d5ca807 100644 --- a/pkg/baremetal/agent.go +++ b/pkg/baremetal/agent.go @@ -21,6 +21,7 @@ import ( "net/http" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/appsrv" o "yunion.io/x/onecloud/pkg/baremetal/options" @@ -29,7 +30,6 @@ import ( "yunion.io/x/onecloud/pkg/hostman/guestfs/fsdriver" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/procutils" ) diff --git a/pkg/baremetal/manager.go b/pkg/baremetal/manager.go index 4946464868..8d54806b21 100644 --- a/pkg/baremetal/manager.go +++ b/pkg/baremetal/manager.go @@ -32,6 +32,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/netutils" "yunion.io/x/pkg/util/regutils" "yunion.io/x/pkg/util/seclib" @@ -66,7 +67,6 @@ import ( modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/util/dhcp" "yunion.io/x/onecloud/pkg/util/fileutils2" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/influxdb" "yunion.io/x/onecloud/pkg/util/procutils" "yunion.io/x/onecloud/pkg/util/redfish" diff --git a/pkg/baremetal/pxe/dhcp.go b/pkg/baremetal/pxe/dhcp.go index 9c648dcad2..5484021d73 100644 --- a/pkg/baremetal/pxe/dhcp.go +++ b/pkg/baremetal/pxe/dhcp.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/apis" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -30,7 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/types" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/util/dhcp" ) @@ -309,7 +309,7 @@ func (req *dhcpRequest) findNetworkConf(session *mcclient.ClientSession, filterU return &network, err } -func (req *dhcpRequest) findBaremetalsByUuid(session *mcclient.ClientSession) (*modulebase.ListResult, error) { +func (req *dhcpRequest) findBaremetalsByUuid(session *mcclient.ClientSession) (*printutils.ListResult, error) { params := jsonutils.NewDict() params.Add(jsonutils.NewString(req.ClientGuid), "uuid") params.Add(jsonutils.NewString("system"), "scope") @@ -323,7 +323,7 @@ func (req *dhcpRequest) findBaremetalsByUuid(session *mcclient.ClientSession) (* return ret, nil } -func (req *dhcpRequest) findBaremetalsOfAnyMac(session *mcclient.ClientSession, isBaremetal bool) (*modulebase.ListResult, error) { +func (req *dhcpRequest) findBaremetalsOfAnyMac(session *mcclient.ClientSession, isBaremetal bool) (*printutils.ListResult, error) { params := jsonutils.NewDict() params.Add(jsonutils.NewString(req.ClientMac.String()), "any_mac") params.Add(jsonutils.NewString("system"), "scope") diff --git a/pkg/baremetal/tasks/base.go b/pkg/baremetal/tasks/base.go index 81435429ca..26a79234cb 100644 --- a/pkg/baremetal/tasks/base.go +++ b/pkg/baremetal/tasks/base.go @@ -24,9 +24,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/object" o "yunion.io/x/onecloud/pkg/baremetal/options" - "yunion.io/x/onecloud/pkg/cloudcommon/object" "yunion.io/x/onecloud/pkg/cloudcommon/types" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/ssh" diff --git a/pkg/baremetal/tasks/cdrom.go b/pkg/baremetal/tasks/cdrom.go index 565189a4b2..bfeaf8cbf3 100644 --- a/pkg/baremetal/tasks/cdrom.go +++ b/pkg/baremetal/tasks/cdrom.go @@ -21,13 +21,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/onecloud/pkg/apis/compute" o "yunion.io/x/onecloud/pkg/baremetal/options" "yunion.io/x/onecloud/pkg/cloudcommon/types" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/fileutils2" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/redfish" ) diff --git a/pkg/cloudcommon/agent/agent.go b/pkg/cloudcommon/agent/agent.go index 190e0798a3..f6f916b588 100644 --- a/pkg/cloudcommon/agent/agent.go +++ b/pkg/cloudcommon/agent/agent.go @@ -22,16 +22,16 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/object" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/version" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/agent/iagent" "yunion.io/x/onecloud/pkg/cloudcommon/consts" - "yunion.io/x/onecloud/pkg/cloudcommon/object" "yunion.io/x/onecloud/pkg/hostman/storageman" "yunion.io/x/onecloud/pkg/mcclient" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SZoneInfo struct { diff --git a/pkg/cloudcommon/app/options.go b/pkg/cloudcommon/app/options.go index f06467642b..a9ab5c03e4 100644 --- a/pkg/cloudcommon/app/options.go +++ b/pkg/cloudcommon/app/options.go @@ -19,6 +19,7 @@ import ( "net/http" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/consts" @@ -31,7 +32,7 @@ import ( func ExportOptionsHandler(app *appsrv.Application, options interface{}) { hf := func(ctx context.Context, w http.ResponseWriter, r *http.Request) { userCred := auth.FetchUserCredential(ctx, policy.FilterPolicyCredential) - result := policy.PolicyManager.Allow(rbacutils.ScopeSystem, userCred, consts.GetServiceType(), "app-options", "list") + result := policy.PolicyManager.Allow(rbacscope.ScopeSystem, userCred, consts.GetServiceType(), "app-options", "list") if result.Result == rbacutils.Deny { httperrors.ForbiddenError(ctx, w, "Not allow to access") return diff --git a/pkg/cloudcommon/cronman/cronman.go b/pkg/cloudcommon/cronman/cronman.go index 7e546e6a33..b25f9e004f 100644 --- a/pkg/cloudcommon/cronman/cronman.go +++ b/pkg/cloudcommon/cronman/cronman.go @@ -23,9 +23,9 @@ import ( "time" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/elect" "yunion.io/x/onecloud/pkg/mcclient" diff --git a/pkg/cloudcommon/db/apply_manager_method.go b/pkg/cloudcommon/db/apply_manager_method.go index c49a7483de..bc0d7d380f 100644 --- a/pkg/cloudcommon/db/apply_manager_method.go +++ b/pkg/cloudcommon/db/apply_manager_method.go @@ -18,10 +18,10 @@ import ( "context" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -66,13 +66,13 @@ func ApplyQueryDistinctExtraField( } type FilterByOwnerProvider interface { - FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery + FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery } func ApplyFilterByOwner( q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, managers ...FilterByOwnerProvider, ) *sqlchemy.SQuery { for _, manager := range managers { diff --git a/pkg/cloudcommon/db/database.go b/pkg/cloudcommon/db/database.go index bc3ddcdc3a..4831ad492c 100644 --- a/pkg/cloudcommon/db/database.go +++ b/pkg/cloudcommon/db/database.go @@ -23,9 +23,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/sqlchemy" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/splitable" diff --git a/pkg/cloudcommon/db/db_dispatcher.go b/pkg/cloudcommon/db/db_dispatcher.go index 62a9de3b02..d18c4070bd 100644 --- a/pkg/cloudcommon/db/db_dispatcher.go +++ b/pkg/cloudcommon/db/db_dispatcher.go @@ -27,6 +27,8 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" "yunion.io/x/pkg/util/filterclause" + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/version" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -39,7 +41,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/util/logclient" "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" @@ -348,7 +349,7 @@ func mergeFields(metaFields, queryFields []string, isSysAdmin bool) stringutils2 func Query2List(manager IModelManager, ctx context.Context, userCred mcclient.TokenCredential, q *sqlchemy.SQuery, query jsonutils.JSONObject, delayFetch bool) ([]jsonutils.JSONObject, error) { metaFields, excludeFields := listFields(manager, userCred) fieldFilter := jsonutils.GetQueryStringArray(query, "field") - allowListResult := IsAllowList(rbacutils.ScopeSystem, userCred, manager) + allowListResult := IsAllowList(rbacscope.ScopeSystem, userCred, manager) listF := mergeFields(metaFields, fieldFilter, allowListResult.Result.IsAllow()) listExcludes, _, _ := stringutils2.Split(stringutils2.NewSortedStrings(excludeFields), listF) @@ -526,7 +527,7 @@ func fetchContextObject(manager IModelManager, ctx context.Context, userCred mcc return nil, httperrors.NewInternalServerError("No such context %s(%s)", ctxId.Type, ctxId.Id) } -func ListItems(manager IModelManager, ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, ctxIds []dispatcher.SResourceContext) (*modulebase.ListResult, error) { +func ListItems(manager IModelManager, ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, ctxIds []dispatcher.SResourceContext) (*printutils.ListResult, error) { var err error var maxLimit int64 = consts.GetMaxPagingLimit() limit, _ := query.Int("limit") @@ -626,7 +627,7 @@ func ListItems(manager IModelManager, ctx context.Context, userCred mcclient.Tok union, err := sqlchemy.UnionWithError(subqs...) if err != nil { if errors.Cause(err) == sql.ErrNoRows { - emptyList := modulebase.ListResult{Data: []jsonutils.JSONObject{}} + emptyList := printutils.ListResult{Data: []jsonutils.JSONObject{}} return &emptyList, nil } else { return nil, errors.Wrap(err, "sqlchemy.UnionWithError") @@ -654,7 +655,7 @@ func ListItems(manager IModelManager, ctx context.Context, userCred mcclient.Tok } //log.Debugf("total count %d", totalCnt) if totalCnt == 0 { - emptyList := modulebase.ListResult{Data: []jsonutils.JSONObject{}} + emptyList := printutils.ListResult{Data: []jsonutils.JSONObject{}} return &emptyList, nil } } @@ -768,7 +769,7 @@ func ListItems(manager IModelManager, ctx context.Context, userCred mcclient.Tok retList = retList[:limit] } nextMarker := encodePagingMarker(nextMarkers) - retResult := modulebase.ListResult{ + retResult := printutils.ListResult{ Data: retList, Limit: int(limit), NextMarker: nextMarker, MarkerField: strings.Join(pagingConf.MarkerFields, ","), @@ -820,7 +821,7 @@ func ListItems(manager IModelManager, ctx context.Context, userCred mcclient.Tok return calculateListResult(retList, int64(totalCnt), limit, offset, paginate), nil } -func calculateListResult(data []jsonutils.JSONObject, total, limit, offset int64, paginate bool) *modulebase.ListResult { +func calculateListResult(data []jsonutils.JSONObject, total, limit, offset int64, paginate bool) *printutils.ListResult { if paginate { // do offset first if offset > 0 { @@ -838,7 +839,7 @@ func calculateListResult(data []jsonutils.JSONObject, total, limit, offset int64 } } - retResult := modulebase.ListResult{Data: data, Total: int(total), Limit: int(limit), Offset: int(offset)} + retResult := printutils.ListResult{Data: data, Total: int(total), Limit: int(limit), Offset: int(offset)} return &retResult } @@ -855,7 +856,7 @@ func getExportCols(query jsonutils.JSONObject, retList []jsonutils.JSONObject) [ return retList } -func (dispatcher *DBModelDispatcher) List(ctx context.Context, query jsonutils.JSONObject, ctxIds []dispatcher.SResourceContext) (*modulebase.ListResult, error) { +func (dispatcher *DBModelDispatcher) List(ctx context.Context, query jsonutils.JSONObject, ctxIds []dispatcher.SResourceContext) (*printutils.ListResult, error) { userCred := fetchUserCredential(ctx) manager := dispatcher.manager.GetImmutableInstance(ctx, userCred, query) @@ -913,7 +914,7 @@ func getItemDetails(manager IModelManager, item IModel, ctx context.Context, use return nil, errors.Wrap(err, "FetchCustomizeColumns") } if len(extraRows) == 1 { - getFields := mergeFields(metaFields, fieldFilter, IsAllowGet(ctx, rbacutils.ScopeSystem, userCred, item)) + getFields := mergeFields(metaFields, fieldFilter, IsAllowGet(ctx, rbacscope.ScopeSystem, userCred, item)) excludes, _, _ := stringutils2.Split(stringutils2.NewSortedStrings(excludeFields), getFields) return extraRows[0].CopyExcludes(excludes...), nil } @@ -1047,7 +1048,7 @@ func (dispatcher *DBModelDispatcher) GetSpecific(ctx context.Context, idStr stri func fetchOwnerId(ctx context.Context, manager IModelManager, userCred mcclient.TokenCredential, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) { var ownerId mcclient.IIdentityProvider var err error - if manager.ResourceScope() != rbacutils.ScopeSystem { + if manager.ResourceScope() != rbacscope.ScopeSystem { ownerId, err = manager.FetchOwnerId(ctx, data) if err != nil { return nil, httperrors.NewGeneralError(err) @@ -1370,7 +1371,7 @@ func expandMultiCreateParams(manager IModelManager, data jsonutils.JSONObject, c return ret, nil } -func (dispatcher *DBModelDispatcher) BatchCreate(ctx context.Context, query jsonutils.JSONObject, data jsonutils.JSONObject, count int, ctxIds []dispatcher.SResourceContext) ([]modulebase.SubmitResult, error) { +func (dispatcher *DBModelDispatcher) BatchCreate(ctx context.Context, query jsonutils.JSONObject, data jsonutils.JSONObject, count int, ctxIds []dispatcher.SResourceContext) ([]printutils.SubmitResult, error) { userCred := fetchUserCredential(ctx) manager := dispatcher.manager.GetMutableInstance(ctx, userCred, query, data) @@ -1461,10 +1462,10 @@ func (dispatcher *DBModelDispatcher) BatchCreate(ctx context.Context, query json return nil, httperrors.NewGeneralError(errors.Wrap(err, "createResults")) } - results := make([]modulebase.SubmitResult, count) + results := make([]printutils.SubmitResult, count) models := make([]IModel, 0) for i, res := range createResults { - result := modulebase.SubmitResult{} + result := printutils.SubmitResult{} if res.err != nil { jsonErr := httperrors.NewGeneralError(res.err) result.Status = jsonErr.Code diff --git a/pkg/cloudcommon/db/db_joint_dispatcher.go b/pkg/cloudcommon/db/db_joint_dispatcher.go index 9a68a43dac..65c7c114b3 100644 --- a/pkg/cloudcommon/db/db_joint_dispatcher.go +++ b/pkg/cloudcommon/db/db_joint_dispatcher.go @@ -21,12 +21,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/cloudcommon/db/lockman" "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" ) type DBJointModelDispatcher struct { @@ -58,7 +58,7 @@ func (dispatcher *DBJointModelDispatcher) SlaveKeywordPlural() string { return jointManager.GetSlaveManager().KeywordPlural() } -func (dispatcher *DBJointModelDispatcher) ListMasterDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*modulebase.ListResult, error) { +func (dispatcher *DBJointModelDispatcher) ListMasterDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*printutils.ListResult, error) { //log.Debugf("ListMasterDescendent %s %s", dispatcher.JointModelManager().GetMasterManager().Keyword(), idStr) userCred := fetchUserCredential(ctx) @@ -85,7 +85,7 @@ func (dispatcher *DBJointModelDispatcher) ListMasterDescendent(ctx context.Conte return dispatcher._listJoint(ctx, userCred, model.(IStandaloneModel), queryDict) } -func (dispatcher *DBJointModelDispatcher) ListSlaveDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*modulebase.ListResult, error) { +func (dispatcher *DBJointModelDispatcher) ListSlaveDescendent(ctx context.Context, idStr string, query jsonutils.JSONObject) (*printutils.ListResult, error) { //log.Debugf("ListSlaveDescendent %s %s", dispatcher.JointModelManager().GetMasterManager().Keyword(), idStr) userCred := fetchUserCredential(ctx) @@ -112,7 +112,7 @@ func (dispatcher *DBJointModelDispatcher) ListSlaveDescendent(ctx context.Contex return dispatcher._listJoint(ctx, userCred, model.(IStandaloneModel), queryDict) } -func (dispatcher *DBJointModelDispatcher) _listJoint(ctx context.Context, userCred mcclient.TokenCredential, ctxModel IStandaloneModel, queryDict jsonutils.JSONObject) (*modulebase.ListResult, error) { +func (dispatcher *DBJointModelDispatcher) _listJoint(ctx context.Context, userCred mcclient.TokenCredential, ctxModel IStandaloneModel, queryDict jsonutils.JSONObject) (*printutils.ListResult, error) { items, err := ListItems(dispatcher.JointModelManager(), ctx, userCred, queryDict, nil) if err != nil { log.Errorf("Fail to list items: %s", err) diff --git a/pkg/cloudcommon/db/domain.go b/pkg/cloudcommon/db/domain.go index 958940f195..ebd71013e9 100644 --- a/pkg/cloudcommon/db/domain.go +++ b/pkg/cloudcommon/db/domain.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/reflectutils" "yunion.io/x/sqlchemy" @@ -28,7 +29,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" "yunion.io/x/onecloud/pkg/util/tagutils" ) @@ -41,22 +41,22 @@ type SDomainizedResourceBase struct { DomainId string `width:"64" charset:"ascii" default:"default" nullable:"false" index:"true" list:"user" json:"domain_id"` } -func (manager *SDomainizedResourceBaseManager) NamespaceScope() rbacutils.TRbacScope { +func (manager *SDomainizedResourceBaseManager) NamespaceScope() rbacscope.TRbacScope { if consts.IsDomainizedNamespace() { - return rbacutils.ScopeDomain + return rbacscope.ScopeDomain } else { - return rbacutils.ScopeSystem + return rbacscope.ScopeSystem } } -func (manager *SDomainizedResourceBaseManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SDomainizedResourceBaseManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } -func (manager *SDomainizedResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SDomainizedResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { switch scope { - case rbacutils.ScopeProject, rbacutils.ScopeDomain: + case rbacscope.ScopeProject, rbacscope.ScopeDomain: q = q.Equals("domain_id", owner.GetProjectDomainId()) } } diff --git a/pkg/cloudcommon/db/fetch.go b/pkg/cloudcommon/db/fetch.go index 48bbb6ca04..f3b472c936 100644 --- a/pkg/cloudcommon/db/fetch.go +++ b/pkg/cloudcommon/db/fetch.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/cloudcommon/consts" @@ -309,21 +310,21 @@ func (m *sUsageManager) KeywordPlural() string { return "usages" } -func (m *sUsageManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (m *sUsageManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (m *sUsageManager) FetchOwnerId(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) { return FetchProjectInfo(ctx, data) } -func FetchUsageOwnerScope(ctx context.Context, userCred mcclient.TokenCredential, data jsonutils.JSONObject) (mcclient.IIdentityProvider, rbacutils.TRbacScope, error, rbacutils.SPolicyResult) { +func FetchUsageOwnerScope(ctx context.Context, userCred mcclient.TokenCredential, data jsonutils.JSONObject) (mcclient.IIdentityProvider, rbacscope.TRbacScope, error, rbacutils.SPolicyResult) { return FetchCheckQueryOwnerScope(ctx, userCred, data, &sUsageManager{}, policy.PolicyActionGet, true) } type IScopedResourceManager interface { KeywordPlural() string - ResourceScope() rbacutils.TRbacScope + ResourceScope() rbacscope.TRbacScope FetchOwnerId(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) } @@ -334,12 +335,12 @@ func FetchCheckQueryOwnerScope( manager IScopedResourceManager, action string, doCheckRbac bool, -) (mcclient.IIdentityProvider, rbacutils.TRbacScope, error, rbacutils.SPolicyResult) { - var scope rbacutils.TRbacScope +) (mcclient.IIdentityProvider, rbacscope.TRbacScope, error, rbacutils.SPolicyResult) { + var scope rbacscope.TRbacScope - var allowScope rbacutils.TRbacScope - var requireScope rbacutils.TRbacScope - var queryScope rbacutils.TRbacScope + var allowScope rbacscope.TRbacScope + var requireScope rbacscope.TRbacScope + var queryScope rbacscope.TRbacScope var policyTagFilters rbacutils.SPolicyResult resScope := manager.ResourceScope() @@ -352,40 +353,40 @@ func FetchCheckQueryOwnerScope( } if ownerId != nil { switch resScope { - case rbacutils.ScopeProject, rbacutils.ScopeDomain: + case rbacscope.ScopeProject, rbacscope.ScopeDomain: if len(ownerId.GetProjectId()) > 0 { - queryScope = rbacutils.ScopeProject + queryScope = rbacscope.ScopeProject if ownerId.GetProjectId() == userCred.GetProjectId() { - requireScope = rbacutils.ScopeProject + requireScope = rbacscope.ScopeProject } else if ownerId.GetProjectDomainId() == userCred.GetProjectDomainId() { - requireScope = rbacutils.ScopeDomain + requireScope = rbacscope.ScopeDomain } else { - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } } else if len(ownerId.GetProjectDomainId()) > 0 { - queryScope = rbacutils.ScopeDomain + queryScope = rbacscope.ScopeDomain if ownerId.GetProjectDomainId() == userCred.GetProjectDomainId() { - requireScope = rbacutils.ScopeDomain + requireScope = rbacscope.ScopeDomain } else { - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } } - case rbacutils.ScopeUser: - queryScope = rbacutils.ScopeUser + case rbacscope.ScopeUser: + queryScope = rbacscope.ScopeUser if ownerId.GetUserId() == userCred.GetUserId() { - requireScope = rbacutils.ScopeUser + requireScope = rbacscope.ScopeUser } else { - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } } } else { ownerId = userCred reqScopeStr, _ := data.GetString("scope") if len(reqScopeStr) > 0 { - queryScope = rbacutils.String2Scope(reqScopeStr) + queryScope = rbacscope.String2Scope(reqScopeStr) } else if data.Contains("admin") { isAdmin := jsonutils.QueryBoolean(data, "admin", false) - if isAdmin && allowScope.HigherThan(rbacutils.ScopeProject) { + if isAdmin && allowScope.HigherThan(rbacscope.ScopeProject) { queryScope = allowScope } } else if action == policy.PolicyActionGet { diff --git a/pkg/cloudcommon/db/infraresource.go b/pkg/cloudcommon/db/infraresource.go index a109a77b74..eb9678dde5 100644 --- a/pkg/cloudcommon/db/infraresource.go +++ b/pkg/cloudcommon/db/infraresource.go @@ -19,13 +19,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -54,7 +54,7 @@ func (manager *SInfrasResourceBaseManager) GetIInfrasModelManager() IInfrasModel return manager.GetVirtualObject().(IInfrasModelManager) } -func (manager *SInfrasResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SInfrasResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { return SharableManagerFilterByOwner(manager.GetIInfrasModelManager(), q, owner, scope) } @@ -215,16 +215,16 @@ func (model *SInfrasResourceBase) Delete(ctx context.Context, userCred mcclient. func (model *SInfrasResourceBase) GetSharedInfo() apis.SShareInfo { ret := apis.SShareInfo{} ret.IsPublic = model.IsPublic - ret.PublicScope = rbacutils.String2ScopeDefault(model.PublicScope, rbacutils.ScopeNone) + ret.PublicScope = rbacscope.String2ScopeDefault(model.PublicScope, rbacscope.ScopeNone) ret.SharedDomains = model.GetSharedDomains() ret.SharedProjects = nil // fix if len(ret.SharedDomains) > 0 { - ret.PublicScope = rbacutils.ScopeDomain + ret.PublicScope = rbacscope.ScopeDomain ret.SharedProjects = nil ret.IsPublic = true } else if !ret.IsPublic { - ret.PublicScope = rbacutils.ScopeNone + ret.PublicScope = rbacscope.ScopeNone } return ret } @@ -248,7 +248,7 @@ func (model *SInfrasResourceBase) SyncShareState(ctx context.Context, userCred m if model.PublicSrc != string(apis.OWNER_SOURCE_LOCAL) { model.SaveSharedInfo(apis.OWNER_SOURCE_CLOUD, ctx, userCred, apis.SShareInfo{ IsPublic: true, - PublicScope: rbacutils.ScopeSystem, + PublicScope: rbacscope.ScopeSystem, }) } return diff --git a/pkg/cloudcommon/db/interface.go b/pkg/cloudcommon/db/interface.go index 2e4e941230..9462eb6979 100644 --- a/pkg/cloudcommon/db/interface.go +++ b/pkg/cloudcommon/db/interface.go @@ -20,13 +20,13 @@ import ( "time" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/object" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/db/lockman" - "yunion.io/x/onecloud/pkg/cloudcommon/object" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/splitable" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -75,9 +75,9 @@ type IModelManager interface { FilterById(q *sqlchemy.SQuery, idStr string) *sqlchemy.SQuery FilterByNotId(q *sqlchemy.SQuery, idStr string) *sqlchemy.SQuery FilterByName(q *sqlchemy.SQuery, name string) *sqlchemy.SQuery - FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery - FilterBySystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacutils.TRbacScope) *sqlchemy.SQuery - FilterByHiddenSystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacutils.TRbacScope) *sqlchemy.SQuery + FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery + FilterBySystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacscope.TRbacScope) *sqlchemy.SQuery + FilterByHiddenSystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacscope.TRbacScope) *sqlchemy.SQuery FilterByUniqValues(q *sqlchemy.SQuery, uniqValues jsonutils.JSONObject) *sqlchemy.SQuery // GetOwnerId(userCred mcclient.IIdentityProvider) mcclient.IIdentityProvider @@ -125,8 +125,8 @@ type IModelManager interface { FetchUniqValues(ctx context.Context, data jsonutils.JSONObject) jsonutils.JSONObject /* name uniqueness scope, system/domain/project, default is system */ - NamespaceScope() rbacutils.TRbacScope - ResourceScope() rbacutils.TRbacScope + NamespaceScope() rbacscope.TRbacScope + ResourceScope() rbacscope.TRbacScope // 如果error为非空,说明没有匹配的field,如果为空,说明匹配上了 QueryDistinctExtraField(q *sqlchemy.SQuery, field string) (*sqlchemy.SQuery, error) diff --git a/pkg/cloudcommon/db/jointbase.go b/pkg/cloudcommon/db/jointbase.go index 82fe9d8df3..98beda092c 100644 --- a/pkg/cloudcommon/db/jointbase.go +++ b/pkg/cloudcommon/db/jointbase.go @@ -22,12 +22,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/reflectutils" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -171,12 +171,12 @@ func (joint *SJointResourceBase) GetIJointModel() IJointModel { return joint.GetVirtualObject().(IJointModel) } -func (manager *SJointResourceBaseManager) ResourceScope() rbacutils.TRbacScope { +func (manager *SJointResourceBaseManager) ResourceScope() rbacscope.TRbacScope { return manager.GetMasterManager().ResourceScope() } -func (manager *SJointResourceBaseManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (manager *SJointResourceBaseManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (manager *SJointResourceBaseManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, input apis.JoinResourceBaseCreateInput) (apis.JoinResourceBaseCreateInput, error) { diff --git a/pkg/cloudcommon/db/lock.go b/pkg/cloudcommon/db/lock.go index f8bed4177d..f3a93292da 100644 --- a/pkg/cloudcommon/db/lock.go +++ b/pkg/cloudcommon/db/lock.go @@ -15,14 +15,15 @@ package db import ( + "yunion.io/x/pkg/util/rbacscope" + "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) func GetLockClassKey(manager IModelManager, ownerId mcclient.IIdentityProvider) string { - if manager.NamespaceScope() == rbacutils.ScopeSystem { + if manager.NamespaceScope() == rbacscope.ScopeSystem { return "" - } else if manager.NamespaceScope() == rbacutils.ScopeDomain { + } else if manager.NamespaceScope() == rbacscope.ScopeDomain { return ownerId.GetProjectDomainId() } else { return ownerId.GetProjectId() diff --git a/pkg/cloudcommon/db/metadata.go b/pkg/cloudcommon/db/metadata.go index 22dd9f3f80..265aecd6cf 100644 --- a/pkg/cloudcommon/db/metadata.go +++ b/pkg/cloudcommon/db/metadata.go @@ -24,6 +24,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/stringutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -35,8 +37,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) const ( @@ -223,7 +223,7 @@ func (manager *SMetadataManager) GetPropertyTagValuePairs( ctx context.Context, userCred mcclient.TokenCredential, input apis.MetaGetPropertyTagValuePairsInput, -) (*modulebase.ListResult, error) { +) (*printutils.ListResult, error) { q, err := manager.fetchKeyValueQuery(ctx, userCred, input) if err != nil { return nil, errors.Wrap(err, "fetchKeyValueQuery") @@ -235,7 +235,7 @@ func (manager *SMetadataManager) GetPropertyTagValuePairs( } if totalCnt == 0 { - emptyList := modulebase.ListResult{Data: []jsonutils.JSONObject{}} + emptyList := printutils.ListResult{Data: []jsonutils.JSONObject{}} return &emptyList, nil } @@ -268,7 +268,7 @@ func (manager *SMetadataManager) GetPropertyTagValuePairs( if err != nil { return nil, errors.Wrap(err, "metadataQuery2List") } - emptyList := modulebase.ListResult{ + emptyList := printutils.ListResult{ Data: data, Total: totalCnt, Limit: int(limit), @@ -383,7 +383,7 @@ func (manager *SMetadataManager) ListItemFilter(ctx context.Context, q *sqlchemy )) } - if !(input.Scope == string(rbacutils.ScopeSystem) && userCred.HasSystemAdminPrivilege()) { + if !(input.Scope == string(rbacscope.ScopeSystem) && userCred.HasSystemAdminPrivilege()) { resources := input.Resources if len(resources) == 0 { for resource := range globalTables { @@ -432,7 +432,7 @@ func (manager *SMetadataManager) ListItemFilter(ctx context.Context, q *sqlchemy } func (manager *SMetadataManager) GetStringValue(ctx context.Context, model IModel, key string, userCred mcclient.TokenCredential) string { - if strings.HasPrefix(key, SYSTEM_ADMIN_PREFIX) && (userCred == nil || !IsAllowGetSpec(ctx, rbacutils.ScopeSystem, userCred, model, "metadata")) { + if strings.HasPrefix(key, SYSTEM_ADMIN_PREFIX) && (userCred == nil || !IsAllowGetSpec(ctx, rbacscope.ScopeSystem, userCred, model, "metadata")) { return "" } idStr := GetModelIdstr(model) @@ -445,7 +445,7 @@ func (manager *SMetadataManager) GetStringValue(ctx context.Context, model IMode } func (manager *SMetadataManager) GetJsonValue(ctx context.Context, model IModel, key string, userCred mcclient.TokenCredential) jsonutils.JSONObject { - if strings.HasPrefix(key, SYSTEM_ADMIN_PREFIX) && (userCred == nil || !IsAllowGetSpec(ctx, rbacutils.ScopeSystem, userCred, model, "metadata")) { + if strings.HasPrefix(key, SYSTEM_ADMIN_PREFIX) && (userCred == nil || !IsAllowGetSpec(ctx, rbacscope.ScopeSystem, userCred, model, "metadata")) { return nil } idStr := GetModelIdstr(model) @@ -645,7 +645,7 @@ func (manager *SMetadataManager) GetAll(ctx context.Context, obj IModel, keys [] } ret := make(map[string]string) for k, v := range meta { - if strings.HasPrefix(k, SYSTEM_ADMIN_PREFIX) && (userCred == nil || !IsAllowGetSpec(ctx, rbacutils.ScopeSystem, userCred, obj, "metadata")) { + if strings.HasPrefix(k, SYSTEM_ADMIN_PREFIX) && (userCred == nil || !IsAllowGetSpec(ctx, rbacscope.ScopeSystem, userCred, obj, "metadata")) { continue } ret[k] = v diff --git a/pkg/cloudcommon/db/metadataresource.go b/pkg/cloudcommon/db/metadataresource.go index 3faac2d083..aace99b967 100644 --- a/pkg/cloudcommon/db/metadataresource.go +++ b/pkg/cloudcommon/db/metadataresource.go @@ -19,6 +19,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -33,14 +34,14 @@ type SMetadataResourceBaseModelManager struct{} func ObjectIdQueryWithPolicyResult(q *sqlchemy.SQuery, manager IModelManager, result rbacutils.SPolicyResult) *sqlchemy.SQuery { scope := manager.ResourceScope() - if scope == rbacutils.ScopeDomain || scope == rbacutils.ScopeProject { + if scope == rbacscope.ScopeDomain || scope == rbacscope.ScopeProject { if !result.DomainTags.IsEmpty() { tagFilters := tagutils.STagFilters{} tagFilters.AddFilters(result.DomainTags) q = ObjectIdQueryWithTagFilters(q, "domain_id", "domain", tagFilters) } } - if scope == rbacutils.ScopeProject { + if scope == rbacscope.ScopeProject { if !result.ProjectTags.IsEmpty() { tagFilters := tagutils.STagFilters{} tagFilters.AddFilters(result.ProjectTags) diff --git a/pkg/cloudcommon/db/modelbase.go b/pkg/cloudcommon/db/modelbase.go index 9466cd9ce1..91b2a08634 100644 --- a/pkg/cloudcommon/db/modelbase.go +++ b/pkg/cloudcommon/db/modelbase.go @@ -23,16 +23,16 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/object" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/version" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" "yunion.io/x/onecloud/pkg/appsrv" - "yunion.io/x/onecloud/pkg/cloudcommon/object" "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/splitable" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -232,15 +232,15 @@ func (manager *SModelBaseManager) FilterByName(q *sqlchemy.SQuery, name string) return q } -func (manager *SModelBaseManager) FilterByOwner(q *sqlchemy.SQuery, ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SModelBaseManager) FilterByOwner(q *sqlchemy.SQuery, ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { return q } -func (manager *SModelBaseManager) FilterBySystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SModelBaseManager) FilterBySystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacscope.TRbacScope) *sqlchemy.SQuery { return q } -func (manager *SModelBaseManager) FilterByHiddenSystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SModelBaseManager) FilterByHiddenSystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacscope.TRbacScope) *sqlchemy.SQuery { return q } @@ -346,12 +346,12 @@ func (manager *SModelBaseManager) FetchUniqValues(ctx context.Context, data json return nil } -func (manager *SModelBaseManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (manager *SModelBaseManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } -func (manager *SModelBaseManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (manager *SModelBaseManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (manager *SModelBaseManager) AllowGetPropertyDistinctField(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool { diff --git a/pkg/cloudcommon/db/opslog.go b/pkg/cloudcommon/db/opslog.go index 68f4e74c89..f743c2bb9d 100644 --- a/pkg/cloudcommon/db/opslog.go +++ b/pkg/cloudcommon/db/opslog.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/reflectutils" "yunion.io/x/pkg/util/stringutils" "yunion.io/x/pkg/util/timeutils" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -358,17 +358,17 @@ func (manager *SOpsLogManager) LogSyncUpdate(m IModel, uds sqlchemy.UpdateDiffs, } } -func (self *SOpsLogManager) FilterByOwner(q *sqlchemy.SQuery, ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (self *SOpsLogManager) FilterByOwner(q *sqlchemy.SQuery, ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if ownerId != nil { switch scope { - case rbacutils.ScopeUser: + case rbacscope.ScopeUser: if len(ownerId.GetUserId()) > 0 { /* * 默认只能查看本人发起的操作 */ q = q.Filter(sqlchemy.Equals(q.Field("user_id"), ownerId.GetUserId())) } - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: if len(ownerId.GetProjectId()) > 0 { /* * 项目视图可以查看本项目人员发起的操作,或者对本项目资源实施的操作, QIU Jian @@ -378,7 +378,7 @@ func (self *SOpsLogManager) FilterByOwner(q *sqlchemy.SQuery, ownerId mcclient.I sqlchemy.Equals(q.Field("owner_tenant_id"), ownerId.GetProjectId()), )) } - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: if len(ownerId.GetProjectDomainId()) > 0 { /* * 域视图可以查看本域人员发起的操作,或者对本域资源实施的操作, QIU Jian @@ -413,8 +413,8 @@ func (self *SOpsLog) IsSharable(reqCred mcclient.IIdentityProvider) bool { return false } -func (manager *SOpsLogManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeUser +func (manager *SOpsLogManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeUser } func (manager *SOpsLogManager) FetchOwnerId(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) { diff --git a/pkg/cloudcommon/db/project.go b/pkg/cloudcommon/db/project.go index 8587dff540..40c9bf86c8 100644 --- a/pkg/cloudcommon/db/project.go +++ b/pkg/cloudcommon/db/project.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/reflectutils" "yunion.io/x/sqlchemy" @@ -29,7 +30,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" "yunion.io/x/onecloud/pkg/util/tagutils" ) @@ -50,12 +50,12 @@ func (model *SProjectizedResourceBase) GetOwnerId() mcclient.IIdentityProvider { return &owner } -func (manager *SProjectizedResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SProjectizedResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { switch scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Equals("tenant_id", owner.GetProjectId()) - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: q = q.Equals("domain_id", owner.GetProjectDomainId()) } /*if len(owner.GetProjectId()) > 0 { @@ -67,8 +67,8 @@ func (manager *SProjectizedResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery return q } -func (manager *SProjectizedResourceBaseManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SProjectizedResourceBaseManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (manager *SProjectizedResourceBaseManager) FetchOwnerId(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) { diff --git a/pkg/cloudcommon/db/proxy/proxysetting.go b/pkg/cloudcommon/db/proxy/proxysetting.go index 84b89575e9..548df07708 100644 --- a/pkg/cloudcommon/db/proxy/proxysetting.go +++ b/pkg/cloudcommon/db/proxy/proxysetting.go @@ -27,13 +27,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/rbacscope" proxyapi "yunion.io/x/onecloud/pkg/apis/cloudcommon/proxy" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SProxySettingManager struct { @@ -198,10 +198,10 @@ func (man *SProxySettingManager) InitializeData() error { psObj, err := man.FetchById(proxyapi.ProxySettingId_DIRECT) if err == nil { ps := psObj.(*SProxySetting) - if !ps.IsPublic || ps.PublicScope != string(rbacutils.ScopeSystem) { + if !ps.IsPublic || ps.PublicScope != string(rbacscope.ScopeSystem) { _, err = db.Update(ps, func() error { ps.IsPublic = true - ps.PublicScope = string(rbacutils.ScopeSystem) + ps.PublicScope = string(rbacscope.ScopeSystem) return nil }) if err != nil { @@ -223,7 +223,7 @@ func (man *SProxySettingManager) InitializeData() error { ps.Name = proxyapi.ProxySettingId_DIRECT ps.Description = "Connect directly" ps.IsPublic = true - ps.PublicScope = string(rbacutils.ScopeSystem) + ps.PublicScope = string(rbacscope.ScopeSystem) if err := man.TableSpec().Insert(context.Background(), ps); err != nil { return err } diff --git a/pkg/cloudcommon/db/query.go b/pkg/cloudcommon/db/query.go index a3acbcd6ff..dc52600ab7 100644 --- a/pkg/cloudcommon/db/query.go +++ b/pkg/cloudcommon/db/query.go @@ -18,10 +18,10 @@ import ( "context" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) func FetchQueryDomain(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (string, error) { @@ -34,8 +34,8 @@ func FetchQueryDomain(ctx context.Context, userCred mcclient.TokenCredential, qu domainId = domainInfo.GetProjectDomainId() } scopeStr, _ := query.GetString("scope") - queryScope := rbacutils.String2ScopeDefault(scopeStr, rbacutils.ScopeDomain) - if queryScope != rbacutils.ScopeSystem && len(domainId) == 0 { + queryScope := rbacscope.String2ScopeDefault(scopeStr, rbacscope.ScopeDomain) + if queryScope != rbacscope.ScopeSystem && len(domainId) == 0 { domainId = userCred.GetProjectDomainId() } return domainId, nil diff --git a/pkg/cloudcommon/db/quotas/context.go b/pkg/cloudcommon/db/quotas/context.go index 295fd777ca..bce1fb584a 100644 --- a/pkg/cloudcommon/db/quotas/context.go +++ b/pkg/cloudcommon/db/quotas/context.go @@ -19,9 +19,9 @@ import ( "context" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/mcclient" ) diff --git a/pkg/cloudcommon/db/quotas/errors.go b/pkg/cloudcommon/db/quotas/errors.go index 42b945368a..d25f25b222 100644 --- a/pkg/cloudcommon/db/quotas/errors.go +++ b/pkg/cloudcommon/db/quotas/errors.go @@ -18,12 +18,13 @@ import ( "fmt" "strings" + "yunion.io/x/pkg/util/rbacscope" + "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SOutOfQuotaError struct { - scope rbacutils.TRbacScope + scope rbacscope.TRbacScope name string limit int used int diff --git a/pkg/cloudcommon/db/quotas/handler.go b/pkg/cloudcommon/db/quotas/handler.go index 51cc12b3db..4fd55eaaa6 100644 --- a/pkg/cloudcommon/db/quotas/handler.go +++ b/pkg/cloudcommon/db/quotas/handler.go @@ -25,10 +25,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/reflectutils" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/cloudcommon/db" @@ -36,7 +37,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) const ( @@ -101,7 +101,7 @@ func AddQuotaHandler(manager *SQuotaBaseManager, prefix string, app *appsrv.Appl fmt.Sprintf("%s/%s/domains//pending", prefix, manager.KeywordPlural()), auth.Authenticate(manager.cleanPendingUsageHandler), nil, "clean_pending_usage_for_domain", nil) - if manager.scope == rbacutils.ScopeProject { + if manager.scope == rbacscope.ScopeProject { app.AddHandler2("GET", fmt.Sprintf("%s/%s/", prefix, manager.KeywordPlural()), auth.Authenticate(manager.getQuotaHandler), nil, "get_quota_for_project", nil) @@ -177,7 +177,7 @@ func (manager *SQuotaBaseManager) getQuotaHandler(ctx context.Context, w http.Re userCred := auth.FetchUserCredential(ctx, policy.FilterPolicyCredential) var ownerId mcclient.IIdentityProvider - var scope rbacutils.TRbacScope + var scope rbacscope.TRbacScope var err error projectId := params[""] @@ -196,10 +196,10 @@ func (manager *SQuotaBaseManager) getQuotaHandler(ctx context.Context, w http.Re } } else { scopeStr, _ := query.GetString("scope") - if scopeStr == "project" && manager.scope == rbacutils.ScopeProject { - scope = rbacutils.ScopeProject + if scopeStr == "project" && manager.scope == rbacscope.ScopeProject { + scope = rbacscope.ScopeProject } else if scopeStr == "domain" { - scope = rbacutils.ScopeDomain + scope = rbacscope.ScopeDomain } else { scope = manager.scope } @@ -209,7 +209,7 @@ func (manager *SQuotaBaseManager) getQuotaHandler(ctx context.Context, w http.Re keys := OwnerIdProjectQuotaKeys(scope, ownerId) refresh := jsonutils.QueryBoolean(query, "refresh", false) primary := jsonutils.QueryBoolean(query, "primary", false) - quotaList, err := manager.listQuotas(ctx, userCred, keys.DomainId, keys.ProjectId, scope == rbacutils.ScopeDomain, primary, refresh) + quotaList, err := manager.listQuotas(ctx, userCred, keys.DomainId, keys.ProjectId, scope == rbacscope.ScopeDomain, primary, refresh) if err != nil { httperrors.GeneralServerError(ctx, w, err) return @@ -217,7 +217,7 @@ func (manager *SQuotaBaseManager) getQuotaHandler(ctx context.Context, w http.Re if len(quotaList) == 0 { quota := manager.newQuota() var baseKeys IQuotaKeys - if manager.scope == rbacutils.ScopeProject { + if manager.scope == rbacscope.ScopeProject { baseKeys = OwnerIdProjectQuotaKeys(scope, ownerId) } else { baseKeys = OwnerIdDomainQuotaKeys(ownerId) @@ -226,7 +226,7 @@ func (manager *SQuotaBaseManager) getQuotaHandler(ctx context.Context, w http.Re quota.FetchSystemQuota() manager.SetQuota(ctx, userCred, quota) - quotaList, err = manager.listQuotas(ctx, userCred, keys.DomainId, keys.ProjectId, scope == rbacutils.ScopeDomain, primary, refresh) + quotaList, err = manager.listQuotas(ctx, userCred, keys.DomainId, keys.ProjectId, scope == rbacscope.ScopeDomain, primary, refresh) if err != nil { httperrors.GeneralServerError(ctx, w, err) return @@ -242,45 +242,45 @@ func (manager *SQuotaBaseManager) fetchSetQuotaScope( isBaseQuotaKeys bool, ) ( mcclient.IIdentityProvider, - rbacutils.TRbacScope, - rbacutils.TRbacScope, + rbacscope.TRbacScope, + rbacscope.TRbacScope, error, ) { - var scope rbacutils.TRbacScope + var scope rbacscope.TRbacScope ownerId, err := db.FetchProjectInfo(ctx, data) if err != nil { return nil, scope, scope, err } - var requestScope rbacutils.TRbacScope + var requestScope rbacscope.TRbacScope if ownerId != nil { if len(ownerId.GetProjectId()) > 0 { // project level - scope = rbacutils.ScopeProject + scope = rbacscope.ScopeProject if ownerId.GetProjectDomainId() == userCred.GetProjectDomainId() { if isBaseQuotaKeys || ownerId.GetProjectId() != userCred.GetProjectId() { - requestScope = rbacutils.ScopeDomain + requestScope = rbacscope.ScopeDomain } else { - requestScope = rbacutils.ScopeProject + requestScope = rbacscope.ScopeProject } } else { - requestScope = rbacutils.ScopeSystem + requestScope = rbacscope.ScopeSystem } } else { // domain level if len(ownerId.GetProjectDomainId()) > 0 { - scope = rbacutils.ScopeDomain + scope = rbacscope.ScopeDomain if isBaseQuotaKeys || ownerId.GetProjectDomainId() != userCred.GetProjectDomainId() { - requestScope = rbacutils.ScopeSystem + requestScope = rbacscope.ScopeSystem } else { - requestScope = rbacutils.ScopeDomain + requestScope = rbacscope.ScopeDomain } } } else { ownerId = userCred - scope = rbacutils.ScopeProject + scope = rbacscope.ScopeProject if isBaseQuotaKeys { - requestScope = rbacutils.ScopeDomain + requestScope = rbacscope.ScopeDomain } else { - requestScope = rbacutils.ScopeProject + requestScope = rbacscope.ScopeProject } } @@ -292,7 +292,7 @@ func (manager *SQuotaBaseManager) cleanPendingUsageHandler(ctx context.Context, userCred := auth.FetchUserCredential(ctx, policy.FilterPolicyCredential) var ownerId mcclient.IIdentityProvider - var scope rbacutils.TRbacScope + var scope rbacscope.TRbacScope var err error projectId := params[""] @@ -312,16 +312,16 @@ func (manager *SQuotaBaseManager) cleanPendingUsageHandler(ctx context.Context, } else { scopeStr, _ := query.GetString("scope") if scopeStr == "project" { - scope = rbacutils.ScopeProject + scope = rbacscope.ScopeProject } else if scopeStr == "domain" { - scope = rbacutils.ScopeDomain + scope = rbacscope.ScopeDomain } else { scope = manager.scope } ownerId = userCred } var keys IQuotaKeys - if manager.scope == rbacutils.ScopeProject { + if manager.scope == rbacscope.ScopeProject { keys = OwnerIdProjectQuotaKeys(scope, ownerId) } else { keys = OwnerIdDomainQuotaKeys(ownerId) @@ -358,7 +358,7 @@ func (manager *SQuotaBaseManager) setQuotaHandler(ctx context.Context, w http.Re // check is there any nonempty key other than domain_id and project_id isBaseQuota := false - if manager.scope == rbacutils.ScopeDomain { + if manager.scope == rbacscope.ScopeDomain { isBaseQuota = IsBaseDomainQuotaKeys(quota.GetKeys()) } else { isBaseQuota = IsBaseProjectQuotaKeys(quota.GetKeys()) @@ -371,7 +371,7 @@ func (manager *SQuotaBaseManager) setQuotaHandler(ctx context.Context, w http.Re // fill project_id and domain_id var baseKeys IQuotaKeys - if manager.scope == rbacutils.ScopeDomain { + if manager.scope == rbacscope.ScopeDomain { baseKeys = OwnerIdDomainQuotaKeys(ownerId) } else { baseKeys = OwnerIdProjectQuotaKeys(scope, ownerId) @@ -455,7 +455,7 @@ func (manager *SQuotaBaseManager) setQuotaHandler(ctx context.Context, w http.Re } } - quotaList, err := manager.listQuotas(ctx, userCred, baseKeys.OwnerId().GetProjectDomainId(), baseKeys.OwnerId().GetProjectId(), scope == rbacutils.ScopeDomain, false, true) + quotaList, err := manager.listQuotas(ctx, userCred, baseKeys.OwnerId().GetProjectDomainId(), baseKeys.OwnerId().GetProjectId(), scope == rbacscope.ScopeDomain, false, true) if err != nil { httperrors.GeneralServerError(ctx, w, err) return @@ -468,7 +468,7 @@ func (manager *SQuotaBaseManager) listDomainQuotaHandler(ctx context.Context, w userCred := auth.FetchUserCredential(ctx, policy.FilterPolicyCredential) allowScope, policyResult := policy.PolicyManager.AllowScope(userCred, consts.GetServiceType(), manager.KeywordPlural(), policy.PolicyActionList) - if policyResult.Result.IsAllow() && allowScope != rbacutils.ScopeSystem { + if policyResult.Result.IsAllow() && allowScope != rbacscope.ScopeSystem { httperrors.ForbiddenError(ctx, w, "not allow to list domain quotas") return } @@ -502,7 +502,7 @@ func (manager *SQuotaBaseManager) listProjectQuotaHandler(ctx context.Context, w } allowScope, _ := policy.PolicyManager.AllowScope(userCred, consts.GetServiceType(), manager.KeywordPlural(), policy.PolicyActionList) - if (allowScope == rbacutils.ScopeDomain && userCred.GetProjectDomainId() == owner.GetProjectDomainId()) || allowScope == rbacutils.ScopeSystem { + if (allowScope == rbacscope.ScopeDomain && userCred.GetProjectDomainId() == owner.GetProjectDomainId()) || allowScope == rbacscope.ScopeSystem { } else { httperrors.ForbiddenError(ctx, w, "not allow to list project quotas") return @@ -524,7 +524,7 @@ func (manager *SQuotaBaseManager) listQuotas(ctx context.Context, userCred mccli if len(targetDomainId) > 0 { q = q.Equals("domain_id", targetDomainId) if domainOnly { - if manager.scope == rbacutils.ScopeProject { + if manager.scope == rbacscope.ScopeProject { q = q.IsEmpty("tenant_id") } } else { @@ -540,7 +540,7 @@ func (manager *SQuotaBaseManager) listQuotas(ctx context.Context, userCred mccli } else { // domain only q = q.IsNotEmpty("domain_id") - if manager.scope == rbacutils.ScopeProject { + if manager.scope == rbacscope.ScopeProject { q = q.IsNullOrEmpty("tenant_id") } } diff --git a/pkg/cloudcommon/db/quotas/interface.go b/pkg/cloudcommon/db/quotas/interface.go index 8d07c29ad8..4afa13ba1a 100644 --- a/pkg/cloudcommon/db/quotas/interface.go +++ b/pkg/cloudcommon/db/quotas/interface.go @@ -18,11 +18,11 @@ import ( "context" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/object" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/cloudcommon/db" - "yunion.io/x/onecloud/pkg/cloudcommon/object" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type IQuotaKeys interface { @@ -32,7 +32,7 @@ type IQuotaKeys interface { OwnerId() mcclient.IIdentityProvider - Scope() rbacutils.TRbacScope + Scope() rbacscope.TRbacScope } type IQuota interface { diff --git a/pkg/cloudcommon/db/quotas/models.go b/pkg/cloudcommon/db/quotas/models.go index 639b04ce01..0e27a25cfa 100644 --- a/pkg/cloudcommon/db/quotas/models.go +++ b/pkg/cloudcommon/db/quotas/models.go @@ -22,13 +22,13 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/reflectutils" "yunion.io/x/sqlchemy" identityapi "yunion.io/x/onecloud/pkg/apis/identity" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SQuotaBaseManager struct { @@ -39,10 +39,10 @@ type SQuotaBaseManager struct { nonNegative bool - scope rbacutils.TRbacScope + scope rbacscope.TRbacScope } -func NewQuotaBaseManager(model interface{}, scope rbacutils.TRbacScope, tableName string, pendingStore IQuotaStore, usageStore IQuotaStore, keyword, keywordPlural string) SQuotaBaseManager { +func NewQuotaBaseManager(model interface{}, scope rbacscope.TRbacScope, tableName string, pendingStore IQuotaStore, usageStore IQuotaStore, keyword, keywordPlural string) SQuotaBaseManager { pendingStore.SetVirtualObject(pendingStore) usageStore.SetVirtualObject(usageStore) return SQuotaBaseManager{ @@ -54,7 +54,7 @@ func NewQuotaBaseManager(model interface{}, scope rbacutils.TRbacScope, tableNam } } -func NewQuotaUsageManager(model interface{}, scope rbacutils.TRbacScope, tableName string, keyword, keywordPlural string) SQuotaBaseManager { +func NewQuotaUsageManager(model interface{}, scope rbacscope.TRbacScope, tableName string, keyword, keywordPlural string) SQuotaBaseManager { return SQuotaBaseManager{ SResourceBaseManager: db.NewResourceBaseManager(model, tableName, keyword, keywordPlural), nonNegative: true, @@ -254,18 +254,18 @@ func (manager *SQuotaBaseManager) InitializeData() error { for i := range tenants { obj := tenants[i] - var scope rbacutils.TRbacScope + var scope rbacscope.TRbacScope var ownerId mcclient.IIdentityProvider if obj.DomainId == identityapi.KeystoneDomainRoot { // domain - scope = rbacutils.ScopeDomain + scope = rbacscope.ScopeDomain ownerId = &db.SOwnerId{ DomainId: tenants[i].Id, Domain: tenants[i].Name, } } else { // project - scope = rbacutils.ScopeProject + scope = rbacscope.ScopeProject ownerId = &db.SOwnerId{ DomainId: tenants[i].DomainId, Domain: tenants[i].Domain, @@ -276,7 +276,7 @@ func (manager *SQuotaBaseManager) InitializeData() error { quota := manager.newQuota() var baseKeys IQuotaKeys - if manager.scope == rbacutils.ScopeDomain { + if manager.scope == rbacscope.ScopeDomain { baseKeys = OwnerIdDomainQuotaKeys(ownerId) } else { baseKeys = OwnerIdProjectQuotaKeys(scope, ownerId) diff --git a/pkg/cloudcommon/db/quotas/quotakeys.go b/pkg/cloudcommon/db/quotas/quotakeys.go index 825793499a..de0d43378c 100644 --- a/pkg/cloudcommon/db/quotas/quotakeys.go +++ b/pkg/cloudcommon/db/quotas/quotakeys.go @@ -18,9 +18,10 @@ import ( "fmt" "strings" + "yunion.io/x/pkg/util/rbacscope" + "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SBaseDomainQuotaKeys struct { @@ -328,23 +329,23 @@ func QuotaKeyWeight(k IQuotaKeys) uint64 { return w } -func (k SBaseDomainQuotaKeys) Scope() rbacutils.TRbacScope { +func (k SBaseDomainQuotaKeys) Scope() rbacscope.TRbacScope { if len(k.DomainId) > 0 { - return rbacutils.ScopeDomain + return rbacscope.ScopeDomain } else { - return rbacutils.ScopeSystem + return rbacscope.ScopeSystem } } -func (k SBaseProjectQuotaKeys) Scope() rbacutils.TRbacScope { +func (k SBaseProjectQuotaKeys) Scope() rbacscope.TRbacScope { if len(k.DomainId) > 0 && len(k.ProjectId) > 0 { - return rbacutils.ScopeProject + return rbacscope.ScopeProject } else if len(k.DomainId) > 0 && len(k.ProjectId) == 0 { - return rbacutils.ScopeDomain + return rbacscope.ScopeDomain } else if len(k.DomainId) == 0 && len(k.ProjectId) == 0 { - return rbacutils.ScopeSystem + return rbacscope.ScopeSystem } else { - return rbacutils.ScopeNone + return rbacscope.ScopeNone } } @@ -393,8 +394,8 @@ func IsBaseDomainQuotaKeys(k IQuotaKeys) bool { return true } -func OwnerIdProjectQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider) SBaseProjectQuotaKeys { - if scope == rbacutils.ScopeDomain { +func OwnerIdProjectQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider) SBaseProjectQuotaKeys { + if scope == rbacscope.ScopeDomain { return SBaseProjectQuotaKeys{ SBaseDomainQuotaKeys: SBaseDomainQuotaKeys{ DomainId: ownerId.GetProjectDomainId(), diff --git a/pkg/cloudcommon/db/quotas/quotas.go b/pkg/cloudcommon/db/quotas/quotas.go index 3b9e2f9c85..fe7078dcd6 100644 --- a/pkg/cloudcommon/db/quotas/quotas.go +++ b/pkg/cloudcommon/db/quotas/quotas.go @@ -21,14 +21,14 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) -func (manager *SQuotaBaseManager) ResourceScope() rbacutils.TRbacScope { +func (manager *SQuotaBaseManager) ResourceScope() rbacscope.TRbacScope { return manager.scope } diff --git a/pkg/cloudcommon/db/quotas/stores.go b/pkg/cloudcommon/db/quotas/stores.go index 406d686965..33a530ecd6 100644 --- a/pkg/cloudcommon/db/quotas/stores.go +++ b/pkg/cloudcommon/db/quotas/stores.go @@ -18,10 +18,10 @@ import ( "context" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) const ( @@ -35,12 +35,12 @@ func newDBQuotaStore() *SDBQuotaStore { return &SDBQuotaStore{} } -func (store *SDBQuotaStore) GetQuota(ctx context.Context, scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, quota IQuota) error { +func (store *SDBQuotaStore) GetQuota(ctx context.Context, scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, quota IQuota) error { var tenant *db.STenant var err error switch scope { - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: tenant, err = db.TenantCacheManager.FetchDomainById(ctx, ownerId.GetProjectDomainId()) default: tenant, err = db.TenantCacheManager.FetchTenantById(ctx, ownerId.GetProjectId()) diff --git a/pkg/cloudcommon/db/rbac.go b/pkg/cloudcommon/db/rbac.go index b0da607033..10dad69a56 100644 --- a/pkg/cloudcommon/db/rbac.go +++ b/pkg/cloudcommon/db/rbac.go @@ -19,6 +19,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/cloudcommon/policy" @@ -45,35 +46,35 @@ func isObjectRbacAllowedResult(ctx context.Context, model IModel, userCred mccli ownerId = userCred } - var requireScope rbacutils.TRbacScope + var requireScope rbacscope.TRbacScope resScope := manager.ResourceScope() switch resScope { - case rbacutils.ScopeSystem: - requireScope = rbacutils.ScopeSystem - case rbacutils.ScopeDomain: + case rbacscope.ScopeSystem: + requireScope = rbacscope.ScopeSystem + case rbacscope.ScopeDomain: if ownerId != nil && objOwnerId != nil && (ownerId.GetUserId() == objOwnerId.GetUserId() && action == policy.PolicyActionGet) { - requireScope = rbacutils.ScopeUser + requireScope = rbacscope.ScopeUser } else if ownerId != nil && objOwnerId != nil && (ownerId.GetProjectDomainId() == objOwnerId.GetProjectDomainId() || objOwnerId.GetProjectDomainId() == "" || (model.IsSharable(ownerId) && action == policy.PolicyActionGet)) { - requireScope = rbacutils.ScopeDomain + requireScope = rbacscope.ScopeDomain } else { - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } - case rbacutils.ScopeUser: + case rbacscope.ScopeUser: if ownerId != nil && objOwnerId != nil && (ownerId.GetUserId() == objOwnerId.GetUserId() || objOwnerId.GetUserId() == "" || (model.IsSharable(ownerId) && action == policy.PolicyActionGet)) { - requireScope = rbacutils.ScopeUser + requireScope = rbacscope.ScopeUser } else if ownerId != nil && objOwnerId != nil && ownerId.GetProjectDomainId() == objOwnerId.GetProjectDomainId() { - requireScope = rbacutils.ScopeDomain + requireScope = rbacscope.ScopeDomain } else { - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } default: // objOwnerId should not be nil if ownerId != nil && objOwnerId != nil && (ownerId.GetProjectId() == objOwnerId.GetProjectId() || objOwnerId.GetProjectId() == "" || (model.IsSharable(ownerId) && action == policy.PolicyActionGet)) { - requireScope = rbacutils.ScopeProject + requireScope = rbacscope.ScopeProject } else if ownerId != nil && objOwnerId != nil && ownerId.GetProjectDomainId() == objOwnerId.GetProjectDomainId() { - requireScope = rbacutils.ScopeDomain + requireScope = rbacscope.ScopeDomain } else { - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } } @@ -104,34 +105,34 @@ func isClassRbacAllowed(ctx context.Context, manager IModelManager, userCred mcc ownerId = userCred } - var requireScope rbacutils.TRbacScope + var requireScope rbacscope.TRbacScope resScope := manager.ResourceScope() switch resScope { - case rbacutils.ScopeSystem: - requireScope = rbacutils.ScopeSystem - case rbacutils.ScopeDomain: + case rbacscope.ScopeSystem: + requireScope = rbacscope.ScopeSystem + case rbacscope.ScopeDomain: // objOwnerId should not be nil if ownerId != nil && ownerId.GetProjectDomainId() == objOwnerId.GetProjectDomainId() { - requireScope = rbacutils.ScopeDomain + requireScope = rbacscope.ScopeDomain } else { - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } - case rbacutils.ScopeUser: + case rbacscope.ScopeUser: if ownerId != nil && ownerId.GetUserId() == objOwnerId.GetUserId() { - requireScope = rbacutils.ScopeUser + requireScope = rbacscope.ScopeUser } else if ownerId != nil && ownerId.GetProjectDomainId() == objOwnerId.GetProjectDomainId() { - requireScope = rbacutils.ScopeDomain + requireScope = rbacscope.ScopeDomain } else { - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } default: // objOwnerId should not be nil if ownerId != nil && ownerId.GetProjectId() == objOwnerId.GetProjectId() { - requireScope = rbacutils.ScopeProject + requireScope = rbacscope.ScopeProject } else if ownerId != nil && ownerId.GetProjectDomainId() == objOwnerId.GetProjectDomainId() { - requireScope = rbacutils.ScopeDomain + requireScope = rbacscope.ScopeDomain } else { - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } } @@ -151,7 +152,7 @@ type IResource interface { KeywordPlural() string } -func IsAllowList(scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, manager IResource) rbacutils.SPolicyResult { +func IsAllowList(scope rbacscope.TRbacScope, userCred mcclient.TokenCredential, manager IResource) rbacutils.SPolicyResult { if userCred == nil { return rbacutils.PolicyDeny } @@ -159,18 +160,18 @@ func IsAllowList(scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, } func IsAdminAllowList(userCred mcclient.TokenCredential, manager IResource) rbacutils.SPolicyResult { - return IsAllowList(rbacutils.ScopeSystem, userCred, manager) + return IsAllowList(rbacscope.ScopeSystem, userCred, manager) } func IsDomainAllowList(userCred mcclient.TokenCredential, manager IResource) rbacutils.SPolicyResult { - return IsAllowList(rbacutils.ScopeDomain, userCred, manager) + return IsAllowList(rbacscope.ScopeDomain, userCred, manager) } func IsProjectAllowList(userCred mcclient.TokenCredential, manager IResource) rbacutils.SPolicyResult { - return IsAllowList(rbacutils.ScopeProject, userCred, manager) + return IsAllowList(rbacscope.ScopeProject, userCred, manager) } -func IsAllowCreate(scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, manager IResource) rbacutils.SPolicyResult { +func IsAllowCreate(scope rbacscope.TRbacScope, userCred mcclient.TokenCredential, manager IResource) rbacutils.SPolicyResult { if userCred == nil { return rbacutils.PolicyDeny } @@ -178,18 +179,18 @@ func IsAllowCreate(scope rbacutils.TRbacScope, userCred mcclient.TokenCredential } func IsAdminAllowCreate(userCred mcclient.TokenCredential, manager IResource) rbacutils.SPolicyResult { - return IsAllowCreate(rbacutils.ScopeSystem, userCred, manager) + return IsAllowCreate(rbacscope.ScopeSystem, userCred, manager) } func IsDomainAllowCreate(userCred mcclient.TokenCredential, manager IResource) rbacutils.SPolicyResult { - return IsAllowCreate(rbacutils.ScopeDomain, userCred, manager) + return IsAllowCreate(rbacscope.ScopeDomain, userCred, manager) } func IsProjectAllowCreate(userCred mcclient.TokenCredential, manager IResource) rbacutils.SPolicyResult { - return IsAllowCreate(rbacutils.ScopeProject, userCred, manager) + return IsAllowCreate(rbacscope.ScopeProject, userCred, manager) } -func IsAllowClassPerform(scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, manager IResource, action string) rbacutils.SPolicyResult { +func IsAllowClassPerform(scope rbacscope.TRbacScope, userCred mcclient.TokenCredential, manager IResource, action string) rbacutils.SPolicyResult { if userCred == nil { return rbacutils.PolicyDeny } @@ -197,18 +198,18 @@ func IsAllowClassPerform(scope rbacutils.TRbacScope, userCred mcclient.TokenCred } func IsAdminAllowClassPerform(userCred mcclient.TokenCredential, manager IResource, action string) rbacutils.SPolicyResult { - return IsAllowClassPerform(rbacutils.ScopeSystem, userCred, manager, action) + return IsAllowClassPerform(rbacscope.ScopeSystem, userCred, manager, action) } func IsDomainAllowClassPerform(userCred mcclient.TokenCredential, manager IResource, action string) rbacutils.SPolicyResult { - return IsAllowClassPerform(rbacutils.ScopeDomain, userCred, manager, action) + return IsAllowClassPerform(rbacscope.ScopeDomain, userCred, manager, action) } func IsProjectAllowClassPerform(userCred mcclient.TokenCredential, manager IResource, action string) rbacutils.SPolicyResult { - return IsAllowClassPerform(rbacutils.ScopeProject, userCred, manager, action) + return IsAllowClassPerform(rbacscope.ScopeProject, userCred, manager, action) } -func IsAllowGet(ctx context.Context, scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, obj IModel) bool { +func IsAllowGet(ctx context.Context, scope rbacscope.TRbacScope, userCred mcclient.TokenCredential, obj IModel) bool { if userCred == nil { return false } @@ -223,18 +224,18 @@ func IsAllowGet(ctx context.Context, scope rbacutils.TRbacScope, userCred mcclie } func IsAdminAllowGet(ctx context.Context, userCred mcclient.TokenCredential, obj IModel) bool { - return IsAllowGet(ctx, rbacutils.ScopeSystem, userCred, obj) + return IsAllowGet(ctx, rbacscope.ScopeSystem, userCred, obj) } func IsDomainAllowGet(ctx context.Context, userCred mcclient.TokenCredential, obj IModel) bool { - return IsAllowGet(ctx, rbacutils.ScopeDomain, userCred, obj) + return IsAllowGet(ctx, rbacscope.ScopeDomain, userCred, obj) } func IsProjectAllowGet(ctx context.Context, userCred mcclient.TokenCredential, obj IModel) bool { - return IsAllowGet(ctx, rbacutils.ScopeProject, userCred, obj) + return IsAllowGet(ctx, rbacscope.ScopeProject, userCred, obj) } -func IsAllowGetSpec(ctx context.Context, scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, obj IModel, spec string) bool { +func IsAllowGetSpec(ctx context.Context, scope rbacscope.TRbacScope, userCred mcclient.TokenCredential, obj IModel, spec string) bool { if userCred == nil { return false } @@ -249,18 +250,18 @@ func IsAllowGetSpec(ctx context.Context, scope rbacutils.TRbacScope, userCred mc } func IsAdminAllowGetSpec(ctx context.Context, userCred mcclient.TokenCredential, obj IModel, spec string) bool { - return IsAllowGetSpec(ctx, rbacutils.ScopeSystem, userCred, obj, spec) + return IsAllowGetSpec(ctx, rbacscope.ScopeSystem, userCred, obj, spec) } func IsDomainAllowGetSpec(ctx context.Context, userCred mcclient.TokenCredential, obj IModel, spec string) bool { - return IsAllowGetSpec(ctx, rbacutils.ScopeDomain, userCred, obj, spec) + return IsAllowGetSpec(ctx, rbacscope.ScopeDomain, userCred, obj, spec) } func IsProjectAllowGetSpec(ctx context.Context, userCred mcclient.TokenCredential, obj IModel, spec string) bool { - return IsAllowGetSpec(ctx, rbacutils.ScopeProject, userCred, obj, spec) + return IsAllowGetSpec(ctx, rbacscope.ScopeProject, userCred, obj, spec) } -func IsAllowPerform(ctx context.Context, scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, obj IModel, action string) bool { +func IsAllowPerform(ctx context.Context, scope rbacscope.TRbacScope, userCred mcclient.TokenCredential, obj IModel, action string) bool { if userCred == nil { return false } @@ -275,18 +276,18 @@ func IsAllowPerform(ctx context.Context, scope rbacutils.TRbacScope, userCred mc } func IsAdminAllowPerform(ctx context.Context, userCred mcclient.TokenCredential, obj IModel, action string) bool { - return IsAllowPerform(ctx, rbacutils.ScopeSystem, userCred, obj, action) + return IsAllowPerform(ctx, rbacscope.ScopeSystem, userCred, obj, action) } func IsDomainAllowPerform(ctx context.Context, userCred mcclient.TokenCredential, obj IModel, action string) bool { - return IsAllowPerform(ctx, rbacutils.ScopeDomain, userCred, obj, action) + return IsAllowPerform(ctx, rbacscope.ScopeDomain, userCred, obj, action) } func IsProjectAllowPerform(ctx context.Context, userCred mcclient.TokenCredential, obj IModel, action string) bool { - return IsAllowPerform(ctx, rbacutils.ScopeProject, userCred, obj, action) + return IsAllowPerform(ctx, rbacscope.ScopeProject, userCred, obj, action) } -func IsAllowUpdate(ctx context.Context, scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, obj IModel) bool { +func IsAllowUpdate(ctx context.Context, scope rbacscope.TRbacScope, userCred mcclient.TokenCredential, obj IModel) bool { if userCred == nil { return false } @@ -301,18 +302,18 @@ func IsAllowUpdate(ctx context.Context, scope rbacutils.TRbacScope, userCred mcc } func IsAdminAllowUpdate(ctx context.Context, userCred mcclient.TokenCredential, obj IModel) bool { - return IsAllowUpdate(ctx, rbacutils.ScopeSystem, userCred, obj) + return IsAllowUpdate(ctx, rbacscope.ScopeSystem, userCred, obj) } func IsDomainAllowUpdate(ctx context.Context, userCred mcclient.TokenCredential, obj IModel) bool { - return IsAllowUpdate(ctx, rbacutils.ScopeDomain, userCred, obj) + return IsAllowUpdate(ctx, rbacscope.ScopeDomain, userCred, obj) } func IsProjectAllowUpdate(ctx context.Context, userCred mcclient.TokenCredential, obj IModel) bool { - return IsAllowUpdate(ctx, rbacutils.ScopeProject, userCred, obj) + return IsAllowUpdate(ctx, rbacscope.ScopeProject, userCred, obj) } -func IsAllowUpdateSpec(ctx context.Context, scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, obj IModel, spec string) bool { +func IsAllowUpdateSpec(ctx context.Context, scope rbacscope.TRbacScope, userCred mcclient.TokenCredential, obj IModel, spec string) bool { if userCred == nil { return false } @@ -327,18 +328,18 @@ func IsAllowUpdateSpec(ctx context.Context, scope rbacutils.TRbacScope, userCred } func IsAdminAllowUpdateSpec(ctx context.Context, userCred mcclient.TokenCredential, obj IModel, spec string) bool { - return IsAllowUpdateSpec(ctx, rbacutils.ScopeSystem, userCred, obj, spec) + return IsAllowUpdateSpec(ctx, rbacscope.ScopeSystem, userCred, obj, spec) } func IsDomainAllowUpdateSpec(ctx context.Context, userCred mcclient.TokenCredential, obj IModel, spec string) bool { - return IsAllowUpdateSpec(ctx, rbacutils.ScopeDomain, userCred, obj, spec) + return IsAllowUpdateSpec(ctx, rbacscope.ScopeDomain, userCred, obj, spec) } func IsProjectAllowUpdateSpec(ctx context.Context, userCred mcclient.TokenCredential, obj IModel, spec string) bool { - return IsAllowUpdateSpec(ctx, rbacutils.ScopeProject, userCred, obj, spec) + return IsAllowUpdateSpec(ctx, rbacscope.ScopeProject, userCred, obj, spec) } -func IsAllowDelete(ctx context.Context, scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, obj IModel) bool { +func IsAllowDelete(ctx context.Context, scope rbacscope.TRbacScope, userCred mcclient.TokenCredential, obj IModel) bool { if userCred == nil { return false } @@ -353,13 +354,13 @@ func IsAllowDelete(ctx context.Context, scope rbacutils.TRbacScope, userCred mcc } func IsAdminAllowDelete(ctx context.Context, userCred mcclient.TokenCredential, obj IModel) bool { - return IsAllowDelete(ctx, rbacutils.ScopeSystem, userCred, obj) + return IsAllowDelete(ctx, rbacscope.ScopeSystem, userCred, obj) } func IsDomainAllowDelete(ctx context.Context, userCred mcclient.TokenCredential, obj IModel) bool { - return IsAllowDelete(ctx, rbacutils.ScopeDomain, userCred, obj) + return IsAllowDelete(ctx, rbacscope.ScopeDomain, userCred, obj) } func IsProjectAllowDelete(ctx context.Context, userCred mcclient.TokenCredential, obj IModel) bool { - return IsAllowDelete(ctx, rbacutils.ScopeProject, userCred, obj) + return IsAllowDelete(ctx, rbacscope.ScopeProject, userCred, obj) } diff --git a/pkg/cloudcommon/db/resourcebase_test.go b/pkg/cloudcommon/db/resourcebase_test.go index 58d032fa59..622c129309 100644 --- a/pkg/cloudcommon/db/resourcebase_test.go +++ b/pkg/cloudcommon/db/resourcebase_test.go @@ -17,6 +17,7 @@ package db import ( "testing" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -28,7 +29,7 @@ type omniToken struct { mcclient.SSimpleToken } -func (tk *omniToken) IsAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { +func (tk *omniToken) IsAllow(scope rbacscope.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { return rbacutils.PolicyAllow } diff --git a/pkg/cloudcommon/db/rolecache.go b/pkg/cloudcommon/db/rolecache.go index ba1c9c0aca..2f34cbe59b 100644 --- a/pkg/cloudcommon/db/rolecache.go +++ b/pkg/cloudcommon/db/rolecache.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/cloudcommon/consts" @@ -31,7 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/informer" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) diff --git a/pkg/cloudcommon/db/scoperesource.go b/pkg/cloudcommon/db/scoperesource.go index 4d4b2a1f59..a22b7bc042 100644 --- a/pkg/cloudcommon/db/scoperesource.go +++ b/pkg/cloudcommon/db/scoperesource.go @@ -19,6 +19,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/reflectutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -26,7 +27,6 @@ import ( "yunion.io/x/onecloud/pkg/apis" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -46,18 +46,18 @@ type sUniqValues struct { } func (m *SScopedResourceBaseManager) FetchUniqValues(ctx context.Context, data jsonutils.JSONObject) jsonutils.JSONObject { - parentScope := rbacutils.ScopeSystem + parentScope := rbacscope.ScopeSystem scope, _ := data.GetString("scope") if scope != "" { - parentScope = rbacutils.TRbacScope(scope) + parentScope = rbacscope.TRbacScope(scope) } uniqValues := sUniqValues{} switch parentScope { - case rbacutils.ScopeSystem: - case rbacutils.ScopeDomain: + case rbacscope.ScopeSystem: + case rbacscope.ScopeDomain: domain, _ := data.GetString("project_domain") uniqValues.Domain = domain - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: project, _ := data.GetString("project") uniqValues.Project = project } @@ -65,19 +65,19 @@ func (m *SScopedResourceBaseManager) FetchUniqValues(ctx context.Context, data j return jsonutils.Marshal(uniqValues) } -func (m *SScopedResourceBaseManager) FilterByScope(q *sqlchemy.SQuery, scope rbacutils.TRbacScope, scopeResId string) *sqlchemy.SQuery { +func (m *SScopedResourceBaseManager) FilterByScope(q *sqlchemy.SQuery, scope rbacscope.TRbacScope, scopeResId string) *sqlchemy.SQuery { isNotNullOrEmpty := func(field string) sqlchemy.ICondition { return sqlchemy.AND(sqlchemy.IsNotNull(q.Field(field)), sqlchemy.IsNotEmpty(q.Field(field))) } switch scope { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: q = q.IsNullOrEmpty("domain_id").IsNullOrEmpty("tenant_id") - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: q = q.IsNullOrEmpty("tenant_id").Filter(isNotNullOrEmpty("domain_id")) if scopeResId != "" { q = q.Equals("domain_id", scopeResId) } - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Filter(isNotNullOrEmpty("domain_id")).Filter(isNotNullOrEmpty("tenant_id")) if scopeResId != "" { q = q.Equals("tenant_id", scopeResId) @@ -90,34 +90,34 @@ func (m *SScopedResourceBaseManager) FilterByUniqValues(q *sqlchemy.SQuery, valu uniqValues := &sUniqValues{} values.Unmarshal(uniqValues) if len(uniqValues.Domain) > 0 { - return m.FilterByScope(q, rbacutils.TRbacScope(uniqValues.Scope), uniqValues.Domain) + return m.FilterByScope(q, rbacscope.TRbacScope(uniqValues.Scope), uniqValues.Domain) } else if len(uniqValues.Project) > 0 { - return m.FilterByScope(q, rbacutils.TRbacScope(uniqValues.Scope), uniqValues.Project) + return m.FilterByScope(q, rbacscope.TRbacScope(uniqValues.Scope), uniqValues.Project) } else { - return m.FilterByScope(q, rbacutils.TRbacScope(uniqValues.Scope), "") + return m.FilterByScope(q, rbacscope.TRbacScope(uniqValues.Scope), "") } } func (m *SScopedResourceBase) IsOwner(userCred mcclient.TokenCredential) bool { scope := m.GetResourceScope() switch scope { - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: return userCred.GetProjectDomainId() == m.GetDomainId() - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: return userCred.GetProjectId() == m.GetProjectId() } // system scope return userCred.HasSystemAdminPrivilege() } -func (m *SScopedResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (m *SScopedResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred == nil { return q } switch scope { - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: q = q.Equals("domain_id", userCred.GetProjectDomainId()) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Equals("tenant_id", userCred.GetProjectId()) } return q @@ -125,22 +125,22 @@ func (m *SScopedResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, userCred func (m *SScopedResourceBaseManager) ValidateCreateData(man IScopedResourceManager, ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, input apis.ScopedResourceCreateInput) (apis.ScopedResourceCreateInput, error) { if input.Scope == "" { - input.Scope = string(rbacutils.ScopeSystem) + input.Scope = string(rbacscope.ScopeSystem) } if !utils.IsInStringArray(input.Scope, []string{ - string(rbacutils.ScopeSystem), - string(rbacutils.ScopeDomain), - string(rbacutils.ScopeProject)}) { + string(rbacscope.ScopeSystem), + string(rbacscope.ScopeDomain), + string(rbacscope.ScopeProject)}) { return input, httperrors.NewInputParameterError("invalid scope %s", input.Scope) } var allowCreate bool - switch rbacutils.TRbacScope(input.Scope) { - case rbacutils.ScopeSystem: + switch rbacscope.TRbacScope(input.Scope) { + case rbacscope.ScopeSystem: allowCreate = IsAdminAllowCreate(userCred, man).Result.IsAllow() - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: allowCreate = IsDomainAllowCreate(userCred, man).Result.IsAllow() input.ProjectDomainId = ownerId.GetDomainId() - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: allowCreate = IsProjectAllowCreate(userCred, man).Result.IsAllow() input.ProjectDomainId = ownerId.GetDomainId() input.ProjectId = ownerId.GetProjectId() @@ -151,20 +151,20 @@ func (m *SScopedResourceBaseManager) ValidateCreateData(man IScopedResourceManag return input, nil } -func getScopedResourceScope(domainId, projectId string) rbacutils.TRbacScope { +func getScopedResourceScope(domainId, projectId string) rbacscope.TRbacScope { if domainId == "" && projectId == "" { - return rbacutils.ScopeSystem + return rbacscope.ScopeSystem } if domainId != "" && projectId == "" { - return rbacutils.ScopeDomain + return rbacscope.ScopeDomain } if domainId != "" && projectId != "" { - return rbacutils.ScopeProject + return rbacscope.ScopeProject } - return rbacutils.ScopeNone + return rbacscope.ScopeNone } -func (s *SScopedResourceBase) GetResourceScope() rbacutils.TRbacScope { +func (s *SScopedResourceBase) GetResourceScope() rbacscope.TRbacScope { return getScopedResourceScope(s.DomainId, s.ProjectId) } @@ -184,14 +184,14 @@ func (s *SScopedResourceBase) SetResourceScope(domainId, projectId string) error func (s *SScopedResourceBase) CustomizeCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) error { scope, _ := data.GetString("scope") - switch rbacutils.TRbacScope(scope) { - case rbacutils.ScopeSystem: + switch rbacscope.TRbacScope(scope) { + case rbacscope.ScopeSystem: s.DomainId = "" s.ProjectId = "" - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: s.DomainId = ownerId.GetDomainId() s.ProjectId = "" - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: s.DomainId = ownerId.GetDomainId() s.ProjectId = ownerId.GetProjectId() } @@ -239,11 +239,11 @@ func PerformSetScope( scopeToSet := getScopedResourceScope(domainId, projectId) var err error switch scopeToSet { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: err = setScopedResourceToSystem(ctx, obj, userCred) - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: err = setScopedResourceToDomain(ctx, obj, userCred, domainId) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: err = setScopedResourceToProject(ctx, obj, userCred, projectId) } return nil, err @@ -309,7 +309,7 @@ func (m *SScopedResourceBaseManager) ListItemFilter( return nil, errors.Wrap(err, "SProjectizedResourceBaseManager.ListItemFilter") } if query.BelongScope != "" { - q = m.FilterByScope(q, rbacutils.TRbacScope(query.BelongScope), "") + q = m.FilterByScope(q, rbacscope.TRbacScope(query.BelongScope), "") } return q, nil } diff --git a/pkg/cloudcommon/db/sharablebase.go b/pkg/cloudcommon/db/sharablebase.go index d531eefd6f..e3989ca9b6 100644 --- a/pkg/cloudcommon/db/sharablebase.go +++ b/pkg/cloudcommon/db/sharablebase.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -28,7 +29,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -65,7 +65,7 @@ func (manager *SSharableBaseResourceManager) FetchCustomizeColumns( var resType string resIds := make([]string, len(rows)) - var resScope rbacutils.TRbacScope + var resScope rbacscope.TRbacScope for i := range rows { if model, ok := objs[i].(ISharableBaseModel); ok { if len(resType) == 0 { @@ -157,48 +157,48 @@ func SharableManagerValidateCreateData( reqScope := resScope isPublic := true switch resScope { - case rbacutils.ScopeProject: - if input.PublicScope == string(rbacutils.ScopeSystem) { + case rbacscope.ScopeProject: + if input.PublicScope == string(rbacscope.ScopeSystem) { input.IsPublic = &isPublic - reqScope = rbacutils.ScopeSystem - } else if input.PublicScope == string(rbacutils.ScopeDomain) { + reqScope = rbacscope.ScopeSystem + } else if input.PublicScope == string(rbacscope.ScopeDomain) { if consts.GetNonDefaultDomainProjects() { // only if non_default_domain_projects turned on, allow sharing to domain input.IsPublic = &isPublic - reqScope = rbacutils.ScopeDomain + reqScope = rbacscope.ScopeDomain } else { input.IsPublic = &isPublic - reqScope = rbacutils.ScopeSystem + reqScope = rbacscope.ScopeSystem } } else if input.IsPublic != nil && *input.IsPublic && len(input.PublicScope) == 0 { // backward compatible, if only is_public is true, make it share to system input.IsPublic = &isPublic - input.PublicScope = string(rbacutils.ScopeSystem) - reqScope = rbacutils.ScopeSystem + input.PublicScope = string(rbacscope.ScopeSystem) + reqScope = rbacscope.ScopeSystem } else { input.IsPublic = nil - input.PublicScope = "" // string(rbacutils.ScopeNone) + input.PublicScope = "" // string(rbacscope.ScopeNone) } - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: if consts.GetNonDefaultDomainProjects() { // only if non_default_domain_projects turned on, allow sharing domain resources - if input.PublicScope == string(rbacutils.ScopeSystem) { + if input.PublicScope == string(rbacscope.ScopeSystem) { input.IsPublic = &isPublic - reqScope = rbacutils.ScopeSystem + reqScope = rbacscope.ScopeSystem } else if input.IsPublic != nil && *input.IsPublic && len(input.PublicScope) == 0 { // backward compatible, if only is_public is true, make it share to system input.IsPublic = &isPublic - input.PublicScope = string(rbacutils.ScopeSystem) - reqScope = rbacutils.ScopeSystem + input.PublicScope = string(rbacscope.ScopeSystem) + reqScope = rbacscope.ScopeSystem } else { input.IsPublic = nil - input.PublicScope = "" // string(rbacutils.ScopeNone) + input.PublicScope = "" // string(rbacscope.ScopeNone) } } else { // if non_default_domain_projects turned off, all domain resources shared to system input.IsPublic = &isPublic - input.PublicScope = string(rbacutils.ScopeSystem) - reqScope = rbacutils.ScopeSystem + input.PublicScope = string(rbacscope.ScopeSystem) + reqScope = rbacscope.ScopeSystem } default: return input, errors.Wrap(httperrors.ErrInputParameter, "the resource is not sharable") @@ -213,10 +213,10 @@ func SharableManagerValidateCreateData( return input, nil } -func SharableManagerFilterByOwner(manager IStandaloneModelManager, q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func SharableManagerFilterByOwner(manager IStandaloneModelManager, q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { resScope := manager.ResourceScope() - if resScope == rbacutils.ScopeProject && scope == rbacutils.ScopeProject { + if resScope == rbacscope.ScopeProject && scope == rbacscope.ScopeProject { ownerProjectId := owner.GetProjectId() if len(ownerProjectId) > 0 { subq := SharedResourceManager.Query("resource_id") @@ -231,11 +231,11 @@ func SharableManagerFilterByOwner(manager IStandaloneModelManager, q *sqlchemy.S sqlchemy.Equals(q.Field("tenant_id"), ownerProjectId), sqlchemy.AND( sqlchemy.IsTrue(q.Field("is_public")), - sqlchemy.Equals(q.Field("public_scope"), rbacutils.ScopeSystem), + sqlchemy.Equals(q.Field("public_scope"), rbacscope.ScopeSystem), ), sqlchemy.AND( sqlchemy.IsTrue(q.Field("is_public")), - sqlchemy.Equals(q.Field("public_scope"), rbacutils.ScopeDomain), + sqlchemy.Equals(q.Field("public_scope"), rbacscope.ScopeDomain), sqlchemy.OR( sqlchemy.Equals(q.Field("domain_id"), owner.GetProjectDomainId()), sqlchemy.In(q.Field("id"), subq2.SubQuery()), @@ -244,7 +244,7 @@ func SharableManagerFilterByOwner(manager IStandaloneModelManager, q *sqlchemy.S sqlchemy.In(q.Field("id"), subq.SubQuery()), )) } - } else if (resScope == rbacutils.ScopeDomain && (scope == rbacutils.ScopeProject || scope == rbacutils.ScopeDomain)) || (resScope == rbacutils.ScopeProject && scope == rbacutils.ScopeDomain) { + } else if (resScope == rbacscope.ScopeDomain && (scope == rbacscope.ScopeProject || scope == rbacscope.ScopeDomain)) || (resScope == rbacscope.ScopeProject && scope == rbacscope.ScopeDomain) { ownerDomainId := owner.GetProjectDomainId() if len(ownerDomainId) > 0 { subq := SharedResourceManager.Query("resource_id") @@ -255,7 +255,7 @@ func SharableManagerFilterByOwner(manager IStandaloneModelManager, q *sqlchemy.S sqlchemy.Equals(q.Field("domain_id"), ownerDomainId), sqlchemy.AND( sqlchemy.IsTrue(q.Field("is_public")), - sqlchemy.Equals(q.Field("public_scope"), rbacutils.ScopeSystem), + sqlchemy.Equals(q.Field("public_scope"), rbacscope.ScopeSystem), ), sqlchemy.AND( sqlchemy.IsTrue(q.Field("is_public")), @@ -284,9 +284,9 @@ type ISharableBaseModel interface { } type ISharableBase interface { - SetShare(scoe rbacutils.TRbacScope) + SetShare(scoe rbacscope.TRbacScope) GetIsPublic() bool - GetPublicScope() rbacutils.TRbacScope + GetPublicScope() rbacscope.TRbacScope GetSharableTargetDomainIds() []string GetRequiredSharedDomainIds() []string GetSharedDomains() []string @@ -296,9 +296,9 @@ func ISharableChangeOwnerCandidateDomainIds(model ISharableBaseModel) []string { var candidates []string if model.GetIsPublic() { switch model.GetPublicScope() { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: return candidates - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: candidates = model.GetSharedDomains() } } @@ -346,11 +346,11 @@ func ISharableMergeShareRequireDomainIds(requiredIds ...[]string) []string { } func SharableModelIsSharable(model ISharableBaseModel, reqUsrId mcclient.IIdentityProvider) bool { - if model.GetIsPublic() && model.GetPublicScope() == rbacutils.ScopeSystem { + if model.GetIsPublic() && model.GetPublicScope() == rbacscope.ScopeSystem { return true } ownerId := model.GetOwnerId() - if model.GetIsPublic() && model.GetPublicScope() == rbacutils.ScopeDomain { + if model.GetIsPublic() && model.GetPublicScope() == rbacscope.ScopeDomain { if ownerId != nil && ownerId.GetProjectDomainId() == reqUsrId.GetProjectDomainId() { return true } @@ -363,7 +363,7 @@ func SharableModelIsSharable(model ISharableBaseModel, reqUsrId mcclient.IIdenti return true } } - if model.GetPublicScope() == rbacutils.ScopeProject { + if model.GetPublicScope() == rbacscope.ScopeProject { if ownerId != nil && ownerId.GetProjectId() == reqUsrId.GetProjectId() { return true } @@ -379,9 +379,9 @@ func SharableModelIsSharable(model ISharableBaseModel, reqUsrId mcclient.IIdenti return false } -func (m *SSharableBaseResource) SetShare(scope rbacutils.TRbacScope) { +func (m *SSharableBaseResource) SetShare(scope rbacscope.TRbacScope) { pub := false - if scope != rbacutils.ScopeNone { + if scope != rbacscope.ScopeNone { pub = true } m.IsPublic = pub @@ -393,25 +393,25 @@ func (m SSharableBaseResource) GetIsPublic() bool { return m.IsPublic } -func (m SSharableBaseResource) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.String2Scope(m.PublicScope) +func (m SSharableBaseResource) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.String2Scope(m.PublicScope) } func SharablePerformPublic(model ISharableBaseModel, ctx context.Context, userCred mcclient.TokenCredential, input apis.PerformPublicProjectInput) error { var err error resourceScope := model.GetModelManager().ResourceScope() - targetScope := rbacutils.String2ScopeDefault(input.Scope, rbacutils.ScopeSystem) + targetScope := rbacscope.String2ScopeDefault(input.Scope, rbacscope.ScopeSystem) if resourceScope.HigherThan(targetScope) { return errors.Wrapf(httperrors.ErrNotSupported, "cannot share %s resource to %s", resourceScope, targetScope) } if len(input.SharedProjectIds) > 0 && len(input.SharedDomainIds) > 0 { return errors.Wrap(httperrors.ErrInputParameter, "cannot set shared_projects and shared_domains at the same time") - } else if len(input.SharedProjectIds) > 0 && targetScope != rbacutils.ScopeProject { - targetScope = rbacutils.ScopeProject - } else if len(input.SharedDomainIds) > 0 && targetScope != rbacutils.ScopeDomain { - targetScope = rbacutils.ScopeDomain + } else if len(input.SharedProjectIds) > 0 && targetScope != rbacscope.ScopeProject { + targetScope = rbacscope.ScopeProject + } else if len(input.SharedDomainIds) > 0 && targetScope != rbacscope.ScopeDomain { + targetScope = rbacscope.ScopeDomain } shareResult := apis.PerformPublicProjectInput{} @@ -421,7 +421,7 @@ func SharablePerformPublic(model ISharableBaseModel, ctx context.Context, userCr requireIds := model.GetRequiredSharedDomainIds() switch targetScope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: if len(requireIds) == 0 { return errors.Wrap(httperrors.ErrForbidden, "require to be shared to system") } else if len(requireIds) > 1 { @@ -435,9 +435,9 @@ func SharablePerformPublic(model ISharableBaseModel, ctx context.Context, userCr return errors.Wrap(err, "shareToTarget") } if len(shareResult.SharedProjectIds) == 0 { - targetScope = rbacutils.ScopeNone + targetScope = rbacscope.ScopeNone } - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: if !consts.GetNonDefaultDomainProjects() { return errors.Wrap(httperrors.ErrForbidden, "not allow to share to domain when non_default_domain_projects turned off") } @@ -452,10 +452,10 @@ func SharablePerformPublic(model ISharableBaseModel, ctx context.Context, userCr if err != nil { return errors.Wrap(err, "shareToTarget add domains") } - if len(shareResult.SharedDomainIds) == 0 && resourceScope == rbacutils.ScopeDomain { - targetScope = rbacutils.ScopeNone + if len(shareResult.SharedDomainIds) == 0 && resourceScope == rbacscope.ScopeDomain { + targetScope = rbacscope.ScopeNone } - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: if len(candidateIds) > 0 { return httperrors.NewForbiddenError("sharing is limited to domains %s", jsonutils.Marshal(candidateIds)) } @@ -492,7 +492,7 @@ func SharablePerformPublic(model ISharableBaseModel, ctx context.Context, userCr return errors.Wrap(err, "Update") } - if targetScope != rbacutils.ScopeNone { + if targetScope != rbacscope.ScopeNone { OpsLog.LogEvent(model, ACT_PUBLIC, shareResult, userCred) logclient.AddActionLogWithContext(ctx, model, logclient.ACT_PUBLIC, shareResult, userCred, true) } @@ -502,12 +502,12 @@ func SharablePerformPublic(model ISharableBaseModel, ctx context.Context, userCr } func SharablePerformPrivate(model ISharableBaseModel, ctx context.Context, userCred mcclient.TokenCredential) error { - if !model.GetIsPublic() && model.GetPublicScope() == rbacutils.ScopeNone { + if !model.GetIsPublic() && model.GetPublicScope() == rbacscope.ScopeNone { return nil } resourceScope := model.GetModelManager().ResourceScope() - if resourceScope == rbacutils.ScopeDomain && !consts.GetNonDefaultDomainProjects() { + if resourceScope == rbacscope.ScopeDomain && !consts.GetNonDefaultDomainProjects() { return errors.Wrap(httperrors.ErrForbidden, "not allow to private domain resource") } @@ -535,7 +535,7 @@ func SharablePerformPrivate(model ISharableBaseModel, ctx context.Context, userC } diff, err := Update(model, func() error { - model.SetShare(rbacutils.ScopeNone) + model.SetShare(rbacscope.ScopeNone) return nil }) @@ -577,12 +577,12 @@ func SharableModelIsShared(model ISharableBaseModel) bool { return true } switch model.GetPublicScope() { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: if model.GetIsPublic() { return true } - case rbacutils.ScopeDomain: - if model.GetModelManager().ResourceScope() == rbacutils.ScopeProject { + case rbacscope.ScopeDomain: + if model.GetModelManager().ResourceScope() == rbacscope.ScopeProject { return true } } @@ -592,20 +592,20 @@ func SharableModelIsShared(model ISharableBaseModel) bool { func SharableModelCustomizeCreate(model ISharableBaseModel, ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) error { if !data.Contains("public_scope") { resScope := model.GetModelManager().ResourceScope() - if resScope == rbacutils.ScopeDomain && consts.GetNonDefaultDomainProjects() { + if resScope == rbacscope.ScopeDomain && consts.GetNonDefaultDomainProjects() { // only if non_default_domain_projects turned on, do the following isManaged := false if managedModel, ok := model.(IManagedResourceBase); ok { isManaged = managedModel.IsManaged() } if !isManaged && IsAdminAllowPerform(ctx, userCred, model, "public") && ownerId.GetProjectDomainId() == userCred.GetProjectDomainId() { - model.SetShare(rbacutils.ScopeSystem) - data.(*jsonutils.JSONDict).Set("public_scope", jsonutils.NewString(string(rbacutils.ScopeSystem))) + model.SetShare(rbacscope.ScopeSystem) + data.(*jsonutils.JSONDict).Set("public_scope", jsonutils.NewString(string(rbacscope.ScopeSystem))) } } } if !data.Contains("public_scope") { - model.SetShare(rbacutils.ScopeNone) + model.SetShare(rbacscope.ScopeNone) } return nil } diff --git a/pkg/cloudcommon/db/sharablevirtual.go b/pkg/cloudcommon/db/sharablevirtual.go index 2ffaaa3159..eb11154c05 100644 --- a/pkg/cloudcommon/db/sharablevirtual.go +++ b/pkg/cloudcommon/db/sharablevirtual.go @@ -19,12 +19,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -48,7 +48,7 @@ func (manager *SSharableVirtualResourceBaseManager) GetISharableVirtualModelMana return manager.GetVirtualObject().(ISharableVirtualModelManager) } -func (manager *SSharableVirtualResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SSharableVirtualResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { return SharableManagerFilterByOwner(manager.GetISharableVirtualModelManager(), q, owner, scope) } @@ -204,20 +204,20 @@ func (model *SSharableVirtualResourceBase) Delete(ctx context.Context, userCred func (model *SSharableVirtualResourceBase) GetSharedInfo() apis.SShareInfo { ret := apis.SShareInfo{} ret.IsPublic = model.IsPublic - ret.PublicScope = rbacutils.String2ScopeDefault(model.PublicScope, rbacutils.ScopeNone) + ret.PublicScope = rbacscope.String2ScopeDefault(model.PublicScope, rbacscope.ScopeNone) ret.SharedDomains = model.GetSharedDomains() ret.SharedProjects = model.GetSharedProjects() // fix if len(ret.SharedDomains) > 0 { - ret.PublicScope = rbacutils.ScopeDomain + ret.PublicScope = rbacscope.ScopeDomain ret.SharedProjects = nil ret.IsPublic = true } else if len(ret.SharedProjects) > 0 { - ret.PublicScope = rbacutils.ScopeProject + ret.PublicScope = rbacscope.ScopeProject ret.SharedDomains = nil ret.IsPublic = true } else if !ret.IsPublic { - ret.PublicScope = rbacutils.ScopeNone + ret.PublicScope = rbacscope.ScopeNone } return ret } diff --git a/pkg/cloudcommon/db/sharedresource.go b/pkg/cloudcommon/db/sharedresource.go index d6bd19462e..fa8d9fd5f7 100644 --- a/pkg/cloudcommon/db/sharedresource.go +++ b/pkg/cloudcommon/db/sharedresource.go @@ -19,13 +19,13 @@ import ( "database/sql" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -69,7 +69,7 @@ func (manager *SSharedResourceManager) CleanModelShares(ctx context.Context, use var err error resScope := model.GetModelManager().ResourceScope() switch resScope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: _, err = manager.shareToTarget(ctx, userCred, model, SharedTargetProject, nil, nil, nil) if err != nil { return errors.Wrap(err, "remove shared project") @@ -78,7 +78,7 @@ func (manager *SSharedResourceManager) CleanModelShares(ctx context.Context, use if err != nil { return errors.Wrap(err, "remove shared domain") } - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: _, err = manager.shareToTarget(ctx, userCred, model, SharedTargetDomain, nil, nil, nil) if err != nil { return errors.Wrap(err, "remove shared domain") @@ -96,24 +96,24 @@ func (manager *SSharedResourceManager) shareToTarget( candidateIds []string, requireDomainIds []string, ) ([]string, error) { - var requireScope rbacutils.TRbacScope + var requireScope rbacscope.TRbacScope resScope := model.GetModelManager().ResourceScope() switch resScope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: switch targetType { case SharedTargetProject: // should have domain-level privileges // cannot share to a project across domain - requireScope = rbacutils.ScopeDomain + requireScope = rbacscope.ScopeDomain case SharedTargetDomain: // should have system-level privileges - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: switch targetType { case SharedTargetDomain: // should have system-level privileges - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem case SharedTargetProject: if len(targetIds) > 0 { return nil, errors.Wrap(httperrors.ErrNotSupported, "cannot share a domain resource to specific project") diff --git a/pkg/cloudcommon/db/standalone_anon.go b/pkg/cloudcommon/db/standalone_anon.go index 576cf99df8..815dec3def 100644 --- a/pkg/cloudcommon/db/standalone_anon.go +++ b/pkg/cloudcommon/db/standalone_anon.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/stringutils" "yunion.io/x/sqlchemy" @@ -30,7 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" "yunion.io/x/onecloud/pkg/util/tagutils" ) @@ -101,7 +101,7 @@ func (manager *SStandaloneAnonResourceBaseManager) FilterByNotId(q *sqlchemy.SQu return q.NotEquals("id", idStr) } -func (manager *SStandaloneAnonResourceBaseManager) FilterByHiddenSystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SStandaloneAnonResourceBaseManager) FilterByHiddenSystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacscope.TRbacScope) *sqlchemy.SQuery { q = manager.SResourceBaseManager.FilterByHiddenSystemAttributes(q, userCred, query, scope) showEmulated := jsonutils.QueryBoolean(query, "show_emulated", false) if showEmulated { @@ -489,7 +489,7 @@ func (model *SStandaloneAnonResourceBase) PerformMetadata(ctx context.Context, u dictStore := make(map[string]interface{}) for k, v := range input { // 已双下滑线开头的metadata是系统内置,普通用户不可添加,只能查看 - if strings.HasPrefix(k, SYS_TAG_PREFIX) && (userCred == nil || !IsAllowPerform(ctx, rbacutils.ScopeSystem, userCred, model, "metadata")) { + if strings.HasPrefix(k, SYS_TAG_PREFIX) && (userCred == nil || !IsAllowPerform(ctx, rbacscope.ScopeSystem, userCred, model, "metadata")) { return nil, httperrors.NewForbiddenError("not allow to set system key, please remove the underscore at the beginning") } dictStore[k] = v diff --git a/pkg/cloudcommon/db/statusinfrasuserresource.go b/pkg/cloudcommon/db/statusinfrasuserresource.go index 64136d84b7..c9f45b3a1f 100644 --- a/pkg/cloudcommon/db/statusinfrasuserresource.go +++ b/pkg/cloudcommon/db/statusinfrasuserresource.go @@ -20,13 +20,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/reflectutils" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -60,12 +60,12 @@ func (manager *SStatusDomainLevelUserResourceBaseManager) ValidateCreateData(ctx return input, nil } -func (manager *SStatusDomainLevelUserResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SStatusDomainLevelUserResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { switch scope { - case rbacutils.ScopeProject, rbacutils.ScopeUser: + case rbacscope.ScopeProject, rbacscope.ScopeUser: return q.Equals("owner_id", owner.GetUserId()) - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: sq := UserCacheManager.Query("id").Equals("domain_id", owner.GetProjectDomainId()) q = q.Filter( sqlchemy.OR( diff --git a/pkg/cloudcommon/db/taskman/tasks.go b/pkg/cloudcommon/db/taskman/tasks.go index 1b456d6ac9..9f108240b7 100644 --- a/pkg/cloudcommon/db/taskman/tasks.go +++ b/pkg/cloudcommon/db/taskman/tasks.go @@ -27,8 +27,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/reflectutils" "yunion.io/x/pkg/util/stringutils" "yunion.io/x/pkg/util/timeutils" @@ -37,16 +40,13 @@ import ( "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/lockman" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) const ( @@ -151,14 +151,14 @@ func (self *STask) GetOwnerId() mcclient.IIdentityProvider { return &owner } -func (manager *STaskManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *STaskManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { switch scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: if len(owner.GetProjectId()) > 0 { q = q.Contains("user_cred", owner.GetProjectId()) } - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: if len(owner.GetProjectDomainId()) > 0 { q = q.Contains("user_cred", owner.GetProjectDomainId()) } diff --git a/pkg/cloudcommon/db/tenantcache.go b/pkg/cloudcommon/db/tenantcache.go index 506ce60001..4e9905401b 100644 --- a/pkg/cloudcommon/db/tenantcache.go +++ b/pkg/cloudcommon/db/tenantcache.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/sqlchemy" identityapi "yunion.io/x/onecloud/pkg/apis/identity" @@ -34,7 +35,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/stringutils2" "yunion.io/x/onecloud/pkg/util/tagutils" ) diff --git a/pkg/cloudcommon/db/tenantcachesync.go b/pkg/cloudcommon/db/tenantcachesync.go index 618637eaa3..1835467496 100644 --- a/pkg/cloudcommon/db/tenantcachesync.go +++ b/pkg/cloudcommon/db/tenantcachesync.go @@ -21,13 +21,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" identityapi "yunion.io/x/onecloud/pkg/apis/identity" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/mcclient/auth" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) var ( @@ -72,7 +72,7 @@ func syncDomains(ctx context.Context) error { s := auth.GetAdminSession(ctx, consts.GetRegion()) query := jsonutils.NewDict() query.Add(jsonutils.NewInt(1024), "limit") - query.Add(jsonutils.NewString(string(rbacutils.ScopeSystem)), "scope") + query.Add(jsonutils.NewString(string(rbacscope.ScopeSystem)), "scope") query.Add(jsonutils.JSONTrue, "details") total := -1 offset := 0 @@ -101,7 +101,7 @@ func syncProjects(ctx context.Context) error { s := auth.GetAdminSession(ctx, consts.GetRegion()) query := jsonutils.NewDict() query.Add(jsonutils.NewInt(1024), "limit") - query.Add(jsonutils.NewString(string(rbacutils.ScopeSystem)), "scope") + query.Add(jsonutils.NewString(string(rbacscope.ScopeSystem)), "scope") query.Add(jsonutils.JSONTrue, "details") total := -1 offset := 0 diff --git a/pkg/cloudcommon/db/usercache.go b/pkg/cloudcommon/db/usercache.go index 5cb3d27eef..f1b8cbb74b 100644 --- a/pkg/cloudcommon/db/usercache.go +++ b/pkg/cloudcommon/db/usercache.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/cloudcommon/consts" @@ -31,7 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) diff --git a/pkg/cloudcommon/db/userresources.go b/pkg/cloudcommon/db/userresources.go index ace22382d4..6679351edc 100644 --- a/pkg/cloudcommon/db/userresources.go +++ b/pkg/cloudcommon/db/userresources.go @@ -20,13 +20,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/reflectutils" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -58,7 +58,7 @@ func (manager *SUserResourceBaseManager) ListItemFilter( if err != nil { return nil, err } - if ((query.Admin != nil && *query.Admin) || query.Scope == string(rbacutils.ScopeSystem)) && IsAdminAllowList(userCred, manager).Result.IsAllow() { + if ((query.Admin != nil && *query.Admin) || query.Scope == string(rbacscope.ScopeSystem)) && IsAdminAllowList(userCred, manager).Result.IsAllow() { user := query.UserId if len(user) > 0 { uc, _ := UserCacheManager.FetchUserByIdOrName(ctx, user) @@ -125,9 +125,9 @@ func (manager *SUserResourceBaseManager) FetchCustomizeColumns( return rows } -func (manager *SUserResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SUserResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { - if scope == rbacutils.ScopeUser { + if scope == rbacscope.ScopeUser { if len(owner.GetUserId()) > 0 { q = q.Equals("owner_id", owner.GetUserId()) } @@ -173,10 +173,10 @@ func (manager *SUserResourceBaseManager) FetchOwnerId(ctx context.Context, data return FetchUserInfo(ctx, data) } -func (manager *SUserResourceBaseManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeUser +func (manager *SUserResourceBaseManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeUser } -func (manager *SUserResourceBaseManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeUser +func (manager *SUserResourceBaseManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeUser } diff --git a/pkg/cloudcommon/db/virtualjointbase.go b/pkg/cloudcommon/db/virtualjointbase.go index 2956bc895a..977aed7dc0 100644 --- a/pkg/cloudcommon/db/virtualjointbase.go +++ b/pkg/cloudcommon/db/virtualjointbase.go @@ -20,12 +20,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/reflectutils" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -59,7 +59,7 @@ func (manager *SVirtualJointResourceBaseManager) AllowAttach(ctx context.Context return false } -func (manager *SVirtualJointResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SVirtualJointResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { masterQ := manager.GetMasterManager().Query("id") masterQ = manager.GetMasterManager().FilterByOwner(masterQ, owner, scope) @@ -72,7 +72,7 @@ func (manager *SVirtualJointResourceBaseManager) FilterByOwner(q *sqlchemy.SQuer return q } -func (manager *SVirtualJointResourceBaseManager) FilterBySystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SVirtualJointResourceBaseManager) FilterBySystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacscope.TRbacScope) *sqlchemy.SQuery { q = manager.SJointResourceBaseManager.FilterBySystemAttributes(q, userCred, query, scope) masterQ := manager.GetMasterManager().Query("id") masterQ = manager.GetMasterManager().FilterBySystemAttributes(masterQ, userCred, query, scope) @@ -84,7 +84,7 @@ func (manager *SVirtualJointResourceBaseManager) FilterBySystemAttributes(q *sql return q } -func (manager *SVirtualJointResourceBaseManager) FilterByHiddenSystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SVirtualJointResourceBaseManager) FilterByHiddenSystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacscope.TRbacScope) *sqlchemy.SQuery { q = manager.SJointResourceBaseManager.FilterByHiddenSystemAttributes(q, userCred, query, scope) masterQ := manager.GetMasterManager().Query("id") masterQ = manager.GetMasterManager().FilterByHiddenSystemAttributes(masterQ, userCred, query, scope) diff --git a/pkg/cloudcommon/db/virtualresource.go b/pkg/cloudcommon/db/virtualresource.go index 95dfc313ae..1909b89eb6 100644 --- a/pkg/cloudcommon/db/virtualresource.go +++ b/pkg/cloudcommon/db/virtualresource.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -33,7 +34,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -76,7 +76,7 @@ func (manager *SVirtualResourceBaseManager) GetIVirtualModelManager() IVirtualMo return manager.GetVirtualObject().(IVirtualModelManager) } -/*func (manager *SVirtualResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +/*func (manager *SVirtualResourceBaseManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { q = manager.SProjectizedResourceBaseManager.FilterByOwner(q, owner, scope) return q } @@ -187,7 +187,7 @@ func (manager *SVirtualResourceBaseManager) GetPropertyDomainStatistics(ctx cont return result, q.All(&result) } -func (manager *SVirtualResourceBaseManager) FilterByHiddenSystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SVirtualResourceBaseManager) FilterByHiddenSystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacscope.TRbacScope) *sqlchemy.SQuery { q = manager.SStatusStandaloneResourceBaseManager.FilterByHiddenSystemAttributes(q, userCred, query, scope) isSystem := jsonutils.QueryBoolean(query, "system", false) @@ -224,7 +224,7 @@ func (model *SVirtualResourceBase) SetProjectInfo(ctx context.Context, userCred return err } -func (manager *SVirtualResourceBaseManager) FilterBySystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SVirtualResourceBaseManager) FilterBySystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacscope.TRbacScope) *sqlchemy.SQuery { q = manager.SStatusStandaloneResourceBaseManager.FilterBySystemAttributes(q, userCred, query, scope) var pendingDelete string @@ -394,16 +394,16 @@ func (model *SVirtualResourceBase) PerformChangeOwner(ctx context.Context, userC return nil, nil } - var requireScope rbacutils.TRbacScope + var requireScope rbacscope.TRbacScope if ownerId.GetProjectDomainId() != model.DomainId { // change domain, do check candidates := model.GetIVirtualModel().GetChangeOwnerCandidateDomainIds() if len(candidates) > 0 && !utils.IsInStringArray(ownerId.GetProjectDomainId(), candidates) { return nil, errors.Wrap(httperrors.ErrForbidden, "target domain not in change owner candidate list") } - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } else { - requireScope = rbacutils.ScopeDomain + requireScope = rbacscope.ScopeDomain } allowScope, policyTags := policy.PolicyManager.AllowScope(userCred, consts.GetServiceType(), model.KeywordPlural(), policy.PolicyActionPerform, "change-owner") diff --git a/pkg/cloudcommon/etcd/handler/dispatcher.go b/pkg/cloudcommon/etcd/handler/dispatcher.go index c6a5fec71f..03b69c1cfa 100644 --- a/pkg/cloudcommon/etcd/handler/dispatcher.go +++ b/pkg/cloudcommon/etcd/handler/dispatcher.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/appsrv" @@ -32,7 +33,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" ) func NewEtcdModelHandler(manger base.IEtcdModelManager) *SEtcdModelHandler { @@ -73,12 +73,12 @@ func (disp *SEtcdModelHandler) FetchUpdateHeaderData(ctx context.Context, header return disp.manager.FetchUpdateHeaderData(ctx, header) } -func (disp *SEtcdModelHandler) List(ctx context.Context, query jsonutils.JSONObject, ctxIds []dispatcher.SResourceContext) (*modulebase.ListResult, error) { +func (disp *SEtcdModelHandler) List(ctx context.Context, query jsonutils.JSONObject, ctxIds []dispatcher.SResourceContext) (*printutils.ListResult, error) { objs, err := disp.manager.AllJson(ctx) if err != nil { return nil, httperrors.NewGeneralError(err) } - return &modulebase.ListResult{ + return &printutils.ListResult{ Data: objs, Total: len(objs), Limit: 0, @@ -171,7 +171,7 @@ func (disp *SEtcdModelHandler) Create(ctx context.Context, query jsonutils.JSONO return nil, httperrors.NewNotImplementedError("not implemented") } -func (disp *SEtcdModelHandler) BatchCreate(ctx context.Context, query jsonutils.JSONObject, data jsonutils.JSONObject, count int, ctxIds []dispatcher.SResourceContext) ([]modulebase.SubmitResult, error) { +func (disp *SEtcdModelHandler) BatchCreate(ctx context.Context, query jsonutils.JSONObject, data jsonutils.JSONObject, count int, ctxIds []dispatcher.SResourceContext) ([]printutils.SubmitResult, error) { return nil, httperrors.NewNotImplementedError("not implemented") } diff --git a/pkg/cloudcommon/etcd/models/base/basemanager.go b/pkg/cloudcommon/etcd/models/base/basemanager.go index 68451e9386..9d7ec7b841 100644 --- a/pkg/cloudcommon/etcd/models/base/basemanager.go +++ b/pkg/cloudcommon/etcd/models/base/basemanager.go @@ -24,11 +24,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/object" "yunion.io/x/pkg/util/stringutils" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/etcd" - "yunion.io/x/onecloud/pkg/cloudcommon/object" ) var ( diff --git a/pkg/cloudcommon/etcd/models/base/basemodel.go b/pkg/cloudcommon/etcd/models/base/basemodel.go index 9abbd1ed4e..91be4a0774 100644 --- a/pkg/cloudcommon/etcd/models/base/basemodel.go +++ b/pkg/cloudcommon/etcd/models/base/basemodel.go @@ -18,8 +18,8 @@ import ( "context" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/object" - "yunion.io/x/onecloud/pkg/cloudcommon/object" "yunion.io/x/onecloud/pkg/mcclient" ) diff --git a/pkg/cloudcommon/notifyclient/notify_internal.go b/pkg/cloudcommon/notifyclient/notify_internal.go index 59434faeb3..d1ab543263 100644 --- a/pkg/cloudcommon/notifyclient/notify_internal.go +++ b/pkg/cloudcommon/notifyclient/notify_internal.go @@ -25,16 +25,16 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/sets" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules/identity" npk "yunion.io/x/onecloud/pkg/mcclient/modules/notify" - "yunion.io/x/onecloud/pkg/util/httputils" ) func notifySystemWarning(ctx context.Context, idstr string, name string, event string, reason string) { diff --git a/pkg/cloudcommon/options/options.go b/pkg/cloudcommon/options/options.go index 566b7dfd5d..1da0b17d59 100644 --- a/pkg/cloudcommon/options/options.go +++ b/pkg/cloudcommon/options/options.go @@ -33,6 +33,7 @@ import ( "yunion.io/x/log" "yunion.io/x/log/hooks" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/reflectutils" "yunion.io/x/pkg/util/version" "yunion.io/x/pkg/utils" @@ -41,7 +42,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/util/atexit" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/pkg/cloudcommon/policy/defaults.go b/pkg/cloudcommon/policy/defaults.go index 7089300f71..f3129b1330 100644 --- a/pkg/cloudcommon/policy/defaults.go +++ b/pkg/cloudcommon/policy/defaults.go @@ -15,6 +15,8 @@ package policy import ( + "yunion.io/x/pkg/util/rbacscope" + "yunion.io/x/onecloud/pkg/util/rbacutils" ) @@ -22,7 +24,7 @@ var ( predefinedDefaultPolicies = []rbacutils.SRbacPolicy{ { Auth: true, - Scope: rbacutils.ScopeSystem, + Scope: rbacscope.ScopeSystem, Rules: []rbacutils.SRbacRule{ { Resource: "tasks", @@ -38,7 +40,7 @@ var ( }, { Auth: true, - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Rules: []rbacutils.SRbacRule{ { Resource: "tasks", @@ -56,7 +58,7 @@ var ( { // for domain Auth: true, - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Rules: []rbacutils.SRbacRule{ { // usages for any services diff --git a/pkg/cloudcommon/policy/policy.go b/pkg/cloudcommon/policy/policy.go index e5f55c9a2f..1e9284c343 100644 --- a/pkg/cloudcommon/policy/policy.go +++ b/pkg/cloudcommon/policy/policy.go @@ -27,6 +27,7 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/apis" "yunion.io/x/onecloud/pkg/appsrv" @@ -67,7 +68,7 @@ func init() { } type SPolicyManager struct { - defaultPolicies map[rbacutils.TRbacScope][]*rbacutils.SRbacPolicy + defaultPolicies map[rbacscope.TRbacScope][]*rbacutils.SRbacPolicy refreshInterval time.Duration @@ -85,9 +86,9 @@ type sPolicyData struct { Enabled bool `json:"enabled"` DomainId string `json:"domain_id"` IsPublic bool `json:"is_public"` - PublicScope rbacutils.TRbacScope `json:"public_scope"` + PublicScope rbacscope.TRbacScope `json:"public_scope"` SharedDomains []apis.SharedDomain `json:"shared_domain"` - Scope rbacutils.TRbacScope `json:"scope"` + Scope rbacscope.TRbacScope `json:"scope"` Policy jsonutils.JSONObject `json:"policy"` DomainTags tagutils.TTagSet `json:"domain_tags"` ProjectTags tagutils.TTagSet `json:"project_tags"` @@ -102,7 +103,7 @@ func (manager *SPolicyManager) init(refreshInterval time.Duration) { manager.refreshInterval = refreshInterval // manager.InitSync(manager) if len(predefinedDefaultPolicies) > 0 { - policiesMap := make(map[rbacutils.TRbacScope][]*rbacutils.SRbacPolicy) + policiesMap := make(map[rbacscope.TRbacScope][]*rbacutils.SRbacPolicy) for i := range predefinedDefaultPolicies { policy := predefinedDefaultPolicies[i] if _, ok := policiesMap[policy.Scope]; !ok { @@ -151,7 +152,7 @@ func policyKey(userCred mcclient.TokenCredential) string { return strings.Join(keys, "-") } -func permissionKey(scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, service string, resource string, action string, extra ...string) string { +func permissionKey(scope rbacscope.TRbacScope, userCred mcclient.TokenCredential, service string, resource string, action string, extra ...string) string { queryKeys := []string{string(scope)} queryKeys = append(queryKeys, userCred.GetProjectId()) roles := userCred.GetRoleIds() @@ -178,43 +179,43 @@ func permissionKey(scope rbacutils.TRbacScope, userCred mcclient.TokenCredential return strings.Join(queryKeys, "-") } -func (manager *SPolicyManager) AllowScope(userCred mcclient.TokenCredential, service string, resource string, action string, extra ...string) (rbacutils.TRbacScope, rbacutils.SPolicyResult) { - for _, scope := range []rbacutils.TRbacScope{ - rbacutils.ScopeSystem, - rbacutils.ScopeDomain, - rbacutils.ScopeProject, - rbacutils.ScopeUser, +func (manager *SPolicyManager) AllowScope(userCred mcclient.TokenCredential, service string, resource string, action string, extra ...string) (rbacscope.TRbacScope, rbacutils.SPolicyResult) { + for _, scope := range []rbacscope.TRbacScope{ + rbacscope.ScopeSystem, + rbacscope.ScopeDomain, + rbacscope.ScopeProject, + rbacscope.ScopeUser, } { result := manager.allow(scope, userCred, service, resource, action, extra...) if result.Result == rbacutils.Allow { return scope, result } } - return rbacutils.ScopeNone, rbacutils.PolicyDeny + return rbacscope.ScopeNone, rbacutils.PolicyDeny } -func (manager *SPolicyManager) Allow(targetScope rbacutils.TRbacScope, userCred mcclient.TokenCredential, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { - var retryScopes []rbacutils.TRbacScope +func (manager *SPolicyManager) Allow(targetScope rbacscope.TRbacScope, userCred mcclient.TokenCredential, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { + var retryScopes []rbacscope.TRbacScope switch targetScope { - case rbacutils.ScopeSystem: - retryScopes = []rbacutils.TRbacScope{ - rbacutils.ScopeSystem, + case rbacscope.ScopeSystem: + retryScopes = []rbacscope.TRbacScope{ + rbacscope.ScopeSystem, } - case rbacutils.ScopeDomain: - retryScopes = []rbacutils.TRbacScope{ - rbacutils.ScopeSystem, - rbacutils.ScopeDomain, + case rbacscope.ScopeDomain: + retryScopes = []rbacscope.TRbacScope{ + rbacscope.ScopeSystem, + rbacscope.ScopeDomain, } - case rbacutils.ScopeProject: - retryScopes = []rbacutils.TRbacScope{ - rbacutils.ScopeSystem, - rbacutils.ScopeDomain, - rbacutils.ScopeProject, + case rbacscope.ScopeProject: + retryScopes = []rbacscope.TRbacScope{ + rbacscope.ScopeSystem, + rbacscope.ScopeDomain, + rbacscope.ScopeProject, } - case rbacutils.ScopeUser: - retryScopes = []rbacutils.TRbacScope{ - rbacutils.ScopeSystem, - rbacutils.ScopeUser, + case rbacscope.ScopeUser: + retryScopes = []rbacscope.TRbacScope{ + rbacscope.ScopeSystem, + rbacscope.ScopeUser, } } for _, scope := range retryScopes { @@ -275,7 +276,7 @@ func (manager *SPolicyManager) fetchMatchedPolicies(userCred mcclient.TokenCrede return res.output, res.err } -func (manager *SPolicyManager) allow(scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { +func (manager *SPolicyManager) allow(scope rbacscope.TRbacScope, userCred mcclient.TokenCredential, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { // first download userCred policy policies, err := manager.fetchMatchedPolicies(userCred) if err != nil { @@ -302,7 +303,7 @@ func (manager *SPolicyManager) allow(scope rbacutils.TRbacScope, userCred mcclie } /* -func (manager *SPolicyManager) findPolicyByName(scope rbacutils.TRbacScope, name string) *rbacutils.SRbacPolicyCore { +func (manager *SPolicyManager) findPolicyByName(scope rbacscope.TRbacScope, name string) *rbacscope.SRbacPolicyCore { if policies, ok := manager.policies[scope]; ok { for i := range policies { if policies[i].Id == name || policies[i].Name == name { @@ -313,13 +314,13 @@ func (manager *SPolicyManager) findPolicyByName(scope rbacutils.TRbacScope, name return nil } -func getMatchedPolicyNames(policies []rbacutils.SPolicyInfo, userCred rbacutils.IRbacIdentity) []string { - _, matchNames := rbacutils.GetMatchedPolicies(policies, userCred) +func getMatchedPolicyNames(policies []rbacscope.SPolicyInfo, userCred rbacscope.IRbacIdentity) []string { + _, matchNames := rbacscope.GetMatchedPolicies(policies, userCred) return matchNames } -func getMatchedPolicyRules(policies []rbacutils.SPolicyInfo, userCred rbacutils.IRbacIdentity, service string, resource string, action string, extra ...string) ([]rbacutils.SRbacRule, bool) { - matchPolicies, _ := rbacutils.GetMatchedPolicies(policies, userCred) +func getMatchedPolicyRules(policies []rbacscope.SPolicyInfo, userCred rbacscope.IRbacIdentity, service string, resource string, action string, extra ...string) ([]rbacscope.SRbacRule, bool) { + matchPolicies, _ := rbacscope.GetMatchedPolicies(policies, userCred) if len(matchPolicies) == 0 { return nil, false } @@ -327,7 +328,7 @@ func getMatchedPolicyRules(policies []rbacutils.SPolicyInfo, userCred rbacutils. } */ -func (manager *SPolicyManager) allowWithoutCache(policies rbacutils.TPolicySet, scope rbacutils.TRbacScope, userCred mcclient.TokenCredential, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { +func (manager *SPolicyManager) allowWithoutCache(policies rbacutils.TPolicySet, scope rbacscope.TRbacScope, userCred mcclient.TokenCredential, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { matchRules := rbacutils.TPolicyMatches{} if len(policies) == 0 { @@ -338,19 +339,19 @@ func (manager *SPolicyManager) allowWithoutCache(policies rbacutils.TPolicySet, scopedDeny := false switch scope { - case rbacutils.ScopeUser: + case rbacscope.ScopeUser: if !isUserResource(service, resource) { scopedDeny = true } - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: if !isProjectResource(service, resource) { scopedDeny = true } - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: if isSystemResource(service, resource) { scopedDeny = true } - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: // no deny at all for system scope } if scopedDeny { @@ -411,10 +412,10 @@ func fetchPolicyDataByIdOrName(ctx context.Context, id string) (*sPolicyData, er return pdata, nil } -func explainPolicyInternal(userCred mcclient.TokenCredential, policyReq jsonutils.JSONObject, policyData *sPolicyData) (rbacutils.TRbacScope, []string, rbacutils.SPolicyResult, rbacutils.SPolicyResult, error) { +func explainPolicyInternal(userCred mcclient.TokenCredential, policyReq jsonutils.JSONObject, policyData *sPolicyData) (rbacscope.TRbacScope, []string, rbacutils.SPolicyResult, rbacutils.SPolicyResult, error) { policySeq, err := policyReq.GetArray() if err != nil { - return rbacutils.ScopeSystem, nil, rbacutils.PolicyDeny, rbacutils.PolicyDeny, httperrors.NewInputParameterError("invalid format") + return rbacscope.ScopeSystem, nil, rbacutils.PolicyDeny, rbacutils.PolicyDeny, httperrors.NewInputParameterError("invalid format") } service := rbacutils.WILD_MATCH resource := rbacutils.WILD_MATCH @@ -442,7 +443,7 @@ func explainPolicyInternal(userCred mcclient.TokenCredential, policyReq jsonutil } scopeStr, _ := policySeq[0].GetString() - scope := rbacutils.String2Scope(scopeStr) + scope := rbacscope.String2Scope(scopeStr) userResult := PolicyManager.Allow(scope, userCred, service, resource, action, extra...) result := userResult @@ -496,7 +497,7 @@ func ExplainRpc(ctx context.Context, userCred mcclient.TokenCredential, params j return ret, nil } -func (manager *SPolicyManager) IsScopeCapable(userCred mcclient.TokenCredential, scope rbacutils.TRbacScope) bool { +func (manager *SPolicyManager) IsScopeCapable(userCred mcclient.TokenCredential, scope rbacscope.TRbacScope) bool { policies, err := manager.fetchMatchedPolicies(userCred) if err != nil { log.Errorf("fetchMatchedPolicyGroup fail %s", err) @@ -511,7 +512,7 @@ func (manager *SPolicyManager) IsScopeCapable(userCred mcclient.TokenCredential, } /* -func (manager *SPolicyManager) MatchedPolicyNames(ctx context.Context, scope rbacutils.TRbacScope, ident rbacutils.IRbacIdentity) []string { +func (manager *SPolicyManager) MatchedPolicyNames(ctx context.Context, scope rbacscope.TRbacScope, ident rbacscope.IRbacIdentity) []string { policies, err := manager.fetchMatchedPolicies(ctx, userCred) if err != nil { log.Errorf("fetchMatchedPolicyGroup fail %s", err) @@ -540,7 +541,7 @@ func (manager *SPolicyManager) AllPolicies() map[string][]string { } func (manager *SPolicyManager) RoleMatchPolicies(roleName string) []string { - ident := rbacutils.NewRbacIdentity("", "", []string{roleName}) + ident := rbacscope.NewRbacIdentity("", "", []string{roleName}) ret := make([]string, 0) for _, policies := range manager.policies { for i := range policies { @@ -552,17 +553,17 @@ func (manager *SPolicyManager) RoleMatchPolicies(roleName string) []string { return ret } -func (manager *SPolicyManager) GetMatchedPolicySet(userCred rbacutils.IRbacIdentity) (rbacutils.TRbacScope, rbacutils.TPolicySet) { - for _, scope := range []rbacutils.TRbacScope{ - rbacutils.ScopeSystem, - rbacutils.ScopeDomain, - rbacutils.ScopeProject, +func (manager *SPolicyManager) GetMatchedPolicySet(userCred rbacscope.IRbacIdentity) (rbacscope.TRbacScope, rbacscope.TPolicySet) { + for _, scope := range []rbacscope.TRbacScope{ + rbacscope.ScopeSystem, + rbacscope.ScopeDomain, + rbacscope.ScopeProject, } { - macthed, _ := rbacutils.GetMatchedPolicies(manager.policies[scope], userCred) + macthed, _ := rbacscope.GetMatchedPolicies(manager.policies[scope], userCred) if len(macthed) > 0 { return scope, macthed } } - return rbacutils.ScopeNone, nil + return rbacscope.ScopeNone, nil } */ diff --git a/pkg/cloudcommon/policy/token.go b/pkg/cloudcommon/policy/token.go index 8ccb0b3799..d7b972e864 100644 --- a/pkg/cloudcommon/policy/token.go +++ b/pkg/cloudcommon/policy/token.go @@ -18,6 +18,7 @@ import ( "context" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" @@ -30,10 +31,10 @@ type SPolicyTokenCredential struct { } func (self *SPolicyTokenCredential) HasSystemAdminPrivilege() bool { - return PolicyManager.IsScopeCapable(self.TokenCredential, rbacutils.ScopeSystem) + return PolicyManager.IsScopeCapable(self.TokenCredential, rbacscope.ScopeSystem) } -func (self *SPolicyTokenCredential) IsAllow(targetScope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { +func (self *SPolicyTokenCredential) IsAllow(targetScope rbacscope.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { allowScope, result := PolicyManager.AllowScope(self.TokenCredential, service, resource, action, extra...) if result.Result == rbacutils.Allow && !targetScope.HigherThan(allowScope) { return result diff --git a/pkg/cloudcommon/validators/errors.go b/pkg/cloudcommon/validators/errors.go index 76222ad67c..3ccb4d7526 100644 --- a/pkg/cloudcommon/validators/errors.go +++ b/pkg/cloudcommon/validators/errors.go @@ -18,9 +18,10 @@ import ( "database/sql" "fmt" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/util/choices" - "yunion.io/x/onecloud/pkg/util/httputils" ) var returnHttpError = true diff --git a/pkg/cloudcommon/workmanager/manager.go b/pkg/cloudcommon/workmanager/manager.go index af9e58cc42..2d0668a060 100644 --- a/pkg/cloudcommon/workmanager/manager.go +++ b/pkg/cloudcommon/workmanager/manager.go @@ -22,8 +22,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" ) diff --git a/pkg/cloudevent/models/cloudevents.go b/pkg/cloudevent/models/cloudevents.go index 547cc5c385..a2e96bde0f 100644 --- a/pkg/cloudevent/models/cloudevents.go +++ b/pkg/cloudevent/models/cloudevents.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/sqlchemy/backends/clickhouse" @@ -30,7 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -183,12 +183,12 @@ func (self *SCloudevent) CustomizeCreate(ctx context.Context, userCred mcclient. return self.SModelBase.CustomizeCreate(ctx, userCred, ownerId, query, data) } -func (manager *SCloudeventManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SCloudeventManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } -func (manager *SCloudeventManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SCloudeventManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SCloudevent) GetOwnerId() mcclient.IIdentityProvider { @@ -196,7 +196,7 @@ func (self *SCloudevent) GetOwnerId() mcclient.IIdentityProvider { return &owner } -func (manager *SCloudeventManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SCloudeventManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { return manager.SDomainizedResourceBaseManager.FilterByOwner(q, owner, scope) } diff --git a/pkg/cloudevent/models/cloudproviders.go b/pkg/cloudevent/models/cloudproviders.go index 7dbb33cc2d..64e2ba368c 100644 --- a/pkg/cloudevent/models/cloudproviders.go +++ b/pkg/cloudevent/models/cloudproviders.go @@ -27,6 +27,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -41,7 +42,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/auth" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/s3gateway/session" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SCloudproviderManager struct { diff --git a/pkg/cloudid/models/cloudaccount.go b/pkg/cloudid/models/cloudaccount.go index de5ceb22ae..3396f4ad43 100644 --- a/pkg/cloudid/models/cloudaccount.go +++ b/pkg/cloudid/models/cloudaccount.go @@ -30,6 +30,8 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/samlutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -43,9 +45,7 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) diff --git a/pkg/cloudid/models/cloudgroupcaches.go b/pkg/cloudid/models/cloudgroupcaches.go index d9846b94e2..8924f84ff6 100644 --- a/pkg/cloudid/models/cloudgroupcaches.go +++ b/pkg/cloudid/models/cloudgroupcaches.go @@ -24,6 +24,8 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rand" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/cloudid" @@ -33,8 +35,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rand" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -109,8 +109,8 @@ func (self *SCloudgroupcache) CustomizeDelete(ctx context.Context, userCred mccl return self.StartCloudgroupcacheDeleteTask(ctx, userCred, "") } -func (manager *SCloudgroupcacheManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SCloudgroupcacheManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SCloudgroupcache) GetOwnerId() mcclient.IIdentityProvider { diff --git a/pkg/cloudid/models/huawei_driver.go b/pkg/cloudid/models/huawei_driver.go index 243a2afb39..04128ab10f 100644 --- a/pkg/cloudid/models/huawei_driver.go +++ b/pkg/cloudid/models/huawei_driver.go @@ -22,11 +22,11 @@ import ( "strings" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/samlutils/idp" ) diff --git a/pkg/cloudid/models/saml_provider.go b/pkg/cloudid/models/saml_provider.go index 47c6103070..de6a169016 100644 --- a/pkg/cloudid/models/saml_provider.go +++ b/pkg/cloudid/models/saml_provider.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/cloudid" @@ -32,7 +33,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudid/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) diff --git a/pkg/cloudid/models/samldriver.go b/pkg/cloudid/models/samldriver.go index 6c5be4acde..08488939b0 100644 --- a/pkg/cloudid/models/samldriver.go +++ b/pkg/cloudid/models/samldriver.go @@ -21,11 +21,11 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/cloudid/options" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/samlutils/idp" ) diff --git a/pkg/cloudid/policy/defaults.go b/pkg/cloudid/policy/defaults.go index 410cfc4b1e..a0ca1a7633 100644 --- a/pkg/cloudid/policy/defaults.go +++ b/pkg/cloudid/policy/defaults.go @@ -15,6 +15,8 @@ package policy import ( + "yunion.io/x/pkg/util/rbacscope" + api "yunion.io/x/onecloud/pkg/apis/cloudid" common_policy "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/util/rbacutils" @@ -33,7 +35,7 @@ var ( predefinedDefaultPolicies = []rbacutils.SRbacPolicy{ { Auth: true, - Scope: rbacutils.ScopeSystem, + Scope: rbacscope.ScopeSystem, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -51,7 +53,7 @@ var ( }, { Auth: true, - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -69,7 +71,7 @@ var ( }, { Auth: true, - Scope: rbacutils.ScopeUser, + Scope: rbacscope.ScopeUser, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -87,7 +89,7 @@ var ( }, { Auth: true, - Scope: rbacutils.ScopeUser, + Scope: rbacscope.ScopeUser, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, diff --git a/pkg/cloudid/saml/init.go b/pkg/cloudid/saml/init.go index 32ad456f18..a22c403426 100644 --- a/pkg/cloudid/saml/init.go +++ b/pkg/cloudid/saml/init.go @@ -18,12 +18,12 @@ import ( "os" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudid/models" "yunion.io/x/onecloud/pkg/cloudid/options" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/samlutils/idp" "yunion.io/x/onecloud/pkg/util/seclib2" ) diff --git a/pkg/cloudid/saml/initidp.go b/pkg/cloudid/saml/initidp.go index 3c1f170bda..a02e1e0ca1 100644 --- a/pkg/cloudid/saml/initidp.go +++ b/pkg/cloudid/saml/initidp.go @@ -19,16 +19,16 @@ import ( "fmt" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudid/models" "yunion.io/x/onecloud/pkg/cloudid/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/i18n" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/samlutils/idp" ) diff --git a/pkg/cloudid/saml/providers/aliyun/driver.go b/pkg/cloudid/saml/providers/aliyun/driver.go index 6e5bb268c0..0f7c47c8a1 100644 --- a/pkg/cloudid/saml/providers/aliyun/driver.go +++ b/pkg/cloudid/saml/providers/aliyun/driver.go @@ -20,12 +20,12 @@ import ( "fmt" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudid/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/samlutils/idp" ) diff --git a/pkg/cloudid/saml/providers/aws/driver.go b/pkg/cloudid/saml/providers/aws/driver.go index 9ca805fd7a..ce46e1ba6b 100644 --- a/pkg/cloudid/saml/providers/aws/driver.go +++ b/pkg/cloudid/saml/providers/aws/driver.go @@ -20,12 +20,12 @@ import ( "fmt" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudid/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/samlutils/idp" ) diff --git a/pkg/cloudid/saml/providers/awscn/driver.go b/pkg/cloudid/saml/providers/awscn/driver.go index 7154a5c0ef..63237eb2ed 100644 --- a/pkg/cloudid/saml/providers/awscn/driver.go +++ b/pkg/cloudid/saml/providers/awscn/driver.go @@ -20,12 +20,12 @@ import ( "fmt" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudid/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/samlutils/idp" ) diff --git a/pkg/cloudid/saml/providers/azure/driver.go b/pkg/cloudid/saml/providers/azure/driver.go index 54ffbbc4a8..b153e80fd3 100644 --- a/pkg/cloudid/saml/providers/azure/driver.go +++ b/pkg/cloudid/saml/providers/azure/driver.go @@ -21,12 +21,12 @@ import ( "strings" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudid/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/samlutils/idp" ) diff --git a/pkg/cloudid/saml/providers/google/driver.go b/pkg/cloudid/saml/providers/google/driver.go index 03ec5a519e..5473080eca 100644 --- a/pkg/cloudid/saml/providers/google/driver.go +++ b/pkg/cloudid/saml/providers/google/driver.go @@ -17,9 +17,10 @@ package google import ( "context" + "yunion.io/x/pkg/util/samlutils" + "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/samlutils/idp" ) diff --git a/pkg/cloudid/saml/providers/qcloud/driver.go b/pkg/cloudid/saml/providers/qcloud/driver.go index a5ae5b3cd7..c73319e050 100644 --- a/pkg/cloudid/saml/providers/qcloud/driver.go +++ b/pkg/cloudid/saml/providers/qcloud/driver.go @@ -20,12 +20,12 @@ import ( "fmt" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudid/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/samlutils/idp" ) diff --git a/pkg/cloudmon/misc/pinger.go b/pkg/cloudmon/misc/pinger.go index 0375319c02..b1f1f219e5 100644 --- a/pkg/cloudmon/misc/pinger.go +++ b/pkg/cloudmon/misc/pinger.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/apis" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -31,7 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/util/influxdb" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/sysutils" ) @@ -51,7 +51,7 @@ func PingProbe(ctx context.Context, userCred mcclient.TokenCredential, isStart b "offset": len(networks), "limit": "10", "cloud_env": api.CLOUD_ENV_ON_PREMISE, - "scope": rbacutils.ScopeSystem, + "scope": rbacscope.ScopeSystem, "is_classic": true, } resp, err := compute.Networks.List(s, jsonutils.Marshal(params)) diff --git a/pkg/cloudmon/misc/system.go b/pkg/cloudmon/misc/system.go index 15fa10e42e..d7e2434c6b 100644 --- a/pkg/cloudmon/misc/system.go +++ b/pkg/cloudmon/misc/system.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/apis" @@ -33,7 +34,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/influxdb" ) diff --git a/pkg/cloudnet/models/routers_realize.go b/pkg/cloudnet/models/routers_realize.go index 3f5a876d55..88de2b2200 100644 --- a/pkg/cloudnet/models/routers_realize.go +++ b/pkg/cloudnet/models/routers_realize.go @@ -21,13 +21,13 @@ import ( "github.com/pkg/errors" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rand" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modules/ansible" "yunion.io/x/onecloud/pkg/util/ansiblev2" - "yunion.io/x/onecloud/pkg/util/rand" ) func (router *SRouter) realize(ctx context.Context, userCred mcclient.TokenCredential) error { diff --git a/pkg/cloudnet/models/routes.go b/pkg/cloudnet/models/routes.go index 5a036a87ae..a220f7f4c3 100644 --- a/pkg/cloudnet/models/routes.go +++ b/pkg/cloudnet/models/routes.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rand" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -28,7 +29,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/validators" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rand" ) type SRoute struct { diff --git a/pkg/cloudnet/models/rules.go b/pkg/cloudnet/models/rules.go index 88358e0ae0..6173d80498 100644 --- a/pkg/cloudnet/models/rules.go +++ b/pkg/cloudnet/models/rules.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rand" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -31,7 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/choices" "yunion.io/x/onecloud/pkg/util/firewalld" - "yunion.io/x/onecloud/pkg/util/rand" ) type SRule struct { diff --git a/pkg/compute/guestdrivers/aliyun.go b/pkg/compute/guestdrivers/aliyun.go index 93c7921318..3eac4ef642 100644 --- a/pkg/compute/guestdrivers/aliyun.go +++ b/pkg/compute/guestdrivers/aliyun.go @@ -21,6 +21,8 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -28,9 +30,7 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SAliyunGuestDriver struct { @@ -50,7 +50,7 @@ func (self *SAliyunGuestDriver) GetProvider() string { return api.CLOUD_PROVIDER_ALIYUN } -func (self *SAliyunGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SAliyunGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PUBLIC_CLOUD diff --git a/pkg/compute/guestdrivers/apsara.go b/pkg/compute/guestdrivers/apsara.go index 001bbab102..13218bb636 100644 --- a/pkg/compute/guestdrivers/apsara.go +++ b/pkg/compute/guestdrivers/apsara.go @@ -15,12 +15,13 @@ package guestdrivers import ( + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" + api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SApsaraGuestDriver struct { @@ -42,7 +43,7 @@ func (self *SApsaraGuestDriver) GetProvider() string { return api.CLOUD_PROVIDER_APSARA } -func (self *SApsaraGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SApsaraGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD diff --git a/pkg/compute/guestdrivers/aws.go b/pkg/compute/guestdrivers/aws.go index 6d709c7528..dd877330ca 100644 --- a/pkg/compute/guestdrivers/aws.go +++ b/pkg/compute/guestdrivers/aws.go @@ -21,7 +21,9 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/osprofile" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -30,8 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SAwsGuestDriver struct { @@ -134,7 +134,7 @@ func (self *SAwsGuestDriver) GetProvider() string { return api.CLOUD_PROVIDER_AWS } -func (self *SAwsGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SAwsGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PUBLIC_CLOUD diff --git a/pkg/compute/guestdrivers/azure.go b/pkg/compute/guestdrivers/azure.go index c2fcc09bc1..67add5eb1f 100644 --- a/pkg/compute/guestdrivers/azure.go +++ b/pkg/compute/guestdrivers/azure.go @@ -21,6 +21,8 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -31,8 +33,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" modules "yunion.io/x/onecloud/pkg/mcclient/modules/image" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SAzureGuestDriver struct { @@ -52,7 +52,7 @@ func (self *SAzureGuestDriver) GetProvider() string { return api.CLOUD_PROVIDER_AZURE } -func (self *SAzureGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SAzureGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PUBLIC_CLOUD diff --git a/pkg/compute/guestdrivers/baremetals.go b/pkg/compute/guestdrivers/baremetals.go index 57c100284c..e672dfd8df 100644 --- a/pkg/compute/guestdrivers/baremetals.go +++ b/pkg/compute/guestdrivers/baremetals.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -37,7 +38,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SBaremetalGuestDriver struct { @@ -64,7 +64,7 @@ func (self *SBaremetalGuestDriver) GetInstanceCapability() cloudprovider.SInstan } } -func (self *SBaremetalGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SBaremetalGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_ON_PREMISE diff --git a/pkg/compute/guestdrivers/base.go b/pkg/compute/guestdrivers/base.go index 97998934d1..93aba361e2 100644 --- a/pkg/compute/guestdrivers/base.go +++ b/pkg/compute/guestdrivers/base.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/osprofile" "yunion.io/x/onecloud/pkg/apis" @@ -38,7 +39,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/billing" ) type SBaseGuestScheduleDriver struct{} diff --git a/pkg/compute/guestdrivers/bingocloud.go b/pkg/compute/guestdrivers/bingocloud.go index 2100f49d37..8993286bda 100644 --- a/pkg/compute/guestdrivers/bingocloud.go +++ b/pkg/compute/guestdrivers/bingocloud.go @@ -16,13 +16,13 @@ package guestdrivers import ( "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SBingoCloudGuestDriver struct { @@ -63,7 +63,7 @@ func (self *SBingoCloudGuestDriver) GetInstanceCapability() cloudprovider.SInsta } } -func (self *SBingoCloudGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SBingoCloudGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD diff --git a/pkg/compute/guestdrivers/cloudpods.go b/pkg/compute/guestdrivers/cloudpods.go index 50744acfe6..23f729b11f 100644 --- a/pkg/compute/guestdrivers/cloudpods.go +++ b/pkg/compute/guestdrivers/cloudpods.go @@ -16,6 +16,7 @@ package guestdrivers import ( "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -24,7 +25,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SCloudpodsGuestDriver struct { @@ -102,7 +102,7 @@ func (self *SCloudpodsGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk return nil } -func (self *SCloudpodsGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SCloudpodsGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD diff --git a/pkg/compute/guestdrivers/container.go b/pkg/compute/guestdrivers/container.go index 2d6547e396..df29934312 100644 --- a/pkg/compute/guestdrivers/container.go +++ b/pkg/compute/guestdrivers/container.go @@ -21,6 +21,8 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" @@ -29,8 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) var ( @@ -66,7 +66,7 @@ func (self *SContainerDriver) GetInstanceCapability() cloudprovider.SInstanceCap } // for backward compatibility, deprecated driver -func (self *SContainerDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SContainerDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_ON_PREMISE diff --git a/pkg/compute/guestdrivers/ctyun.go b/pkg/compute/guestdrivers/ctyun.go index b59b36d164..3b9145607b 100644 --- a/pkg/compute/guestdrivers/ctyun.go +++ b/pkg/compute/guestdrivers/ctyun.go @@ -18,13 +18,13 @@ import ( "fmt" "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SCtyunGuestDriver struct { @@ -56,7 +56,7 @@ func (self *SCtyunGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCa } } -func (self *SCtyunGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SCtyunGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PUBLIC_CLOUD diff --git a/pkg/compute/guestdrivers/ecloud.go b/pkg/compute/guestdrivers/ecloud.go index 92def4ce68..7c57357658 100644 --- a/pkg/compute/guestdrivers/ecloud.go +++ b/pkg/compute/guestdrivers/ecloud.go @@ -17,12 +17,12 @@ package guestdrivers import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SEcloudGuestDriver struct { @@ -54,7 +54,7 @@ func (self *SEcloudGuestDriver) GetInstanceCapability() cloudprovider.SInstanceC } } -func (self *SEcloudGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SEcloudGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PUBLIC_CLOUD diff --git a/pkg/compute/guestdrivers/esxi.go b/pkg/compute/guestdrivers/esxi.go index 78bcd05b35..f8da1f9908 100644 --- a/pkg/compute/guestdrivers/esxi.go +++ b/pkg/compute/guestdrivers/esxi.go @@ -25,6 +25,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -36,9 +39,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SESXiGuestDriver struct { @@ -83,7 +83,7 @@ func (self *SESXiGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCap } } -func (self *SESXiGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SESXiGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_ON_PREMISE diff --git a/pkg/compute/guestdrivers/google.go b/pkg/compute/guestdrivers/google.go index 1ae4051190..8ad473b4f7 100644 --- a/pkg/compute/guestdrivers/google.go +++ b/pkg/compute/guestdrivers/google.go @@ -25,7 +25,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/osprofile" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -34,8 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SGoogleGuestDriver struct { @@ -47,7 +47,7 @@ func init() { models.RegisterGuestDriver(&driver) } -func (self *SGoogleGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SGoogleGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PUBLIC_CLOUD diff --git a/pkg/compute/guestdrivers/hcs.go b/pkg/compute/guestdrivers/hcs.go index 72c06fb505..b114857866 100644 --- a/pkg/compute/guestdrivers/hcs.go +++ b/pkg/compute/guestdrivers/hcs.go @@ -22,6 +22,8 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -30,8 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SHCSGuestDriver struct { @@ -59,7 +59,7 @@ func (self *SHCSGuestDriver) DoScheduleStorageFilter() bool { return false } -func (self *SHCSGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SHCSGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD diff --git a/pkg/compute/guestdrivers/hcsop.go b/pkg/compute/guestdrivers/hcsop.go index 68040b4a52..d7a9c91eb7 100644 --- a/pkg/compute/guestdrivers/hcsop.go +++ b/pkg/compute/guestdrivers/hcsop.go @@ -22,6 +22,8 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -30,8 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SHCSOPGuestDriver struct { @@ -59,7 +59,7 @@ func (self *SHCSOPGuestDriver) DoScheduleStorageFilter() bool { return false } -func (self *SHCSOPGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SHCSOPGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD diff --git a/pkg/compute/guestdrivers/huawei.go b/pkg/compute/guestdrivers/huawei.go index d50192e1b3..675e059e1d 100644 --- a/pkg/compute/guestdrivers/huawei.go +++ b/pkg/compute/guestdrivers/huawei.go @@ -18,14 +18,14 @@ import ( "fmt" "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SHuaweiGuestDriver struct { @@ -45,7 +45,7 @@ func (self *SHuaweiGuestDriver) GetProvider() string { return api.CLOUD_PROVIDER_HUAWEI } -func (self *SHuaweiGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SHuaweiGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PUBLIC_CLOUD diff --git a/pkg/compute/guestdrivers/huaweistack.go b/pkg/compute/guestdrivers/huaweistack.go index efda0dd7cf..7929538d94 100644 --- a/pkg/compute/guestdrivers/huaweistack.go +++ b/pkg/compute/guestdrivers/huaweistack.go @@ -22,6 +22,8 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -30,8 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SHCSOGuestDriver struct { @@ -55,7 +55,7 @@ func (self *SHCSOGuestDriver) DoScheduleSKUFilter() bool { return false } -func (self *SHCSOGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SHCSOGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD diff --git a/pkg/compute/guestdrivers/incloudsphere.go b/pkg/compute/guestdrivers/incloudsphere.go index ea57a35cd2..8986017588 100644 --- a/pkg/compute/guestdrivers/incloudsphere.go +++ b/pkg/compute/guestdrivers/incloudsphere.go @@ -19,6 +19,7 @@ import ( "fmt" "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -28,7 +29,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SInCloudSphereGuestDriver struct { @@ -73,7 +73,7 @@ func (self *SInCloudSphereGuestDriver) GetInstanceCapability() cloudprovider.SIn } } -func (self *SInCloudSphereGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SInCloudSphereGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD diff --git a/pkg/compute/guestdrivers/jdcloud.go b/pkg/compute/guestdrivers/jdcloud.go index 3f3e2e6526..7cccdaf720 100644 --- a/pkg/compute/guestdrivers/jdcloud.go +++ b/pkg/compute/guestdrivers/jdcloud.go @@ -16,13 +16,13 @@ package guestdrivers import ( "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SJDcloudGuestDriver struct { @@ -42,7 +42,7 @@ func (self *SJDcloudGuestDriver) GetProvider() string { return api.CLOUD_PROVIDER_JDCLOUD } -func (self *SJDcloudGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SJDcloudGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PUBLIC_CLOUD diff --git a/pkg/compute/guestdrivers/kvm.go b/pkg/compute/guestdrivers/kvm.go index 83b12f2cda..73c0457f8c 100644 --- a/pkg/compute/guestdrivers/kvm.go +++ b/pkg/compute/guestdrivers/kvm.go @@ -25,6 +25,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -40,9 +42,7 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SKVMGuestDriver struct { @@ -62,7 +62,7 @@ func (self *SKVMGuestDriver) GetProvider() string { return api.CLOUD_PROVIDER_ONECLOUD } -func (self *SKVMGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SKVMGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_ON_PREMISE diff --git a/pkg/compute/guestdrivers/managedvirtual.go b/pkg/compute/guestdrivers/managedvirtual.go index 37ee5b206e..127e5dac1d 100644 --- a/pkg/compute/guestdrivers/managedvirtual.go +++ b/pkg/compute/guestdrivers/managedvirtual.go @@ -24,6 +24,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/cloudinit" + "yunion.io/x/pkg/util/pinyinutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -36,10 +39,7 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/cloudinit" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/pinyinutils" ) type SManagedVirtualizedGuestDriver struct { diff --git a/pkg/compute/guestdrivers/nutanix.go b/pkg/compute/guestdrivers/nutanix.go index e78f8adc47..1050a25982 100644 --- a/pkg/compute/guestdrivers/nutanix.go +++ b/pkg/compute/guestdrivers/nutanix.go @@ -20,6 +20,8 @@ import ( "time" "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -29,8 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SNutanixGuestDriver struct { @@ -75,7 +75,7 @@ func (self *SNutanixGuestDriver) GetInstanceCapability() cloudprovider.SInstance } } -func (self *SNutanixGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SNutanixGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD diff --git a/pkg/compute/guestdrivers/openstack.go b/pkg/compute/guestdrivers/openstack.go index 02aaaa9c1a..743e56a4b3 100644 --- a/pkg/compute/guestdrivers/openstack.go +++ b/pkg/compute/guestdrivers/openstack.go @@ -23,6 +23,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -36,8 +38,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" scheduler "yunion.io/x/onecloud/pkg/scheduler/options" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SOpenStackGuestDriver struct { @@ -90,7 +90,7 @@ func (self *SOpenStackGuestDriver) GetInstanceCapability() cloudprovider.SInstan } } -func (self *SOpenStackGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SOpenStackGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD diff --git a/pkg/compute/guestdrivers/proxmox.go b/pkg/compute/guestdrivers/proxmox.go index aabdea6f1a..535cfa84e7 100644 --- a/pkg/compute/guestdrivers/proxmox.go +++ b/pkg/compute/guestdrivers/proxmox.go @@ -18,6 +18,7 @@ import ( "context" "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" @@ -26,7 +27,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SProxmoxGuestDriver struct { @@ -71,7 +71,7 @@ func (self *SProxmoxGuestDriver) GetInstanceCapability() cloudprovider.SInstance } } -func (self *SProxmoxGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SProxmoxGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD diff --git a/pkg/compute/guestdrivers/qcloud.go b/pkg/compute/guestdrivers/qcloud.go index e9c5565321..93554b088e 100644 --- a/pkg/compute/guestdrivers/qcloud.go +++ b/pkg/compute/guestdrivers/qcloud.go @@ -20,7 +20,9 @@ import ( "strings" "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/osprofile" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -28,8 +30,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SQcloudGuestDriver struct { @@ -49,7 +49,7 @@ func (self *SQcloudGuestDriver) GetProvider() string { return api.CLOUD_PROVIDER_QCLOUD } -func (self *SQcloudGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SQcloudGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PUBLIC_CLOUD diff --git a/pkg/compute/guestdrivers/remotefile.go b/pkg/compute/guestdrivers/remotefile.go index cac60616d6..d07a069086 100644 --- a/pkg/compute/guestdrivers/remotefile.go +++ b/pkg/compute/guestdrivers/remotefile.go @@ -16,13 +16,13 @@ package guestdrivers import ( "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SRemoteFileGuestDriver struct { @@ -59,7 +59,7 @@ func (self *SRemoteFileGuestDriver) GetInstanceCapability() cloudprovider.SInsta } } -func (self *SRemoteFileGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SRemoteFileGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD diff --git a/pkg/compute/guestdrivers/ucloud.go b/pkg/compute/guestdrivers/ucloud.go index e5420ad038..6df5a580ba 100644 --- a/pkg/compute/guestdrivers/ucloud.go +++ b/pkg/compute/guestdrivers/ucloud.go @@ -18,13 +18,13 @@ import ( "fmt" "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SUCloudGuestDriver struct { @@ -39,7 +39,7 @@ func (self *SUCloudGuestDriver) GetProvider() string { return api.CLOUD_PROVIDER_UCLOUD } -func (self *SUCloudGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SUCloudGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PUBLIC_CLOUD diff --git a/pkg/compute/guestdrivers/zstack.go b/pkg/compute/guestdrivers/zstack.go index ef84df0420..59e8c2ca3f 100644 --- a/pkg/compute/guestdrivers/zstack.go +++ b/pkg/compute/guestdrivers/zstack.go @@ -19,6 +19,8 @@ import ( "fmt" "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -26,8 +28,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SZStackGuestDriver struct { @@ -55,7 +55,7 @@ func (self *SZStackGuestDriver) GetProvider() string { return api.CLOUD_PROVIDER_ZSTACK } -func (self *SZStackGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { +func (self *SZStackGuestDriver) GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys { keys := models.SComputeResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) keys.CloudEnv = api.CLOUD_ENV_PRIVATE_CLOUD diff --git a/pkg/compute/hostdrivers/esxi.go b/pkg/compute/hostdrivers/esxi.go index edc1890503..e729fbd977 100644 --- a/pkg/compute/hostdrivers/esxi.go +++ b/pkg/compute/hostdrivers/esxi.go @@ -23,12 +23,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SESXiHostDriver struct { diff --git a/pkg/compute/hostdrivers/kvm.go b/pkg/compute/hostdrivers/kvm.go index 8d3244eb57..03d5555f0e 100644 --- a/pkg/compute/hostdrivers/kvm.go +++ b/pkg/compute/hostdrivers/kvm.go @@ -27,6 +27,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -38,7 +39,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/k8s/tokens" ) diff --git a/pkg/compute/models/access_group_caches.go b/pkg/compute/models/access_group_caches.go index 7872d9b7e3..b525be565c 100644 --- a/pkg/compute/models/access_group_caches.go +++ b/pkg/compute/models/access_group_caches.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -30,7 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -70,8 +70,8 @@ type SAccessGroupCache struct { NetworkType string `width:"8" charset:"ascii" nullable:"false" index:"true" list:"user" default:"vpc"` } -func (manager *SAccessGroupCacheManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SAccessGroupCacheManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (manager *SAccessGroupCacheManager) ListItemFilter( @@ -162,10 +162,10 @@ func (self *SAccessGroupCache) GetOwnerId() mcclient.IIdentityProvider { return &db.SOwnerId{DomainId: ag.DomainId} } -func (manager *SAccessGroupCacheManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SAccessGroupCacheManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred != nil { sq := AccessGroupManager.Query("id") - if scope == rbacutils.ScopeDomain && len(userCred.GetProjectDomainId()) > 0 { + if scope == rbacscope.ScopeDomain && len(userCred.GetProjectDomainId()) > 0 { sq = sq.Equals("domain_id", userCred.GetProjectDomainId()) return q.In("access_group_id", sq) } diff --git a/pkg/compute/models/access_group_rules.go b/pkg/compute/models/access_group_rules.go index f8fe81c66a..c2df6de3b3 100644 --- a/pkg/compute/models/access_group_rules.go +++ b/pkg/compute/models/access_group_rules.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/regutils" "yunion.io/x/pkg/util/stringutils" "yunion.io/x/pkg/utils" @@ -32,7 +33,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -81,8 +81,8 @@ func (manager *SAccessGroupRuleManager) CreateByInsertOrUpdate() bool { return false } -func (manager *SAccessGroupRuleManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SAccessGroupRuleManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (manager *SAccessGroupRuleManager) FetchUniqValues(ctx context.Context, data jsonutils.JSONObject) jsonutils.JSONObject { @@ -110,7 +110,7 @@ func (manager *SAccessGroupRuleManager) FetchOwnerId(ctx context.Context, data j return db.FetchDomainInfo(ctx, data) } -func (manager *SAccessGroupRuleManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SAccessGroupRuleManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { sq := AccessGroupManager.Query("id") sq = db.SharableManagerFilterByOwner(AccessGroupManager, sq, userCred, scope) return q.In("access_group_id", sq.SubQuery()) diff --git a/pkg/compute/models/billingresource.go b/pkg/compute/models/billingresource.go index fbccfd1c82..fc7072859f 100644 --- a/pkg/compute/models/billingresource.go +++ b/pkg/compute/models/billingresource.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -31,7 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/stringutils2" ) diff --git a/pkg/compute/models/buckets.go b/pkg/compute/models/buckets.go index dd2d969e7c..21d3d7ed7d 100644 --- a/pkg/compute/models/buckets.go +++ b/pkg/compute/models/buckets.go @@ -30,6 +30,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -459,7 +460,7 @@ func (manager *SBucketManager) ValidateCreateData( } } - quotaKeys := fetchRegionalQuotaKeys(rbacutils.ScopeProject, ownerId, cloudRegionV, managerV) + quotaKeys := fetchRegionalQuotaKeys(rbacscope.ScopeProject, ownerId, cloudRegionV, managerV) pendingUsage := SRegionQuota{Bucket: 1} pendingUsage.SetKeys(quotaKeys) if err := quotas.CheckSetPendingQuota(ctx, userCred, &pendingUsage); err != nil { @@ -479,7 +480,7 @@ func (bucket *SBucket) GetQuotaKeys() (quotas.IQuotaKeys, error) { return nil, errors.Wrap(httperrors.ErrInvalidStatus, "no valid region") } return fetchRegionalQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, bucket.GetOwnerId(), region, bucket.GetCloudprovider(), @@ -1707,7 +1708,7 @@ type SBucketUsages struct { DiskUsedRate float64 } -func (manager *SBucketManager) TotalCount(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) SBucketUsages { +func (manager *SBucketManager) TotalCount(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) SBucketUsages { usage := SBucketUsages{} bq := manager.Query() bq = db.ObjectIdQueryWithPolicyResult(bq, manager, policyResult) diff --git a/pkg/compute/models/cachedimages.go b/pkg/compute/models/cachedimages.go index bd7227e3dd..4b181983d9 100644 --- a/pkg/compute/models/cachedimages.go +++ b/pkg/compute/models/cachedimages.go @@ -27,6 +27,8 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/sqlchemy" @@ -38,8 +40,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modules/image" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -558,7 +558,7 @@ func (self *SCachedimage) syncWithCloudImage(ctx context.Context, userCred mccli self.ImageType = string(image.GetImageType()) self.PublicScope = string(image.GetPublicScope()) self.Status = image.GetStatus() - if image.GetPublicScope() == rbacutils.ScopeSystem { + if image.GetPublicScope() == rbacscope.ScopeSystem { self.IsPublic = true } self.UEFI = tristate.NewFromBool(cloudprovider.IsUEFI(image)) @@ -587,7 +587,7 @@ func (manager *SCachedimageManager) newFromCloudImage(ctx context.Context, userC cachedImage.Status = image.GetStatus() cachedImage.PublicScope = string(image.GetPublicScope()) switch image.GetPublicScope() { - case rbacutils.ScopeNone: + case rbacscope.ScopeNone: default: cachedImage.IsPublic = true } @@ -908,7 +908,7 @@ func (manager *SCachedimageManager) InitializeData() error { for i := range images { _, err := db.Update(&images[i], func() error { images[i].IsPublic = true - images[i].PublicScope = string(rbacutils.ScopeSystem) + images[i].PublicScope = string(rbacscope.ScopeSystem) images[i].ProjectId = "system" if len(images[i].ExternalId) > 0 { images[i].Status = api.CACHED_IMAGE_STATUS_ACTIVE diff --git a/pkg/compute/models/capabilities.go b/pkg/compute/models/capabilities.go index 950b569425..42b62e9d9c 100644 --- a/pkg/compute/models/capabilities.go +++ b/pkg/compute/models/capabilities.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -34,7 +35,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SCapabilities struct { @@ -155,7 +155,7 @@ func GetCapabilities(ctx context.Context, userCred mcclient.TokenCredential, que capa := SCapabilities{} var ownerId mcclient.IIdentityProvider scopeStr := jsonutils.GetAnyString(query, []string{"scope"}) - scope := rbacutils.String2Scope(scopeStr) + scope := rbacscope.String2Scope(scopeStr) var domainId string domainStr := jsonutils.GetAnyString(query, []string{"domain", "domain_id", "project_domain", "project_domain_id"}) if len(domainStr) > 0 { @@ -168,12 +168,12 @@ func GetCapabilities(ctx context.Context, userCred mcclient.TokenCredential, que } domainId = domain.GetId() ownerId = &db.SOwnerId{DomainId: domainId} - scope = rbacutils.ScopeDomain + scope = rbacscope.ScopeDomain } else { domainId = userCred.GetProjectDomainId() ownerId = userCred } - if scope == rbacutils.ScopeSystem { + if scope == rbacscope.ScopeSystem { result := policy.PolicyManager.Allow(scope, userCred, consts.GetServiceType(), "capabilities", policy.PolicyActionList) if result.Result.IsDeny() { return capa, httperrors.NewForbiddenError("not allow to query system capability") @@ -250,7 +250,7 @@ func GetAvailableHostCount(userCred mcclient.TokenCredential, query *jsonutils.J Equals("host_status", "online").Equals("host_type", api.HOST_TYPE_HYPERVISOR) if len(domainId) > 0 { ownerId := &db.SOwnerId{DomainId: domainId} - q = HostManager.FilterByOwner(q, ownerId, rbacutils.ScopeDomain) + q = HostManager.FilterByOwner(q, ownerId, rbacscope.ScopeDomain) } if len(zoneId) > 0 { q = q.Equals("zone_id", zoneId) @@ -459,7 +459,7 @@ func getHypervisors(region *SCloudregion, zone *SZone, domainId string) []string } if len(domainId) > 0 { ownerId := &db.SOwnerId{DomainId: domainId} - q = HostManager.FilterByOwner(q, ownerId, rbacutils.ScopeDomain) + q = HostManager.FilterByOwner(q, ownerId, rbacscope.ScopeDomain) /*subq := getDomainManagerSubq(domainId) q = q.Filter(sqlchemy.OR( sqlchemy.In(q.Field("manager_id"), subq), @@ -501,7 +501,7 @@ func getResourceTypes(region *SCloudregion, zone *SZone, domainId string) []stri } if len(domainId) > 0 { ownerId := &db.SOwnerId{DomainId: domainId} - q = HostManager.FilterByOwner(q, ownerId, rbacutils.ScopeDomain) + q = HostManager.FilterByOwner(q, ownerId, rbacscope.ScopeDomain) /*subq := getDomainManagerSubq(domainId) q = q.Filter(sqlchemy.OR( sqlchemy.In(q.Field("manager_id"), subq), @@ -586,7 +586,7 @@ func getStorageTypes( hostQuery := HostManager.Query() if len(domainId) > 0 { ownerId := &db.SOwnerId{DomainId: domainId} - hostQuery = HostManager.FilterByOwner(hostQuery, ownerId, rbacutils.ScopeDomain) + hostQuery = HostManager.FilterByOwner(hostQuery, ownerId, rbacscope.ScopeDomain) } hosts := hostQuery.SubQuery() @@ -623,7 +623,7 @@ func getStorageTypes( } if len(domainId) > 0 { ownerId := &db.SOwnerId{DomainId: domainId} - q = StorageManager.FilterByOwner(q, ownerId, rbacutils.ScopeDomain) + q = StorageManager.FilterByOwner(q, ownerId, rbacscope.ScopeDomain) } q = q.Filter(sqlchemy.Equals(hosts.Field("resource_type"), api.HostResourceTypeShared)) q = q.Filter(sqlchemy.IsNotEmpty(storages.Field("storage_type"))) @@ -746,7 +746,7 @@ func getGPUs(region *SCloudregion, zone *SZone, domainId string) []string { hostQuery := HostManager.Query() if len(domainId) > 0 { ownerId := &db.SOwnerId{DomainId: domainId} - hostQuery = StorageManager.FilterByOwner(hostQuery, ownerId, rbacutils.ScopeDomain) + hostQuery = StorageManager.FilterByOwner(hostQuery, ownerId, rbacscope.ScopeDomain) } hosts := hostQuery.SubQuery() @@ -791,7 +791,7 @@ func getHostCpuArchs(region *SCloudregion, zone *SZone, domainId string) []strin Equals("host_status", "online").Equals("host_type", api.HOST_TYPE_HYPERVISOR) if len(domainId) > 0 { ownerId := &db.SOwnerId{DomainId: domainId} - q = HostManager.FilterByOwner(q, ownerId, rbacutils.ScopeDomain) + q = HostManager.FilterByOwner(q, ownerId, rbacscope.ScopeDomain) } if zone != nil { q = q.Equals("zone_id", zone.Id) @@ -819,15 +819,15 @@ func getHostCpuArchs(region *SCloudregion, zone *SZone, domainId string) []strin return res } -func getNetworkCount(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope, region *SCloudregion, zone *SZone) (int, error) { +func getNetworkCount(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope, region *SCloudregion, zone *SZone) (int, error) { return getNetworkCountByFilter(ownerId, scope, region, zone, tristate.None, "") } -func getAutoAllocNetworkCount(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope, region *SCloudregion, zone *SZone, serverType string) (int, error) { +func getAutoAllocNetworkCount(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope, region *SCloudregion, zone *SZone, serverType string) (int, error) { return getNetworkCountByFilter(ownerId, scope, region, zone, tristate.True, serverType) } -func getNetworkCountByFilter(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope, region *SCloudregion, zone *SZone, isAutoAlloc tristate.TriState, serverType string) (int, error) { +func getNetworkCountByFilter(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope, region *SCloudregion, zone *SZone, isAutoAlloc tristate.TriState, serverType string) (int, error) { if zone != nil && region == nil { region, _ = zone.GetRegion() } @@ -914,7 +914,7 @@ func getMaxDataDiskCount(region *SCloudregion, zone *SZone) int { return 0 } -func isUsable(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope, region *SCloudregion, zone *SZone) bool { +func isUsable(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope, region *SCloudregion, zone *SZone) bool { cnt, err := getNetworkCount(ownerId, scope, region, zone) if err != nil { return false diff --git a/pkg/compute/models/cdn_domains.go b/pkg/compute/models/cdn_domains.go index 85dbd9d311..d195eefa8a 100644 --- a/pkg/compute/models/cdn_domains.go +++ b/pkg/compute/models/cdn_domains.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -34,7 +35,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/validators" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -402,7 +402,7 @@ func (manager *SCDNDomainManager) OrderByExtraFields( func (manager *SCDNDomainManager) totalCount( ownerId mcclient.IIdentityProvider, - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, rangeObjs []db.IStandaloneModel, providers []string, brands []string, @@ -410,7 +410,7 @@ func (manager *SCDNDomainManager) totalCount( ) int { q := CDNDomainManager.Query() - if scope != rbacutils.ScopeSystem && ownerId != nil { + if scope != rbacscope.ScopeSystem && ownerId != nil { q = q.Equals("domain_id", ownerId.GetProjectDomainId()) } q = CloudProviderFilter(q, q.Field("manager_id"), providers, brands, cloudEnv) diff --git a/pkg/compute/models/cloudaccount_saml.go b/pkg/compute/models/cloudaccount_saml.go index 997fcd4efc..750fa146bc 100644 --- a/pkg/compute/models/cloudaccount_saml.go +++ b/pkg/compute/models/cloudaccount_saml.go @@ -19,6 +19,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/apis/cloudid" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -27,7 +28,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" cloudid_modules "yunion.io/x/onecloud/pkg/mcclient/modules/cloudid" - "yunion.io/x/onecloud/pkg/util/httputils" ) func (account *SCloudaccount) GetDetailsSaml(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (api.GetCloudaccountSamlOutput, error) { diff --git a/pkg/compute/models/cloudaccounts.go b/pkg/compute/models/cloudaccounts.go index c1d1878137..5f2b67391a 100644 --- a/pkg/compute/models/cloudaccounts.go +++ b/pkg/compute/models/cloudaccounts.go @@ -31,6 +31,8 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -48,9 +50,7 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -550,7 +550,7 @@ func (self *SCloudaccount) CustomizeCreate(ctx context.Context, userCred mcclien if !data.Contains("public_scope") { self.ShareMode = api.CLOUD_ACCOUNT_SHARE_MODE_ACCOUNT_DOMAIN self.IsPublic = false - self.PublicScope = string(rbacutils.ScopeNone) + self.PublicScope = string(rbacscope.ScopeNone) // mark the public_scope has been set data.(*jsonutils.JSONDict).Set("public_scope", jsonutils.NewString(self.PublicScope)) } @@ -1426,13 +1426,13 @@ func (manager *SCloudaccountManager) initializePublicScope() error { _, err = db.Update(account, func() error { switch account.ShareMode { case api.CLOUD_ACCOUNT_SHARE_MODE_ACCOUNT_DOMAIN: - account.PublicScope = string(rbacutils.ScopeNone) + account.PublicScope = string(rbacscope.ScopeNone) account.IsPublic = false case api.CLOUD_ACCOUNT_SHARE_MODE_PROVIDER_DOMAIN: - account.PublicScope = string(rbacutils.ScopeSystem) + account.PublicScope = string(rbacscope.ScopeSystem) account.IsPublic = true case api.CLOUD_ACCOUNT_SHARE_MODE_SYSTEM: - account.PublicScope = string(rbacutils.ScopeSystem) + account.PublicScope = string(rbacscope.ScopeSystem) account.IsPublic = true } return nil @@ -2181,9 +2181,9 @@ func (account *SCloudaccount) PerformPublic(ctx context.Context, userCred mcclie switch input.ShareMode { case api.CLOUD_ACCOUNT_SHARE_MODE_PROVIDER_DOMAIN: if len(input.SharedDomainIds) == 0 { - input.Scope = string(rbacutils.ScopeSystem) + input.Scope = string(rbacscope.ScopeSystem) } else { - input.Scope = string(rbacutils.ScopeDomain) + input.Scope = string(rbacscope.ScopeDomain) providers := account.GetCloudproviders() for i := range providers { if !utils.IsInStringArray(providers[i].DomainId, input.SharedDomainIds) && providers[i].DomainId != account.DomainId { @@ -2194,9 +2194,9 @@ func (account *SCloudaccount) PerformPublic(ctx context.Context, userCred mcclie } case api.CLOUD_ACCOUNT_SHARE_MODE_SYSTEM: if len(input.SharedDomainIds) == 0 { - input.Scope = string(rbacutils.ScopeSystem) + input.Scope = string(rbacscope.ScopeSystem) } else { - input.Scope = string(rbacutils.ScopeDomain) + input.Scope = string(rbacscope.ScopeDomain) } default: return nil, errors.Wrap(httperrors.ErrInputParameter, "share_mode cannot be account_domain") @@ -2277,7 +2277,7 @@ func (account *SCloudaccount) PerformShareMode(ctx context.Context, userCred mcc input2 := api.CloudaccountPerformPublicInput{ ShareMode: input.ShareMode, PerformPublicDomainInput: apis.PerformPublicDomainInput{ - Scope: string(rbacutils.ScopeSystem), + Scope: string(rbacscope.ScopeSystem), }, } return account.PerformPublic(ctx, userCred, query, input2) @@ -2324,23 +2324,23 @@ func (manager *SCloudaccountManager) filterByDomainId(q *sqlchemy.SQuery, domain // sqlchemy.Equals(q.Field("share_mode"), api.CLOUD_ACCOUNT_SHARE_MODE_SYSTEM), sqlchemy.In(q.Field("id"), subq.SubQuery()), sqlchemy.IsTrue(q.Field("is_public")), - sqlchemy.Equals(q.Field("public_scope"), rbacutils.ScopeDomain), + sqlchemy.Equals(q.Field("public_scope"), rbacscope.ScopeDomain), ), // share_mode=system/public_scope=system sqlchemy.AND( // sqlchemy.Equals(q.Field("share_mode"), api.CLOUD_ACCOUNT_SHARE_MODE_SYSTEM), sqlchemy.IsTrue(q.Field("is_public")), - sqlchemy.Equals(q.Field("public_scope"), rbacutils.ScopeSystem), + sqlchemy.Equals(q.Field("public_scope"), rbacscope.ScopeSystem), ), )) return q } -func (manager *SCloudaccountManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SCloudaccountManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { switch scope { - case rbacutils.ScopeProject, rbacutils.ScopeDomain: + case rbacscope.ScopeProject, rbacscope.ScopeDomain: if len(owner.GetProjectDomainId()) > 0 { q = manager.filterByDomainId(q, owner.GetProjectDomainId()) /*cloudproviders := CloudproviderManager.Query().SubQuery() @@ -2553,15 +2553,15 @@ func (account *SCloudaccount) getAccountShareInfo() apis.SAccountShareInfo { return apis.SAccountShareInfo{ ShareMode: account.ShareMode, IsPublic: account.IsPublic, - PublicScope: rbacutils.String2Scope(account.PublicScope), + PublicScope: rbacscope.String2Scope(account.PublicScope), SharedDomains: account.GetSharedDomains(), } } -func (manager *SCloudaccountManager) totalCount(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider) int { +func (manager *SCloudaccountManager) totalCount(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider) int { q := manager.Query() switch scope { - case rbacutils.ScopeProject, rbacutils.ScopeDomain: + case rbacscope.ScopeProject, rbacscope.ScopeDomain: q = q.Equals("domain_id", ownerId.GetProjectDomainId()) } cnt, _ := q.CountWithError() diff --git a/pkg/compute/models/cloudaccounts_prepare.go b/pkg/compute/models/cloudaccounts_prepare.go index 20adb0b618..fee5f7d90c 100644 --- a/pkg/compute/models/cloudaccounts_prepare.go +++ b/pkg/compute/models/cloudaccounts_prepare.go @@ -23,7 +23,9 @@ import ( "yunion.io/x/cloudmux/pkg/multicloud/esxi" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" proxyapi "yunion.io/x/onecloud/pkg/apis/cloudcommon/proxy" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -33,8 +35,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type sNetworkInfo struct { @@ -219,7 +219,7 @@ func (cam *SCloudaccountManager) prepareNets(ctx context.Context, userCred mccli // fetch networks networks := make([][]SNetwork, len(wires)) for i := range networks { - nets, err := wires[i].getNetworks(userCred, rbacutils.ScopeSystem) + nets, err := wires[i].getNetworks(userCred, rbacscope.ScopeSystem) if err != nil { return output, errors.Wrap(err, "wire.getNetwork") } @@ -586,9 +586,9 @@ func (manager *SCloudaccountManager) fetchWires(userCred mcclient.TokenCredentia if len(domainId) > 0 { ownerId := &db.SOwnerId{} ownerId.DomainId = domainId - q = WireManager.FilterByOwner(q, ownerId, rbacutils.ScopeDomain) + q = WireManager.FilterByOwner(q, ownerId, rbacscope.ScopeDomain) } else { - q = WireManager.FilterByOwner(q, userCred, rbacutils.ScopeDomain) + q = WireManager.FilterByOwner(q, userCred, rbacscope.ScopeDomain) } wires := make([]SWire, 0, 1) err := db.FetchModelObjects(WireManager, q, &wires) diff --git a/pkg/compute/models/cloudproviders.go b/pkg/compute/models/cloudproviders.go index 63572eee47..734dabba63 100644 --- a/pkg/compute/models/cloudproviders.go +++ b/pkg/compute/models/cloudproviders.go @@ -28,6 +28,7 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -45,7 +46,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modules/identity" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -490,8 +490,8 @@ func (self *SCloudaccount) getOrCreateTenant(ctx context.Context, name, domainId return createTenant(ctx, name, domainId, desc) } share := self.GetSharedInfo() - if tenant.DomainId == self.DomainId || (share.PublicScope == rbacutils.ScopeSystem || - (share.PublicScope == rbacutils.ScopeDomain && utils.IsInStringArray(tenant.DomainId, share.SharedDomains))) { + if tenant.DomainId == self.DomainId || (share.PublicScope == rbacscope.ScopeSystem || + (share.PublicScope == rbacscope.ScopeDomain && utils.IsInStringArray(tenant.DomainId, share.SharedDomains))) { return tenant.DomainId, tenant.Id, nil } return createTenant(ctx, name, domainId, desc) @@ -749,7 +749,7 @@ func (self *SCloudprovider) PerformChangeProject(ctx context.Context, userCred m return nil, httperrors.NewInvalidStatusError("cannot change to a different domain from a private cloud account") } // if account's public_scope=domain and share_mode=provider_domain, only allow to share to specific domains - if account.PublicScope == string(rbacutils.ScopeDomain) { + if account.PublicScope == string(rbacscope.ScopeDomain) { sharedDomains := account.GetSharedDomains() if !utils.IsInStringArray(tenant.DomainId, sharedDomains) && account.DomainId != tenant.DomainId { return nil, errors.Wrap(httperrors.ErrForbidden, "cannot set to domain outside of the shared domains") @@ -1628,17 +1628,17 @@ func (manager *SCloudproviderManager) filterByDomainId(q *sqlchemy.SQuery, domai sqlchemy.Equals(cloudaccounts.Field("share_mode"), api.CLOUD_ACCOUNT_SHARE_MODE_SYSTEM), sqlchemy.OR( sqlchemy.AND( - sqlchemy.Equals(cloudaccounts.Field("public_scope"), rbacutils.ScopeNone), + sqlchemy.Equals(cloudaccounts.Field("public_scope"), rbacscope.ScopeNone), sqlchemy.Equals(cloudaccounts.Field("domain_id"), domainId), ), sqlchemy.AND( - sqlchemy.Equals(cloudaccounts.Field("public_scope"), rbacutils.ScopeDomain), + sqlchemy.Equals(cloudaccounts.Field("public_scope"), rbacscope.ScopeDomain), sqlchemy.OR( sqlchemy.Equals(cloudaccounts.Field("domain_id"), domainId), sqlchemy.In(cloudaccounts.Field("id"), subq.SubQuery()), ), ), - sqlchemy.Equals(cloudaccounts.Field("public_scope"), rbacutils.ScopeSystem), + sqlchemy.Equals(cloudaccounts.Field("public_scope"), rbacscope.ScopeSystem), ), ), sqlchemy.AND( @@ -1649,10 +1649,10 @@ func (manager *SCloudproviderManager) filterByDomainId(q *sqlchemy.SQuery, domai return q } -func (manager *SCloudproviderManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SCloudproviderManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { switch scope { - case rbacutils.ScopeProject, rbacutils.ScopeDomain: + case rbacscope.ScopeProject, rbacscope.ScopeDomain: if len(owner.GetProjectDomainId()) > 0 { q = manager.filterByDomainId(q, owner.GetProjectDomainId()) } @@ -1715,8 +1715,8 @@ func (provider *SCloudprovider) GetDetailsClirc(ctx context.Context, userCred mc return jsonutils.Marshal(rc), nil } -func (manager *SCloudproviderManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SCloudproviderManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (provider *SCloudprovider) GetDetailsStorageClasses( @@ -1797,7 +1797,7 @@ func (provider *SCloudprovider) GetChangeOwnerCandidateDomainIds() []string { return []string{account.DomainId} } // if account's public_scope=domain and share_mode=provider_domain, only allow to share to specific domains - if account.PublicScope == string(rbacutils.ScopeDomain) { + if account.PublicScope == string(rbacscope.ScopeDomain) { sharedDomains := account.GetSharedDomains() return append(sharedDomains, account.DomainId) } diff --git a/pkg/compute/models/cloudregions.go b/pkg/compute/models/cloudregions.go index bafbe4665f..1ebc33f808 100644 --- a/pkg/compute/models/cloudregions.go +++ b/pkg/compute/models/cloudregions.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -927,7 +927,7 @@ func (self *SCloudregion) GetDetailsDiskCapability(ctx context.Context, userCred } func (self *SCloudregion) GetNetworkCount() (int, error) { - return getNetworkCount(nil, rbacutils.ScopeSystem, self, nil) + return getNetworkCount(nil, rbacscope.ScopeSystem, self, nil) } func (self *SCloudregion) getMinNicCount() int { diff --git a/pkg/compute/models/dbinstance_accounts.go b/pkg/compute/models/dbinstance_accounts.go index ee9c719c78..87aa30b2a0 100644 --- a/pkg/compute/models/dbinstance_accounts.go +++ b/pkg/compute/models/dbinstance_accounts.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -33,7 +34,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/seclib2" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -74,8 +74,8 @@ func (manager *SDBInstanceAccountManager) GetContextManagers() [][]db.IModelMana } } -func (manager *SDBInstanceAccountManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SDBInstanceAccountManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (self *SDBInstanceAccount) GetOwnerId() mcclient.IIdentityProvider { @@ -99,14 +99,14 @@ func (manager *SDBInstanceAccountManager) FetchOwnerId(ctx context.Context, data return db.FetchProjectInfo(ctx, data) } -func (manager *SDBInstanceAccountManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SDBInstanceAccountManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred != nil { sq := DBInstanceManager.Query("id") switch scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: sq = sq.Equals("tenant_id", userCred.GetProjectId()) return q.In("dbinstance_id", sq.SubQuery()) - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: sq = sq.Equals("domain_id", userCred.GetProjectDomainId()) return q.In("dbinstance_id", sq.SubQuery()) } diff --git a/pkg/compute/models/dbinstance_databases.go b/pkg/compute/models/dbinstance_databases.go index 4bbf1ae34c..6a715d5dc0 100644 --- a/pkg/compute/models/dbinstance_databases.go +++ b/pkg/compute/models/dbinstance_databases.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -31,7 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -76,8 +76,8 @@ func (manager *SDBInstanceDatabaseManager) GetContextManagers() [][]db.IModelMan } } -func (manager *SDBInstanceDatabaseManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SDBInstanceDatabaseManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (self *SDBInstanceDatabase) GetOwnerId() mcclient.IIdentityProvider { @@ -101,14 +101,14 @@ func (manager *SDBInstanceDatabaseManager) FetchOwnerId(ctx context.Context, dat return db.FetchProjectInfo(ctx, data) } -func (manager *SDBInstanceDatabaseManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SDBInstanceDatabaseManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred != nil { sq := DBInstanceManager.Query("id") switch scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: sq = sq.Equals("tenant_id", userCred.GetProjectId()) return q.In("dbinstance_id", sq.SubQuery()) - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: sq = sq.Equals("domain_id", userCred.GetProjectDomainId()) return q.In("dbinstance_id", sq.SubQuery()) } diff --git a/pkg/compute/models/dbinstances.go b/pkg/compute/models/dbinstances.go index 23510aeff6..35224801c4 100644 --- a/pkg/compute/models/dbinstances.go +++ b/pkg/compute/models/dbinstances.go @@ -27,8 +27,10 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/compare" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -45,7 +47,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/logclient" "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/seclib2" @@ -467,7 +468,7 @@ func (man *SDBInstanceManager) ValidateCreateData(ctx context.Context, userCred return input, err } - quotaKeys := fetchRegionalQuotaKeys(rbacutils.ScopeProject, ownerId, region, cloudprovider) + quotaKeys := fetchRegionalQuotaKeys(rbacscope.ScopeProject, ownerId, region, cloudprovider) pendingUsage := SRegionQuota{Rds: 1} pendingUsage.SetKeys(quotaKeys) if err := quotas.CheckSetPendingQuota(ctx, userCred, &pendingUsage); err != nil { @@ -1823,7 +1824,7 @@ type SRdsCountStat struct { } func (man *SDBInstanceManager) TotalCount( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, @@ -1856,7 +1857,7 @@ func (man *SDBInstanceManager) TotalCount( func (self *SDBInstance) GetQuotaKeys() quotas.IQuotaKeys { region, _ := self.GetRegion() return fetchRegionalQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, self.GetOwnerId(), region, self.GetCloudprovider(), diff --git a/pkg/compute/models/disks.go b/pkg/compute/models/disks.go index c862cfe8ee..27ed10a11d 100644 --- a/pkg/compute/models/disks.go +++ b/pkg/compute/models/disks.go @@ -28,7 +28,11 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/pinyinutils" + "yunion.io/x/pkg/util/rand" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/sets" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -48,10 +52,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modules/image" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/pinyinutils" - "yunion.io/x/onecloud/pkg/util/rand" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -463,7 +463,7 @@ func diskCreateInput2ComputeQuotaKeys(input api.DiskCreateInput, ownerId mcclien // input.Hypervisor must be set brand := guessBrandForHypervisor(input.Hypervisor) keys := GetDriver(input.Hypervisor).GetComputeQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, ownerId, brand, ) @@ -536,7 +536,7 @@ func (manager *SDiskManager) ValidateCreateData(ctx context.Context, userCred mc zone, _ := storage.getZone() quotaKey = fetchComputeQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, ownerId, zone, provider, @@ -696,7 +696,7 @@ func getDiskResourceRequirements(ctx context.Context, userCred mcclient.TokenCre storage := storageObj.(*SStorage) zone, _ := storage.getZone() quotaKey = fetchComputeQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, ownerId, zone, storage.GetCloudprovider(), @@ -1012,7 +1012,7 @@ func (disk *SDisk) GetQuotaKeys() (quotas.IQuotaKeys, error) { return nil, errors.Wrap(httperrors.ErrInvalidStatus, "no valid zone") } return fetchComputeQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, disk.GetOwnerId(), zone, provider, @@ -1814,7 +1814,7 @@ func (manager *SDiskManager) newFromCloudDisk(ctx context.Context, userCred mccl } func totalDiskSize( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, active tristate.TriState, ready tristate.TriState, @@ -1848,11 +1848,11 @@ func totalDiskSize( } switch scope { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: // do nothing - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: q = q.Filter(sqlchemy.Equals(disks.Field("domain_id"), ownerId.GetProjectDomainId())) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Filter(sqlchemy.Equals(disks.Field("tenant_id"), ownerId.GetProjectId())) } diff --git a/pkg/compute/models/dns_recordsets.go b/pkg/compute/models/dns_recordsets.go index 2ba952317c..2630be35c6 100644 --- a/pkg/compute/models/dns_recordsets.go +++ b/pkg/compute/models/dns_recordsets.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -425,14 +425,14 @@ func (manager *SDnsRecordSetManager) FetchOwnerId(ctx context.Context, data json return db.FetchDomainInfo(ctx, data) } -func (manager *SDnsRecordSetManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SDnsRecordSetManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { sq := DnsZoneManager.Query("id") sq = db.SharableManagerFilterByOwner(DnsZoneManager, sq, userCred, scope) return q.In("dns_zone_id", sq.SubQuery()) } -func (manager *SDnsRecordSetManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SDnsRecordSetManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SDnsRecordSet) IsSharable(reqUsrId mcclient.IIdentityProvider) bool { diff --git a/pkg/compute/models/dns_zonecaches.go b/pkg/compute/models/dns_zonecaches.go index 5795b641f2..3c8ae697c8 100644 --- a/pkg/compute/models/dns_zonecaches.go +++ b/pkg/compute/models/dns_zonecaches.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/notifyclient" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -74,8 +74,8 @@ func (manager *SDnsZoneCacheManager) ValidateCreateData(ctx context.Context, use return input, httperrors.NewNotSupportedError("Not support") } -func (manager *SDnsZoneCacheManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SDnsZoneCacheManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (manager *SDnsZoneCacheManager) FetchOwnerId(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) { @@ -98,7 +98,7 @@ func (self *SDnsZoneCache) GetOwnerId() mcclient.IIdentityProvider { return dnsZone.GetOwnerId() } -func (manager *SDnsZoneCacheManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SDnsZoneCacheManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { sq := DnsZoneManager.Query("id") sq = db.SharableManagerFilterByOwner(DnsZoneManager, sq, userCred, scope) return q.In("dns_zone_id", sq.SubQuery()) diff --git a/pkg/compute/models/dns_zones.go b/pkg/compute/models/dns_zones.go index c66766c547..9d71f884fb 100644 --- a/pkg/compute/models/dns_zones.go +++ b/pkg/compute/models/dns_zones.go @@ -27,6 +27,7 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/regutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -40,7 +41,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -923,10 +923,10 @@ func (self *SDnsZone) PerformPurge(ctx context.Context, userCred mcclient.TokenC return nil, self.StartDnsZoneDeleteTask(ctx, userCred, true, "") } -func (manager *SDnsZoneManager) totalCount(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider) int { +func (manager *SDnsZoneManager) totalCount(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider) int { q := manager.Query() switch scope { - case rbacutils.ScopeProject, rbacutils.ScopeDomain: + case rbacscope.ScopeProject, rbacscope.ScopeDomain: q = q.Equals("domain_id", ownerId.GetProjectDomainId()) } cnt, _ := q.CountWithError() diff --git a/pkg/compute/models/domainquota.go b/pkg/compute/models/domainquota.go index 8c7cf8cfd3..ada62140fe 100644 --- a/pkg/compute/models/domainquota.go +++ b/pkg/compute/models/domainquota.go @@ -18,11 +18,11 @@ import ( "context" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" commonOptions "yunion.io/x/onecloud/pkg/cloudcommon/options" "yunion.io/x/onecloud/pkg/compute/options" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) var ( @@ -37,7 +37,7 @@ func init() { DomainUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(DomainQuota, - rbacutils.ScopeDomain, + rbacscope.ScopeDomain, "domain_quota_usage_tbl", "domain_quota_usage", "domain_quota_usages", @@ -45,7 +45,7 @@ func init() { } DomainPendingUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(DomainQuota, - rbacutils.ScopeDomain, + rbacscope.ScopeDomain, "domain_quota_pending_usage_tbl", "domain_quota_pending_usage", "domain_quota_pending_usages", @@ -53,7 +53,7 @@ func init() { } DomainQuotaManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaBaseManager(DomainQuota, - rbacutils.ScopeDomain, + rbacscope.ScopeDomain, "domain_quota_tbl", DomainPendingUsageManager, DomainUsageManager, diff --git a/pkg/compute/models/elastic_search.go b/pkg/compute/models/elastic_search.go index 8e40d22bbe..66f969a649 100644 --- a/pkg/compute/models/elastic_search.go +++ b/pkg/compute/models/elastic_search.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" billing_api "yunion.io/x/onecloud/pkg/apis/billing" @@ -320,7 +321,7 @@ type SEsCountStat struct { } func (man *SElasticSearchManager) TotalCount( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, diff --git a/pkg/compute/models/elasticcache_accounts.go b/pkg/compute/models/elasticcache_accounts.go index b2c411328b..e35ce2b03c 100644 --- a/pkg/compute/models/elasticcache_accounts.go +++ b/pkg/compute/models/elasticcache_accounts.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/choices" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/seclib2" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -197,15 +197,15 @@ func (manager *SElasticcacheAccountManager) FetchUniqValues(ctx context.Context, return jsonutils.Marshal(map[string]string{"elasticcache_id": cacheId}) } -func (manager *SElasticcacheAccountManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SElasticcacheAccountManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (manager *SElasticcacheAccountManager) FetchOwnerId(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) { return elasticcacheSubResourceFetchOwnerId(ctx, data) } -func (manager *SElasticcacheAccountManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SElasticcacheAccountManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { return elasticcacheSubResourceFetchOwner(q, userCred, scope) } diff --git a/pkg/compute/models/elasticcache_acls.go b/pkg/compute/models/elasticcache_acls.go index e5f03272e3..cbbe14a3fd 100644 --- a/pkg/compute/models/elasticcache_acls.go +++ b/pkg/compute/models/elasticcache_acls.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -34,7 +35,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/validators" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -176,15 +176,15 @@ func (manager *SElasticcacheAclManager) FetchUniqValues(ctx context.Context, dat return jsonutils.Marshal(map[string]string{"elasticcache_id": elasticcacheId}) } -func (manager *SElasticcacheAclManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SElasticcacheAclManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (manager *SElasticcacheAclManager) FetchOwnerId(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) { return elasticcacheSubResourceFetchOwnerId(ctx, data) } -func (manager *SElasticcacheAclManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SElasticcacheAclManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { return elasticcacheSubResourceFetchOwner(q, userCred, scope) } diff --git a/pkg/compute/models/elasticcache_backups.go b/pkg/compute/models/elasticcache_backups.go index 067cc29205..cbf336fe73 100644 --- a/pkg/compute/models/elasticcache_backups.go +++ b/pkg/compute/models/elasticcache_backups.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -33,7 +34,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -204,15 +204,15 @@ func (manager *SElasticcacheBackupManager) FetchUniqValues(ctx context.Context, return jsonutils.Marshal(map[string]string{"elasticcache_id": cacheId}) } -func (manager *SElasticcacheBackupManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SElasticcacheBackupManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (manager *SElasticcacheBackupManager) FetchOwnerId(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) { return elasticcacheSubResourceFetchOwnerId(ctx, data) } -func (manager *SElasticcacheBackupManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SElasticcacheBackupManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { return elasticcacheSubResourceFetchOwner(q, userCred, scope) } diff --git a/pkg/compute/models/elasticcache_instances.go b/pkg/compute/models/elasticcache_instances.go index b3b2a16b84..11565ec5ca 100644 --- a/pkg/compute/models/elasticcache_instances.go +++ b/pkg/compute/models/elasticcache_instances.go @@ -27,8 +27,11 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/billing" + bc "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/compare" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -45,8 +48,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - bc "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/choices" "yunion.io/x/onecloud/pkg/util/logclient" "yunion.io/x/onecloud/pkg/util/rbacutils" @@ -174,15 +175,15 @@ func elasticcacheSubResourceFetchOwnerId(ctx context.Context, data jsonutils.JSO } // elastic cache 子资源获取owner query -func elasticcacheSubResourceFetchOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func elasticcacheSubResourceFetchOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred != nil { var subq *sqlchemy.SSubQuery q1 := ElasticcacheManager.Query() switch scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: subq = q1.Equals("tenant_id", userCred.GetProjectId()).SubQuery() - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: subq = q1.Equals("domain_id", userCred.GetProjectDomainId()).SubQuery() } @@ -894,7 +895,7 @@ func (manager *SElasticcacheManager) validateCreateData(ctx context.Context, use } cachePendingUsage := &SRegionQuota{Cache: 1} - quotaKeys := fetchRegionalQuotaKeys(rbacutils.ScopeProject, ownerId, region, provider) + quotaKeys := fetchRegionalQuotaKeys(rbacscope.ScopeProject, ownerId, region, provider) cachePendingUsage.SetKeys(quotaKeys) if err = quotas.CheckSetPendingQuota(ctx, userCred, cachePendingUsage); err != nil { return nil, errors.Wrap(err, "quotas.CheckSetPendingQuota") @@ -1450,7 +1451,7 @@ func (self *SElasticcache) DeleteSubResources(ctx context.Context, userCred mccl } func (man *SElasticcacheManager) TotalCount( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, @@ -1469,7 +1470,7 @@ func (man *SElasticcacheManager) TotalCount( func (cache *SElasticcache) GetQuotaKeys() quotas.IQuotaKeys { region, _ := cache.GetRegion() return fetchRegionalQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, cache.GetOwnerId(), region, cache.GetCloudprovider(), diff --git a/pkg/compute/models/elasticcache_parameters.go b/pkg/compute/models/elasticcache_parameters.go index 37c89b8102..5e625b037a 100644 --- a/pkg/compute/models/elasticcache_parameters.go +++ b/pkg/compute/models/elasticcache_parameters.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -30,7 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -183,15 +183,15 @@ func (manager *SElasticcacheParameterManager) newFromCloudElasticcacheParameter( return ¶meter, nil } -func (manager *SElasticcacheParameterManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SElasticcacheParameterManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (manager *SElasticcacheParameterManager) FetchOwnerId(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) { return elasticcacheSubResourceFetchOwnerId(ctx, data) } -func (manager *SElasticcacheParameterManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SElasticcacheParameterManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { return elasticcacheSubResourceFetchOwner(q, userCred, scope) } diff --git a/pkg/compute/models/elasticips.go b/pkg/compute/models/elasticips.go index 71ccff07ea..f882c355c2 100644 --- a/pkg/compute/models/elasticips.go +++ b/pkg/compute/models/elasticips.go @@ -26,6 +26,8 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/pinyinutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -41,7 +43,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/validators" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/pinyinutils" "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -996,7 +997,7 @@ func (manager *SElasticipManager) ValidateCreateData(ctx context.Context, userCr //避免参数重名后还有pending.eip残留 eipPendingUsage := &SRegionQuota{Eip: 1} - quotaKeys := fetchRegionalQuotaKeys(rbacutils.ScopeProject, ownerId, region, provider) + quotaKeys := fetchRegionalQuotaKeys(rbacscope.ScopeProject, ownerId, region, provider) eipPendingUsage.SetKeys(quotaKeys) if err = quotas.CheckSetPendingQuota(ctx, userCred, eipPendingUsage); err != nil { return input, err @@ -1011,7 +1012,7 @@ func (eip *SElasticip) GetQuotaKeys() (quotas.IQuotaKeys, error) { return nil, errors.Wrapf(err, "eip.GetRegion") } return fetchRegionalQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, eip.GetOwnerId(), region, eip.GetCloudprovider(), @@ -1663,7 +1664,7 @@ func (manager *SElasticipManager) NewEipForVMOnHost(ctx context.Context, userCre eipPendingUsage := &SRegionQuota{Eip: 1} keys := fetchRegionalQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, ownerId, region, provider, @@ -1772,22 +1773,22 @@ func (manager *SElasticipManager) usageQByRanges(q *sqlchemy.SQuery, rangeObjs [ return RangeObjectsFilter(q, rangeObjs, q.Field("cloudregion_id"), nil, q.Field("manager_id"), nil, nil) } -func (manager *SElasticipManager) usageQ(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, q *sqlchemy.SQuery, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) *sqlchemy.SQuery { +func (manager *SElasticipManager) usageQ(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, q *sqlchemy.SQuery, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) *sqlchemy.SQuery { q = manager.usageQByRanges(q, rangeObjs) q = manager.usageQByCloudEnv(q, providers, brands, cloudEnv) switch scope { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: // do nothing - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: q = q.Equals("domain_id", ownerId.GetProjectDomainId()) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Equals("tenant_id", ownerId.GetProjectId()) } q = db.ObjectIdQueryWithPolicyResult(q, manager, policyResult) return q } -func (manager *SElasticipManager) TotalCount(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) EipUsage { +func (manager *SElasticipManager) TotalCount(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) EipUsage { usage := EipUsage{} q1sq := manager.Query().SubQuery() q1 := q1sq.Query( diff --git a/pkg/compute/models/external_projects.go b/pkg/compute/models/external_projects.go index d0c0fb3160..e68c6b0e17 100644 --- a/pkg/compute/models/external_projects.go +++ b/pkg/compute/models/external_projects.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -39,7 +40,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modules/identity" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -251,8 +251,8 @@ func (self *SExternalProject) SyncWithCloudProject(ctx context.Context, userCred self.ManagerId, _ = providerMaps[accountId] } share := account.GetSharedInfo() - if self.DomainId != account.DomainId && !(share.PublicScope == rbacutils.ScopeSystem || - (share.PublicScope == rbacutils.ScopeDomain && utils.IsInStringArray(self.DomainId, share.SharedDomains))) { + if self.DomainId != account.DomainId && !(share.PublicScope == rbacscope.ScopeSystem || + (share.PublicScope == rbacscope.ScopeDomain && utils.IsInStringArray(self.DomainId, share.SharedDomains))) { self.ProjectId = account.ProjectId self.DomainId = account.DomainId if account.AutoCreateProject { @@ -290,8 +290,8 @@ func (self *SExternalProject) SyncWithCloudProject(ctx context.Context, userCred return errors.Wrapf(err, "FetchTenantByName(%s)", self.Name) } if proj.DomainId == account.DomainId || - share.PublicScope == rbacutils.ScopeSystem || - (share.PublicScope == rbacutils.ScopeDomain && utils.IsInStringArray(proj.DomainId, share.SharedDomains)) { + share.PublicScope == rbacscope.ScopeSystem || + (share.PublicScope == rbacscope.ScopeDomain && utils.IsInStringArray(proj.DomainId, share.SharedDomains)) { self.ProjectId = proj.Id self.DomainId = proj.DomainId return nil @@ -343,13 +343,13 @@ func (self *SCloudaccount) getOrCreateDomain(ctx context.Context, userCred mccli } share := self.GetSharedInfo() - if share.PublicScope == rbacutils.ScopeSystem { + if share.PublicScope == rbacscope.ScopeSystem { return domainId, nil } input := api.CloudaccountPerformPublicInput{} - input.ShareMode = string(rbacutils.ScopeSystem) + input.ShareMode = string(rbacscope.ScopeSystem) input.PerformPublicDomainInput = apis.PerformPublicDomainInput{ - Scope: string(rbacutils.ScopeDomain), + Scope: string(rbacscope.ScopeDomain), SharedDomains: append(share.SharedDomains, domainId), SharedDomainIds: append(share.SharedDomains, domainId), } @@ -473,8 +473,8 @@ func (self *SExternalProject) PerformChangeProject(ctx context.Context, userCred } share := account.GetSharedInfo() - if self.DomainId != tenant.DomainId && !(tenant.DomainId == account.DomainId || share.PublicScope == rbacutils.ScopeSystem || - (share.PublicScope == rbacutils.ScopeDomain && utils.IsInStringArray(tenant.DomainId, share.SharedDomains))) { + if self.DomainId != tenant.DomainId && !(tenant.DomainId == account.DomainId || share.PublicScope == rbacscope.ScopeSystem || + (share.PublicScope == rbacscope.ScopeDomain && utils.IsInStringArray(tenant.DomainId, share.SharedDomains))) { return nil, httperrors.NewForbiddenError("account %s not share for domain %s", account.Name, tenant.DomainId) } diff --git a/pkg/compute/models/filesystem.go b/pkg/compute/models/filesystem.go index 5a3fee5781..a29547b5d5 100644 --- a/pkg/compute/models/filesystem.go +++ b/pkg/compute/models/filesystem.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/compare" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -37,7 +38,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/stringutils2" ) diff --git a/pkg/compute/models/filters.go b/pkg/compute/models/filters.go index b8946ec834..d94bbbe1b7 100644 --- a/pkg/compute/models/filters.go +++ b/pkg/compute/models/filters.go @@ -15,11 +15,11 @@ package models import ( + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) func RangeObjectsFilter(q *sqlchemy.SQuery, rangeObjs []db.IStandaloneModel, regionField sqlchemy.IQueryField, zoneField sqlchemy.IQueryField, managerField sqlchemy.IQueryField, hostField sqlchemy.IQueryField, storageField sqlchemy.IQueryField) *sqlchemy.SQuery { @@ -160,13 +160,13 @@ func rangeObjFilter(q *sqlchemy.SQuery, rangeObj db.IStandaloneModel, regionFiel return q } -func scopeOwnerIdFilter(q *sqlchemy.SQuery, scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider) *sqlchemy.SQuery { +func scopeOwnerIdFilter(q *sqlchemy.SQuery, scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider) *sqlchemy.SQuery { switch scope { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: // do nothing - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: q = q.Equals("domain_id", ownerId.GetProjectDomainId()) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Equals("tenant_id", ownerId.GetProjectId()) } return q diff --git a/pkg/compute/models/globalvpcs.go b/pkg/compute/models/globalvpcs.go index 8f82053f08..0668655944 100644 --- a/pkg/compute/models/globalvpcs.go +++ b/pkg/compute/models/globalvpcs.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/validators" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -242,10 +242,10 @@ func (self *SGlobalVpc) ValidateUpdateCondition(ctx context.Context) error { return self.SEnabledStatusInfrasResourceBase.ValidateUpdateCondition(ctx) } -func (manager *SGlobalVpcManager) totalCount(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider) int { +func (manager *SGlobalVpcManager) totalCount(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider) int { q := manager.Query() switch scope { - case rbacutils.ScopeProject, rbacutils.ScopeDomain: + case rbacscope.ScopeProject, rbacscope.ScopeDomain: q = q.Equals("domain_id", ownerId.GetProjectDomainId()) } cnt, _ := q.CountWithError() diff --git a/pkg/compute/models/groups.go b/pkg/compute/models/groups.go index e24dbbd837..da2db94d10 100644 --- a/pkg/compute/models/groups.go +++ b/pkg/compute/models/groups.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/sets" "yunion.io/x/sqlchemy" @@ -36,7 +37,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -504,7 +504,7 @@ func (net *SNetwork) GetRegionalQuotaKeys(ownerId mcclient.IIdentityProvider) (q if region == nil { return nil, errors.Wrap(httperrors.ErrInvalidStatus, "no valid region") } - return fetchRegionalQuotaKeys(rbacutils.ScopeProject, ownerId, region, provider), nil + return fetchRegionalQuotaKeys(rbacscope.ScopeProject, ownerId, region, provider), nil } func (grp *SGroup) PerformDetachnetwork(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input *api.GroupDetachNetworkInput) (*api.SGroup, error) { diff --git a/pkg/compute/models/guest_actions.go b/pkg/compute/models/guest_actions.go index 86cff00853..453c564855 100644 --- a/pkg/compute/models/guest_actions.go +++ b/pkg/compute/models/guest_actions.go @@ -30,8 +30,11 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/fileutils" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/osprofile" + "yunion.io/x/pkg/util/rand" "yunion.io/x/pkg/util/regutils" "yunion.io/x/pkg/util/sets" "yunion.io/x/pkg/utils" @@ -61,11 +64,8 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/modules/image" "yunion.io/x/onecloud/pkg/mcclient/modules/notify" "yunion.io/x/onecloud/pkg/mcclient/modules/scheduler" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/bitmap" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rand" "yunion.io/x/onecloud/pkg/util/seclib2" ) diff --git a/pkg/compute/models/guest_sshable.go b/pkg/compute/models/guest_sshable.go index 5949a366e7..3b00a53950 100644 --- a/pkg/compute/models/guest_sshable.go +++ b/pkg/compute/models/guest_sshable.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/sqlchemy" cloudproxy_api "yunion.io/x/onecloud/pkg/apis/cloudproxy" @@ -37,7 +38,6 @@ import ( ansible_modules "yunion.io/x/onecloud/pkg/mcclient/modules/ansible" cloudproxy_module "yunion.io/x/onecloud/pkg/mcclient/modules/cloudproxy" "yunion.io/x/onecloud/pkg/util/ansible" - "yunion.io/x/onecloud/pkg/util/httputils" ssh_util "yunion.io/x/onecloud/pkg/util/ssh" ) diff --git a/pkg/compute/models/guest_template.go b/pkg/compute/models/guest_template.go index dea4e136b4..01989f95fd 100644 --- a/pkg/compute/models/guest_template.go +++ b/pkg/compute/models/guest_template.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/sets" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -37,7 +38,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modules/image" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -515,7 +515,7 @@ func (gt *SGuestTemplate) PerformPublic( } targetScopeStr := data.Scope - targetScope := rbacutils.String2ScopeDefault(targetScopeStr, rbacutils.ScopeSystem) + targetScope := rbacscope.String2ScopeDefault(targetScopeStr, rbacscope.ScopeSystem) // check if secgroup is public if len(input.SecgroupId) > 0 { @@ -525,7 +525,7 @@ func (gt *SGuestTemplate) PerformPublic( input.SecgroupId) } secgroup := model.(*SSecurityGroup) - sgScope := rbacutils.String2Scope(secgroup.PublicScope) + sgScope := rbacscope.String2Scope(secgroup.PublicScope) if !secgroup.IsPublic || !sgScope.HigherEqual(targetScope) { return nil, gt.genForbiddenError("security group", input.SecgroupId, string(targetScope)) } @@ -541,7 +541,7 @@ func (gt *SGuestTemplate) PerformPublic( "there is no such secgroup %s descripted by guest template", str) } network := model.(*SNetwork) - netScope := rbacutils.String2Scope(network.PublicScope) + netScope := rbacscope.String2Scope(network.PublicScope) if !network.IsPublic || !netScope.HigherEqual(targetScope) { return nil, gt.genForbiddenError("network", str, string(targetScope)) } @@ -571,7 +571,7 @@ func (gt *SGuestTemplate) PerformPublic( default: //no arrivals } - igScope := rbacutils.String2Scope(publicScope) + igScope := rbacscope.String2Scope(publicScope) if !isPublic || !igScope.HigherEqual(targetScope) { return nil, gt.genForbiddenError("image", "", string(targetScope)) } diff --git a/pkg/compute/models/guestdrivers.go b/pkg/compute/models/guestdrivers.go index b1019a7c73..99d31f97e7 100644 --- a/pkg/compute/models/guestdrivers.go +++ b/pkg/compute/models/guestdrivers.go @@ -21,14 +21,14 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" guestdriver_types "yunion.io/x/onecloud/pkg/compute/guestdrivers/types" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type IGuestScheduleDriver interface { @@ -44,7 +44,7 @@ type IGuestDriver interface { GetHypervisor() string GetProvider() string - GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) SComputeResourceKeys + GetComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) SComputeResourceKeys GetMaxVCpuCount() int GetMaxVMemSizeGB() int diff --git a/pkg/compute/models/guestnetworks.go b/pkg/compute/models/guestnetworks.go index 3f46079d40..d03bf8c266 100644 --- a/pkg/compute/models/guestnetworks.go +++ b/pkg/compute/models/guestnetworks.go @@ -25,6 +25,8 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/netutils" + randutil "yunion.io/x/pkg/util/rand" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/regutils" "yunion.io/x/sqlchemy" @@ -34,8 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - randutil "yunion.io/x/onecloud/pkg/util/rand" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -706,7 +706,7 @@ func (self *SGuestnetwork) Detach(ctx context.Context, userCred mcclient.TokenCr } func totalGuestNicCount( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, includeSystem bool, @@ -728,11 +728,11 @@ func totalGuestNicCount( q = RangeObjectsFilter(q, rangeObjs, nil, hosts.Field("zone_id"), hosts.Field("manager_id"), hosts.Field("id"), nil) switch scope { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: // do nothing - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: q = q.Filter(sqlchemy.Equals(guests.Field("domain_id"), ownerId.GetProjectDomainId())) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Filter(sqlchemy.Equals(guests.Field("tenant_id"), ownerId.GetProjectId())) } diff --git a/pkg/compute/models/guests.go b/pkg/compute/models/guests.go index 2c64d830c6..5077b7e39b 100644 --- a/pkg/compute/models/guests.go +++ b/pkg/compute/models/guests.go @@ -28,9 +28,12 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/compare" "yunion.io/x/pkg/util/netutils" "yunion.io/x/pkg/util/osprofile" + "yunion.io/x/pkg/util/pinyinutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/regutils" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/pkg/utils" @@ -57,11 +60,9 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modules/image" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/bitmap" "yunion.io/x/onecloud/pkg/util/logclient" "yunion.io/x/onecloud/pkg/util/netutils2" - "yunion.io/x/onecloud/pkg/util/pinyinutils" "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/seclib2" "yunion.io/x/onecloud/pkg/util/stringutils2" @@ -331,7 +332,7 @@ func (manager *SGuestManager) ListItemFilter( isAdmin := false // admin := (query.VirtualResourceListInput.Admin != nil && *query.VirtualResourceListInput.Admin) allowScope, _ := policy.PolicyManager.AllowScope(userCred, consts.GetServiceType(), manager.KeywordPlural(), policy.PolicyActionList) - if allowScope == rbacutils.ScopeSystem || allowScope == rbacutils.ScopeDomain { + if allowScope == rbacscope.ScopeSystem || allowScope == rbacscope.ScopeDomain { isAdmin = true } @@ -1176,7 +1177,7 @@ func serverCreateInput2ComputeQuotaKeys(input api.ServerCreateInput, ownerId mcc // input.Hypervisor must be set brand := guessBrandForHypervisor(input.Hypervisor) keys := GetDriver(input.Hypervisor).GetComputeQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, ownerId, brand, ) @@ -3069,7 +3070,7 @@ func (manager *SGuestManager) newCloudVM(ctx context.Context, userCred mcclient. } func (manager *SGuestManager) TotalCount( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, status []string, hypervisors []string, @@ -3711,7 +3712,7 @@ type SGuestCountStat struct { } func usageTotalGuestResouceCount( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, status []string, @@ -3746,7 +3747,7 @@ func usageTotalGuestResouceCount( } func _guestResourceCountQuery( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, status []string, @@ -3794,10 +3795,10 @@ func _guestResourceCountQuery( } switch scope { - case rbacutils.ScopeSystem: - case rbacutils.ScopeDomain: + case rbacscope.ScopeSystem: + case rbacscope.ScopeDomain: gq = gq.Filter(sqlchemy.Equals(gq.Field("domain_id"), ownerId.GetProjectDomainId())) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: gq = gq.Filter(sqlchemy.Equals(gq.Field("tenant_id"), ownerId.GetProjectId())) } @@ -6150,7 +6151,7 @@ func (guest *SGuest) GetRegionalQuotaKeys() (quotas.IQuotaKeys, error) { if region == nil { return nil, errors.Wrap(httperrors.ErrInvalidStatus, "no valid region") } - return fetchRegionalQuotaKeys(rbacutils.ScopeProject, guest.GetOwnerId(), region, provider), nil + return fetchRegionalQuotaKeys(rbacscope.ScopeProject, guest.GetOwnerId(), region, provider), nil } func (guest *SGuest) GetQuotaKeys() (quotas.IQuotaKeys, error) { @@ -6171,7 +6172,7 @@ func (guest *SGuest) GetQuotaKeys() (quotas.IQuotaKeys, error) { hypervisor = "" } return fetchComputeQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, guest.GetOwnerId(), zone, provider, diff --git a/pkg/compute/models/host_recycle.go b/pkg/compute/models/host_recycle.go index 0e689d8682..e5e4d7bd20 100644 --- a/pkg/compute/models/host_recycle.go +++ b/pkg/compute/models/host_recycle.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/billing" "yunion.io/x/sqlchemy" billing_api "yunion.io/x/onecloud/pkg/apis/billing" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/baremetal" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/logclient" ) diff --git a/pkg/compute/models/hostnameresource.go b/pkg/compute/models/hostnameresource.go index 22ae4132c7..95d2303cfb 100644 --- a/pkg/compute/models/hostnameresource.go +++ b/pkg/compute/models/hostnameresource.go @@ -19,10 +19,10 @@ import ( "strings" "yunion.io/x/pkg/util/osprofile" + "yunion.io/x/pkg/util/pinyinutils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/pinyinutils" ) type SHostnameResourceBase struct { diff --git a/pkg/compute/models/hosts.go b/pkg/compute/models/hosts.go index ca815c82cc..697912081e 100644 --- a/pkg/compute/models/hosts.go +++ b/pkg/compute/models/hosts.go @@ -36,7 +36,9 @@ import ( "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/compare" "yunion.io/x/pkg/util/fileutils" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/regutils" "yunion.io/x/pkg/util/sets" "yunion.io/x/pkg/utils" @@ -61,7 +63,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modules/scheduler" "yunion.io/x/onecloud/pkg/util/cgrouputils/cpuset" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/k8s/tokens" "yunion.io/x/onecloud/pkg/util/logclient" "yunion.io/x/onecloud/pkg/util/rbacutils" @@ -2150,7 +2151,7 @@ func (manager *SHostManager) NewFromCloudHost(ctx context.Context, userCred mccl host.Version = extHost.GetVersion() host.IsPublic = false - host.PublicScope = string(rbacutils.ScopeNone) + host.PublicScope = string(rbacscope.ScopeNone) var err = func() error { lockman.LockRawObject(ctx, manager.Keyword(), "name") @@ -2611,7 +2612,7 @@ func (self *SHost) SyncHostVMs(ctx context.Context, userCred mcclient.TokenCrede func (self *SHost) getNetworkOfIPOnHost(ipAddr string) (*SNetwork, error) { netInterfaces := self.GetNetInterfaces() for _, netInterface := range netInterfaces { - network, err := netInterface.GetCandidateNetworkForIp(nil, rbacutils.ScopeNone, ipAddr) + network, err := netInterface.GetCandidateNetworkForIp(nil, rbacscope.ScopeNone, ipAddr) if err == nil && network != nil { return network, nil } @@ -2733,7 +2734,7 @@ func (manager *SHostManager) FetchHostByHostname(hostname string) *SHost { func (manager *SHostManager) totalCountQ( userCred mcclient.IIdentityProvider, - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, rangeObjs []db.IStandaloneModel, hostStatus, status string, hostTypes []string, @@ -2752,7 +2753,7 @@ func (manager *SHostManager) totalCountQ( hosts.Field("cpu_cmtbound"), hosts.Field("storage_size"), ) - if scope != rbacutils.ScopeSystem && userCred != nil { + if scope != rbacscope.ScopeSystem && userCred != nil { q = q.Filter(sqlchemy.Equals(hosts.Field("domain_id"), userCred.GetProjectDomainId())) } if len(status) > 0 { @@ -2905,7 +2906,7 @@ func (manager *SHostManager) calculateCount(q *sqlchemy.SQuery) HostsCountStat { func (manager *SHostManager) TotalCount( userCred mcclient.IIdentityProvider, - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, rangeObjs []db.IStandaloneModel, hostStatus, status string, hostTypes []string, @@ -6092,7 +6093,7 @@ func GetHostQuotaKeysFromCreateInput(owner mcclient.IIdentityProvider, input api if len(input.ZoneId) > 0 { zone = ZoneManager.FetchZoneById(input.ZoneId) } - zoneKeys := fetchZonalQuotaKeys(rbacutils.ScopeDomain, ownerId, zone, nil) + zoneKeys := fetchZonalQuotaKeys(rbacscope.ScopeDomain, ownerId, zone, nil) keys := quotas.SDomainRegionalCloudResourceKeys{} keys.SBaseDomainQuotaKeys = zoneKeys.SBaseDomainQuotaKeys keys.SRegionalBaseKeys = zoneKeys.SRegionalBaseKeys @@ -6103,7 +6104,7 @@ func (model *SHost) GetQuotaKeys() quotas.SDomainRegionalCloudResourceKeys { zone, _ := model.GetZone() manager := model.GetCloudprovider() ownerId := model.GetOwnerId() - zoneKeys := fetchZonalQuotaKeys(rbacutils.ScopeDomain, ownerId, zone, manager) + zoneKeys := fetchZonalQuotaKeys(rbacscope.ScopeDomain, ownerId, zone, manager) keys := quotas.SDomainRegionalCloudResourceKeys{} keys.SBaseDomainQuotaKeys = zoneKeys.SBaseDomainQuotaKeys keys.SRegionalBaseKeys = zoneKeys.SRegionalBaseKeys @@ -6241,8 +6242,8 @@ func (host *SHost) IsAssignable(ctx context.Context, userCred mcclient.TokenCred return nil } else if db.IsDomainAllowPerform(ctx, userCred, host, "assign-host") && (userCred.GetProjectDomainId() == host.DomainId || - host.PublicScope == string(rbacutils.ScopeSystem) || - (host.PublicScope == string(rbacutils.ScopeDomain) && utils.IsInStringArray(userCred.GetProjectDomainId(), host.GetSharedDomains()))) { + host.PublicScope == string(rbacscope.ScopeSystem) || + (host.PublicScope == string(rbacscope.ScopeDomain) && utils.IsInStringArray(userCred.GetProjectDomainId(), host.GetSharedDomains()))) { return nil } else { return httperrors.NewNotSufficientPrivilegeError("Only system admin can assign host") diff --git a/pkg/compute/models/infrasquota.go b/pkg/compute/models/infrasquota.go index 873a4261f3..4d33b14bbf 100644 --- a/pkg/compute/models/infrasquota.go +++ b/pkg/compute/models/infrasquota.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" @@ -40,7 +41,7 @@ func init() { InfrasUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(InfrasQuota, - rbacutils.ScopeDomain, + rbacscope.ScopeDomain, "infras_quota_usage_tbl", "infras_quota_usage", "infras_quota_usages", @@ -48,7 +49,7 @@ func init() { } InfrasPendingUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(InfrasQuota, - rbacutils.ScopeDomain, + rbacscope.ScopeDomain, "infras_quota_pending_usage_tbl", "infras_quota_pending_usage", "infras_quota_pending_usages", @@ -56,7 +57,7 @@ func init() { } InfrasQuotaManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaBaseManager(InfrasQuota, - rbacutils.ScopeDomain, + rbacscope.ScopeDomain, "infras_quota_tbl", InfrasPendingUsageManager, InfrasUsageManager, diff --git a/pkg/compute/models/instance_snapshots.go b/pkg/compute/models/instance_snapshots.go index 225f9e47e8..bbd4765f3a 100644 --- a/pkg/compute/models/instance_snapshots.go +++ b/pkg/compute/models/instance_snapshots.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -508,7 +509,7 @@ func (self *SInstanceSnapshot) GetSnapshots() ([]SSnapshot, error) { func (self *SInstanceSnapshot) GetQuotaKeys() quotas.IQuotaKeys { region, _ := self.GetRegion() return fetchRegionalQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, self.GetOwnerId(), region, self.GetCloudprovider(), @@ -527,14 +528,14 @@ func (self *SInstanceSnapshot) GetUsages() []db.IUsage { } } -func TotalInstanceSnapshotCount(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) (int, error) { +func TotalInstanceSnapshotCount(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) (int, error) { q := InstanceSnapshotManager.Query() switch scope { - case rbacutils.ScopeSystem: - case rbacutils.ScopeDomain: + case rbacscope.ScopeSystem: + case rbacscope.ScopeDomain: q = q.Equals("domain_id", ownerId.GetProjectDomainId()) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Equals("tenant_id", ownerId.GetProjectId()) } diff --git a/pkg/compute/models/ipv6_gateways.go b/pkg/compute/models/ipv6_gateways.go index 8767619455..1a7d5f6bf8 100644 --- a/pkg/compute/models/ipv6_gateways.go +++ b/pkg/compute/models/ipv6_gateways.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -31,7 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -329,7 +329,7 @@ func (manager *SIPv6GatewayManager) ListItemExportKeys(ctx context.Context, return q, nil } -func (manager *SIPv6GatewayManager) AllowScope(userCred mcclient.TokenCredential) rbacutils.TRbacScope { +func (manager *SIPv6GatewayManager) AllowScope(userCred mcclient.TokenCredential) rbacscope.TRbacScope { scope, _ := policy.PolicyManager.AllowScope(userCred, api.SERVICE_TYPE, IPv6GatewayManager.KeywordPlural(), policy.PolicyActionGet) return scope } diff --git a/pkg/compute/models/isolated_devices.go b/pkg/compute/models/isolated_devices.go index bbd16c5324..fe2360904e 100644 --- a/pkg/compute/models/isolated_devices.go +++ b/pkg/compute/models/isolated_devices.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -578,14 +579,14 @@ func (manager *SIsolatedDeviceManager) ReleaseDevicesOfGuest(ctx context.Context } func (manager *SIsolatedDeviceManager) totalCountQ( - scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, devType []string, hostTypes []string, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, devType []string, hostTypes []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, rangeObjs []db.IStandaloneModel, policyResult rbacutils.SPolicyResult, ) *sqlchemy.SQuery { hq := HostManager.Query() - if scope == rbacutils.ScopeDomain { + if scope == rbacscope.ScopeDomain { hq = hq.Filter(sqlchemy.Equals(hq.Field("domain_id"), ownerId.GetProjectDomainId())) } hq = db.ObjectIdQueryWithPolicyResult(hq, HostManager, policyResult) @@ -605,7 +606,7 @@ type IsolatedDeviceCountStat struct { } func (manager *SIsolatedDeviceManager) totalCount( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, devType, hostTypes []string, @@ -631,7 +632,7 @@ func (manager *SIsolatedDeviceManager) totalCount( } func (manager *SIsolatedDeviceManager) TotalCount( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, hostType []string, resourceTypes []string, @@ -856,22 +857,22 @@ func (manager *SIsolatedDeviceManager) FilterByUniqValues(q *sqlchemy.SQuery, va return q } -func (manager *SIsolatedDeviceManager) NamespaceScope() rbacutils.TRbacScope { +func (manager *SIsolatedDeviceManager) NamespaceScope() rbacscope.TRbacScope { if consts.IsDomainizedNamespace() { - return rbacutils.ScopeDomain + return rbacscope.ScopeDomain } else { - return rbacutils.ScopeSystem + return rbacscope.ScopeSystem } } -func (manager *SIsolatedDeviceManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SIsolatedDeviceManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } -func (manager *SIsolatedDeviceManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SIsolatedDeviceManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { switch scope { - case rbacutils.ScopeProject, rbacutils.ScopeDomain: + case rbacscope.ScopeProject, rbacscope.ScopeDomain: hostsQ := HostManager.Query("id") hostsQ = HostManager.FilterByOwner(hostsQ, owner, scope) hosts := hostsQ.SubQuery() diff --git a/pkg/compute/models/kafka.go b/pkg/compute/models/kafka.go index 0724b0e6ea..a4618e96ae 100644 --- a/pkg/compute/models/kafka.go +++ b/pkg/compute/models/kafka.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" billing_api "yunion.io/x/onecloud/pkg/apis/billing" @@ -317,7 +318,7 @@ type SKafkaCountStat struct { } func (man *SKafkaManager) TotalCount( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, diff --git a/pkg/compute/models/keypairs.go b/pkg/compute/models/keypairs.go index 3c0c0d41d2..b1f9b90874 100644 --- a/pkg/compute/models/keypairs.go +++ b/pkg/compute/models/keypairs.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -30,7 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/seclib2" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -194,9 +194,9 @@ func totalKeypairCount(userId string) (int, error) { return q.CountWithError() } -func (manager *SKeypairManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SKeypairManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { - if scope == rbacutils.ScopeUser { + if scope == rbacscope.ScopeUser { if len(owner.GetUserId()) > 0 { q = q.Equals("owner_id", owner.GetUserId()) } diff --git a/pkg/compute/models/kube_clusters.go b/pkg/compute/models/kube_clusters.go index b3c34f75e2..2974e83386 100644 --- a/pkg/compute/models/kube_clusters.go +++ b/pkg/compute/models/kube_clusters.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -36,7 +37,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modules/k8s" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -515,7 +515,7 @@ func (cluster *SKubeCluster) GetQuotaKeys() quotas.SDomainRegionalCloudResourceK region, _ := cluster.GetRegion() manager := cluster.GetCloudprovider() ownerId := cluster.GetOwnerId() - regionKeys := fetchRegionalQuotaKeys(rbacutils.ScopeDomain, ownerId, region, manager) + regionKeys := fetchRegionalQuotaKeys(rbacscope.ScopeDomain, ownerId, region, manager) keys := quotas.SDomainRegionalCloudResourceKeys{} keys.SBaseDomainQuotaKeys = regionKeys.SBaseDomainQuotaKeys keys.SRegionalBaseKeys = regionKeys.SRegionalBaseKeys diff --git a/pkg/compute/models/kube_node_pools.go b/pkg/compute/models/kube_node_pools.go index 9e16563201..c0b6db8f29 100644 --- a/pkg/compute/models/kube_node_pools.go +++ b/pkg/compute/models/kube_node_pools.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -31,7 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -67,8 +67,8 @@ func (manager *SKubeNodePoolManager) GetContextManagers() [][]db.IModelManager { } } -func (manager *SKubeNodePoolManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SKubeNodePoolManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SKubeNodePool) GetCloudproviderId() string { @@ -109,11 +109,11 @@ func (manager *SKubeNodePoolManager) FetchOwnerId(ctx context.Context, data json return db.FetchProjectInfo(ctx, data) } -func (manager *SKubeNodePoolManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SKubeNodePoolManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred != nil { sq := KubeClusterManager.Query("id") switch scope { - case rbacutils.ScopeDomain, rbacutils.ScopeProject: + case rbacscope.ScopeDomain, rbacscope.ScopeProject: sq = sq.Equals("domain_id", userCred.GetProjectDomainId()) return q.In("cloud_kube_cluster_id", sq.SubQuery()) } diff --git a/pkg/compute/models/kube_nodes.go b/pkg/compute/models/kube_nodes.go index 8a974186c6..a3d5990e5c 100644 --- a/pkg/compute/models/kube_nodes.go +++ b/pkg/compute/models/kube_nodes.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -31,7 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -68,8 +68,8 @@ func (manager *SKubeNodeManager) GetContextManagers() [][]db.IModelManager { } } -func (manager *SKubeNodeManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SKubeNodeManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SKubeNode) GetCloudproviderId() string { @@ -110,11 +110,11 @@ func (manager *SKubeNodeManager) FetchOwnerId(ctx context.Context, data jsonutil return db.FetchProjectInfo(ctx, data) } -func (manager *SKubeNodeManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SKubeNodeManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred != nil { sq := KubeClusterManager.Query("id") switch scope { - case rbacutils.ScopeDomain, rbacutils.ScopeProject: + case rbacscope.ScopeDomain, rbacscope.ScopeProject: sq = sq.Equals("domain_id", userCred.GetProjectDomainId()) return q.In("cloud_kube_cluster_id", sq.SubQuery()) } diff --git a/pkg/compute/models/loadbalancerbackendgroups.go b/pkg/compute/models/loadbalancerbackendgroups.go index 84def80293..55213e769e 100644 --- a/pkg/compute/models/loadbalancerbackendgroups.go +++ b/pkg/compute/models/loadbalancerbackendgroups.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -34,7 +35,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/validators" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -68,8 +68,8 @@ type SLoadbalancerBackendGroup struct { Type string `width:"36" charset:"ascii" nullable:"false" list:"user" default:"normal" create:"optional"` } -func (manager *SLoadbalancerBackendGroupManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SLoadbalancerBackendGroupManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (self *SLoadbalancerBackendGroup) GetOwnerId() mcclient.IIdentityProvider { @@ -92,14 +92,14 @@ func (manager *SLoadbalancerBackendGroupManager) FetchOwnerId(ctx context.Contex return db.FetchProjectInfo(ctx, data) } -func (man *SLoadbalancerBackendGroupManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (man *SLoadbalancerBackendGroupManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred != nil { sq := LoadbalancerManager.Query("id") switch scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: sq = sq.Equals("tenant_id", userCred.GetProjectId()) return q.In("loadbalancer_id", sq.SubQuery()) - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: sq = sq.Equals("domain_id", userCred.GetProjectDomainId()) return q.In("loadbalancer_id", sq.SubQuery()) } diff --git a/pkg/compute/models/loadbalancerbackends.go b/pkg/compute/models/loadbalancerbackends.go index b6fb7a53db..e4f3096a31 100644 --- a/pkg/compute/models/loadbalancerbackends.go +++ b/pkg/compute/models/loadbalancerbackends.go @@ -24,6 +24,8 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rand" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -34,8 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/validators" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rand" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -77,8 +77,8 @@ type SLoadbalancerBackend struct { Ssl string `width:"16" charset:"ascii" nullable:"true" list:"user" create:"optional" update:"user" default:"off"` } -func (manager *SLoadbalancerBackendManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SLoadbalancerBackendManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (self *SLoadbalancerBackend) GetOwnerId() mcclient.IIdentityProvider { @@ -101,16 +101,16 @@ func (manager *SLoadbalancerBackendManager) FetchOwnerId(ctx context.Context, da return db.FetchProjectInfo(ctx, data) } -func (man *SLoadbalancerBackendManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (man *SLoadbalancerBackendManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred != nil { sq := LoadbalancerBackendGroupManager.Query("id") lb := LoadbalancerManager.Query().SubQuery() sq = sq.Join(lb, sqlchemy.Equals(sq.Field("loadbalancer_id"), lb.Field("id"))) switch scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: sq = sq.Filter(sqlchemy.Equals(lb.Field("tenant_id"), userCred.GetProjectId())) return q.In("backend_group_id", sq.SubQuery()) - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: sq = sq.Filter(sqlchemy.Equals(lb.Field("domain_id"), userCred.GetProjectDomainId())) return q.In("backend_group_id", sq.SubQuery()) } diff --git a/pkg/compute/models/loadbalancercachedacls.go b/pkg/compute/models/loadbalancercachedacls.go index 27f9251494..c1902ccb33 100644 --- a/pkg/compute/models/loadbalancercachedacls.go +++ b/pkg/compute/models/loadbalancercachedacls.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -32,7 +33,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -68,8 +68,8 @@ type SCachedLoadbalancerAcl struct { SLoadbalancerAclResourceBase } -func (manager *SCachedLoadbalancerAclManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SCachedLoadbalancerAclManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (self *SCachedLoadbalancerAcl) GetOwnerId() mcclient.IIdentityProvider { @@ -92,14 +92,14 @@ func (manager *SCachedLoadbalancerAclManager) FetchOwnerId(ctx context.Context, return db.FetchProjectInfo(ctx, data) } -func (manager *SCachedLoadbalancerAclManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SCachedLoadbalancerAclManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred != nil { sq := LoadbalancerAclManager.Query("id") switch scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: sq = sq.Equals("tenant_id", userCred.GetProjectId()) return q.In("acl_id", sq.SubQuery()) - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: sq = sq.Equals("domain_id", userCred.GetProjectDomainId()) return q.In("acl_id", sq.SubQuery()) } @@ -390,7 +390,7 @@ func (man *SCachedLoadbalancerAclManager) newFromCloudLoadbalancerAcl(ctx contex localAcl.AclEntries = &aclEntites localAcl.Fingerprint = f localAcl.IsPublic = true - localAcl.PublicScope = string(rbacutils.ScopeDomain) + localAcl.PublicScope = string(rbacscope.ScopeDomain) err := LoadbalancerAclManager.TableSpec().Insert(ctx, localAcl) if err != nil { return nil, errors.Wrap(err, "cachedLoadbalancerAclManager.new.InsertAcl") diff --git a/pkg/compute/models/loadbalancercachedcertificates.go b/pkg/compute/models/loadbalancercachedcertificates.go index 0eb9a56b3a..8deed88641 100644 --- a/pkg/compute/models/loadbalancercachedcertificates.go +++ b/pkg/compute/models/loadbalancercachedcertificates.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -32,7 +33,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/notifyclient" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -69,8 +69,8 @@ type SCachedLoadbalancerCertificate struct { SLoadbalancerCertificateResourceBase `width:"128" charset:"ascii" nullable:"false" create:"required" index:"true" list:"user"` } -func (manager *SCachedLoadbalancerCertificateManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SCachedLoadbalancerCertificateManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (self *SCachedLoadbalancerCertificate) GetOwnerId() mcclient.IIdentityProvider { @@ -93,14 +93,14 @@ func (manager *SCachedLoadbalancerCertificateManager) FetchOwnerId(ctx context.C return db.FetchProjectInfo(ctx, data) } -func (manager *SCachedLoadbalancerCertificateManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SCachedLoadbalancerCertificateManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred != nil { sq := LoadbalancerCertificateManager.Query("id") switch scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: sq = sq.Equals("tenant_id", userCred.GetProjectId()) return q.In("certificate_id", sq.SubQuery()) - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: sq = sq.Equals("domain_id", userCred.GetProjectDomainId()) return q.In("certificate_id", sq.SubQuery()) } @@ -259,7 +259,7 @@ func (self *SCloudprovider) newFromCloudLoadbalancerCertificate(ctx context.Cont c.CommonName = ext.GetCommonName() c.SubjectAlternativeNames = ext.GetSubjectAlternativeNames() c.NotAfter = ext.GetExpireTime() - c.PublicScope = string(rbacutils.ScopeDomain) + c.PublicScope = string(rbacscope.ScopeDomain) c.IsPublic = true err := LoadbalancerCertificateManager.TableSpec().Insert(ctx, c) diff --git a/pkg/compute/models/loadbalancerlistenerrules.go b/pkg/compute/models/loadbalancerlistenerrules.go index 44a2d8d097..04d4ecc417 100644 --- a/pkg/compute/models/loadbalancerlistenerrules.go +++ b/pkg/compute/models/loadbalancerlistenerrules.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -33,7 +34,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/validators" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -78,8 +78,8 @@ type SLoadbalancerListenerRule struct { SLoadbalancerHTTPRedirect } -func (manager *SLoadbalancerListenerRuleManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SLoadbalancerListenerRuleManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (self *SLoadbalancerListenerRule) GetOwnerId() mcclient.IIdentityProvider { @@ -102,16 +102,16 @@ func (manager *SLoadbalancerListenerRuleManager) FetchOwnerId(ctx context.Contex return db.FetchProjectInfo(ctx, data) } -func (man *SLoadbalancerListenerRuleManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (man *SLoadbalancerListenerRuleManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred != nil { sq := LoadbalancerListenerManager.Query("id") lb := LoadbalancerManager.Query().SubQuery() sq = sq.Join(lb, sqlchemy.Equals(lb.Field("id"), sq.Field("loadbalancer_id"))) switch scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: sq = sq.Filter(sqlchemy.Equals(lb.Field("tenant_id"), userCred.GetProjectId())) return q.In("listener_id", sq.SubQuery()) - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: sq = sq.Filter(sqlchemy.Equals(lb.Field("domain_id"), userCred.GetProjectDomainId())) return q.In("listener_id", sq.SubQuery()) } diff --git a/pkg/compute/models/loadbalancerlisteners.go b/pkg/compute/models/loadbalancerlisteners.go index 1616a14a03..a9ef720f7d 100644 --- a/pkg/compute/models/loadbalancerlisteners.go +++ b/pkg/compute/models/loadbalancerlisteners.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/validators" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -160,8 +160,8 @@ type SLoadbalancerListener struct { SLoadbalancerHTTPRedirect } -func (manager *SLoadbalancerListenerManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SLoadbalancerListenerManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (self *SLoadbalancerListener) GetOwnerId() mcclient.IIdentityProvider { @@ -184,14 +184,14 @@ func (manager *SLoadbalancerListenerManager) FetchOwnerId(ctx context.Context, d return db.FetchProjectInfo(ctx, data) } -func (man *SLoadbalancerListenerManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (man *SLoadbalancerListenerManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred != nil { sq := LoadbalancerManager.Query("id") switch scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: sq = sq.Equals("tenant_id", userCred.GetProjectId()) return q.In("loadbalancer_id", sq.SubQuery()) - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: sq = sq.Equals("domain_id", userCred.GetProjectDomainId()) return q.In("loadbalancer_id", sq.SubQuery()) } diff --git a/pkg/compute/models/loadbalancernetworks.go b/pkg/compute/models/loadbalancernetworks.go index 8ff719bff3..feefda5914 100644 --- a/pkg/compute/models/loadbalancernetworks.go +++ b/pkg/compute/models/loadbalancernetworks.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/regutils" "yunion.io/x/sqlchemy" @@ -30,7 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/lockman" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -264,7 +264,7 @@ func (manager *SLoadbalancernetworkManager) FetchCustomizeColumns( } func totalLBNicCount( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, @@ -277,11 +277,11 @@ func totalLBNicCount( q = q.Join(lbs, sqlchemy.Equals(lbs.Field("id"), lbnics.Field("loadbalancer_id"))) switch scope { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: // do nothing - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: q = q.Filter(sqlchemy.Equals(lbs.Field("domain_id"), ownerId.GetProjectDomainId())) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Filter(sqlchemy.Equals(lbs.Field("tenant_id"), ownerId.GetProjectId())) } q = RangeObjectsFilter(q, rangeObjs, nil, lbs.Field("zone_id"), lbs.Field("manager_id"), nil, nil) diff --git a/pkg/compute/models/loadbalancers.go b/pkg/compute/models/loadbalancers.go index 2309eb4fa5..9a090a1d98 100644 --- a/pkg/compute/models/loadbalancers.go +++ b/pkg/compute/models/loadbalancers.go @@ -25,8 +25,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/compare" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -42,7 +44,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/validators" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -535,7 +536,7 @@ func (man *SLoadbalancerManager) ValidateCreateData( return nil, err } - quotaKeys := fetchRegionalQuotaKeys(rbacutils.ScopeProject, ownerId, region, cloudprovider) + quotaKeys := fetchRegionalQuotaKeys(rbacscope.ScopeProject, ownerId, region, cloudprovider) pendingUsage := SRegionQuota{Loadbalancer: 1} if input.EipBw > 0 && len(input.Eip) == 0 { pendingUsage.Eip = 1 @@ -1370,7 +1371,7 @@ func (manager *SLoadbalancerManager) GetLbDefaultBackendGroupIds() ([]string, er } func (man *SLoadbalancerManager) TotalCount( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, @@ -1387,7 +1388,7 @@ func (man *SLoadbalancerManager) TotalCount( func (lb *SLoadbalancer) GetQuotaKeys() quotas.IQuotaKeys { region, _ := lb.GetRegion() return fetchRegionalQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, lb.GetOwnerId(), region, lb.GetCloudprovider(), diff --git a/pkg/compute/models/managedresource.go b/pkg/compute/models/managedresource.go index ff9af973ab..8705f386db 100644 --- a/pkg/compute/models/managedresource.go +++ b/pkg/compute/models/managedresource.go @@ -22,18 +22,18 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/reflectutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" api "yunion.io/x/onecloud/pkg/apis/compute" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -165,7 +165,7 @@ func (self *SManagedResourceBase) CanShareToDomain(domainId string) bool { return false } case api.CLOUD_ACCOUNT_SHARE_MODE_SYSTEM: - if account.PublicScope == string(rbacutils.ScopeSystem) { + if account.PublicScope == string(rbacscope.ScopeSystem) { return true } else { // public_scope = domain @@ -359,7 +359,7 @@ func (model *SManagedResourceBase) GetChangeOwnerCandidateDomainIds() []string { case api.CLOUD_ACCOUNT_SHARE_MODE_PROVIDER_DOMAIN: candidateIds = append(candidateIds, provider.DomainId) case api.CLOUD_ACCOUNT_SHARE_MODE_SYSTEM: - if account.PublicScope != string(rbacutils.ScopeSystem) { + if account.PublicScope != string(rbacscope.ScopeSystem) { candidateIds = account.GetSharedDomains() candidateIds = append(candidateIds, account.DomainId) } diff --git a/pkg/compute/models/mongodb.go b/pkg/compute/models/mongodb.go index b913c17b75..8175a5d9e3 100644 --- a/pkg/compute/models/mongodb.go +++ b/pkg/compute/models/mongodb.go @@ -23,7 +23,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -36,7 +38,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/notifyclient" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -662,7 +663,7 @@ type SMongoDBCountStat struct { } func (man *SMongoDBManager) TotalCount( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, @@ -689,7 +690,7 @@ func (man *SMongoDBManager) TotalCount( func (self *SMongoDB) GetQuotaKeys() quotas.IQuotaKeys { region, _ := self.GetRegion() return fetchRegionalQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, self.GetOwnerId(), region, self.GetCloudprovider(), diff --git a/pkg/compute/models/mount_targets.go b/pkg/compute/models/mount_targets.go index acd3462819..d8e339d371 100644 --- a/pkg/compute/models/mount_targets.go +++ b/pkg/compute/models/mount_targets.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -33,7 +34,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/validators" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -71,8 +71,8 @@ type SMountTarget struct { FileSystemId string `width:"36" charset:"ascii" nullable:"false" create:"required" index:"true" list:"user"` } -func (manager *SMountTargetManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SMountTargetManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SMountTarget) GetFileSystem() (*SFileSystem, error) { @@ -264,10 +264,10 @@ func (self *SMountTarget) GetOwnerId() mcclient.IIdentityProvider { return &db.SOwnerId{DomainId: fs.DomainId} } -func (manager *SMountTargetManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SMountTargetManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred != nil { sq := FileSystemManager.Query("id") - if scope == rbacutils.ScopeDomain && len(userCred.GetProjectDomainId()) > 0 { + if scope == rbacscope.ScopeDomain && len(userCred.GetProjectDomainId()) > 0 { sq = sq.Equals("domain_id", userCred.GetProjectDomainId()) return q.In("file_system_id", sq) } diff --git a/pkg/compute/models/natgateways.go b/pkg/compute/models/natgateways.go index c97d9280f3..f1dcfe8c0e 100644 --- a/pkg/compute/models/natgateways.go +++ b/pkg/compute/models/natgateways.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/compare" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -38,7 +39,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/logclient" "yunion.io/x/onecloud/pkg/util/stringutils2" ) diff --git a/pkg/compute/models/netinterfaces.go b/pkg/compute/models/netinterfaces.go index 556d40e5da..78bf1bcf47 100644 --- a/pkg/compute/models/netinterfaces.go +++ b/pkg/compute/models/netinterfaces.go @@ -22,12 +22,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/regutils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) // +onecloud:swagger-gen-ignore @@ -281,7 +281,7 @@ func (self *SNetInterface) Remove(ctx context.Context, userCred mcclient.TokenCr return errors.Wrap(err, "db.Update") } -func (self *SNetInterface) GetCandidateNetworkForIp(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope, ipAddr string) (*SNetwork, error) { +func (self *SNetInterface) GetCandidateNetworkForIp(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope, ipAddr string) (*SNetwork, error) { wire := self.GetWire() if wire == nil { return nil, nil diff --git a/pkg/compute/models/networkaddresses.go b/pkg/compute/models/networkaddresses.go index edaa55c2e9..7ae557872c 100644 --- a/pkg/compute/models/networkaddresses.go +++ b/pkg/compute/models/networkaddresses.go @@ -26,6 +26,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/delayedwork" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -33,7 +34,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/lockman" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -603,16 +603,16 @@ func (man *SNetworkAddressManager) FetchCustomizeColumns( return ret } -func (man *SNetworkAddressManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (man *SNetworkAddressManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { q = db.ApplyFilterByOwner(q, owner, scope, &man.SStandaloneAnonResourceBaseManager, ) if owner != nil { var condVar, condVal string switch scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: condVar, condVal = "tenant_id", owner.GetProjectId() - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: condVar, condVal = "domain_id", owner.GetProjectDomainId() default: return q diff --git a/pkg/compute/models/networks.go b/pkg/compute/models/networks.go index e2dab70606..dcd6c8db9e 100644 --- a/pkg/compute/models/networks.go +++ b/pkg/compute/models/networks.go @@ -28,8 +28,11 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/compare" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rand" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/regutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -47,9 +50,7 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rand" "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -256,7 +257,7 @@ func (manager *SNetworkManager) GetOrCreateClassicNetwork(ctx context.Context, w func (self *SNetwork) GetUsedAddresses() map[string]bool { used := make(map[string]bool) - q := self.getUsedAddressQuery(nil, rbacutils.ScopeSystem, true) + q := self.getUsedAddressQuery(nil, rbacscope.ScopeSystem, true) results, err := q.AllStringMap() if err != nil { log.Errorf("GetUsedAddresses fail %s", err) @@ -532,7 +533,7 @@ func (self *SNetwork) IsExitNetwork() bool { } func (manager *SNetworkManager) getNetworksByWire(wire *SWire) ([]SNetwork, error) { - return wire.getNetworks(nil, rbacutils.ScopeNone) + return wire.getNetworks(nil, rbacscope.ScopeNone) /* nets := make([]SNetwork, 0) q := manager.Query().Equals("wire_id", wire.Id) err := db.FetchModelObjects(manager, q, &nets) @@ -668,10 +669,10 @@ func (self *SNetwork) SyncWithCloudNetwork(ctx context.Context, userCred mcclien if provider != nil { shareInfo := provider.getAccountShareInfo() - if utils.IsInStringArray(provider.Provider, api.PRIVATE_CLOUD_PROVIDERS) && extNet.GetPublicScope() == rbacutils.ScopeNone { + if utils.IsInStringArray(provider.Provider, api.PRIVATE_CLOUD_PROVIDERS) && extNet.GetPublicScope() == rbacscope.ScopeNone { shareInfo = apis.SAccountShareInfo{ IsPublic: false, - PublicScope: rbacutils.ScopeNone, + PublicScope: rbacscope.ScopeNone, } } self.SyncShareState(ctx, userCred, shareInfo) @@ -727,10 +728,10 @@ func (manager *SNetworkManager) newFromCloudNetwork(ctx context.Context, userCre if provider != nil { shareInfo := provider.getAccountShareInfo() - if utils.IsInStringArray(provider.Provider, api.PRIVATE_CLOUD_PROVIDERS) && extNet.GetPublicScope() == rbacutils.ScopeNone { + if utils.IsInStringArray(provider.Provider, api.PRIVATE_CLOUD_PROVIDERS) && extNet.GetPublicScope() == rbacscope.ScopeNone { shareInfo = apis.SAccountShareInfo{ IsPublic: false, - PublicScope: rbacutils.ScopeNone, + PublicScope: rbacscope.ScopeNone, } } net.SyncShareState(ctx, userCred, shareInfo) @@ -750,7 +751,7 @@ func (self *SNetwork) IsAddressInRange(address netutils.IPV4Addr) bool { } func (self *SNetwork) isAddressUsed(address string) (bool, error) { - q := self.getUsedAddressQuery(nil, rbacutils.ScopeSystem, true) + q := self.getUsedAddressQuery(nil, rbacscope.ScopeSystem, true) q = q.Equals("ip_addr", address) count, err := q.CountWithError() if err != nil && errors.Cause(err) != sql.ErrNoRows { @@ -813,7 +814,7 @@ func (manager *SNetworkManager) allNetworksQ(providers []string, brands []string } func (manager *SNetworkManager) totalPortCountQ( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, providers []string, brands []string, @@ -823,10 +824,10 @@ func (manager *SNetworkManager) totalPortCountQ( ) *sqlchemy.SQuery { q := manager.allNetworksQ(providers, brands, cloudEnv, rangeObjs) switch scope { - case rbacutils.ScopeSystem: - case rbacutils.ScopeDomain: + case rbacscope.ScopeSystem: + case rbacscope.ScopeDomain: q = q.Equals("domain_id", userCred.GetProjectDomainId()) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Equals("tenant_id", userCred.GetProjectId()) } q = db.ObjectIdQueryWithPolicyResult(q, manager, policyResult) @@ -839,7 +840,7 @@ type NetworkPortStat struct { } func (manager *SNetworkManager) TotalPortCount( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, providers []string, brands []string, cloudEnv string, rangeObjs []db.IStandaloneModel, @@ -1847,16 +1848,16 @@ func (self *SNetwork) CustomizeCreate(ctx context.Context, userCred mcclient.Tok if !data.Contains("public_scope") { if self.ServerType == api.NETWORK_TYPE_GUEST && !self.IsManaged() { wire, _ := self.GetWire() - if db.IsAdminAllowPerform(ctx, userCred, self, "public") && ownerId.GetProjectDomainId() == userCred.GetProjectDomainId() && wire != nil && wire.IsPublic && wire.PublicScope == string(rbacutils.ScopeSystem) { - self.SetShare(rbacutils.ScopeSystem) + if db.IsAdminAllowPerform(ctx, userCred, self, "public") && ownerId.GetProjectDomainId() == userCred.GetProjectDomainId() && wire != nil && wire.IsPublic && wire.PublicScope == string(rbacscope.ScopeSystem) { + self.SetShare(rbacscope.ScopeSystem) } else if db.IsDomainAllowPerform(ctx, userCred, self, "public") && ownerId.GetProjectId() == userCred.GetProjectId() && consts.GetNonDefaultDomainProjects() { // only if non_default_domain_projects turned on, share to domain - self.SetShare(rbacutils.ScopeDomain) + self.SetShare(rbacscope.ScopeDomain) } else { - self.SetShare(rbacutils.ScopeNone) + self.SetShare(rbacscope.ScopeNone) } } else { - self.SetShare(rbacutils.ScopeNone) + self.SetShare(rbacscope.ScopeNone) } data.(*jsonutils.JSONDict).Set("public_scope", jsonutils.NewString(self.PublicScope)) } @@ -2790,7 +2791,7 @@ func (network *SNetwork) PerformChangeOwner(ctx context.Context, userCred mcclie return ret, nil } -func (network *SNetwork) getUsedAddressQuery(owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope, addrOnly bool) *sqlchemy.SQuery { +func (network *SNetwork) getUsedAddressQuery(owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope, addrOnly bool) *sqlchemy.SQuery { var ( args = &usedAddressQueryArgs{ network: network, @@ -2828,7 +2829,7 @@ func (network *SNetwork) GetDetailsAddresses(ctx context.Context, userCred mccli output := api.GetNetworkAddressesOutput{} allowScope, _ := policy.PolicyManager.AllowScope(userCred, api.SERVICE_TYPE, network.KeywordPlural(), policy.PolicyActionGet, "addresses") - scope := rbacutils.String2ScopeDefault(input.Scope, allowScope) + scope := rbacscope.String2ScopeDefault(input.Scope, allowScope) if scope.HigherThan(allowScope) { return output, errors.Wrapf(httperrors.ErrNotSufficientPrivilege, "require %s allow %s", scope, allowScope) } @@ -2909,7 +2910,7 @@ func (manager *SNetworkManager) ListItemExportKeys(ctx context.Context, return q, nil } -func (manager *SNetworkManager) AllowScope(userCred mcclient.TokenCredential) rbacutils.TRbacScope { +func (manager *SNetworkManager) AllowScope(userCred mcclient.TokenCredential) rbacscope.TRbacScope { scope, _ := policy.PolicyManager.AllowScope(userCred, api.SERVICE_TYPE, NetworkManager.KeywordPlural(), policy.PolicyActionGet) return scope } diff --git a/pkg/compute/models/networks_used_addresses_query.go b/pkg/compute/models/networks_used_addresses_query.go index 6f5dc344cb..a2487db91e 100644 --- a/pkg/compute/models/networks_used_addresses_query.go +++ b/pkg/compute/models/networks_used_addresses_query.go @@ -17,16 +17,16 @@ package models import ( "time" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type usedAddressQueryArgs struct { network *SNetwork owner mcclient.IIdentityProvider - scope rbacutils.TRbacScope + scope rbacscope.TRbacScope addrOnly bool } diff --git a/pkg/compute/models/projectquota.go b/pkg/compute/models/projectquota.go index 979b5f3859..12c46504dc 100644 --- a/pkg/compute/models/projectquota.go +++ b/pkg/compute/models/projectquota.go @@ -18,13 +18,13 @@ import ( "context" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" identityapi "yunion.io/x/onecloud/pkg/apis/identity" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" commonOptions "yunion.io/x/onecloud/pkg/cloudcommon/options" "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) var ( @@ -39,7 +39,7 @@ func init() { ProjectUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(ProjectQuota, - rbacutils.ScopeProject, + rbacscope.ScopeProject, "project_quota_usage_tbl", "project_quota_usage", "project_quota_usages", @@ -47,7 +47,7 @@ func init() { } ProjectPendingUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(ProjectQuota, - rbacutils.ScopeProject, + rbacscope.ScopeProject, "project_quota_pending_usage_tbl", "project_quota_pending_usage", "project_quota_pending_usages", @@ -55,7 +55,7 @@ func init() { } ProjectQuotaManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaBaseManager(ProjectQuota, - rbacutils.ScopeProject, + rbacscope.ScopeProject, "project_quota_tbl", ProjectPendingUsageManager, ProjectUsageManager, @@ -90,14 +90,14 @@ func (self *SProjectQuota) FetchSystemQuota() { base = -1 case commonOptions.DefaultQuotaZero: base = 0 - if keys.Scope() == rbacutils.ScopeDomain { // domain level quota + if keys.Scope() == rbacscope.ScopeDomain { // domain level quota base = 10 } else if keys.DomainId == identityapi.DEFAULT_DOMAIN_ID && keys.ProjectId == auth.AdminCredential().GetProjectId() { base = 1 } case commonOptions.DefaultQuotaDefault: base = 1 - if keys.Scope() == rbacutils.ScopeDomain { + if keys.Scope() == rbacscope.ScopeDomain { base = 10 } } diff --git a/pkg/compute/models/purge.go b/pkg/compute/models/purge.go index 25df40eee5..2683fad6c2 100644 --- a/pkg/compute/models/purge.go +++ b/pkg/compute/models/purge.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/apis" @@ -29,7 +30,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/lockman" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) var LB_CERTS_TO_BE_PURGE = map[string][]string{} @@ -929,7 +929,7 @@ func (net *SNetwork) purge(ctx context.Context, userCred mcclient.TokenCredentia } func (wire *SWire) purgeNetworks(ctx context.Context, userCred mcclient.TokenCredential) error { - nets, err := wire.getNetworks(nil, rbacutils.ScopeNone) + nets, err := wire.getNetworks(nil, rbacscope.ScopeNone) if err != nil { return err } diff --git a/pkg/compute/models/quotas.go b/pkg/compute/models/quotas.go index 4900733d4e..6d1b299682 100644 --- a/pkg/compute/models/quotas.go +++ b/pkg/compute/models/quotas.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/compute" identityapi "yunion.io/x/onecloud/pkg/apis/identity" @@ -50,7 +51,7 @@ func init() { QuotaUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(Quota, - rbacutils.ScopeProject, + rbacscope.ScopeProject, "quota_usage_tbl", "quota_usage", "quota_usages", @@ -58,7 +59,7 @@ func init() { } QuotaPendingUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(Quota, - rbacutils.ScopeProject, + rbacscope.ScopeProject, "quota_pending_usage_tbl", "quota_pending_usage", "quota_pending_usages", @@ -66,7 +67,7 @@ func init() { } QuotaManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaBaseManager(Quota, - rbacutils.ScopeProject, + rbacscope.ScopeProject, "quota_tbl", QuotaPendingUsageManager, QuotaUsageManager, @@ -113,14 +114,14 @@ func (self *SQuota) FetchSystemQuota() { base = -1 case commonOptions.DefaultQuotaZero: base = 0 - if keys.Scope() == rbacutils.ScopeDomain { // domain level quota + if keys.Scope() == rbacscope.ScopeDomain { // domain level quota base = 10 } else if keys.DomainId == identityapi.DEFAULT_DOMAIN_ID && keys.ProjectId == auth.AdminCredential().GetProjectId() { base = 1 } case commonOptions.DefaultQuotaDefault: base = 1 - if keys.Scope() == rbacutils.ScopeDomain { + if keys.Scope() == rbacscope.ScopeDomain { base = 10 } } @@ -449,7 +450,7 @@ func (k1 SComputeResourceKeys) Compare(ik quotas.IQuotaKeys) int { return 0 } -func fetchCloudQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, manager *SCloudprovider) quotas.SCloudResourceKeys { +func fetchCloudQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, manager *SCloudprovider) quotas.SCloudResourceKeys { keys := quotas.SCloudResourceKeys{} keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId) if manager != nil { @@ -469,7 +470,7 @@ func fetchCloudQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityP return keys } -func fetchRegionalQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, region *SCloudregion, manager *SCloudprovider) quotas.SRegionalCloudResourceKeys { +func fetchRegionalQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, region *SCloudregion, manager *SCloudprovider) quotas.SRegionalCloudResourceKeys { keys := quotas.SRegionalCloudResourceKeys{} keys.SCloudResourceKeys = fetchCloudQuotaKeys(scope, ownerId, manager) if region != nil { @@ -478,7 +479,7 @@ func fetchRegionalQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdenti return keys } -func fetchZonalQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, zone *SZone, manager *SCloudprovider) quotas.SZonalCloudResourceKeys { +func fetchZonalQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, zone *SZone, manager *SCloudprovider) quotas.SZonalCloudResourceKeys { keys := quotas.SZonalCloudResourceKeys{} keys.SCloudResourceKeys = fetchCloudQuotaKeys(scope, ownerId, manager) if zone != nil { @@ -488,7 +489,7 @@ func fetchZonalQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityP return keys } -func fetchComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, zone *SZone, manager *SCloudprovider, hypervisor string) SComputeResourceKeys { +func fetchComputeQuotaKeys(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, zone *SZone, manager *SCloudprovider, hypervisor string) SComputeResourceKeys { keys := SComputeResourceKeys{} keys.SZonalCloudResourceKeys = fetchZonalQuotaKeys(scope, ownerId, zone, manager) keys.Hypervisor = hypervisor diff --git a/pkg/compute/models/regiondrivers.go b/pkg/compute/models/regiondrivers.go index 821cfe7815..22e2c1bc0f 100644 --- a/pkg/compute/models/regiondrivers.go +++ b/pkg/compute/models/regiondrivers.go @@ -21,13 +21,13 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type IRegionDriver interface { @@ -143,7 +143,7 @@ type IRegionDriver interface { IsSecurityGroupBelongGlobalVpc() bool //安全组子账号范围内可用 GetDefaultSecurityGroupVpcId() string GetSecurityGroupVpcId(ctx context.Context, userCred mcclient.TokenCredential, region *SCloudregion, host *SHost, vpc *SVpc, classic bool) (string, error) - GetSecurityGroupPublicScope(service string) rbacutils.TRbacScope + GetSecurityGroupPublicScope(service string) rbacscope.TRbacScope IsSupportedBillingCycle(bc billing.SBillingCycle, resource string) bool GetSecgroupVpcid(vpcId string) string diff --git a/pkg/compute/models/regionquota.go b/pkg/compute/models/regionquota.go index 5f7de9a98e..3391c9c0f2 100644 --- a/pkg/compute/models/regionquota.go +++ b/pkg/compute/models/regionquota.go @@ -19,6 +19,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" identityapi "yunion.io/x/onecloud/pkg/apis/identity" "yunion.io/x/onecloud/pkg/cloudcommon/db" @@ -41,7 +42,7 @@ func init() { RegionUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(RegionQuota, - rbacutils.ScopeProject, + rbacscope.ScopeProject, "region_quota_usage_tbl", "region_quota_usage", "region_quota_usages", @@ -49,7 +50,7 @@ func init() { } RegionPendingUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(RegionQuota, - rbacutils.ScopeProject, + rbacscope.ScopeProject, "region_quota_pending_usage_tbl", "region_quota_pending_usage", "region_quota_pending_usages", @@ -57,7 +58,7 @@ func init() { } RegionQuotaManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaBaseManager(RegionQuota, - rbacutils.ScopeProject, + rbacscope.ScopeProject, "region_quota_tbl", RegionPendingUsageManager, RegionUsageManager, @@ -109,14 +110,14 @@ func (self *SRegionQuota) FetchSystemQuota() { base = -1 case commonOptions.DefaultQuotaZero: base = 0 - if keys.Scope() == rbacutils.ScopeDomain { // domain level quota + if keys.Scope() == rbacscope.ScopeDomain { // domain level quota base = 10 } else if keys.DomainId == identityapi.DEFAULT_DOMAIN_ID && keys.ProjectId == auth.AdminCredential().GetProjectId() { base = 1 } case commonOptions.DefaultQuotaDefault: base = 1 - if keys.Scope() == rbacutils.ScopeDomain { + if keys.Scope() == rbacscope.ScopeDomain { base = 10 } } diff --git a/pkg/compute/models/reservedips.go b/pkg/compute/models/reservedips.go index 9537c947fd..9a4a97f466 100644 --- a/pkg/compute/models/reservedips.go +++ b/pkg/compute/models/reservedips.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -30,7 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -320,22 +320,22 @@ func (manager *SReservedipManager) FilterByUniqValues(q *sqlchemy.SQuery, values return q } -func (manager *SReservedipManager) NamespaceScope() rbacutils.TRbacScope { +func (manager *SReservedipManager) NamespaceScope() rbacscope.TRbacScope { if consts.IsDomainizedNamespace() { - return rbacutils.ScopeDomain + return rbacscope.ScopeDomain } else { - return rbacutils.ScopeSystem + return rbacscope.ScopeSystem } } -func (manager *SReservedipManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SReservedipManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } -func (manager *SReservedipManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SReservedipManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { switch scope { - case rbacutils.ScopeProject, rbacutils.ScopeDomain: + case rbacscope.ScopeProject, rbacscope.ScopeDomain: netsQ := NetworkManager.Query("id") netsQ = NetworkManager.FilterByOwner(netsQ, owner, scope) netsSQ := netsQ.SubQuery() diff --git a/pkg/compute/models/scaling_activity.go b/pkg/compute/models/scaling_activity.go index 2f878272c6..fc4b340417 100644 --- a/pkg/compute/models/scaling_activity.go +++ b/pkg/compute/models/scaling_activity.go @@ -20,12 +20,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -182,18 +182,18 @@ func (sam *SScalingActivityManager) ListItemFilter(ctx context.Context, q *sqlch return q, nil } -func (sam *SScalingActivityManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (sam *SScalingActivityManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } -func (sam *SScalingActivityManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (sam *SScalingActivityManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } -func (sam *SScalingActivityManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (sam *SScalingActivityManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { switch scope { - case rbacutils.ScopeProject, rbacutils.ScopeDomain: + case rbacscope.ScopeProject, rbacscope.ScopeDomain: scalingGroupQ := ScalingGroupManager.Query("id", "domain_id").SubQuery() q = q.Join(scalingGroupQ, sqlchemy.Equals(q.Field("scaling_group_id"), scalingGroupQ.Field("id"))) q = q.Filter(sqlchemy.Equals(scalingGroupQ.Field("domain_id"), owner.GetProjectDomainId())) diff --git a/pkg/compute/models/schedtags.go b/pkg/compute/models/schedtags.go index a5a8f5de74..0eaed7973f 100644 --- a/pkg/compute/models/schedtags.go +++ b/pkg/compute/models/schedtags.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -32,7 +33,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -116,8 +116,8 @@ func (manager *SSchedtagManager) InitializeData() error { return nil } -func (manager *SSchedtagManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (manager *SSchedtagManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (manager *SSchedtagManager) BindJointManagers(ms map[db.IModelManager]ISchedtagJointManager) { @@ -146,12 +146,12 @@ type SSchedtag struct { ResourceType string `width:"16" charset:"ascii" nullable:"true" list:"user" create:"required"` // Column(VARCHAR(16, charset='ascii'), nullable=True, default='') } -func (m *SSchedtagManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (m *SSchedtagManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred == nil { return q } switch scope { - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: q = q.Filter(sqlchemy.OR( // share to system sqlchemy.AND( @@ -161,7 +161,7 @@ func (m *SSchedtagManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.I // share to this domain or its sub-projects sqlchemy.Equals(q.Field("domain_id"), userCred.GetProjectDomainId()), )) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Filter(sqlchemy.OR( // share to system sqlchemy.AND( diff --git a/pkg/compute/models/secgroupcache.go b/pkg/compute/models/secgroupcache.go index 54b142cb6e..dbdbaa5cba 100644 --- a/pkg/compute/models/secgroupcache.go +++ b/pkg/compute/models/secgroupcache.go @@ -24,6 +24,8 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rand" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -34,8 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/notifyclient" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rand" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -85,8 +85,8 @@ func (self *SSecurityGroupCache) GetOwnerId() mcclient.IIdentityProvider { return &db.SOwnerId{DomainId: sec.DomainId, ProjectId: sec.ProjectId} } -func (manager *SSecurityGroupCacheManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SSecurityGroupCacheManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } // 安全组缓存列表 @@ -188,16 +188,16 @@ func (sgc *SSecurityGroupCache) IsSupportPeerSecgroup() bool { return driver.IsSupportPeerSecgroup() } -func (manager *SSecurityGroupCacheManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SSecurityGroupCacheManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred != nil { sq := SecurityGroupManager.Query("id") switch scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: if len(userCred.GetProjectId()) > 0 { sq = sq.Equals("tenant_id", userCred.GetProjectId()) return q.In("secgroup_id", sq) } - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: if len(userCred.GetProjectDomainId()) > 0 { sq = sq.Equals("domain_id", userCred.GetProjectDomainId()) return q.In("secgroup_id", sq) diff --git a/pkg/compute/models/secgrouprules.go b/pkg/compute/models/secgrouprules.go index 6b3e34802a..986487a788 100644 --- a/pkg/compute/models/secgrouprules.go +++ b/pkg/compute/models/secgrouprules.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/regutils" "yunion.io/x/pkg/util/secrules" "yunion.io/x/pkg/util/stringutils" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -108,7 +108,7 @@ func (manager *SSecurityGroupRuleManager) FetchOwnerId(ctx context.Context, data return db.FetchProjectInfo(ctx, data) } -func (manager *SSecurityGroupRuleManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SSecurityGroupRuleManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { sq := SecurityGroupManager.Query("id") sq = db.SharableManagerFilterByOwner(SecurityGroupManager, sq, userCred, scope) return q.In("secgroup_id", sq.SubQuery()) @@ -530,8 +530,8 @@ func (self *SSecurityGroupRule) GetOwnerId() mcclient.IIdentityProvider { return nil } -func (manager *SSecurityGroupRuleManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SSecurityGroupRuleManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (manager *SSecurityGroupRuleManager) ListItemExportKeys(ctx context.Context, diff --git a/pkg/compute/models/secgroups.go b/pkg/compute/models/secgroups.go index b83e345c2b..bf8b14e1d6 100644 --- a/pkg/compute/models/secgroups.go +++ b/pkg/compute/models/secgroups.go @@ -26,6 +26,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/regutils" "yunion.io/x/pkg/util/secrules" "yunion.io/x/pkg/utils" @@ -45,7 +46,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -134,7 +134,7 @@ func (manager *SSecurityGroupManager) ListItemFilter( isAdmin := false // admin := (input.Admin != nil && *input.Admin) allowScope, _ := policy.PolicyManager.AllowScope(userCred, consts.GetServiceType(), manager.KeywordPlural(), policy.PolicyActionList) - if allowScope == rbacutils.ScopeSystem || allowScope == rbacutils.ScopeDomain { + if allowScope == rbacscope.ScopeSystem || allowScope == rbacscope.ScopeDomain { isAdmin = true } @@ -616,7 +616,7 @@ func (manager *SSecurityGroupManager) ValidateCreateData( } pendingUsage := SProjectQuota{Secgroup: 1} - quotaKey := quotas.OwnerIdProjectQuotaKeys(rbacutils.ScopeProject, ownerId) + quotaKey := quotas.OwnerIdProjectQuotaKeys(rbacscope.ScopeProject, ownerId) pendingUsage.SetKeys(quotaKey) err = quotas.CheckSetPendingQuota(ctx, userCred, &pendingUsage) if err != nil { @@ -729,15 +729,15 @@ func (self *SSecurityGroup) getSecurityRuleString() (string, error) { return strings.Join(rules, SECURITY_GROUP_SEPARATOR), nil } -func totalSecurityGroupCount(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider) (int, error) { +func totalSecurityGroupCount(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider) (int, error) { q := SecurityGroupManager.Query() switch scope { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: // do nothing - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: q = q.Equals("domain_id", ownerId.GetProjectDomainId()) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Equals("tenant_id", ownerId.GetProjectId()) } @@ -863,7 +863,7 @@ func (self *SSecurityGroup) PerformClone(ctx context.Context, userCred mcclient. ProjectId: userCred.GetProjectId(), } pendingUsage := SProjectQuota{Secgroup: 1} - quotaKey := quotas.OwnerIdProjectQuotaKeys(rbacutils.ScopeProject, ownerId) + quotaKey := quotas.OwnerIdProjectQuotaKeys(rbacscope.ScopeProject, ownerId) pendingUsage.SetKeys(quotaKey) err := quotas.CheckSetPendingQuota(ctx, userCred, &pendingUsage) if err != nil { @@ -1260,7 +1260,7 @@ func (manager *SSecurityGroupManager) InitializeData() error { // secGrp.IsEmulated = false secGrp.IsPublic = true secGrp.Deleted = false - secGrp.PublicScope = string(rbacutils.ScopeSystem) + secGrp.PublicScope = string(rbacscope.ScopeSystem) err = manager.TableSpec().InsertOrUpdate(context.TODO(), secGrp) if err != nil { return errors.Wrapf(err, "Insert default secgroup") @@ -1454,7 +1454,7 @@ func (self *SSecurityGroup) RealDelete(ctx context.Context, userCred mcclient.To } func (sg *SSecurityGroup) GetQuotaKeys() quotas.IQuotaKeys { - return quotas.OwnerIdProjectQuotaKeys(rbacutils.ScopeProject, sg.GetOwnerId()) + return quotas.OwnerIdProjectQuotaKeys(rbacscope.ScopeProject, sg.GetOwnerId()) } func (sg *SSecurityGroup) GetUsages() []db.IUsage { diff --git a/pkg/compute/models/skus_tools.go b/pkg/compute/models/skus_tools.go index f6e05faf30..d8523781e0 100644 --- a/pkg/compute/models/skus_tools.go +++ b/pkg/compute/models/skus_tools.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/httputils" v "yunion.io/x/pkg/util/version" "yunion.io/x/pkg/utils" @@ -34,7 +35,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/pkg/compute/models/snapshotpolicycache.go b/pkg/compute/models/snapshotpolicycache.go index 6334f737f3..106e0eb320 100644 --- a/pkg/compute/models/snapshotpolicycache.go +++ b/pkg/compute/models/snapshotpolicycache.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -33,7 +34,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -552,8 +552,8 @@ func (manager *SSnapshotPolicyCacheManager) ListItemExportKeys(ctx context.Conte return q, nil } -func (manager *SSnapshotPolicyCacheManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SSnapshotPolicyCacheManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (spc *SSnapshotPolicyCache) GetOwnerId() mcclient.IIdentityProvider { diff --git a/pkg/compute/models/snapshots.go b/pkg/compute/models/snapshots.go index 528e9d5a92..ab0e590c67 100644 --- a/pkg/compute/models/snapshots.go +++ b/pkg/compute/models/snapshots.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -848,14 +849,14 @@ func (self *SSnapshotManager) DeleteDiskSnapshots(ctx context.Context, userCred return nil } -func TotalSnapshotCount(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) (int, error) { +func TotalSnapshotCount(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) (int, error) { q := SnapshotManager.Query() switch scope { - case rbacutils.ScopeSystem: - case rbacutils.ScopeDomain: + case rbacscope.ScopeSystem: + case rbacscope.ScopeDomain: q = q.Equals("domain_id", ownerId.GetProjectDomainId()) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Equals("tenant_id", ownerId.GetProjectId()) } @@ -1105,7 +1106,7 @@ func (manager *SSnapshotManager) StartSnapshotCleanupTask( func (self *SSnapshot) GetQuotaKeys() quotas.IQuotaKeys { region, _ := self.GetRegion() return fetchRegionalQuotaKeys( - rbacutils.ScopeProject, + rbacscope.ScopeProject, self.GetOwnerId(), region, self.GetCloudprovider(), diff --git a/pkg/compute/models/storagecaches.go b/pkg/compute/models/storagecaches.go index 73e75f4880..6dc26c6789 100644 --- a/pkg/compute/models/storagecaches.go +++ b/pkg/compute/models/storagecaches.go @@ -27,6 +27,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/imagetools" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/imagetools" "yunion.io/x/onecloud/pkg/util/stringutils2" ) diff --git a/pkg/compute/models/storages.go b/pkg/compute/models/storages.go index 392e766870..03c021a9a5 100644 --- a/pkg/compute/models/storages.go +++ b/pkg/compute/models/storages.go @@ -26,6 +26,8 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -38,7 +40,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" @@ -956,13 +957,13 @@ type StorageCapacityStat struct { TotalSizeVirtual float64 } -func filterDisksByScope(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, policyResult rbacutils.SPolicyResult) *sqlchemy.SSubQuery { +func filterDisksByScope(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, policyResult rbacutils.SPolicyResult) *sqlchemy.SSubQuery { q := DiskManager.Query() switch scope { - case rbacutils.ScopeSystem: - case rbacutils.ScopeDomain: + case rbacscope.ScopeSystem: + case rbacscope.ScopeDomain: q = q.Filter(sqlchemy.Equals(q.Field("domain_id"), ownerId.GetProjectDomainId())) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Filter(sqlchemy.Equals(q.Field("tenant_id"), ownerId.GetProjectId())) } if pendingDeleted { @@ -976,7 +977,7 @@ func filterDisksByScope(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityPr return db.ObjectIdQueryWithPolicyResult(q, DiskManager, policyResult).SubQuery() } -func (manager *SStorageManager) disksReadyQ(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, policyResult rbacutils.SPolicyResult) *sqlchemy.SSubQuery { +func (manager *SStorageManager) disksReadyQ(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, policyResult rbacutils.SPolicyResult) *sqlchemy.SSubQuery { disks := filterDisksByScope(scope, ownerId, pendingDeleted, includeSystem, policyResult) q := disks.Query( disks.Field("storage_id"), @@ -987,7 +988,7 @@ func (manager *SStorageManager) disksReadyQ(scope rbacutils.TRbacScope, ownerId return q.SubQuery() } -func (manager *SStorageManager) diskIsAttachedQ(isAttached bool, scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, policyResult rbacutils.SPolicyResult) *sqlchemy.SSubQuery { +func (manager *SStorageManager) diskIsAttachedQ(isAttached bool, scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, policyResult rbacutils.SPolicyResult) *sqlchemy.SSubQuery { sumKey := "attached_used_capacity" countKey := "attached_count" cond := sqlchemy.In @@ -1007,15 +1008,15 @@ func (manager *SStorageManager) diskIsAttachedQ(isAttached bool, scope rbacutils return q.SubQuery() } -func (manager *SStorageManager) diskAttachedQ(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, policyResult rbacutils.SPolicyResult) *sqlchemy.SSubQuery { +func (manager *SStorageManager) diskAttachedQ(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, policyResult rbacutils.SPolicyResult) *sqlchemy.SSubQuery { return manager.diskIsAttachedQ(true, scope, ownerId, pendingDeleted, includeSystem, policyResult) } -func (manager *SStorageManager) diskDetachedQ(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, policyResult rbacutils.SPolicyResult) *sqlchemy.SSubQuery { +func (manager *SStorageManager) diskDetachedQ(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, policyResult rbacutils.SPolicyResult) *sqlchemy.SSubQuery { return manager.diskIsAttachedQ(false, scope, ownerId, pendingDeleted, includeSystem, policyResult) } -func (manager *SStorageManager) disksFailedQ(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, policyResult rbacutils.SPolicyResult) *sqlchemy.SSubQuery { +func (manager *SStorageManager) disksFailedQ(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, policyResult rbacutils.SPolicyResult) *sqlchemy.SSubQuery { disks := filterDisksByScope(scope, ownerId, pendingDeleted, includeSystem, policyResult) q := disks.Query( disks.Field("storage_id"), @@ -1030,7 +1031,7 @@ func (manager *SStorageManager) totalCapacityQ( rangeObjs []db.IStandaloneModel, hostTypes []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, - scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, storageOwnership bool, policyResult rbacutils.SPolicyResult, @@ -1060,8 +1061,8 @@ func (manager *SStorageManager) totalCapacityQ( if storageOwnership { switch scope { - case rbacutils.ScopeSystem: - case rbacutils.ScopeDomain, rbacutils.ScopeProject: + case rbacscope.ScopeSystem: + case rbacscope.ScopeDomain, rbacscope.ScopeProject: sq = sq.Equals("domain_id", ownerId.GetProjectDomainId()) } } @@ -1215,7 +1216,7 @@ func (manager *SStorageManager) TotalCapacity( hostTypes []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, storageOwnership bool, diff --git a/pkg/compute/models/tablestores.go b/pkg/compute/models/tablestores.go index 197e5b1a46..97c1185d77 100644 --- a/pkg/compute/models/tablestores.go +++ b/pkg/compute/models/tablestores.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -31,7 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -346,7 +346,7 @@ func (manager *STablestoreManager) ListItemExportKeys(ctx context.Context, return q, nil } -func (manager *STablestoreManager) AllowScope(userCred mcclient.TokenCredential) rbacutils.TRbacScope { +func (manager *STablestoreManager) AllowScope(userCred mcclient.TokenCredential) rbacscope.TRbacScope { scope, _ := policy.PolicyManager.AllowScope(userCred, api.SERVICE_TYPE, TablestoreManager.KeywordPlural(), policy.PolicyActionGet) return scope } diff --git a/pkg/compute/models/vpcs.go b/pkg/compute/models/vpcs.go index faa451dc82..88d51de134 100644 --- a/pkg/compute/models/vpcs.go +++ b/pkg/compute/models/vpcs.go @@ -28,6 +28,7 @@ import ( "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/compare" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -43,7 +44,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -660,7 +660,7 @@ func (manager *SVpcManager) InitializeData() error { defVpc.Status = api.VPC_STATUS_AVAILABLE defVpc.IsDefault = true defVpc.IsPublic = true - defVpc.PublicScope = string(rbacutils.ScopeSystem) + defVpc.PublicScope = string(rbacscope.ScopeSystem) err = manager.TableSpec().Insert(context.TODO(), &defVpc) if err != nil { log.Errorf("Insert default vpc fail: %s", err) @@ -671,7 +671,7 @@ func (manager *SVpcManager) InitializeData() error { } } else { vpc := vpcObj.(*SVpc) - if vpc.Status != api.VPC_STATUS_AVAILABLE || (vpc.PublicScope == string(rbacutils.ScopeSystem) && !vpc.IsPublic) { + if vpc.Status != api.VPC_STATUS_AVAILABLE || (vpc.PublicScope == string(rbacscope.ScopeSystem) && !vpc.IsPublic) { _, err = db.Update(vpc, func() error { vpc.Status = api.VPC_STATUS_AVAILABLE vpc.IsPublic = true @@ -1319,7 +1319,7 @@ func GetVpcQuotaKeysFromCreateInput(owner mcclient.IIdentityProvider, input api. if len(input.CloudproviderId) > 0 { provider = CloudproviderManager.FetchCloudproviderById(input.CloudproviderId) } - regionKeys := fetchRegionalQuotaKeys(rbacutils.ScopeDomain, ownerId, region, provider) + regionKeys := fetchRegionalQuotaKeys(rbacscope.ScopeDomain, ownerId, region, provider) keys := quotas.SDomainRegionalCloudResourceKeys{} keys.SBaseDomainQuotaKeys = regionKeys.SBaseDomainQuotaKeys keys.SRegionalBaseKeys = regionKeys.SRegionalBaseKeys @@ -1331,7 +1331,7 @@ func (vpc *SVpc) GetQuotaKeys() quotas.SDomainRegionalCloudResourceKeys { region, _ := vpc.GetRegion() manager := vpc.GetCloudprovider() ownerId := vpc.GetOwnerId() - regionKeys := fetchRegionalQuotaKeys(rbacutils.ScopeDomain, ownerId, region, manager) + regionKeys := fetchRegionalQuotaKeys(rbacscope.ScopeDomain, ownerId, region, manager) keys := quotas.SDomainRegionalCloudResourceKeys{} keys.SBaseDomainQuotaKeys = regionKeys.SBaseDomainQuotaKeys keys.SRegionalBaseKeys = regionKeys.SRegionalBaseKeys @@ -1353,7 +1353,7 @@ func (vpc *SVpc) GetUsages() []db.IUsage { func (manager *SVpcManager) totalCount( ownerId mcclient.IIdentityProvider, - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, rangeObjs []db.IStandaloneModel, providers []string, brands []string, @@ -1361,7 +1361,7 @@ func (manager *SVpcManager) totalCount( ) int { q := VpcManager.Query() - if scope != rbacutils.ScopeSystem && ownerId != nil { + if scope != rbacscope.ScopeSystem && ownerId != nil { q = q.Equals("domain_id", ownerId.GetProjectDomainId()) } q = CloudProviderFilter(q, q.Field("manager_id"), providers, brands, cloudEnv) @@ -1455,7 +1455,7 @@ func (manager *SVpcManager) ListItemExportKeys(ctx context.Context, } func (vpc *SVpc) PerformPublic(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformPublicDomainInput) (jsonutils.JSONObject, error) { - if vpc.Id == api.DEFAULT_VPC_ID && rbacutils.String2ScopeDefault(input.Scope, rbacutils.ScopeSystem) != rbacutils.ScopeSystem { + if vpc.Id == api.DEFAULT_VPC_ID && rbacscope.String2ScopeDefault(input.Scope, rbacscope.ScopeSystem) != rbacscope.ScopeSystem { return nil, httperrors.NewForbiddenError("For default vpc, only system level sharing can be set") } _, err := vpc.SEnabledStatusInfrasResourceBase.PerformPublic(ctx, userCred, query, input) @@ -1504,7 +1504,7 @@ func (vpc *SVpc) PerformPrivate(ctx context.Context, userCred mcclient.TokenCred wires, _ := vpc.GetWires() for i := range wires { if wires[i].DomainId == vpc.DomainId { - nets, _ := wires[i].getNetworks(nil, rbacutils.ScopeNone) + nets, _ := wires[i].getNetworks(nil, rbacscope.ScopeNone) for j := range nets { if nets[j].DomainId != vpc.DomainId { emptyNets = false @@ -1521,14 +1521,14 @@ func (vpc *SVpc) PerformPrivate(ctx context.Context, userCred mcclient.TokenCred } if emptyNets { for i := range wires { - nets, _ := wires[i].getNetworks(nil, rbacutils.ScopeNone) + nets, _ := wires[i].getNetworks(nil, rbacscope.ScopeNone) netfail := false for j := range nets { - if nets[j].IsPublic && nets[j].GetPublicScope().HigherEqual(rbacutils.ScopeDomain) { + if nets[j].IsPublic && nets[j].GetPublicScope().HigherEqual(rbacscope.ScopeDomain) { var err error if consts.GetNonDefaultDomainProjects() { netinput := apis.PerformPublicProjectInput{} - netinput.Scope = string(rbacutils.ScopeDomain) + netinput.Scope = string(rbacscope.ScopeDomain) _, err = nets[j].PerformPublic(ctx, userCred, nil, netinput) } else { _, err = nets[j].PerformPrivate(ctx, userCred, nil, input) @@ -1790,7 +1790,7 @@ func (self *SVpc) GetDetailsTopology(ctx context.Context, userCred mcclient.Toke } wire.Hosts = append(wire.Hosts, host) } - networks, err := wires[i].GetNetworks(nil, rbacutils.ScopeSystem) + networks, err := wires[i].GetNetworks(nil, rbacscope.ScopeSystem) if err != nil { return nil, errors.Wrapf(err, "GetNetworks") } @@ -1808,7 +1808,7 @@ func (self *SVpc) GetDetailsTopology(ctx context.Context, userCred mcclient.Toke netAddrs := make([]api.SNetworkUsedAddress, 0) - q := networks[j].getUsedAddressQuery(userCred, rbacutils.ScopeSystem, false) + q := networks[j].getUsedAddressQuery(userCred, rbacscope.ScopeSystem, false) err = q.All(&netAddrs) if err != nil { return nil, errors.Wrapf(err, "q.All") diff --git a/pkg/compute/models/waf_rules.go b/pkg/compute/models/waf_rules.go index af6d5c93b5..add7a5172b 100644 --- a/pkg/compute/models/waf_rules.go +++ b/pkg/compute/models/waf_rules.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -30,7 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/validators" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -116,7 +116,7 @@ func (manager *SWafRuleManager) FetchOwnerId(ctx context.Context, data jsonutils return db.FetchDomainInfo(ctx, data) } -func (manager *SWafRuleManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SWafRuleManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { sq1 := WafInstanceManager.Query("id") sq1 = db.SharableManagerFilterByOwner(WafInstanceManager, sq1, userCred, scope) sq2 := WafRuleGroupManager.Query("id") @@ -295,8 +295,8 @@ func (self *SWafRule) GetOwnerId() mcclient.IIdentityProvider { return nil } -func (manager *SWafRuleManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SWafRuleManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SWafInstance) GetWafRules() ([]SWafRule, error) { diff --git a/pkg/compute/models/wires.go b/pkg/compute/models/wires.go index c69203efa8..9c57a5ead3 100644 --- a/pkg/compute/models/wires.go +++ b/pkg/compute/models/wires.go @@ -28,6 +28,7 @@ import ( "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/compare" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/sets" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -414,7 +415,7 @@ func (self *SWire) syncWithCloudWire(ctx context.Context, userCred mcclient.Toke } func (self *SWire) markNetworkUnknown(userCred mcclient.TokenCredential) error { - nets, err := self.getNetworks(nil, rbacutils.ScopeNone) + nets, err := self.getNetworks(nil, rbacscope.ScopeNone) if err != nil { return err } @@ -480,12 +481,12 @@ func (manager *SWireManager) newFromCloudWire(ctx context.Context, userCred mccl return &wire, nil } -func filterByScopeOwnerId(q *sqlchemy.SQuery, scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, domainResource bool) *sqlchemy.SQuery { +func filterByScopeOwnerId(q *sqlchemy.SQuery, scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, domainResource bool) *sqlchemy.SQuery { switch scope { - case rbacutils.ScopeSystem: - case rbacutils.ScopeDomain: + case rbacscope.ScopeSystem: + case rbacscope.ScopeDomain: q = q.Equals("domain_id", ownerId.GetProjectDomainId()) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: if domainResource { q = q.Equals("domain_id", ownerId.GetProjectId()) } else { @@ -519,7 +520,7 @@ func (manager *SWireManager) totalCountQ( rangeObjs []db.IStandaloneModel, hostTypes []string, hostProviders, hostBrands []string, providers []string, brands []string, cloudEnv string, - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, policyResult rbacutils.SPolicyResult, ) *sqlchemy.SQuery { @@ -689,7 +690,7 @@ func (manager *SWireManager) totalCountQ2( rangeObjs []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, policyResult rbacutils.SPolicyResult, ) *sqlchemy.SQuery { @@ -726,7 +727,7 @@ func (manager *SWireManager) totalCountQ3( rangeObjs []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, policyResult rbacutils.SPolicyResult, ) *sqlchemy.SQuery { @@ -787,7 +788,7 @@ func (manager *SWireManager) TotalCount( rangeObjs []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, policyResult rbacutils.SPolicyResult, ) WiresCountStat { @@ -852,7 +853,7 @@ func (manager *SWireManager) TotalCount( return stat } -func (self *SWire) getNetworkQuery(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (self *SWire) getNetworkQuery(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { q := NetworkManager.Query().Equals("wire_id", self.Id) if ownerId != nil { q = NetworkManager.FilterByOwner(q, ownerId, scope) @@ -860,11 +861,11 @@ func (self *SWire) getNetworkQuery(ownerId mcclient.IIdentityProvider, scope rba return q } -func (self *SWire) GetNetworks(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope) ([]SNetwork, error) { +func (self *SWire) GetNetworks(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope) ([]SNetwork, error) { return self.getNetworks(ownerId, scope) } -func (self *SWire) getNetworks(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope) ([]SNetwork, error) { +func (self *SWire) getNetworks(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope) ([]SNetwork, error) { q := self.getNetworkQuery(ownerId, scope) nets := make([]SNetwork, 0) err := db.FetchModelObjects(NetworkManager, q, &nets) @@ -874,14 +875,14 @@ func (self *SWire) getNetworks(ownerId mcclient.IIdentityProvider, scope rbacuti return nets, nil } -func (self *SWire) getGatewayNetworkQuery(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (self *SWire) getGatewayNetworkQuery(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { q := self.getNetworkQuery(ownerId, scope) q = q.IsNotNull("guest_gateway").IsNotEmpty("guest_gateway") q = q.Equals("status", api.NETWORK_STATUS_AVAILABLE) return q } -func (self *SWire) getAutoAllocNetworks(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope) ([]SNetwork, error) { +func (self *SWire) getAutoAllocNetworks(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope) ([]SNetwork, error) { q := self.getGatewayNetworkQuery(ownerId, scope) q = q.IsTrue("is_auto_alloc") nets := make([]SNetwork, 0) @@ -892,7 +893,7 @@ func (self *SWire) getAutoAllocNetworks(ownerId mcclient.IIdentityProvider, scop return nets, nil } -func (self *SWire) getPublicNetworks(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope) ([]SNetwork, error) { +func (self *SWire) getPublicNetworks(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope) ([]SNetwork, error) { q := self.getGatewayNetworkQuery(ownerId, scope) q = q.IsTrue("is_public") nets := make([]SNetwork, 0) @@ -903,7 +904,7 @@ func (self *SWire) getPublicNetworks(ownerId mcclient.IIdentityProvider, scope r return nets, nil } -func (self *SWire) getPrivateNetworks(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope) ([]SNetwork, error) { +func (self *SWire) getPrivateNetworks(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope) ([]SNetwork, error) { q := self.getGatewayNetworkQuery(ownerId, scope) q = q.IsFalse("is_public") nets := make([]SNetwork, 0) @@ -914,7 +915,7 @@ func (self *SWire) getPrivateNetworks(ownerId mcclient.IIdentityProvider, scope return nets, nil } -func (self *SWire) GetCandidatePrivateNetwork(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope, isExit bool, serverTypes []string) (*SNetwork, error) { +func (self *SWire) GetCandidatePrivateNetwork(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope, isExit bool, serverTypes []string) (*SNetwork, error) { nets, err := self.getPrivateNetworks(ownerId, scope) if err != nil { return nil, err @@ -922,7 +923,7 @@ func (self *SWire) GetCandidatePrivateNetwork(ownerId mcclient.IIdentityProvider return ChooseCandidateNetworks(nets, isExit, serverTypes), nil } -func (self *SWire) GetCandidateAutoAllocNetwork(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope, isExit bool, serverTypes []string) (*SNetwork, error) { +func (self *SWire) GetCandidateAutoAllocNetwork(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope, isExit bool, serverTypes []string) (*SNetwork, error) { nets, err := self.getAutoAllocNetworks(ownerId, scope) if err != nil { return nil, err @@ -930,7 +931,7 @@ func (self *SWire) GetCandidateAutoAllocNetwork(ownerId mcclient.IIdentityProvid return ChooseCandidateNetworks(nets, isExit, serverTypes), nil } -func (self *SWire) GetCandidateNetworkForIp(ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope, ipAddr string) (*SNetwork, error) { +func (self *SWire) GetCandidateNetworkForIp(ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope, ipAddr string) (*SNetwork, error) { ip, err := netutils.NewIPV4Addr(ipAddr) if err != nil { return nil, err @@ -1454,10 +1455,10 @@ func (self *SWire) IsManaged() bool { func (model *SWire) CustomizeCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) error { if !data.Contains("public_scope") { vpc, _ := model.GetVpc() - if !model.IsManaged() && db.IsAdminAllowPerform(ctx, userCred, model, "public") && ownerId.GetProjectDomainId() == userCred.GetProjectDomainId() && vpc != nil && vpc.IsPublic && vpc.PublicScope == string(rbacutils.ScopeSystem) { - model.SetShare(rbacutils.ScopeSystem) + if !model.IsManaged() && db.IsAdminAllowPerform(ctx, userCred, model, "public") && ownerId.GetProjectDomainId() == userCred.GetProjectDomainId() && vpc != nil && vpc.IsPublic && vpc.PublicScope == string(rbacscope.ScopeSystem) { + model.SetShare(rbacscope.ScopeSystem) } else { - model.SetShare(rbacutils.ScopeNone) + model.SetShare(rbacscope.ScopeNone) } data.(*jsonutils.JSONDict).Set("public_scope", jsonutils.NewString(model.PublicScope)) } @@ -1490,7 +1491,7 @@ func (wire *SWire) GetChangeOwnerCandidateDomainIds() []string { func (wire *SWire) GetChangeOwnerRequiredDomainIds() []string { requires := stringutils2.SSortedStrings{} - networks, _ := wire.getNetworks(nil, rbacutils.ScopeNone) + networks, _ := wire.getNetworks(nil, rbacscope.ScopeNone) for i := range networks { requires = stringutils2.Append(requires, networks[i].DomainId) } @@ -1498,7 +1499,7 @@ func (wire *SWire) GetChangeOwnerRequiredDomainIds() []string { } func (wire *SWire) GetRequiredSharedDomainIds() []string { - networks, _ := wire.getNetworks(nil, rbacutils.ScopeNone) + networks, _ := wire.getNetworks(nil, rbacscope.ScopeNone) if len(networks) == 0 { return wire.SInfrasResourceBase.GetRequiredSharedDomainIds() } @@ -1582,7 +1583,7 @@ func (self *SWire) GetDetailsTopology(ctx context.Context, userCred mcclient.Tok } ret.Hosts = append(ret.Hosts, host) } - networks, err := self.GetNetworks(nil, rbacutils.ScopeSystem) + networks, err := self.GetNetworks(nil, rbacscope.ScopeSystem) if err != nil { return nil, errors.Wrapf(err, "GetNetworks") } @@ -1600,7 +1601,7 @@ func (self *SWire) GetDetailsTopology(ctx context.Context, userCred mcclient.Tok netAddrs := make([]api.SNetworkUsedAddress, 0) - q := networks[j].getUsedAddressQuery(userCred, rbacutils.ScopeSystem, false) + q := networks[j].getUsedAddressQuery(userCred, rbacscope.ScopeSystem, false) err = q.All(&netAddrs) if err != nil { return nil, errors.Wrapf(err, "q.All") diff --git a/pkg/compute/models/zonequota.go b/pkg/compute/models/zonequota.go index 9b8f2f6c33..843fed0796 100644 --- a/pkg/compute/models/zonequota.go +++ b/pkg/compute/models/zonequota.go @@ -18,9 +18,9 @@ import ( "context" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) var ( @@ -35,7 +35,7 @@ func init() { ZoneUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(ZoneQuota, - rbacutils.ScopeDomain, + rbacscope.ScopeDomain, "zone_quota_usage_tbl", "zone_quota_usage", "zone_quota_usages", @@ -43,7 +43,7 @@ func init() { } ZonePendingUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(ZoneQuota, - rbacutils.ScopeDomain, + rbacscope.ScopeDomain, "zone_quota_pending_usage_tbl", "zone_quota_pending_usage", "zone_quota_pending_usages", @@ -51,7 +51,7 @@ func init() { } ZoneQuotaManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaBaseManager(ZoneQuota, - rbacutils.ScopeDomain, + rbacscope.ScopeDomain, "zone_quota_tbl", ZonePendingUsageManager, ZoneUsageManager, diff --git a/pkg/compute/models/zones.go b/pkg/compute/models/zones.go index b733d2b096..aa603df9bf 100644 --- a/pkg/compute/models/zones.go +++ b/pkg/compute/models/zones.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/compare" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -32,7 +33,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -138,7 +138,7 @@ func (zone *SZone) getStorageCount() (int, error) { } func (zone *SZone) getNetworkCount() (int, error) { - return getNetworkCount(nil, rbacutils.ScopeSystem, nil, zone) + return getNetworkCount(nil, rbacscope.ScopeSystem, nil, zone) } func (manager *SZoneManager) FetchCustomizeColumns( diff --git a/pkg/compute/policy/defaults.go b/pkg/compute/policy/defaults.go index e054f37ea5..905ec2ad20 100644 --- a/pkg/compute/policy/defaults.go +++ b/pkg/compute/policy/defaults.go @@ -15,6 +15,8 @@ package policy import ( + "yunion.io/x/pkg/util/rbacscope" + api "yunion.io/x/onecloud/pkg/apis/compute" common_policy "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/util/rbacutils" @@ -33,7 +35,7 @@ var ( predefinedDefaultPolicies = []rbacutils.SRbacPolicy{ { Auth: true, - Scope: rbacutils.ScopeSystem, + Scope: rbacscope.ScopeSystem, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -178,7 +180,7 @@ var ( }, { Auth: true, - Scope: rbacutils.ScopeUser, + Scope: rbacscope.ScopeUser, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -214,7 +216,7 @@ var ( }, { Auth: true, - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -340,7 +342,7 @@ var ( }, { Auth: true, - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, diff --git a/pkg/compute/regiondrivers/aliyun.go b/pkg/compute/regiondrivers/aliyun.go index 0e3a9c18bd..c2164858ac 100644 --- a/pkg/compute/regiondrivers/aliyun.go +++ b/pkg/compute/regiondrivers/aliyun.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/regutils" "yunion.io/x/pkg/util/secrules" "yunion.io/x/pkg/utils" @@ -36,7 +37,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/choices" "yunion.io/x/onecloud/pkg/util/seclib2" ) diff --git a/pkg/compute/regiondrivers/aws.go b/pkg/compute/regiondrivers/aws.go index 5c4a250ea7..715af4a03f 100644 --- a/pkg/compute/regiondrivers/aws.go +++ b/pkg/compute/regiondrivers/aws.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/pinyinutils" "yunion.io/x/pkg/util/secrules" "yunion.io/x/pkg/utils" @@ -34,7 +35,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/pinyinutils" "yunion.io/x/onecloud/pkg/util/seclib2" ) diff --git a/pkg/compute/regiondrivers/azure.go b/pkg/compute/regiondrivers/azure.go index 2738e04865..f666b4050a 100644 --- a/pkg/compute/regiondrivers/azure.go +++ b/pkg/compute/regiondrivers/azure.go @@ -19,6 +19,7 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/pinyinutils" "yunion.io/x/pkg/util/secrules" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -26,7 +27,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/pinyinutils" ) type SAzureRegionDriver struct { diff --git a/pkg/compute/regiondrivers/base.go b/pkg/compute/regiondrivers/base.go index 3451bf6fc8..c13d4b84d4 100644 --- a/pkg/compute/regiondrivers/base.go +++ b/pkg/compute/regiondrivers/base.go @@ -22,6 +22,9 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/pinyinutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/secrules" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -30,9 +33,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/pinyinutils" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SBaseRegionDriver struct { @@ -265,8 +265,8 @@ func (self *SBaseRegionDriver) GetDefaultSecurityGroupVpcId() string { return api.NORMAL_VPC_ID } -func (self *SBaseRegionDriver) GetSecurityGroupPublicScope(service string) rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (self *SBaseRegionDriver) GetSecurityGroupPublicScope(service string) rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (self *SBaseRegionDriver) GetSecurityGroupVpcId(ctx context.Context, userCred mcclient.TokenCredential, region *models.SCloudregion, host *models.SHost, vpc *models.SVpc, classic bool) (string, error) { diff --git a/pkg/compute/regiondrivers/ecloud.go b/pkg/compute/regiondrivers/ecloud.go index da0f95698c..42f7428249 100644 --- a/pkg/compute/regiondrivers/ecloud.go +++ b/pkg/compute/regiondrivers/ecloud.go @@ -15,9 +15,10 @@ package regiondrivers import ( + "yunion.io/x/pkg/util/pinyinutils" + api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/compute/models" - "yunion.io/x/onecloud/pkg/util/pinyinutils" ) type SEcloudRegionDriver struct { diff --git a/pkg/compute/regiondrivers/google.go b/pkg/compute/regiondrivers/google.go index 7027a111cb..08ea3f8a05 100644 --- a/pkg/compute/regiondrivers/google.go +++ b/pkg/compute/regiondrivers/google.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/pinyinutils" "yunion.io/x/pkg/util/secrules" billing_api "yunion.io/x/onecloud/pkg/apis/billing" @@ -33,7 +34,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/pinyinutils" ) type SGoogleRegionDriver struct { diff --git a/pkg/compute/regiondrivers/huawei.go b/pkg/compute/regiondrivers/huawei.go index 6fdcb4e578..e9b407fc80 100644 --- a/pkg/compute/regiondrivers/huawei.go +++ b/pkg/compute/regiondrivers/huawei.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/secrules" "yunion.io/x/pkg/utils" @@ -32,7 +33,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" ) type SHuaWeiRegionDriver struct { diff --git a/pkg/compute/regiondrivers/kvm.go b/pkg/compute/regiondrivers/kvm.go index 4c17fe5ad7..83c6330e2a 100644 --- a/pkg/compute/regiondrivers/kvm.go +++ b/pkg/compute/regiondrivers/kvm.go @@ -25,6 +25,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + randutil "yunion.io/x/pkg/util/rand" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -39,8 +41,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" - randutil "yunion.io/x/onecloud/pkg/util/rand" ) type SKVMRegionDriver struct { diff --git a/pkg/compute/regiondrivers/managedvirtual.go b/pkg/compute/regiondrivers/managedvirtual.go index abc17b9458..c18db3fef4 100644 --- a/pkg/compute/regiondrivers/managedvirtual.go +++ b/pkg/compute/regiondrivers/managedvirtual.go @@ -25,7 +25,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/pinyinutils" + "yunion.io/x/pkg/util/rand" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" billing_api "yunion.io/x/onecloud/pkg/apis/billing" @@ -37,11 +41,7 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/pinyinutils" - "yunion.io/x/onecloud/pkg/util/rand" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/seclib2" ) @@ -1424,7 +1424,7 @@ func (self *SManagedVirtualizationRegionDriver) RequestSyncSecurityGroup(ctx con return "", errors.Wrap(err, "vpc.GetRegon") } - if region.GetDriver().GetSecurityGroupPublicScope(service) == rbacutils.ScopeSystem { + if region.GetDriver().GetSecurityGroupPublicScope(service) == rbacscope.ScopeSystem { remoteProjectId = "" } diff --git a/pkg/compute/regiondrivers/openstack.go b/pkg/compute/regiondrivers/openstack.go index 3cf911347c..73c2a1bb80 100644 --- a/pkg/compute/regiondrivers/openstack.go +++ b/pkg/compute/regiondrivers/openstack.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/secrules" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -29,7 +30,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SOpenStackRegionDriver struct { @@ -72,8 +72,8 @@ func (self *SOpenStackRegionDriver) IsOnlySupportAllowRules() bool { return true } -func (self *SOpenStackRegionDriver) GetSecurityGroupPublicScope(service string) rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (self *SOpenStackRegionDriver) GetSecurityGroupPublicScope(service string) rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (self *SOpenStackRegionDriver) GetProvider() string { diff --git a/pkg/compute/regiondrivers/qcloud.go b/pkg/compute/regiondrivers/qcloud.go index 03ee1dbc2c..1644466aab 100644 --- a/pkg/compute/regiondrivers/qcloud.go +++ b/pkg/compute/regiondrivers/qcloud.go @@ -22,6 +22,8 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/secrules" "yunion.io/x/pkg/utils" @@ -32,9 +34,7 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/choices" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/seclib2" ) @@ -536,11 +536,11 @@ func (self *SQcloudRegionDriver) IsSupportedElasticcache() bool { return true } -func (self *SQcloudRegionDriver) GetSecurityGroupPublicScope(service string) rbacutils.TRbacScope { +func (self *SQcloudRegionDriver) GetSecurityGroupPublicScope(service string) rbacscope.TRbacScope { if service == "redis" { - return rbacutils.ScopeProject + return rbacscope.ScopeProject } - return rbacutils.ScopeSystem + return rbacscope.ScopeSystem } func (self *SQcloudRegionDriver) ValidateCreateElasticcacheAccountData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) { diff --git a/pkg/compute/specs/handler.go b/pkg/compute/specs/handler.go index 354772d74b..55f99a9ca6 100644 --- a/pkg/compute/specs/handler.go +++ b/pkg/compute/specs/handler.go @@ -22,10 +22,10 @@ import ( "strings" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/sets" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/policy" diff --git a/pkg/compute/sshkeys/handler.go b/pkg/compute/sshkeys/handler.go index ab20e0655f..c5c59f8f0c 100644 --- a/pkg/compute/sshkeys/handler.go +++ b/pkg/compute/sshkeys/handler.go @@ -21,8 +21,9 @@ import ( "net/http" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/appctx" + "yunion.io/x/pkg/util/rbacscope" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/cloudcommon/db" @@ -30,7 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) func AddSshKeysHandler(prefix string, app *appsrv.Application) { @@ -41,7 +41,7 @@ func AddSshKeysHandler(prefix string, app *appsrv.Application) { func adminSshKeysHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) { publicOnly := false userCred := auth.FetchUserCredential(ctx, policy.FilterPolicyCredential) - if !userCred.IsAllow(rbacutils.ScopeDomain, consts.GetServiceType(), "sshkeypairs", policy.PolicyActionGet).Result.IsAllow() { + if !userCred.IsAllow(rbacscope.ScopeDomain, consts.GetServiceType(), "sshkeypairs", policy.PolicyActionGet).Result.IsAllow() { publicOnly = true } params := appctx.AppContextParams(ctx) @@ -85,7 +85,7 @@ func sshKeysHandler(ctx context.Context, w http.ResponseWriter, r *http.Request) func sendSshKey(ctx context.Context, w http.ResponseWriter, userCred mcclient.TokenCredential, projectId string, isAdmin bool, publicOnly bool) { var privKey, pubKey string - if isAdmin && userCred.IsAllow(rbacutils.ScopeSystem, consts.GetServiceType(), "sshkeypairs", policy.PolicyActionGet).Result.IsAllow() { + if isAdmin && userCred.IsAllow(rbacscope.ScopeSystem, consts.GetServiceType(), "sshkeypairs", policy.PolicyActionGet).Result.IsAllow() { privKey, pubKey, _ = GetSshAdminKeypair(ctx) } else { privKey, pubKey, _ = GetSshProjectKeypair(ctx, projectId) diff --git a/pkg/compute/storagedrivers/rbd.go b/pkg/compute/storagedrivers/rbd.go index a6f76e5341..bf6606ed90 100644 --- a/pkg/compute/storagedrivers/rbd.go +++ b/pkg/compute/storagedrivers/rbd.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" @@ -30,7 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SRbdStorageDriver struct { diff --git a/pkg/compute/tasks/baremetal_delete_task.go b/pkg/compute/tasks/baremetal_delete_task.go index 9f4087dcd9..d5c092d351 100644 --- a/pkg/compute/tasks/baremetal_delete_task.go +++ b/pkg/compute/tasks/baremetal_delete_task.go @@ -20,12 +20,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/compute/models" - "yunion.io/x/onecloud/pkg/util/httputils" ) type BaremetalDeleteTask struct { diff --git a/pkg/compute/tasks/cloud_account_sync_vmware_net.go b/pkg/compute/tasks/cloud_account_sync_vmware_net.go index e0a341d839..94c3654743 100644 --- a/pkg/compute/tasks/cloud_account_sync_vmware_net.go +++ b/pkg/compute/tasks/cloud_account_sync_vmware_net.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" @@ -31,7 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/compute/options" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type CloudAccountSyncVMwareNetworkTask struct { @@ -285,7 +285,7 @@ func (self *CloudAccountSyncVMwareNetworkTask) createNetwork(ctx context.Context network.ServerType = networkType network.IsPublic = true network.Status = api.NETWORK_STATUS_AVAILABLE - network.PublicScope = string(rbacutils.ScopeDomain) + network.PublicScope = string(rbacscope.ScopeDomain) network.ProjectId = cloudaccount.ProjectId network.DomainId = cloudaccount.DomainId network.Description = net.Description @@ -333,7 +333,7 @@ func (self *CloudAccountSyncVMwareNetworkTask) ipPool(cloudaccount *models.SClou } } else { for _, wire := range wires { - nets, err := wire.GetNetworks(cloudaccount.GetOwnerId(), rbacutils.ScopeDomain) + nets, err := wire.GetNetworks(cloudaccount.GetOwnerId(), rbacscope.ScopeDomain) if err != nil { return nil, errors.Wrapf(err, "unable to fetch networks of wire %s", wire.GetId()) } @@ -372,7 +372,7 @@ func (self *CloudAccountSyncVMwareNetworkTask) zoneId() (string, error) { func (self *CloudAccountSyncVMwareNetworkTask) fetchWires(cloudaccount *models.SCloudaccount, zoneId string) (map[string]*models.SWire, error) { q := models.WireManager.Query().Equals("zone_id", zoneId) - q = models.WireManager.FilterByOwner(q, cloudaccount.GetOwnerId(), rbacutils.ScopeDomain) + q = models.WireManager.FilterByOwner(q, cloudaccount.GetOwnerId(), rbacscope.ScopeDomain) wires := make([]models.SWire, 0, 1) err := db.FetchModelObjects(models.WireManager, q, &wires) if err != nil { diff --git a/pkg/compute/tasks/dbinstance_renew_task.go b/pkg/compute/tasks/dbinstance_renew_task.go index 3230afdad1..746175af0a 100644 --- a/pkg/compute/tasks/dbinstance_renew_task.go +++ b/pkg/compute/tasks/dbinstance_renew_task.go @@ -22,12 +22,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/compute/models" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/logclient" ) diff --git a/pkg/compute/tasks/dbinstance_set_auto_renew_task.go b/pkg/compute/tasks/dbinstance_set_auto_renew_task.go index 828f0b9a92..d4a8c09bad 100644 --- a/pkg/compute/tasks/dbinstance_set_auto_renew_task.go +++ b/pkg/compute/tasks/dbinstance_set_auto_renew_task.go @@ -19,12 +19,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/compute/models" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/logclient" ) diff --git a/pkg/compute/tasks/disk_backup_create_task.go b/pkg/compute/tasks/disk_backup_create_task.go index 6d020eab4b..333e5c9e9f 100644 --- a/pkg/compute/tasks/disk_backup_create_task.go +++ b/pkg/compute/tasks/disk_backup_create_task.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rand" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" @@ -29,7 +30,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/notifyclient" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rand" ) type DiskBackupCreateTask struct { diff --git a/pkg/compute/tasks/elasticcache_renew_task.go b/pkg/compute/tasks/elasticcache_renew_task.go index a144149f28..c2a4b09b07 100644 --- a/pkg/compute/tasks/elasticcache_renew_task.go +++ b/pkg/compute/tasks/elasticcache_renew_task.go @@ -20,12 +20,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/billing" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/compute/models" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/logclient" ) diff --git a/pkg/compute/tasks/guest_convert_esxi_to_kvm_task.go b/pkg/compute/tasks/guest_convert_esxi_to_kvm_task.go index 305a0a669b..56b564c0b5 100644 --- a/pkg/compute/tasks/guest_convert_esxi_to_kvm_task.go +++ b/pkg/compute/tasks/guest_convert_esxi_to_kvm_task.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -27,7 +28,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/compute/models" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" ) diff --git a/pkg/compute/tasks/guest_create_task.go b/pkg/compute/tasks/guest_create_task.go index 00c268fcc8..017257c0a8 100644 --- a/pkg/compute/tasks/guest_create_task.go +++ b/pkg/compute/tasks/guest_create_task.go @@ -22,13 +22,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/cloudcommon/notifyclient" "yunion.io/x/onecloud/pkg/compute/models" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/logclient" ) diff --git a/pkg/compute/tasks/guest_delete_backup_task.go b/pkg/compute/tasks/guest_delete_backup_task.go index d50a3f13a3..1023e4b67c 100644 --- a/pkg/compute/tasks/guest_delete_backup_task.go +++ b/pkg/compute/tasks/guest_delete_backup_task.go @@ -19,13 +19,13 @@ import ( "fmt" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/cloudcommon/notifyclient" "yunion.io/x/onecloud/pkg/compute/models" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" ) diff --git a/pkg/compute/tasks/guest_live_migrate_task.go b/pkg/compute/tasks/guest_live_migrate_task.go index a2c8f4e7c4..16027ba513 100644 --- a/pkg/compute/tasks/guest_live_migrate_task.go +++ b/pkg/compute/tasks/guest_live_migrate_task.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -28,7 +29,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/cloudcommon/notifyclient" "yunion.io/x/onecloud/pkg/compute/models" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" ) diff --git a/pkg/compute/tasks/guest_renew_task.go b/pkg/compute/tasks/guest_renew_task.go index 155bd07c4c..39eef86143 100644 --- a/pkg/compute/tasks/guest_renew_task.go +++ b/pkg/compute/tasks/guest_renew_task.go @@ -20,12 +20,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/billing" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/compute/models" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/logclient" ) diff --git a/pkg/compute/tasks/guest_undeploy_task.go b/pkg/compute/tasks/guest_undeploy_task.go index 13c5a30045..af3cffcda6 100644 --- a/pkg/compute/tasks/guest_undeploy_task.go +++ b/pkg/compute/tasks/guest_undeploy_task.go @@ -18,11 +18,11 @@ import ( "context" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/compute/models" - "yunion.io/x/onecloud/pkg/util/httputils" ) type GuestUndeployTask struct { diff --git a/pkg/compute/tasks/nat_create_task.go b/pkg/compute/tasks/nat_create_task.go index b56c9221d2..7eb06e34a2 100644 --- a/pkg/compute/tasks/nat_create_task.go +++ b/pkg/compute/tasks/nat_create_task.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" billing_api "yunion.io/x/onecloud/pkg/apis/billing" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -28,7 +29,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/cloudcommon/notifyclient" "yunion.io/x/onecloud/pkg/compute/models" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/logclient" ) diff --git a/pkg/compute/tasks/nat_renew_task.go b/pkg/compute/tasks/nat_renew_task.go index a60faa7c24..1afc62c6f2 100644 --- a/pkg/compute/tasks/nat_renew_task.go +++ b/pkg/compute/tasks/nat_renew_task.go @@ -22,12 +22,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/compute/models" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/logclient" ) diff --git a/pkg/compute/tasks/nat_set_auto_renew_task.go b/pkg/compute/tasks/nat_set_auto_renew_task.go index e0266895f1..257ee97bfa 100644 --- a/pkg/compute/tasks/nat_set_auto_renew_task.go +++ b/pkg/compute/tasks/nat_set_auto_renew_task.go @@ -19,12 +19,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/compute/models" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/onecloud/pkg/util/logclient" ) diff --git a/pkg/compute/tasks/networks_under_wire_merge_task.go b/pkg/compute/tasks/networks_under_wire_merge_task.go index 23248cd351..f22b38fa0e 100644 --- a/pkg/compute/tasks/networks_under_wire_merge_task.go +++ b/pkg/compute/tasks/networks_under_wire_merge_task.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" @@ -29,7 +30,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type NetworksUnderWireMergeTask struct { @@ -71,7 +71,7 @@ func (self *NetworksUnderWireMergeTask) OnInit(ctx context.Context, obj db.IStan lockman.LockClass(ctx, models.NetworkManager, db.GetLockClassKey(models.NetworkManager, self.UserCred)) defer lockman.ReleaseClass(ctx, models.NetworkManager, db.GetLockClassKey(models.NetworkManager, self.UserCred)) - networks, err := w.GetNetworks(self.UserCred, rbacutils.ScopeDomain) + networks, err := w.GetNetworks(self.UserCred, rbacscope.ScopeDomain) if err != nil { self.taskFailed(ctx, w, "unable to GetNetworks", err) return diff --git a/pkg/compute/tasks/storage_update_task.go b/pkg/compute/tasks/storage_update_task.go index b4d33ae772..e860648a9e 100644 --- a/pkg/compute/tasks/storage_update_task.go +++ b/pkg/compute/tasks/storage_update_task.go @@ -20,12 +20,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" ) func init() { diff --git a/pkg/compute/usages/cache.go b/pkg/compute/usages/cache.go index d47123590c..2633036bd1 100644 --- a/pkg/compute/usages/cache.go +++ b/pkg/compute/usages/cache.go @@ -18,11 +18,11 @@ import ( "time" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/hashcache" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/tagutils" ) @@ -31,7 +31,7 @@ var ( ) func getCacheKey( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, rangeObjs []db.IStandaloneModel, @@ -47,7 +47,7 @@ func getCacheKey( Id string `json:"id"` } type KeyStruct struct { - Scope rbacutils.TRbacScope `json:"scope"` + Scope rbacscope.TRbacScope `json:"scope"` Domain string `json:"domain"` Project string `json:"project"` IsOwner bool `json:"is_owner"` @@ -62,10 +62,10 @@ func getCacheKey( key := KeyStruct{} key.Scope = scope switch scope { - case rbacutils.ScopeSystem: - case rbacutils.ScopeDomain: + case rbacscope.ScopeSystem: + case rbacscope.ScopeDomain: key.Domain = userCred.GetProjectDomainId() - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: key.Project = userCred.GetProjectId() } if isOwner { diff --git a/pkg/compute/usages/handler.go b/pkg/compute/usages/handler.go index 1e7faf6ded..33196ea8b9 100644 --- a/pkg/compute/usages/handler.go +++ b/pkg/compute/usages/handler.go @@ -22,13 +22,14 @@ import ( json "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/sets" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/policy" @@ -65,7 +66,7 @@ func (u Usage) Include(nus ...Usage) Usage { return u } -type objUsageFunc func(rbacutils.TRbacScope, mcclient.IIdentityProvider, bool, []db.IStandaloneModel, []string, []string, []string, string, bool, rbacutils.SPolicyResult) (Usage, error) +type objUsageFunc func(rbacscope.TRbacScope, mcclient.IIdentityProvider, bool, []db.IStandaloneModel, []string, []string, []string, string, bool, rbacutils.SPolicyResult) (Usage, error) func getRangeObjId(ctx context.Context) (string, error) { params := appctx.AppContextParams(ctx) @@ -114,7 +115,7 @@ func rangeObjHandler( } result.ProjectTags = *projectTags isOwner := false - if scope == rbacutils.ScopeDomain && obj != nil && db.IsObjectRbacAllowed(ctx, obj, userCred, policy.PolicyActionGet, "usage") == nil { + if scope == rbacscope.ScopeDomain && obj != nil && db.IsObjectRbacAllowed(ctx, obj, userCred, policy.PolicyActionGet, "usage") == nil { isOwner = true } log.Debugf("ownerId: %s isOwner: %v scope: %s result: %s", ownerId, isOwner, scope, result.String()) @@ -189,31 +190,31 @@ func getQuery(r *http.Request) json.JSONObject { return query } -func ReportHostUsage(scope rbacutils.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, hosts []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) (Usage, error) { +func ReportHostUsage(scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, hosts []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) (Usage, error) { return ReportGeneralUsage(scope, userCred, isOwner, hosts, hostTypes, providers, brands, cloudEnv, includeSystem, policyResult) } -func ReportWireUsage(scope rbacutils.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, wires []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) (Usage, error) { +func ReportWireUsage(scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, wires []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) (Usage, error) { return ReportGeneralUsage(scope, userCred, isOwner, wires, hostTypes, providers, brands, cloudEnv, includeSystem, policyResult) } -func ReportCloudAccountUsage(scope rbacutils.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, accounts []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) (Usage, error) { +func ReportCloudAccountUsage(scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, accounts []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) (Usage, error) { return ReportGeneralUsage(scope, userCred, isOwner, accounts, hostTypes, providers, brands, cloudEnv, includeSystem, policyResult) } -func ReportCloudProviderUsage(scope rbacutils.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, managers []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) (Usage, error) { +func ReportCloudProviderUsage(scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, managers []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) (Usage, error) { return ReportGeneralUsage(scope, userCred, isOwner, managers, hostTypes, providers, brands, cloudEnv, includeSystem, policyResult) } -func ReportSchedtagUsage(scope rbacutils.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, schedtags []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) (Usage, error) { +func ReportSchedtagUsage(scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, schedtags []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) (Usage, error) { return ReportGeneralUsage(scope, userCred, isOwner, schedtags, hostTypes, providers, brands, cloudEnv, includeSystem, policyResult) } -func ReportZoneUsage(scope rbacutils.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, zones []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) (Usage, error) { +func ReportZoneUsage(scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, zones []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) (Usage, error) { return ReportGeneralUsage(scope, userCred, isOwner, zones, hostTypes, providers, brands, cloudEnv, includeSystem, policyResult) } -func ReportCloudRegionUsage(scope rbacutils.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, cloudRegions []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) (Usage, error) { +func ReportCloudRegionUsage(scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, cloudRegions []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) (Usage, error) { return ReportGeneralUsage(scope, userCred, isOwner, cloudRegions, hostTypes, providers, brands, cloudEnv, includeSystem, policyResult) } @@ -229,7 +230,7 @@ func getSystemGeneralUsage( var pmemTotal float64 var pcpuTotal float64 - hostEnabledUsage := HostEnabledUsage("", userCred, rbacutils.ScopeSystem, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, policyResult) + hostEnabledUsage := HostEnabledUsage("", userCred, rbacscope.ScopeSystem, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, policyResult) pmemTotal = float64(hostEnabledUsage.Get("enabled_hosts.memory").(int64)) pcpuTotal = float64(hostEnabledUsage.Get("enabled_hosts.cpu").(int64)) if len(rangeObjs) > 0 && rangeObjs[0].Keyword() == "host" { @@ -242,11 +243,11 @@ func getSystemGeneralUsage( count.Add("cpu.virtual", int64(host.GetVirtualCPUCount())) } - guestRunningUsage := GuestRunningUsage("all.running_servers", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, policyResult) + guestRunningUsage := GuestRunningUsage("all.running_servers", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, policyResult) runningMem := guestRunningUsage.Get("all.running_servers.memory").(int) runningCpu := guestRunningUsage.Get("all.running_servers.cpu").(int) - // containerRunningUsage := containerUsage("all.containers", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, nil, providers, brands, cloudEnv) + // containerRunningUsage := containerUsage("all.containers", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, nil, providers, brands, cloudEnv) // containerRunningMem := containerRunningUsage.Get("all.containers.memory").(int) // containerRunningCpu := containerRunningUsage.Get("all.containers.cpu").(int) // runningMem += containerRunningMem @@ -265,86 +266,86 @@ func getSystemGeneralUsage( lastWeek := time.Now().Add(-7 * 24 * time.Hour) lastMonth := time.Now().Add(-30 * 24 * time.Hour) count.Include( - VpcUsage("all", providers, brands, cloudEnv, nil, rbacutils.ScopeSystem, rangeObjs, policyResult), + VpcUsage("all", providers, brands, cloudEnv, nil, rbacscope.ScopeSystem, rangeObjs, policyResult), - DnsZoneUsage("", nil, rbacutils.ScopeSystem, policyResult), + DnsZoneUsage("", nil, rbacscope.ScopeSystem, policyResult), - HostAllUsage("", userCred, rbacutils.ScopeSystem, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, policyResult), - // HostAllUsage("prepaid_pool", userCred, rbacutils.ScopeSystem, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv), - // HostAllUsage("any_pool", userCred, rbacutils.ScopeSystem, rangeObjs, hostTypes, nil, providers, brands, cloudEnv), + HostAllUsage("", userCred, rbacscope.ScopeSystem, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, policyResult), + // HostAllUsage("prepaid_pool", userCred, rbacscope.ScopeSystem, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv), + // HostAllUsage("any_pool", userCred, rbacscope.ScopeSystem, rangeObjs, hostTypes, nil, providers, brands, cloudEnv), hostEnabledUsage, - // HostEnabledUsage("prepaid_pool", userCred, rbacutils.ScopeSystem, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv), - // HostEnabledUsage("any_pool", userCred, rbacutils.ScopeSystem, rangeObjs, hostTypes, nil, providers, brands, cloudEnv), + // HostEnabledUsage("prepaid_pool", userCred, rbacscope.ScopeSystem, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv), + // HostEnabledUsage("any_pool", userCred, rbacscope.ScopeSystem, rangeObjs, hostTypes, nil, providers, brands, cloudEnv), - BaremetalUsage(userCred, rbacutils.ScopeSystem, rangeObjs, hostTypes, providers, brands, cloudEnv, policyResult), + BaremetalUsage(userCred, rbacscope.ScopeSystem, rangeObjs, hostTypes, providers, brands, cloudEnv, policyResult), - StorageUsage("", rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, false, includeSystem, rbacutils.ScopeSystem, nil, policyResult), - StorageUsage("system", rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, false, true, rbacutils.ScopeSystem, nil, policyResult), - // StorageUsage("prepaid_pool", rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, false, includeSystem, rbacutils.ScopeSystem, nil), - // StorageUsage("any_pool", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, false, includeSystem, rbacutils.ScopeSystem, nil), - // StorageUsage("any_pool.system", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, false, true, rbacutils.ScopeSystem, nil), - // StorageUsage("any_pool.pending_delete", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, true, includeSystem, rbacutils.ScopeSystem, nil), - // StorageUsage("any_pool.pending_delete.system", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, true, true, rbacutils.ScopeSystem, nil), + StorageUsage("", rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, false, includeSystem, rbacscope.ScopeSystem, nil, policyResult), + StorageUsage("system", rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, false, true, rbacscope.ScopeSystem, nil, policyResult), + // StorageUsage("prepaid_pool", rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, false, includeSystem, rbacscope.ScopeSystem, nil), + // StorageUsage("any_pool", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, false, includeSystem, rbacscope.ScopeSystem, nil), + // StorageUsage("any_pool.system", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, false, true, rbacscope.ScopeSystem, nil), + // StorageUsage("any_pool.pending_delete", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, true, includeSystem, rbacscope.ScopeSystem, nil), + // StorageUsage("any_pool.pending_delete.system", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, true, true, rbacscope.ScopeSystem, nil), - GuestNormalUsage("all.servers", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, nil, policyResult), - GuestNormalUsage("all.servers.last_week", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, &lastWeek, policyResult), - GuestNormalUsage("all.servers.last_month", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, &lastMonth, policyResult), - // GuestNormalUsage("all.servers.prepaid_pool", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, includeSystem), - // GuestNormalUsage("all.servers.any_pool", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, nil, providers, brands, cloudEnv, includeSystem), + GuestNormalUsage("all.servers", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, nil, policyResult), + GuestNormalUsage("all.servers.last_week", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, &lastWeek, policyResult), + GuestNormalUsage("all.servers.last_month", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, &lastMonth, policyResult), + // GuestNormalUsage("all.servers.prepaid_pool", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, includeSystem), + // GuestNormalUsage("all.servers.any_pool", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, nil, providers, brands, cloudEnv, includeSystem), - GuestPendingDeleteUsage("all.pending_delete_servers", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, nil, policyResult), - GuestPendingDeleteUsage("all.pending_delete_servers.last_week", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, &lastWeek, policyResult), - GuestPendingDeleteUsage("all.pending_delete_servers.last_month", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, &lastMonth, policyResult), - // GuestPendingDeleteUsage("all.pending_delete_servers.prepaid_pool", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, includeSystem), - // GuestNormalUsage("all.servers.prepaid_pool", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, includeSystem), - // GuestNormalUsage("all.servers.any_pool", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, nil, providers, brands, cloudEnv, includeSystem), + GuestPendingDeleteUsage("all.pending_delete_servers", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, nil, policyResult), + GuestPendingDeleteUsage("all.pending_delete_servers.last_week", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, &lastWeek, policyResult), + GuestPendingDeleteUsage("all.pending_delete_servers.last_month", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, &lastMonth, policyResult), + // GuestPendingDeleteUsage("all.pending_delete_servers.prepaid_pool", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, includeSystem), + // GuestNormalUsage("all.servers.prepaid_pool", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, includeSystem), + // GuestNormalUsage("all.servers.any_pool", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, nil, providers, brands, cloudEnv, includeSystem), - // GuestPendingDeleteUsage("all.pending_delete_servers", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem), - // GuestPendingDeleteUsage("all.pending_delete_servers.prepaid_pool", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, includeSystem), - // GuestPendingDeleteUsage("all.pending_delete_servers.any_pool", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, nil, providers, brands, cloudEnv, includeSystem), + // GuestPendingDeleteUsage("all.pending_delete_servers", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem), + // GuestPendingDeleteUsage("all.pending_delete_servers.prepaid_pool", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, includeSystem), + // GuestPendingDeleteUsage("all.pending_delete_servers.any_pool", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, nil, providers, brands, cloudEnv, includeSystem), - GuestReadyUsage("all.ready_servers", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, policyResult), - // GuestReadyUsage("all.ready_servers.prepaid_pool", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, includeSystem), - // GuestReadyUsage("all.ready_servers.any_pool", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, nil, providers, brands, cloudEnv, includeSystem), - // GuestRunningUsage("all.running_servers.prepaid_pool", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, includeSystem), - // GuestRunningUsage("all.running_servers.any_pool", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, nil, providers, brands, cloudEnv, includeSystem), + GuestReadyUsage("all.ready_servers", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, includeSystem, policyResult), + // GuestReadyUsage("all.ready_servers.prepaid_pool", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, includeSystem), + // GuestReadyUsage("all.ready_servers.any_pool", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, nil, providers, brands, cloudEnv, includeSystem), + // GuestRunningUsage("all.running_servers.prepaid_pool", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, includeSystem), + // GuestRunningUsage("all.running_servers.any_pool", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, nil, providers, brands, cloudEnv, includeSystem), guestRunningUsage, // containerRunningUsage, - IsolatedDeviceUsage("", rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, policyResult), + IsolatedDeviceUsage("", rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, policyResult), // IsolatedDeviceUsage("prepaid_pool", rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv), // IsolatedDeviceUsage("any_pool", rangeObjs, hostTypes, nil, providers, brands, cloudEnv), - WireUsage(rbacutils.ScopeSystem, nil, rangeObjs, hostTypes, providers, brands, cloudEnv, policyResult), - NetworkUsage("all", rbacutils.ScopeSystem, nil, providers, brands, cloudEnv, rangeObjs, policyResult), + WireUsage(rbacscope.ScopeSystem, nil, rangeObjs, hostTypes, providers, brands, cloudEnv, policyResult), + NetworkUsage("all", rbacscope.ScopeSystem, nil, providers, brands, cloudEnv, rangeObjs, policyResult), - EipUsage(rbacutils.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), + EipUsage(rbacscope.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), - BucketUsage(rbacutils.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), + BucketUsage(rbacscope.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), - SnapshotUsage(rbacutils.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), + SnapshotUsage(rbacscope.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), - InstanceSnapshotUsage(rbacutils.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), + InstanceSnapshotUsage(rbacscope.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), - LoadbalancerUsage(rbacutils.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), + LoadbalancerUsage(rbacscope.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), - DBInstanceUsage(rbacutils.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), + DBInstanceUsage(rbacscope.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), - MongoDBUsage(rbacutils.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), + MongoDBUsage(rbacscope.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), - ElasticSearchUsage(rbacutils.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), + ElasticSearchUsage(rbacscope.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), - KafkaUsage(rbacutils.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), + KafkaUsage(rbacscope.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), - ElasticCacheUsage(rbacutils.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), + ElasticCacheUsage(rbacscope.ScopeSystem, nil, rangeObjs, providers, brands, cloudEnv, policyResult), ) return count, nil } -func getDomainGeneralUsage(scope rbacutils.TRbacScope, cred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) (Usage, error) { +func getDomainGeneralUsage(scope rbacscope.TRbacScope, cred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) (Usage, error) { lastWeek := time.Now().Add(-7 * 24 * time.Hour) lastMonth := time.Now().Add(-30 * 24 * time.Hour) count := GuestNormalUsage(getKey(scope, "servers"), scope, cred, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, false, nil, policyResult) @@ -352,11 +353,11 @@ func getDomainGeneralUsage(scope rbacutils.TRbacScope, cred mcclient.IIdentityPr var pmemTotal float64 var pcpuTotal float64 - hostEnabledUsage := HostEnabledUsage("", cred, rbacutils.ScopeDomain, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, policyResult) + hostEnabledUsage := HostEnabledUsage("", cred, rbacscope.ScopeDomain, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, policyResult) pmemTotal = float64(hostEnabledUsage.Get("domain.enabled_hosts.memory").(int64)) pcpuTotal = float64(hostEnabledUsage.Get("domain.enabled_hosts.cpu").(int64)) - guestRunningUsage := GuestRunningUsage("domain.running_servers", rbacutils.ScopeDomain, cred, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, false, policyResult) + guestRunningUsage := GuestRunningUsage("domain.running_servers", rbacscope.ScopeDomain, cred, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, false, policyResult) runningMem := guestRunningUsage.Get("domain.running_servers.memory").(int) runningCpu := guestRunningUsage.Get("domain.running_servers.cpu").(int) @@ -372,27 +373,27 @@ func getDomainGeneralUsage(scope rbacutils.TRbacScope, cred mcclient.IIdentityPr count.Add("domain.cpu_commit_rate.running", runningCpuCmtRate) count.Include( - VpcUsage("domain", providers, brands, cloudEnv, cred, rbacutils.ScopeDomain, rangeObjs, policyResult), + VpcUsage("domain", providers, brands, cloudEnv, cred, rbacscope.ScopeDomain, rangeObjs, policyResult), - DnsZoneUsage("domain", cred, rbacutils.ScopeDomain, policyResult), + DnsZoneUsage("domain", cred, rbacscope.ScopeDomain, policyResult), - HostAllUsage("", cred, rbacutils.ScopeDomain, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, policyResult), - // HostAllUsage("prepaid_pool", cred, rbacutils.ScopeDomain, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv), - // HostAllUsage("any_pool", cred, rbacutils.ScopeDomain, rangeObjs, hostTypes, nil, providers, brands, cloudEnv), + HostAllUsage("", cred, rbacscope.ScopeDomain, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, policyResult), + // HostAllUsage("prepaid_pool", cred, rbacscope.ScopeDomain, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv), + // HostAllUsage("any_pool", cred, rbacscope.ScopeDomain, rangeObjs, hostTypes, nil, providers, brands, cloudEnv), hostEnabledUsage, - // HostEnabledUsage("prepaid_pool", cred, rbacutils.ScopeDomain, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv), - // HostEnabledUsage("any_pool", cred, rbacutils.ScopeDomain, rangeObjs, hostTypes, nil, providers, brands, cloudEnv), + // HostEnabledUsage("prepaid_pool", cred, rbacscope.ScopeDomain, rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv), + // HostEnabledUsage("any_pool", cred, rbacscope.ScopeDomain, rangeObjs, hostTypes, nil, providers, brands, cloudEnv), - BaremetalUsage(cred, rbacutils.ScopeDomain, rangeObjs, hostTypes, providers, brands, cloudEnv, policyResult), + BaremetalUsage(cred, rbacscope.ScopeDomain, rangeObjs, hostTypes, providers, brands, cloudEnv, policyResult), - StorageUsage("", rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, false, false, rbacutils.ScopeDomain, cred, policyResult), - StorageUsage("system", rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, false, true, rbacutils.ScopeDomain, cred, policyResult), - // StorageUsage("prepaid_pool", rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, false, false, rbacutils.ScopeDomain, cred), - // StorageUsage("any_pool", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, false, false, rbacutils.ScopeDomain, cred), - // StorageUsage("any_pool.system", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, false, true, rbacutils.ScopeDomain, cred), - // StorageUsage("any_pool.pending_delete", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, true, false, rbacutils.ScopeDomain, cred), - // StorageUsage("any_pool.pending_delete.system", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, true, true, rbacutils.ScopeDomain, cred), + StorageUsage("", rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, false, false, rbacscope.ScopeDomain, cred, policyResult), + StorageUsage("system", rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, false, true, rbacscope.ScopeDomain, cred, policyResult), + // StorageUsage("prepaid_pool", rangeObjs, hostTypes, []string{api.HostResourceTypePrepaidRecycle}, providers, brands, cloudEnv, false, false, rbacscope.ScopeDomain, cred), + // StorageUsage("any_pool", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, false, false, rbacscope.ScopeDomain, cred), + // StorageUsage("any_pool.system", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, false, true, rbacscope.ScopeDomain, cred), + // StorageUsage("any_pool.pending_delete", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, true, false, rbacscope.ScopeDomain, cred), + // StorageUsage("any_pool.pending_delete.system", rangeObjs, hostTypes, nil, providers, brands, cloudEnv, true, true, rbacscope.ScopeDomain, cred), GuestNormalUsage(getKey(scope, "servers.last_week"), scope, cred, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, false, &lastWeek, policyResult), GuestNormalUsage(getKey(scope, "servers.last_month"), scope, cred, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, false, &lastMonth, policyResult), @@ -444,7 +445,7 @@ func getDomainGeneralUsage(scope rbacutils.TRbacScope, cred mcclient.IIdentityPr return count, nil } -func getProjectGeneralUsage(scope rbacutils.TRbacScope, cred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) (Usage, error) { +func getProjectGeneralUsage(scope rbacscope.TRbacScope, cred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) (Usage, error) { lastWeek := time.Now().Add(-7 * 24 * time.Hour) lastMonth := time.Now().Add(-30 * 24 * time.Hour) count := GuestNormalUsage(getKey(scope, "servers"), scope, cred, rangeObjs, hostTypes, []string{api.HostResourceTypeShared}, providers, brands, cloudEnv, false, nil, policyResult) @@ -503,7 +504,7 @@ func getProjectGeneralUsage(scope rbacutils.TRbacScope, cred mcclient.IIdentityP } func ReportGeneralUsage( - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, isOwner bool, rangeObjs []db.IStandaloneModel, @@ -516,25 +517,25 @@ func ReportGeneralUsage( ) (count Usage, err error) { count = make(map[string]interface{}) - // if scope == rbacutils.ScopeSystem || isOwner { - if scope == rbacutils.ScopeSystem { + // if scope == rbacscope.ScopeSystem || isOwner { + if scope == rbacscope.ScopeSystem { count, err = getSystemGeneralUsage(userCred, rangeObjs, hostTypes, providers, brands, cloudEnv, includeSystem, policyResult) if err != nil { return } } - // if scope.HigherEqual(rbacutils.ScopeDomain) && len(userCred.GetProjectDomainId()) > 0 { - if scope == rbacutils.ScopeDomain && len(userCred.GetProjectDomainId()) > 0 { - commonUsage, err := getDomainGeneralUsage(rbacutils.ScopeDomain, userCred, rangeObjs, hostTypes, providers, brands, cloudEnv, policyResult) + // if scope.HigherEqual(rbacscope.ScopeDomain) && len(userCred.GetProjectDomainId()) > 0 { + if scope == rbacscope.ScopeDomain && len(userCred.GetProjectDomainId()) > 0 { + commonUsage, err := getDomainGeneralUsage(rbacscope.ScopeDomain, userCred, rangeObjs, hostTypes, providers, brands, cloudEnv, policyResult) if err == nil { count.Include(commonUsage) } } - // if scope.HigherEqual(rbacutils.ScopeProject) && len(userCred.GetProjectId()) > 0 { - if scope == rbacutils.ScopeProject && len(userCred.GetProjectId()) > 0 { - commonUsage, err := getProjectGeneralUsage(rbacutils.ScopeProject, userCred, rangeObjs, hostTypes, providers, brands, cloudEnv, policyResult) + // if scope.HigherEqual(rbacscope.ScopeProject) && len(userCred.GetProjectId()) > 0 { + if scope == rbacscope.ScopeProject && len(userCred.GetProjectId()) > 0 { + commonUsage, err := getProjectGeneralUsage(rbacscope.ScopeProject, userCred, rangeObjs, hostTypes, providers, brands, cloudEnv, policyResult) if err == nil { count.Include(commonUsage) } @@ -572,13 +573,13 @@ func ZoneUsage(rangeObjs []db.IStandaloneModel, providers []string, brands []str return count } -func VpcUsage(prefix string, providers []string, brands []string, cloudEnv string, ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope, rangeObjs []db.IStandaloneModel, policyResult rbacutils.SPolicyResult) Usage { +func VpcUsage(prefix string, providers []string, brands []string, cloudEnv string, ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope, rangeObjs []db.IStandaloneModel, policyResult rbacutils.SPolicyResult) Usage { q := models.VpcManager.Query().IsFalse("is_emulated") if len(rangeObjs) > 0 || len(providers) > 0 || len(brands) > 0 || len(cloudEnv) > 0 { q = models.CloudProviderFilter(q, q.Field("manager_id"), providers, brands, cloudEnv) q = models.RangeObjectsFilter(q, rangeObjs, nil, nil, q.Field("manager_id"), nil, nil) } - if scope == rbacutils.ScopeDomain { + if scope == rbacscope.ScopeDomain { q = q.Equals("domain_id", ownerId.GetProjectDomainId()) } @@ -593,9 +594,9 @@ func VpcUsage(prefix string, providers []string, brands []string, cloudEnv strin return count } -func DnsZoneUsage(prefix string, ownerId mcclient.IIdentityProvider, scope rbacutils.TRbacScope, policyResult rbacutils.SPolicyResult) Usage { +func DnsZoneUsage(prefix string, ownerId mcclient.IIdentityProvider, scope rbacscope.TRbacScope, policyResult rbacutils.SPolicyResult) Usage { q := models.DnsZoneManager.Query() - if scope == rbacutils.ScopeDomain { + if scope == rbacscope.ScopeDomain { q = q.Equals("domain_id", ownerId.GetProjectDomainId()) } @@ -616,7 +617,7 @@ func StorageUsage( hostTypes []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, pendingDeleted bool, includeSystem bool, - scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, policyResult rbacutils.SPolicyResult, ) Usage { sPrefix := getSysKey(scope, "storages") @@ -726,7 +727,7 @@ func DisksUsage( providers []string, brands []string, cloudEnv string, - scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, pendingDeleted bool, includeSystem bool, policyResult rbacutils.SPolicyResult, ) Usage { @@ -749,7 +750,7 @@ func DisksUsage( return count } -func WireUsage(scope rbacutils.TRbacScope, userCred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { +func WireUsage(scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { count := make(map[string]interface{}) result := models.WireManager.TotalCount(rangeObjs, hostTypes, providers, brands, cloudEnv, scope, userCred, policyResult) count[getKey(scope, "wires")] = result.WiresCount - result.EmulatedWiresCount @@ -770,7 +771,7 @@ func WireUsage(scope rbacutils.TRbacScope, userCred mcclient.IIdentityProvider, return count } -/*func nicsUsage(prefix string, rangeObjs []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider) Usage { +/*func nicsUsage(prefix string, rangeObjs []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider) Usage { count := make(map[string]interface{}) result := models.WireManager.TotalCount(rangeObjs, hostTypes, providers, brands, cloudEnv, scope, ownerId) // including nics for pending_deleted guests @@ -793,7 +794,7 @@ func prefixKey(prefix string, key string) string { } } -func NetworkUsage(prefix string, scope rbacutils.TRbacScope, userCred mcclient.IIdentityProvider, providers []string, brands []string, cloudEnv string, rangeObjs []db.IStandaloneModel, policyResult rbacutils.SPolicyResult) Usage { +func NetworkUsage(prefix string, scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, providers []string, brands []string, cloudEnv string, rangeObjs []db.IStandaloneModel, policyResult rbacutils.SPolicyResult) Usage { count := make(map[string]interface{}) ret := models.NetworkManager.TotalPortCount(scope, userCred, providers, brands, cloudEnv, rangeObjs, policyResult) for k, v := range ret { @@ -808,7 +809,7 @@ func NetworkUsage(prefix string, scope rbacutils.TRbacScope, userCred mcclient.I return count } -func HostAllUsage(pref string, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope, rangeObjs []db.IStandaloneModel, +func HostAllUsage(pref string, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope, rangeObjs []db.IStandaloneModel, hostTypes []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { prefix := getSysKey(scope, "hosts") if len(pref) > 0 { @@ -817,7 +818,7 @@ func HostAllUsage(pref string, userCred mcclient.IIdentityProvider, scope rbacut return hostUsage(userCred, scope, prefix, rangeObjs, hostTypes, resourceTypes, providers, brands, cloudEnv, tristate.None, tristate.False, policyResult) } -func HostEnabledUsage(pref string, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope, rangeObjs []db.IStandaloneModel, +func HostEnabledUsage(pref string, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope, rangeObjs []db.IStandaloneModel, hostTypes []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { prefix := getSysKey(scope, "enabled_hosts") if len(pref) > 0 { @@ -826,7 +827,7 @@ func HostEnabledUsage(pref string, userCred mcclient.IIdentityProvider, scope rb return hostUsage(userCred, scope, prefix, rangeObjs, hostTypes, resourceTypes, providers, brands, cloudEnv, tristate.True, tristate.False, policyResult) } -func BaremetalUsage(userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope, rangeObjs []db.IStandaloneModel, +func BaremetalUsage(userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope, rangeObjs []db.IStandaloneModel, hostTypes []string, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { prefix := getSysKey(scope, "baremetals") count := hostUsage(userCred, scope, prefix, rangeObjs, hostTypes, nil, providers, brands, cloudEnv, tristate.None, tristate.True, policyResult) @@ -836,7 +837,7 @@ func BaremetalUsage(userCred mcclient.IIdentityProvider, scope rbacutils.TRbacSc } func hostUsage( - userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope, prefix string, + userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope, prefix string, rangeObjs []db.IStandaloneModel, hostTypes []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, enabled, isBaremetal tristate.TriState, @@ -861,19 +862,19 @@ func hostUsage( return count } -func GuestNormalUsage(prefix string, scope rbacutils.TRbacScope, cred mcclient.IIdentityProvider, +func GuestNormalUsage(prefix string, scope rbacscope.TRbacScope, cred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostTypes []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, since *time.Time, policyResult rbacutils.SPolicyResult) Usage { return guestUsage(prefix, scope, cred, rangeObjs, hostTypes, resourceTypes, providers, brands, cloudEnv, nil, false, includeSystem, since, policyResult) } -func GuestPendingDeleteUsage(prefix string, scope rbacutils.TRbacScope, cred mcclient.IIdentityProvider, +func GuestPendingDeleteUsage(prefix string, scope rbacscope.TRbacScope, cred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostTypes []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, since *time.Time, policyResult rbacutils.SPolicyResult) Usage { return guestUsage(prefix, scope, cred, rangeObjs, hostTypes, resourceTypes, providers, brands, cloudEnv, nil, true, includeSystem, since, policyResult) } -func GuestRunningUsage(prefix string, scope rbacutils.TRbacScope, cred mcclient.IIdentityProvider, +func GuestRunningUsage(prefix string, scope rbacscope.TRbacScope, cred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostTypes []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult, @@ -881,7 +882,7 @@ func GuestRunningUsage(prefix string, scope rbacutils.TRbacScope, cred mcclient. return guestUsage(prefix, scope, cred, rangeObjs, hostTypes, resourceTypes, providers, brands, cloudEnv, []string{api.VM_RUNNING}, false, includeSystem, nil, policyResult) } -func GuestReadyUsage(prefix string, scope rbacutils.TRbacScope, cred mcclient.IIdentityProvider, +func GuestReadyUsage(prefix string, scope rbacscope.TRbacScope, cred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostTypes []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, includeSystem bool, policyResult rbacutils.SPolicyResult) Usage { return guestUsage(prefix, scope, cred, rangeObjs, hostTypes, resourceTypes, providers, brands, cloudEnv, []string{api.VM_READY}, false, includeSystem, nil, policyResult) @@ -889,7 +890,7 @@ func GuestReadyUsage(prefix string, scope rbacutils.TRbacScope, cred mcclient.II func guestHypervisorsUsage( prefix string, - scope rbacutils.TRbacScope, + scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostTypes []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, @@ -925,7 +926,7 @@ func guestHypervisorsUsage( return count } -func guestUsage(prefix string, scope rbacutils.TRbacScope, userCred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, +func guestUsage(prefix string, scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostTypes []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, status []string, pendingDelete, includeSystem bool, since *time.Time, policyResult rbacutils.SPolicyResult, @@ -935,13 +936,13 @@ func guestUsage(prefix string, scope rbacutils.TRbacScope, userCred mcclient.IId return guestHypervisorsUsage(prefix, scope, userCred, rangeObjs, hostTypes, resourceTypes, providers, brands, cloudEnv, status, hypervisors.List(), pendingDelete, includeSystem, since, policyResult) } -/*func containerUsage(prefix string, scope rbacutils.TRbacScope, userCred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, +/*func containerUsage(prefix string, scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostTypes []string, resourceTypes []string, providers []string, brands []string, cloudEnv string) Usage { hypervisors := []string{api.HYPERVISOR_CONTAINER} return guestHypervisorsUsage(prefix, scope, userCred, rangeObjs, hostTypes, resourceTypes, providers, brands, cloudEnv, nil, hypervisors, false) }*/ -func IsolatedDeviceUsage(pref string, scope rbacutils.TRbacScope, userCred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostType []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { +func IsolatedDeviceUsage(pref string, scope rbacscope.TRbacScope, userCred mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, hostType []string, resourceTypes []string, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { prefix := "isolated_devices" if len(pref) > 0 { prefix = fmt.Sprintf("%s.%s", prefix, pref) @@ -952,17 +953,17 @@ func IsolatedDeviceUsage(pref string, scope rbacutils.TRbacScope, userCred mccli return count } -func getSysKey(scope rbacutils.TRbacScope, key string) string { +func getSysKey(scope rbacscope.TRbacScope, key string) string { return _getKey(scope, key, true) } -func getKey(scope rbacutils.TRbacScope, key string) string { +func getKey(scope rbacscope.TRbacScope, key string) string { return _getKey(scope, key, false) } -func _getKey(scope rbacutils.TRbacScope, key string, includeSystem bool) string { +func _getKey(scope rbacscope.TRbacScope, key string, includeSystem bool) string { switch scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: if includeSystem { if len(key) > 0 { return fmt.Sprintf("project.%s", key) @@ -972,7 +973,7 @@ func _getKey(scope rbacutils.TRbacScope, key string, includeSystem bool) string } else { return key } - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: if len(key) > 0 { return fmt.Sprintf("domain.%s", key) } else { @@ -991,7 +992,7 @@ func _getKey(scope rbacutils.TRbacScope, key string, includeSystem bool) string } } -func EipUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { +func EipUsage(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { eipUsage := models.ElasticipManager.TotalCount(scope, ownerId, rangeObjs, providers, brands, cloudEnv, policyResult) count := make(map[string]interface{}) count[getKey(scope, "eip")] = eipUsage.Total() @@ -1005,7 +1006,7 @@ func EipUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, ra return count } -func BucketUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { +func BucketUsage(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { bucketUsage := models.BucketManager.TotalCount(scope, ownerId, rangeObjs, providers, brands, cloudEnv, policyResult) count := make(map[string]interface{}) count[getKey(scope, "buckets")] = bucketUsage.Buckets @@ -1016,28 +1017,28 @@ func BucketUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, return count } -func SnapshotUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { +func SnapshotUsage(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { cnt, _ := models.TotalSnapshotCount(scope, ownerId, rangeObjs, providers, brands, cloudEnv, policyResult) count := make(map[string]interface{}) count[getKey(scope, "snapshot")] = cnt return count } -func InstanceSnapshotUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { +func InstanceSnapshotUsage(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { cnt, _ := models.TotalInstanceSnapshotCount(scope, ownerId, rangeObjs, providers, brands, cloudEnv, policyResult) count := make(map[string]interface{}) count[getKey(scope, "instance_snapshot")] = cnt return count } -func LoadbalancerUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { +func LoadbalancerUsage(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { cnt, _ := models.LoadbalancerManager.TotalCount(scope, ownerId, rangeObjs, providers, brands, cloudEnv, policyResult) count := make(map[string]interface{}) count[getKey(scope, "loadbalancer")] = cnt return count } -func DBInstanceUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { +func DBInstanceUsage(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { cnt, _ := models.DBInstanceManager.TotalCount(scope, ownerId, rangeObjs, providers, brands, cloudEnv, policyResult) count := make(map[string]interface{}) count[getKey(scope, "rds")] = cnt.TotalRdsCount @@ -1049,7 +1050,7 @@ func DBInstanceUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvi return count } -func MongoDBUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { +func MongoDBUsage(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { cnt, _ := models.MongoDBManager.TotalCount(scope, ownerId, rangeObjs, providers, brands, cloudEnv, policyResult) count := make(map[string]interface{}) count[getKey(scope, "mongodb")] = cnt.TotalMongodbCount @@ -1058,7 +1059,7 @@ func MongoDBUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider return count } -func ElasticSearchUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { +func ElasticSearchUsage(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { cnt, _ := models.ElasticSearchManager.TotalCount(scope, ownerId, rangeObjs, providers, brands, cloudEnv, policyResult) count := make(map[string]interface{}) count[getKey(scope, "es")] = cnt.TotalEsCount @@ -1067,7 +1068,7 @@ func ElasticSearchUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityPr return count } -func KafkaUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { +func KafkaUsage(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { cnt, _ := models.KafkaManager.TotalCount(scope, ownerId, rangeObjs, providers, brands, cloudEnv, policyResult) count := make(map[string]interface{}) count[getKey(scope, "kafka")] = cnt.TotalKafkaCount @@ -1075,7 +1076,7 @@ func KafkaUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, return count } -func ElasticCacheUsage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { +func ElasticCacheUsage(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, rangeObjs []db.IStandaloneModel, providers []string, brands []string, cloudEnv string, policyResult rbacutils.SPolicyResult) Usage { cnt, _ := models.ElasticcacheManager.TotalCount(scope, ownerId, rangeObjs, providers, brands, cloudEnv, policyResult) count := make(map[string]interface{}) count[getKey(scope, "cache")] = cnt diff --git a/pkg/controller/autoscaling/controller.go b/pkg/controller/autoscaling/controller.go index 958cd4e9ff..a734c71b76 100644 --- a/pkg/controller/autoscaling/controller.go +++ b/pkg/controller/autoscaling/controller.go @@ -27,6 +27,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/sets" "yunion.io/x/sqlchemy" @@ -39,7 +40,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/auth" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/modules/scheduler" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" "yunion.io/x/onecloud/pkg/util/nopanic" ) diff --git a/pkg/devtool/models/script_apply_record.go b/pkg/devtool/models/script_apply_record.go index 3c98ef3324..c540cc5500 100644 --- a/pkg/devtool/models/script_apply_record.go +++ b/pkg/devtool/models/script_apply_record.go @@ -20,12 +20,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/devtool" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -128,18 +128,18 @@ func (sarm *SScriptApplyRecordManager) createRecordWithResult(ctx context.Contex return sar, nil } -func (sarm *SScriptApplyRecordManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (sarm *SScriptApplyRecordManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } -func (sarm *SScriptApplyRecordManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (sarm *SScriptApplyRecordManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } -func (sarm *SScriptApplyRecordManager) FileterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (sarm *SScriptApplyRecordManager) FileterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { switch scope { - case rbacutils.ScopeProject, rbacutils.ScopeDomain: + case rbacscope.ScopeProject, rbacscope.ScopeDomain: scriptQ := ScriptManager.Query("id", "domain_id").SubQuery() q = q.Join(scriptQ, sqlchemy.Equals(q.Field("script_id"), scriptQ.Field("id"))) q = q.Filter(sqlchemy.Equals(scriptQ.Field("domain_id"), owner.GetProjectDomainId())) diff --git a/pkg/devtool/utils/service_url.go b/pkg/devtool/utils/service_url.go index 4ffb767d5c..b0b51ce099 100644 --- a/pkg/devtool/utils/service_url.go +++ b/pkg/devtool/utils/service_url.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/sets" ansible_api "yunion.io/x/onecloud/pkg/apis/ansible" @@ -36,7 +37,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/modules/identity" "yunion.io/x/onecloud/pkg/util/ansible" - "yunion.io/x/onecloud/pkg/util/httputils" ) type Service struct { diff --git a/pkg/esxi/handler/handlers.go b/pkg/esxi/handler/handlers.go index f995375b4c..cfff4f7c33 100644 --- a/pkg/esxi/handler/handlers.go +++ b/pkg/esxi/handler/handlers.go @@ -21,10 +21,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" api "yunion.io/x/onecloud/pkg/apis/compute" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/esxi" "yunion.io/x/onecloud/pkg/hostman/hostutils" diff --git a/pkg/hostimage/host_image_service.go b/pkg/hostimage/host_image_service.go index 17c21ddd49..62bc536d03 100644 --- a/pkg/hostimage/host_image_service.go +++ b/pkg/hostimage/host_image_service.go @@ -27,9 +27,9 @@ import ( "github.com/pierrec/lz4/v4" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/onecloud/pkg/apis" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" app_common "yunion.io/x/onecloud/pkg/cloudcommon/app" "yunion.io/x/onecloud/pkg/cloudcommon/consts" diff --git a/pkg/hostman/diskutils/nbd/driver.go b/pkg/hostman/diskutils/nbd/driver.go index 60027c8241..51fb2d42dd 100644 --- a/pkg/hostman/diskutils/nbd/driver.go +++ b/pkg/hostman/diskutils/nbd/driver.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/version" "yunion.io/x/onecloud/pkg/hostman/diskutils/fsutils" "yunion.io/x/onecloud/pkg/hostman/guestfs/fsdriver" @@ -32,7 +33,6 @@ import ( "yunion.io/x/onecloud/pkg/util/procutils" "yunion.io/x/onecloud/pkg/util/qemuimg" "yunion.io/x/onecloud/pkg/util/qemutils" - "yunion.io/x/onecloud/pkg/util/version" ) const MAX_TRIES = 3 diff --git a/pkg/hostman/guestfs/fsdriver/windows.go b/pkg/hostman/guestfs/fsdriver/windows.go index abf1e590e0..196c4be623 100644 --- a/pkg/hostman/guestfs/fsdriver/windows.go +++ b/pkg/hostman/guestfs/fsdriver/windows.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/version" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/apis" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/util/procutils" "yunion.io/x/onecloud/pkg/util/seclib2" "yunion.io/x/onecloud/pkg/util/stringutils2" - "yunion.io/x/onecloud/pkg/util/version" "yunion.io/x/onecloud/pkg/util/winutils" ) diff --git a/pkg/hostman/guestman/guesttasks.go b/pkg/hostman/guestman/guesttasks.go index 588b0c8460..a1b7ad6d22 100644 --- a/pkg/hostman/guestman/guesttasks.go +++ b/pkg/hostman/guestman/guesttasks.go @@ -26,11 +26,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/version" api "yunion.io/x/onecloud/pkg/apis/compute" hostapi "yunion.io/x/onecloud/pkg/apis/host" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/hostman/guestman/desc" "yunion.io/x/onecloud/pkg/hostman/guestman/qemu" "yunion.io/x/onecloud/pkg/hostman/hostinfo" @@ -43,7 +44,6 @@ import ( "yunion.io/x/onecloud/pkg/util/procutils" "yunion.io/x/onecloud/pkg/util/qemuimg" "yunion.io/x/onecloud/pkg/util/timeutils2" - "yunion.io/x/onecloud/pkg/util/version" ) type IGuestTasks interface { diff --git a/pkg/hostman/guestman/qemu-kvm.go b/pkg/hostman/guestman/qemu-kvm.go index 2bdf5ba435..9036838be2 100644 --- a/pkg/hostman/guestman/qemu-kvm.go +++ b/pkg/hostman/guestman/qemu-kvm.go @@ -30,16 +30,17 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/regutils" "yunion.io/x/pkg/util/seclib" + "yunion.io/x/pkg/util/version" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/apis" api "yunion.io/x/onecloud/pkg/apis/compute" hostapi "yunion.io/x/onecloud/pkg/apis/host" noapi "yunion.io/x/onecloud/pkg/apis/notify" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/cloudcommon/notifyclient" "yunion.io/x/onecloud/pkg/hostman/guestman/arch" @@ -69,7 +70,6 @@ import ( "yunion.io/x/onecloud/pkg/util/regutils2" "yunion.io/x/onecloud/pkg/util/seclib2" "yunion.io/x/onecloud/pkg/util/timeutils2" - "yunion.io/x/onecloud/pkg/util/version" ) const ( diff --git a/pkg/hostman/hostmetrics/hostmetrics.go b/pkg/hostman/hostmetrics/hostmetrics.go index 9748bcbbb2..3d29ac28a9 100644 --- a/pkg/hostman/hostmetrics/hostmetrics.go +++ b/pkg/hostman/hostmetrics/hostmetrics.go @@ -30,13 +30,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/netutils" "yunion.io/x/onecloud/pkg/hostman/guestman" "yunion.io/x/onecloud/pkg/hostman/guestman/desc" "yunion.io/x/onecloud/pkg/hostman/hostinfo/hostconsts" "yunion.io/x/onecloud/pkg/hostman/options" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/pkg/hostman/hostutils/hostutils.go b/pkg/hostman/hostutils/hostutils.go index 34d987081a..7d18cbb17a 100644 --- a/pkg/hostman/hostutils/hostutils.go +++ b/pkg/hostman/hostutils/hostutils.go @@ -21,9 +21,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/onecloud/pkg/apis" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/cloudcommon/workmanager" diff --git a/pkg/hostman/storageman/backupstorage/backup_storage.go b/pkg/hostman/storageman/backupstorage/backup_storage.go index b35a19a554..a77d8af9bb 100644 --- a/pkg/hostman/storageman/backupstorage/backup_storage.go +++ b/pkg/hostman/storageman/backupstorage/backup_storage.go @@ -20,9 +20,9 @@ import ( "sync" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/qemuimgfmt" api "yunion.io/x/onecloud/pkg/apis/compute" - "yunion.io/x/onecloud/pkg/util/qemuimg" ) type IBackupStorage interface { @@ -30,8 +30,8 @@ type IBackupStorage interface { CopyBackupTo(targetFilename string, backupId string) error RemoveBackup(backupId string) error IsExists(backupId string) (bool, error) - ConvertTo(destPath string, format qemuimg.TImageFormat, backupId string) error - ConvertFrom(srcPath string, format qemuimg.TImageFormat, backupId string) (int, error) + ConvertTo(destPath string, format qemuimgfmt.TImageFormat, backupId string) error + ConvertFrom(srcPath string, format qemuimgfmt.TImageFormat, backupId string) (int, error) InstancePack(ctx context.Context, packageName string, backupIds []string, metadata *api.InstanceBackupPackMetadata) (string, error) InstanceUnpack(ctx context.Context, packageName string, metadataOnly bool) ([]string, *api.InstanceBackupPackMetadata, error) IsOnline() (bool, string, error) diff --git a/pkg/hostman/storageman/backupstorage/backup_storage_nfs.go b/pkg/hostman/storageman/backupstorage/backup_storage_nfs.go index 0e89498563..ee4fb1c947 100644 --- a/pkg/hostman/storageman/backupstorage/backup_storage_nfs.go +++ b/pkg/hostman/storageman/backupstorage/backup_storage_nfs.go @@ -26,6 +26,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/cloudcommon/db" @@ -419,7 +420,7 @@ func (s *SNFSBackupStorage) InstanceUnpack(ctx context.Context, packageName stri return backupIds, metadata, nil } -func (s *SNFSBackupStorage) ConvertFrom(srcPath string, format qemuimg.TImageFormat, backupId string) (int, error) { +func (s *SNFSBackupStorage) ConvertFrom(srcPath string, format qemuimgfmt.TImageFormat, backupId string) (int, error) { err := s.checkAndMount() if err != nil { return 0, errors.Wrap(err, "unable to checkAndMount") @@ -435,7 +436,7 @@ func (s *SNFSBackupStorage) ConvertFrom(srcPath string, format qemuimg.TImageFor } destInfo := qemuimg.SImageInfo{ Path: destPath, - Format: qemuimg.QCOW2, + Format: qemuimgfmt.QCOW2, IoLevel: qemuimg.IONiceNone, Password: "", } @@ -450,7 +451,7 @@ func (s *SNFSBackupStorage) ConvertFrom(srcPath string, format qemuimg.TImageFor return newImage.GetActualSizeMB(), nil } -func (s *SNFSBackupStorage) ConvertTo(destPath string, format qemuimg.TImageFormat, backupId string) error { +func (s *SNFSBackupStorage) ConvertTo(destPath string, format qemuimgfmt.TImageFormat, backupId string) error { err := s.checkAndMount() if err != nil { return errors.Wrap(err, "unable to checkAndMount") @@ -460,7 +461,7 @@ func (s *SNFSBackupStorage) ConvertTo(destPath string, format qemuimg.TImageForm srcPath := path.Join(backupDir, backupId) srcInfo := qemuimg.SImageInfo{ Path: srcPath, - Format: qemuimg.QCOW2, + Format: qemuimgfmt.QCOW2, IoLevel: qemuimg.IONiceNone, Password: "", } diff --git a/pkg/hostman/storageman/disk_agent.go b/pkg/hostman/storageman/disk_agent.go index cd75c5eb22..711264a173 100644 --- a/pkg/hostman/storageman/disk_agent.go +++ b/pkg/hostman/storageman/disk_agent.go @@ -23,6 +23,9 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/onecloud/pkg/apis/compute" + deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis" + "yunion.io/x/onecloud/pkg/hostman/hostdeployer/deployclient" "yunion.io/x/onecloud/pkg/hostman/hostutils" "yunion.io/x/onecloud/pkg/httperrors" ) @@ -93,9 +96,33 @@ func (sd *SAgentDisk) Resize(ctx context.Context, diskInfo interface{}) (jsonuti desc := jsonutils.NewDict() desc.Add(jsonutils.NewInt(resize.SizeMb), "disk_size") // try to resize partition - err = iDisk.(*esxi.SVirtualDisk).ResizePartition(ctx, resize.HostInfo) + err = resizeESXiPartition(ctx, vm, iDisk.(*esxi.SVirtualDisk), resize.HostInfo) if err != nil { log.Errorf("unable to ResizePartition: %v", err) } return desc, nil } + +func resizeESXiPartition(ctx context.Context, vm *esxi.SVirtualMachine, disk *esxi.SVirtualDisk, accessInfo vcenter.SVCenterAccessInfo) error { + diskPath := disk.GetFilename() + vmref := vm.GetMoid() + diskInfo := deployapi.DiskInfo{ + Path: diskPath, + } + vddkInfo := deployapi.VDDKConInfo{ + Host: accessInfo.Host, + Port: int32(accessInfo.Port), + User: accessInfo.Account, + Passwd: accessInfo.Password, + Vmref: vmref, + } + _, err := deployclient.GetDeployClient().ResizeFs(ctx, &deployapi.ResizeFsParams{ + DiskInfo: &diskInfo, + Hypervisor: compute.HYPERVISOR_ESXI, + VddkInfo: &vddkInfo, + }) + if err != nil { + return errors.Wrap(err, "unable to ResizeFs") + } + return nil +} diff --git a/pkg/hostman/storageman/disk_local.go b/pkg/hostman/storageman/disk_local.go index 027d3a9c0a..475eac931b 100644 --- a/pkg/hostman/storageman/disk_local.go +++ b/pkg/hostman/storageman/disk_local.go @@ -25,12 +25,13 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/apis" api "yunion.io/x/onecloud/pkg/apis/compute" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/cloudcommon/consts" deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis" "yunion.io/x/onecloud/pkg/hostman/hostdeployer/deployclient" @@ -439,7 +440,7 @@ func (d *SLocalDisk) DiskBackup(ctx context.Context, params interface{}) (jsonut if len(encKey) > 0 { img.SetPassword(encKey) } - newImage, err := img.Clone(backupPath, qemuimg.QCOW2, true) + newImage, err := img.Clone(backupPath, qemuimgfmt.QCOW2, true) if err != nil { return nil, errors.Wrap(err, "unable to backup snapshot") } diff --git a/pkg/hostman/storageman/disk_rbd.go b/pkg/hostman/storageman/disk_rbd.go index 6f2a5cbc8c..be3ca54d05 100644 --- a/pkg/hostman/storageman/disk_rbd.go +++ b/pkg/hostman/storageman/disk_rbd.go @@ -21,12 +21,12 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/apis" api "yunion.io/x/onecloud/pkg/apis/compute" - "yunion.io/x/onecloud/pkg/appctx" deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis" "yunion.io/x/onecloud/pkg/hostman/hostutils" "yunion.io/x/onecloud/pkg/httperrors" diff --git a/pkg/hostman/storageman/remotefile/remotefile.go b/pkg/hostman/storageman/remotefile/remotefile.go index 450b1b64d8..8375b4e594 100644 --- a/pkg/hostman/storageman/remotefile/remotefile.go +++ b/pkg/hostman/storageman/remotefile/remotefile.go @@ -28,10 +28,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/util/fileutils2" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/pb" "yunion.io/x/onecloud/pkg/util/sparsefile" ) diff --git a/pkg/hostman/storageman/storage_agent.go b/pkg/hostman/storageman/storage_agent.go index 596dd6cca8..ef82d0b9fe 100644 --- a/pkg/hostman/storageman/storage_agent.go +++ b/pkg/hostman/storageman/storage_agent.go @@ -28,6 +28,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/pkg/util/seclib" "yunion.io/x/pkg/util/timeutils" @@ -528,7 +529,7 @@ func (as *SAgentStorage) saveToGlance(ctx context.Context, imageId, imagePath st if len(format) == 0 { format = options.HostOptions.DefaultImageSaveFormat } - if format == string(qemuimg.QCOW2) { + if format == string(qemuimgfmt.QCOW2) { // may be encrypted if err := origin.Convert2Qcow2(true, "", "", ""); err != nil { log.Errorln(err) diff --git a/pkg/hostman/storageman/storage_base.go b/pkg/hostman/storageman/storage_base.go index 0f5c5ab360..5e00d05b39 100644 --- a/pkg/hostman/storageman/storage_base.go +++ b/pkg/hostman/storageman/storage_base.go @@ -28,6 +28,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/onecloud/pkg/apis" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -459,7 +460,7 @@ func (s *SBaseStorage) CreateDiskFromBackup(ctx context.Context, disk IDisk, inp log.Errorf("unable to new qemu image for %s: %s", backupPath, err.Error()) return errors.Wrapf(err, "unable to new qemu image for %s", backupPath) } - _, err = img.Clone(disk.GetPath(), qemuimg.QCOW2, false) + _, err = img.Clone(disk.GetPath(), qemuimgfmt.QCOW2, false) return err } diff --git a/pkg/hostman/storageman/storage_local.go b/pkg/hostman/storageman/storage_local.go index 93498cc2f5..f687d3e119 100644 --- a/pkg/hostman/storageman/storage_local.go +++ b/pkg/hostman/storageman/storage_local.go @@ -26,6 +26,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/onecloud/pkg/apis" @@ -728,7 +729,7 @@ func (s *SLocalStorage) CloneDiskFromStorage( // empty target disk with same size and format accessPath := s.GetCloneTargetDiskPath(ctx, targetDiskId) if fullCopy { - _, err = srcImg.Clone(s.GetCloneTargetDiskPath(ctx, targetDiskId), qemuimg.QCOW2, false) + _, err = srcImg.Clone(s.GetCloneTargetDiskPath(ctx, targetDiskId), qemuimgfmt.QCOW2, false) } else { newImg, err := qemuimg.NewQemuImage(accessPath) if err != nil { @@ -742,6 +743,6 @@ func (s *SLocalStorage) CloneDiskFromStorage( } return &hostapi.ServerCloneDiskFromStorageResponse{ TargetAccessPath: accessPath, - TargetFormat: qemuimg.QCOW2.String(), + TargetFormat: qemuimgfmt.QCOW2.String(), }, nil } diff --git a/pkg/hostman/storageman/storage_rbd.go b/pkg/hostman/storageman/storage_rbd.go index 570f93503a..8ea2ffb942 100644 --- a/pkg/hostman/storageman/storage_rbd.go +++ b/pkg/hostman/storageman/storage_rbd.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -330,9 +331,9 @@ func (s *SRbdStorage) createBackup(pool string, diskId string, snapshotId string } srcPath := fmt.Sprintf("rbd:%s/%s%s", pool, backupName, s.getStorageConfString()) // convert - sizeMb, err := backupStorage.ConvertFrom(srcPath, qemuimg.RAW, backupId) + sizeMb, err := backupStorage.ConvertFrom(srcPath, qemuimgfmt.RAW, backupId) if err != nil { - return 0, errors.Wrapf(err, "unable to ConvertFrom with srcPath %s and format %s", srcPath, qemuimg.RAW.String()) + return 0, errors.Wrapf(err, "unable to ConvertFrom with srcPath %s and format %s", srcPath, qemuimgfmt.RAW.String()) } return sizeMb, nil } @@ -589,9 +590,9 @@ func (s *SRbdStorage) CreateDiskFromBackup(ctx context.Context, disk IDisk, inpu if err != nil { return errors.Wrap(err, "unable to GetBackupStorage") } - err = backupStorage.ConvertTo(destPath, qemuimg.RAW, backup.BackupId) + err = backupStorage.ConvertTo(destPath, qemuimgfmt.RAW, backup.BackupId) if err != nil { - return errors.Wrapf(err, "unable to Convert to with destPath %s and format %s", destPath, qemuimg.RAW.String()) + return errors.Wrapf(err, "unable to Convert to with destPath %s and format %s", destPath, qemuimgfmt.RAW.String()) } return nil } @@ -620,7 +621,7 @@ func (s *SRbdStorage) CloneDiskFromStorage( } accessPath := s.GetCloneTargetDiskPath(ctx, targetDiskId) if fullCopy { - _, err = srcImg.Clone(accessPath, qemuimg.RAW, false) + _, err = srcImg.Clone(accessPath, qemuimgfmt.RAW, false) if err != nil { return nil, errors.Wrap(err, "Clone source disk to target rbd storage") } @@ -633,7 +634,7 @@ func (s *SRbdStorage) CloneDiskFromStorage( return &hostapi.ServerCloneDiskFromStorageResponse{ TargetAccessPath: accessPath, - TargetFormat: qemuimg.RAW.String(), + TargetFormat: qemuimgfmt.RAW.String(), }, nil } diff --git a/pkg/hostman/system_service/telegraf.go b/pkg/hostman/system_service/telegraf.go index cb004e2d1f..0f08f3ad29 100644 --- a/pkg/hostman/system_service/telegraf.go +++ b/pkg/hostman/system_service/telegraf.go @@ -21,8 +21,7 @@ import ( "strings" "yunion.io/x/log" - - "yunion.io/x/onecloud/pkg/util/httputils" + "yunion.io/x/pkg/util/httputils" ) type STelegraf struct { diff --git a/pkg/httperrors/consts.go b/pkg/httperrors/consts.go index 3cbc057f4c..ec86d08677 100644 --- a/pkg/httperrors/consts.go +++ b/pkg/httperrors/consts.go @@ -33,7 +33,7 @@ const ( ErrServerStatus = errors.Error("ServerStatusError") ErrInvalidStatus = errors.ErrInvalidStatus - ErrInvalidFormat = errors.Error("InvalidFormatError") + ErrInvalidFormat = errors.ErrInvalidFormat ErrInputParameter = errors.Error("InputParameterError") ErrWeakPassword = errors.Error("WeakPasswordError") @@ -83,7 +83,7 @@ const ( ErrTooManyAttempts = errors.Error("TooManyFailedAttempts") ErrTooManyRequests = errors.Error("TooManyRequests") - ErrUnsupportedProtocol = errors.Error("UnsupportedProtocol") + ErrUnsupportedProtocol = errors.ErrUnsupportedProtocol ErrPolicyDefinition = errors.Error("PolicyDefinitionError") diff --git a/pkg/httperrors/errors.go b/pkg/httperrors/errors.go index 7afdf28125..561918f029 100644 --- a/pkg/httperrors/errors.go +++ b/pkg/httperrors/errors.go @@ -16,8 +16,7 @@ package httperrors import ( "yunion.io/x/pkg/errors" - - "yunion.io/x/onecloud/pkg/util/httputils" + "yunion.io/x/pkg/util/httputils" ) func NewBadGatewayError(msg string, params ...interface{}) *httputils.JSONClientError { diff --git a/pkg/httperrors/general.go b/pkg/httperrors/general.go index e2562f9081..30e81124c9 100644 --- a/pkg/httperrors/general.go +++ b/pkg/httperrors/general.go @@ -16,8 +16,7 @@ package httperrors import ( "yunion.io/x/pkg/errors" - - "yunion.io/x/onecloud/pkg/util/httputils" + "yunion.io/x/pkg/util/httputils" ) func NewGeneralError(err error) *httputils.JSONClientError { diff --git a/pkg/httperrors/httperrors.go b/pkg/httperrors/httperrors.go index 7312ff9382..3f1be2c4e3 100644 --- a/pkg/httperrors/httperrors.go +++ b/pkg/httperrors/httperrors.go @@ -21,10 +21,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" + "yunion.io/x/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/i18n" - "yunion.io/x/onecloud/pkg/util/httputils" ) func SendHTTPErrorHeader(w http.ResponseWriter, statusCode int) { diff --git a/pkg/i18n/table.go b/pkg/i18n/table.go index 93f8d56978..8ffdce1481 100644 --- a/pkg/i18n/table.go +++ b/pkg/i18n/table.go @@ -19,7 +19,7 @@ import ( "golang.org/x/text/language" - "yunion.io/x/onecloud/pkg/appctx" + "yunion.io/x/pkg/appctx" ) type Tag = language.Tag diff --git a/pkg/image/models/image_guest.go b/pkg/image/models/image_guest.go index 75c78d6699..6acc8d1303 100644 --- a/pkg/image/models/image_guest.go +++ b/pkg/image/models/image_guest.go @@ -27,6 +27,8 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/qemuimgfmt" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -41,7 +43,6 @@ import ( "yunion.io/x/onecloud/pkg/image/options" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/qemuimg" "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -91,7 +92,7 @@ func (manager *SGuestImageManager) ValidateCreateData(ctx context.Context, userC return input, httperrors.NewMissingParameterError("images") } - input.DiskFormat = string(qemuimg.QCOW2) + input.DiskFormat = string(qemuimgfmt.QCOW2) pendingUsage := SQuota{Image: int(imageNum)} keys := imageCreateInput2QuotaKeys("qcow2", ownerId) @@ -632,17 +633,17 @@ func (manager *SGuestImageManager) QueryDistinctExtraField(q *sqlchemy.SQuery, f return q, httperrors.ErrNotFound } -func (manager *SGuestImageManager) Usage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, prefix string, policyResult rbacutils.SPolicyResult) map[string]int64 { +func (manager *SGuestImageManager) Usage(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, prefix string, policyResult rbacutils.SPolicyResult) map[string]int64 { usages := make(map[string]int64) count := ImageManager.count(scope, ownerId, api.IMAGE_STATUS_ACTIVE, tristate.False, false, tristate.True, policyResult) expandUsageCount(usages, prefix, "guest_image", "", count) sq := manager.Query() switch scope { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: // do nothing - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: sq = sq.Equals("domain_id", ownerId.GetProjectDomainId()) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: sq = sq.Equals("tenant_id", ownerId.GetProjectId()) } cnt, _ := sq.CountWithError() diff --git a/pkg/image/models/images.go b/pkg/image/models/images.go index 53fee7719c..c1d7e955ff 100644 --- a/pkg/image/models/images.go +++ b/pkg/image/models/images.go @@ -32,6 +32,10 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/pinyinutils" + "yunion.io/x/pkg/util/qemuimgfmt" + "yunion.io/x/pkg/util/rbacscope" + "yunion.io/x/pkg/util/streamutils" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -56,11 +60,9 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/modules/notify" "yunion.io/x/onecloud/pkg/util/fileutils2" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/pinyinutils" "yunion.io/x/onecloud/pkg/util/procutils" "yunion.io/x/onecloud/pkg/util/qemuimg" "yunion.io/x/onecloud/pkg/util/rbacutils" - "yunion.io/x/onecloud/pkg/util/streamutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -666,7 +668,7 @@ func (self *SImage) ValidateUpdateData(ctx context.Context, userCred mcclient.To if appParams != nil && appParams.Request.ContentLength > 0 { return nil, httperrors.NewInvalidStatusError("cannot upload in status %s", self.Status) } - if minDiskSize, err := data.Int("min_disk"); err == nil && self.DiskFormat != string(qemuimg.ISO) { + if minDiskSize, err := data.Int("min_disk"); err == nil && self.DiskFormat != string(qemuimgfmt.ISO) { img, err := qemuimg.NewQemuImage(self.GetLocalLocation()) if err != nil { return nil, errors.Wrap(err, "open image") @@ -917,15 +919,15 @@ type SImageUsage struct { Size int64 } -func (manager *SImageManager) count(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, status string, isISO tristate.TriState, pendingDelete bool, guestImage tristate.TriState, policyResult rbacutils.SPolicyResult) map[string]SImageUsage { +func (manager *SImageManager) count(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, status string, isISO tristate.TriState, pendingDelete bool, guestImage tristate.TriState, policyResult rbacutils.SPolicyResult) map[string]SImageUsage { sq := manager.Query("id") sq = db.ObjectIdQueryWithPolicyResult(sq, manager, policyResult) switch scope { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: // do nothing - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: sq = sq.Equals("domain_id", ownerId.GetProjectDomainId()) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: sq = sq.Equals("tenant_id", ownerId.GetProjectId()) } // exclude GuestImage!!! @@ -944,9 +946,9 @@ func (manager *SImageManager) count(scope rbacutils.TRbacScope, ownerId mcclient sq = sq.IsFalse("pending_deleted") } if isISO.IsTrue() { - sq = sq.Equals("disk_format", string(qemuimg.ISO)) + sq = sq.Equals("disk_format", string(qemuimgfmt.ISO)) } else if isISO.IsFalse() { - sq = sq.NotEquals("disk_format", string(qemuimg.ISO)) + sq = sq.NotEquals("disk_format", string(qemuimgfmt.ISO)) } cnt, _ := sq.CountWithError() @@ -995,32 +997,32 @@ func expandUsageCount(usages map[string]int64, prefix, imgType, state string, co } } -func (manager *SImageManager) Usage(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, prefix string, policyResult rbacutils.SPolicyResult) map[string]int64 { +func (manager *SImageManager) Usage(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider, prefix string, policyResult rbacutils.SPolicyResult) map[string]int64 { usages := make(map[string]int64) count := manager.count(scope, ownerId, api.IMAGE_STATUS_ACTIVE, tristate.False, false, tristate.False, policyResult) expandUsageCount(usages, prefix, "img", "", count) count = manager.count(scope, ownerId, api.IMAGE_STATUS_ACTIVE, tristate.True, false, tristate.False, policyResult) - expandUsageCount(usages, prefix, string(qemuimg.ISO), "", count) + expandUsageCount(usages, prefix, string(qemuimgfmt.ISO), "", count) count = manager.count(scope, ownerId, api.IMAGE_STATUS_ACTIVE, tristate.None, false, tristate.False, policyResult) expandUsageCount(usages, prefix, "imgiso", "", count) count = manager.count(scope, ownerId, "", tristate.False, true, tristate.False, policyResult) expandUsageCount(usages, prefix, "img", "pending_delete", count) count = manager.count(scope, ownerId, "", tristate.True, true, tristate.False, policyResult) - expandUsageCount(usages, prefix, string(qemuimg.ISO), "pending_delete", count) + expandUsageCount(usages, prefix, string(qemuimgfmt.ISO), "pending_delete", count) count = manager.count(scope, ownerId, "", tristate.None, true, tristate.False, policyResult) expandUsageCount(usages, prefix, "imgiso", "pending_delete", count) return usages } func (self *SImage) GetImageType() api.TImageType { - if self.DiskFormat == string(qemuimg.ISO) { + if self.DiskFormat == string(qemuimgfmt.ISO) { return api.ImageTypeISO } else { return api.ImageTypeTemplate } } -func (self *SImage) newSubformat(ctx context.Context, format qemuimg.TImageFormat, migrate bool) error { +func (self *SImage) newSubformat(ctx context.Context, format qemuimgfmt.TImageFormat, migrate bool) error { subformat := &SImageSubformat{} subformat.SetModelManager(ImageSubformatManager, subformat) @@ -1050,7 +1052,7 @@ func (self *SImage) newSubformat(ctx context.Context, format qemuimg.TImageForma func (self *SImage) migrateSubImage(ctx context.Context) error { log.Debugf("migrateSubImage") - if !qemuimg.IsSupportedImageFormat(self.DiskFormat) { + if !qemuimgfmt.IsSupportedImageFormat(self.DiskFormat) { log.Warningf("Unsupported image format %s, no need to migrate", self.DiskFormat) return nil } @@ -1066,7 +1068,7 @@ func (self *SImage) migrateSubImage(ctx context.Context) error { } if self.GetImageType() != api.ImageTypeISO && imgInst.IsSparse() && utils.IsInStringArray(self.DiskFormat, options.Options.TargetImageFormats) { // need to convert again - return self.newSubformat(ctx, qemuimg.String2ImageFormat(self.DiskFormat), false) + return self.newSubformat(ctx, qemuimgfmt.String2ImageFormat(self.DiskFormat), false) } else { localPath := self.GetLocalLocation() if !strings.HasSuffix(localPath, fmt.Sprintf(".%s", self.DiskFormat)) { @@ -1083,12 +1085,12 @@ func (self *SImage) migrateSubImage(ctx context.Context) error { return err } } - return self.newSubformat(ctx, qemuimg.String2ImageFormat(self.DiskFormat), true) + return self.newSubformat(ctx, qemuimgfmt.String2ImageFormat(self.DiskFormat), true) } } func (img *SImage) isEncrypted() bool { - return img.DiskFormat == string(qemuimg.QCOW2) && len(img.EncryptKeyId) > 0 + return img.DiskFormat == string(qemuimgfmt.QCOW2) && len(img.EncryptKeyId) > 0 } func (self *SImage) makeSubImages(ctx context.Context) error { @@ -1102,14 +1104,14 @@ func (self *SImage) makeSubImages(ctx context.Context) error { } log.Debugf("[MakeSubImages] convert image to %#v", options.Options.TargetImageFormats) for _, format := range options.Options.TargetImageFormats { - if !qemuimg.IsSupportedImageFormat(format) { + if !qemuimgfmt.IsSupportedImageFormat(format) { continue } if format != self.DiskFormat { // need to create a record subformat := ImageSubformatManager.FetchSubImage(self.Id, format) if subformat == nil { - err := self.newSubformat(ctx, qemuimg.String2ImageFormat(format), false) + err := self.newSubformat(ctx, qemuimgfmt.String2ImageFormat(format), false) if err != nil { return err } @@ -1525,7 +1527,7 @@ func (self *SImage) CanUpdate(data jsonutils.JSONObject) bool { func (img *SImage) GetQuotaKeys() quotas.IQuotaKeys { keys := SImageQuotaKeys{} - keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(rbacutils.ScopeProject, img.GetOwnerId()) + keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(rbacscope.ScopeProject, img.GetOwnerId()) if img.GetImageType() == api.ImageTypeISO { keys.Type = string(api.ImageTypeISO) } else { @@ -1536,7 +1538,7 @@ func (img *SImage) GetQuotaKeys() quotas.IQuotaKeys { func imageCreateInput2QuotaKeys(format string, ownerId mcclient.IIdentityProvider) quotas.IQuotaKeys { keys := SImageQuotaKeys{} - keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(rbacutils.ScopeProject, ownerId) + keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(rbacscope.ScopeProject, ownerId) if format == string(api.ImageTypeISO) { keys.Type = string(api.ImageTypeISO) } else if len(format) > 0 { @@ -1921,7 +1923,7 @@ func (img *SImage) doEncrypt(ctx context.Context, userCred mcclient.TokenCredent if len(img.EncryptKeyId) == 0 { return false, nil } - if img.DiskFormat != string(qemuimg.QCOW2) { + if img.DiskFormat != string(qemuimgfmt.QCOW2) { // only qcow2 support encryption return false, nil } diff --git a/pkg/image/models/quotas.go b/pkg/image/models/quotas.go index a705b27fd5..28fe84805f 100644 --- a/pkg/image/models/quotas.go +++ b/pkg/image/models/quotas.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" identityapi "yunion.io/x/onecloud/pkg/apis/identity" api "yunion.io/x/onecloud/pkg/apis/image" @@ -47,7 +48,7 @@ func init() { QuotaPendingUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(SQuota{}, - rbacutils.ScopeProject, + rbacscope.ScopeProject, "quota_pending_usage_tbl", "quota_pending_usage", "quota_pending_usages", @@ -55,7 +56,7 @@ func init() { } QuotaUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(SQuota{}, - rbacutils.ScopeProject, + rbacscope.ScopeProject, "quota_usage_tbl", "quota_usage", "quota_usages", @@ -63,7 +64,7 @@ func init() { } QuotaManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaBaseManager(SQuota{}, - rbacutils.ScopeProject, + rbacscope.ScopeProject, "quota_tbl", QuotaPendingUsageManager, QuotaUsageManager, @@ -99,14 +100,14 @@ func (self *SQuota) FetchSystemQuota() { base = -1 case commonOptions.DefaultQuotaZero: base = 0 - if keys.Scope() == rbacutils.ScopeDomain { // domain level quota + if keys.Scope() == rbacscope.ScopeDomain { // domain level quota base = 10 } else if keys.DomainId == identityapi.DEFAULT_DOMAIN_ID && keys.ProjectId == auth.AdminCredential().GetProjectId() { base = 1 } case commonOptions.DefaultQuotaDefault: base = 1 - if keys.Scope() == rbacutils.ScopeDomain { + if keys.Scope() == rbacscope.ScopeDomain { base = 10 } } diff --git a/pkg/image/models/storage.go b/pkg/image/models/storage.go index c673af16fe..fbd89bfa3f 100644 --- a/pkg/image/models/storage.go +++ b/pkg/image/models/storage.go @@ -22,13 +22,13 @@ import ( "strings" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/onecloud/pkg/apis/image" "yunion.io/x/onecloud/pkg/image/drivers/s3" "yunion.io/x/onecloud/pkg/image/options" "yunion.io/x/onecloud/pkg/util/fileutils2" "yunion.io/x/onecloud/pkg/util/procutils" - "yunion.io/x/onecloud/pkg/util/qemuimg" ) var local Storage = &LocalStorage{} @@ -126,7 +126,7 @@ func (s *LocalStorage) ConvertImage(ctx context.Context, image *SImage, targetFo if err != nil { return nil, errors.Wrap(err, "unable to image.getQemuImage") } - nimg, err := img.Clone(location, qemuimg.String2ImageFormat(targetFormat), true) + nimg, err := img.Clone(location, qemuimgfmt.String2ImageFormat(targetFormat), true) if err != nil { return nil, errors.Wrap(err, "unable to img.Clone") } @@ -201,7 +201,7 @@ func (s *S3Storage) ConvertImage(ctx context.Context, image *SImage, targetForma if err != nil { return nil, errors.Wrap(err, "unable to image.getQemuImage") } - nimg, err := img.Clone(location, qemuimg.String2ImageFormat(targetFormat), true) + nimg, err := img.Clone(location, qemuimgfmt.String2ImageFormat(targetFormat), true) if err != nil { return nil, errors.Wrap(err, "unable to img.Clone") } diff --git a/pkg/image/policy/defaults.go b/pkg/image/policy/defaults.go index 7ae7f70eb7..c6a5559b32 100644 --- a/pkg/image/policy/defaults.go +++ b/pkg/image/policy/defaults.go @@ -15,6 +15,8 @@ package policy import ( + "yunion.io/x/pkg/util/rbacscope" + api "yunion.io/x/onecloud/pkg/apis/image" common_policy "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/util/rbacutils" @@ -30,7 +32,7 @@ var ( predefinedDefaultPolicies = []rbacutils.SRbacPolicy{ { Auth: true, - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -74,7 +76,7 @@ var ( { // for anonymous update torrent status Auth: false, - Scope: rbacutils.ScopeSystem, + Scope: rbacscope.ScopeSystem, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, diff --git a/pkg/image/tasks/image_copy_from_url_task.go b/pkg/image/tasks/image_copy_from_url_task.go index bce6476929..5dbe290cde 100644 --- a/pkg/image/tasks/image_copy_from_url_task.go +++ b/pkg/image/tasks/image_copy_from_url_task.go @@ -20,12 +20,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" "yunion.io/x/onecloud/pkg/image/models" "yunion.io/x/onecloud/pkg/image/options" - "yunion.io/x/onecloud/pkg/util/httputils" ) type ImageCopyFromUrlTask struct { diff --git a/pkg/image/usages/handler.go b/pkg/image/usages/handler.go index 210496c91b..5f220284e1 100644 --- a/pkg/image/usages/handler.go +++ b/pkg/image/usages/handler.go @@ -20,6 +20,7 @@ import ( "net/http" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/db" @@ -27,7 +28,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/image/models" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/tagutils" ) @@ -53,24 +53,24 @@ func ReportGeneralUsage(ctx context.Context, w http.ResponseWriter, r *http.Requ result.ProjectTags = *projectTags usages := jsonutils.NewDict() - if scope == rbacutils.ScopeSystem { - adminUsage := models.ImageManager.Usage(rbacutils.ScopeSystem, ownerId, "all", result) + if scope == rbacscope.ScopeSystem { + adminUsage := models.ImageManager.Usage(rbacscope.ScopeSystem, ownerId, "all", result) usages.Update(jsonutils.Marshal(adminUsage)) - adminUsage = models.GuestImageManager.Usage(rbacutils.ScopeSystem, ownerId, "all", result) + adminUsage = models.GuestImageManager.Usage(rbacscope.ScopeSystem, ownerId, "all", result) usages.Update(jsonutils.Marshal(adminUsage)) } - if scope.HigherEqual(rbacutils.ScopeDomain) { - domainUsage := models.ImageManager.Usage(rbacutils.ScopeDomain, ownerId, "domain", result) + if scope.HigherEqual(rbacscope.ScopeDomain) { + domainUsage := models.ImageManager.Usage(rbacscope.ScopeDomain, ownerId, "domain", result) usages.Update(jsonutils.Marshal(domainUsage)) - domainUsage = models.GuestImageManager.Usage(rbacutils.ScopeDomain, ownerId, "domain", result) + domainUsage = models.GuestImageManager.Usage(rbacscope.ScopeDomain, ownerId, "domain", result) usages.Update(jsonutils.Marshal(domainUsage)) } - if scope.HigherEqual(rbacutils.ScopeProject) { - projectUsage := models.ImageManager.Usage(rbacutils.ScopeProject, ownerId, "", result) + if scope.HigherEqual(rbacscope.ScopeProject) { + projectUsage := models.ImageManager.Usage(rbacscope.ScopeProject, ownerId, "", result) usages.Update(jsonutils.Marshal(projectUsage)) - projectUsage = models.GuestImageManager.Usage(rbacutils.ScopeProject, ownerId, "", result) + projectUsage = models.GuestImageManager.Usage(rbacscope.ScopeProject, ownerId, "", result) usages.Update(jsonutils.Marshal(projectUsage)) } diff --git a/pkg/keystone/cronjobs/project_resources.go b/pkg/keystone/cronjobs/project_resources.go index a8d36531c7..fca671dfb4 100644 --- a/pkg/keystone/cronjobs/project_resources.go +++ b/pkg/keystone/cronjobs/project_resources.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/apis" @@ -34,7 +35,6 @@ import ( "yunion.io/x/onecloud/pkg/keystone/tokens" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/httputils" ) var ( diff --git a/pkg/keystone/driver/base.go b/pkg/keystone/driver/base.go index 91315a7a9c..d4aeec1c18 100644 --- a/pkg/keystone/driver/base.go +++ b/pkg/keystone/driver/base.go @@ -15,8 +15,9 @@ package driver import ( + "yunion.io/x/pkg/object" + api "yunion.io/x/onecloud/pkg/apis/identity" - "yunion.io/x/onecloud/pkg/cloudcommon/object" ) var ( diff --git a/pkg/keystone/driver/cas/cas.go b/pkg/keystone/driver/cas/cas.go index 0a8b835a86..36fe03d421 100644 --- a/pkg/keystone/driver/cas/cas.go +++ b/pkg/keystone/driver/cas/cas.go @@ -23,12 +23,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/onecloud/pkg/apis/identity" "yunion.io/x/onecloud/pkg/keystone/driver" "yunion.io/x/onecloud/pkg/keystone/models" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" ) // apereo CAS (Central Authentication Server) diff --git a/pkg/keystone/driver/oauth2/dingtalk/dingtalk.go b/pkg/keystone/driver/oauth2/dingtalk/dingtalk.go index 15e95a3f84..b0932ca437 100644 --- a/pkg/keystone/driver/oauth2/dingtalk/dingtalk.go +++ b/pkg/keystone/driver/oauth2/dingtalk/dingtalk.go @@ -25,9 +25,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/keystone/driver/oauth2" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SDingtalkOAuth2Driver struct { diff --git a/pkg/keystone/driver/oauth2/feishu/feishu.go b/pkg/keystone/driver/oauth2/feishu/feishu.go index cd138f7441..e1ac12fd32 100644 --- a/pkg/keystone/driver/oauth2/feishu/feishu.go +++ b/pkg/keystone/driver/oauth2/feishu/feishu.go @@ -21,9 +21,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/keystone/driver/oauth2" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SFeishuOAuth2Driver struct { diff --git a/pkg/keystone/driver/oauth2/qywechat/qywechat.go b/pkg/keystone/driver/oauth2/qywechat/qywechat.go index 411e56ead7..93434d6a3a 100644 --- a/pkg/keystone/driver/oauth2/qywechat/qywechat.go +++ b/pkg/keystone/driver/oauth2/qywechat/qywechat.go @@ -21,10 +21,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/keystone/driver/oauth2" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SQywxOAuth2Driver struct { diff --git a/pkg/keystone/driver/oauth2/wechat/wechat.go b/pkg/keystone/driver/oauth2/wechat/wechat.go index f2167a2ee1..2e928cb787 100644 --- a/pkg/keystone/driver/oauth2/wechat/wechat.go +++ b/pkg/keystone/driver/oauth2/wechat/wechat.go @@ -20,9 +20,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/keystone/driver/oauth2" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SWechatOAuth2Driver struct { diff --git a/pkg/keystone/driver/saml/saml.go b/pkg/keystone/driver/saml/saml.go index bb89439f07..0e0c7350bb 100644 --- a/pkg/keystone/driver/saml/saml.go +++ b/pkg/keystone/driver/saml/saml.go @@ -22,6 +22,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/samlutils" api "yunion.io/x/onecloud/pkg/apis/identity" "yunion.io/x/onecloud/pkg/httperrors" @@ -29,8 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/keystone/models" "yunion.io/x/onecloud/pkg/keystone/saml" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/samlutils/sp" ) diff --git a/pkg/keystone/locale/genpolicy.go b/pkg/keystone/locale/genpolicy.go index ec3cb09561..ff1c411230 100644 --- a/pkg/keystone/locale/genpolicy.go +++ b/pkg/keystone/locale/genpolicy.go @@ -18,8 +18,7 @@ import ( "strings" "yunion.io/x/jsonutils" - - "yunion.io/x/onecloud/pkg/util/rbacutils" + "yunion.io/x/pkg/util/rbacscope" ) var ( @@ -146,10 +145,10 @@ func GenerateAllPolicies() []SPolicyData { ret := make([]SPolicyData, 0) for i := range policyDefinitons { def := policyDefinitons[i] - for _, scope := range []rbacutils.TRbacScope{ - rbacutils.ScopeSystem, - rbacutils.ScopeDomain, - rbacutils.ScopeProject, + for _, scope := range []rbacscope.TRbacScope{ + rbacscope.ScopeSystem, + rbacscope.ScopeDomain, + rbacscope.ScopeProject, } { if scope.HigherEqual(def.Scope) { ps := generatePolicies(scope, def) @@ -163,24 +162,24 @@ func GenerateAllPolicies() []SPolicyData { type SPolicyData struct { Name string - Scope rbacutils.TRbacScope + Scope rbacscope.TRbacScope Policy jsonutils.JSONObject Description string DescriptionCN string } -func generatePolicies(scope rbacutils.TRbacScope, def sPolicyDefinition) []SPolicyData { +func generatePolicies(scope rbacscope.TRbacScope, def sPolicyDefinition) []SPolicyData { level := "" switch scope { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: level = "sys" - if def.Scope == rbacutils.ScopeSystem { + if def.Scope == rbacscope.ScopeSystem { level = "" } - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: level = "domain" - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: level = "project" } @@ -250,13 +249,13 @@ func generatePolicies(scope rbacutils.TRbacScope, def sPolicyDefinition) []SPoli desc := "" descCN := "" switch scope { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: descCN += "全局" desc += "System-level" - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: descCN += "本域内" desc += "Domain-level" - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: descCN += "本项目内" desc += "Project-level" } diff --git a/pkg/keystone/locale/predefined_policies.go b/pkg/keystone/locale/predefined_policies.go index e0195502e4..ddb21b26e3 100644 --- a/pkg/keystone/locale/predefined_policies.go +++ b/pkg/keystone/locale/predefined_policies.go @@ -15,7 +15,7 @@ package locale import ( - "yunion.io/x/onecloud/pkg/util/rbacutils" + "yunion.io/x/pkg/util/rbacscope" ) const ( @@ -38,7 +38,7 @@ type sPolicyDefinition struct { Name string DescCN string Desc string - Scope rbacutils.TRbacScope + Scope rbacscope.TRbacScope Services map[string][]string Extra map[string]map[string][]string } @@ -59,7 +59,7 @@ var ( Name: "", DescCN: "任意资源", Desc: "any resources", - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Services: map[string][]string{ "*": nil, }, @@ -68,7 +68,7 @@ var ( Name: "dashboard", DescCN: "控制面板查看相关资源", Desc: "resources for viewing dashboard", - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Extra: map[string]map[string][]string{ "compute": { "dashboard": { @@ -184,7 +184,7 @@ var ( Name: "compute", DescCN: "计算服务(云主机与容器)相关资源", Desc: "resources of computing (cloud servers and containers)", - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Services: map[string][]string{ "compute": nil, "image": nil, @@ -195,7 +195,7 @@ var ( Name: "server", DescCN: "云主机相关资源", Desc: "resources of cloud servers", - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Services: map[string][]string{ "compute": { "servers", @@ -232,7 +232,7 @@ var ( Name: "host", DescCN: "宿主机和物理机相关资源", Desc: "resources of hosts and baremetals", - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Services: map[string][]string{ "compute": { "hosts", @@ -249,7 +249,7 @@ var ( Name: "storage", DescCN: "云硬盘存储相关资源", Desc: "resources of cloud disk storages", - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Services: map[string][]string{ "compute": { "storages", @@ -260,7 +260,7 @@ var ( Name: "loadbalancer", DescCN: "负载均衡相关资源", Desc: "resources of load balancers", - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Services: map[string][]string{ "compute": { "loadbalanceracls", @@ -288,7 +288,7 @@ var ( Name: "oss", DescCN: "对象存储相关资源", Desc: "resources of object storages", - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Services: map[string][]string{ "compute": { "buckets", @@ -299,7 +299,7 @@ var ( Name: "dbinstance", DescCN: "关系型数据库(MySQL等)相关资源", Desc: "resources of RDS", - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Services: map[string][]string{ "compute": { "dbinstance_skus", @@ -317,7 +317,7 @@ var ( Name: "elasticcache", DescCN: "弹性缓存(Redis等)相关资源", Desc: "resources of elastic caches", - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Services: map[string][]string{ "compute": { "elasticcacheaccounts", @@ -333,7 +333,7 @@ var ( Name: "network", DescCN: "网络相关资源", Desc: "resources of networking", - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Services: map[string][]string{ "compute": { "vpcs", @@ -361,7 +361,7 @@ var ( Name: "snapshotpolicy", DescCN: "快照策略", Desc: "snapshot policy", - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Services: map[string][]string{ "compute": { "snapshotpolicies", @@ -373,7 +373,7 @@ var ( Name: "secgroup", DescCN: "安全组", Desc: "security group", - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Services: map[string][]string{ "compute": { "secgroups", @@ -385,7 +385,7 @@ var ( Name: "meter", DescCN: "计费计量分析服务相关资源", Desc: "resources of metering and billing service", - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Services: map[string][]string{ "meter": nil, "suggestion": nil, @@ -398,7 +398,7 @@ var ( Name: "identity", DescCN: "身份认证(IAM)服务相关资源", Desc: "resources of identity service", - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Services: map[string][]string{ "identity": nil, }, @@ -407,7 +407,7 @@ var ( Name: "image", DescCN: "镜像服务相关资源", Desc: "resources of image service", - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Services: map[string][]string{ "image": nil, }, @@ -416,7 +416,7 @@ var ( Name: "monitor", DescCN: "监控服务相关资源", Desc: "resources of monitor service", - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Services: map[string][]string{ "monitor": nil, }, @@ -425,7 +425,7 @@ var ( Name: "container", DescCN: "容器服务相关资源", Desc: "resources of container service", - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Services: map[string][]string{ "k8s": nil, }, @@ -434,7 +434,7 @@ var ( Name: "cloudid", DescCN: "云用户及权限管理相关资源", Desc: "resources of service CloudId and IAM", - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Services: map[string][]string{ "compute": { "cloudaccounts", @@ -452,7 +452,7 @@ var ( Name: "cloudaccount", DescCN: "云账号管理相关资源", Desc: "resources for cloud account administration", - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Services: map[string][]string{ "compute": { "cloudaccounts", @@ -466,7 +466,7 @@ var ( Name: "projectresource", DescCN: "项目管理相关资源", Desc: "resources for project administration", - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Services: map[string][]string{ "compute": { "project_quotas", @@ -488,7 +488,7 @@ var ( Name: "domainresource", DescCN: "域管理相关资源", Desc: "resources for domain administration", - Scope: rbacutils.ScopeSystem, + Scope: rbacscope.ScopeSystem, Services: map[string][]string{ "compute": { "domain_quotas", @@ -509,7 +509,7 @@ var ( Name: "notify", DescCN: "通知服务相关资源", Desc: "resources of notify service", - Scope: rbacutils.ScopeSystem, + Scope: rbacscope.ScopeSystem, Services: map[string][]string{ "notify": nil, }, diff --git a/pkg/keystone/locale/predefined_yaml.go b/pkg/keystone/locale/predefined_yaml.go index 459ffc23e4..322c59572f 100644 --- a/pkg/keystone/locale/predefined_yaml.go +++ b/pkg/keystone/locale/predefined_yaml.go @@ -17,8 +17,7 @@ package locale import ( "yunion.io/x/jsonutils" "yunion.io/x/log" - - "yunion.io/x/onecloud/pkg/util/rbacutils" + "yunion.io/x/pkg/util/rbacscope" ) var opsAdminPolicy = ` @@ -226,49 +225,49 @@ func toJson(yamlDef string) jsonutils.JSONObject { var predefinedPolicyData = []SPolicyData{ { Name: "sys-opsadmin", - Scope: rbacutils.ScopeSystem, + Scope: rbacscope.ScopeSystem, Policy: toJson(opsAdminPolicy), Description: "System-wide operation manager", DescriptionCN: "全局系统管理员权限", }, { Name: "sys-secadmin", - Scope: rbacutils.ScopeSystem, + Scope: rbacscope.ScopeSystem, Policy: toJson(secAdminPolicy), Description: "System-wide security manager", DescriptionCN: "全局安全管理员权限", }, { Name: "sys-adtadmin", - Scope: rbacutils.ScopeSystem, + Scope: rbacscope.ScopeSystem, Policy: toJson(adtAdminPolicy), Description: "System-wide audit manager", DescriptionCN: "全局审计管理员权限", }, { Name: "domain-opsadmin", - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Policy: toJson(opsAdminPolicy), Description: "Domain-wide operation manager", DescriptionCN: "组织系统管理员权限", }, { Name: "domain-secadmin", - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Policy: toJson(secAdminPolicy), Description: "Domain-wide security manager", DescriptionCN: "组织安全管理员权限", }, { Name: "domain-adtadmin", - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Policy: toJson(adtAdminPolicy), Description: "Domain-wide audit manager", DescriptionCN: "组织审计管理员权限", }, { Name: "normal-user", - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Policy: toJson(normalUserPolicy), Description: "Default policy for normal user", DescriptionCN: "普通用户默认权限", diff --git a/pkg/keystone/models/assignments.go b/pkg/keystone/models/assignments.go index a3ac7c46b2..88a19c8e35 100644 --- a/pkg/keystone/models/assignments.go +++ b/pkg/keystone/models/assignments.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -33,7 +34,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -313,11 +313,11 @@ func (manager *SAssignmentManager) ProjectAddUser(ctx context.Context, userCred // if project.DomainId != api.DEFAULT_DOMAIN_ID && !options.Options.AllowJoinProjectsAcrossDomains { // return httperrors.NewInputParameterError("join user into project of default domain or identical domain") // } else - if !db.IsAllowPerform(ctx, rbacutils.ScopeSystem, userCred, user, "join-project") { + if !db.IsAllowPerform(ctx, rbacscope.ScopeSystem, userCred, user, "join-project") { return httperrors.NewForbiddenError("not enough privilege") } } else { - if !db.IsAllowPerform(ctx, rbacutils.ScopeDomain, userCred, user, "join-project") { + if !db.IsAllowPerform(ctx, rbacscope.ScopeDomain, userCred, user, "join-project") { return httperrors.NewForbiddenError("not enough privilege") } } @@ -388,11 +388,11 @@ func (manager *SAssignmentManager) projectRemoveUser(ctx context.Context, userCr // if project.DomainId != api.DEFAULT_DOMAIN_ID { // return httperrors.NewInputParameterError("join user into project of default domain or identical domain") // } else - if !db.IsAllowPerform(ctx, rbacutils.ScopeSystem, userCred, user, "leave-project") { + if !db.IsAllowPerform(ctx, rbacscope.ScopeSystem, userCred, user, "leave-project") { return httperrors.NewForbiddenError("not enough privilege") } } else { - if !db.IsAllowPerform(ctx, rbacutils.ScopeDomain, userCred, user, "leave-project") { + if !db.IsAllowPerform(ctx, rbacscope.ScopeDomain, userCred, user, "leave-project") { return httperrors.NewForbiddenError("not enough privilege") } } @@ -414,11 +414,11 @@ func (manager *SAssignmentManager) projectAddGroup(ctx context.Context, userCred // if project.DomainId != api.DEFAULT_DOMAIN_ID && !options.Options.AllowJoinProjectsAcrossDomains { // return httperrors.NewInputParameterError("join group into project of default domain or identical domain") // } else - if !db.IsAllowPerform(ctx, rbacutils.ScopeSystem, userCred, group, "join-project") { + if !db.IsAllowPerform(ctx, rbacscope.ScopeSystem, userCred, group, "join-project") { return httperrors.NewForbiddenError("not enough privilege") } } else { - if !db.IsAllowPerform(ctx, rbacutils.ScopeDomain, userCred, group, "join-project") { + if !db.IsAllowPerform(ctx, rbacscope.ScopeDomain, userCred, group, "join-project") { return httperrors.NewForbiddenError("not enough privilege") } } @@ -436,11 +436,11 @@ func (manager *SAssignmentManager) projectRemoveGroup(ctx context.Context, userC // if project.DomainId != api.DEFAULT_DOMAIN_ID { // return httperrors.NewInputParameterError("join group into project of default domain or identical domain") // } else - if !db.IsAllowPerform(ctx, rbacutils.ScopeSystem, userCred, group, "leave-project") { + if !db.IsAllowPerform(ctx, rbacscope.ScopeSystem, userCred, group, "leave-project") { return httperrors.NewForbiddenError("not enough privilege") } } else { - if !db.IsAllowPerform(ctx, rbacutils.ScopeDomain, userCred, group, "leave-project") { + if !db.IsAllowPerform(ctx, rbacscope.ScopeDomain, userCred, group, "leave-project") { return httperrors.NewForbiddenError("not enough privilege") } } @@ -658,9 +658,9 @@ func (manager *SAssignmentManager) queryAll( func fetchRoleAssignmentPolicies(ra *api.SRoleAssignment) { policyNames, _, _ := RolePolicyManager.GetMatchPolicyGroup(ra, time.Time{}, true) - ra.Policies.Project, _ = policyNames[rbacutils.ScopeProject] - ra.Policies.Domain, _ = policyNames[rbacutils.ScopeDomain] - ra.Policies.System, _ = policyNames[rbacutils.ScopeSystem] + ra.Policies.Project, _ = policyNames[rbacscope.ScopeProject] + ra.Policies.Domain, _ = policyNames[rbacscope.ScopeDomain] + ra.Policies.System, _ = policyNames[rbacscope.ScopeSystem] } type sAssignmentInternal struct { diff --git a/pkg/keystone/models/credentials.go b/pkg/keystone/models/credentials.go index 9dd2bb607c..80a50bfc6b 100644 --- a/pkg/keystone/models/credentials.go +++ b/pkg/keystone/models/credentials.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/identity" @@ -30,7 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/keystone/keys" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -230,13 +230,13 @@ func (self *SCredential) GetAccessKeySecret() (*api.SAccessKeySecretBlob, error) return nil, errors.Error("no an AK/SK credential") } -func (manager *SCredentialManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeUser +func (manager *SCredentialManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeUser } -func (manager *SCredentialManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SCredentialManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { - if scope == rbacutils.ScopeUser { + if scope == rbacscope.ScopeUser { if len(owner.GetUserId()) > 0 { q = q.Equals("user_id", owner.GetUserId()) } diff --git a/pkg/keystone/models/groups.go b/pkg/keystone/models/groups.go index 4ec1b9520e..401e8e02e6 100644 --- a/pkg/keystone/models/groups.go +++ b/pkg/keystone/models/groups.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/identity" @@ -29,7 +30,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -302,8 +302,8 @@ func (manager *SGroupManager) fetchGroupById(gid string) *SGroup { return nil } -func (manager *SGroupManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SGroupManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (group *SGroup) getIdmapping() (*SIdmapping, error) { @@ -384,8 +384,8 @@ func (group *SGroup) PerformLeave( return nil, nil } -func (manager *SGroupManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { - if owner != nil && scope == rbacutils.ScopeProject { +func (manager *SGroupManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { + if owner != nil && scope == rbacscope.ScopeProject { // if user has project level privilege, returns all groups in user's project subq := AssignmentManager.fetchProjectGroupIdsQuery(owner.GetProjectId()) q = q.In("id", subq.SubQuery()) diff --git a/pkg/keystone/models/identity_provider.go b/pkg/keystone/models/identity_provider.go index d518bc8104..69be6fe2a9 100644 --- a/pkg/keystone/models/identity_provider.go +++ b/pkg/keystone/models/identity_provider.go @@ -26,6 +26,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -40,7 +41,6 @@ import ( "yunion.io/x/onecloud/pkg/keystone/saml" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/samlutils/sp" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -1279,7 +1279,7 @@ func (idp *SIdentityProvider) TryUserJoinProject(attrConf api.SIdpAttributeOptio projName := fetchAttribute(attrs, attrConf.ProjectAttribute) if len(projName) > 0 { projDomainId := "" - if ProjectManager.NamespaceScope() == rbacutils.ScopeDomain { + if ProjectManager.NamespaceScope() == rbacscope.ScopeDomain { projDomainId = domainId } targetProject, err = ProjectManager.FetchProject("", projName, projDomainId, "") diff --git a/pkg/keystone/models/identitybase.go b/pkg/keystone/models/identitybase.go index b374c89477..175a67e09e 100644 --- a/pkg/keystone/models/identitybase.go +++ b/pkg/keystone/models/identitybase.go @@ -21,13 +21,13 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/identity" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -407,9 +407,9 @@ func (model *SIdentityBaseResource) PostDelete(ctx context.Context, userCred mcc model.SStandaloneResourceBase.PostDelete(ctx, userCred) } -func (manager *SIdentityBaseResourceManager) totalCount(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider) int { +func (manager *SIdentityBaseResourceManager) totalCount(scope rbacscope.TRbacScope, ownerId mcclient.IIdentityProvider) int { q := manager.Query() - if scope != rbacutils.ScopeSystem { + if scope != rbacscope.ScopeSystem { q = q.Equals("domain_id", ownerId.GetProjectDomainId()) } cnt, _ := q.CountWithError() diff --git a/pkg/keystone/models/identityquota.go b/pkg/keystone/models/identityquota.go index 8886e0e890..a5d28662b1 100644 --- a/pkg/keystone/models/identityquota.go +++ b/pkg/keystone/models/identityquota.go @@ -19,13 +19,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/quotas" commonOptions "yunion.io/x/onecloud/pkg/cloudcommon/options" "yunion.io/x/onecloud/pkg/keystone/options" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SQuotaManager struct { @@ -44,7 +44,7 @@ func init() { IdentityUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(IdentityQuota, - rbacutils.ScopeDomain, + rbacscope.ScopeDomain, "identity_quota_usage_tbl", "identity_quota_usage", "identity_quota_usages", @@ -52,7 +52,7 @@ func init() { } IdentityPendingUsageManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaUsageManager(IdentityQuota, - rbacutils.ScopeDomain, + rbacscope.ScopeDomain, "identity_quota_pending_usage_tbl", "identity_quota_pending_usage", "identity_quota_pending_usages", @@ -60,7 +60,7 @@ func init() { } IdentityQuotaManager = &SQuotaManager{ SQuotaBaseManager: quotas.NewQuotaBaseManager(IdentityQuota, - rbacutils.ScopeDomain, + rbacscope.ScopeDomain, "identity_quota_tbl", IdentityPendingUsageManager, IdentityUsageManager, diff --git a/pkg/keystone/models/policies.go b/pkg/keystone/models/policies.go index 0b21e685a5..bcf0172dc7 100644 --- a/pkg/keystone/models/policies.go +++ b/pkg/keystone/models/policies.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/pkg/gotypes" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -85,7 +86,7 @@ type SPolicy struct { Blob jsonutils.JSONObject `nullable:"false" list:"user" create:"domain_required" update:"domain"` // 权限范围 - Scope rbacutils.TRbacScope `nullable:"true" list:"user" create:"domain_required" update:"domain"` + Scope rbacscope.TRbacScope `nullable:"true" list:"user" create:"domain_required" update:"domain"` // 是否为系统权限 IsSystem tristate.TriState `default:"false" list:"domain" update:"admin" create:"admin_optional"` @@ -240,7 +241,7 @@ func (manager *SPolicyManager) FetchEnabledPolicies() ([]SPolicy, error) { return policies, nil } -func validatePolicyVioldatePrivilege(userCred mcclient.TokenCredential, policyScope rbacutils.TRbacScope, policy *rbacutils.SPolicy) error { +func validatePolicyVioldatePrivilege(userCred mcclient.TokenCredential, policyScope rbacscope.TRbacScope, policy *rbacutils.SPolicy) error { if options.Options.NoPolicyViolationCheck { return nil } @@ -253,10 +254,10 @@ func validatePolicyVioldatePrivilege(userCred mcclient.TokenCredential, policySc } noViolate := false assignPolicySet := rbacutils.TPolicySet{*policy} - for _, scope := range []rbacutils.TRbacScope{ - rbacutils.ScopeSystem, - rbacutils.ScopeDomain, - rbacutils.ScopeProject, + for _, scope := range []rbacscope.TRbacScope{ + rbacscope.ScopeSystem, + rbacscope.ScopeDomain, + rbacscope.ScopeProject, } { isViolate := false policySet, ok := policyGroup[scope] @@ -296,7 +297,7 @@ func (manager *SPolicyManager) ValidateCreateData( return input, httperrors.NewInputParameterError("fail to decode policy data") } - input.Scope = rbacutils.String2ScopeDefault(string(input.Scope), rbacutils.ScopeProject) + input.Scope = rbacscope.String2ScopeDefault(string(input.Scope), rbacscope.ScopeProject) err = validatePolicyVioldatePrivilege(userCred, input.Scope, policy) if err != nil { @@ -327,7 +328,7 @@ func (manager *SPolicyManager) ValidateCreateData( requireScope := input.Scope if input.IsSystem != nil && *input.IsSystem { - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } allowScope, _ := policyman.PolicyManager.AllowScope(userCred, api.SERVICE_TYPE, manager.KeywordPlural(), policyman.PolicyActionCreate) if requireScope.HigherThan(allowScope) { @@ -338,14 +339,14 @@ func (manager *SPolicyManager) ValidateCreateData( } func (policy *SPolicy) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.PolicyUpdateInput) (api.PolicyUpdateInput, error) { - var requireScope rbacutils.TRbacScope + var requireScope rbacscope.TRbacScope if len(input.Scope) > 0 { - input.Scope = rbacutils.String2ScopeDefault(string(input.Scope), rbacutils.ScopeProject) + input.Scope = rbacscope.String2ScopeDefault(string(input.Scope), rbacscope.ScopeProject) requireScope = input.Scope } if input.IsSystem != nil && *input.IsSystem { - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } if len(requireScope) > 0 { @@ -518,10 +519,10 @@ func (manager *SPolicyManager) ListItemFilter( query.Scope = string(allowScope) } switch query.Scope { - case string(rbacutils.ScopeProject): - q = q.Equals("scope", rbacutils.ScopeProject) - case string(rbacutils.ScopeDomain): - q = q.NotEquals("scope", rbacutils.ScopeSystem) + case string(rbacscope.ScopeProject): + q = q.Equals("scope", rbacscope.ScopeProject) + case string(rbacscope.ScopeDomain): + q = q.NotEquals("scope", rbacscope.ScopeSystem) } return q, nil } @@ -584,7 +585,7 @@ func (policy *SPolicy) GetUsages() []db.IUsage { } } -func (manager *SPolicyManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SPolicyManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { q = db.SharableManagerFilterByOwner(manager, q, owner, scope) return q } diff --git a/pkg/keystone/models/projects.go b/pkg/keystone/models/projects.go index 475020ebc3..88ad591f17 100644 --- a/pkg/keystone/models/projects.go +++ b/pkg/keystone/models/projects.go @@ -25,6 +25,8 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/pinyinutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/identity" @@ -34,8 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/keystone/options" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/pinyinutils" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" "yunion.io/x/onecloud/pkg/util/tagutils" ) @@ -684,7 +684,7 @@ func (manager *SProjectManager) NewProject(ctx context.Context, projectName stri project := &SProject{} project.SetModelManager(ProjectManager, project) ownerId := &db.SOwnerId{} - if manager.NamespaceScope() == rbacutils.ScopeDomain { + if manager.NamespaceScope() == rbacscope.ScopeDomain { ownerId.DomainId = domainId } project.DomainId = domainId diff --git a/pkg/keystone/models/rolepolicies.go b/pkg/keystone/models/rolepolicies.go index 9cbe82c890..6d77f6a6ac 100644 --- a/pkg/keystone/models/rolepolicies.go +++ b/pkg/keystone/models/rolepolicies.go @@ -26,6 +26,7 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -171,11 +172,11 @@ func (rp *SRolePolicy) GetPolicy() *SPolicy { return policy.(*SPolicy) } -func (manager *SRolePolicyManager) NamespaceScope() rbacutils.TRbacScope { +func (manager *SRolePolicyManager) NamespaceScope() rbacscope.TRbacScope { return PolicyManager.NamespaceScope() } -func (manager *SRolePolicyManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SRolePolicyManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { policyQ := PolicyManager.Query() policyQ = PolicyManager.FilterByOwner(policyQ, owner, scope) subq := policyQ.SubQuery() @@ -395,7 +396,7 @@ func (manager *SRolePolicyManager) getMatchPolicyIds2(isGuest bool, roleIds []st return policyIds, nil } -func appendPolicy(names map[rbacutils.TRbacScope][]string, policies rbacutils.TPolicyGroup, scope rbacutils.TRbacScope, policyName string, nameOnly bool) (map[rbacutils.TRbacScope][]string, rbacutils.TPolicyGroup, error) { +func appendPolicy(names map[rbacscope.TRbacScope][]string, policies rbacutils.TPolicyGroup, scope rbacscope.TRbacScope, policyName string, nameOnly bool) (map[rbacscope.TRbacScope][]string, rbacutils.TPolicyGroup, error) { if utils.IsInStringArray(policyName, names[scope]) { return names, policies, nil } @@ -418,7 +419,7 @@ func appendPolicy(names map[rbacutils.TRbacScope][]string, policies rbacutils.TP return names, policies, nil } -func (manager *SRolePolicyManager) GetMatchPolicyGroup(userCred rbacutils.IRbacIdentity, tm time.Time, nameOnly bool) (map[rbacutils.TRbacScope][]string, rbacutils.TPolicyGroup, error) { +func (manager *SRolePolicyManager) GetMatchPolicyGroup(userCred rbacutils.IRbacIdentity, tm time.Time, nameOnly bool) (map[rbacscope.TRbacScope][]string, rbacutils.TPolicyGroup, error) { policyIds, err := manager.getMatchPolicyIds(userCred, tm) if err != nil { return nil, nil, errors.Wrap(err, "getMatchPolicyIds") @@ -426,7 +427,7 @@ func (manager *SRolePolicyManager) GetMatchPolicyGroup(userCred rbacutils.IRbacI return manager.GetPolicyGroupByIds(policyIds, nameOnly) } -func (manager *SRolePolicyManager) GetMatchPolicyGroupByCred(userCred mcclient.TokenCredential, tm time.Time, nameOnly bool) (map[rbacutils.TRbacScope][]string, rbacutils.TPolicyGroup, error) { +func (manager *SRolePolicyManager) GetMatchPolicyGroupByCred(userCred mcclient.TokenCredential, tm time.Time, nameOnly bool) (map[rbacscope.TRbacScope][]string, rbacutils.TPolicyGroup, error) { names, policies, err := manager.GetMatchPolicyGroup(userCred, tm, nameOnly) if err != nil { return nil, nil, errors.Wrap(err, "GetMatchPolicyGroup") @@ -446,11 +447,11 @@ func (manager *SRolePolicyManager) GetMatchPolicyGroupByCred(userCred mcclient.T for scope := range names { consolePolicyName := "" switch scope { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: consolePolicyName = options.Options.SystemDashboardPolicy - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: consolePolicyName = options.Options.DomainDashboardPolicy - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: consolePolicyName = options.Options.ProjectDashboardPolicy } names, policies, err = appendPolicy(names, policies, scope, consolePolicyName, nameOnly) @@ -462,7 +463,7 @@ func (manager *SRolePolicyManager) GetMatchPolicyGroupByCred(userCred mcclient.T return names, policies, nil } -func (manager *SRolePolicyManager) GetMatchPolicyGroup2(isGuest bool, roleIds []string, pid string, loginIp string, tm time.Time, nameOnly bool) (map[rbacutils.TRbacScope][]string, rbacutils.TPolicyGroup, error) { +func (manager *SRolePolicyManager) GetMatchPolicyGroup2(isGuest bool, roleIds []string, pid string, loginIp string, tm time.Time, nameOnly bool) (map[rbacscope.TRbacScope][]string, rbacutils.TPolicyGroup, error) { policyIds, err := manager.getMatchPolicyIds2(isGuest, roleIds, pid, loginIp, tm) if err != nil { return nil, nil, errors.Wrap(err, "getMatchPolicyIds") @@ -470,8 +471,8 @@ func (manager *SRolePolicyManager) GetMatchPolicyGroup2(isGuest bool, roleIds [] return manager.GetPolicyGroupByIds(policyIds, nameOnly) } -func (manager *SRolePolicyManager) GetPolicyGroupByIds(policyIds []string, nameOnly bool) (map[rbacutils.TRbacScope][]string, rbacutils.TPolicyGroup, error) { - names := make(map[rbacutils.TRbacScope][]string) +func (manager *SRolePolicyManager) GetPolicyGroupByIds(policyIds []string, nameOnly bool) (map[rbacscope.TRbacScope][]string, rbacutils.TPolicyGroup, error) { + names := make(map[rbacscope.TRbacScope][]string) var group rbacutils.TPolicyGroup if !nameOnly { group = rbacutils.TPolicyGroup{} diff --git a/pkg/keystone/models/roles.go b/pkg/keystone/models/roles.go index 0bf38a7959..2597043025 100644 --- a/pkg/keystone/models/roles.go +++ b/pkg/keystone/models/roles.go @@ -26,6 +26,7 @@ import ( "yunion.io/x/pkg/gotypes" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/keystone/locale" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -152,7 +152,7 @@ func (manager *SRoleManager) initSysRole(ctx context.Context) error { role := SRole{} role.Name = api.SystemAdminRole role.IsPublic = true - role.PublicScope = string(rbacutils.ScopeSystem) + role.PublicScope = string(rbacscope.ScopeSystem) role.DomainId = api.DEFAULT_DOMAIN_ID role.Description = "Boostrap system default admin role" role.SetModelManager(manager, &role) @@ -532,7 +532,7 @@ func (role *SRole) PostCreate( } } -func (manager *SRoleManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SRoleManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { return db.SharableManagerFilterByOwner(manager, q, owner, scope) } diff --git a/pkg/keystone/models/users.go b/pkg/keystone/models/users.go index 1440dacca9..6a8ce4b41b 100644 --- a/pkg/keystone/models/users.go +++ b/pkg/keystone/models/users.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/identity" @@ -36,7 +37,6 @@ import ( o "yunion.io/x/onecloud/pkg/keystone/options" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/seclib2" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -465,7 +465,7 @@ func (manager *SUserManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field s return q, httperrors.ErrNotFound } -func (manager *SUserManager) FilterByHiddenSystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SUserManager) FilterByHiddenSystemAttributes(q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject, scope rbacscope.TRbacScope) *sqlchemy.SQuery { q = manager.SEnabledIdentityBaseResourceManager.FilterByHiddenSystemAttributes(q, userCred, query, scope) isSystem := jsonutils.QueryBoolean(query, "system", false) if isSystem { @@ -960,8 +960,8 @@ func tokenV3LoginSession(token *mcclient.TokenCredentialV3) sLoginSession { return s } -func (manager *SUserManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (manager *SUserManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (user *SUser) getIdmappings() ([]SIdmapping, error) { @@ -1133,9 +1133,9 @@ func (manager *SUserManager) LockUser(uid string, reason string) error { return nil } -func (manager *SUserManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SUserManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { log.Debugf("owner: %s scope %s", jsonutils.Marshal(owner), scope) - if owner != nil && scope == rbacutils.ScopeProject { + if owner != nil && scope == rbacscope.ScopeProject { // if user has project level privilege, returns all users in user's project subq := AssignmentManager.fetchProjectUserIdsQuery(owner.GetProjectId()) q = q.In("id", subq.SubQuery()) diff --git a/pkg/keystone/policy/defaults.go b/pkg/keystone/policy/defaults.go index 7e952f9407..f9c478931f 100644 --- a/pkg/keystone/policy/defaults.go +++ b/pkg/keystone/policy/defaults.go @@ -15,6 +15,8 @@ package policy import ( + "yunion.io/x/pkg/util/rbacscope" + api "yunion.io/x/onecloud/pkg/apis/identity" common_policy "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/util/rbacutils" @@ -33,7 +35,7 @@ var ( predefinedDefaultPolicies = []rbacutils.SRbacPolicy{ { Auth: true, - Scope: rbacutils.ScopeSystem, + Scope: rbacscope.ScopeSystem, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -51,7 +53,7 @@ var ( }, { Auth: true, - Scope: rbacutils.ScopeUser, + Scope: rbacscope.ScopeUser, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -87,7 +89,7 @@ var ( }, { Auth: true, - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -106,7 +108,7 @@ var ( { // for domain Auth: true, - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -119,7 +121,7 @@ var ( { // for policies administration Auth: true, - Scope: rbacutils.ScopeSystem, + Scope: rbacscope.ScopeSystem, DomainId: api.DEFAULT_DOMAIN_ID, Projects: []string{api.SystemAdminProject}, Roles: []string{api.SystemAdminRole}, diff --git a/pkg/keystone/saml/init.go b/pkg/keystone/saml/init.go index 50610bbabc..eb6dc09088 100644 --- a/pkg/keystone/saml/init.go +++ b/pkg/keystone/saml/init.go @@ -18,10 +18,10 @@ import ( "os" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/keystone/options" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/seclib2" ) diff --git a/pkg/keystone/saml/metadata.go b/pkg/keystone/saml/metadata.go index a78ef53709..060dada45e 100644 --- a/pkg/keystone/saml/metadata.go +++ b/pkg/keystone/saml/metadata.go @@ -18,8 +18,9 @@ import ( "encoding/xml" "fmt" + "yunion.io/x/pkg/util/samlutils" + "yunion.io/x/onecloud/pkg/keystone/options" - "yunion.io/x/onecloud/pkg/util/samlutils" ) func GetMetadata(idpName string, pretty bool) string { diff --git a/pkg/keystone/tokens/auth.go b/pkg/keystone/tokens/auth.go index 60198f7e6e..a0775c66b6 100644 --- a/pkg/keystone/tokens/auth.go +++ b/pkg/keystone/tokens/auth.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/s3auth" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" notify_modules "yunion.io/x/onecloud/pkg/mcclient/modules/notify" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/s3auth" ) func authUserByTokenV2(ctx context.Context, input mcclient.SAuthenticationInputV2) (*api.SUserExtended, error) { diff --git a/pkg/keystone/tokens/handlers.go b/pkg/keystone/tokens/handlers.go index b37bf13425..434eeff630 100644 --- a/pkg/keystone/tokens/handlers.go +++ b/pkg/keystone/tokens/handlers.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/identity" @@ -30,7 +31,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/util/netutils2" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) func AddHandler(app *appsrv.Application) { @@ -220,7 +220,7 @@ func verifyCommon(ctx context.Context, w http.ResponseWriter, tokenStr string) ( if adminToken == nil || len(tokenStr) == 0 { return nil, httperrors.NewForbiddenError("missing auth token") } - if adminToken.IsAllow(rbacutils.ScopeSystem, api.SERVICE_TYPE, "tokens", "perform", "auth").Result.IsDeny() { + if adminToken.IsAllow(rbacscope.ScopeSystem, api.SERVICE_TYPE, "tokens", "perform", "auth").Result.IsDeny() { return nil, httperrors.NewForbiddenError("%s not allow to auth", adminToken.GetUserName()) } token := SAuthToken{} diff --git a/pkg/keystone/tokens/token.go b/pkg/keystone/tokens/token.go index d6a8b8198a..f180e7471e 100644 --- a/pkg/keystone/tokens/token.go +++ b/pkg/keystone/tokens/token.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/identity" @@ -28,7 +29,6 @@ import ( "yunion.io/x/onecloud/pkg/keystone/models" "yunion.io/x/onecloud/pkg/keystone/options" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) var ( @@ -355,9 +355,9 @@ func (t *SAuthToken) getTokenV3( } policyNames, _, _ := models.RolePolicyManager.GetMatchPolicyGroup(&token, time.Time{}, true) - token.Token.Policies.Project, _ = policyNames[rbacutils.ScopeProject] - token.Token.Policies.Domain, _ = policyNames[rbacutils.ScopeDomain] - token.Token.Policies.System, _ = policyNames[rbacutils.ScopeSystem] + token.Token.Policies.Project, _ = policyNames[rbacscope.ScopeProject] + token.Token.Policies.Domain, _ = policyNames[rbacscope.ScopeDomain] + token.Token.Policies.System, _ = policyNames[rbacscope.ScopeSystem] endpoints, err := models.EndpointManager.FetchAll() if err != nil { diff --git a/pkg/keystone/usages/handler.go b/pkg/keystone/usages/handler.go index 0ca8f9a8bb..a0aab1deeb 100644 --- a/pkg/keystone/usages/handler.go +++ b/pkg/keystone/usages/handler.go @@ -20,6 +20,7 @@ import ( "net/http" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/consts" @@ -28,7 +29,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/keystone/models" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/tagutils" ) @@ -55,7 +55,7 @@ func ReportGeneralUsage(ctx context.Context, w http.ResponseWriter, r *http.Requ result.ProjectTags = *projectTags isAdmin := false - if policy.PolicyManager.Allow(rbacutils.ScopeSystem, userCred, consts.GetServiceType(), + if policy.PolicyManager.Allow(rbacscope.ScopeSystem, userCred, consts.GetServiceType(), "usages", policy.PolicyActionGet).Result.IsAllow() { isAdmin = true } diff --git a/pkg/logger/models/baremetalevents.go b/pkg/logger/models/baremetalevents.go index 20bd39077f..48d5617134 100644 --- a/pkg/logger/models/baremetalevents.go +++ b/pkg/logger/models/baremetalevents.go @@ -20,6 +20,7 @@ import ( "time" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/sqlchemy/backends/clickhouse" @@ -27,7 +28,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SBaremetalEventManager struct { @@ -104,8 +104,8 @@ func (manager *SBaremetalEventManager) CreateByInsertOrUpdate() bool { return false } -func (manager *SBaremetalEventManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (manager *SBaremetalEventManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (manager *SBaremetalEventManager) GetPagingConfig() *db.SPagingConfig { diff --git a/pkg/logger/policy/defaults.go b/pkg/logger/policy/defaults.go index 40fe6dc4d9..1545ca9fd6 100644 --- a/pkg/logger/policy/defaults.go +++ b/pkg/logger/policy/defaults.go @@ -15,6 +15,8 @@ package policy import ( + "yunion.io/x/pkg/util/rbacscope" + api "yunion.io/x/onecloud/pkg/apis/logger" common_policy "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/util/rbacutils" @@ -30,7 +32,7 @@ var ( predefinedDefaultPolicies = []rbacutils.SRbacPolicy{ { Auth: true, - Scope: rbacutils.ScopeUser, + Scope: rbacscope.ScopeUser, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, diff --git a/pkg/mcclient/aksk.go b/pkg/mcclient/aksk.go index c39e16fecb..48a03f2a0a 100644 --- a/pkg/mcclient/aksk.go +++ b/pkg/mcclient/aksk.go @@ -22,10 +22,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/s3auth" api "yunion.io/x/onecloud/pkg/apis/identity" "yunion.io/x/onecloud/pkg/util/netutils2" - "yunion.io/x/onecloud/pkg/util/s3auth" ) type SAkskTokenCredential struct { diff --git a/pkg/mcclient/auth/aksk.go b/pkg/mcclient/auth/aksk.go index e2b126a9d5..b5563deb8d 100644 --- a/pkg/mcclient/auth/aksk.go +++ b/pkg/mcclient/auth/aksk.go @@ -19,9 +19,9 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/cache" + "yunion.io/x/pkg/util/s3auth" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/s3auth" ) type sAccessKeyCache struct { diff --git a/pkg/mcclient/auth/middleware.go b/pkg/mcclient/auth/middleware.go index dccbe9b82c..5e1bb830dc 100644 --- a/pkg/mcclient/auth/middleware.go +++ b/pkg/mcclient/auth/middleware.go @@ -19,9 +19,9 @@ import ( "net/http" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" api "yunion.io/x/onecloud/pkg/apis/identity" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/cloudpods.go b/pkg/mcclient/cloudpods/cloudpods.go similarity index 98% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/cloudpods.go rename to pkg/mcclient/cloudpods/cloudpods.go index 811f709d26..83b3f6e603 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/cloudpods.go +++ b/pkg/mcclient/cloudpods/cloudpods.go @@ -20,16 +20,15 @@ import ( "net/http" "strings" - "yunion.io/x/jsonutils" - "yunion.io/x/pkg/errors" - - "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/mcclient/modulebase" - "yunion.io/x/onecloud/pkg/mcclient/modules" - "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/jsonutils" + "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/printutils" + + "yunion.io/x/onecloud/pkg/mcclient" + "yunion.io/x/onecloud/pkg/mcclient/modules" + "yunion.io/x/onecloud/pkg/mcclient/modules/compute" ) const ( @@ -48,7 +47,7 @@ var ( ) type ModelManager interface { - List(session *mcclient.ClientSession, params jsonutils.JSONObject) (*modulebase.ListResult, error) + List(session *mcclient.ClientSession, params jsonutils.JSONObject) (*printutils.ListResult, error) Create(session *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) Delete(session *mcclient.ClientSession, id string, param jsonutils.JSONObject) (jsonutils.JSONObject, error) PerformAction(session *mcclient.ClientSession, id string, action string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/disk.go b/pkg/mcclient/cloudpods/disk.go similarity index 99% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/disk.go rename to pkg/mcclient/cloudpods/disk.go index dcc5990979..ff2814beeb 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/disk.go +++ b/pkg/mcclient/cloudpods/disk.go @@ -19,13 +19,12 @@ import ( "fmt" "time" + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/jsonutils" api "yunion.io/x/onecloud/pkg/apis/compute" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SDisk struct { diff --git a/pkg/cloudcommon/object/doc.go b/pkg/mcclient/cloudpods/doc.go similarity index 88% rename from pkg/cloudcommon/object/doc.go rename to pkg/mcclient/cloudpods/doc.go index ac9e878b84..724776177d 100644 --- a/pkg/cloudcommon/object/doc.go +++ b/pkg/mcclient/cloudpods/doc.go @@ -12,4 +12,4 @@ // See the License for the specific language governing permissions and // limitations under the License. -package object // import "yunion.io/x/onecloud/pkg/cloudcommon/object" +package cloudpods // import "yunion.io/x/onecloud/pkg/mcclient/cloudpods" diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/eip.go b/pkg/mcclient/cloudpods/eip.go similarity index 99% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/eip.go rename to pkg/mcclient/cloudpods/eip.go index bd0cb70cb8..0f68934e42 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/eip.go +++ b/pkg/mcclient/cloudpods/eip.go @@ -17,13 +17,12 @@ package cloudpods import ( "time" + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/jsonutils" api "yunion.io/x/onecloud/pkg/apis/compute" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SEip struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/host.go b/pkg/mcclient/cloudpods/host.go similarity index 99% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/host.go rename to pkg/mcclient/cloudpods/host.go index 6e7f49ae79..30415fd063 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/host.go +++ b/pkg/mcclient/cloudpods/host.go @@ -15,15 +15,14 @@ package cloudpods import ( + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" api "yunion.io/x/onecloud/pkg/apis/compute" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SHost struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/image.go b/pkg/mcclient/cloudpods/image.go similarity index 97% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/image.go rename to pkg/mcclient/cloudpods/image.go index c6a34944ff..39407d8e74 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/image.go +++ b/pkg/mcclient/cloudpods/image.go @@ -18,16 +18,15 @@ import ( "context" "time" + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/imagetools" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/image" modules "yunion.io/x/onecloud/pkg/mcclient/modules/image" - "yunion.io/x/onecloud/pkg/util/imagetools" - "yunion.io/x/onecloud/pkg/util/qemuimg" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SImage struct { @@ -189,7 +188,7 @@ func (self *SRegion) GetImage(id string) (*SImage, error) { } func (self *SRegion) UploadImage(ctx context.Context, opts *cloudprovider.SImageCreateOption, callback func(progress float32)) (string, error) { - reader, sizeByte, err := opts.GetReader(opts.ImageId, string(qemuimg.QCOW2)) + reader, sizeByte, err := opts.GetReader(opts.ImageId, string(qemuimgfmt.QCOW2)) if err != nil { return "", err } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/instance.go b/pkg/mcclient/cloudpods/instance.go similarity index 99% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/instance.go rename to pkg/mcclient/cloudpods/instance.go index 83c1b4af5e..db8b4676d4 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/instance.go +++ b/pkg/mcclient/cloudpods/instance.go @@ -19,6 +19,8 @@ import ( "fmt" "time" + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/utils" @@ -30,9 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/modules/logger" "yunion.io/x/onecloud/pkg/mcclient/modules/monitor" "yunion.io/x/onecloud/pkg/mcclient/modules/webconsole" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SInstance struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/instancenic.go b/pkg/mcclient/cloudpods/instancenic.go similarity index 99% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/instancenic.go rename to pkg/mcclient/cloudpods/instancenic.go index 63726f6701..4cce36e518 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/instancenic.go +++ b/pkg/mcclient/cloudpods/instancenic.go @@ -17,13 +17,12 @@ package cloudpods import ( "fmt" + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/jsonutils" api "yunion.io/x/onecloud/pkg/apis/compute" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SInstanceNic struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/keypair.go b/pkg/mcclient/cloudpods/keypair.go similarity index 100% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/keypair.go rename to pkg/mcclient/cloudpods/keypair.go diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/network.go b/pkg/mcclient/cloudpods/network.go similarity index 95% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/network.go rename to pkg/mcclient/cloudpods/network.go index 15daa732e2..100dee40e6 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/network.go +++ b/pkg/mcclient/cloudpods/network.go @@ -15,14 +15,13 @@ package cloudpods import ( + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/compute" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - "yunion.io/x/onecloud/pkg/util/rbacutils" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SNetwork struct { @@ -77,8 +76,8 @@ func (self *SNetwork) GetServerType() string { return self.ServerType } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.TRbacScope(self.PublicScope) +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.TRbacScope(self.PublicScope) } func (self *SNetwork) GetAllocTimeoutSeconds() int { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/project.go b/pkg/mcclient/cloudpods/project.go similarity index 100% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/project.go rename to pkg/mcclient/cloudpods/project.go index de02821465..392c9a579a 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/project.go +++ b/pkg/mcclient/cloudpods/project.go @@ -15,12 +15,12 @@ package cloudpods import ( + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" + "yunion.io/x/onecloud/pkg/apis/compute" api "yunion.io/x/onecloud/pkg/apis/identity" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SProject struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/provider/doc.go b/pkg/mcclient/cloudpods/provider/doc.go similarity index 100% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/provider/doc.go rename to pkg/mcclient/cloudpods/provider/doc.go diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/provider/provider.go b/pkg/mcclient/cloudpods/provider/provider.go similarity index 98% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/provider/provider.go rename to pkg/mcclient/cloudpods/provider/provider.go index 4e2bd6f998..cbd7be727b 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/provider/provider.go +++ b/pkg/mcclient/cloudpods/provider/provider.go @@ -17,12 +17,12 @@ package provider import ( "context" - "github.com/pkg/errors" - "yunion.io/x/jsonutils" - api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud/cloudpods" + "yunion.io/x/jsonutils" + "yunion.io/x/pkg/errors" + + "yunion.io/x/onecloud/pkg/mcclient/cloudpods" ) type SCloudpodsProviderFactory struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/region.go b/pkg/mcclient/cloudpods/region.go similarity index 99% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/region.go rename to pkg/mcclient/cloudpods/region.go index abae26d509..9dd510f367 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/region.go +++ b/pkg/mcclient/cloudpods/region.go @@ -17,12 +17,11 @@ package cloudpods import ( "fmt" + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/jsonutils" api "yunion.io/x/onecloud/pkg/apis/compute" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SRegion struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/secgroup.go b/pkg/mcclient/cloudpods/secgroup.go similarity index 99% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/secgroup.go rename to pkg/mcclient/cloudpods/secgroup.go index 1b0421d770..6e4f4ce433 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/secgroup.go +++ b/pkg/mcclient/cloudpods/secgroup.go @@ -18,14 +18,13 @@ import ( "fmt" "strings" + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/secrules" api "yunion.io/x/onecloud/pkg/apis/compute" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SSecurityGroup struct { diff --git a/pkg/mcclient/cloudpods/shell/disk.go b/pkg/mcclient/cloudpods/shell/disk.go new file mode 100644 index 0000000000..a06a0dafdf --- /dev/null +++ b/pkg/mcclient/cloudpods/shell/disk.go @@ -0,0 +1,36 @@ +// 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 shell + +import ( + "yunion.io/x/pkg/util/shellutils" + + "yunion.io/x/onecloud/pkg/mcclient/cloudpods" +) + +func init() { + type DiskListOptions struct { + StorageId string + ServerId string + } + shellutils.R(&DiskListOptions{}, "disk-list", "List disks", func(cli *cloudpods.SRegion, args *DiskListOptions) error { + disks, err := cli.GetDisks(args.StorageId, args.ServerId) + if err != nil { + return err + } + printList(disks, 0, 0, 0, nil) + return nil + }) +} diff --git a/pkg/util/cloudinit/doc.go b/pkg/mcclient/cloudpods/shell/doc.go similarity index 88% rename from pkg/util/cloudinit/doc.go rename to pkg/mcclient/cloudpods/shell/doc.go index 1d51f2ce3e..ba7f567fb9 100644 --- a/pkg/util/cloudinit/doc.go +++ b/pkg/mcclient/cloudpods/shell/doc.go @@ -12,4 +12,4 @@ // See the License for the specific language governing permissions and // limitations under the License. -package cloudinit // import "yunion.io/x/onecloud/pkg/util/cloudinit" +package shell // import "yunion.io/x/onecloud/pkg/mcclient/cloudpods/shell" diff --git a/pkg/mcclient/cloudpods/shell/hosts.go b/pkg/mcclient/cloudpods/shell/hosts.go new file mode 100644 index 0000000000..dcf0edb83f --- /dev/null +++ b/pkg/mcclient/cloudpods/shell/hosts.go @@ -0,0 +1,35 @@ +// 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 shell + +import ( + "yunion.io/x/pkg/util/shellutils" + + "yunion.io/x/onecloud/pkg/mcclient/cloudpods" +) + +func init() { + type HostListOptions struct { + ZoneId string + } + shellutils.R(&HostListOptions{}, "host-list", "List hosts", func(cli *cloudpods.SRegion, args *HostListOptions) error { + hosts, err := cli.GetHosts(args.ZoneId) + if err != nil { + return err + } + printList(hosts, 0, 0, 0, nil) + return nil + }) +} diff --git a/pkg/mcclient/cloudpods/shell/image.go b/pkg/mcclient/cloudpods/shell/image.go new file mode 100644 index 0000000000..f519e3aa32 --- /dev/null +++ b/pkg/mcclient/cloudpods/shell/image.go @@ -0,0 +1,48 @@ +// 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 shell + +import ( + "yunion.io/x/pkg/util/shellutils" + + "yunion.io/x/onecloud/pkg/mcclient/cloudpods" +) + +func init() { + type ImageListOptions struct { + } + shellutils.R(&ImageListOptions{}, "image-list", "List instances", func(cli *cloudpods.SRegion, args *ImageListOptions) error { + images, err := cli.GetImages() + if err != nil { + return err + } + printList(images, 0, 0, 0, nil) + return nil + }) + + type ImageIdOptions struct { + ID string + } + + shellutils.R(&ImageIdOptions{}, "image-show", "Show instance", func(cli *cloudpods.SRegion, args *ImageIdOptions) error { + image, err := cli.GetImage(args.ID) + if err != nil { + return err + } + printObject(image) + return nil + }) + +} diff --git a/pkg/mcclient/cloudpods/shell/instance.go b/pkg/mcclient/cloudpods/shell/instance.go new file mode 100644 index 0000000000..b01c8a25fd --- /dev/null +++ b/pkg/mcclient/cloudpods/shell/instance.go @@ -0,0 +1,82 @@ +// 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 shell + +import ( + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/util/shellutils" + + "yunion.io/x/onecloud/pkg/mcclient/cloudpods" +) + +func init() { + type InstanceListOptions struct { + HostId string + } + shellutils.R(&InstanceListOptions{}, "instance-list", "List instances", func(cli *cloudpods.SRegion, args *InstanceListOptions) error { + instances, err := cli.GetInstances(args.HostId) + if err != nil { + return err + } + printList(instances, 0, 0, 0, nil) + return nil + }) + + type InstanceIdOptions struct { + ID string + } + + shellutils.R(&InstanceIdOptions{}, "instance-show", "Show instance", func(cli *cloudpods.SRegion, args *InstanceIdOptions) error { + instance, err := cli.GetInstance(args.ID) + if err != nil { + return err + } + printObject(instance) + return nil + }) + + shellutils.R(&InstanceIdOptions{}, "instance-vnc", "Show instance vnc", func(cli *cloudpods.SRegion, args *InstanceIdOptions) error { + vnc, err := cli.GetInstanceVnc(args.ID, "") + if err != nil { + return err + } + printObject(vnc) + return nil + }) + + type InstanceSaveImageOptions struct { + ID string + NAME string + Note string + } + + shellutils.R(&InstanceSaveImageOptions{}, "instance-save-image", "Save instance image", func(cli *cloudpods.SRegion, args *InstanceSaveImageOptions) error { + image, err := cli.SaveImage(args.ID, args.NAME, args.Note) + if err != nil { + return err + } + printObject(image) + return nil + }) + + shellutils.R(&cloudprovider.MetricListOptions{}, "instance-monitor-list", "Instance Monitor List", func(cli *cloudpods.SRegion, opts *cloudprovider.MetricListOptions) error { + metrics, err := cli.GetClient().GetMetrics(opts) + if err != nil { + return err + } + printList(metrics, len(metrics), 0, 0, []string{}) + return nil + }) +} diff --git a/pkg/mcclient/cloudpods/shell/network.go b/pkg/mcclient/cloudpods/shell/network.go new file mode 100644 index 0000000000..e1deb9712d --- /dev/null +++ b/pkg/mcclient/cloudpods/shell/network.go @@ -0,0 +1,35 @@ +// 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 shell + +import ( + "yunion.io/x/pkg/util/shellutils" + + "yunion.io/x/onecloud/pkg/mcclient/cloudpods" +) + +func init() { + type NetworkListOptions struct { + WireId string + } + shellutils.R(&NetworkListOptions{}, "network-list", "List networks", func(cli *cloudpods.SRegion, args *NetworkListOptions) error { + networks, err := cli.GetNetworks(args.WireId) + if err != nil { + return err + } + printList(networks, 0, 0, 0, nil) + return nil + }) +} diff --git a/pkg/util/billing/doc.go b/pkg/mcclient/cloudpods/shell/printutils.go similarity index 67% rename from pkg/util/billing/doc.go rename to pkg/mcclient/cloudpods/shell/printutils.go index 67ff2d0f40..a04ad1223a 100644 --- a/pkg/util/billing/doc.go +++ b/pkg/mcclient/cloudpods/shell/printutils.go @@ -12,4 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -package billing // import "yunion.io/x/onecloud/pkg/util/billing" +package shell + +import "yunion.io/x/pkg/util/printutils" + +func printList(data interface{}, total, offset, limit int, columns []string) { + printutils.PrintInterfaceList(data, total, offset, limit, columns) +} + +func printObject(obj interface{}) { + printutils.PrintInterfaceObject(obj) +} diff --git a/pkg/mcclient/cloudpods/shell/region.go b/pkg/mcclient/cloudpods/shell/region.go new file mode 100644 index 0000000000..d082aac80f --- /dev/null +++ b/pkg/mcclient/cloudpods/shell/region.go @@ -0,0 +1,34 @@ +// 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 shell + +import ( + "yunion.io/x/pkg/util/shellutils" + + "yunion.io/x/onecloud/pkg/mcclient/cloudpods" +) + +func init() { + type RegionListOptions struct { + } + shellutils.R(&RegionListOptions{}, "region-list", "List regions", func(cli *cloudpods.SRegion, args *RegionListOptions) error { + regions, err := cli.GetClient().GetRegions() + if err != nil { + return err + } + printList(regions, 0, 0, 0, nil) + return nil + }) +} diff --git a/pkg/mcclient/cloudpods/shell/secgroup.go b/pkg/mcclient/cloudpods/shell/secgroup.go new file mode 100644 index 0000000000..09a9ecabb9 --- /dev/null +++ b/pkg/mcclient/cloudpods/shell/secgroup.go @@ -0,0 +1,47 @@ +// 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 shell + +import ( + "yunion.io/x/pkg/util/shellutils" + + "yunion.io/x/onecloud/pkg/mcclient/cloudpods" +) + +func init() { + type SecurityGroupListOptions struct { + } + shellutils.R(&SecurityGroupListOptions{}, "security-group-list", "List security-groups", func(cli *cloudpods.SRegion, args *SecurityGroupListOptions) error { + groups, err := cli.GetSecurityGroups() + if err != nil { + return err + } + printList(groups, 0, 0, 0, nil) + return nil + }) + + type SecurityGroupIdOptions struct { + ID string + } + shellutils.R(&SecurityGroupIdOptions{}, "security-group-show", "Show security group", func(cli *cloudpods.SRegion, args *SecurityGroupIdOptions) error { + group, err := cli.GetSecurityGroup(args.ID) + if err != nil { + return err + } + printObject(group) + return nil + }) + +} diff --git a/pkg/util/pinyinutils/pinyin_test.go b/pkg/mcclient/cloudpods/shell/vpc.go similarity index 62% rename from pkg/util/pinyinutils/pinyin_test.go rename to pkg/mcclient/cloudpods/shell/vpc.go index 3010343379..9314789026 100644 --- a/pkg/util/pinyinutils/pinyin_test.go +++ b/pkg/mcclient/cloudpods/shell/vpc.go @@ -12,25 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -package pinyinutils +package shell import ( - "testing" + "yunion.io/x/pkg/util/shellutils" + + "yunion.io/x/onecloud/pkg/mcclient/cloudpods" ) -func TestPinyin(t *testing.T) { - cases := []struct { - In string - Want string - }{ - {"中国人", "zhongguoren"}, - {"中国人1", "zhongguoren1"}, - {"中 国 人", "zhong guo ren"}, +func init() { + type VpcListOptions struct { } - for _, c := range cases { - got := Text2Pinyin(c.In) - if got != c.Want { - t.Errorf("Text2Pinyin %s got: %s want %s", c.In, got, c.Want) + shellutils.R(&VpcListOptions{}, "vpc-list", "List vpcs", func(cli *cloudpods.SRegion, args *VpcListOptions) error { + vpcs, err := cli.GetVpcs() + if err != nil { + return err } - } + printList(vpcs, 0, 0, 0, nil) + return nil + }) } diff --git a/pkg/mcclient/cloudpods/shell/wire.go b/pkg/mcclient/cloudpods/shell/wire.go new file mode 100644 index 0000000000..109236f33e --- /dev/null +++ b/pkg/mcclient/cloudpods/shell/wire.go @@ -0,0 +1,36 @@ +// 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 shell + +import ( + "yunion.io/x/pkg/util/shellutils" + + "yunion.io/x/onecloud/pkg/mcclient/cloudpods" +) + +func init() { + type WireListOptions struct { + VpcId string + HostId string + } + shellutils.R(&WireListOptions{}, "wire-list", "List wires", func(cli *cloudpods.SRegion, args *WireListOptions) error { + wires, err := cli.GetWires(args.VpcId, args.HostId) + if err != nil { + return err + } + printList(wires, 0, 0, 0, nil) + return nil + }) +} diff --git a/pkg/mcclient/cloudpods/shell/zones.go b/pkg/mcclient/cloudpods/shell/zones.go new file mode 100644 index 0000000000..5cfa457934 --- /dev/null +++ b/pkg/mcclient/cloudpods/shell/zones.go @@ -0,0 +1,34 @@ +// 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 shell + +import ( + "yunion.io/x/pkg/util/shellutils" + + "yunion.io/x/onecloud/pkg/mcclient/cloudpods" +) + +func init() { + type ZoneListOptions struct { + } + shellutils.R(&ZoneListOptions{}, "zone-list", "List zones", func(cli *cloudpods.SRegion, args *ZoneListOptions) error { + zones, err := cli.GetZones() + if err != nil { + return err + } + printList(zones, 0, 0, 0, nil) + return nil + }) +} diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/sku.go b/pkg/mcclient/cloudpods/sku.go similarity index 100% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/sku.go rename to pkg/mcclient/cloudpods/sku.go index b7d850fc5a..19da5c5c1e 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/sku.go +++ b/pkg/mcclient/cloudpods/sku.go @@ -15,11 +15,11 @@ package cloudpods import ( - api "yunion.io/x/onecloud/pkg/apis/compute" - modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" + + api "yunion.io/x/onecloud/pkg/apis/compute" + modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" ) type SServerSku struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/snapshot.go b/pkg/mcclient/cloudpods/snapshot.go similarity index 99% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/snapshot.go rename to pkg/mcclient/cloudpods/snapshot.go index d574594d20..87d0ea6871 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/snapshot.go +++ b/pkg/mcclient/cloudpods/snapshot.go @@ -15,13 +15,12 @@ package cloudpods import ( + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/jsonutils" api "yunion.io/x/onecloud/pkg/apis/compute" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SSnapshot struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/storage.go b/pkg/mcclient/cloudpods/storage.go similarity index 99% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/storage.go rename to pkg/mcclient/cloudpods/storage.go index e3cca3c34c..e08967595c 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/storage.go +++ b/pkg/mcclient/cloudpods/storage.go @@ -15,14 +15,13 @@ package cloudpods import ( + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" api "yunion.io/x/onecloud/pkg/apis/compute" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SStorage struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/storagecache.go b/pkg/mcclient/cloudpods/storagecache.go similarity index 99% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/storagecache.go rename to pkg/mcclient/cloudpods/storagecache.go index be312db683..2b54003095 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/storagecache.go +++ b/pkg/mcclient/cloudpods/storagecache.go @@ -18,14 +18,13 @@ import ( "context" "time" + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SStoragecache struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/tag_base.go b/pkg/mcclient/cloudpods/tag_base.go similarity index 99% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/tag_base.go rename to pkg/mcclient/cloudpods/tag_base.go index b67e8d7632..c62ff5234b 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/tag_base.go +++ b/pkg/mcclient/cloudpods/tag_base.go @@ -17,10 +17,9 @@ package cloudpods import ( "strings" - "yunion.io/x/pkg/errors" - "yunion.io/x/cloudmux/pkg/apis" "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/pkg/errors" ) type CloudpodsTags struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/vpc.go b/pkg/mcclient/cloudpods/vpc.go similarity index 99% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/vpc.go rename to pkg/mcclient/cloudpods/vpc.go index a8ade004b8..fa17311ff6 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/vpc.go +++ b/pkg/mcclient/cloudpods/vpc.go @@ -15,14 +15,13 @@ package cloudpods import ( + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" api "yunion.io/x/onecloud/pkg/apis/compute" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SVpc struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/wire.go b/pkg/mcclient/cloudpods/wire.go similarity index 99% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/wire.go rename to pkg/mcclient/cloudpods/wire.go index e3a42d2500..77824476ca 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/wire.go +++ b/pkg/mcclient/cloudpods/wire.go @@ -15,14 +15,13 @@ package cloudpods import ( + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" api "yunion.io/x/onecloud/pkg/apis/compute" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SWire struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/zone.go b/pkg/mcclient/cloudpods/zone.go similarity index 99% rename from vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/zone.go rename to pkg/mcclient/cloudpods/zone.go index 6fbe431314..4d5f4bec19 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/zone.go +++ b/pkg/mcclient/cloudpods/zone.go @@ -15,13 +15,12 @@ package cloudpods import ( + "yunion.io/x/cloudmux/pkg/cloudprovider" + "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/pkg/errors" api "yunion.io/x/onecloud/pkg/apis/compute" modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - - "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/cloudmux/pkg/multicloud" ) type SZone struct { diff --git a/pkg/mcclient/mcclient.go b/pkg/mcclient/mcclient.go index 9fa0cfea3f..c84a86c518 100644 --- a/pkg/mcclient/mcclient.go +++ b/pkg/mcclient/mcclient.go @@ -27,12 +27,13 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/apis" api "yunion.io/x/onecloud/pkg/apis/identity" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/seclib2" ) @@ -426,7 +427,7 @@ func (this *Client) NewSession(ctx context.Context, region, zone, endpointType s } type SFetchMatchPoliciesOutput struct { - Names map[rbacutils.TRbacScope][]string `json:"names"` + Names map[rbacscope.TRbacScope][]string `json:"names"` Policies rbacutils.TPolicyGroup `json:"policies"` } diff --git a/pkg/mcclient/modulebase/base.go b/pkg/mcclient/modulebase/base.go index a49ae503c3..6452cba7da 100644 --- a/pkg/mcclient/modulebase/base.go +++ b/pkg/mcclient/modulebase/base.go @@ -25,10 +25,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" ) type BaseManager struct { @@ -137,7 +138,7 @@ func (this *BaseManager) rawBaseUrlRequest(s *mcclient.ClientSession, header, body, baseUrlF) } -type ListResult struct { +/*type ListResult struct { Data []jsonutils.JSONObject `json:"data,allowempty"` Total int Limit int @@ -146,9 +147,9 @@ type ListResult struct { NextMarker string MarkerField string MarkerOrder string -} +}*/ -func ListResult2JSONWithKey(result *ListResult, key string) jsonutils.JSONObject { +func ListResult2JSONWithKey(result *printutils.ListResult, key string) jsonutils.JSONObject { obj := jsonutils.NewDict() if result.Total > 0 { obj.Add(jsonutils.NewInt(int64(result.Total)), "total") @@ -173,11 +174,11 @@ func ListResult2JSONWithKey(result *ListResult, key string) jsonutils.JSONObject return obj } -func ListResult2JSON(result *ListResult) jsonutils.JSONObject { +func ListResult2JSON(result *printutils.ListResult) jsonutils.JSONObject { return ListResult2JSONWithKey(result, "data") } -func JSON2ListResult(result jsonutils.JSONObject) *ListResult { +func JSON2ListResult(result jsonutils.JSONObject) *printutils.ListResult { total, _ := result.Int("total") limit, _ := result.Int("limit") offset, _ := result.Int("offset") @@ -188,7 +189,7 @@ func JSON2ListResult(result jsonutils.JSONObject) *ListResult { if len(markerField) == 0 && total == 0 { total = int64(len(data)) } - return &ListResult{ + return &printutils.ListResult{ Data: data, Total: int(total), Limit: int(limit), Offset: int(offset), NextMarker: nextMarker, @@ -197,7 +198,7 @@ func JSON2ListResult(result jsonutils.JSONObject) *ListResult { } } -func (this *BaseManager) _list(session *mcclient.ClientSession, path, responseKey string) (*ListResult, error) { +func (this *BaseManager) _list(session *mcclient.ClientSession, path, responseKey string) (*printutils.ListResult, error) { _, body, err := this.jsonRequest(session, "GET", path, nil, nil) if err != nil { return nil, err @@ -218,7 +219,7 @@ func (this *BaseManager) _list(session *mcclient.ClientSession, path, responseKe if len(nextMarker) == 0 && total == 0 { total = int64(len(rets)) } - return &ListResult{ + return &printutils.ListResult{ Data: rets, Total: int(total), Limit: int(limit), Offset: int(offset), NextMarker: nextMarker, @@ -260,13 +261,15 @@ func (this *BaseManager) _submit(session *mcclient.ClientSession, method httputi return ret, nil } -type SubmitResult struct { +/*type SubmitResult struct { Status int Id interface{} Data jsonutils.JSONObject -} +}*/ -func SubmitResults2JSON(results []SubmitResult) jsonutils.JSONObject { +//type SubmitResult printutils.SubmitResult + +func SubmitResults2JSON(results []printutils.SubmitResult) jsonutils.JSONObject { arr := jsonutils.NewArray() for _, r := range results { obj := jsonutils.NewDict() @@ -280,46 +283,46 @@ func SubmitResults2JSON(results []SubmitResult) jsonutils.JSONObject { return body } -func SubmitResults2ListResult(results []SubmitResult) *ListResult { +func SubmitResults2ListResult(results []printutils.SubmitResult) *printutils.ListResult { arr := make([]jsonutils.JSONObject, 0) for _, r := range results { if r.Status == 200 { arr = append(arr, r.Data) } } - return &ListResult{Data: arr, Total: len(arr), Limit: 0, Offset: 0} + return &printutils.ListResult{Data: arr, Total: len(arr), Limit: 0, Offset: 0} } -func (this *BaseManager) _batch(session *mcclient.ClientSession, method httputils.THttpMethod, path string, ids []string, body jsonutils.JSONObject, respKey string) []SubmitResult { +func (this *BaseManager) _batch(session *mcclient.ClientSession, method httputils.THttpMethod, path string, ids []string, body jsonutils.JSONObject, respKey string) []printutils.SubmitResult { return BatchDo(ids, func(id string) (jsonutils.JSONObject, error) { u := fmt.Sprintf(path, url.PathEscape(id)) return this._submit(session, method, u, body, respKey) }) } -func addResult(results chan SubmitResult, id interface{}, r jsonutils.JSONObject, e error) { +func addResult(results chan printutils.SubmitResult, id interface{}, r jsonutils.JSONObject, e error) { if e != nil { ecls, ok := e.(*httputils.JSONClientError) if ok { - results <- SubmitResult{Status: ecls.Code, Id: id, Data: jsonutils.Marshal(ecls)} + results <- printutils.SubmitResult{Status: ecls.Code, Id: id, Data: jsonutils.Marshal(ecls)} } else { - results <- SubmitResult{Status: 400, Id: id, Data: jsonutils.NewString(e.Error())} + results <- printutils.SubmitResult{Status: 400, Id: id, Data: jsonutils.NewString(e.Error())} } } else { - results <- SubmitResult{Status: 200, Id: id, Data: r} + results <- printutils.SubmitResult{Status: 200, Id: id, Data: r} } } -func waitResults(results chan SubmitResult, length int) []SubmitResult { - ret := make([]SubmitResult, length) +func waitResults(results chan printutils.SubmitResult, length int) []printutils.SubmitResult { + ret := make([]printutils.SubmitResult, length) for i := 0; i < length; i++ { ret[i] = <-results } return ret } -func BatchDo(ids []string, do func(id string) (jsonutils.JSONObject, error)) []SubmitResult { - results := make(chan SubmitResult, len(ids)) +func BatchDo(ids []string, do func(id string) (jsonutils.JSONObject, error)) []printutils.SubmitResult { + results := make(chan printutils.SubmitResult, len(ids)) for i := 0; i < len(ids); i++ { go func(id string) { r, e := do(id) @@ -332,8 +335,8 @@ func BatchDo(ids []string, do func(id string) (jsonutils.JSONObject, error)) []S func BatchParamsDo( ids []string, params []jsonutils.JSONObject, do func(id string, param jsonutils.JSONObject) (jsonutils.JSONObject, error), -) []SubmitResult { - results := make(chan SubmitResult, len(ids)) +) []printutils.SubmitResult { + results := make(chan printutils.SubmitResult, len(ids)) for i := 0; i < len(ids); i++ { go func(id string, param jsonutils.JSONObject) { r, e := do(id, param) @@ -345,8 +348,8 @@ func BatchParamsDo( func BatchDoClassAction( batchParams []jsonutils.JSONObject, do func(jsonutils.JSONObject) (jsonutils.JSONObject, error), -) []SubmitResult { - results := make(chan SubmitResult, len(batchParams)) +) []printutils.SubmitResult { + results := make(chan printutils.SubmitResult, len(batchParams)) for i := 0; i < len(batchParams); i++ { go func(params jsonutils.JSONObject) { r, e := do(params) diff --git a/pkg/mcclient/modulebase/filter.go b/pkg/mcclient/modulebase/filter.go index 290c30ee33..e6ade6cee8 100644 --- a/pkg/mcclient/modulebase/filter.go +++ b/pkg/mcclient/modulebase/filter.go @@ -17,6 +17,7 @@ package modulebase import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" ) @@ -28,7 +29,7 @@ func (this *ResourceManager) filterSingleResult(session *mcclient.ClientSession, return result, nil } -func (this *ResourceManager) filterListResults(session *mcclient.ClientSession, results *ListResult, query jsonutils.JSONObject) (*ListResult, error) { +func (this *ResourceManager) filterListResults(session *mcclient.ClientSession, results *printutils.ListResult, query jsonutils.JSONObject) (*printutils.ListResult, error) { if this.enableFilter && this.readFilter != nil { for i := 0; i < len(results.Data); i += 1 { val, err := this.readFilter(session, results.Data[i], query) diff --git a/pkg/mcclient/modulebase/joint.go b/pkg/mcclient/modulebase/joint.go index 18f0839618..3b5e63d063 100644 --- a/pkg/mcclient/modulebase/joint.go +++ b/pkg/mcclient/modulebase/joint.go @@ -19,6 +19,7 @@ import ( "net/url" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" ) @@ -67,7 +68,7 @@ func (this *JointResourceManager) List(s *mcclient.ClientSession, params jsonuti } */ -func (this *JointResourceManager) ListDescendent(s *mcclient.ClientSession, mid string, params jsonutils.JSONObject) (*ListResult, error) { +func (this *JointResourceManager) ListDescendent(s *mcclient.ClientSession, mid string, params jsonutils.JSONObject) (*printutils.ListResult, error) { path := fmt.Sprintf("/%s/%s/%s", this.Master.KeyString(), url.PathEscape(mid), this.Slave.KeyString()) if params != nil { qs := params.QueryString() @@ -82,11 +83,11 @@ func (this *JointResourceManager) ListDescendent(s *mcclient.ClientSession, mid return this.filterListResults(s, results, params) } -func (this *JointResourceManager) ListDescendent2(s *mcclient.ClientSession, sid string, params jsonutils.JSONObject) (*ListResult, error) { +func (this *JointResourceManager) ListDescendent2(s *mcclient.ClientSession, sid string, params jsonutils.JSONObject) (*printutils.ListResult, error) { return this.ListAscendent(s, sid, params) } -func (this *JointResourceManager) ListAscendent(s *mcclient.ClientSession, mid string, params jsonutils.JSONObject) (*ListResult, error) { +func (this *JointResourceManager) ListAscendent(s *mcclient.ClientSession, mid string, params jsonutils.JSONObject) (*printutils.ListResult, error) { path := fmt.Sprintf("/%s/%s/%s", this.Slave.KeyString(), url.PathEscape(mid), this.Master.KeyString()) if params != nil { qs := params.QueryString() @@ -121,13 +122,13 @@ func (this *JointResourceManager) Attach(s *mcclient.ClientSession, mid, sid str return this.filterSingleResult(s, result, nil) } -func (this *JointResourceManager) BatchAttach(s *mcclient.ClientSession, mid string, sids []string, params jsonutils.JSONObject) []SubmitResult { +func (this *JointResourceManager) BatchAttach(s *mcclient.ClientSession, mid string, sids []string, params jsonutils.JSONObject) []printutils.SubmitResult { return BatchDo(sids, func(sid string) (jsonutils.JSONObject, error) { return this.Attach(s, mid, sid, params) }) } -func (this *JointResourceManager) BatchAttach2(s *mcclient.ClientSession, mid string, sids []string, params jsonutils.JSONObject) []SubmitResult { +func (this *JointResourceManager) BatchAttach2(s *mcclient.ClientSession, mid string, sids []string, params jsonutils.JSONObject) []printutils.SubmitResult { return BatchDo(sids, func(sid string) (jsonutils.JSONObject, error) { return this.Attach(s, sid, mid, params) }) @@ -148,13 +149,13 @@ func (this *JointResourceManager) Detach(s *mcclient.ClientSession, mid, sid str return this.filterSingleResult(s, result, nil) } -func (this *JointResourceManager) BatchDetach(s *mcclient.ClientSession, mid string, sids []string) []SubmitResult { +func (this *JointResourceManager) BatchDetach(s *mcclient.ClientSession, mid string, sids []string) []printutils.SubmitResult { return BatchDo(sids, func(sid string) (jsonutils.JSONObject, error) { return this.Detach(s, mid, sid, nil) }) } -func (this *JointResourceManager) BatchDetach2(s *mcclient.ClientSession, mid string, sids []string) []SubmitResult { +func (this *JointResourceManager) BatchDetach2(s *mcclient.ClientSession, mid string, sids []string) []printutils.SubmitResult { return BatchDo(sids, func(sid string) (jsonutils.JSONObject, error) { return this.Detach(s, sid, mid, nil) }) @@ -190,13 +191,13 @@ func (this *JointResourceManager) Patch(s *mcclient.ClientSession, mid, sid stri return this.filterSingleResult(s, result, nil) } -func (this *JointResourceManager) BatchUpdate(s *mcclient.ClientSession, mid string, sids []string, query jsonutils.JSONObject, params jsonutils.JSONObject) []SubmitResult { +func (this *JointResourceManager) BatchUpdate(s *mcclient.ClientSession, mid string, sids []string, query jsonutils.JSONObject, params jsonutils.JSONObject) []printutils.SubmitResult { return BatchDo(sids, func(sid string) (jsonutils.JSONObject, error) { return this.Update(s, mid, sid, query, params) }) } -func (this *JointResourceManager) BatchPatch(s *mcclient.ClientSession, mid string, sids []string, query jsonutils.JSONObject, params jsonutils.JSONObject) []SubmitResult { +func (this *JointResourceManager) BatchPatch(s *mcclient.ClientSession, mid string, sids []string, query jsonutils.JSONObject, params jsonutils.JSONObject) []printutils.SubmitResult { return BatchDo(sids, func(sid string) (jsonutils.JSONObject, error) { return this.Patch(s, mid, sid, query, params) }) diff --git a/pkg/mcclient/modulebase/misc.go b/pkg/mcclient/modulebase/misc.go index 24f22b9ef5..b8e5c4b971 100644 --- a/pkg/mcclient/modulebase/misc.go +++ b/pkg/mcclient/modulebase/misc.go @@ -18,6 +18,7 @@ import ( "io/ioutil" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" ) @@ -36,7 +37,7 @@ func GetVersion(s *mcclient.ClientSession, serviceType string) (string, error) { return string(body), nil } -func ListWorkers(s *mcclient.ClientSession, serviceType string) (*ListResult, error) { +func ListWorkers(s *mcclient.ClientSession, serviceType string) (*printutils.ListResult, error) { man := NewBaseManager(serviceType, "", "", nil, nil) resp, err := man.rawBaseUrlRequest(s, "GET", "/worker_stats", nil, nil) if err != nil { @@ -47,7 +48,7 @@ func ListWorkers(s *mcclient.ClientSession, serviceType string) (*ListResult, er if err != nil { return nil, err } - ret := ListResult{} + ret := printutils.ListResult{} if workers, _ := jsonutils.Parse(body); workers != nil { workers.Unmarshal(&ret.Data, "workers") ret.Total = len(ret.Data) diff --git a/pkg/mcclient/modulebase/modules.go b/pkg/mcclient/modulebase/modules.go index de783964bf..c4012f79a7 100644 --- a/pkg/mcclient/modulebase/modules.go +++ b/pkg/mcclient/modulebase/modules.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" ) @@ -34,7 +35,7 @@ type IBaseManager interface { ServiceType() string EndpointType() string GetColumns(session *mcclient.ClientSession) []string - List(session *mcclient.ClientSession, params jsonutils.JSONObject) (*ListResult, error) + List(session *mcclient.ClientSession, params jsonutils.JSONObject) (*printutils.ListResult, error) } type ManagerContext struct { @@ -62,8 +63,8 @@ type Manager interface { return: { "": [ {object details}, {object details}, ...] }, limit: 20, offset: 20, total: 2000} */ - ListInContext(session *mcclient.ClientSession, params jsonutils.JSONObject, ctx Manager, ctxid string) (*ListResult, error) - ListInContexts(session *mcclient.ClientSession, params jsonutils.JSONObject, ctxs []ManagerContext) (*ListResult, error) + ListInContext(session *mcclient.ClientSession, params jsonutils.JSONObject, ctx Manager, ctxid string) (*printutils.ListResult, error) + ListInContexts(session *mcclient.ClientSession, params jsonutils.JSONObject, ctxs []ManagerContext) (*printutils.ListResult, error) /* GET // e.g GET /alarams/1 @@ -89,9 +90,9 @@ type Manager interface { Head(session *mcclient.ClientSession, id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) HeadInContext(session *mcclient.ClientSession, id string, params jsonutils.JSONObject, ctx Manager, ctxid string) (jsonutils.JSONObject, error) HeadInContexts(session *mcclient.ClientSession, id string, params jsonutils.JSONObject, ctxs []ManagerContext) (jsonutils.JSONObject, error) - BatchGet(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []SubmitResult - BatchGetInContext(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult - BatchGetInContexts(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult + BatchGet(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []printutils.SubmitResult + BatchGetInContext(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctx Manager, ctxid string) []printutils.SubmitResult + BatchGetInContexts(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult GetSpecific(session *mcclient.ClientSession, id string, spec string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) GetSpecificInContext(session *mcclient.ClientSession, id string, spec string, params jsonutils.JSONObject, ctx Manager, ctxid string) (jsonutils.JSONObject, error) GetSpecificInContexts(session *mcclient.ClientSession, id string, spec string, params jsonutils.JSONObject, ctxs []ManagerContext) (jsonutils.JSONObject, error) @@ -103,44 +104,44 @@ type Manager interface { Create(session *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) CreateInContext(session *mcclient.ClientSession, params jsonutils.JSONObject, ctx Manager, ctxid string) (jsonutils.JSONObject, error) CreateInContexts(session *mcclient.ClientSession, params jsonutils.JSONObject, ctxs []ManagerContext) (jsonutils.JSONObject, error) - BatchCreate(session *mcclient.ClientSession, params jsonutils.JSONObject, count int) []SubmitResult - BatchCreateInContext(session *mcclient.ClientSession, params jsonutils.JSONObject, count int, ctx Manager, ctxid string) []SubmitResult - BatchCreateInContexts(session *mcclient.ClientSession, params jsonutils.JSONObject, count int, ctxs []ManagerContext) []SubmitResult + BatchCreate(session *mcclient.ClientSession, params jsonutils.JSONObject, count int) []printutils.SubmitResult + BatchCreateInContext(session *mcclient.ClientSession, params jsonutils.JSONObject, count int, ctx Manager, ctxid string) []printutils.SubmitResult + BatchCreateInContexts(session *mcclient.ClientSession, params jsonutils.JSONObject, count int, ctxs []ManagerContext) []printutils.SubmitResult Update(session *mcclient.ClientSession, id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) Put(session *mcclient.ClientSession, id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) PutSpecific(session *mcclient.ClientSession, id string, spec string, query jsonutils.JSONObject, params jsonutils.JSONObject) (jsonutils.JSONObject, error) PutInContext(session *mcclient.ClientSession, id string, params jsonutils.JSONObject, ctx Manager, ctxid string) (jsonutils.JSONObject, error) PutInContexts(session *mcclient.ClientSession, id string, params jsonutils.JSONObject, ctxs []ManagerContext) (jsonutils.JSONObject, error) - BatchUpdate(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []SubmitResult - BatchParamsUpdate(session *mcclient.ClientSession, idlist []string, params []jsonutils.JSONObject) []SubmitResult - BatchPut(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []SubmitResult - BatchPutInContext(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult - BatchPutInContexts(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult + BatchUpdate(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []printutils.SubmitResult + BatchParamsUpdate(session *mcclient.ClientSession, idlist []string, params []jsonutils.JSONObject) []printutils.SubmitResult + BatchPut(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []printutils.SubmitResult + BatchPutInContext(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctx Manager, ctxid string) []printutils.SubmitResult + BatchPutInContexts(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult Patch(session *mcclient.ClientSession, id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) PatchInContext(session *mcclient.ClientSession, id string, params jsonutils.JSONObject, ctx Manager, ctxid string) (jsonutils.JSONObject, error) PatchInContexts(session *mcclient.ClientSession, id string, params jsonutils.JSONObject, ctxs []ManagerContext) (jsonutils.JSONObject, error) - BatchPatch(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []SubmitResult - BatchPatchInContext(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult - BatchPatchInContexts(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult + BatchPatch(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []printutils.SubmitResult + BatchPatchInContext(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctx Manager, ctxid string) []printutils.SubmitResult + BatchPatchInContexts(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult PerformAction(session *mcclient.ClientSession, id string, action string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) PerformClassAction(session *mcclient.ClientSession, action string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) PerformActionInContext(session *mcclient.ClientSession, id string, action string, params jsonutils.JSONObject, ctx Manager, ctxid string) (jsonutils.JSONObject, error) PerformActionInContexts(session *mcclient.ClientSession, id string, action string, params jsonutils.JSONObject, ctxs []ManagerContext) (jsonutils.JSONObject, error) - BatchPerformAction(session *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject) []SubmitResult - BatchPerformActionInContext(session *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult - BatchPerformActionInContexts(session *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult + BatchPerformAction(session *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject) []printutils.SubmitResult + BatchPerformActionInContext(session *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject, ctx Manager, ctxid string) []printutils.SubmitResult + BatchPerformActionInContexts(session *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult Delete(session *mcclient.ClientSession, id string, body jsonutils.JSONObject) (jsonutils.JSONObject, error) DeleteWithParam(session *mcclient.ClientSession, id string, query jsonutils.JSONObject, body jsonutils.JSONObject) (jsonutils.JSONObject, error) DeleteInContext(session *mcclient.ClientSession, id string, body jsonutils.JSONObject, ctx Manager, ctxid string) (jsonutils.JSONObject, error) DeleteInContextWithParam(session *mcclient.ClientSession, id string, query jsonutils.JSONObject, body jsonutils.JSONObject, ctx Manager, ctxid string) (jsonutils.JSONObject, error) DeleteInContexts(session *mcclient.ClientSession, id string, body jsonutils.JSONObject, ctxs []ManagerContext) (jsonutils.JSONObject, error) DeleteInContextsWithParam(session *mcclient.ClientSession, id string, query jsonutils.JSONObject, body jsonutils.JSONObject, ctxs []ManagerContext) (jsonutils.JSONObject, error) - BatchDelete(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject) []SubmitResult - BatchDeleteWithParam(session *mcclient.ClientSession, idlist []string, query jsonutils.JSONObject, body jsonutils.JSONObject) []SubmitResult - BatchDeleteInContext(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult - BatchDeleteInContextWithParam(session *mcclient.ClientSession, idlist []string, query jsonutils.JSONObject, body jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult - BatchDeleteInContexts(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult - BatchDeleteInContextsWithParam(session *mcclient.ClientSession, idlist []string, query jsonutils.JSONObject, body jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult + BatchDelete(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject) []printutils.SubmitResult + BatchDeleteWithParam(session *mcclient.ClientSession, idlist []string, query jsonutils.JSONObject, body jsonutils.JSONObject) []printutils.SubmitResult + BatchDeleteInContext(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject, ctx Manager, ctxid string) []printutils.SubmitResult + BatchDeleteInContextWithParam(session *mcclient.ClientSession, idlist []string, query jsonutils.JSONObject, body jsonutils.JSONObject, ctx Manager, ctxid string) []printutils.SubmitResult + BatchDeleteInContexts(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult + BatchDeleteInContextsWithParam(session *mcclient.ClientSession, idlist []string, query jsonutils.JSONObject, body jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult } type IResourceManager interface { @@ -154,19 +155,19 @@ type JointManager interface { MasterManager() Manager SlaveManager() Manager Get(s *mcclient.ClientSession, mid, sid string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) - ListDescendent(s *mcclient.ClientSession, mid string, params jsonutils.JSONObject) (*ListResult, error) - ListDescendent2(s *mcclient.ClientSession, sid string, params jsonutils.JSONObject) (*ListResult, error) - ListAscendent(s *mcclient.ClientSession, mid string, params jsonutils.JSONObject) (*ListResult, error) + ListDescendent(s *mcclient.ClientSession, mid string, params jsonutils.JSONObject) (*printutils.ListResult, error) + ListDescendent2(s *mcclient.ClientSession, sid string, params jsonutils.JSONObject) (*printutils.ListResult, error) + ListAscendent(s *mcclient.ClientSession, mid string, params jsonutils.JSONObject) (*printutils.ListResult, error) Attach(s *mcclient.ClientSession, mid, sid string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) - BatchAttach(s *mcclient.ClientSession, mid string, sids []string, params jsonutils.JSONObject) []SubmitResult - BatchAttach2(s *mcclient.ClientSession, mid string, sids []string, params jsonutils.JSONObject) []SubmitResult + BatchAttach(s *mcclient.ClientSession, mid string, sids []string, params jsonutils.JSONObject) []printutils.SubmitResult + BatchAttach2(s *mcclient.ClientSession, mid string, sids []string, params jsonutils.JSONObject) []printutils.SubmitResult Detach(s *mcclient.ClientSession, mid, sid string, query jsonutils.JSONObject) (jsonutils.JSONObject, error) - BatchDetach(s *mcclient.ClientSession, mid string, sids []string) []SubmitResult - BatchDetach2(s *mcclient.ClientSession, mid string, sids []string) []SubmitResult + BatchDetach(s *mcclient.ClientSession, mid string, sids []string) []printutils.SubmitResult + BatchDetach2(s *mcclient.ClientSession, mid string, sids []string) []printutils.SubmitResult Update(s *mcclient.ClientSession, mid, sid string, query jsonutils.JSONObject, params jsonutils.JSONObject) (jsonutils.JSONObject, error) - BatchUpdate(s *mcclient.ClientSession, mid string, sids []string, query jsonutils.JSONObject, params jsonutils.JSONObject) []SubmitResult + BatchUpdate(s *mcclient.ClientSession, mid string, sids []string, query jsonutils.JSONObject, params jsonutils.JSONObject) []printutils.SubmitResult Patch(s *mcclient.ClientSession, mid, sid string, query jsonutils.JSONObject, params jsonutils.JSONObject) (jsonutils.JSONObject, error) - BatchPatch(s *mcclient.ClientSession, mid string, sids []string, query jsonutils.JSONObject, params jsonutils.JSONObject) []SubmitResult + BatchPatch(s *mcclient.ClientSession, mid string, sids []string, query jsonutils.JSONObject, params jsonutils.JSONObject) []printutils.SubmitResult } var ( diff --git a/pkg/mcclient/modulebase/resource.go b/pkg/mcclient/modulebase/resource.go index 1cfefe3f3c..d7b076cc4f 100644 --- a/pkg/mcclient/modulebase/resource.go +++ b/pkg/mcclient/modulebase/resource.go @@ -21,10 +21,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" ) type TResourceFilter func(*mcclient.ClientSession, jsonutils.JSONObject, jsonutils.JSONObject) (jsonutils.JSONObject, error) @@ -239,29 +240,29 @@ func (this *ResourceManager) GetSpecificInContexts(session *mcclient.ClientSessi return this._get(session, path, this.Keyword) } -func (this *ResourceManager) BatchGet(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []SubmitResult { +func (this *ResourceManager) BatchGet(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []printutils.SubmitResult { return this.BatchGetInContexts(session, idlist, params, nil) } -func (this *ResourceManager) BatchGetInContext(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult { +func (this *ResourceManager) BatchGetInContext(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctx Manager, ctxid string) []printutils.SubmitResult { return this.BatchGetInContexts(session, idlist, params, []ManagerContext{{ctx, ctxid}}) } -func (this *ResourceManager) BatchGetInContexts(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult { +func (this *ResourceManager) BatchGetInContexts(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult { return BatchDo(idlist, func(id string) (jsonutils.JSONObject, error) { return this.GetInContexts(session, id, params, ctxs) }) } -func (this *ResourceManager) List(session *mcclient.ClientSession, params jsonutils.JSONObject) (*ListResult, error) { +func (this *ResourceManager) List(session *mcclient.ClientSession, params jsonutils.JSONObject) (*printutils.ListResult, error) { return this.ListInContexts(session, params, nil) } -func (this *ResourceManager) ListInContext(session *mcclient.ClientSession, params jsonutils.JSONObject, ctx Manager, ctxid string) (*ListResult, error) { +func (this *ResourceManager) ListInContext(session *mcclient.ClientSession, params jsonutils.JSONObject, ctx Manager, ctxid string) (*printutils.ListResult, error) { return this.ListInContexts(session, params, []ManagerContext{{ctx, ctxid}}) } -func (this *ResourceManager) ListInContexts(session *mcclient.ClientSession, params jsonutils.JSONObject, ctxs []ManagerContext) (*ListResult, error) { +func (this *ResourceManager) ListInContexts(session *mcclient.ClientSession, params jsonutils.JSONObject, ctxs []ManagerContext) (*printutils.ListResult, error) { path := fmt.Sprintf("/%s", this.ContextPath(ctxs)) if params != nil { qs := params.QueryString() @@ -332,29 +333,29 @@ func (this *ResourceManager) CreateInContexts(session *mcclient.ClientSession, p return this.filterSingleResult(session, result, nil) } -func (this *ResourceManager) BatchCreate(session *mcclient.ClientSession, params jsonutils.JSONObject, count int) []SubmitResult { +func (this *ResourceManager) BatchCreate(session *mcclient.ClientSession, params jsonutils.JSONObject, count int) []printutils.SubmitResult { return this.BatchCreateInContexts(session, params, count, nil) } -func (this *ResourceManager) BatchCreateInContext(session *mcclient.ClientSession, params jsonutils.JSONObject, count int, ctx Manager, ctxid string) []SubmitResult { +func (this *ResourceManager) BatchCreateInContext(session *mcclient.ClientSession, params jsonutils.JSONObject, count int, ctx Manager, ctxid string) []printutils.SubmitResult { return this.BatchCreateInContexts(session, params, count, []ManagerContext{{ctx, ctxid}}) } -func (this *ResourceManager) BatchCreateInContexts(session *mcclient.ClientSession, params jsonutils.JSONObject, count int, ctxs []ManagerContext) []SubmitResult { +func (this *ResourceManager) BatchCreateInContexts(session *mcclient.ClientSession, params jsonutils.JSONObject, count int, ctxs []ManagerContext) []printutils.SubmitResult { path := fmt.Sprintf("/%s", this.ContextPath(ctxs)) body := this.params2Body(session, params, this.Keyword) body.Add(jsonutils.NewInt(int64(count)), "count") - ret := make([]SubmitResult, count) + ret := make([]printutils.SubmitResult, count) respbody, err := this._post(session, path, body, this.KeywordPlural) if err != nil { jsonErr, ok := err.(*httputils.JSONClientError) if ok { for i := 0; i < count; i++ { - ret[i] = SubmitResult{Status: jsonErr.Code, Data: jsonutils.Marshal(jsonErr)} + ret[i] = printutils.SubmitResult{Status: jsonErr.Code, Data: jsonutils.Marshal(jsonErr)} } } else { for i := 0; i < count; i++ { - ret[i] = SubmitResult{Status: 500, Data: jsonutils.NewString(err.Error())} + ret[i] = printutils.SubmitResult{Status: 500, Data: jsonutils.NewString(err.Error())} } } return ret @@ -362,14 +363,14 @@ func (this *ResourceManager) BatchCreateInContexts(session *mcclient.ClientSessi respArray, ok := respbody.(*jsonutils.JSONArray) if !ok { for i := 0; i < count; i++ { - ret[i] = SubmitResult{Status: 500, Data: jsonutils.NewString("Invalid response")} + ret[i] = printutils.SubmitResult{Status: 500, Data: jsonutils.NewString("Invalid response")} } return ret } for i := 0; i < respArray.Size(); i++ { json, e := respArray.GetAt(i) if e != nil { - ret[i] = SubmitResult{Status: 500, Data: jsonutils.NewString(e.Error())} + ret[i] = printutils.SubmitResult{Status: 500, Data: jsonutils.NewString(e.Error())} } else { code, _ := json.Int("status") dat, _ := json.Get("body") @@ -382,7 +383,7 @@ func (this *ResourceManager) BatchCreateInContexts(session *mcclient.ClientSessi } } idstr, _ := dat.GetString(this.getIdFieldName()) - ret[i] = SubmitResult{Status: int(code), Id: idstr, Data: dat} + ret[i] = printutils.SubmitResult{Status: int(code), Id: idstr, Data: dat} } } return ret @@ -435,29 +436,29 @@ func (this *ResourceManager) PutSpecificInContexts(session *mcclient.ClientSessi return this.filterSingleResult(session, result, nil) } -func (this *ResourceManager) BatchUpdate(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []SubmitResult { +func (this *ResourceManager) BatchUpdate(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []printutils.SubmitResult { return this.BatchPutInContexts(session, idlist, params, nil) } -func (this *ResourceManager) BatchPut(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []SubmitResult { +func (this *ResourceManager) BatchPut(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []printutils.SubmitResult { return this.BatchPutInContexts(session, idlist, params, nil) } -func (this *ResourceManager) BatchPutInContext(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult { +func (this *ResourceManager) BatchPutInContext(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctx Manager, ctxid string) []printutils.SubmitResult { return this.BatchPutInContexts(session, idlist, params, []ManagerContext{{ctx, ctxid}}) } -func (this *ResourceManager) BatchPutInContexts(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult { +func (this *ResourceManager) BatchPutInContexts(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult { return BatchDo(idlist, func(id string) (jsonutils.JSONObject, error) { return this.PutInContexts(session, id, params, ctxs) }) } -func (this *ResourceManager) BatchParamsUpdate(session *mcclient.ClientSession, idlist []string, params []jsonutils.JSONObject) []SubmitResult { +func (this *ResourceManager) BatchParamsUpdate(session *mcclient.ClientSession, idlist []string, params []jsonutils.JSONObject) []printutils.SubmitResult { return this.BatchParamsPutInContexts(session, idlist, params, nil) } -func (this *ResourceManager) BatchParamsPutInContexts(session *mcclient.ClientSession, idlist []string, params []jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult { +func (this *ResourceManager) BatchParamsPutInContexts(session *mcclient.ClientSession, idlist []string, params []jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult { return BatchParamsDo(idlist, params, func(id string, param jsonutils.JSONObject) (jsonutils.JSONObject, error) { return this.PutInContexts(session, id, param, ctxs) }) @@ -480,15 +481,15 @@ func (this *ResourceManager) PatchInContexts(session *mcclient.ClientSession, id return this.filterSingleResult(session, result, nil) } -func (this *ResourceManager) BatchPatch(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []SubmitResult { +func (this *ResourceManager) BatchPatch(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []printutils.SubmitResult { return this.BatchPatchInContexts(session, idlist, params, nil) } -func (this *ResourceManager) BatchPatchInContext(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult { +func (this *ResourceManager) BatchPatchInContext(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctx Manager, ctxid string) []printutils.SubmitResult { return this.BatchPatchInContexts(session, idlist, params, []ManagerContext{{ctx, ctxid}}) } -func (this *ResourceManager) BatchPatchInContexts(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult { +func (this *ResourceManager) BatchPatchInContexts(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult { return BatchDo(idlist, func(id string) (jsonutils.JSONObject, error) { return this.PatchInContexts(session, id, params, ctxs) }) @@ -520,25 +521,25 @@ func (this *ResourceManager) PerformClassActionInContexts(session *mcclient.Clie return this._post(session, path, this.params2Body(session, params, this.KeywordPlural), this.KeywordPlural) } -func (this *ResourceManager) BatchPerformClassAction(session *mcclient.ClientSession, action string, batchParams []jsonutils.JSONObject) []SubmitResult { +func (this *ResourceManager) BatchPerformClassAction(session *mcclient.ClientSession, action string, batchParams []jsonutils.JSONObject) []printutils.SubmitResult { return this.BatchPerformClassActionInContexts(session, action, batchParams, nil) } -func (this *ResourceManager) BatchPerformClassActionInContexts(session *mcclient.ClientSession, action string, batchParams []jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult { +func (this *ResourceManager) BatchPerformClassActionInContexts(session *mcclient.ClientSession, action string, batchParams []jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult { return BatchDoClassAction(batchParams, func(params jsonutils.JSONObject) (jsonutils.JSONObject, error) { return this.PerformClassActionInContexts(session, action, params, ctxs) }) } -func (this *ResourceManager) BatchPerformAction(session *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject) []SubmitResult { +func (this *ResourceManager) BatchPerformAction(session *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject) []printutils.SubmitResult { return this.BatchPerformActionInContexts(session, idlist, action, params, nil) } -func (this *ResourceManager) BatchPerformActionInContext(session *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult { +func (this *ResourceManager) BatchPerformActionInContext(session *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject, ctx Manager, ctxid string) []printutils.SubmitResult { return this.BatchPerformActionInContexts(session, idlist, action, params, []ManagerContext{{ctx, ctxid}}) } -func (this *ResourceManager) BatchPerformActionInContexts(session *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult { +func (this *ResourceManager) BatchPerformActionInContexts(session *mcclient.ClientSession, idlist []string, action string, params jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult { return BatchDo(idlist, func(id string) (jsonutils.JSONObject, error) { return this.PerformActionInContexts(session, id, action, params, ctxs) }) @@ -586,29 +587,29 @@ func (this *ResourceManager) deleteInContexts(session *mcclient.ClientSession, i return this.filterSingleResult(session, result, nil) } -func (this *ResourceManager) BatchDelete(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject) []SubmitResult { +func (this *ResourceManager) BatchDelete(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject) []printutils.SubmitResult { return this.BatchDeleteInContexts(session, idlist, body, nil) } -func (this *ResourceManager) BatchDeleteWithParam(session *mcclient.ClientSession, idlist []string, params, body jsonutils.JSONObject) []SubmitResult { +func (this *ResourceManager) BatchDeleteWithParam(session *mcclient.ClientSession, idlist []string, params, body jsonutils.JSONObject) []printutils.SubmitResult { return this.BatchDeleteInContextsWithParam(session, idlist, params, body, nil) } -func (this *ResourceManager) BatchDeleteInContext(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult { +func (this *ResourceManager) BatchDeleteInContext(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject, ctx Manager, ctxid string) []printutils.SubmitResult { return this.BatchDeleteInContexts(session, idlist, body, []ManagerContext{{ctx, ctxid}}) } -func (this *ResourceManager) BatchDeleteInContextWithParam(session *mcclient.ClientSession, idlist []string, params, body jsonutils.JSONObject, ctx Manager, ctxid string) []SubmitResult { +func (this *ResourceManager) BatchDeleteInContextWithParam(session *mcclient.ClientSession, idlist []string, params, body jsonutils.JSONObject, ctx Manager, ctxid string) []printutils.SubmitResult { return this.BatchDeleteInContextsWithParam(session, idlist, params, body, []ManagerContext{{ctx, ctxid}}) } -func (this *ResourceManager) BatchDeleteInContexts(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult { +func (this *ResourceManager) BatchDeleteInContexts(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult { return BatchDo(idlist, func(id string) (jsonutils.JSONObject, error) { return this.DeleteInContexts(session, id, body, ctxs) }) } -func (this *ResourceManager) BatchDeleteInContextsWithParam(session *mcclient.ClientSession, idlist []string, params, body jsonutils.JSONObject, ctxs []ManagerContext) []SubmitResult { +func (this *ResourceManager) BatchDeleteInContextsWithParam(session *mcclient.ClientSession, idlist []string, params, body jsonutils.JSONObject, ctxs []ManagerContext) []printutils.SubmitResult { return BatchDo(idlist, func(id string) (jsonutils.JSONObject, error) { return this.deleteInContexts(session, id, params, body, ctxs) }) diff --git a/pkg/mcclient/modulebase/utils.go b/pkg/mcclient/modulebase/utils.go index 97e25a2992..52d9bbeffe 100644 --- a/pkg/mcclient/modulebase/utils.go +++ b/pkg/mcclient/modulebase/utils.go @@ -19,16 +19,17 @@ import ( "net/http" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" ) func Get(manager ResourceManager, session *mcclient.ClientSession, path string, respKey string) (jsonutils.JSONObject, error) { return manager._get(session, path, respKey) } -func List(manager ResourceManager, session *mcclient.ClientSession, path, respKey string) (*ListResult, error) { +func List(manager ResourceManager, session *mcclient.ClientSession, path, respKey string) (*printutils.ListResult, error) { return manager._list(session, path, respKey) } diff --git a/pkg/mcclient/modules/compute/mod_buckets.go b/pkg/mcclient/modules/compute/mod_buckets.go index 3c4c0de09c..3060d1ee97 100644 --- a/pkg/mcclient/modules/compute/mod_buckets.go +++ b/pkg/mcclient/modules/compute/mod_buckets.go @@ -22,12 +22,12 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SBucketManager struct { diff --git a/pkg/mcclient/modules/compute/mod_capabilities.go b/pkg/mcclient/modules/compute/mod_capabilities.go index da7897f23d..771fc28e48 100644 --- a/pkg/mcclient/modules/compute/mod_capabilities.go +++ b/pkg/mcclient/modules/compute/mod_capabilities.go @@ -16,6 +16,7 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modulebase" @@ -26,7 +27,7 @@ type SCapabilityManager struct { modulebase.ResourceManager } -func (this *SCapabilityManager) List(s *mcclient.ClientSession, params jsonutils.JSONObject) (*modulebase.ListResult, error) { +func (this *SCapabilityManager) List(s *mcclient.ClientSession, params jsonutils.JSONObject) (*printutils.ListResult, error) { url := "/capabilities" if params != nil { qs := params.QueryString() @@ -38,7 +39,7 @@ func (this *SCapabilityManager) List(s *mcclient.ClientSession, params jsonutils if err != nil { return nil, err } - result := modulebase.ListResult{Data: []jsonutils.JSONObject{body}} + result := printutils.ListResult{Data: []jsonutils.JSONObject{body}} return &result, nil } diff --git a/pkg/mcclient/modules/compute/mod_cloudproviders.go b/pkg/mcclient/modules/compute/mod_cloudproviders.go index ed9019588a..1644bbbf4a 100644 --- a/pkg/mcclient/modules/compute/mod_cloudproviders.go +++ b/pkg/mcclient/modules/compute/mod_cloudproviders.go @@ -26,13 +26,13 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" proxyapi "yunion.io/x/onecloud/pkg/apis/cloudcommon/proxy" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SCloudprovider struct { diff --git a/pkg/mcclient/modules/compute/mod_hosts.go b/pkg/mcclient/modules/compute/mod_hosts.go index 2141803398..12f7d8d539 100644 --- a/pkg/mcclient/modules/compute/mod_hosts.go +++ b/pkg/mcclient/modules/compute/mod_hosts.go @@ -20,13 +20,14 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules" - "yunion.io/x/onecloud/pkg/util/httputils" ) const MACAddressPattern = `(([a-fA-F0-9]{2}[:-]){5}([a-fA-F0-9]{2}))` @@ -117,7 +118,7 @@ func parseHosts(titles []string, data string) []*jsonutils.JSONDict { return ret } -func (this *HostManager) BatchRegister(s *mcclient.ClientSession, titles []string, params jsonutils.JSONObject) ([]modulebase.SubmitResult, error) { +func (this *HostManager) BatchRegister(s *mcclient.ClientSession, titles []string, params jsonutils.JSONObject) ([]printutils.SubmitResult, error) { data, err := params.GetString("hosts") if err != nil { return nil, err @@ -127,7 +128,7 @@ func (this *HostManager) BatchRegister(s *mcclient.ClientSession, titles []strin hosts := parseHosts(titles, data) - results := make(chan modulebase.SubmitResult, len(hosts)) + results := make(chan printutils.SubmitResult, len(hosts)) for _, host := range hosts { host.Update(input) go func(data jsonutils.JSONObject) { @@ -136,17 +137,17 @@ func (this *HostManager) BatchRegister(s *mcclient.ClientSession, titles []strin if e != nil { ecls, ok := e.(*httputils.JSONClientError) if ok { - results <- modulebase.SubmitResult{Status: ecls.Code, Id: id, Data: jsonutils.Marshal(ecls)} + results <- printutils.SubmitResult{Status: ecls.Code, Id: id, Data: jsonutils.Marshal(ecls)} } else { - results <- modulebase.SubmitResult{Status: 400, Id: id, Data: jsonutils.NewString(e.Error())} + results <- printutils.SubmitResult{Status: 400, Id: id, Data: jsonutils.NewString(e.Error())} } } else { - results <- modulebase.SubmitResult{Status: 200, Id: id, Data: ret} + results <- printutils.SubmitResult{Status: 200, Id: id, Data: ret} } }(host) } - ret := make([]modulebase.SubmitResult, len(hosts)) + ret := make([]printutils.SubmitResult, len(hosts)) for i := 0; i < len(hosts); i++ { ret[i] = <-results } @@ -155,7 +156,7 @@ func (this *HostManager) BatchRegister(s *mcclient.ClientSession, titles []strin return ret, nil } -func (this *HostManager) DoBatchRegister(s *mcclient.ClientSession, params jsonutils.JSONObject) ([]modulebase.SubmitResult, error) { +func (this *HostManager) DoBatchRegister(s *mcclient.ClientSession, params jsonutils.JSONObject) ([]printutils.SubmitResult, error) { titles := []string{"access_mac", "name", "ipmi_ip_addr", "ipmi_username", "ipmi_password"} return this.BatchRegister(s, titles, params) } diff --git a/pkg/mcclient/modules/compute/mod_metadatas.go b/pkg/mcclient/modules/compute/mod_metadatas.go index 60e93e99fe..dabc6b4af3 100644 --- a/pkg/mcclient/modules/compute/mod_metadatas.go +++ b/pkg/mcclient/modules/compute/mod_metadatas.go @@ -19,6 +19,7 @@ import ( "strings" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/httperrors" @@ -103,7 +104,7 @@ func (this *MetadataManager) getModule(session *mcclient.ClientSession, params j }, nil } -func (this *MetadataManager) List(session *mcclient.ClientSession, params jsonutils.JSONObject) (*modulebase.ListResult, error) { +func (this *MetadataManager) List(session *mcclient.ClientSession, params jsonutils.JSONObject) (*printutils.ListResult, error) { mod, err := this.getModule(session, params) if err != nil { return nil, err diff --git a/pkg/mcclient/modules/compute/mod_skus.go b/pkg/mcclient/modules/compute/mod_skus.go index 1bcb248169..83b67f2d43 100644 --- a/pkg/mcclient/modules/compute/mod_skus.go +++ b/pkg/mcclient/modules/compute/mod_skus.go @@ -21,11 +21,12 @@ import ( "strings" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SkusManager struct { @@ -78,14 +79,14 @@ func init() { modules.RegisterCompute(&ElasticcacheSkus) } -func (self *SkusManager) GetSkus(s *mcclient.ClientSession, providerId, regionId, zoneId string, limit, offset int) (*modulebase.ListResult, error) { +func (self *SkusManager) GetSkus(s *mcclient.ClientSession, providerId, regionId, zoneId string, limit, offset int) (*printutils.ListResult, error) { p := strings.ToLower(providerId) r := strings.ToLower(regionId) z := strings.ToLower(zoneId) url := fmt.Sprintf("/providers/%s/regions/%s/zones/%s/skus?limit=%d&offset=%d", p, r, z, limit, offset) ret, err := modulebase.List(self.ResourceManager, s, url, self.KeywordPlural) if err != nil { - return &modulebase.ListResult{}, err + return &printutils.ListResult{}, err } return ret, nil diff --git a/pkg/mcclient/modules/compute/mod_sshkeypairs.go b/pkg/mcclient/modules/compute/mod_sshkeypairs.go index 54bd064434..1e1b7ba9b9 100644 --- a/pkg/mcclient/modules/compute/mod_sshkeypairs.go +++ b/pkg/mcclient/modules/compute/mod_sshkeypairs.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" @@ -32,7 +33,7 @@ type SSshkeypairManager struct { modulebase.ResourceManager } -func (this *SSshkeypairManager) List(s *mcclient.ClientSession, params jsonutils.JSONObject) (*modulebase.ListResult, error) { +func (this *SSshkeypairManager) List(s *mcclient.ClientSession, params jsonutils.JSONObject) (*printutils.ListResult, error) { url := "/sshkeypairs" if params != nil { if queryStr := params.QueryString(); queryStr != "" { @@ -43,7 +44,7 @@ func (this *SSshkeypairManager) List(s *mcclient.ClientSession, params jsonutils if err != nil { return nil, err } - result := modulebase.ListResult{Data: []jsonutils.JSONObject{body}} + result := printutils.ListResult{Data: []jsonutils.JSONObject{body}} return &result, nil } diff --git a/pkg/mcclient/modules/compute/mod_tasks.go b/pkg/mcclient/modules/compute/mod_tasks.go index 41c5b6b492..46bc1c7377 100644 --- a/pkg/mcclient/modules/compute/mod_tasks.go +++ b/pkg/mcclient/modules/compute/mod_tasks.go @@ -16,6 +16,7 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/apis" "yunion.io/x/onecloud/pkg/httperrors" @@ -97,7 +98,7 @@ func (self *TasksManager) getManager(session *mcclient.ClientSession, params jso }, nil } -func (this *TasksManager) List(session *mcclient.ClientSession, params jsonutils.JSONObject) (*modulebase.ListResult, error) { +func (this *TasksManager) List(session *mcclient.ClientSession, params jsonutils.JSONObject) (*printutils.ListResult, error) { man, err := this.getManager(session, params) if err != nil { return nil, err diff --git a/pkg/mcclient/modules/compute/mod_workers.go b/pkg/mcclient/modules/compute/mod_workers.go index 51db022360..0f74462a2f 100644 --- a/pkg/mcclient/modules/compute/mod_workers.go +++ b/pkg/mcclient/modules/compute/mod_workers.go @@ -16,6 +16,7 @@ package compute import ( "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/apis" "yunion.io/x/onecloud/pkg/mcclient" @@ -39,7 +40,7 @@ func init() { modules.RegisterCompute(&Workers) } -func (this *WorkerManager) List(s *mcclient.ClientSession, params jsonutils.JSONObject) (*modulebase.ListResult, error) { +func (this *WorkerManager) List(s *mcclient.ClientSession, params jsonutils.JSONObject) (*printutils.ListResult, error) { serviceType := apis.SERVICE_TYPE_REGION + "_v2" if params.Contains("service_type") { serviceType, _ = params.GetString("service_type") diff --git a/pkg/mcclient/modules/identity/mod_groups.go b/pkg/mcclient/modules/identity/mod_groups.go index c7e14bdddc..0354cce88d 100644 --- a/pkg/mcclient/modules/identity/mod_groups.go +++ b/pkg/mcclient/modules/identity/mod_groups.go @@ -18,6 +18,7 @@ import ( "fmt" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modulebase" @@ -28,7 +29,7 @@ type GroupManager struct { modulebase.ResourceManager } -func (this *GroupManager) GetUsers(s *mcclient.ClientSession, gid string, query jsonutils.JSONObject) (*modulebase.ListResult, error) { +func (this *GroupManager) GetUsers(s *mcclient.ClientSession, gid string, query jsonutils.JSONObject) (*printutils.ListResult, error) { url := fmt.Sprintf("/groups/%s/users", gid) if query != nil { qs := query.QueryString() @@ -43,7 +44,7 @@ var ( Groups GroupManager ) -func (this *GroupManager) GetProjects(session *mcclient.ClientSession, uid string) (*modulebase.ListResult, error) { +func (this *GroupManager) GetProjects(session *mcclient.ClientSession, uid string) (*printutils.ListResult, error) { url := fmt.Sprintf("/groups/%s/projects?admin=true", uid) return modulebase.List(this.ResourceManager, session, url, "projects") } diff --git a/pkg/mcclient/modules/identity/mod_roles.go b/pkg/mcclient/modules/identity/mod_roles.go index 1606fdd20c..52632f8996 100644 --- a/pkg/mcclient/modules/identity/mod_roles.go +++ b/pkg/mcclient/modules/identity/mod_roles.go @@ -18,11 +18,12 @@ import ( "fmt" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules" - "yunion.io/x/onecloud/pkg/util/httputils" ) type RolesManager struct { @@ -62,11 +63,11 @@ func (this *RolesManager) DeleteInContexts(session *mcclient.ClientSession, id s return this.ResourceManager.DeleteInContexts(session, id, body, ctxs) } -func (this *RolesManager) BatchDelete(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject) []modulebase.SubmitResult { +func (this *RolesManager) BatchDelete(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject) []printutils.SubmitResult { return this.BatchDeleteInContexts(session, idlist, body, nil) } -func (this *RolesManager) BatchDeleteInContexts(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject, ctxs []modulebase.ManagerContext) []modulebase.SubmitResult { +func (this *RolesManager) BatchDeleteInContexts(session *mcclient.ClientSession, idlist []string, body jsonutils.JSONObject, ctxs []modulebase.ManagerContext) []printutils.SubmitResult { return modulebase.BatchDo(idlist, func(id string) (jsonutils.JSONObject, error) { return this.DeleteInContexts(session, id, body, ctxs) }) diff --git a/pkg/mcclient/modules/identity/mod_users.go b/pkg/mcclient/modules/identity/mod_users.go index a65b3702f2..cf926128a9 100644 --- a/pkg/mcclient/modules/identity/mod_users.go +++ b/pkg/mcclient/modules/identity/mod_users.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" @@ -31,7 +32,7 @@ type UserManager struct { modulebase.ResourceManager } -func (this *UserManager) GetTenantRoles(session *mcclient.ClientSession, uid string, tenantId string) (*modulebase.ListResult, error) { +func (this *UserManager) GetTenantRoles(session *mcclient.ClientSession, uid string, tenantId string) (*printutils.ListResult, error) { url := fmt.Sprintf("/users/%s/roles", uid) if len(tenantId) > 0 { url = fmt.Sprintf("/tenants/%s/%s", tenantId, url) @@ -56,12 +57,12 @@ type UserManagerV3 struct { modulebase.ResourceManager } -func (this *UserManagerV3) GetProjects(session *mcclient.ClientSession, uid string) (*modulebase.ListResult, error) { +func (this *UserManagerV3) GetProjects(session *mcclient.ClientSession, uid string) (*printutils.ListResult, error) { url := fmt.Sprintf("/users/%s/projects?admin=true", uid) return modulebase.List(this.ResourceManager, session, url, "projects") } -func (this *UserManagerV3) GetGroups(session *mcclient.ClientSession, uid string) (*modulebase.ListResult, error) { +func (this *UserManagerV3) GetGroups(session *mcclient.ClientSession, uid string) (*printutils.ListResult, error) { url := fmt.Sprintf("/users/%s/groups?admin=true", uid) return modulebase.List(this.ResourceManager, session, url, "groups") } diff --git a/pkg/mcclient/modules/image/mod_images.go b/pkg/mcclient/modules/image/mod_images.go index d3b35e049f..ac79e16892 100644 --- a/pkg/mcclient/modules/image/mod_images.go +++ b/pkg/mcclient/modules/image/mod_images.go @@ -24,6 +24,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/printutils" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/httperrors" @@ -31,7 +33,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules" "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - "yunion.io/x/onecloud/pkg/util/httputils" ) type ImageManager struct { @@ -128,13 +129,13 @@ func (this *ImageManager) GetId(session *mcclient.ClientSession, id string, para return img.GetString("id") } -func (this *ImageManager) BatchGet(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []modulebase.SubmitResult { +func (this *ImageManager) BatchGet(session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject) []printutils.SubmitResult { return modulebase.BatchDo(idlist, func(id string) (jsonutils.JSONObject, error) { return this.Get(session, id, params) }) } -func (this *ImageManager) List(session *mcclient.ClientSession, params jsonutils.JSONObject) (*modulebase.ListResult, error) { +func (this *ImageManager) List(session *mcclient.ClientSession, params jsonutils.JSONObject) (*printutils.ListResult, error) { path := fmt.Sprintf("/%s", this.URLPath()) if params != nil { details, _ := params.Bool("details") @@ -175,7 +176,7 @@ func (this *ImageManager) countUsage(session *mcclient.ClientSession, deleted bo var limit int64 = 1000 var offset int64 = 0 ret := make(map[string]*ImageUsageCount) - count := func(ret map[string]*ImageUsageCount, results *modulebase.ListResult) { + count := func(ret map[string]*ImageUsageCount, results *printutils.ListResult) { for _, r := range results.Data { format, _ := r.GetString("disk_format") status, _ := r.GetString("status") @@ -270,7 +271,7 @@ func setImageMeta(params jsonutils.JSONObject) (http.Header, error) { return header, nil } -func (this *ImageManager) ListMemberProjects(s *mcclient.ClientSession, imageId string) (*modulebase.ListResult, error) { +func (this *ImageManager) ListMemberProjects(s *mcclient.ClientSession, imageId string) (*printutils.ListResult, error) { result, e := this.ListMemberProjectIds(s, imageId) if e != nil { return nil, e @@ -289,7 +290,7 @@ func (this *ImageManager) ListMemberProjects(s *mcclient.ClientSession, imageId return result, nil } -func (this *ImageManager) ListMemberProjectIds(s *mcclient.ClientSession, imageId string) (*modulebase.ListResult, error) { +func (this *ImageManager) ListMemberProjectIds(s *mcclient.ClientSession, imageId string) (*printutils.ListResult, error) { path := fmt.Sprintf("/%s/%s/members", this.URLPath(), url.PathEscape(imageId)) return modulebase.List(this.ResourceManager, s, path, "members") } @@ -405,13 +406,13 @@ func (this *ImageManager) _removeMembership(s *mcclient.ClientSession, image_id return e } -func (this *ImageManager) ListSharedImageIds(s *mcclient.ClientSession, projectId string) (*modulebase.ListResult, error) { +func (this *ImageManager) ListSharedImageIds(s *mcclient.ClientSession, projectId string) (*printutils.ListResult, error) { path := fmt.Sprintf("/shared-images/%s", projectId) // {"shared_images": [{"image_id": "4d82c731-937e-4420-959b-de9c213efd2b", "can_share": false}]} return modulebase.List(this.ResourceManager, s, path, "shared_images") } -func (this *ImageManager) ListSharedImages(s *mcclient.ClientSession, projectId string) (*modulebase.ListResult, error) { +func (this *ImageManager) ListSharedImages(s *mcclient.ClientSession, projectId string) (*printutils.ListResult, error) { result, e := this.ListSharedImageIds(s, projectId) if e != nil { return nil, e @@ -530,7 +531,7 @@ func (this *ImageManager) _update(s *mcclient.ClientSession, id string, params j func (this *ImageManager) BatchUpdate( session *mcclient.ClientSession, idlist []string, params jsonutils.JSONObject, -) []modulebase.SubmitResult { +) []printutils.SubmitResult { return modulebase.BatchDo(idlist, func(id string) (jsonutils.JSONObject, error) { var curParams = params.(*jsonutils.JSONDict).Copy() img, err := this.Get(session, id, nil) diff --git a/pkg/mcclient/modules/k8s/raw.go b/pkg/mcclient/modules/k8s/raw.go index 6d4a8d64be..14935a42b5 100644 --- a/pkg/mcclient/modules/k8s/raw.go +++ b/pkg/mcclient/modules/k8s/raw.go @@ -20,9 +20,9 @@ import ( "strings" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/httputils" ) var RawResource *RawResourceManager diff --git a/pkg/mcclient/modules/misc.go b/pkg/mcclient/modules/misc.go index 70183c9604..49e8f03605 100644 --- a/pkg/mcclient/modules/misc.go +++ b/pkg/mcclient/modules/misc.go @@ -15,6 +15,8 @@ package modules import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modulebase" ) @@ -23,6 +25,6 @@ func GetVersion(s *mcclient.ClientSession, serviceType string) (string, error) { return modulebase.GetVersion(s, serviceType) } -func ListWorkers(s *mcclient.ClientSession, serviceType string) (*modulebase.ListResult, error) { +func ListWorkers(s *mcclient.ClientSession, serviceType string) (*printutils.ListResult, error) { return modulebase.ListWorkers(s, serviceType) } diff --git a/pkg/mcclient/modules/pprof.go b/pkg/mcclient/modules/pprof.go index 3dcc9911b0..d70ab25e4f 100644 --- a/pkg/mcclient/modules/pprof.go +++ b/pkg/mcclient/modules/pprof.go @@ -20,10 +20,10 @@ import ( "io" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modulebase" - "yunion.io/x/onecloud/pkg/util/httputils" ) func GetPProfByType(s *mcclient.ClientSession, serviceType string, profileType string, seconds int) (io.Reader, error) { diff --git a/pkg/mcclient/modules/quota/mod_quotas.go b/pkg/mcclient/modules/quota/mod_quotas.go index f300f4e7c6..5a0b9649c6 100644 --- a/pkg/mcclient/modules/quota/mod_quotas.go +++ b/pkg/mcclient/modules/quota/mod_quotas.go @@ -18,11 +18,11 @@ import ( "fmt" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modulebase" "yunion.io/x/onecloud/pkg/mcclient/modules" - "yunion.io/x/onecloud/pkg/util/httputils" ) type QuotaManager struct { diff --git a/pkg/mcclient/session.go b/pkg/mcclient/session.go index fd509b47f0..bc7138fb96 100644 --- a/pkg/mcclient/session.go +++ b/pkg/mcclient/session.go @@ -27,13 +27,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/identity" - "yunion.io/x/onecloud/pkg/appctx" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/pkg/mcclient/token.go b/pkg/mcclient/token.go index 95626c0f89..ba70e47e5d 100644 --- a/pkg/mcclient/token.go +++ b/pkg/mcclient/token.go @@ -19,6 +19,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/util/rbacutils" ) @@ -39,13 +40,13 @@ type Endpoint struct { Interface string } -func OwnerIdString(owner IIdentityProvider, scope rbacutils.TRbacScope) string { +func OwnerIdString(owner IIdentityProvider, scope rbacscope.TRbacScope) string { switch scope { - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: return owner.GetProjectDomainId() - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: return owner.GetProjectId() - case rbacutils.ScopeUser: + case rbacscope.ScopeUser: return owner.GetUserId() default: return "" @@ -83,7 +84,7 @@ type TokenCredential interface { // IsAdmin() bool HasSystemAdminPrivilege() bool - IsAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult + IsAllow(scope rbacscope.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult GetRegions() []string diff --git a/pkg/mcclient/token2.go b/pkg/mcclient/token2.go index 3d1370ca6a..3ed0983562 100644 --- a/pkg/mcclient/token2.go +++ b/pkg/mcclient/token2.go @@ -21,6 +21,7 @@ import ( "time" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/identity" "yunion.io/x/onecloud/pkg/util/rbacutils" @@ -207,7 +208,7 @@ func (this *TokenCredentialV2) HasSystemAdminPrivilege() bool { return this.IsAdmin() && this.GetTenantName() == "system" } -func (this *TokenCredentialV2) IsAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { +func (this *TokenCredentialV2) IsAllow(scope rbacscope.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { if this.isAllow(scope, service, resource, action, extra...) { return rbacutils.PolicyAllow } else { @@ -215,8 +216,8 @@ func (this *TokenCredentialV2) IsAllow(scope rbacutils.TRbacScope, service strin } } -func (this *TokenCredentialV2) isAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) bool { - if scope == rbacutils.ScopeSystem || scope == rbacutils.ScopeDomain { +func (this *TokenCredentialV2) isAllow(scope rbacscope.TRbacScope, service string, resource string, action string, extra ...string) bool { + if scope == rbacscope.ScopeSystem || scope == rbacscope.ScopeDomain { return this.HasSystemAdminPrivilege() } else { return true diff --git a/pkg/mcclient/token3.go b/pkg/mcclient/token3.go index 49caad9b43..fef093562b 100644 --- a/pkg/mcclient/token3.go +++ b/pkg/mcclient/token3.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/identity" @@ -235,7 +236,7 @@ func (this *TokenCredentialV3) HasSystemAdminPrivilege() bool { return this.IsAdmin() && this.GetTenantName() == "system" } -func (this *TokenCredentialV3) IsAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { +func (this *TokenCredentialV3) IsAllow(scope rbacscope.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { if this.isAllow(scope, service, resource, action, extra...) { return rbacutils.PolicyAllow } else { @@ -243,8 +244,8 @@ func (this *TokenCredentialV3) IsAllow(scope rbacutils.TRbacScope, service strin } } -func (this *TokenCredentialV3) isAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) bool { - if scope == rbacutils.ScopeSystem || scope == rbacutils.ScopeDomain { +func (this *TokenCredentialV3) isAllow(scope rbacscope.TRbacScope, service string, resource string, action string, extra ...string) bool { + if scope == rbacscope.ScopeSystem || scope == rbacscope.ScopeDomain { return this.HasSystemAdminPrivilege() } else { return true diff --git a/pkg/mcclient/tokensimple.go b/pkg/mcclient/tokensimple.go index 4ef6f59f5a..720ff9da69 100644 --- a/pkg/mcclient/tokensimple.go +++ b/pkg/mcclient/tokensimple.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/onecloud/pkg/apis/identity" "yunion.io/x/onecloud/pkg/util/rbacutils" @@ -130,7 +131,7 @@ func (self *SSimpleToken) HasSystemAdminPrivilege() bool { return self.IsAdmin() && self.Project == "system" } -func (this *SSimpleToken) IsAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { +func (this *SSimpleToken) IsAllow(scope rbacscope.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { if this.isAllow(scope, service, resource, action, extra...) { return rbacutils.PolicyAllow } else { @@ -138,8 +139,8 @@ func (this *SSimpleToken) IsAllow(scope rbacutils.TRbacScope, service string, re } } -func (this *SSimpleToken) isAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) bool { - if scope == rbacutils.ScopeSystem || scope == rbacutils.ScopeDomain { +func (this *SSimpleToken) isAllow(scope rbacscope.TRbacScope, service string, resource string, action string, extra ...string) bool { + if scope == rbacscope.ScopeSystem || scope == rbacscope.ScopeDomain { return this.HasSystemAdminPrivilege() } else { return true diff --git a/pkg/mcclient/utils/fetchnames.go b/pkg/mcclient/utils/fetchnames.go index b820e8d7ff..ea94f4f2e7 100644 --- a/pkg/mcclient/utils/fetchnames.go +++ b/pkg/mcclient/utils/fetchnames.go @@ -20,13 +20,13 @@ import ( "strings" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" identityapi "yunion.io/x/onecloud/pkg/apis/identity" "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient/auth" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) func MapKeys(idMap map[string]string) []string { @@ -44,7 +44,7 @@ func FetchDomainNames(ctx context.Context, domainMap map[string]string) (map[str query := jsonutils.NewDict() query.Add(jsonutils.NewString(fmt.Sprintf("id.equals(%s)", strings.Join(MapKeys(domainMap), ","))), "filter.0") query.Add(jsonutils.NewInt(int64(len(domainMap))), "limit") - query.Add(jsonutils.NewString(string(rbacutils.ScopeSystem)), "scope") + query.Add(jsonutils.NewString(string(rbacscope.ScopeSystem)), "scope") query.Add(jsonutils.JSONTrue, "details") results, err := modules.Domains.List(s, query) if err == nil { @@ -73,7 +73,7 @@ func FetchTenantNames(ctx context.Context, tenantMap map[string]string) (map[str query := jsonutils.NewDict() query.Add(jsonutils.NewString(fmt.Sprintf("id.equals(%s)", strings.Join(MapKeys(tenantMap), ","))), "filter.0") query.Add(jsonutils.NewInt(int64(len(tenantMap))), "limit") - query.Add(jsonutils.NewString(string(rbacutils.ScopeSystem)), "scope") + query.Add(jsonutils.NewString(string(rbacscope.ScopeSystem)), "scope") query.Add(jsonutils.JSONTrue, "details") results, err := modules.Projects.List(s, query) if err == nil { diff --git a/pkg/monitor/alerting/notifiers/onecloud.go b/pkg/monitor/alerting/notifiers/onecloud.go index e24fb72631..179e46be93 100644 --- a/pkg/monitor/alerting/notifiers/onecloud.go +++ b/pkg/monitor/alerting/notifiers/onecloud.go @@ -24,12 +24,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/sets" "yunion.io/x/onecloud/pkg/apis/monitor" notiapi "yunion.io/x/onecloud/pkg/apis/notify" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/notifyclient" "yunion.io/x/onecloud/pkg/hostman/hostinfo/hostconsts" @@ -43,7 +44,6 @@ import ( "yunion.io/x/onecloud/pkg/monitor/alerting/notifiers/templates" "yunion.io/x/onecloud/pkg/monitor/models" "yunion.io/x/onecloud/pkg/monitor/options" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) const ( @@ -192,9 +192,9 @@ func (oc *OneCloudNotifier) Notify(ctx *alerting.EvalContext, _ jsonutils.JSONOb scope := alert.GetResourceScope() scopeId := "" switch scope { - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: scopeId = alert.GetDomainId() - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: scopeId = alert.GetProjectId() } roleUserIds, err := getUsersByRoles(oc.Setting.RoleIds, string(scope), scopeId) diff --git a/pkg/monitor/models/alert.go b/pkg/monitor/models/alert.go index 34bfb04f97..b5f42fac9b 100644 --- a/pkg/monitor/models/alert.go +++ b/pkg/monitor/models/alert.go @@ -22,6 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -31,7 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/monitor/validators" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -81,8 +81,8 @@ func (man *SAlertManager) GetTester() AlertTestRunner { return man.tester } -func (manager *SAlertManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (manager *SAlertManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (manager *SAlertManager) ListItemExportKeys(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, keys stringutils2.SSortedStrings) (*sqlchemy.SQuery, error) { diff --git a/pkg/monitor/models/alertdashboard.go b/pkg/monitor/models/alertdashboard.go index 7996d734e8..fb27df05f1 100644 --- a/pkg/monitor/models/alertdashboard.go +++ b/pkg/monitor/models/alertdashboard.go @@ -21,13 +21,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis/monitor" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -61,8 +61,8 @@ func init() { AlertDashBoardManager.SetVirtualObject(AlertDashBoardManager) } -func (manager *SAlertDashBoardManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (manager *SAlertDashBoardManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (manager *SAlertDashBoardManager) ListItemExportKeys(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, keys stringutils2.SSortedStrings) (*sqlchemy.SQuery, error) { @@ -140,13 +140,13 @@ func (dash *SAlertDashBoard) PerformSetScope(ctx context.Context, userCred mccli if len(domainId) == 0 && len(projectId) == 0 { scope, _ := data.GetString("scope") if len(scope) != 0 { - switch rbacutils.TRbacScope(scope) { - case rbacutils.ScopeSystem: + switch rbacscope.TRbacScope(scope) { + case rbacscope.ScopeSystem: - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: domainId = userCred.GetProjectDomainId() data.(*jsonutils.JSONDict).Set("domain_id", jsonutils.NewString(domainId)) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: projectId = userCred.GetProjectId() data.(*jsonutils.JSONDict).Set("project_id", jsonutils.NewString(projectId)) } diff --git a/pkg/monitor/models/alertpannel.go b/pkg/monitor/models/alertpannel.go index 1fbb1391cc..1d63554d5a 100644 --- a/pkg/monitor/models/alertpannel.go +++ b/pkg/monitor/models/alertpannel.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -29,7 +30,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" merrors "yunion.io/x/onecloud/pkg/monitor/errors" "yunion.io/x/onecloud/pkg/monitor/validators" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -62,8 +62,8 @@ type SAlertPanel struct { Message string `charset:"utf8" list:"user" create:"optional" update:"user"` } -func (manager *SAlertPanelManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (manager *SAlertPanelManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (manager *SAlertPanelManager) ListItemExportKeys(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, diff --git a/pkg/monitor/models/alertrecord.go b/pkg/monitor/models/alertrecord.go index 773541954f..897c656854 100644 --- a/pkg/monitor/models/alertrecord.go +++ b/pkg/monitor/models/alertrecord.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/filterclause" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/sqlchemy" @@ -31,7 +32,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -73,8 +73,8 @@ func init() { AlertRecordManager.SetVirtualObject(AlertRecordManager) } -func (manager *SAlertRecordManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (manager *SAlertRecordManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (manager *SAlertRecordManager) ListItemExportKeys(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, keys stringutils2.SSortedStrings) (*sqlchemy.SQuery, error) { @@ -413,7 +413,7 @@ func (manager *SAlertRecordManager) getNowAlertingRecord(ctx context.Context, us ownerId = userCred } query := manager.Query() - query = manager.FilterByOwner(query, ownerId, rbacutils.String2Scope(input.Scope)) + query = manager.FilterByOwner(query, ownerId, rbacscope.String2Scope(input.Scope)) //query = query.GE("created_at", startTime.UTC().Format(timeutils.MysqlTimeFormat)) query = query.Equals("state", monitor.AlertStateAlerting) query = query.IsNotNull("res_type").IsNotEmpty("res_type").Desc("created_at") @@ -424,7 +424,7 @@ func (manager *SAlertRecordManager) getNowAlertingRecord(ctx context.Context, us alertsQuery := CommonAlertManager.Query("id").Equals("state", monitor.AlertStateAlerting).IsTrue("enabled"). IsNull("used_by") - alertsQuery = CommonAlertManager.FilterByOwner(alertsQuery, userCred, rbacutils.String2Scope(input.Scope)) + alertsQuery = CommonAlertManager.FilterByOwner(alertsQuery, userCred, rbacscope.String2Scope(input.Scope)) alerts := make([]SCommonAlert, 0) records := make([]SAlertRecord, 0) err = db.FetchModelObjects(CommonAlertManager, alertsQuery, &alerts) diff --git a/pkg/monitor/models/commonalert.go b/pkg/monitor/models/commonalert.go index 8c61dce2d3..176084ac27 100644 --- a/pkg/monitor/models/commonalert.go +++ b/pkg/monitor/models/commonalert.go @@ -25,7 +25,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/sets" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -33,7 +35,6 @@ import ( "yunion.io/x/onecloud/pkg/apis" "yunion.io/x/onecloud/pkg/apis/monitor" notiapi "yunion.io/x/onecloud/pkg/apis/notify" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/lockman" "yunion.io/x/onecloud/pkg/hostman/hostinfo/hostconsts" @@ -46,7 +47,6 @@ import ( "yunion.io/x/onecloud/pkg/monitor/options" "yunion.io/x/onecloud/pkg/monitor/validators" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -118,8 +118,8 @@ func (man *SCommonAlertManager) DeleteSubscriptionAlert(alert *SCommonAlert) { man.subscriptionManager.DeleteAlert(alert) } -func (man *SCommonAlertManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (man *SCommonAlertManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (manager *SCommonAlertManager) Init() error { @@ -1215,13 +1215,13 @@ func (alert *SCommonAlert) PerformSetScope(ctx context.Context, userCred mcclien if len(domainId) == 0 && len(projectId) == 0 { scope, _ := data.GetString("scope") if len(scope) != 0 { - switch rbacutils.TRbacScope(scope) { - case rbacutils.ScopeSystem: + switch rbacscope.TRbacScope(scope) { + case rbacscope.ScopeSystem: - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: domainId = userCred.GetProjectDomainId() data.(*jsonutils.JSONDict).Set("domain_id", jsonutils.NewString(domainId)) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: projectId = userCred.GetProjectId() data.(*jsonutils.JSONDict).Set("project_id", jsonutils.NewString(projectId)) } diff --git a/pkg/monitor/models/metric.go b/pkg/monitor/models/metric.go index fc7eff25f6..f72f956d78 100644 --- a/pkg/monitor/models/metric.go +++ b/pkg/monitor/models/metric.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -33,7 +34,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/monitor/dbinit" "yunion.io/x/onecloud/pkg/monitor/registry" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -99,8 +99,8 @@ func (manager *SMetricMeasurementManager) GetCache() IMetricMeasurementCache { return manager.measurementsCache } -func (manager *SMetricMeasurementManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (manager *SMetricMeasurementManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (manager *SMetricMeasurementManager) ListItemExportKeys(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, keys stringutils2.SSortedStrings) (*sqlchemy.SQuery, error) { diff --git a/pkg/monitor/models/metric_field.go b/pkg/monitor/models/metric_field.go index 04ef0963b9..a9306fbca1 100644 --- a/pkg/monitor/models/metric_field.go +++ b/pkg/monitor/models/metric_field.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -28,7 +29,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -64,8 +64,8 @@ func init() { MetricFieldManager.SetVirtualObject(MetricFieldManager) } -func (manager *SMetricFieldManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (manager *SMetricFieldManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (manager *SMetricFieldManager) ListItemExportKeys(ctx context.Context, q *sqlchemy.SQuery, diff --git a/pkg/monitor/models/monitor_resource.go b/pkg/monitor/models/monitor_resource.go index 24ccc5011f..7864bc00d6 100644 --- a/pkg/monitor/models/monitor_resource.go +++ b/pkg/monitor/models/monitor_resource.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -33,7 +34,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -351,7 +351,7 @@ func (manager *SMonitorResourceManager) GetPropertyAlert(ctx context.Context, us if owner == nil { owner = userCred } - manager.FilterByOwner(query, owner, rbacutils.TRbacScope(scope)) + manager.FilterByOwner(query, owner, rbacscope.TRbacScope(scope)) query.AppendField(sqlchemy.COUNT("count_id", query.Field("id"))) input := monitor.MonitorResourceListInput{ResType: resType} query = manager.FieldListFilter(query, input) diff --git a/pkg/monitor/models/monitor_resource_alert.go b/pkg/monitor/models/monitor_resource_alert.go index 4ab00fab92..d29f97832e 100644 --- a/pkg/monitor/models/monitor_resource_alert.go +++ b/pkg/monitor/models/monitor_resource_alert.go @@ -21,12 +21,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis/monitor" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -165,7 +165,7 @@ func (m *SMonitorResourceAlertManager) ListItemFilter(ctx context.Context, q *sq if err != nil { return q, errors.Wrap(err, "Get monitor in Query err") } - m.SMonitorScopedResourceManager.FilterByOwner(resQ, userCred, rbacutils.TRbacScope(input.Scope)) + m.SMonitorScopedResourceManager.FilterByOwner(resQ, userCred, rbacscope.TRbacScope(input.Scope)) q.Filter(sqlchemy.In(q.Field("monitor_resource_id"), resQ.SubQuery())) } if len(input.SendState) != 0 { @@ -184,7 +184,7 @@ func (m *SMonitorResourceAlertManager) ListItemFilter(ctx context.Context, q *sq q.Filter(sqlchemy.In(q.Field("monitor_resource_id"), resQ.SubQuery())) } alertQuery := CommonAlertManager.Query("id") - m.SMonitorScopedResourceManager.FilterByOwner(alertQuery, userCred, rbacutils.TRbacScope(input.Scope)) + m.SMonitorScopedResourceManager.FilterByOwner(alertQuery, userCred, rbacscope.TRbacScope(input.Scope)) if len(input.AlertName) != 0 { CommonAlertManager.FieldListFilter(alertQuery, monitor.CommonAlertListInput{Name: input.AlertName}) q.Filter(sqlchemy.In(q.Field(m.GetSlaveFieldName()), alertQuery.SubQuery())) @@ -261,7 +261,7 @@ func (obj *SMonitorResourceAlert) getMoreDetails(detail monitor.MonitorResourceJ return detail } -func (manager *SMonitorResourceAlertManager) ResourceScope() rbacutils.TRbacScope { +func (manager *SMonitorResourceAlertManager) ResourceScope() rbacscope.TRbacScope { return manager.SScopedResourceBaseManager.ResourceScope() } @@ -273,6 +273,6 @@ func (manager *SMonitorResourceAlertManager) ListItemExportKeys(ctx context.Cont return q, nil } -func (m *SMonitorResourceAlertManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (m *SMonitorResourceAlertManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { return q } diff --git a/pkg/monitor/models/monitorscoperesource.go b/pkg/monitor/models/monitorscoperesource.go index f045fd2101..b9e150d68e 100644 --- a/pkg/monitor/models/monitorscoperesource.go +++ b/pkg/monitor/models/monitorscoperesource.go @@ -18,11 +18,11 @@ import ( "context" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SMonitorScopedResourceManager struct { @@ -33,14 +33,14 @@ type SMonitorScopedResource struct { db.SScopedResourceBase } -func (m *SMonitorScopedResourceManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (m *SMonitorScopedResourceManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if userCred == nil { return q } switch scope { - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: q = q.Equals("domain_id", userCred.GetProjectDomainId()) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: q = q.Equals("tenant_id", userCred.GetProjectId()) } @@ -49,21 +49,21 @@ func (m *SMonitorScopedResourceManager) FilterByOwner(q *sqlchemy.SQuery, userCr func (s *SMonitorScopedResource) CustomizeCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) error { scope, _ := data.GetString("scope") - switch rbacutils.TRbacScope(scope) { - case rbacutils.ScopeSystem: + switch rbacscope.TRbacScope(scope) { + case rbacscope.ScopeSystem: s.DomainId = "" s.ProjectId = "" - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: s.DomainId = ownerId.GetProjectDomainId() s.ProjectId = "" - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: s.DomainId = ownerId.GetProjectDomainId() s.ProjectId = ownerId.GetProjectId() } return nil } -func (manager *SMonitorScopedResourceManager) ResourceScope() rbacutils.TRbacScope { +func (manager *SMonitorScopedResourceManager) ResourceScope() rbacscope.TRbacScope { return manager.SScopedResourceBaseManager.ResourceScope() } diff --git a/pkg/monitor/models/nodealert.go b/pkg/monitor/models/nodealert.go index a7ed8b2921..dda4194796 100644 --- a/pkg/monitor/models/nodealert.go +++ b/pkg/monitor/models/nodealert.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis" @@ -35,7 +36,6 @@ import ( modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" merrors "yunion.io/x/onecloud/pkg/monitor/errors" "yunion.io/x/onecloud/pkg/monitor/options" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -894,6 +894,6 @@ func (alert *SNodeAlert) CustomizeDelete( return alert.SCommonAlert.CustomizeDelete(ctx, userCred, query, data) } -func (m *SNodeAlertManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (m *SNodeAlertManager) FilterByOwner(q *sqlchemy.SQuery, userCred mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { return q } diff --git a/pkg/monitor/models/unifiedmonitor.go b/pkg/monitor/models/unifiedmonitor.go index 651e21c197..beb634be72 100644 --- a/pkg/monitor/models/unifiedmonitor.go +++ b/pkg/monitor/models/unifiedmonitor.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/apis/monitor" "yunion.io/x/onecloud/pkg/cloudcommon/db" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/monitor/tsdb" "yunion.io/x/onecloud/pkg/monitor/validators" "yunion.io/x/onecloud/pkg/util/influxdb" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) const ( @@ -374,8 +374,8 @@ func setDefaultValue(query *monitor.AlertQuery, inputQuery *monitor.MetricInputQ query.Model.Selects[i] = sel } var projectId, domainId string - switch rbacutils.TRbacScope(scope) { - case rbacutils.ScopeProject: + switch rbacscope.TRbacScope(scope) { + case rbacscope.ScopeProject: projectId = ownerId.GetProjectId() containId := false for _, tagFilter := range query.Model.Tags { @@ -392,7 +392,7 @@ func setDefaultValue(query *monitor.AlertQuery, inputQuery *monitor.MetricInputQ Condition: "and", }) } - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: domainId = ownerId.GetProjectDomainId() containId := false for _, tagFilter := range query.Model.Tags { diff --git a/pkg/monitor/notifydrivers/feishu/client.go b/pkg/monitor/notifydrivers/feishu/client.go index dbc3491872..e95a5da5ee 100644 --- a/pkg/monitor/notifydrivers/feishu/client.go +++ b/pkg/monitor/notifydrivers/feishu/client.go @@ -22,8 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" - - "yunion.io/x/onecloud/pkg/util/httputils" + "yunion.io/x/pkg/util/httputils" ) const ( diff --git a/pkg/monitor/service/dispatcher.go b/pkg/monitor/service/dispatcher.go index e55f0d1e15..cd08c0721f 100644 --- a/pkg/monitor/service/dispatcher.go +++ b/pkg/monitor/service/dispatcher.go @@ -22,8 +22,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/mcclient/auth" diff --git a/pkg/notify/models/config.go b/pkg/notify/models/config.go index 83f251e466..19cd62ee27 100644 --- a/pkg/notify/models/config.go +++ b/pkg/notify/models/config.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/sets" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -36,7 +37,6 @@ import ( notifyv2 "yunion.io/x/onecloud/pkg/notify" "yunion.io/x/onecloud/pkg/notify/oldmodels" "yunion.io/x/onecloud/pkg/notify/options" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -88,7 +88,7 @@ func (cm *SConfigManager) ValidateCreateData(ctx context.Context, userCred mccli } if input.Attribution == api.CONFIG_ATTRIBUTION_SYSTEM { allowScope, _ := policy.PolicyManager.AllowScope(userCred, consts.GetServiceType(), ConfigManager.KeywordPlural(), policy.PolicyActionCreate) - if allowScope != rbacutils.ScopeSystem { + if allowScope != rbacscope.ScopeSystem { return input, httperrors.NewInputParameterError("No permission to set %q attribution", api.CONFIG_ATTRIBUTION_SYSTEM) } } @@ -507,13 +507,13 @@ func (self *SConfigManager) InitializeData() error { return nil } -func (cm *SConfigManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (cm *SConfigManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } -func (cm *SConfigManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (cm *SConfigManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { switch scope { - case rbacutils.ScopeDomain, rbacutils.ScopeProject: + case rbacscope.ScopeDomain, rbacscope.ScopeProject: q = q.Equals("attribution", api.CONFIG_ATTRIBUTION_DOMAIN) if owner != nil { q = q.Equals("domain_id", owner.GetProjectDomainId()) diff --git a/pkg/notify/models/notification.go b/pkg/notify/models/notification.go index 1a398dc97f..0c10847640 100644 --- a/pkg/notify/models/notification.go +++ b/pkg/notify/models/notification.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/sets" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -36,7 +37,6 @@ import ( notifyv2 "yunion.io/x/onecloud/pkg/notify" "yunion.io/x/onecloud/pkg/notify/oldmodels" "yunion.io/x/onecloud/pkg/notify/options" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -83,7 +83,7 @@ func (nm *SNotificationManager) ValidateCreateData(ctx context.Context, userCred return input, httperrors.NewInputParameterError("invalid tag") } if len(input.Contacts) > 0 { - if userCred.IsAllow(rbacutils.ScopeSystem, api.SERVICE_TYPE, nm.KeywordPlural(), policy.PolicyActionPerform, SendByContact).Result.IsDeny() { + if userCred.IsAllow(rbacscope.ScopeSystem, api.SERVICE_TYPE, nm.KeywordPlural(), policy.PolicyActionPerform, SendByContact).Result.IsDeny() { return input, httperrors.NewForbiddenError("only admin can send notification by contact") } if len(input.Contacts) == 0 { @@ -522,14 +522,14 @@ func (n *SNotification) ReceiverNotificationsNotOK() ([]SReceiverNotification, e func (n *SNotification) ReceiveDetails(userCred mcclient.TokenCredential, scope string) ([]api.ReceiveDetail, error) { RQ := ReceiverManager.Query("id", "name") q := ReceiverNotificationManager.Query("receiver_id", "notification_id", "receiver_type", "contact", "send_at", "send_by", "status", "failed_reason").Equals("notification_id", n.Id) - s := rbacutils.TRbacScope(scope) + s := rbacscope.TRbacScope(scope) switch s { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: subRQ := RQ.SubQuery() q.AppendField(subRQ.Field("name", "receiver_name")) q = q.LeftJoin(subRQ, sqlchemy.OR(sqlchemy.Equals(q.Field("receiver_id"), subRQ.Field("id")), sqlchemy.Equals(q.Field("contact"), subRQ.Field("id")))) - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: subRQ := RQ.Equals("domain_id", userCred.GetDomainId()).SubQuery() q.AppendField(subRQ.Field("name", "receiver_name")) q = q.Join(subRQ, sqlchemy.OR(sqlchemy.Equals(q.Field("receiver_id"), subRQ.Field("id")), sqlchemy.Equals(q.Field("contact"), subRQ.Field("id")))) @@ -592,29 +592,29 @@ func (n *SNotification) Notification() (notifyv2.SNotification, error) { }, nil } -func (nm *SNotificationManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeUser +func (nm *SNotificationManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeUser } -func (nm *SNotificationManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (nm *SNotificationManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (nm *SNotificationManager) FetchOwnerId(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) { return db.FetchUserInfo(ctx, data) } -func (nm *SNotificationManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (nm *SNotificationManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner == nil { return q } switch scope { - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: subRq := ReceiverManager.Query("id").Equals("domain_id", owner.GetDomainId()).SubQuery() RNq := ReceiverNotificationManager.Query("notification_id", "receiver_id") subRNq := RNq.Join(subRq, sqlchemy.OR(sqlchemy.Equals(RNq.Field("receiver_id"), subRq.Field("id")), sqlchemy.Equals(RNq.Field("contact"), subRq.Field("id")))).SubQuery() q = q.Join(subRNq, sqlchemy.Equals(q.Field("id"), subRNq.Field("notification_id"))) - case rbacutils.ScopeProject, rbacutils.ScopeUser: + case rbacscope.ScopeProject, rbacscope.ScopeUser: sq := ReceiverNotificationManager.Query("notification_id") subq := sq.Filter(sqlchemy.OR(sqlchemy.Equals(sq.Field("receiver_id"), owner.GetUserId()), sqlchemy.Equals(sq.Field("contact"), owner.GetUserId()))).SubQuery() q = q.Join(subq, sqlchemy.Equals(q.Field("id"), subq.Field("notification_id"))) diff --git a/pkg/notify/models/receiver.go b/pkg/notify/models/receiver.go index f5d1a616bb..ffb014467b 100644 --- a/pkg/notify/models/receiver.go +++ b/pkg/notify/models/receiver.go @@ -26,6 +26,8 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/regutils" "yunion.io/x/pkg/util/sets" "yunion.io/x/pkg/utils" @@ -44,9 +46,7 @@ import ( notify_modules "yunion.io/x/onecloud/pkg/mcclient/modules/notify" "yunion.io/x/onecloud/pkg/notify/oldmodels" "yunion.io/x/onecloud/pkg/notify/options" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -547,8 +547,8 @@ func (rm *SReceiverManager) VerifiedContactFilter(contactType string, q *sqlchem return q } -func (rm *SReceiverManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeUser +func (rm *SReceiverManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeUser } func (rm *SReceiverManager) FetchOwnerId(ctx context.Context, data jsonutils.JSONObject) (mcclient.IIdentityProvider, error) { @@ -574,20 +574,20 @@ func (rm *SReceiverManager) FetchOwnerId(ctx context.Context, data jsonutils.JSO return db.FetchDomainInfo(ctx, data) } -func (rm *SReceiverManager) filterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (rm *SReceiverManager) filterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner == nil { return q } switch scope { - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: q = q.Equals("domain_id", owner.GetProjectDomainId()) - case rbacutils.ScopeProject, rbacutils.ScopeUser: + case rbacscope.ScopeProject, rbacscope.ScopeUser: q = q.Equals("id", owner.GetUserId()) } return q } -func (rm *SReceiverManager) filterByOwnerAndProjectDomain(ctx context.Context, userCred mcclient.TokenCredential, q *sqlchemy.SQuery, scope rbacutils.TRbacScope) (*sqlchemy.SQuery, error) { +func (rm *SReceiverManager) filterByOwnerAndProjectDomain(ctx context.Context, userCred mcclient.TokenCredential, q *sqlchemy.SQuery, scope rbacscope.TRbacScope) (*sqlchemy.SQuery, error) { if userCred == nil { return q, nil } @@ -607,9 +607,9 @@ func (rm *SReceiverManager) filterByOwnerAndProjectDomain(ctx context.Context, u } switch scope { - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: ownerCondition = sqlchemy.Equals(q.Field("domain_id"), userCred.GetProjectDomainId()) - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: ownerCondition = sqlchemy.Equals(q.Field("id"), userCred.GetUserId()) } @@ -625,7 +625,7 @@ func (rm *SReceiverManager) filterByOwnerAndProjectDomain(ctx context.Context, u return q, nil } -func (rm *SReceiverManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (rm *SReceiverManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { return q } @@ -851,7 +851,7 @@ func (r *SReceiver) CustomizeCreate(ctx context.Context, userCred mcclient.Token // 方案:检查请求者对于创建联系人 是否具有system scope if input.ForceVerified { allowScope, _ := policy.PolicyManager.AllowScope(userCred, api.SERVICE_TYPE, ReceiverManager.KeywordPlural(), policy.PolicyActionCreate) - if allowScope == rbacutils.ScopeSystem { + if allowScope == rbacscope.ScopeSystem { if r.EnabledEmail.Bool() { r.VerifiedEmail = tristate.True } @@ -922,7 +922,7 @@ func (r *SReceiver) PreUpdate(ctx context.Context, userCred mcclient.TokenCreden // 管理后台修改联系人,如果修改或者启用手机号和邮箱,无需进行校验 if input.ForceVerified { allowScope, _ := policy.PolicyManager.AllowScope(userCred, api.SERVICE_TYPE, ReceiverManager.KeywordPlural(), policy.PolicyActionCreate) - if allowScope == rbacutils.ScopeSystem { + if allowScope == rbacscope.ScopeSystem { // 修改并启用 if len(input.Email) != 0 && input.Email != r.Email && r.EnabledEmail.Bool() { r.VerifiedEmail = tristate.True diff --git a/pkg/notify/models/robot.go b/pkg/notify/models/robot.go index c8c8bea870..b650b386ae 100644 --- a/pkg/notify/models/robot.go +++ b/pkg/notify/models/robot.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" rpcapi "yunion.io/x/onecloud/pkg/notify/rpc/apis" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -120,7 +120,7 @@ func (rm *SRobotManager) InitializeData() error { Lang: "zh_CN", } robot.IsPublic = true - robot.PublicScope = string(rbacutils.ScopeSystem) + robot.PublicScope = string(rbacscope.ScopeSystem) robot.DomainId = idenapi.DEFAULT_DOMAIN_ID robot.ProjectId = systemId robot.ProjectSrc = "local" diff --git a/pkg/notify/models/subscriber.go b/pkg/notify/models/subscriber.go index c4839b9bda..832a72567f 100644 --- a/pkg/notify/models/subscriber.go +++ b/pkg/notify/models/subscriber.go @@ -40,6 +40,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -50,7 +51,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/auth" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -109,7 +109,7 @@ func (sm *SSubscriberManager) validateReceivers(ctx context.Context, receivers [ func (sm *SSubscriberManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, input api.SubscriberCreateInput) (api.SubscriberCreateInput, error) { var err error // permission check - sSystem, sDomain := string(rbacutils.ScopeSystem), string(rbacutils.ScopeDomain) + sSystem, sDomain := string(rbacscope.ScopeSystem), string(rbacscope.ScopeDomain) switch input.Scope { case sSystem: allow := db.IsAdminAllowCreate(userCred, sm) @@ -251,7 +251,7 @@ func (s *SSubscriber) CustomizeCreate(ctx context.Context, userCred mcclient.Tok } func (s *SSubscriber) PerformChange(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.SubscriberChangeInput) (jsonutils.JSONObject, error) { - if s.Scope == string(rbacutils.ScopeSystem) { + if s.Scope == string(rbacscope.ScopeSystem) { if !db.IsAdminAllowUpdate(ctx, userCred, s) { return nil, httperrors.NewForbiddenError("") } @@ -302,7 +302,7 @@ func (sm *SSubscriberManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQ if err != nil { return nil, errors.Wrap(err, "SEnabledResourceBaseManager.ListItemFilter") } - sSystem, sDomain := string(rbacutils.ScopeSystem), string(rbacutils.ScopeDomain) + sSystem, sDomain := string(rbacscope.ScopeSystem), string(rbacscope.ScopeDomain) if input.Scope == "" { input.Scope = sSystem } @@ -366,7 +366,7 @@ func (s *SSubscriber) CustomizeDelete(ctx context.Context, userCred mcclient.Tok if err != nil { return err } - if s.Scope == string(rbacutils.ScopeSystem) { + if s.Scope == string(rbacscope.ScopeSystem) { if !db.IsAdminAllowDelete(ctx, userCred, s) { return httperrors.NewForbiddenError("") } diff --git a/pkg/notify/models/template.go b/pkg/notify/models/template.go index d92152fd9c..6c6d2a1211 100644 --- a/pkg/notify/models/template.go +++ b/pkg/notify/models/template.go @@ -26,12 +26,13 @@ import ( ptem "text/template" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/notify" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" @@ -39,7 +40,6 @@ import ( notifyv2 "yunion.io/x/onecloud/pkg/notify" "yunion.io/x/onecloud/pkg/notify/options" "yunion.io/x/onecloud/pkg/notify/rpc/apis" - "yunion.io/x/onecloud/pkg/util/httputils" ) type STemplateManager struct { diff --git a/pkg/notify/policy/defaults.go b/pkg/notify/policy/defaults.go index f08409a705..509b2efba7 100644 --- a/pkg/notify/policy/defaults.go +++ b/pkg/notify/policy/defaults.go @@ -15,6 +15,8 @@ package policy import ( + "yunion.io/x/pkg/util/rbacscope" + api "yunion.io/x/onecloud/pkg/apis/notify" common_policy "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/util/rbacutils" @@ -33,7 +35,7 @@ var ( predefinedDefaultPolicies = []rbacutils.SRbacPolicy{ { Auth: true, - Scope: rbacutils.ScopeUser, + Scope: rbacscope.ScopeUser, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -75,7 +77,7 @@ var ( }, { Auth: true, - Scope: rbacutils.ScopeSystem, + Scope: rbacscope.ScopeSystem, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -93,7 +95,7 @@ var ( }, { Auth: true, - Scope: rbacutils.ScopeSystem, + Scope: rbacscope.ScopeSystem, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -135,7 +137,7 @@ var ( }, { Auth: true, - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, diff --git a/pkg/proxy/http.go b/pkg/proxy/http.go index 4e47584463..69072201e0 100644 --- a/pkg/proxy/http.go +++ b/pkg/proxy/http.go @@ -22,8 +22,8 @@ import ( "net/url" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/httperrors" ) diff --git a/pkg/s3gateway/handlers/errors.go b/pkg/s3gateway/handlers/errors.go index 6985f157ae..77ab1cd2fa 100644 --- a/pkg/s3gateway/handlers/errors.go +++ b/pkg/s3gateway/handlers/errors.go @@ -20,10 +20,10 @@ import ( "runtime/debug" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" "yunion.io/x/s3cli" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/httperrors" ) diff --git a/pkg/s3gateway/handlers/middelware.go b/pkg/s3gateway/handlers/middelware.go index 6972f05ef6..7ea07dce7a 100644 --- a/pkg/s3gateway/handlers/middelware.go +++ b/pkg/s3gateway/handlers/middelware.go @@ -19,9 +19,9 @@ import ( "net/http" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/gotypes" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/mcclient/auth" ) diff --git a/pkg/s3gateway/models/cloudproviders.go b/pkg/s3gateway/models/cloudproviders.go index 0da9c2747d..32988d9130 100644 --- a/pkg/s3gateway/models/cloudproviders.go +++ b/pkg/s3gateway/models/cloudproviders.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" proxyapi "yunion.io/x/onecloud/pkg/apis/cloudcommon/proxy" @@ -32,7 +33,6 @@ import ( modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/s3gateway/session" "yunion.io/x/onecloud/pkg/util/hashcache" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SCloudproviderManagerDelegate struct { diff --git a/pkg/scheduledtask/models/scheduled_tasks.go b/pkg/scheduledtask/models/scheduled_tasks.go index 41ecda789e..28800198cf 100644 --- a/pkg/scheduledtask/models/scheduled_tasks.go +++ b/pkg/scheduledtask/models/scheduled_tasks.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/sets" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" @@ -40,7 +41,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/modules/compute" "yunion.io/x/onecloud/pkg/mcclient/options" sop "yunion.io/x/onecloud/pkg/scheduledtask/options" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" "yunion.io/x/onecloud/pkg/util/stringutils2" ) diff --git a/pkg/scheduledtask/models/scheduledtask_activity.go b/pkg/scheduledtask/models/scheduledtask_activity.go index 264ec88acd..c32657ec2f 100644 --- a/pkg/scheduledtask/models/scheduledtask_activity.go +++ b/pkg/scheduledtask/models/scheduledtask_activity.go @@ -19,13 +19,13 @@ import ( "time" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/scheduledtask" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -114,18 +114,18 @@ func (sam *SScheduledTaskActivityManager) ListItemFilter(ctx context.Context, q return q, nil } -func (sam *SScheduledTaskActivityManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (sam *SScheduledTaskActivityManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } -func (sam *SScheduledTaskActivityManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (sam *SScheduledTaskActivityManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } -func (sam *SScheduledTaskActivityManager) FileterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (sam *SScheduledTaskActivityManager) FileterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { switch scope { - case rbacutils.ScopeProject, rbacutils.ScopeDomain: + case rbacscope.ScopeProject, rbacscope.ScopeDomain: scheduledTaskQ := ScheduledTaskManager.Query("id", "domain_id").SubQuery() q = q.Join(scheduledTaskQ, sqlchemy.Equals(q.Field("scheduled_task_id"), scheduledTaskQ.Field("id"))) q = q.Filter(sqlchemy.Equals(scheduledTaskQ.Field("domain_id"), owner.GetProjectDomainId())) diff --git a/pkg/scheduler/algorithm/predicates/class_metadata_predicate.go b/pkg/scheduler/algorithm/predicates/class_metadata_predicate.go index 6d8a73d9c7..73db6c3beb 100644 --- a/pkg/scheduler/algorithm/predicates/class_metadata_predicate.go +++ b/pkg/scheduler/algorithm/predicates/class_metadata_predicate.go @@ -20,12 +20,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/compute/models" "yunion.io/x/onecloud/pkg/mcclient/auth" "yunion.io/x/onecloud/pkg/scheduler/core" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type ClassMetadataPredicate struct { @@ -102,7 +102,7 @@ func (p *ClassMetadataPredicate) PreExecute(ctx context.Context, u *core.Unit, c // no check if image if system public image public := jsonutils.QueryBoolean(obj.Info, "is_public", false) publicScope, _ := obj.Info.GetString("public_scope") - if !public || publicScope != string(rbacutils.ScopeSystem) { + if !public || publicScope != string(rbacscope.ScopeSystem) { stand = obj guestSource.keyword = "image" } diff --git a/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go b/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go index fe04878afe..e6a812af98 100644 --- a/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go +++ b/pkg/scheduler/algorithm/predicates/disk_schedtag_predicate.go @@ -19,13 +19,13 @@ import ( "fmt" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" computeapi "yunion.io/x/onecloud/pkg/apis/compute" schedapi "yunion.io/x/onecloud/pkg/apis/scheduler" "yunion.io/x/onecloud/pkg/scheduler/api" "yunion.io/x/onecloud/pkg/scheduler/core" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type DiskSchedtagPredicate struct { @@ -139,8 +139,8 @@ func (p *DiskSchedtagPredicate) IsResourceFitInput(ctx context.Context, u *core. // domain ownership filter if storage.DomainId == u.SchedInfo.Domain { - } else if storage.IsPublic && storage.PublicScope == string(rbacutils.ScopeSystem) { - } else if storage.IsPublic && storage.PublicScope == string(rbacutils.ScopeDomain) && utils.IsInStringArray(u.SchedInfo.Domain, storage.GetSharedDomains()) { + } else if storage.IsPublic && storage.PublicScope == string(rbacscope.ScopeSystem) { + } else if storage.IsPublic && storage.PublicScope == string(rbacscope.ScopeDomain) && utils.IsInStringArray(u.SchedInfo.Domain, storage.GetSharedDomains()) { } else { return &FailReason{ Reason: fmt.Sprintf("Storage %s is not accessible due to domain ownership", storage.Name), diff --git a/pkg/scheduler/algorithm/predicates/domain_predicate.go b/pkg/scheduler/algorithm/predicates/domain_predicate.go index 239ea05f36..15d296e790 100644 --- a/pkg/scheduler/algorithm/predicates/domain_predicate.go +++ b/pkg/scheduler/algorithm/predicates/domain_predicate.go @@ -17,10 +17,10 @@ package predicates import ( "context" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/scheduler/core" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type DomainPredicate struct { @@ -39,8 +39,8 @@ func (p *DomainPredicate) Execute(ctx context.Context, u *core.Unit, c core.Cand h := NewPredicateHelper(p, u, c) getter := c.Getter() if getter.DomainId() == u.SchedInfo.Domain { - } else if getter.IsPublic() && getter.PublicScope() == string(rbacutils.ScopeSystem) { - } else if getter.IsPublic() && getter.PublicScope() == string(rbacutils.ScopeDomain) && utils.IsInStringArray(u.SchedInfo.Domain, getter.SharedDomains()) { + } else if getter.IsPublic() && getter.PublicScope() == string(rbacscope.ScopeSystem) { + } else if getter.IsPublic() && getter.PublicScope() == string(rbacscope.ScopeDomain) && utils.IsInStringArray(u.SchedInfo.Domain, getter.SharedDomains()) { // } else if db.IsAdminAllowGet(context.Background(), u.SchedInfo.UserCred, getter) { } else { h.Exclude("domain_ownership") diff --git a/pkg/scheduler/algorithm/predicates/network_predicate.go b/pkg/scheduler/algorithm/predicates/network_predicate.go index 2c93ad406c..9cbb0c2f8c 100644 --- a/pkg/scheduler/algorithm/predicates/network_predicate.go +++ b/pkg/scheduler/algorithm/predicates/network_predicate.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/sets" "yunion.io/x/pkg/utils" @@ -29,7 +30,6 @@ import ( "yunion.io/x/onecloud/pkg/scheduler/algorithm/plugin" "yunion.io/x/onecloud/pkg/scheduler/api" "yunion.io/x/onecloud/pkg/scheduler/core" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) // NetworkPredicate will filter the current network information with @@ -225,11 +225,11 @@ func IsNetworkAvailable( } } - if n.IsPublic && n.PublicScope == string(rbacutils.ScopeSystem) { + if n.IsPublic && n.PublicScope == string(rbacscope.ScopeSystem) { // system-wide share - } else if n.IsPublic && n.PublicScope == string(rbacutils.ScopeDomain) && (n.DomainId == data.Domain || utils.IsInStringArray(data.Domain, n.GetSharedDomains())) { + } else if n.IsPublic && n.PublicScope == string(rbacscope.ScopeDomain) && (n.DomainId == data.Domain || utils.IsInStringArray(data.Domain, n.GetSharedDomains())) { // domain-wide share - } else if n.PublicScope == string(rbacutils.ScopeProject) && utils.IsInStringArray(data.Project, n.GetSharedProjects()) { + } else if n.PublicScope == string(rbacscope.ScopeProject) && utils.IsInStringArray(data.Project, n.GetSharedProjects()) { // project-wide share } else if n.ProjectId == data.Project { // owner diff --git a/pkg/util/alipayclient/alipay.go b/pkg/util/alipayclient/alipay.go index 1330164b8b..f71fc02ebe 100644 --- a/pkg/util/alipayclient/alipay.go +++ b/pkg/util/alipayclient/alipay.go @@ -28,8 +28,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/seclib2" ) diff --git a/pkg/util/billing/billingcycle_test.go b/pkg/util/billing/billingcycle_test.go deleted file mode 100644 index c43785fb26..0000000000 --- a/pkg/util/billing/billingcycle_test.go +++ /dev/null @@ -1,102 +0,0 @@ -// 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 billing - -import ( - "testing" - "time" -) - -func TestParseBillingCycle(t *testing.T) { - now := time.Now().UTC() - for _, cycleStr := range []string{"1H", "2H", "1D", "1W", "2W", "3W", "4W", "1M", "2M", "1Y", "2Y"} { - bc, err := ParseBillingCycle(cycleStr) - if err != nil { - t.Errorf("error parse %s: %s", cycleStr, err) - } else { - t.Logf("%s: %s + %s = %s Weeks: %d Months: %d", bc.String(), now, bc.String(), bc.EndAt(now), bc.GetWeeks(), bc.GetMonths()) - } - } -} - -func TestLatestLastStart(t *testing.T) { - cases := []struct { - tm string - bc string - want string - }{ - { - tm: "2020-05-16T00:00:00Z", - bc: "1m", - want: "2020-05-01T00:00:00Z", - }, - { - tm: "2020-05-16T23:34:02Z", - bc: "1h", - want: "2020-05-16T23:00:00Z", - }, - { - tm: "2020-05-16T23:34:02Z", - bc: "1i", - want: "2020-05-16T23:34:00Z", - }, - { - tm: "2020-05-16T23:34:02Z", - bc: "1d", - want: "2020-05-16T00:00:00Z", - }, - { - tm: "2020-05-16T23:34:02Z", - bc: "1w", - want: "2020-05-11T00:00:00Z", - }, - { - tm: "2020-05-16T23:34:02Z", - bc: "1y", - want: "2020-01-01T00:00:00Z", - }, - } - for _, c := range cases { - tm, _ := time.Parse(time.RFC3339, c.tm) - bc, _ := ParseBillingCycle(c.bc) - got := bc.LatestLastStart(tm) - want, _ := time.Parse(time.RFC3339, c.want) - if got != want { - t.Errorf("bc: %s want: %s got: %s", c.bc, want, got) - } - } -} - -func TestTimeString(t *testing.T) { - cases := []struct { - tm string - bc string - want string - }{ - { - tm: "2020-05-16T23:23:54Z", - bc: "1m", - want: "202005", - }, - } - for _, c := range cases { - tm, _ := time.Parse(time.RFC3339, c.tm) - bc, _ := ParseBillingCycle(c.bc) - got := bc.TimeString(tm) - if c.want != got { - t.Errorf("bc: %s TimeString want: %s got: %s", c.bc, c.want, got) - } - } -} diff --git a/pkg/util/cloudinit/cloudconfig_test.go b/pkg/util/cloudinit/cloudconfig_test.go deleted file mode 100644 index f751d0abdc..0000000000 --- a/pkg/util/cloudinit/cloudconfig_test.go +++ /dev/null @@ -1,64 +0,0 @@ -// 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 cloudinit - -import ( - "testing" -) - -func TestSCloudConfig_UserData(t *testing.T) { - usr1 := NewUser("root") - usr1.SshKey("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCa4E8wmIOlmh1G8ZRcU2zpnl2frD2lLKdXpbTeUUZEKYFFlYM8TM5UrKrqrMCd3rFjaYGTKWiQwOiWroXlAXausbbVEI29KY+1Vd26qNyejj+CZO9MCj0naIrqa1V0of3TQY5I2U+ToIkyLqVFWhWVa57v/GUxsV2aNTmUS/qz0OPSCFPbGWWB35rsjwnFwq2jF6E8yJgTGDTYZcsghRi3IWfyfeHbSuWdvn6N8XrPBDmNg7h+GSvO6FJlp6MUw1hscECi13GwqXYgJnLG5RMiFH6s0vhozyHkue1vOTcryPHRQD0Jz/INUSaggH8L1HnYSUavOf4Cw25W9HfzgUBf") - - usr2 := NewUser("yunion") - usr2.Password("123@yunion").SudoPolicy(USER_SUDO_NOPASSWD) - - file1 := NewWriteFile("/etc/ansible/hosts", "gobuild\ncloudev\n", "", "", true) - file2 := NewWriteFile("/etc/hosts", "127.0.0.1 localhost\n", "", "", false) - config := SCloudConfig{ - Users: []SUser{ - usr1, - usr2, - }, - WriteFiles: []SWriteFile{ - file1, - file2, - }, - Runcmd: []string{ - "mkdir /var/run/httpd", - }, - PhoneHome: &SPhoneHome{ - Url: "http://www.yunion.io/$INSTANCE_ID", - }, - DisableRoot: 0, - SshPwauth: SSH_PASSWORD_AUTH_ON, - } - userData := config.UserData() - - t.Logf("%s", userData) - - config2, err := ParseUserData(userData) - if err != nil { - t.Errorf("%s", err) - } else { - userData2 := config2.UserData() - t.Logf("%s", userData2) - - if userData != userData2 { - t.Errorf("userData not equal to userData2") - } - } - t.Log(config2.UserDataScript()) -} diff --git a/pkg/util/encode/encode_test.go b/pkg/util/encode/encode_test.go deleted file mode 100644 index 80ab9b5729..0000000000 --- a/pkg/util/encode/encode_test.go +++ /dev/null @@ -1,57 +0,0 @@ -// 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 encode - -import ( - "testing" -) - -func TestLabelEncode(t *testing.T) { - cases := []struct { - label string - encodeLabel string - }{ - { - label: "app/test/hellow", - encodeLabel: "app_2ftest_2fhellow", - }, - { - label: "app/test_hellow", - encodeLabel: "app_2ftest_5fhellow", - }, - { - label: "projName", - encodeLabel: "proj_4eame", - }, - { - label: "你好test", - encodeLabel: "你好test", - }, - { - label: "你好test:", - encodeLabel: "你好test_3a", - }, - } - for _, label := range cases { - encodeLabel := EncodeGoogleLabel(label.label) - if label.encodeLabel != encodeLabel { - t.Fatalf("encode %s to %s want: %s", label.label, encodeLabel, label.encodeLabel) - } - decodeLabel := DecodeGoogleLable(encodeLabel) - if label.label != decodeLabel { - t.Fatalf("decode %s to %s want: %s", encodeLabel, decodeLabel, label.label) - } - } -} diff --git a/pkg/util/fileutils2/exists.go b/pkg/util/fileutils2/exists.go index 42b178e733..f5b8931ef6 100644 --- a/pkg/util/fileutils2/exists.go +++ b/pkg/util/fileutils2/exists.go @@ -14,7 +14,11 @@ package fileutils2 -import "os" +import ( + "os" + + "yunion.io/x/pkg/util/fileutils" +) func Exists(filepath string) bool { _, err := os.Lstat(filepath) @@ -25,19 +29,9 @@ func Exists(filepath string) bool { } func IsFile(filepath string) bool { - fi, err := os.Lstat(filepath) - if err != nil { - return false - } - mode := fi.Mode() - return mode.IsRegular() + return fileutils.IsFile(filepath) } func IsDir(filepath string) bool { - fi, err := os.Lstat(filepath) - if err != nil { - return false - } - mode := fi.Mode() - return mode.IsDir() + return fileutils.IsDir(filepath) } diff --git a/pkg/util/fileutils2/seeker_test.go b/pkg/util/fileutils2/seeker_test.go deleted file mode 100644 index cb69a73711..0000000000 --- a/pkg/util/fileutils2/seeker_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// 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 fileutils2 - -import ( - "io" - "strings" - "testing" -) - -func TestNewReadSeeker(t *testing.T) { - for _, testStr := range []string{ - "This is a test reader string", - "", - } { - seeker, err := NewReadSeeker(strings.NewReader(testStr), int64(len(testStr))) - if err != nil { - t.Fatalf("NewReadSeeker error %s", err) - } - defer seeker.Close() - buf1 := make([]byte, 1024) - n, err := seeker.Read(buf1) - if n != len(testStr) { - t.Fatalf("read buf1 error %s", err) - } - buf2 := make([]byte, 1024) - n, err = seeker.Read(buf2) - if n != 0 { - t.Fatalf("read buf2 should fail") - } - seeker.Seek(0, io.SeekStart) - n, err = seeker.Read(buf2) - if n != len(testStr) { - t.Fatalf("read buf2 error %s", err) - } - } -} diff --git a/pkg/util/fileutils2/sparse_test.go b/pkg/util/fileutils2/sparse_test.go deleted file mode 100644 index ecf8ace758..0000000000 --- a/pkg/util/fileutils2/sparse_test.go +++ /dev/null @@ -1,96 +0,0 @@ -// 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 fileutils2 - -import ( - "bytes" - "io/ioutil" - "os" - "testing" - - "golang.org/x/sys/unix" -) - -func TestSparseFileWriter(t *testing.T) { - writeTmp := func(t *testing.T, want []byte, partSizes []int) { - f, err := ioutil.TempFile("", "sparse-test-") - if err != nil { - t.Fatalf("tmpfile: %v", err) - } - defer f.Close() // close twice - defer os.Remove(f.Name()) - - func() { - sf := NewSparseFileWriter(f) - defer sf.Close() - - wrote := 0 - for i, partSize := range partSizes { - n, err := sf.Write(want[wrote : wrote+partSize]) - if err != nil { - t.Fatalf("wrote part %d (%d bytes), written %d, : %v", i, partSize, n, err) - } - wrote += partSize - } - }() - - got, err := ioutil.ReadFile(f.Name()) - if err != nil { - t.Fatalf("read tmpfile: %v", err) - } - if !bytes.Equal(got, want) { - // hexdump - t.Errorf("got != want") - } - { - stat := &unix.Stat_t{} - err := unix.Lstat(f.Name(), stat) - if err != nil { - t.Errorf("stat(%s): %v", f.Name(), err) - } - t.Logf("data %d, file size: %d, 512*blocks: %d", len(want), stat.Size, 512*stat.Blocks) - } - } - t.Run("1 nul write", func(t *testing.T) { - want := make([]byte, 1024*8-1) - writeTmp(t, want, []int{len(want)}) - }) - t.Run("2 nul write", func(t *testing.T) { - want := make([]byte, 1024*8-1) - writeTmp(t, want, []int{4096, len(want) - 4096}) - }) - t.Run("1 almost nul write", func(t *testing.T) { - want := make([]byte, 4095) - want[1023] = 1 - writeTmp(t, want, []int{len(want)}) - }) - t.Run("nul-nonnul-nul", func(t *testing.T) { - want := make([]byte, 4095) - for i := 1023; i < 2024; i++ { - want[i] = byte(i) - } - writeTmp(t, want, []int{1023, 2024 - 1023, 4095 - 2024}) - }) - t.Run("nonnul-nul-nonnul", func(t *testing.T) { - want := make([]byte, 4095) - for i := 0; i < 2024; i++ { - want[i] = byte(i) | 1 - } - for i := 3011; i < 4095; i++ { - want[i] = byte(i) | 1 - } - writeTmp(t, want, []int{2024, 3011 - 2024, 4095 - 3011}) - }) -} diff --git a/pkg/util/httputils/doc.go b/pkg/util/httputils/doc.go deleted file mode 100644 index aba553ace0..0000000000 --- a/pkg/util/httputils/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// 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 httputils // import "yunion.io/x/onecloud/pkg/util/httputils" diff --git a/pkg/util/httputils/error_test.go b/pkg/util/httputils/error_test.go deleted file mode 100644 index f68855acf4..0000000000 --- a/pkg/util/httputils/error_test.go +++ /dev/null @@ -1,103 +0,0 @@ -// 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 httputils - -import ( - "testing" -) - -func TestVariadic(t *testing.T) { - conv := func(v interface{}) interface{} { return v } - cases := []struct { - name string - msg string - params []interface{} - out string - }{ - { - name: "no params", - msg: "hello", - out: "hello", - }, - { - name: "no params (with fmt escape)", - msg: "hello %s %d %v", - out: "hello %s %d %v", - }, - { - name: "with params (no fmt escape)", - msg: "hello", - params: []interface{}{conv("world")}, - out: "hello%!(EXTRA string=world)", - }, - { - name: "with params (with fmt escape)", - msg: "hello %s", - params: []interface{}{conv("world")}, - out: "hello world", - }, - } - for _, c := range cases { - t.Run(c.name+"_New", func(t *testing.T) { - err := NewJsonClientError(400, "InputParameterError", c.msg, c.params...) - if err.Details != c.out { - t.Errorf("want %s, got %s", c.out, err.Details) - } - }) - } -} - -func TestMsgFmtTmplConversion(t *testing.T) { - cases := []struct { - name string - msgFmt string - msgTmpl string - msgFmt2 string - params []interface{} - out string - }{ - { - name: "empty", - msgFmt: "", - msgTmpl: "", - msgFmt2: "", - }, - { - name: "non-empty", - msgFmt: "%% baremetals %s delete.time %d%", - msgTmpl: "% baremetals {0} delete.time {1}%", - msgFmt2: "% baremetals %s delete.time %s%", - }, - { - name: "non-empty with zh-utf8", - msgFmt: "%% baremetals %s 中文%d ¥%%", - msgTmpl: "% baremetals {0} 中文{1} ¥%", - msgFmt2: "% baremetals %s 中文%s ¥%", - }, - } - - for _, c := range cases { - t.Run(c.name, func(t *testing.T) { - msgTmpl := msgFmtToTmpl(c.msgFmt) - if msgTmpl != c.msgTmpl { - t.Errorf("msgFmtToTmpl: want %s, got %s", c.msgTmpl, msgTmpl) - } - msgFmt2 := msgTmplToFmt(msgTmpl) - if msgFmt2 != c.msgFmt2 { - t.Errorf("msgTmplToFmt: want %s, got %s", c.msgFmt2, msgFmt2) - } - }) - } -} diff --git a/pkg/util/httputils/httputils_test.go b/pkg/util/httputils/httputils_test.go deleted file mode 100644 index 3ce05e002e..0000000000 --- a/pkg/util/httputils/httputils_test.go +++ /dev/null @@ -1,309 +0,0 @@ -// 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 httputils - -import ( - "context" - "encoding/json" - "fmt" - "net" - "net/http" - "net/http/httptest" - "net/url" - "reflect" - "testing" - "time" - - "yunion.io/x/jsonutils" - "yunion.io/x/pkg/errors" - - "yunion.io/x/onecloud/pkg/util/netutils2" -) - -type SErrorMsg struct { - statusCode int - Code string - Message string - Title string - Type string - ErrorCode string - ErrorMsg string - result JSONClientErrorMsg -} - -func TestError(t *testing.T) { - - for testName, msg := range map[string]SErrorMsg{ - "test1": { - statusCode: 400, - Code: "VPC.0601", - Message: "Securitygroup id is invalid.", - Title: "", - Type: "", - result: JSONClientErrorMsg{ - Error: &JSONClientError{ - Code: 400, - Class: "VPC.0601", - Details: "Securitygroup id is invalid.", - }, - }, - }, - "test2": { - statusCode: 400, - Code: "3435", - Message: "Securitygroup id is invalid.", - Title: "", - Type: "", - result: JSONClientErrorMsg{ - Error: &JSONClientError{ - Code: 3435, - Class: "", - Details: "Securitygroup id is invalid.", - }, - }, - }, - "test3": { - statusCode: 400, - ErrorCode: "APIGW.0301", - ErrorMsg: "Incorrect IAM authentication information: verify aksk signature fail", - result: JSONClientErrorMsg{ - Error: &JSONClientError{ - Code: 400, - Class: "APIGW.0301", - Details: "Incorrect IAM authentication information: verify aksk signature fail", - }, - }, - }, - } { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(msg.statusCode) - w.Header().Set("Content-Type", "application/json") - w.Write([]byte(jsonutils.Marshal(msg).String())) - })) - _, _, err := JSONRequest(ts.Client(), context.Background(), THttpMethod("GET"), ts.URL, nil, nil, true) - if err != nil { - respErr := JSONClientErrorMsg{} - if err := json.Unmarshal([]byte(err.Error()), &respErr); err != nil { - t.Error(err) - } - if msg.result.Error.Class != respErr.Error.Class { - t.Errorf("expect %s class %s not %s", testName, msg.result.Error.Class, respErr.Error.Class) - } - if msg.result.Error.Code != respErr.Error.Code { - t.Errorf("expect %s code %d not %d", testName, msg.result.Error.Code, respErr.Error.Code) - } - if msg.result.Error.Details != respErr.Error.Details { - t.Errorf("expect %s detail %s not %s", testName, msg.result.Error.Class, respErr.Error.Class) - } - } - - ts = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(msg.statusCode) - w.Header().Set("Content-Type", "application/json") - w.Write([]byte(jsonutils.Marshal(map[string]SErrorMsg{"error": msg}).String())) - })) - _, _, err = JSONRequest(ts.Client(), context.Background(), THttpMethod("GET"), ts.URL, nil, nil, true) - if err != nil { - respErr := JSONClientErrorMsg{} - if err := json.Unmarshal([]byte(err.Error()), &respErr); err != nil { - t.Error(err) - } - if msg.result.Error.Class != respErr.Error.Class { - t.Errorf("expect %s class %s not %s", testName, msg.result.Error.Class, respErr.Error.Class) - } - if msg.result.Error.Code != respErr.Error.Code { - t.Errorf("expect %s code %d not %d", testName, msg.result.Error.Code, respErr.Error.Code) - } - if msg.result.Error.Details != respErr.Error.Details { - t.Errorf("expect %s detail %s not %s", testName, msg.result.Error.Class, respErr.Error.Class) - } - } - - } -} - -func TestErrorCause(t *testing.T) { - err := errors.Error("TestError") - jsonError := &JSONClientError{ - Code: 400, - Class: string(err), - Details: "detailed test error", - } - wrapError := errors.Wrap(jsonError, "wrap1") - if errors.Cause(wrapError) == err { - t.Logf("%s", wrapError) - } else { - t.Errorf("wrapErro.Cause should be err: %#v != %#v", errors.Cause(wrapError), err) - } -} - -type ResponseHeaderTimeoutHandler struct{} - -func (h *ResponseHeaderTimeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - time.Sleep(time.Duration(ResponseHeaderTimeout+2) * time.Second) - w.Write([]byte("hello")) -} - -func TestResponseHeaderTimeout(t *testing.T) { - s := getTestServer(t, &ResponseHeaderTimeoutHandler{}) - go func() { - s.ListenAndServe() - }() - - clientWait(t) - cli := GetAdaptiveTimeoutClient() - resp, err := cli.Get(fmt.Sprintf("http://%s", s.Addr)) - if err == nil { - t.Errorf("Read shoud error") - } else if !err.(*url.Error).Timeout() { - t.Errorf("Read error %s %s, should be url.Error.Timeout", err, reflect.TypeOf(err)) - } else { - t.Logf("Read error %s %s", err, reflect.TypeOf(err)) - } - CloseResponse(resp) - s.Close() -} - -type clientTimeoutHandler struct{} - -func (h *clientTimeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - for i := 0; i < 4096; i++ { - for j := 0; j < 4096; j++ { - w.Write([]byte("ABCDEFD\n")) - } - time.Sleep(1 * time.Second) - } -} - -func clientWait(t *testing.T) { - t.Logf("wait 2 seconds for server ...") - time.Sleep(2 * time.Second) - t.Logf("Start client ...") -} - -func getTestServer(t *testing.T, h http.Handler) *http.Server { - port, err := netutils2.GetFreePort() - if err != nil { - t.Fatalf("fail to found free port %s", err) - } - t.Logf("Start serve at %d", port) - return &http.Server{ - Addr: fmt.Sprintf("127.0.0.1:%d", port), - Handler: h, - ReadTimeout: 300 * time.Second, - WriteTimeout: 300 * time.Second, - MaxHeaderBytes: 1 << 20, - } -} - -func TestClientTimeout(t *testing.T) { - s := getTestServer(t, &clientTimeoutHandler{}) - go func() { - s.ListenAndServe() - }() - - clientWait(t) - cli := GetTimeoutClient(15 * time.Second) - resp, err := cli.Get(fmt.Sprintf("http://%s", s.Addr)) - if err != nil { - t.Errorf("Read error %s", err) - } else { - buf := make([]byte, 4096) - offset := 0 - for { - var n int - n, err = resp.Body.Read(buf) - if n > 0 { - offset += n - } - if err != nil { - t.Logf("read error %s %s", err, reflect.TypeOf(err)) - break - } - } - t.Logf("read offset %d", offset) - CloseResponse(resp) - } - s.Close() - if err == nil { - t.Errorf("read should error") - } -} - -type idleTimeoutHandler struct{} - -func (h *idleTimeoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - for i := 0; i < 4096; i++ { - for j := 0; j < 4096; j++ { - w.Write([]byte("ABCDEFD\n")) - } - // sleep 15 seconds, make read timeout - time.Sleep(15 * time.Second) - } -} - -func TestIdleTimeout(t *testing.T) { - s := getTestServer(t, &idleTimeoutHandler{}) - go func() { - s.ListenAndServe() - }() - - t.Logf("%s", s.Addr) - clientWait(t) - cli := GetAdaptiveTimeoutClient() - resp, err := cli.Get(fmt.Sprintf("http://%s", s.Addr)) - if err != nil { - t.Errorf("Read error %s", err) - } else { - buf := make([]byte, 4096) - offset := 0 - for { - var n int - n, err = resp.Body.Read(buf) - if n > 0 { - offset += n - } - if err != nil { - t.Logf("read error %s %s", err, reflect.TypeOf(err)) - break - } - } - t.Logf("read offset %d", offset) - CloseResponse(resp) - } - s.Close() - if err == nil { - t.Errorf("read shoud error") - } else if !err.(*net.OpError).Timeout() { - t.Errorf("error shoud be net.OpsError.Timeout, not %s", err) - } else { - t.Logf("error found %s", err) - } -} - -/*func TestDialTimeout(t *testing.T) { - cli := GetAdaptiveTimeoutClient() - resp, err := cli.Get(fmt.Sprintf("http://192.0.0.1:48481")) - if err == nil { - t.Errorf("Read shoud error") - } else if !err.(*url.Error).Timeout() { - t.Errorf("Read error %s %s, should be url.Error.Timeout", err, reflect.TypeOf(err)) - } else { - t.Logf("Read error %s %s", err, reflect.TypeOf(err)) - } - CloseResponse(resp) -}*/ diff --git a/pkg/util/imagetools/doc.go b/pkg/util/imagetools/doc.go deleted file mode 100644 index f5e325625a..0000000000 --- a/pkg/util/imagetools/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// 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 imagetools // import "yunion.io/x/onecloud/pkg/util/imagetools" diff --git a/pkg/util/imagetools/image_test.go b/pkg/util/imagetools/image_test.go deleted file mode 100644 index d29e06b24b..0000000000 --- a/pkg/util/imagetools/image_test.go +++ /dev/null @@ -1,133 +0,0 @@ -// 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 imagetools - -import ( - "testing" - - "yunion.io/x/pkg/util/osprofile" -) - -func TestNormalizeImageInfo(t *testing.T) { - images := []struct { - Name string - OsDistro string - OsType string - OsVersion string - OsLang string - OsArch string - }{ - { - Name: "rhel67_20180816.qcow2", - OsDistro: "RHEL", - OsType: osprofile.OS_TYPE_LINUX, - OsVersion: "6.7", - OsLang: "", - OsArch: "x86_64", - }, - { - Name: "Ubuntu_16.04.3_amd64_qingcloud_20180817.qcow2", - OsDistro: "Ubuntu", - OsType: osprofile.OS_TYPE_LINUX, - OsVersion: "16.04.3", - OsLang: "", - OsArch: "x86_64", - }, - { - Name: "windows-server-2008-dc-cn-20180717", - OsDistro: "Windows Server", - OsType: osprofile.OS_TYPE_WINDOWS, - OsVersion: "2008", - OsLang: "zh_CN", - OsArch: "x86_64", - }, - { - Name: "Ubuntu 14.04 32位", - OsDistro: "Ubuntu", - OsType: osprofile.OS_TYPE_LINUX, - OsVersion: "14.04", - OsLang: "", - OsArch: "x86_32", - }, - { - Name: "CentOS 7.2 64位", - OsDistro: "CentOS", - OsType: osprofile.OS_TYPE_LINUX, - OsVersion: "7.2", - OsLang: "", - OsArch: "x86_64", - }, - { - Name: "Windows Server 2019 数据中心版 64位 中文版 GRID13", - OsDistro: "Windows Server", - OsType: osprofile.OS_TYPE_WINDOWS, - OsVersion: "2019", - OsLang: "zh_CN", - OsArch: "x86_64", - }, - { - Name: "CentOS 8.2(arm64)", - OsDistro: "CentOS", - OsType: osprofile.OS_TYPE_LINUX, - OsVersion: "8.2", - OsLang: "", - OsArch: "aarch64", - }, - { - Name: "Ubuntu Server 22.04 LTS 64位", - OsDistro: "Ubuntu Server", - OsType: osprofile.OS_TYPE_LINUX, - OsVersion: "22.04", - OsLang: "", - OsArch: "x86_64", - }, - { - Name: "CentOS Stream 9 64位", - OsDistro: "CentOS Stream", - OsType: osprofile.OS_TYPE_LINUX, - OsVersion: "9", - OsLang: "", - OsArch: "x86_64", - }, - { - Name: "Debian 11.4 64位", - OsDistro: "Debian", - OsType: osprofile.OS_TYPE_LINUX, - OsVersion: "11.4", - OsLang: "", - OsArch: "x86_64", - }, - } - - for _, image := range images { - info := NormalizeImageInfo(image.Name, "", "", "", "") - if info.OsType != image.OsType { - t.Errorf("%s osType should be %s", image.Name, image.OsType) - } - if info.OsDistro != image.OsDistro { - t.Errorf("%s osDistro should be %s, but is %s", image.Name, image.OsDistro, info.OsDistro) - } - if info.OsVersion != image.OsVersion { - t.Errorf("%s osVersion should be %s, but is %s", image.Name, image.OsVersion, info.OsVersion) - } - if info.OsLang != image.OsLang { - t.Errorf("%s osLang should be %s, but is %s", image.Name, image.OsLang, info.OsLang) - } - if info.OsArch != image.OsArch { - t.Errorf("%s osArch should be %s, but is %s", image.Name, image.OsArch, info.OsArch) - } - } - -} diff --git a/pkg/util/influxdb/influxdb.go b/pkg/util/influxdb/influxdb.go index 5777524e2f..51d40b82f6 100644 --- a/pkg/util/influxdb/influxdb.go +++ b/pkg/util/influxdb/influxdb.go @@ -28,10 +28,10 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SInfluxdb struct { diff --git a/pkg/util/ipmitool/shell/boot.go b/pkg/util/ipmitool/shell/boot.go index 6d95873af9..f0cd920378 100644 --- a/pkg/util/ipmitool/shell/boot.go +++ b/pkg/util/ipmitool/shell/boot.go @@ -17,9 +17,10 @@ package shell import ( "fmt" + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/pkg/util/shellutils" + "yunion.io/x/onecloud/pkg/baremetal/utils/ipmitool" - "yunion.io/x/onecloud/pkg/util/printutils" - "yunion.io/x/onecloud/pkg/util/shellutils" ) func init() { diff --git a/pkg/util/ipmitool/shell/lan.go b/pkg/util/ipmitool/shell/lan.go index 3457a0fbb4..0724ef85ee 100644 --- a/pkg/util/ipmitool/shell/lan.go +++ b/pkg/util/ipmitool/shell/lan.go @@ -15,9 +15,10 @@ package shell import ( + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/pkg/util/shellutils" + "yunion.io/x/onecloud/pkg/baremetal/utils/ipmitool" - "yunion.io/x/onecloud/pkg/util/printutils" - "yunion.io/x/onecloud/pkg/util/shellutils" ) func init() { diff --git a/pkg/util/ipmitool/shell/shell.go b/pkg/util/ipmitool/shell/shell.go index cf0671bb00..222c24aab8 100644 --- a/pkg/util/ipmitool/shell/shell.go +++ b/pkg/util/ipmitool/shell/shell.go @@ -17,9 +17,10 @@ package shell import ( "fmt" + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/pkg/util/shellutils" + "yunion.io/x/onecloud/pkg/baremetal/utils/ipmitool" - "yunion.io/x/onecloud/pkg/util/printutils" - "yunion.io/x/onecloud/pkg/util/shellutils" ) type EmptyOptions struct{} diff --git a/pkg/util/ipmitool/shell/status.go b/pkg/util/ipmitool/shell/status.go index 1f1fe787fd..d5cd6f638b 100644 --- a/pkg/util/ipmitool/shell/status.go +++ b/pkg/util/ipmitool/shell/status.go @@ -17,8 +17,9 @@ package shell import ( "fmt" + "yunion.io/x/pkg/util/shellutils" + "yunion.io/x/onecloud/pkg/baremetal/utils/ipmitool" - "yunion.io/x/onecloud/pkg/util/shellutils" ) func init() { diff --git a/pkg/util/logclient/logclient.go b/pkg/util/logclient/logclient.go index cfa40fd9dc..99597593c4 100644 --- a/pkg/util/logclient/logclient.go +++ b/pkg/util/logclient/logclient.go @@ -22,13 +22,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/util/stringutils" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/logger" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/mcclient" diff --git a/pkg/util/multipart/doc.go b/pkg/util/multipart/doc.go deleted file mode 100644 index d6ac5a8ecb..0000000000 --- a/pkg/util/multipart/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// 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 multipart // import "yunion.io/x/onecloud/pkg/util/multipart" diff --git a/pkg/util/netutils2/netutils.go b/pkg/util/netutils2/netutils.go index 927b26073f..3b5aa47c75 100644 --- a/pkg/util/netutils2/netutils.go +++ b/pkg/util/netutils2/netutils.go @@ -33,7 +33,8 @@ import ( ) var PSEUDO_VIP = "169.254.169.231" -var MASKS = []string{"0", "128", "192", "224", "240", "248", "252", "254", "255"} + +// var MASKS = []string{"0", "128", "192", "224", "240", "248", "252", "254", "255"} var PRIVATE_PREFIXES = []string{ "10.0.0.0/8", @@ -42,16 +43,7 @@ var PRIVATE_PREFIXES = []string{ } func GetFreePort() (int, error) { - addr, err := net.ResolveTCPAddr("tcp", "localhost:0") - if err != nil { - return 0, err - } - l, err := net.ListenTCP("tcp", addr) - if err != nil { - return 0, err - } - defer l.Close() - return l.Addr().(*net.TCPAddr).Port, nil + return netutils.GetFreePort() } func IsTcpPortUsed(addr string, port int) bool { @@ -135,30 +127,7 @@ func GetMainNicFromDeployApi(nics []*types.SServerNic) (*types.SServerNic, error } func Netlen2Mask(netmasklen int) string { - var mask = "" - var segCnt = 0 - for netmasklen > 0 { - var m string - if netmasklen > 8 { - m = MASKS[8] - netmasklen -= 8 - } else { - m = MASKS[netmasklen] - netmasklen = 0 - } - if mask != "" { - mask += "." - } - mask += m - segCnt += 1 - } - for i := 0; i < (4 - segCnt); i++ { - if mask != "" { - mask += "." - } - mask += "0" - } - return mask + return netutils.Netlen2Mask(netmasklen) } func addRoute(routes *[][]string, net, gw string) { diff --git a/pkg/util/netutils2/netutils_test.go b/pkg/util/netutils2/netutils_test.go index de70e5baac..a2b1a046c7 100644 --- a/pkg/util/netutils2/netutils_test.go +++ b/pkg/util/netutils2/netutils_test.go @@ -20,40 +20,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/types" ) -func TestNetlen2Mask(t *testing.T) { - type args struct { - netmasklen int - } - tests := []struct { - name string - args args - want string - }{ - { - name: "mask 0", - args: args{0}, - want: "0.0.0.0", - }, - { - name: "mask 24", - args: args{24}, - want: "255.255.255.0", - }, - { - name: "mask 32", - args: args{32}, - want: "255.255.255.255", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := Netlen2Mask(tt.args.netmasklen); got != tt.want { - t.Errorf("Netlen2Mask() = %v, want %v", got, tt.want) - } - }) - } -} - func TestNetBytes2Mask(t *testing.T) { type args struct { mask []byte diff --git a/pkg/util/oidcutils/client/client.go b/pkg/util/oidcutils/client/client.go index d054b66359..7797f8b4d9 100644 --- a/pkg/util/oidcutils/client/client.go +++ b/pkg/util/oidcutils/client/client.go @@ -28,9 +28,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/oidcutils" ) diff --git a/pkg/util/pinyinutils/doc.go b/pkg/util/pinyinutils/doc.go deleted file mode 100644 index 56f8247b31..0000000000 --- a/pkg/util/pinyinutils/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// 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 pinyinutils // import "yunion.io/x/onecloud/pkg/util/pinyinutils" diff --git a/pkg/util/printutils/doc.go b/pkg/util/printutils/doc.go deleted file mode 100644 index 664a2fc636..0000000000 --- a/pkg/util/printutils/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// 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 printutils // import "yunion.io/x/onecloud/pkg/util/printutils" diff --git a/pkg/util/printutils/printjson_test.go b/pkg/util/printutils/printjson_test.go deleted file mode 100644 index ca864f9a34..0000000000 --- a/pkg/util/printutils/printjson_test.go +++ /dev/null @@ -1,68 +0,0 @@ -// 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 printutils - -import ( - "testing" - - "yunion.io/x/jsonutils" -) - -func TestPrintJSONObjectRecursive(t *testing.T) { - cases := []struct { - name string - in string - out string - }{ - { - name: "basic", - in: `{ - "k0": { - "k00": "v00", - "k01": [ - { - "k010": "v010", - "k011": "v011" - } - ] - } - }`, - out: `+---------------+-------+ -| Field | Value | -+---------------+-------+ -| k0.k00 | v00 | -| k0.k01.0.k010 | v010 | -| k0.k01.0.k011 | v011 | -+---------------+-------+ -`, - }, - } - for _, c := range cases { - t.Run(c.name, func(t *testing.T) { - j, err := jsonutils.ParseString(c.in) - if err != nil { - t.Fatalf("unexpected parse json error: %s", err) - } - PrintJSONObjectRecursiveEx(j, func(obj jsonutils.JSONObject) { - dict := obj.(*jsonutils.JSONDict) - printJSONObject(dict, func(s string) { - if s != c.out { - t.Errorf("want:\n%s\ngot:\n%s", c.out, s) - } - }) - }) - }) - } -} diff --git a/pkg/util/qemuimg/consts.go b/pkg/util/qemuimg/consts.go index 9b0b0bc0b6..ee9056c0b0 100644 --- a/pkg/util/qemuimg/consts.go +++ b/pkg/util/qemuimg/consts.go @@ -13,57 +13,3 @@ // limitations under the License. package qemuimg - -import ( - "strings" - // "yunion.io/x/log" -) - -type TImageFormat string - -const ( - QCOW2 = TImageFormat("qcow2") - VMDK = TImageFormat("vmdk") - VHD = TImageFormat("vhd") - ISO = TImageFormat("iso") - RAW = TImageFormat("raw") -) - -var supportedImageFormats = []TImageFormat{ - QCOW2, VMDK, VHD, ISO, RAW, -} - -func IsSupportedImageFormat(fmtStr string) bool { - for i := 0; i < len(supportedImageFormats); i += 1 { - if fmtStr == string(supportedImageFormats[i]) { - return true - } - } - return false -} - -func (fmt TImageFormat) String() string { - switch string(fmt) { - case "vhd": - return "vpc" - default: - return string(fmt) - } -} - -func String2ImageFormat(fmt string) TImageFormat { - switch strings.ToLower(fmt) { - case "vhd", "vpc": - return VHD - case "qcow2": - return QCOW2 - case "vmdk": - return VMDK - case "iso": - return ISO - case "raw": - return RAW - } - // log.Fatalf("unknown image format!!! %s", fmt) - return TImageFormat(fmt) -} diff --git a/pkg/util/qemuimg/init.go b/pkg/util/qemuimg/init.go index 457e87a915..a1830900af 100644 --- a/pkg/util/qemuimg/init.go +++ b/pkg/util/qemuimg/init.go @@ -19,10 +19,10 @@ import ( "regexp" "yunion.io/x/log" + "yunion.io/x/pkg/util/version" "yunion.io/x/onecloud/pkg/util/procutils" "yunion.io/x/onecloud/pkg/util/qemutils" - "yunion.io/x/onecloud/pkg/util/version" ) const ( diff --git a/pkg/util/qemuimg/qemuimg.go b/pkg/util/qemuimg/qemuimg.go index 7e94c49de9..565c453ebb 100644 --- a/pkg/util/qemuimg/qemuimg.go +++ b/pkg/util/qemuimg/qemuimg.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/pkg/utils" api "yunion.io/x/onecloud/pkg/apis/compute" @@ -50,7 +51,7 @@ const ( type SQemuImage struct { Path string Password string - Format TImageFormat + Format qemuimgfmt.TImageFormat SizeBytes int64 ActualSizeBytes int64 ClusterSize int @@ -190,7 +191,7 @@ func (img *SQemuImage) parse() error { if err != nil { return errors.Wrapf(err, "resp.Unmarshal") } - img.Format = TImageFormat(info.Format) + img.Format = qemuimgfmt.TImageFormat(info.Format) img.SizeBytes = info.VirtualSizeBytes img.ClusterSize = info.ClusterSize img.Compat = info.FormatSpecific.Data.Compat @@ -209,11 +210,11 @@ func (img *SQemuImage) parse() error { img.EncryptAlg = seclib2.TSymEncAlg(info.FormatSpecific.Data.Encrypt.CipherAlg) } - if img.Format == RAW && fileutils2.IsFile(img.Path) { + if img.Format == qemuimgfmt.RAW && fileutils2.IsFile(img.Path) { // test if it is an ISO blkType := fileutils2.GetBlkidType(img.Path) if utils.IsInStringArray(blkType, []string{"iso9660", "udf"}) { - img.Format = ISO + img.Format = qemuimgfmt.ISO } } return nil @@ -240,7 +241,7 @@ const ( type SImageInfo struct { Path string - Format TImageFormat + Format qemuimgfmt.TImageFormat IoLevel TIONiceLevel Password string @@ -259,7 +260,7 @@ func (info SImageInfo) ImageOptions() string { opts := make([]string, 0) format := info.Format if len(format) == 0 { - format = QCOW2 + format = qemuimgfmt.QCOW2 } opts = append(opts, fmt.Sprintf("driver=%s", format)) opts = append(opts, fmt.Sprintf("file.filename=%s", info.Path)) @@ -371,12 +372,12 @@ func convertEncrypt(srcInfo, destInfo SImageInfo, compact bool, workerOpions []s cmdline = append(cmdline, workerOpions...) } if srcInfo.Encrypted() { - if srcInfo.Format != QCOW2 { + if srcInfo.Format != qemuimgfmt.QCOW2 { return errors.Wrap(errors.ErrNotSupported, "source image not support encryption") } } if destInfo.Encrypted() { - if destInfo.Format != QCOW2 { + if destInfo.Format != qemuimgfmt.QCOW2 { return errors.Wrap(errors.ErrNotSupported, "target image not support encryption") } } @@ -413,7 +414,7 @@ func convertEncrypt(srcInfo, destInfo SImageInfo, compact bool, workerOpions []s return nil } -func (img *SQemuImage) doConvert(targetPath string, format TImageFormat, compact bool, password string, encryptFormat TEncryptFormat, encryptAlg seclib2.TSymEncAlg) error { +func (img *SQemuImage) doConvert(targetPath string, format qemuimgfmt.TImageFormat, compact bool, password string, encryptFormat TEncryptFormat, encryptAlg seclib2.TSymEncAlg) error { if !img.IsValid() { return fmt.Errorf("self is not valid") } @@ -435,22 +436,22 @@ func (img *SQemuImage) doConvert(targetPath string, format TImageFormat, compact }, compact, nil) } -func (img *SQemuImage) Clone(name string, format TImageFormat, compact bool) (*SQemuImage, error) { +func (img *SQemuImage) Clone(name string, format qemuimgfmt.TImageFormat, compact bool) (*SQemuImage, error) { switch format { - case QCOW2: + case qemuimgfmt.QCOW2: return img.CloneQcow2(name, compact) - case VMDK: + case qemuimgfmt.VMDK: return img.CloneVmdk(name, compact) - case RAW: + case qemuimgfmt.RAW: return img.CloneRaw(name) - case VHD: + case qemuimgfmt.VHD: return img.CloneVhd(name) default: return nil, ErrUnsupportedFormat } } -func (img *SQemuImage) clone(target string, format TImageFormat, compact bool, password string, encryptFormat TEncryptFormat, encryptAlg seclib2.TSymEncAlg) (*SQemuImage, error) { +func (img *SQemuImage) clone(target string, format qemuimgfmt.TImageFormat, compact bool, password string, encryptFormat TEncryptFormat, encryptAlg seclib2.TSymEncAlg) (*SQemuImage, error) { err := img.doConvert(target, format, compact, password, encryptFormat, encryptAlg) if err != nil { return nil, errors.Wrap(err, "doConvert") @@ -458,7 +459,7 @@ func (img *SQemuImage) clone(target string, format TImageFormat, compact bool, p return NewQemuImage(target) } -func (img *SQemuImage) convert(format TImageFormat, compact bool, password string, encryptFormat TEncryptFormat, alg seclib2.TSymEncAlg) error { +func (img *SQemuImage) convert(format qemuimgfmt.TImageFormat, compact bool, password string, encryptFormat TEncryptFormat, alg seclib2.TSymEncAlg) error { tmpPath := fmt.Sprintf("%s.%s", img.Path, utils.GenRequestId(36)) err := img.doConvert(tmpPath, format, compact, password, encryptFormat, alg) if err != nil { @@ -477,7 +478,7 @@ func (img *SQemuImage) convert(format TImageFormat, compact bool, password strin } func (img *SQemuImage) convertTo( - format TImageFormat, compact bool, password string, output string, encFormat TEncryptFormat, encAlg seclib2.TSymEncAlg, + format qemuimgfmt.TImageFormat, compact bool, password string, output string, encFormat TEncryptFormat, encAlg seclib2.TSymEncAlg, ) error { err := img.doConvert(output, format, compact, password, encFormat, encAlg) if err != nil { @@ -506,7 +507,7 @@ func (img *SQemuImage) Copy(name string) (*SQemuImage, error) { } func (img *SQemuImage) Convert2Qcow2To(output string, compact bool, password string, encFormat TEncryptFormat, encAlg seclib2.TSymEncAlg) error { - return img.convertTo(QCOW2, compact, password, output, encFormat, encAlg) + return img.convertTo(qemuimgfmt.QCOW2, compact, password, output, encFormat, encAlg) } func (img *SQemuImage) Convert2Qcow2(compact bool, password string, encFormat TEncryptFormat, encAlg seclib2.TSymEncAlg) error { @@ -515,31 +516,31 @@ func (img *SQemuImage) Convert2Qcow2(compact bool, password string, encFormat TE encFormat = img.EncryptFormat encAlg = img.EncryptAlg } - return img.convert(QCOW2, compact, password, encFormat, encAlg) + return img.convert(qemuimgfmt.QCOW2, compact, password, encFormat, encAlg) } func (img *SQemuImage) Convert2Vmdk(compact bool) error { - return img.convert(VMDK, compact, "", "", "") + return img.convert(qemuimgfmt.VMDK, compact, "", "", "") } func (img *SQemuImage) Convert2Vhd() error { - return img.convert(VHD, false, "", "", "") + return img.convert(qemuimgfmt.VHD, false, "", "", "") } func (img *SQemuImage) Convert2Raw() error { - return img.convert(RAW, false, "", "", "") + return img.convert(qemuimgfmt.RAW, false, "", "", "") } func (img *SQemuImage) IsRaw() bool { - return img.Format == RAW + return img.Format == qemuimgfmt.RAW } func (img *SQemuImage) IsSparseQcow2() bool { - return img.Format == QCOW2 && img.ClusterSize >= 1024*1024*2 + return img.Format == qemuimgfmt.QCOW2 && img.ClusterSize >= 1024*1024*2 } func (img *SQemuImage) IsSparseVmdk() bool { - return img.Format == VMDK && img.Subformat != "streamOptimized" + return img.Format == qemuimgfmt.VMDK && img.Subformat != "streamOptimized" } func (img *SQemuImage) IsSparse() bool { @@ -554,7 +555,7 @@ func (img *SQemuImage) Expand() error { } func (img *SQemuImage) CloneQcow2(name string, compact bool) (*SQemuImage, error) { - return img.clone(name, QCOW2, compact, img.Password, img.EncryptFormat, img.EncryptAlg) + return img.clone(name, qemuimgfmt.QCOW2, compact, img.Password, img.EncryptFormat, img.EncryptAlg) } func vmdkOptions(compact bool) []string { @@ -574,18 +575,18 @@ func vmdkOptions(compact bool) []string { // } func (img *SQemuImage) CloneVmdk(name string, compact bool) (*SQemuImage, error) { - return img.clone(name, VMDK, compact, "", "", "") + return img.clone(name, qemuimgfmt.VMDK, compact, "", "", "") } func (img *SQemuImage) CloneVhd(name string) (*SQemuImage, error) { - return img.clone(name, VHD, false, "", "", "") + return img.clone(name, qemuimgfmt.VHD, false, "", "", "") } func (img *SQemuImage) CloneRaw(name string) (*SQemuImage, error) { - return img.clone(name, RAW, false, "", "", "") + return img.clone(name, qemuimgfmt.RAW, false, "", "", "") } -func (img *SQemuImage) create(sizeMB int, format TImageFormat, options []string, extraArgs []string) error { +func (img *SQemuImage) create(sizeMB int, format qemuimgfmt.TImageFormat, options []string, extraArgs []string) error { if img.IsValid() { return fmt.Errorf("create: the image is valid??? %s", img.Format) } @@ -683,19 +684,19 @@ func (img *SQemuImage) CreateQcow2(sizeMB int, compact bool, backPath string, pa options = append(options, fmt.Sprintf("encrypt.cipher-alg=%s", encAlg)) } } - return img.create(sizeMB, QCOW2, options, extraArgs) + return img.create(sizeMB, qemuimgfmt.QCOW2, options, extraArgs) } func (img *SQemuImage) CreateVmdk(sizeMB int, compact bool) error { - return img.create(sizeMB, VMDK, vmdkOptions(compact), nil) + return img.create(sizeMB, qemuimgfmt.VMDK, vmdkOptions(compact), nil) } func (img *SQemuImage) CreateVhd(sizeMB int) error { - return img.create(sizeMB, VHD, nil, nil) + return img.create(sizeMB, qemuimgfmt.VHD, nil, nil) } func (img *SQemuImage) CreateRaw(sizeMB int) error { - return img.create(sizeMB, RAW, nil, nil) + return img.create(sizeMB, qemuimgfmt.RAW, nil, nil) } func (img *SQemuImage) GetSizeMB() int { diff --git a/pkg/util/qemutils/qemutils.go b/pkg/util/qemutils/qemutils.go index dff78d4f6c..4ed5792ccb 100644 --- a/pkg/util/qemutils/qemutils.go +++ b/pkg/util/qemutils/qemutils.go @@ -22,9 +22,9 @@ import ( "strings" "yunion.io/x/log" + "yunion.io/x/pkg/util/version" "yunion.io/x/onecloud/pkg/util/procutils" - "yunion.io/x/onecloud/pkg/util/version" ) const ( diff --git a/pkg/util/rand/rand_test.go b/pkg/util/rand/rand_test.go deleted file mode 100644 index 9676f2dddf..0000000000 --- a/pkg/util/rand/rand_test.go +++ /dev/null @@ -1,128 +0,0 @@ -// 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. - -/* -Copyright 2015 The Kubernetes Authors. - -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 rand - -import ( - "math/rand" - "strings" - "testing" -) - -const ( - maxRangeTestCount = 500 - testStringLength = 32 -) - -func TestString(t *testing.T) { - valid := "0123456789abcdefghijklmnopqrstuvwxyz" - for _, l := range []int{0, 1, 2, 10, 123} { - s := String(l) - if len(s) != l { - t.Errorf("expected string of size %d, got %q", l, s) - } - for _, c := range s { - if !strings.ContainsRune(valid, c) { - t.Errorf("expected valid characters, got %v", c) - } - } - } -} - -// Confirm that panic occurs on invalid input. -func TestRangePanic(t *testing.T) { - defer func() { - if err := recover(); err == nil { - t.Errorf("Panic didn't occur!") - } - }() - // Should result in an error... - Intn(0) -} - -func TestIntn(t *testing.T) { - // 0 is invalid. - for _, max := range []int{1, 2, 10, 123} { - inrange := Intn(max) - if inrange < 0 || inrange > max { - t.Errorf("%v out of range (0,%v)", inrange, max) - } - } -} - -func TestPerm(t *testing.T) { - Seed(5) - rand.Seed(5) - for i := 1; i < 20; i++ { - actual := Perm(i) - expected := rand.Perm(i) - for j := 0; j < i; j++ { - if actual[j] != expected[j] { - t.Errorf("Perm call result is unexpected") - } - } - } -} - -func TestIntnRange(t *testing.T) { - // 0 is invalid. - for min, max := range map[int]int{1: 2, 10: 123, 100: 500} { - for i := 0; i < maxRangeTestCount; i++ { - inrange := IntnRange(min, max) - if inrange < min || inrange >= max { - t.Errorf("%v out of range (%v,%v)", inrange, min, max) - } - } - } -} - -func TestInt63nRange(t *testing.T) { - // 0 is invalid. - for min, max := range map[int64]int64{1: 2, 10: 123, 100: 500} { - for i := 0; i < maxRangeTestCount; i++ { - inrange := Int63nRange(min, max) - if inrange < min || inrange >= max { - t.Errorf("%v out of range (%v,%v)", inrange, min, max) - } - } - } -} - -func BenchmarkRandomStringGeneration(b *testing.B) { - b.ResetTimer() - var s string - for i := 0; i < b.N; i++ { - s = String(testStringLength) - } - b.StopTimer() - if len(s) == 0 { - b.Fatal(s) - } -} diff --git a/pkg/util/rbacutils/policy.go b/pkg/util/rbacutils/policy.go index 223e1f908d..1a5559f8a8 100644 --- a/pkg/util/rbacutils/policy.go +++ b/pkg/util/rbacutils/policy.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" ) type SRbacPolicy struct { @@ -31,7 +32,7 @@ type SRbacPolicy struct { IsPublic bool - PublicScope TRbacScope + PublicScope rbacscope.TRbacScope SharedDomainIds []string @@ -44,7 +45,7 @@ type SRbacPolicy struct { Auth bool // whether needs authentication // scope, the scope of the policy, system/domain/project - Scope TRbacScope + Scope rbacscope.TRbacScope // Deprecated // is_admin=true means scope=system, is_admin=false means scope=project IsAdmin bool @@ -118,14 +119,14 @@ func (policy *SRbacPolicy) Decode(policyJson jsonutils.JSONObject) error { scopeStr, _ := policyJson.GetString("scope") if len(scopeStr) > 0 { - policy.Scope = TRbacScope(scopeStr) + policy.Scope = rbacscope.TRbacScope(scopeStr) } else { policy.IsAdmin = jsonutils.QueryBoolean(policyJson, "is_admin", false) if len(policy.Scope) == 0 { if policy.IsAdmin { - policy.Scope = ScopeSystem + policy.Scope = rbacscope.ScopeSystem } else { - policy.Scope = ScopeProject + policy.Scope = rbacscope.ScopeProject } } } @@ -173,7 +174,7 @@ func (policy *SRbacPolicy) Encode() jsonutils.JSONObject { } func (policy *SRbacPolicy) IsSystemWidePolicy() bool { - return (len(policy.DomainId) == 0 || (policy.IsPublic && policy.PublicScope == ScopeSystem)) && len(policy.Roles) == 0 && len(policy.Projects) == 0 + return (len(policy.DomainId) == 0 || (policy.IsPublic && policy.PublicScope == rbacscope.ScopeSystem)) && len(policy.Roles) == 0 && len(policy.Projects) == 0 } func (policy *SRbacPolicy) MatchDomain(domainId string) bool { @@ -184,7 +185,7 @@ func (policy *SRbacPolicy) MatchDomain(domainId string) bool { return true } if policy.IsPublic { - if policy.PublicScope == ScopeSystem { + if policy.PublicScope == rbacscope.ScopeSystem { return true } if contains(policy.SharedDomainIds, domainId) { diff --git a/pkg/util/rbacutils/policygroup.go b/pkg/util/rbacutils/policygroup.go index 8e50630246..046f267aae 100644 --- a/pkg/util/rbacutils/policygroup.go +++ b/pkg/util/rbacutils/policygroup.go @@ -17,11 +17,12 @@ package rbacutils import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/onecloud/pkg/httperrors" ) -type TPolicyGroup map[TRbacScope]TPolicySet +type TPolicyGroup map[rbacscope.TRbacScope]TPolicySet func DecodePolicyGroup(json jsonutils.JSONObject) (TPolicyGroup, error) { jmap, err := json.GetMap() @@ -30,7 +31,7 @@ func DecodePolicyGroup(json jsonutils.JSONObject) (TPolicyGroup, error) { } group := TPolicyGroup{} for k := range jmap { - scope := TRbacScope(k) + scope := rbacscope.TRbacScope(k) group[scope], err = DecodePolicySet(jmap[k]) if err != nil { return nil, errors.Wrapf(err, "decode %s", k) @@ -39,18 +40,18 @@ func DecodePolicyGroup(json jsonutils.JSONObject) (TPolicyGroup, error) { return group, nil } -func (sets TPolicyGroup) HighestScope() TRbacScope { - for _, s := range []TRbacScope{ - ScopeSystem, - ScopeDomain, - ScopeProject, - ScopeUser, +func (sets TPolicyGroup) HighestScope() rbacscope.TRbacScope { + for _, s := range []rbacscope.TRbacScope{ + rbacscope.ScopeSystem, + rbacscope.ScopeDomain, + rbacscope.ScopeProject, + rbacscope.ScopeUser, } { if _, ok := sets[s]; ok { return s } } - return ScopeNone + return rbacscope.ScopeNone } func (sets TPolicyGroup) Encode() jsonutils.JSONObject { diff --git a/pkg/util/rbacutils/rbac.go b/pkg/util/rbacutils/rbac.go index b39439f57d..a39d3b47f0 100644 --- a/pkg/util/rbacutils/rbac.go +++ b/pkg/util/rbacutils/rbac.go @@ -15,14 +15,11 @@ package rbacutils import ( - "strings" - "yunion.io/x/log" "yunion.io/x/pkg/util/netutils" ) type TRbacResult string -type TRbacScope string const ( WILD_MATCH = "*" @@ -37,12 +34,12 @@ const ( UserAllow = TRbacResult("user") // deprecated GuestAllow = TRbacResult("guest") // deprecated - ScopeSystem = TRbacScope("system") - ScopeDomain = TRbacScope("domain") - ScopeProject = TRbacScope("project") + /*ScopeSystem = rbacscope.ScopeSystem + ScopeDomain = rbacscope.ScopeDomain + ScopeProject = rbacscope.ScopeProject // ScopeObject = "object" - ScopeUser = TRbacScope("user") - ScopeNone = TRbacScope("none") + ScopeUser = rbacscope.ScopeUser + ScopeNone = rbacscope.ScopeNone*/ ) func (r TRbacResult) IsAllow() bool { @@ -62,14 +59,6 @@ var ( GuestAllow: 4, Allow: 5, } - - scopeScore = map[TRbacScope]int{ - ScopeNone: 0, - ScopeUser: 1, - ScopeProject: 2, - ScopeDomain: 3, - ScopeSystem: 4, - } ) func (r TRbacResult) Strictness() int { @@ -84,14 +73,6 @@ func (r1 TRbacResult) LooserThan(r2 TRbacResult) bool { return r1.Strictness() > r2.Strictness() } -func (s1 TRbacScope) HigherEqual(s2 TRbacScope) bool { - return scopeScore[s1] >= scopeScore[s2] -} - -func (s1 TRbacScope) HigherThan(s2 TRbacScope) bool { - return scopeScore[s1] > scopeScore[s2] -} - type SRbacRule struct { Service string Resource string @@ -336,24 +317,3 @@ func NewRbacIdentity(projectId string, roleIds []string, ip string) IRbacIdentit ip: ip, } } - -func String2Scope(str string) TRbacScope { - return String2ScopeDefault(str, ScopeProject) -} - -func String2ScopeDefault(str string, defScope TRbacScope) TRbacScope { - switch strings.ToLower(str) { - case string(ScopeSystem): - return ScopeSystem - case string(ScopeDomain): - return ScopeDomain - case string(ScopeProject): - return ScopeProject - case string(ScopeUser): - return ScopeUser - case "true": - return ScopeSystem - default: - return defScope - } -} diff --git a/pkg/util/redfish/bmconsole/bmconsole.go b/pkg/util/redfish/bmconsole/bmconsole.go index 721f57927c..1ab332b23f 100644 --- a/pkg/util/redfish/bmconsole/bmconsole.go +++ b/pkg/util/redfish/bmconsole/bmconsole.go @@ -22,8 +22,7 @@ import ( "strings" "yunion.io/x/pkg/errors" - - "yunion.io/x/onecloud/pkg/util/httputils" + "yunion.io/x/pkg/util/httputils" ) type SBMCConsole struct { diff --git a/pkg/util/redfish/bmconsole/idrac.go b/pkg/util/redfish/bmconsole/idrac.go index 6eee7060bb..f7ded62bab 100644 --- a/pkg/util/redfish/bmconsole/idrac.go +++ b/pkg/util/redfish/bmconsole/idrac.go @@ -25,9 +25,9 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/httputils" ) func (r *SBMCConsole) GetIdracConsoleJNLP(ctx context.Context, sku, model string) (string, error) { diff --git a/pkg/util/redfish/bmconsole/idrac6.go b/pkg/util/redfish/bmconsole/idrac6.go index fba88e2d5d..8daadd9ebb 100644 --- a/pkg/util/redfish/bmconsole/idrac6.go +++ b/pkg/util/redfish/bmconsole/idrac6.go @@ -25,9 +25,9 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/httputils" ) func (r *SBMCConsole) GetIdrac6ConsoleJNLP(ctx context.Context, sku, model string) (string, error) { diff --git a/pkg/util/redfish/bmconsole/idrac9.go b/pkg/util/redfish/bmconsole/idrac9.go index cd90b88154..56e16d6d4c 100644 --- a/pkg/util/redfish/bmconsole/idrac9.go +++ b/pkg/util/redfish/bmconsole/idrac9.go @@ -20,8 +20,7 @@ import ( "strings" "yunion.io/x/pkg/errors" - - "yunion.io/x/onecloud/pkg/util/httputils" + "yunion.io/x/pkg/util/httputils" ) const ( diff --git a/pkg/util/redfish/bmconsole/ilo.go b/pkg/util/redfish/bmconsole/ilo.go index 550407ccf5..f0f985bf43 100644 --- a/pkg/util/redfish/bmconsole/ilo.go +++ b/pkg/util/redfish/bmconsole/ilo.go @@ -23,8 +23,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" - - "yunion.io/x/onecloud/pkg/util/httputils" + "yunion.io/x/pkg/util/httputils" ) func (r *SBMCConsole) GetIloConsoleJNLP(ctx context.Context) (string, error) { diff --git a/pkg/util/redfish/bmconsole/lenovo.go b/pkg/util/redfish/bmconsole/lenovo.go index 974f7b8920..eb4ab2c148 100644 --- a/pkg/util/redfish/bmconsole/lenovo.go +++ b/pkg/util/redfish/bmconsole/lenovo.go @@ -24,9 +24,9 @@ import ( "time" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/httputils" ) func (r *SBMCConsole) GetLenovoConsoleJNLP(ctx context.Context) (string, error) { diff --git a/pkg/util/redfish/bmconsole/supermicro.go b/pkg/util/redfish/bmconsole/supermicro.go index 4c64acdd2f..e1b33496c4 100644 --- a/pkg/util/redfish/bmconsole/supermicro.go +++ b/pkg/util/redfish/bmconsole/supermicro.go @@ -22,8 +22,7 @@ import ( "strings" "yunion.io/x/pkg/errors" - - "yunion.io/x/onecloud/pkg/util/httputils" + "yunion.io/x/pkg/util/httputils" ) func (r *SBMCConsole) GetSupermicroConsoleJNLP(ctx context.Context) (string, error) { diff --git a/pkg/util/redfish/idrac/idrac.go b/pkg/util/redfish/idrac/idrac.go index 993711fcc4..7d03c81af6 100644 --- a/pkg/util/redfish/idrac/idrac.go +++ b/pkg/util/redfish/idrac/idrac.go @@ -23,9 +23,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/redfish" "yunion.io/x/onecloud/pkg/util/redfish/bmconsole" "yunion.io/x/onecloud/pkg/util/redfish/generic" diff --git a/pkg/util/redfish/ilo/ilo.go b/pkg/util/redfish/ilo/ilo.go index fda939a7e5..d2807087b1 100644 --- a/pkg/util/redfish/ilo/ilo.go +++ b/pkg/util/redfish/ilo/ilo.go @@ -22,8 +22,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/redfish" "yunion.io/x/onecloud/pkg/util/redfish/bmconsole" "yunion.io/x/onecloud/pkg/util/redfish/generic" diff --git a/pkg/util/redfish/redfish.go b/pkg/util/redfish/redfish.go index 9ec76f24b5..b52961f196 100644 --- a/pkg/util/redfish/redfish.go +++ b/pkg/util/redfish/redfish.go @@ -27,13 +27,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/object" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/netutils" "yunion.io/x/pkg/utils" - "yunion.io/x/onecloud/pkg/cloudcommon/object" "yunion.io/x/onecloud/pkg/cloudcommon/types" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/httputils" ) var redfishBasePaths = []string{ diff --git a/pkg/util/redfish/supermicro/supermicro.go b/pkg/util/redfish/supermicro/supermicro.go index f98d9852ce..66db19776e 100644 --- a/pkg/util/redfish/supermicro/supermicro.go +++ b/pkg/util/redfish/supermicro/supermicro.go @@ -21,9 +21,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/redfish" "yunion.io/x/onecloud/pkg/util/redfish/bmconsole" "yunion.io/x/onecloud/pkg/util/redfish/generic" diff --git a/pkg/util/s3auth/v4_test.go b/pkg/util/s3auth/v4_test.go deleted file mode 100644 index b378559872..0000000000 --- a/pkg/util/s3auth/v4_test.go +++ /dev/null @@ -1,68 +0,0 @@ -// 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 s3auth - -import ( - "io" - "net/http" - "strings" - "testing" -) - -func TestSignV4(t *testing.T) { - getReq, _ := http.NewRequest(http.MethodGet, "https://api.aliyun-cs.com/2018-06-23/DescribeInstances?limit=10&offset=0", nil) - putBody := "<123>" - putReq, _ := http.NewRequest(http.MethodPut, "https://api.aliyun-cs.com/2018-06-23/ModifyInstance?InstanceId=aabbccdd", strings.NewReader(putBody)) - - cases := []struct { - request http.Request - accessKey string - secret string - location string - body io.Reader - }{ - { - request: *getReq, - accessKey: "1234567890", - secret: "1234567890", - location: "cn-beijing", - body: nil, - }, - { - request: *putReq, - accessKey: "1234567890", - secret: "1234567890", - location: "cn-beijing", - body: strings.NewReader(putBody), - }, - } - - for _, c := range cases { - newreq := SignV4(c.request, c.accessKey, c.secret, c.location, c.body) - t.Logf("%#v", newreq) - - req, err := DecodeAccessKeyRequest(*newreq, false) - if err != nil { - t.Errorf("DecodeAccessKeyRequest fail %s", err) - continue - } - - err = req.Verify(c.secret) - if err != nil { - t.Errorf("verify fail %s", err) - } - } - -} diff --git a/pkg/util/samlutils/demo/service.go b/pkg/util/samlutils/demo/service.go index ae0fdfe8ec..ece88e8132 100644 --- a/pkg/util/samlutils/demo/service.go +++ b/pkg/util/samlutils/demo/service.go @@ -25,14 +25,14 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/samlutils" "yunion.io/x/structarg" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/i18n" "yunion.io/x/onecloud/pkg/util/fileutils2" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/util/samlutils/idp" "yunion.io/x/onecloud/pkg/util/samlutils/sp" ) diff --git a/pkg/util/samlutils/doc.go b/pkg/util/samlutils/doc.go deleted file mode 100644 index 5e131aa2cb..0000000000 --- a/pkg/util/samlutils/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// 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 samlutils // import "yunion.io/x/onecloud/pkg/util/samlutils" diff --git a/pkg/util/samlutils/idp/idp.go b/pkg/util/samlutils/idp/idp.go index e56c262527..a817c73b6c 100644 --- a/pkg/util/samlutils/idp/idp.go +++ b/pkg/util/samlutils/idp/idp.go @@ -23,14 +23,14 @@ import ( "strings" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/samlutils" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/i18n" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/samlutils" ) const ( diff --git a/pkg/util/samlutils/idp/sp.go b/pkg/util/samlutils/idp/sp.go index faf01120c2..5067922d2d 100644 --- a/pkg/util/samlutils/idp/sp.go +++ b/pkg/util/samlutils/idp/sp.go @@ -16,9 +16,9 @@ package idp import ( "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/samlutils" ) type SSAMLServiceProvider struct { diff --git a/pkg/util/samlutils/metadata_test.go b/pkg/util/samlutils/metadata_test.go deleted file mode 100644 index 54e07799e6..0000000000 --- a/pkg/util/samlutils/metadata_test.go +++ /dev/null @@ -1,670 +0,0 @@ -// 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 samlutils - -import ( - "encoding/xml" - "testing" -) - -var ( - spMetadata1 = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SAMLtest SP - A free and basic SP for testing SAML deployments - https://samltest.id/saml/logo.png - - - - - - - - -MIIERTCCAq2gAwIBAgIJAKmtzjCD1+tqMA0GCSqGSIb3DQEBCwUAMDUxMzAxBgNV -BAMTKmlwLTE3Mi0zMS0yOC02NC51cy13ZXN0LTIuY29tcHV0ZS5pbnRlcm5hbDAe -Fw0xODA4MTgyMzI0MjNaFw0yODA4MTUyMzI0MjNaMDUxMzAxBgNVBAMTKmlwLTE3 -Mi0zMS0yOC02NC51cy13ZXN0LTIuY29tcHV0ZS5pbnRlcm5hbDCCAaIwDQYJKoZI -hvcNAQEBBQADggGPADCCAYoCggGBALhUlY3SkIOze+l8y6dBzM6p7B8OykJWlwiz -szU16Lih8D7KLhNJfahoVxbPxB3YFM/81PJLOeK2krvJ5zY6CJyQY3sPQAkZKI7I -8qq9lmZ2g4QPqybNstXS6YUXJNUt/ixbbK/N97+LKTiSutbD1J7AoFnouMuLjlhN -5VRZ43jez4xLSHVZaYuUFKn01Y9oLKbj46LQnZnJCAGpTgPqEQJr6GpVGw43bKyU -pGoaPrdDRgRgtPMUWgFDkgcI3QiV1lsKfBs1t1E2UA7ACFnlJZpEuBtwgivzo3Ve -itiSaF3Jxh25EY5/vABpcgQQRz3RH2l8MMKdRsxb8VT3yh2S+CX55s+cN67LiCPr -6f2u+KS1iKfB9mWN6o2S4lcmo82HIBbsuXJV0oA1HrGMyyc4Y9nng/I8iuAp8or1 -JrWRHQ+8NzO85DWK0rtvtLPxkvw0HK32glyuOP/9F05Z7+tiVIgn67buC0EdoUm1 -RSpibqmB1ST2PikslOlVbJuy4Ah93wIDAQABo1gwVjA1BgNVHREELjAsgippcC0x -NzItMzEtMjgtNjQudXMtd2VzdC0yLmNvbXB1dGUuaW50ZXJuYWwwHQYDVR0OBBYE -FAdsTxYfulJ5yunYtgYJHC9IcevzMA0GCSqGSIb3DQEBCwUAA4IBgQB3J6i7Krei -HL8NPMglfWLHk1PZOgvIEEpKL+GRebvcbyqgcuc3VVPylq70VvGqhJxp1q/mzLfr -aUiypzfWFGm9zfwIg0H5TqRZYEPTvgIhIICjaDWRwZBDJG8D5G/KoV60DlUG0crP -BlIuCCr/SRa5ZoDQqvucTfr3Rx4Ha6koXFSjoSXllR+jn4GnInhm/WH137a+v35P -UcffNxfuehoGn6i4YeXF3cwJK4e35cOFW+dLbnaLk+Ty7HOGvpw86h979C6mJ9qE -HYgq9rQyzlSPbLZGZSgVcIezunOaOsWm81BsXRNNJjzHGCqKf8RMhd8oZP55+2/S -VRBwnkGyUNCuDPrJcymC95ZT2NW/KeWkz28HF2i31xQmecT2r3lQRSM8acvOXQsN -EDCDvJvCzJT9c2AnsnO24r6arPXs/UWAxOI+MjclXPLkLD6uTHV+Oo8XZ7bOjegD -5hL6/bKUWnNMurQNGrmi/jvqsCFLDKftl7ajuxKjtodnSuwhoY7NQy8= - - - - - - - - - -MIIERTCCAq2gAwIBAgIJAKGA/tV7hXUvMA0GCSqGSIb3DQEBCwUAMDUxMzAxBgNV -BAMTKmlwLTE3Mi0zMS0yOC02NC51cy13ZXN0LTIuY29tcHV0ZS5pbnRlcm5hbDAe -Fw0xODA4MTgyMzI0MjVaFw0yODA4MTUyMzI0MjVaMDUxMzAxBgNVBAMTKmlwLTE3 -Mi0zMS0yOC02NC51cy13ZXN0LTIuY29tcHV0ZS5pbnRlcm5hbDCCAaIwDQYJKoZI -hvcNAQEBBQADggGPADCCAYoCggGBANoi7TtbPz5DD5b+pGj2bWHUWcOm135Dl+kf -KWcJV6x4Z4VRMa33nwSfFg6U0DhPaA6rYr8BfcmCIY4V4cGlJkLNsYbgbZNnrLh2 -3mj7jkaUeyv/DlGtLBcqr0gP6eDtcOf3MMGAkhROcicMj6i+uF6hqLDh4eNcpqEV -DVn+ADBsosIPiAx+RkcyZkfAF3UeGEV5WTSiQw7qYpI7x+c4ViiBzV4waBgXjvNN -72Dqlc01AylpmMKaUPfxIpPC+Ctr0bHu5xn7NxMS8Zt5NDWsP9T15qrpYatW68sX -VyE5nJRYpiRiRbo8i7QpUEya+TkXEI8PVD3KBw9UwhqL8qPPe0T+EeaawF6BVRTE -Pc+Mn4lGBr4cCFcGk/PLHeyksgPdjNmO1g7y5TWQzu21WzkXRTWJq7wGwWeW6Nrc -NqweYPLbXEo0JlmHqunkUs+NsLQAFqSPX02P2xzkA/eOU2o/jN4jAPNpzqxJouvm -iWGXl8Qy4U7vQZ0tGvlTDSltATOQ/QIDAQABo1gwVjA1BgNVHREELjAsgippcC0x -NzItMzEtMjgtNjQudXMtd2VzdC0yLmNvbXB1dGUuaW50ZXJuYWwwHQYDVR0OBBYE -FBBtS9YNKSIwViH37GJCTxjNBzLAMA0GCSqGSIb3DQEBCwUAA4IBgQDWXcaI7zMn -hGsLVTUA6dgzZCa88QkN/Z6n7lCY2oaKj1neBAWA1Mxg7GBJsmLOrHN8ie0D/uKA -F+7NqKCXYqd0PpTX7c1NICL92DvbugG/Ow50j5Dw6rU4Y8dPS7Y/T1ddbT2F9/5l -HCIWP/O2E9HREJ0JAIbu/Mi0CE1qui2aSJMDWKuiGK63M/7fvP51m6xSJOfZBhmj -gllIwEhIzfh4hVPhH0C7iqVls34UyLCZ8IZOCuGPJyTaJN6Pi3Uo1Otkz/1igN5M -pQhVaeYG7SMgha6skTLrVXTt4CuMVsOZ6cG3kHqw8XZoRld+I50iyHqansf5qwzm -NoPeXyjGRFQzV/EH3SUu8eAISTt9pfirwjKsVNHrmMRnQEB/hJYYbTWSsvdS8ghw -7a/A0EKQPVaZGCP/hcpt9JMMb66y2L8VgBbb6aTsR+Uabf6aiMnj1UBMUz9yaMka -kKM7e66uHdXUDZ/s8F5rPOGCK+O8O6EsLRf8XetRWLa1TXRDkJZVPX4= - - - - - - - - - - - - - - - - - - - - - - - - - - - - -` - - idpMetadata = ` - - - - - - samltest.id - - - - SAMLtest IdP - A free and basic IdP for testing SAML deployments - https://samltest.id/saml/logo.png - - - - - - - -MIIDETCCAfmgAwIBAgIUZRpDhkNKl5eWtJqk0Bu1BgTTargwDQYJKoZIhvcNAQEL -BQAwFjEUMBIGA1UEAwwLc2FtbHRlc3QuaWQwHhcNMTgwODI0MjExNDEwWhcNMzgw -ODI0MjExNDEwWjAWMRQwEgYDVQQDDAtzYW1sdGVzdC5pZDCCASIwDQYJKoZIhvcN -AQEBBQADggEPADCCAQoCggEBAJrh9/PcDsiv3UeL8Iv9rf4WfLPxuOm9W6aCntEA -8l6c1LQ1Zyrz+Xa/40ZgP29ENf3oKKbPCzDcc6zooHMji2fBmgXp6Li3fQUzu7yd -+nIC2teejijVtrNLjn1WUTwmqjLtuzrKC/ePoZyIRjpoUxyEMJopAd4dJmAcCq/K -k2eYX9GYRlqvIjLFoGNgy2R4dWwAKwljyh6pdnPUgyO/WjRDrqUBRFrLQJorR2kD -c4seZUbmpZZfp4MjmWMDgyGM1ZnR0XvNLtYeWAyt0KkSvFoOMjZUeVK/4xR74F8e -8ToPqLmZEg9ZUx+4z2KjVK00LpdRkH9Uxhh03RQ0FabHW6UCAwEAAaNXMFUwHQYD -VR0OBBYEFJDbe6uSmYQScxpVJhmt7PsCG4IeMDQGA1UdEQQtMCuCC3NhbWx0ZXN0 -LmlkhhxodHRwczovL3NhbWx0ZXN0LmlkL3NhbWwvaWRwMA0GCSqGSIb3DQEBCwUA -A4IBAQBNcF3zkw/g51q26uxgyuy4gQwnSr01Mhvix3Dj/Gak4tc4XwvxUdLQq+jC -cxr2Pie96klWhY/v/JiHDU2FJo9/VWxmc/YOk83whvNd7mWaNMUsX3xGv6AlZtCO -L3JhCpHjiN+kBcMgS5jrtGgV1Lz3/1zpGxykdvS0B4sPnFOcaCwHe2B9SOCWbDAN -JXpTjz1DmJO4ImyWPJpN1xsYKtm67Pefxmn0ax0uE2uuzq25h0xbTkqIQgJzyoE/ -DPkBFK1vDkMfAW11dQ0BXatEnW7Gtkc0lh2/PIbHWj4AzxYMyBf5Gy6HSVOftwjC -voQR2qr2xJBixsg+MIORKtmKHLfU - - - - - - - - - -MIIDEjCCAfqgAwIBAgIVAMECQ1tjghafm5OxWDh9hwZfxthWMA0GCSqGSIb3DQEB -CwUAMBYxFDASBgNVBAMMC3NhbWx0ZXN0LmlkMB4XDTE4MDgyNDIxMTQwOVoXDTM4 -MDgyNDIxMTQwOVowFjEUMBIGA1UEAwwLc2FtbHRlc3QuaWQwggEiMA0GCSqGSIb3 -DQEBAQUAA4IBDwAwggEKAoIBAQC0Z4QX1NFKs71ufbQwoQoW7qkNAJRIANGA4iM0 -ThYghul3pC+FwrGv37aTxWXfA1UG9njKbbDreiDAZKngCgyjxj0uJ4lArgkr4AOE -jj5zXA81uGHARfUBctvQcsZpBIxDOvUUImAl+3NqLgMGF2fktxMG7kX3GEVNc1kl -bN3dfYsaw5dUrw25DheL9np7G/+28GwHPvLb4aptOiONbCaVvh9UMHEA9F7c0zfF -/cL5fOpdVa54wTI0u12CsFKt78h6lEGG5jUs/qX9clZncJM7EFkN3imPPy+0HC8n -spXiH/MZW8o2cqWRkrw3MzBZW3Ojk5nQj40V6NUbjb7kfejzAgMBAAGjVzBVMB0G -A1UdDgQWBBQT6Y9J3Tw/hOGc8PNV7JEE4k2ZNTA0BgNVHREELTArggtzYW1sdGVz -dC5pZIYcaHR0cHM6Ly9zYW1sdGVzdC5pZC9zYW1sL2lkcDANBgkqhkiG9w0BAQsF -AAOCAQEASk3guKfTkVhEaIVvxEPNR2w3vWt3fwmwJCccW98XXLWgNbu3YaMb2RSn -7Th4p3h+mfyk2don6au7Uyzc1Jd39RNv80TG5iQoxfCgphy1FYmmdaSfO8wvDtHT -TNiLArAxOYtzfYbzb5QrNNH/gQEN8RJaEf/g/1GTw9x/103dSMK0RXtl+fRs2nbl -D1JJKSQ3AdhxK/weP3aUPtLxVVJ9wMOQOfcy02l+hHMb6uAjsPOpOVKqi3M8XmcU -ZOpx4swtgGdeoSpeRyrtMvRwdcciNBp9UZome44qZAYH1iqrpmmjsfI9pJItsgWu -3kXPjhSfj1AJGR1l9JGvJrHki1iHTA== - - - - - - - - - -MIIDEjCCAfqgAwIBAgIVAPVbodo8Su7/BaHXUHykx0Pi5CFaMA0GCSqGSIb3DQEB -CwUAMBYxFDASBgNVBAMMC3NhbWx0ZXN0LmlkMB4XDTE4MDgyNDIxMTQwOVoXDTM4 -MDgyNDIxMTQwOVowFjEUMBIGA1UEAwwLc2FtbHRlc3QuaWQwggEiMA0GCSqGSIb3 -DQEBAQUAA4IBDwAwggEKAoIBAQCQb+1a7uDdTTBBFfwOUun3IQ9nEuKM98SmJDWa -MwM877elswKUTIBVh5gB2RIXAPZt7J/KGqypmgw9UNXFnoslpeZbA9fcAqqu28Z4 -sSb2YSajV1ZgEYPUKvXwQEmLWN6aDhkn8HnEZNrmeXihTFdyr7wjsLj0JpQ+VUlc -4/J+hNuU7rGYZ1rKY8AA34qDVd4DiJ+DXW2PESfOu8lJSOteEaNtbmnvH8KlwkDs -1NvPTsI0W/m4SK0UdXo6LLaV8saIpJfnkVC/FwpBolBrRC/Em64UlBsRZm2T89ca -uzDee2yPUvbBd5kLErw+sC7i4xXa2rGmsQLYcBPhsRwnmBmlAgMBAAGjVzBVMB0G -A1UdDgQWBBRZ3exEu6rCwRe5C7f5QrPcAKRPUjA0BgNVHREELTArggtzYW1sdGVz -dC5pZIYcaHR0cHM6Ly9zYW1sdGVzdC5pZC9zYW1sL2lkcDANBgkqhkiG9w0BAQsF -AAOCAQEABZDFRNtcbvIRmblnZItoWCFhVUlq81ceSQddLYs8DqK340//hWNAbYdj -WcP85HhIZnrw6NGCO4bUipxZXhiqTA/A9d1BUll0vYB8qckYDEdPDduYCOYemKkD -dmnHMQWs9Y6zWiYuNKEJ9mf3+1N8knN/PK0TYVjVjXAf2CnOETDbLtlj6Nqb8La3 -sQkYmU+aUdopbjd5JFFwbZRaj6KiHXHtnIRgu8sUXNPrgipUgZUOVhP0C0N5OfE4 -JW8ZBrKgQC/6vJ2rSa9TlzI6JAa5Ww7gMXMP9M+cJUNQklcq+SBnTK8G+uBHgPKR -zBDsMIEzRtQZm4GIoHJae4zmnCekkQ== - - - - - - - - - - - - - - - - - - - - - - - - -` - - hwSpMetadata = ` - - - - - - - - - - -diBMwyuN633Q/kBf0M+SQZ4fNCI= - - - -k6+6QX8T5+S5wEIWlxwvd5a48xLWmp4Jd0bcs33vNaQVQ93YiztGcroUUqnLYK8uqAsmk2ZP4NtKFL/MyqoznrStglSi7uycwX6X3fswMwvkHJ9UVhH6Gp2Txl2JQ9/0vXy/tlXjQNFbfqzLhqxKC/K/PmKd684XkPYXlkiEJa6nGibu0gse9rvP2hE0G9bDMfdiyQnanfBvN+oNRte3xyI3DWh2P/jDTAPJMYzGM76JIneS8jLPa4gKDz5KcumG/8JV7GUWTDTZZ4ftujsjEuUFdPzKqwMYogMXOnTt8wbisSF8ZlLSMH/TIj6xAO9aSkEAo8HtlHJbekYlVA5Tz5IamLLzfaPpf7+NghLSuATIwY8/pvBZ8qhY8PVOjzRCeoEZJUrlFOcZ2CvO9zVKYdkEa1JC3mUW7CgeQc7G2/9niub7Vu00eyp9AAd9nkPfLoiWam8/yg2TBPRRJ9VKsv2UMFuITWrcFJayjezlTzY3dI3tI8lfoIMEVRaEP1v1D8XbxnxiaiKZXsGQHtpTSLc1ZL441jeZDLa661raUJDlGA6mBc1QukJklEocGg+Q+FeU33MJCaN/rIZCGvrjIZNng3yKFw1+R7/CqeJJlFWw0hPJQGiy6wfrDYSmhwuXJ2vQn3dTHjlT3kWsniiZtuOUi2TjHbq8gVHqlxmPxSs= - - - - -MIIF6TCCA9GgAwIBAgIEPHSCijANBgkqhkiG9w0BAQsFADCBpDELMAkGA1UEBhMCQ04xEjAQBgNV BAgTCUd1YW5nRG9uZzERMA8GA1UEBxMIU2hlblpoZW4xJTAjBgNVBAoTHEh1YXdlaSBUZWNobm9s b2dpZXMgQ28uLCBMdGQxKDAmBgNVBAsTH1NlcnZpY2UgUHJvdmlkZXIgT3BlcmF0aW9uIERlcHQx HTAbBgNVBAMTFGF1dGguaHVhd2VpY2xvdWQuY29tMB4XDTE4MDYyMTEzMjUwMFoXDTI4MDYxODEz MjUwMFowgaQxCzAJBgNVBAYTAkNOMRIwEAYDVQQIEwlHdWFuZ0RvbmcxETAPBgNVBAcTCFNoZW5a aGVuMSUwIwYDVQQKExxIdWF3ZWkgVGVjaG5vbG9naWVzIENvLiwgTHRkMSgwJgYDVQQLEx9TZXJ2 aWNlIFByb3ZpZGVyIE9wZXJhdGlvbiBEZXB0MR0wGwYDVQQDExRhdXRoLmh1YXdlaWNsb3VkLmNv bTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJisHObeLOPs2mJ4eJBcruMZl9FjvRQe DmofxgOcIcmybt6qlDqAv7275JMMQfQFcEoxH3GqcCTYqvSaSnHPaJB1xljPIKAWtd7p1ymevcSy F2HdCZ8gPJKg3Q6+ZjwTipKS/nZr7xmpUQ0WvwRkgZ7zfslAW+y5PCgkDrgmEjG92rLArj8iPhmu jajXaTPQKVHuZMxBzS735uo4yjVwYE3+0mE4HTZjK+6n6Ffu+JhLzhcKGulmrT/6qHisMbIXAZyE egBDavomb+5zu/CUQwii5IAPrRTwwegYpG4+uYJ2cHfrUdHqw9lSCSbQzu1yW1AS4zB16sjoHZdV rxYyktlswNmJ1/MyRH5bO90e2kvVwV4l34Hi5HEFvFFjL8TAsbN4mGvA9fgohXp30x97UdPVV8Ji NNAKZjdZSEdG9xqrTRfe4+LQg/hzLNSwsko3nDnH8qhCgtb8qIipQ3s7niCa53AQWYR82lEViols /dbWU9qYeldVvGNAgJSqHLB7qLwcQW78+2V1446KhQqzqPeLI4ANGaLFKw8fGzgh85RKOjrIetb4 wAOZmhrrUJrRg47DYQQjNv3glDg53ijLPFunzRqUoqLphrZ1XpEA4y21OtTP6OMYAM0lSOj1gjvb ubTDo8XOQs5YGtTOyHn4CQ4GR8NNo7UrwVEmoZHA+AKbAgMBAAGjITAfMB0GA1UdDgQWBBTt05QW 9dyXi7eMekKOH0bn4xKrkDANBgkqhkiG9w0BAQsFAAOCAgEACv9zgzUgxxQ8t9ldOXmirxzSOrHx MCL8SKsu+c+Y4hoHma5LFjylv6x76NWTAFSE6GgqfuNI/gPj/2AWqObAvsHd8lsPjJ96ZoSaTmS8 NrtU6HuT1Lc+CmVfeGd3/G+KspQECjg2JeBrfyEw9B8KUAQV20DQukGfAHtKKQPOZmKm0Qm3ExWC eXz1TR2KP+Lrhny/yG43g4iVUKq65HFHs5cRzRk0iR0/NLpggl5+Op0rxMxBn+bCrnJBi0n9/PIM fWNhkEBl+B++EifPUQxQaOEsnxTgFo1O4ksK9hDFcLbr+1qCDgVIMkyC1xMBBikCgLvIdzy3SXBN ndIEUq+QgOORxLlq1WqrfLFO22TxZm8XaB5g36UMk5PGoVHGnjALReAHjC0C5sIiKMJSgQOPd71X mQSsw3G9NsMKf/H3xJXkq/b672ls/l1JBslm52DAk2k5UlLkf/1p4I7WHOfm5ZNpDjj1rTP6SiAc tWLtqXIU28fLa2sA+zHXA5acDGOm6eIrMme5HpsV/KoUOW1MXGugK59zofeueCFDGRfbyoS2lj0S W+CbJVa72CLf3xPh2nWH0cK9de+wyCx8uI0KGPyV4I9/XBLHhvkb3XPaUfnkzYkcrG/39cOaxuPF z+haXwI1lvI964zvmTgwdDjdf/0asA09S7EEK2KyzXUREM4= - - - - - - - - - -MIIF6TCCA9GgAwIBAgIEPHSCijANBgkqhkiG9w0BAQsFADCBpDELMAkGA1UEBhMCQ04xEjAQBgNV BAgTCUd1YW5nRG9uZzERMA8GA1UEBxMIU2hlblpoZW4xJTAjBgNVBAoTHEh1YXdlaSBUZWNobm9s b2dpZXMgQ28uLCBMdGQxKDAmBgNVBAsTH1NlcnZpY2UgUHJvdmlkZXIgT3BlcmF0aW9uIERlcHQx HTAbBgNVBAMTFGF1dGguaHVhd2VpY2xvdWQuY29tMB4XDTE4MDYyMTEzMjUwMFoXDTI4MDYxODEz MjUwMFowgaQxCzAJBgNVBAYTAkNOMRIwEAYDVQQIEwlHdWFuZ0RvbmcxETAPBgNVBAcTCFNoZW5a aGVuMSUwIwYDVQQKExxIdWF3ZWkgVGVjaG5vbG9naWVzIENvLiwgTHRkMSgwJgYDVQQLEx9TZXJ2 aWNlIFByb3ZpZGVyIE9wZXJhdGlvbiBEZXB0MR0wGwYDVQQDExRhdXRoLmh1YXdlaWNsb3VkLmNv bTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJisHObeLOPs2mJ4eJBcruMZl9FjvRQe DmofxgOcIcmybt6qlDqAv7275JMMQfQFcEoxH3GqcCTYqvSaSnHPaJB1xljPIKAWtd7p1ymevcSy F2HdCZ8gPJKg3Q6+ZjwTipKS/nZr7xmpUQ0WvwRkgZ7zfslAW+y5PCgkDrgmEjG92rLArj8iPhmu jajXaTPQKVHuZMxBzS735uo4yjVwYE3+0mE4HTZjK+6n6Ffu+JhLzhcKGulmrT/6qHisMbIXAZyE egBDavomb+5zu/CUQwii5IAPrRTwwegYpG4+uYJ2cHfrUdHqw9lSCSbQzu1yW1AS4zB16sjoHZdV rxYyktlswNmJ1/MyRH5bO90e2kvVwV4l34Hi5HEFvFFjL8TAsbN4mGvA9fgohXp30x97UdPVV8Ji NNAKZjdZSEdG9xqrTRfe4+LQg/hzLNSwsko3nDnH8qhCgtb8qIipQ3s7niCa53AQWYR82lEViols /dbWU9qYeldVvGNAgJSqHLB7qLwcQW78+2V1446KhQqzqPeLI4ANGaLFKw8fGzgh85RKOjrIetb4 wAOZmhrrUJrRg47DYQQjNv3glDg53ijLPFunzRqUoqLphrZ1XpEA4y21OtTP6OMYAM0lSOj1gjvb ubTDo8XOQs5YGtTOyHn4CQ4GR8NNo7UrwVEmoZHA+AKbAgMBAAGjITAfMB0GA1UdDgQWBBTt05QW 9dyXi7eMekKOH0bn4xKrkDANBgkqhkiG9w0BAQsFAAOCAgEACv9zgzUgxxQ8t9ldOXmirxzSOrHx MCL8SKsu+c+Y4hoHma5LFjylv6x76NWTAFSE6GgqfuNI/gPj/2AWqObAvsHd8lsPjJ96ZoSaTmS8 NrtU6HuT1Lc+CmVfeGd3/G+KspQECjg2JeBrfyEw9B8KUAQV20DQukGfAHtKKQPOZmKm0Qm3ExWC eXz1TR2KP+Lrhny/yG43g4iVUKq65HFHs5cRzRk0iR0/NLpggl5+Op0rxMxBn+bCrnJBi0n9/PIM fWNhkEBl+B++EifPUQxQaOEsnxTgFo1O4ksK9hDFcLbr+1qCDgVIMkyC1xMBBikCgLvIdzy3SXBN ndIEUq+QgOORxLlq1WqrfLFO22TxZm8XaB5g36UMk5PGoVHGnjALReAHjC0C5sIiKMJSgQOPd71X mQSsw3G9NsMKf/H3xJXkq/b672ls/l1JBslm52DAk2k5UlLkf/1p4I7WHOfm5ZNpDjj1rTP6SiAc tWLtqXIU28fLa2sA+zHXA5acDGOm6eIrMme5HpsV/KoUOW1MXGugK59zofeueCFDGRfbyoS2lj0S W+CbJVa72CLf3xPh2nWH0cK9de+wyCx8uI0KGPyV4I9/XBLHhvkb3XPaUfnkzYkcrG/39cOaxuPF z+haXwI1lvI964zvmTgwdDjdf/0asA09S7EEK2KyzXUREM4= - - - - - - - - -MIIF6TCCA9GgAwIBAgIEPHSCijANBgkqhkiG9w0BAQsFADCBpDELMAkGA1UEBhMCQ04xEjAQBgNV BAgTCUd1YW5nRG9uZzERMA8GA1UEBxMIU2hlblpoZW4xJTAjBgNVBAoTHEh1YXdlaSBUZWNobm9s b2dpZXMgQ28uLCBMdGQxKDAmBgNVBAsTH1NlcnZpY2UgUHJvdmlkZXIgT3BlcmF0aW9uIERlcHQx HTAbBgNVBAMTFGF1dGguaHVhd2VpY2xvdWQuY29tMB4XDTE4MDYyMTEzMjUwMFoXDTI4MDYxODEz MjUwMFowgaQxCzAJBgNVBAYTAkNOMRIwEAYDVQQIEwlHdWFuZ0RvbmcxETAPBgNVBAcTCFNoZW5a aGVuMSUwIwYDVQQKExxIdWF3ZWkgVGVjaG5vbG9naWVzIENvLiwgTHRkMSgwJgYDVQQLEx9TZXJ2 aWNlIFByb3ZpZGVyIE9wZXJhdGlvbiBEZXB0MR0wGwYDVQQDExRhdXRoLmh1YXdlaWNsb3VkLmNv bTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJisHObeLOPs2mJ4eJBcruMZl9FjvRQe DmofxgOcIcmybt6qlDqAv7275JMMQfQFcEoxH3GqcCTYqvSaSnHPaJB1xljPIKAWtd7p1ymevcSy F2HdCZ8gPJKg3Q6+ZjwTipKS/nZr7xmpUQ0WvwRkgZ7zfslAW+y5PCgkDrgmEjG92rLArj8iPhmu jajXaTPQKVHuZMxBzS735uo4yjVwYE3+0mE4HTZjK+6n6Ffu+JhLzhcKGulmrT/6qHisMbIXAZyE egBDavomb+5zu/CUQwii5IAPrRTwwegYpG4+uYJ2cHfrUdHqw9lSCSbQzu1yW1AS4zB16sjoHZdV rxYyktlswNmJ1/MyRH5bO90e2kvVwV4l34Hi5HEFvFFjL8TAsbN4mGvA9fgohXp30x97UdPVV8Ji NNAKZjdZSEdG9xqrTRfe4+LQg/hzLNSwsko3nDnH8qhCgtb8qIipQ3s7niCa53AQWYR82lEViols /dbWU9qYeldVvGNAgJSqHLB7qLwcQW78+2V1446KhQqzqPeLI4ANGaLFKw8fGzgh85RKOjrIetb4 wAOZmhrrUJrRg47DYQQjNv3glDg53ijLPFunzRqUoqLphrZ1XpEA4y21OtTP6OMYAM0lSOj1gjvb ubTDo8XOQs5YGtTOyHn4CQ4GR8NNo7UrwVEmoZHA+AKbAgMBAAGjITAfMB0GA1UdDgQWBBTt05QW 9dyXi7eMekKOH0bn4xKrkDANBgkqhkiG9w0BAQsFAAOCAgEACv9zgzUgxxQ8t9ldOXmirxzSOrHx MCL8SKsu+c+Y4hoHma5LFjylv6x76NWTAFSE6GgqfuNI/gPj/2AWqObAvsHd8lsPjJ96ZoSaTmS8 NrtU6HuT1Lc+CmVfeGd3/G+KspQECjg2JeBrfyEw9B8KUAQV20DQukGfAHtKKQPOZmKm0Qm3ExWC eXz1TR2KP+Lrhny/yG43g4iVUKq65HFHs5cRzRk0iR0/NLpggl5+Op0rxMxBn+bCrnJBi0n9/PIM fWNhkEBl+B++EifPUQxQaOEsnxTgFo1O4ksK9hDFcLbr+1qCDgVIMkyC1xMBBikCgLvIdzy3SXBN ndIEUq+QgOORxLlq1WqrfLFO22TxZm8XaB5g36UMk5PGoVHGnjALReAHjC0C5sIiKMJSgQOPd71X mQSsw3G9NsMKf/H3xJXkq/b672ls/l1JBslm52DAk2k5UlLkf/1p4I7WHOfm5ZNpDjj1rTP6SiAc tWLtqXIU28fLa2sA+zHXA5acDGOm6eIrMme5HpsV/KoUOW1MXGugK59zofeueCFDGRfbyoS2lj0S W+CbJVa72CLf3xPh2nWH0cK9de+wyCx8uI0KGPyV4I9/XBLHhvkb3XPaUfnkzYkcrG/39cOaxuPF z+haXwI1lvI964zvmTgwdDjdf/0asA09S7EEK2KyzXUREM4= - - - - - - - - - - - -urn:oasis:names:tc:SAML:2.0:nameid-format:transient - - - -` - hwIdpMetadata = ` - - - - - -MIICsDCCAhmgAwIBAgIJAKNbH+B0Vm9HMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV -BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX -aWRnaXRzIFB0eSBMdGQwHhcNMTgxMDMwMDIxMzA4WhcNMzMxMDMxMDIxMzA4WjBF -MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 -ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB -gQDIIZtsLpqLDpXB1LI8tbtwoeOyJbM2PIxJTOqRm1ZM0r7rpvt4kFCgAd68gAsl -YAEeSqUawxV3FUgt62DLMOT2auwBcpywVW7L/ZF4IUziwuFQLWdw5NIGMP5lpt1M -HSel8k4paokoXAwZ2B+Vtku+kDTGLc3cp1T5/ClYE/ofdQIDAQABo4GnMIGkMB0G -A1UdDgQWBBRVZlu4B6TzuNHasJz5tHoMilKLdjB1BgNVHSMEbjBsgBRVZlu4B6Tz -uNHasJz5tHoMilKLdqFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt -U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAKNbH+B0 -Vm9HMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAhyVdBqW4r94XdwMy -LK42mwqNnHy4WjM8eq9X5FhBckZX+TyM909iH2AsMjpkv8BDIxTiX6tpmNyYhOCp -vCPMmQHl9450maIA7At//sEgL94FNRJbTYkme7F3xI90X0htMr23Yan31lRwdj53 -DgagnkMlzQ8QccUXrdQgzXzKb0w= - - - - - - - -MIICsDCCAhmgAwIBAgIJAKNbH+B0Vm9HMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV -BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX -aWRnaXRzIFB0eSBMdGQwHhcNMTgxMDMwMDIxMzA4WhcNMzMxMDMxMDIxMzA4WjBF -MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 -ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB -gQDIIZtsLpqLDpXB1LI8tbtwoeOyJbM2PIxJTOqRm1ZM0r7rpvt4kFCgAd68gAsl -YAEeSqUawxV3FUgt62DLMOT2auwBcpywVW7L/ZF4IUziwuFQLWdw5NIGMP5lpt1M -HSel8k4paokoXAwZ2B+Vtku+kDTGLc3cp1T5/ClYE/ofdQIDAQABo4GnMIGkMB0G -A1UdDgQWBBRVZlu4B6TzuNHasJz5tHoMilKLdjB1BgNVHSMEbjBsgBRVZlu4B6Tz -uNHasJz5tHoMilKLdqFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt -U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAKNbH+B0 -Vm9HMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAhyVdBqW4r94XdwMy -LK42mwqNnHy4WjM8eq9X5FhBckZX+TyM909iH2AsMjpkv8BDIxTiX6tpmNyYhOCp -vCPMmQHl9450maIA7At//sEgL94FNRJbTYkme7F3xI90X0htMr23Yan31lRwdj53 -DgagnkMlzQ8QccUXrdQgzXzKb0w= - - - - - - urn:oasis:names:tc:SAML:2.0:nameid-format:transient - - -` - aliyunSpMeta = ` - - - - - - MIIDXjCCAkagAwIBAgIEXHToLjANBgkqhkiG9w0BAQsFADBwMQswCQYDVQQGEwJDTjERMA8GA1UE - CBMISGFuZ3pob3UxKTAnBgNVBAsTIEFsaWJhYmEgQ2xvdWQgQ29tcHV0aW5nIENvLiBMdGQuMSMw - IQYDVQQDExp1cm46YWxpYmFiYTpjbG91ZGNvbXB1dGluZzAgFw0xOTAyMjYwNzE4MDZaGA8yMTE5 - MDIwMjA3MTgwNlowcDELMAkGA1UEBhMCQ04xETAPBgNVBAgTCEhhbmd6aG91MSkwJwYDVQQLEyBB - bGliYWJhIENsb3VkIENvbXB1dGluZyBDby4gTHRkLjEjMCEGA1UEAxMadXJuOmFsaWJhYmE6Y2xv - dWRjb21wdXRpbmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDDjD53ZENEHoYNXAOf - OIbVBJhj7SCWKmdjnbnxq8WAFWEeZtS6hZLPpWh1z7b0NjJkvCf5oFVqBJYbbW5kEKV+9CpV6VHZ - qOXmsIRlkvZB+Wnc3SduwiiiUR9JojSPxVQvSf4WLT+HDASlrBztuRV2vHj9utLbvy+6bgVBqF8g - emL9Pcif1robDH8HlqUcADXLAt18E4MbToldVoHjpFc6fAKUXujWH5feAL8g0CKlmf/JVlHLEtu4 - vKPxBQ8sgkysk6EnrjXl6Q4a4t+vbPG5uczA1ouTkDupMCRlaWHIHaJL/AoDGabn8sVXdaVJUKC5 - 54FNkRznBhRQll+Nuc2rAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAE8k4S4HvOglthJwF3aMQXGi - LKW6Becs9SljA0/5VtZQDrDf2By/1BIMvWfZ/dFnO+MylDLVdS6XWvWat/DW0fOGxU4s1WNfshX7 - DJDGR2G1XgtGoDZEYIDahUp5katAPypCkY57fGZlI0d3nq46/2qT/Zpne+pFE3DI/x8klZMniniw - YjNXbG96y/M4DYi1J7RR8mLIfVvz5o1SMGT4Ta2p/USE2M9F6O7/zc2j62dQgXiYa9OONo31RiXR - TmvGEUNuQoBZhVrFIvOnNjIfFT7Xd3CUowwJKP1floserrx4B5jScRAi9yK3x2a2lhfc+PksXfTs - aqIr5TQL4OorLEE= - - - - urn:oasis:names:tc:SAML:2.0:nameid-format:transient - urn:oasis:names:tc:SAML:2.0:nameid-format:persistent - urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress - urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified - urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName - urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName - urn:oasis:names:tc:SAML:2.0:nameid-format:kerberos - urn:oasis:names:tc:SAML:2.0:nameid-format:entity - - - Alibaba Cloud Console Single Sign-On - - - - - - - Alibaba Cloud Computing Co. Ltd. - AlibabaCloud - https://www.aliyun.com - -` - - aliyunUserMeta = ` -MIIDUTCCAjmgAwIBAgIEIv2v9DANBgkqhkiG9w0BAQsFADBZMQswCQYDVQQGEwJDTjERMA8GA1UE -BxMISGFuZ3pob3UxFDASBgNVBAoTC0FsaWJhYmEgSW5jMQ8wDQYDVQQLEwZBcHNhcmExEDAOBgNV -BAMTB0FsaWJhYmEwHhcNMTcwMzE0MTc1OTE5WhcNMjcwMzEyMTc1OTE5WjBZMQswCQYDVQQGEwJD -TjERMA8GA1UEBxMISGFuZ3pob3UxFDASBgNVBAoTC0FsaWJhYmEgSW5jMQ8wDQYDVQQLEwZBcHNh -cmExEDAOBgNVBAMTB0FsaWJhYmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCqK2HR -tf4smv9pCQtPenFE1w6lvxsHiv0J/knvpC1BU4iAWcS8LxAElKb49QbKHuUxcwEGJfm0+zZpqS+J -I3jmGc4aHYACyL2WxtKNx/5EK1Qs5ugCipn7g+ySOqXxc/Rv2S7muw6LTrGVTT7vo09EUDkZM34s -TupuU7tzX0ktYhimxwskG9o7bvZuQKQf66gN8l/DUzyUl59/0wA1+x5A5B3pvaABCA6dq4mi8mtJ -fTXcqWm06+FgVNPgKo59uP6y08rQJXjKDwLIf0owuoiRrPLR5JKC1vQ6PSz0cGv8tGUts5dr/0zG -FHy4h3aufQiXCSi44WUB3FejQQfgEiBdAgMBAAGjITAfMB0GA1UdDgQWBBShWN61nZsWz9MYnSrV -kCkJnSdFtDANBgkqhkiG9w0BAQsFAAOCAQEAMMAl+C3oyI6kZNmvX05Sb0q6UAM8wqjFKbPhSSiy -srjVZwjEjiZnOSnoX8vO07fsZpcVmByHzGXWuBxxKCviCpQCS9hyOTF6bvAoXwe37h02Uhv3tKI0 -7FRkXJA7HeB0HEuHPCBxxWVWJfgtkeUETnGV06CrUlGON7Du3h37EUzfTqmKhlsqKeK8uqw3gLYq -Bp6ULrP1PbNo2AaHMYaZhFL1dSUtNYvekZppregZKMIDqtEm6Pwpw2lj8gjTC40PQ0GuXEeTsfE5 -dhw42xc9RkyUg1Go04k9Z/UMxTX0KVMiRZ9DF2FWjWp1AAQJ3TvZ2Ao/XOhmk4GWRehUoHr7Hw==urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddressurn:oasis:names:tc:SAML:2.0:nameid-format:transienturn:oasis:names:tc:SAML:2.0:nameid-format:persistenturn:oasis:names:tc:SAML:1.1:nameid-format:unspecified` -) - -func TestParseMetadata(t *testing.T) { - cases := []struct { - In string - }{ - { - In: spMetadata1, - }, - { - In: idpMetadata, - }, - { - In: hwSpMetadata, - }, - { - In: hwIdpMetadata, - }, - { - In: aliyunSpMeta, - }, - { - In: aliyunUserMeta, - }, - } - for _, c := range cases { - ed, err := ParseMetadata([]byte(c.In)) - if err != nil { - t.Errorf("ParseMetadata fail %s", err) - } else { - xmlstr, err := xml.MarshalIndent(ed, "", " ") - if err != nil { - t.Errorf("xml.Marshal fail %s", err) - } else { - t.Logf("%s", xmlstr) - } - } - } -} - -var ( - resp1 = ` - - - - - https://www.test.com - - - urn:oasis:names:tc:SAML:2.0:status:Success - - - - https://www.test.com - - - - - - - - - - - - - - - rFxrycznfGNYOnprZIFJJou4ro0Mz65+43MIR5F0+H4= - - - - - YqTWQngAPfGqQmWa610PM7LeefqWdKuveUVINrqL67NoHJIDa2WxLwdVzoJIlJh64QiNPr6+ndmL DCMgIC5F/9ijuzhIICZcc6lHNIjy6EsPkKRjfo9oeoVAqLgG/kmVQYeHLBID0y11RNXXpAVY4nhJ 26KiIVGt7ywyKAmhichE+eW/UYAGiOI5vkfgD2gZUGV+yPkv64k7xK4yAH3mL2NaCPuw/90e4enm iUx0YuazDwM5FiRUSMpcJs0rcNmS6clWAUcCzbOx+y2vJGtTjHb7k3UsmpnTop5eYNp94+sDPEat 8FaV4SgafMEL5z54gpe8+//9yOWEvlBs1b0RYg== - - - - - -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhK3L160NjP9EhBGQOC2s4r+Wc62bkRkc nUxfhiZwCwJdQCykzuLOAoATnfoEamV5W25xtSS5kFs+4OC0mYVpKcI3SWoydX+UE5Qik5UfJ8Dt G1AvSEKhSluyO9axrV5Uv089jMxBnlm/R+xND73WcZM11yIbKJEZSTCEDfh+KnFbMw108umFMden RZCrNWUJoSp/90XeG0V2Nmj7Fkq72skSifwIASLRq9KqLbmh1QwUX+AoWpHK/jRUBustMBmG1n1i - AqpD4EBjjBOB27k1wXZ30+IoJt8IZmfSZRFoNn5VFWXNeEmZ1aQvGSvd3Tyyw2/Wr+w/8Mags69C mpeX6QIDAQAB - - - - - - - Some NameID value - - - - - - - - - https://auth.huaweicloud.com/ - - - - - - ******* - - - - ******** - - - ****** - - - - - - ****** - - - ***** - - - - - - - urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified - - - -` - resp2 = ` - https://idp.example.org/SAML2 - - - - - https://idp.example.org/SAML2 - - ... - - - 3f7b3dcf-1674-4ecd-92c8-1544f346baf8 - - - - - - - - https://sp.example.com/SAML2 - - - - - - urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport - - - - - ` -) - -func TestParseResponse(t *testing.T) { - cases := []struct { - In string - }{ - { - In: resp1, - }, - { - In: resp2, - }, - } - for _, c := range cases { - resp := Response{} - err := xml.Unmarshal([]byte(c.In), &resp) - if err != nil { - t.Errorf("xml.Unmarshal %s", err) - } else { - xmlstr, err := xml.MarshalIndent(resp, "", " ") - if err != nil { - t.Errorf("xml.Marshal fail %s", err) - } else { - t.Logf("%s", xmlstr) - } - } - } -} diff --git a/pkg/util/samlutils/response_test.go b/pkg/util/samlutils/response_test.go deleted file mode 100644 index fb6d391f3f..0000000000 --- a/pkg/util/samlutils/response_test.go +++ /dev/null @@ -1,207 +0,0 @@ -// 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 samlutils - -import ( - "encoding/xml" - "strings" - "testing" - - "yunion.io/x/onecloud/pkg/util/seclib2" -) - -var ( - privateKeyString = `-----BEGIN PRIVATE KEY----- -MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDKpaC0XoinzuQO -bt/VsWap0OVqN8O3cBFS41Ss9GGbjn1ZIg+D14OxywZdrRA17MKxfjhO4F+d2n8H -Ih5ZofGURKgOH8KrEIPcii5HLk1ZVnLXXbinExwG26OPAID9rYNSdBhVeR4pqHm7 -SBnBXV+s83eIekAuPE6lIOF4irA3kOXxKhInYAygnx2fNR6p98suNda+F1VTO8HV -WoAvjJoQ0iAA6/eHmUv1gPtJ+odjJPH7m6FrF3voJIiwmgFua01qkn6tZH53hBc2 -Dkbt5PxqI1KC0C79wq1ufehkk9MR5NTMxIwxbc3PcTbmwduGelKOsloLK/tGu5g8 -Kq5UJE4ZAgMBAAECggEBAJmRtNybe1I4Hmm1qlkl7Fgqn4DEK8Sa3/YBowzC0ilx -bRqcDkfqjbmx0uwwl8VV3CFoNsHHlY5po7RDLd7dM9cZxIWXmg3LITKDYRi+RQ27 -zqHZO3MZrzafQi6/wgD8ejWFF1/Gvo3xR/ceZ6461aOaie5aPsMLHspSxat05p/k -C4NkBvjHdYt4PiH873PLOI6mpt8N5mnkYmer8S5XX02GyQI4OGnHuCqQsHtlhgj7 -XeSB2biDNrcYfL1Kp1E8vEGBYqhohVWVWo+rP5zyoWNxQUXOVDE5zQanLrktjno5 -uzHkK1zKGcOlh7s40pV3qgcQFRTWt4RRP5wBasKc9wECgYEA948ikAVBiAiEPDha -hlNboaUKYeB6HxKSUZhqaGY0+7OWSyBhQBALCZRk4ccscysj4VUur+6FwC7lleRj -tG+S7ukyiQEeH0c0NAfnIlSd+LFQREsj4MVLn+Sl/8edNIl/UH+69pDtVU6Az/2u -DF0FloGL5XZ0WLIVcRZdUjt8HfkCgYEA0Y54DPN5PcLKci0Plioc0qLb33kp6F+w -JJhOLJv+tbmeNVA0EM+BwTHlHF8MRsreybwSHoUYX61vkR2AlGLo8D5TlTEA1VSD -k4w5Yic3cjQzOFMWQczpGdBwV37inHOU2phOp2kKs8LyT/gJw5f6b34R7zfRc8ry -uAEXaTg4OSECgYBb37ESBgFV/OMmfjuKUnFVQiziOi7YTUokIg6LhDLxnqqOYwv0 -fH+8JGh0Kjji3QXJ4JUdEcZtlnn58PLXyfib1cu9cL6/GOvUy4IKCaE+5H9HeSNt -jYsNYgwBKxG6p7SqKV03mH2cBTBlAF6RlAw42QcUN6viJuUyPPyRQiZD8QKBgQCO -N28X8wC8Pn9gH16tnaTz+pzXvAYJ8y66lzaupaumLvPE4MqFAh7gO3lu2L6fKL0s -EdwGJHOXM0A9LtV9XucRbGsTHC+hl/q33vluuIizk+OS/ShkvakQ4NntN2qZnQNP -mv/+M5aUyt/iD8aonHLUya1oOOyH9hrlb7Aws3vMoQKBgQDNH4xxS7wxnf7GcTnt -96tHvjBVHXa0SK1XkbFjgIEDU+xeEUteYs/9jW4AMA/lqsfBXUwhF3JAVoRUWm0M -d95jkAi6q2icuGogkftyv+LgUvhSUm6N+8eQ+YvQfgsNBqxlSudjpP0V+S2v73vp -8egFWKkL+H0upowTbr0T0OUfog== ------END PRIVATE KEY----- -` - certString = `MIIE/DCCA+SgAwIBAgIQQHdQar3faUJLgHcCgO4z3zANBgkqhkiG9w0BAQsFADCB -nzELMAkGA1UEBhMCQ04xEDAOBgNVBAgMB0JlaWppbmcxETAPBgNVBAcMCENoYW95 -YW5nMSMwIQYDVQQKDBpZdW5pb24gVGVjaG5vbG9neSBDby4gTHRkLjERMA8GA1UE -CwwIT25lQ2xvdWQxFDASBgNVBAMMC0AxNTkxNzIxNDc5MR0wGwYJKoZIhvcNAQkB -Fg5pbmZvQHl1bmlvbi5jbjAeFw0yMDA2MDkxNjUxMjBaFw0yMjA4MTgxNjUxMjBa -MIGXMQswCQYDVQQGEwJDTjEQMA4GA1UECAwHQmVpamluZzERMA8GA1UEBwwIQ2hh -b3lhbmcxIzAhBgNVBAoMGll1bmlvbiBUZWNobm9sb2d5IENvLiBMdGQuMREwDwYD -VQQLDAhPbmVDbG91ZDEMMAoGA1UEAwwDaWRwMR0wGwYJKoZIhvcNAQkBFg5pbmZv -QHl1bmlvbi5jbjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMqloLRe -iKfO5A5u39WxZqnQ5Wo3w7dwEVLjVKz0YZuOfVkiD4PXg7HLBl2tEDXswrF+OE7g -X53afwciHlmh8ZREqA4fwqsQg9yKLkcuTVlWctdduKcTHAbbo48AgP2tg1J0GFV5 -HimoebtIGcFdX6zzd4h6QC48TqUg4XiKsDeQ5fEqEidgDKCfHZ81Hqn3yy411r4X -VVM7wdVagC+MmhDSIADr94eZS/WA+0n6h2Mk8fuboWsXe+gkiLCaAW5rTWqSfq1k -fneEFzYORu3k/GojUoLQLv3CrW596GST0xHk1MzEjDFtzc9xNubB24Z6Uo6yWgsr -+0a7mDwqrlQkThkCAwEAAaOCATgwggE0MAkGA1UdEwQCMAAwHQYDVR0OBBYEFFie -B9nsyKQ0A+oUWqiJkkURLJMqMIHUBgNVHSMEgcwwgcmAFISskqtTpDD4otifwvuG -bFwyvZ0zoYGlpIGiMIGfMQswCQYDVQQGEwJDTjEQMA4GA1UECAwHQmVpamluZzER -MA8GA1UEBwwIQ2hhb3lhbmcxIzAhBgNVBAoMGll1bmlvbiBUZWNobm9sb2d5IENv -LiBMdGQuMREwDwYDVQQLDAhPbmVDbG91ZDEUMBIGA1UEAwwLQDE1OTE3MjE0Nzkx -HTAbBgkqhkiG9w0BCQEWDmluZm9AeXVuaW9uLmNuggkA7uFZmhG6rz0wEwYDVR0l -BAwwCgYIKwYBBQUHAwEwCwYDVR0PBAQDAgWgMA8GA1UdEQQIMAaHBH8AAAEwDQYJ -KoZIhvcNAQELBQADggEBAKc7gUyrAMto3O8/Qi/m23aHxYc33GVMRrDPNS7asSWO -l+3IiWc2L61OiWhmK75t1leMRZU5hEuxAb3Rq6TwHVQWD3mAuIrss+Dsfhs0Y/wa -miIYV+v4rXuu3CusBxQo8NRuNW+f/F5cR0WVBDDMm5NDQKPVdeQ5uszqtWN62tPq -zvi1nRqaRKZQbzENGmqLwfMQCm0fsUzw6mdZb137S04MuSnvb1hTyhQ492uqoTlE -KM6qMM9M9PWLW8PiZxiHxtLdO5BIXOXY//xU9xD58sOIAePuc322+TbMBtRZAyqg -OZ+tB0Nzk2RJp4luPEqxoBcDVpcuiyfu3s3Jtnr3Lns=` -) - -func TestNewResponse(t *testing.T) { - input := SSAMLResponseInput{ - // NameId: "testUser", - // NameIdFormat: NAME_ID_FORMAT_TRANSIENT, - RequestID: "_dck4mm08qmdhc8k4nuir07hghetdqqg8umg5", - RequestEntityId: "https://auth.huaweicloud.com/", - IssuerEntityId: "https://saml.yunion.io/", - IssuerCertString: certString, - AssertionConsumerServiceURL: "https://auth.huaweicloud.com/authui/saml/SAMLAssertionConsumer", - } - resp := NewResponse(input) - resp.AddAudienceRestriction(input.RequestEntityId) - for k, v := range map[string]string{ - "xUserId": "userXXXX", - "xAccountId": "accountXXXX", - "bpId": "bpXXXXX", - "email": "xxxx@yunion.io", - "name": "xxxx", - "mobile": "13812341234", - } { - resp.AddAttribute(k, k, "urn:oasis:names:tc:SAML:2.0:attrname-format:uri", []string{v}) - } - - respXml, err := xml.MarshalIndent(resp, "", " ") - if err != nil { - t.Fatalf("xml.MarshalIndent fail %s", err) - } - - privateKey, err := seclib2.DecodePrivateKey([]byte(privateKeyString)) - if err != nil { - t.Fatalf("decodePrivateKey fail %s", err) - } - - signed, err := SignXML(string(respXml), privateKey) - if err != nil { - t.Fatalf("SignXML fail %s", err) - } - - t.Logf("signed XML: %s", signed) - - validXMLs, err := ValidateXML(signed) - if err != nil { - t.Fatalf("ValidateXML fail %s", err) - } - - t.Logf("validated xml: %s", validXMLs) -} - -var ( - encryptedResp = ` -https://samltest.id/saml/idpRE6No535ZL120aHLfko+nmZmphMma53rPfyEbenqxQU=EjPgOQ4oufcqcTZu9VaOlEcZUmvEZa3fOYAWxvLMMjmx5OcGfhk8Xs9Dsyy4UOcdNXL+4vQx0ZfglBFXCLHPCO209V0oAhwRK9g0VMH5RAvgKJIH0pEU7ThHq66AMYqgKumwAE3APzMzDapI+hLvyH6wWYQNxjqOCYlGQ1Y8CNjPu11XxFzgIG0VgcHHaDL5ovAVZThrgf9M8iO0rnMpo/BmeetjOd624aws9ajZMdhNbeNeswHukvg70YmfbS0PoheYfJneeMtIvywWOfBSArOCSbwAXpCnwKVSNCYNQifVUTnJVt27QEai4LhsGYlZVeu4ilwYbMo9U+iVP27S2g==MIIDEjCCAfqgAwIBAgIVAMECQ1tjghafm5OxWDh9hwZfxthWMA0GCSqGSIb3DQEBCwUAMBYxFDAS -BgNVBAMMC3NhbWx0ZXN0LmlkMB4XDTE4MDgyNDIxMTQwOVoXDTM4MDgyNDIxMTQwOVowFjEUMBIG -A1UEAwwLc2FtbHRlc3QuaWQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC0Z4QX1NFK -s71ufbQwoQoW7qkNAJRIANGA4iM0ThYghul3pC+FwrGv37aTxWXfA1UG9njKbbDreiDAZKngCgyj -xj0uJ4lArgkr4AOEjj5zXA81uGHARfUBctvQcsZpBIxDOvUUImAl+3NqLgMGF2fktxMG7kX3GEVN -c1klbN3dfYsaw5dUrw25DheL9np7G/+28GwHPvLb4aptOiONbCaVvh9UMHEA9F7c0zfF/cL5fOpd -Va54wTI0u12CsFKt78h6lEGG5jUs/qX9clZncJM7EFkN3imPPy+0HC8nspXiH/MZW8o2cqWRkrw3 -MzBZW3Ojk5nQj40V6NUbjb7kfejzAgMBAAGjVzBVMB0GA1UdDgQWBBQT6Y9J3Tw/hOGc8PNV7JEE -4k2ZNTA0BgNVHREELTArggtzYW1sdGVzdC5pZIYcaHR0cHM6Ly9zYW1sdGVzdC5pZC9zYW1sL2lk -cDANBgkqhkiG9w0BAQsFAAOCAQEASk3guKfTkVhEaIVvxEPNR2w3vWt3fwmwJCccW98XXLWgNbu3 -YaMb2RSn7Th4p3h+mfyk2don6au7Uyzc1Jd39RNv80TG5iQoxfCgphy1FYmmdaSfO8wvDtHTTNiL -ArAxOYtzfYbzb5QrNNH/gQEN8RJaEf/g/1GTw9x/103dSMK0RXtl+fRs2nblD1JJKSQ3AdhxK/we -P3aUPtLxVVJ9wMOQOfcy02l+hHMb6uAjsPOpOVKqi3M8XmcUZOpx4swtgGdeoSpeRyrtMvRwdcci -NBp9UZome44qZAYH1iqrpmmjsfI9pJItsgWu3kXPjhSfj1AJGR1l9JGvJrHki1iHTA==MIIE/DCCA+SgAwIBAgIQQHdQar3faUJLgHcCgO4z3zANBgkqhkiG9w0BAQsFADCBnzELMAkGA1UE -BhMCQ04xEDAOBgNVBAgMB0JlaWppbmcxETAPBgNVBAcMCENoYW95YW5nMSMwIQYDVQQKDBpZdW5p -b24gVGVjaG5vbG9neSBDby4gTHRkLjERMA8GA1UECwwIT25lQ2xvdWQxFDASBgNVBAMMC0AxNTkx -NzIxNDc5MR0wGwYJKoZIhvcNAQkBFg5pbmZvQHl1bmlvbi5jbjAeFw0yMDA2MDkxNjUxMjBaFw0y -MjA4MTgxNjUxMjBaMIGXMQswCQYDVQQGEwJDTjEQMA4GA1UECAwHQmVpamluZzERMA8GA1UEBwwI -Q2hhb3lhbmcxIzAhBgNVBAoMGll1bmlvbiBUZWNobm9sb2d5IENvLiBMdGQuMREwDwYDVQQLDAhP -bmVDbG91ZDEMMAoGA1UEAwwDaWRwMR0wGwYJKoZIhvcNAQkBFg5pbmZvQHl1bmlvbi5jbjCCASIw -DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMqloLReiKfO5A5u39WxZqnQ5Wo3w7dwEVLjVKz0 -YZuOfVkiD4PXg7HLBl2tEDXswrF+OE7gX53afwciHlmh8ZREqA4fwqsQg9yKLkcuTVlWctdduKcT -HAbbo48AgP2tg1J0GFV5HimoebtIGcFdX6zzd4h6QC48TqUg4XiKsDeQ5fEqEidgDKCfHZ81Hqn3 -yy411r4XVVM7wdVagC+MmhDSIADr94eZS/WA+0n6h2Mk8fuboWsXe+gkiLCaAW5rTWqSfq1kfneE -FzYORu3k/GojUoLQLv3CrW596GST0xHk1MzEjDFtzc9xNubB24Z6Uo6yWgsr+0a7mDwqrlQkThkC -AwEAAaOCATgwggE0MAkGA1UdEwQCMAAwHQYDVR0OBBYEFFieB9nsyKQ0A+oUWqiJkkURLJMqMIHU -BgNVHSMEgcwwgcmAFISskqtTpDD4otifwvuGbFwyvZ0zoYGlpIGiMIGfMQswCQYDVQQGEwJDTjEQ -MA4GA1UECAwHQmVpamluZzERMA8GA1UEBwwIQ2hhb3lhbmcxIzAhBgNVBAoMGll1bmlvbiBUZWNo -bm9sb2d5IENvLiBMdGQuMREwDwYDVQQLDAhPbmVDbG91ZDEUMBIGA1UEAwwLQDE1OTE3MjE0Nzkx -HTAbBgkqhkiG9w0BCQEWDmluZm9AeXVuaW9uLmNuggkA7uFZmhG6rz0wEwYDVR0lBAwwCgYIKwYB -BQUHAwEwCwYDVR0PBAQDAgWgMA8GA1UdEQQIMAaHBH8AAAEwDQYJKoZIhvcNAQELBQADggEBAKc7 -gUyrAMto3O8/Qi/m23aHxYc33GVMRrDPNS7asSWOl+3IiWc2L61OiWhmK75t1leMRZU5hEuxAb3R -q6TwHVQWD3mAuIrss+Dsfhs0Y/wamiIYV+v4rXuu3CusBxQo8NRuNW+f/F5cR0WVBDDMm5NDQKPV -deQ5uszqtWN62tPqzvi1nRqaRKZQbzENGmqLwfMQCm0fsUzw6mdZb137S04MuSnvb1hTyhQ492uq -oTlEKM6qMM9M9PWLW8PiZxiHxtLdO5BIXOXY//xU9xD58sOIAePuc322+TbMBtRZAyqgOZ+tB0Nz -k2RJp4luPEqxoBcDVpcuiyfu3s3Jtnr3Lns=ZwBIXvZM7t168N7l10Kt6FxGuF9dpHD876iktHrkfx9Tp+bxcRFGizdFV/BA1KD7NF1/04OnvtXbki+hQhDx4wym7JUuWa/tUMLli3Ks1iOhSeCGwW/wM7i5ZPQ1LF6LLtbl4n2bIL9ystpodR/i2OJ7nqgoA1125qm0XDgzrm1424g1uIQlDS/+ONpuuipD4GcTd7bv+Ef7grtIHZhDuptXjWr1pKy2tKjwQLJw0Otx4UaFvvLz/jfGIKdv4/KsWYJXOHBjt8Kegz73WEDRaHeHhhDy1JIaXP6La1+tg0TCzVQ2pfSg+teXj8CJ0oaBM1n5C2zG77g6JMdtGr5waA==X5yCI8u0+xNVaBBoerAxVTuENQtgWVRy7VcXOWERgQYdvKU8DbLpcynavBmBm+uEroiQeU6LUJ/wONR20OnYlrzlU/A2Ejz1WVsNSoTtXGnw/ccPJ0AgRDT9EWKbYfYGTNxS3mdV5fJwmCfoadkY7AP967GToQ4IRXLcc1jNTc3/6J5UQtbHL6/tNoFWgBggG96xJDC0dUp1TL1TbHThtMuGAQAib5+XYsTFqQvUUELTbViiZEX07UZSEZ/HMCjtdlo8RZShVhd5OPnmsXWYG1tHNtEzI+DA7Jb/rAnmiY9fT3IZNeZMUFGnmP7fl1laQjb2Xqp1hnaG/MryfrGKSMhK6k0NWIWUPCte7J2RNLGyQeUOs3/VnSRudzqowoWOpNxGRQASR6xfjqvt1l/GZuL659Yd4No8v4XDMHxuItAcQuD7k6RIw7+4llyWFcwn7qqJHUCtJlXY/KoR78pxxMpwaS5lhOlc++tv8Rma/rIkEVr4k9CiHf9bvo8w/wyb14Tn2sf6ajlMm4J1MaE5ua8O3o7nEt0uODRMWf58pMITOXihq1UjGMNgD8u6nXBRkJFgiYudTL95kvuI6Lb5JRcO0KRI+arLKAzBa1DKpTe+xa2t22Od99TJlFZICN+Yd4OoosrOLCkbvRBpkxO4hMafh5R2f7j4f/YsN8hVnDhPCGxoW1Nh7eZNGnUnhWoXq0lHXGYO3egHrB7bdaULtdlSN+wDe3xFsZ4pZfLZlnkIZytJfM3tTjimYWipknkrcRe950Wo8cXtVuJCjeqplFjeNDl7goF9J3zfm+AoIR4247qD2ht4alT3zKt357Q2StdD3wMRX12C36PRouYpuzOdGoAiV+nXAyFym2oFKXGyXKDgSFitic7hS7I/JEd+xtY747hbiAvHi8SZ/LlZ7caIjhV+W0SPDmf9S6Wyx6ONwI/eS0R+bmEjyxy4pHTuipqj/HHCjTISgcN1yLyCHicISJLXmXRgDmrTbRUzFYw2NdwzJPsoz1iIxF+FY26pM4opfWy19UMe4TZBFjIzo4Kx0PKWJ5PJ0zUDeHTcrybelqAu77bHugjr5fJ3gWC50NR7QnzLFzJ4S1aHx+oUpFmDVkLeKN00A95o2cyBgdXT/atQOZdXDXeQGEaUKASiCIc8HzIg4qMhDkDpwVlokYkxbPS5bk4sAADSXR0KfpCteWm6i6tgA4T/jPLLxeO/tzLE/a1StaQcINGxmq/QzEpRq9gNVJ8ulIBdVADOhonNVc7rmaIWFgLTyoT9297QEBsKXbF2TVtrJwB0qbOpASGWtkg00TT6pCuBId8CVd4Q5O3n7n1MiEI040Le1udDSd2Qjb4J14gRTnX2bztKELZkI0K+18aKn1oX9pUuhNiXuF6Q+ZG7sswloOX7+JQY0h/h1m+uSpM+bxzxumk3wn6ycU8Ekf6o3jlrRXKy4CYsHy7AGtKm1AnVob47BmA8RevXD7AllJx0wpfrHEw40pSy/39Q8IvOVBwdbRfaMP9vfJZFpRskbCsDb0mdtfgYBcV7cjRpsUvf1yvmzfgdUi922vNVC/n7tPcBC2LHluOcklCxHEF/y+Btzw94kDq6otjnZzEKWPoG+OoI3xeOxgncQP77akdofH56Luf+bJ9tUOvh5Sn5OeMAaJnQLWnQgLtQ1JORQrGOKSDb7iN2fNuEaWBFGJS9tvTq7mqaVWmUeO5XfDaCQXHksjDuj2SBnNCmz8cy3A8xhTL2DkJ5IPcrXpskD28EV/Si179dRP6NpauoWhsf32dsr4Igm9AlRxrQxMaXEPOy60uwSQeNFkpnJo0niSUBRxOhuL7Mko3fUImk87uA5qvhZ7BQRgBmEV4WqL6fYBTBGOuBB/Bd1YFVRl2HCliYbljQiaNpnlphXV5E8+RcslqGrMb7gjtS6NUdo2oVf3iVQTKg9tMo+E2a/+z/adyf3QrbMFkENNztp6o5d5MoEiC4GaTEcB2bNY3/Y0YZUNGRtq6vzXIuL11RSRipoKVWacOk115SIyVAoUQaMxXvjUG7vioqS/XcC4jil7iheFvRnN32I6kD2Q3cFDqZhHvx0FGuEOMhoXMo9VmEypFG3nQQiioKUMp8XoW2JpElNBZOLkRC4NI9jcdCmfCaoIpIcEg9txE2rSlOSJZZoh/AydG8Luiw2NejSF3ICX90WgfiSV6nwwevxX3rHvrV+FJYYyRO0LUXXGdwN0r6nLA3qoH8+pV8CJJ52MdOROUX6dw5KGSMhwyEksIasr6Ngp/9K/JdsH86jBfXuVBstPsMVpg29xQ4ApM6YVU3idv0Rvngx4AnjhFWnJw92WW6CBYVAusBheWgCMj/TS1rJi+kYIP2X1gAvee2PGnjyizXQI2lTO5QXlcI+ke8GumJGfY+4COTWUFipyEOJ7ls0FjxBfux8RpD3ZhPTYHc1TdUTUw95j1gHoo/uFv351mlgcy2GliDJQNQmjMz9YMGZcWMsJz2kLfn6m5eNoa1ppH6SpKbyzWlpLr0rS7qLSCt2++yTh7oFrdYO52l1v0yrmn6gm7fCk/SXFbd2FUWL4s31i4raXKpVpftOz/bpCQhY5+IqFAt1EwBQ1j47oCWsjATrV8rQ+s4FlB4RrMrq3jSnBaiijP2b0ILXSg77LXhhU08q33qzwmOCaKDtcudoP1VlP+XfajQIdx6zlr5TLPRlRMF27jQ5/t3QdnmrwtRGMESfsd5QWJDRP0QFZuveOTK+cS30Tb0S96jFLPaipKqfNF39jGjbsNj++X/3YJbi8YOAqNFtk3I0cbHW2vus2Zl4xySHBFyhNerQ7eClhR1M/3WYoDFbr2JI+EBtz3E2j/MBZVc8b3UNJlDv9UZqH1cfRJnMu1QgVc9xe037O/7PTW91J+tGY137BlyYamXv/XvFicjNhmRNUhaJCWC6oLCXCLlAhPtu8bxFqtHNCMQrBBEp1B+T7HDtI60V5JKehsFN4sGizfN6ZxTQ0Cwiko9aO9eGTpmFg52QOKdSdhQSL4bjqQ9tFfnqdfItHtSrWfh4EjEAQK3ocC+lgISSa96Xhf5iT9LvbuEy53QSLSYfqkSSONOrx8Pt6YEkPG+oKkKh30fn1UhZmfWu5KYuJiDttdxYmOKSXfIP8Gu4Lj1EoMCfUIiHzYcMNNm+73x+RlZltO+KO/wPq065o4qaFlgGPnAp+RWcmQ6qWABFZPRN/dD+m8Uht5XSCty2g9F8CRHyzyGr8ZHzhN9IeElBAm9LPWqJDtjTdE1VzU9pMBOxMs4V/FdkTUoz5mbNI6MIJ7nKpSA5jUz6REUu2qqW09N9bo83Z/gceHl+0ATfS+zrM240/YwHyiH8GFMGay1hbEsKE9BMrEv+IY5GlhYQ0GrXE0TV6eIWyuAad8hFQbyPyrGrFib4411Uz1UVoZNmHcePMWCrrahBU8Gi1dy294hrFuJjxkvnAU/GWHKrlINd62pdyL0k0UgXOex1mrboyhEiTR6xjU2CPgiwRYspM33qnMyPgadJ8tTyYZC5bGqwzxTt522BMWKmJpFWxCa1xPqI/c1cNu9xA1m4Q3Th1GIXVvVdnXeKQvOkGTSzpiqkAs6fttJW4EBOjGn/msLmhsZpGe88O+vkWKyDJw/hbXmNqZywxe9TkGHTP32SHPvQUI/GrJ5poP/JUb6Km9GAJs0p5uQazR2Njv67RbnLV+Frze2tXf0+VueKko07Yfx/NgqxrI/nlHpq8pKHtYuryBBBYIFKbbk+H5qu/R9oSuJo5tmIyTrxcVldwaH43jNQQcnXlCquJnj0TQJatsjEF+ILSLAlcjh3bDnWn5zmJ3X6kpyl/Y7x3B+b7lnq0KuAUZobAcZq313Hhb5fxCeEVtXutdWwzjuBrmZz+nfDcuwEHuBzWQTe/Ny57R0RlpJFMJVVyfu77Y3UuHaqBGBP6VG/12SBN/pLOEFqvshmCmdKeIZYPP+J8OMq5qz12/XfpFIHNsIA+vWdvboE+9pat76Akqaip+HOF8+Wbe6YXDaLOUJSfmPbx+/52EUfj46Lf5D5CNeSkVg2AEdMgSt+ox89l0Jo6ri97eZ+MCWvb37RtLEJzeuEvYJykf1xksNsbk0JchsefnaoY3TPPeFL/Uw+jXx7Ow4uyW2IdKWl/XZz430ZbPqXtPZ8iXyPCt3m2qBOoqvu56/JBIOQ0ZfkqWjqzTh/TLYvqDo9i1pADEpKqWG+XIrghzXR1Eb5nmjKOWxWiWNQBdIVarfnLmqZMnQqgD4CYynh18hbek13u2aXryMzK75rBv/yf02OCJ2Dq3h+G+4MQtA8SzBaJAV7htb4DUtnSmsVpq8Bis3aEQ31iY1bX0arSH7Eu8QgQctZjd3oV98BOkxsOY+x1mnLzdJcL2g678Y1Fw64a3t6K+0GOKeJ65vyiPhyUwPFjwXPDXaCbREM64ZtMUsdh8h5uKTGR+EHaOk51CaayUyh4R45H+XyJexnInfbykLFlzmDYLZ3ieQ/ibxBUSWaOda7MAlY4Eo1KbT78d1LlH8T79Qosts5EfGamjNVACX7RMgfDZvRLru+q3zxL5Is3Nar1oyRNQ/O67f6EDlO0JZd/9nynsNmP+snXjQh6U13NW+cVutR2A8OK5cgOS0qGZtBLnkB2FUTF7ztVXnJ/T8ieympNXGfCdjvck0NYVRiw9XejvZz8tSjXIs/ob++QBHhQ9a7sKpm8ugFc+pONjAUj110Bbk60UzQ4pD9t/GKZWnmsnd0sxZqiVRXzxlPxEiCUCEUnMtGqotfP2FdVFWjOvzuNROt3fG2s8nAXk6UYaQPiXOtX0L14/fERXykv60iyp5VJ/IR9n0/HDaARBQJaNOK8lALOQZRldgdMqD5fJOQTEm8u6vfGAaBCKSG1XYrF4n1iw4F597E5MoWa7y/eMV8mRk2KzCvP9s90p+U5o0ThBqLZzgXFVpjAerCqr6TfuJ9LzQFBu9q3fdd6bli+lhQv7192c1JeiHCyzEHqqxQg1UKD1IG4sh+sVzpCJ4UEZWAlkHYXSi/Q8TsIv+YQSQdCKydAOkvrJvpb55VPB1y9ySSnKfOmSw6dBEQYQi88jGAF4iC/WeZu+/rvkr8kstwaCnJoU+G+v+fXXVJem/vEZC7m+DALdB49RY089+FHyYp/a+Ahrp7rfFrJIDLyiYU0+BaLU+5k4JIRlO4jToa5AwJYGlRH6U6sYpSnYAklpzJ5vWd/4tl2n+7GC5ujeKWzG+0BzKRJ9uxg4hFxOEgSH2CZjqxS212crOQZARq1//tsgsxiVLH2xZBu19h45+HnN4s4RRVxHVJqs5QInSTG4CTx00wIZPAWeVXKswP7QNrGTa2jnts1/mRzl1NfqLdl2mdOFd5yEr049my0Ggd+1vONwCJIxnWD/H5QGXSi6RadIUER6nUEFTtoVZxMOuOXBK/+jytNhB8ORIck+5N96nyz3V4hddfTylHCwsFd7eZBFEfMT1Cza5geAZWgNNHz8EUUfa0ZwrenAGRVMvmcV1hLs17n02CsoAuh2IWDpu7fn0ZvvaHzCBjUeLZz16Rm2pn/N6r/k6bcHMtECR0/prWzcfY4RzvKwyJCVzEKN0UIEm3ywaxunYR0f6rhP22FVSAZnfolB0g2HgFiu8xouDY3K1Yd6GskFq4FISZm+9tlwyOaYhUH6LPJZry02N0b8c1vW8e7naHAH9kQx4Ib4cGvGSP9hQAJCG0v9LztWrGtCWQmM8lW7NcraJ5U/QRoMWi9YGKMymNZn7thtHKb6ux8qW1838Puc6udjKl8Vbe1R7SBhp5IpVZFNTU4YzTUpb4ATmrnbsLC9Ax27NDvC8DAOY3ShCQWoLA1K7APHgorstommr58tDQ0C71JptI44M/CvkBmRT50id3XC4BJfZWE6WM+3aylRn+56Eqd8vHumO+L6aofOHFM0SPZEfXh9BQegskB5APv8rZMZshnhYuiTYWQIi4U0YNTfVMLgrYn2re9ulSb7VFmDMNheUI+BjqXBufykjHPs5wCpgJL+kIOp/mZSMDejB4yFIU5zvIepK4jgFQg3AKC252MpwG8cBE1yYBkeTWFwt/3dVmqEjKJ+qEy+0EoKqPurJDJm5FYA8TjgF+GdTlf/VoOuTSULUHdilHiFg9QeiHY5pv3mdYTeBYdSbaR3isj5kkQxhXT0gMX/Xv4GS2Xy8HaPP3JpySXTv8cJXiLFiuZGStKeKo6EnP9AswNirrxURXxH1G9ZNUePs+VjXmPqyCz8mxD/B2OnmO3vTkAONd0hMNqALiE3ybIApKIjkZPTCP5W+w8G/iDgW2d704Srk+mxIAuvYpgCLcMdriySuZ96RedvJG4XtvbDk1Ejb2nzjDOXDrrHYjVtgVXinDGbgKUdUa82Bjac5NKEGNCcYOSkTm0gaSrHCzf/cwIfdqEWz87vlchwJooENWrua8FZDuPkQ2HbzGqxZlPa3fd75s12UpMcXcurb3Nj1wLTr3/pTBNB72gAz52G3j+g4nEETmkgrip7mReyhZiYGl8GyfUilWsVqUC1ra2yAl8s5AKrrV+gISjy42Id691RLpzsjhPRlEDeU5IbXudoDM5tHwda7necHGw3sFwsG7ydbiuDWZcn1MtMSTkdyoMOQmZyHub+Q9UV7xFHkbs3vdfTzWzszhE+7OInSp8FYCxP6WWRfMFCc9E9pQNe9NAOm26rpP9Hb3m/rR8sggjasUP0RKMeOyOJylzd9iMrZnMYgpZCtVD6WH/KD/egJgGDF3P4P6HMLgdtZN0J5d0MLiIX8tQeK8q1xqCp6B2J8BVzurpv4BfxAPdn8xosS4o2ufi63H/+Q/N8e56j43fYokdIxZYvTNZklj7EAgGg/dRffTrhcWiC2Vr7uv2ERzXOT1GJoheVHHAtrOWINeeKzKSP8IlPSBx879Nzkva75N/zxQLWeYZRuLLA1s4HEilW0PqXoPz0fDm/LeaO7+QsfVBk/ES1RWuPNeio1M7DZp2wbjbbTzb01FIvgVxfmuzCMqGJzwfsTeUVHXYgLoRS+c3TmTt6mThMv/Hst+5BCj3QmoTkhWnAYtrhRCmyMoViDQ4pTMjYvor3gs+DeEEvjJm3hF7qdz1yYa6PrpmyX9maghDoeFi80gynC6WloOaWhUfVYaPn8CUFxE3TWhX0XVjCNxL8ZR9uWXd3E00xSq0RH5b8pT2RzULARpMKrJZ6XiXfqOWRaxWBs7VHkmBk2MV6AYqnME84M68r8gcXUOjJ2wbY+zOxgQthzGJQmfDnsDWmwB9hL/JWxggG+tGWknGhGOGC35HO/K+vMzuxI/NP14xkPiOKFf1SHGq24qbpCJzvAwBGHVwVYabxxmXF4msVKg+SrrRIGpq7IEdoXjQHWcXIBBdO9QAm3UkGP/1No4u194d77AYNiT1IMJXFmFckaNddIW6bt5x1gy1dhiXLv9037QiWcOdDyOuLN0MPO1d+rVpRT1ySOFPzBCEUpu7/YscOOPqRHj0lTsbgsNpSGtC1jlfnPJSRYZWyYCHbKq/0WfBhNAgVpivTfwtj1ZZiRX4wcXCF0dzdS8IerXdgWfCJZhYbZxYhhUvjQs6mwqgPb0kQ7HsfKEqkEx7S4Sv43eK/7+cnBJ2C/lDxSKm79L7Gu/h/0mJKCTaXo8/NeUcC78fAeB3tm0LAHgqbZH08Te3K/2ul2N3HBfvMtwzaFSGihIqp+DbmFGwLmhaT8nbFKuhmTe7JsZCecjQKGoxOAZ+GR98RaEHepIJZIlw4irM4POhCQrGxl9YvwAn2lZ/U1SkdBGL/3vEnGl0bMkY3iLKnpuaGnU4uZ8/zrhA==` -) - -func TestDecryptResponse(t *testing.T) { - - privateKey, err := seclib2.DecodePrivateKey([]byte(privateKeyString)) - if err != nil { - t.Fatalf("decodePrivateKey fail %s", err) - } - - resp := Response{} - err = xml.Unmarshal([]byte(encryptedResp), &resp) - if err != nil { - t.Fatalf("unmarshal xml fail %s", err) - } - - if resp.EncryptedAssertion != nil { - asserText, err := resp.EncryptedAssertion.EncryptedData.decryptData(privateKey) - if err != nil { - t.Fatalf("EncryptedAssertion.EncryptedData.decryptData fail %s", err) - } - lastKey := "" - lastIndex := strings.Index(string(asserText), lastKey) + len(lastKey) - t.Logf("Decrypted assertion: len(assertion)=%d lastIndex=%d", len(asserText), lastIndex) - - assertion := Assertion{} - err = xml.Unmarshal(asserText, &assertion) - if err != nil { - t.Fatalf("xml.Unmarshal fail %s", err) - } - - encAsset, err := xml.MarshalIndent(assertion, "", " ") - if err != nil { - t.Fatalf("xml.MarshalIndent fail %s", err) - } - - t.Logf("assertion: %s", encAsset) - } -} diff --git a/pkg/util/samlutils/sp/idp.go b/pkg/util/samlutils/sp/idp.go index 70e6440c33..56077914ed 100644 --- a/pkg/util/samlutils/sp/idp.go +++ b/pkg/util/samlutils/sp/idp.go @@ -18,9 +18,9 @@ import ( "net/url" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/samlutils" ) type SSAMLIdentityProvider struct { diff --git a/pkg/util/samlutils/sp/sp.go b/pkg/util/samlutils/sp/sp.go index 2df20a06f0..33d17cdd7e 100644 --- a/pkg/util/samlutils/sp/sp.go +++ b/pkg/util/samlutils/sp/sp.go @@ -25,11 +25,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/samlutils" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/samlutils" ) type SSAMLAttribute struct { diff --git a/pkg/util/seclib2/certfile.go b/pkg/util/seclib2/certfile.go index 4a909c2e15..695b2b589b 100644 --- a/pkg/util/seclib2/certfile.go +++ b/pkg/util/seclib2/certfile.go @@ -16,16 +16,11 @@ package seclib2 import ( "crypto/rsa" - "crypto/x509" - "encoding/pem" "fmt" "io/ioutil" - "regexp" "strings" - "yunion.io/x/pkg/errors" - - "yunion.io/x/onecloud/pkg/httperrors" + "yunion.io/x/pkg/util/seclib" ) const ( @@ -65,22 +60,9 @@ func MergeCaCertFiles(cafile string, certfile string) (string, error) { } func CleanCertificate(cert string) string { - re := regexp.MustCompile("---(.*)CERTIFICATE(.*)---") - cert = re.ReplaceAllString(cert, "") - cert = strings.Trim(cert, " \n") - // cert = strings.Replace(cert, "\n", "", -1) - return cert + return seclib.CleanCertificate(cert) } func DecodePrivateKey(keyString []byte) (*rsa.PrivateKey, error) { - block, _ := pem.Decode(keyString) - privKey, err := x509.ParsePKCS8PrivateKey(block.Bytes) - if err == nil { - return privKey.(*rsa.PrivateKey), nil - } - priv, err := x509.ParsePKCS1PrivateKey(block.Bytes) - if err == nil { - return priv, nil - } - return nil, errors.Wrap(httperrors.ErrInvalidFormat, "not a valid private key") + return seclib.DecodePrivateKey(keyString) } diff --git a/pkg/util/seclib2/passwd.go b/pkg/util/seclib2/passwd.go index 9589c2743e..ba83d9c20f 100644 --- a/pkg/util/seclib2/passwd.go +++ b/pkg/util/seclib2/passwd.go @@ -15,18 +15,14 @@ package seclib2 import ( - "fmt" - - "github.com/tredoe/osutil/user/crypt/sha512_crypt" + "github.com/tredoe/osutil/v2/userutil/crypt/sha512_crypt" "golang.org/x/crypto/bcrypt" "yunion.io/x/pkg/util/seclib" ) func GeneratePassword(passwd string) (string, error) { - salt := seclib.RandomPassword(8) - sha512Crypt := sha512_crypt.New() - return sha512Crypt.Generate([]byte(passwd), []byte(fmt.Sprintf("$6$%s", salt))) + return seclib.GeneratePassword(passwd) } func VerifyPassword(passwd string, hash string) error { diff --git a/pkg/util/seclib2/seclib.go b/pkg/util/seclib2/seclib.go index 0cb1f0f689..9f12ff8e7b 100644 --- a/pkg/util/seclib2/seclib.go +++ b/pkg/util/seclib2/seclib.go @@ -15,114 +15,18 @@ package seclib2 import ( - "bytes" - "fmt" - "math/rand" - "strings" - + "yunion.io/x/pkg/util/seclib" "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/httperrors" ) -const ( - DIGITS = "23456789" - LETTERS = "abcdefghjkmnpqrstuvwxyz" - UPPERS = "ABCDEFGHJKMNPRSTUVWXYZ" - PUNC = "@^-+=" - - ALL_DIGITS = "0123456789" - ALL_LETTERS = "abcdefghijklmnopqrstuvwxyz" - ALL_UPPERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - ALL_PUNC = "~`!@#$%^&*()-_=+[]{}|:';\",./<>?" -) - -type PasswordStrength struct { - Digits int - Lowercases int - Uppercases int - Punctuats int - Invalid []byte -} - -var WEAK_PASSWORDS []string = []string{ - "Huawei@", "huawei@", "Admin@", "admin@", "Root@", "root@", "ABC@", "abc@", "ABCD@", "abcd@", "Huawei123@", "huawei123@", "Admin123@", "admin123@", "Root123@", "root123@", "Huawei#", "huawei#", "Admin#", "admin#", "Root#", "root#", "ABC#", "abc#", "ABCD#", "abcd#", "Huawei123#", "huawei123#", "Admin123#", "admin123#", "Root123#", "root123#,Huawei!", "huawei!", "Admin!", "admin!", "Root!", "root!", "ABC!", "abc!", "ABCD!", "abcd!", "Huawei123!", "huawei123!", "Admin123!", "admin123!", "Root123!", "root123!", "ABC123!", "abc123!", "Huawei@123", "huawei@123", "Admin@123", "admin@123", "Root@123", "root@123", "ABC@123", "abc@123", "123@Huawei", "123@Root", "123@abc", "Huawei123", "huawei123", "Admin123", "admin123", "Root123", "root123", "abc123", "Huawei_123", "huawei_123", "Admin_123", "admin_123", "Root_123", "root_123", "ABC_123", "abc_123", "123abc", "123abcd", "1234abc", "1234abcd", "abcd123", "abc1234", "abcd1234", "abcd@1234", "abcd1234!", "abcd_1234", "a123456", "123.com", "123@com", "123_com", "Huawei!@#", "huawei!@#", "Admin!@#", "admin!@#", "Root!@#", "root!@#", "Huawei!@", "huawei!@", "Admin!@", "admin!@", "Root!@", "root!@", "Huaweiroot", "HuaweiRoot", "huaweiroot", "huaweiRoot", "Huaweiadmin", "HuaweiAdmin", "huaweiadmin", "huaweiAdmin", "Adminroot", "AdminRoot", "adminRoot", "adminroot", "Rootadmin", "RootAdmin", "rootAdmin", "rootadmin", "Rootroot", "RootRoot", "rootroot", "Administrator", "Password", "Password123", "Password@123", "Password_123", "Password123!", "DDM@123", "ddM@123", "dDm@123", -} - -var CHARS = fmt.Sprintf("%s%s%s%s", DIGITS, LETTERS, UPPERS, PUNC) - func RandomPassword2(width int) string { - for { - password := randomPassword2(width) - if !utils.IsInStringArray(password, WEAK_PASSWORDS) { - return password - } - } + return seclib.RandomPassword2(width) } -func randomPassword2(width int) string { - if width < 6 { - width = 6 - } - for { - ps := PasswordStrength{} - var buf bytes.Buffer - for i := 0; i < width; i += 1 { - var ch byte - for { - index := rand.Intn(len(CHARS)) - ch = CHARS[index] - if i == 0 && ch == '/' { - continue - } - break - } - if strings.IndexByte(DIGITS, ch) >= 0 { - ps.Digits += 1 - } else if strings.IndexByte(LETTERS, ch) >= 0 { - ps.Lowercases += 1 - } else if strings.IndexByte(UPPERS, ch) >= 0 { - ps.Uppercases += 1 - } else if strings.IndexByte(PUNC, ch) >= 0 { - ps.Punctuats += 1 - } - buf.WriteByte(ch) - } - if ps.Digits > 1 && ps.Lowercases > 1 && ps.Uppercases > 1 && ps.Punctuats >= 1 && ps.Punctuats <= 2 { - return buf.String() - } - } -} - -func AnalyzePasswordStrenth(passwd string) PasswordStrength { - ps := PasswordStrength{Invalid: []byte{}} - - for i := 0; i < len(passwd); i += 1 { - if strings.IndexByte(ALL_DIGITS, passwd[i]) >= 0 { - ps.Digits += 1 - } else if strings.IndexByte(ALL_LETTERS, passwd[i]) >= 0 { - ps.Lowercases += 1 - } else if strings.IndexByte(ALL_UPPERS, passwd[i]) >= 0 { - ps.Uppercases += 1 - } else if strings.IndexByte(ALL_PUNC, passwd[i]) >= 0 { - ps.Punctuats += 1 - } else { - ps.Invalid = append(ps.Invalid, passwd[i]) - } - } - return ps -} - -func (ps PasswordStrength) Len() int { - return ps.Punctuats + ps.Uppercases + ps.Lowercases + ps.Digits -} - -func (ps PasswordStrength) MeetComplexity() bool { - if ps.Punctuats > 0 && ps.Digits > 0 && ps.Lowercases > 0 && ps.Uppercases > 0 && ps.Len() >= 12 { - return true - } else { - return false - } +func AnalyzePasswordStrenth(passwd string) seclib.PasswordStrength { + return seclib.AnalyzePasswordStrenth(passwd) } func ValidatePassword(passwd string) error { @@ -130,16 +34,12 @@ func ValidatePassword(passwd string) error { if len(ps.Invalid) > 0 { return httperrors.NewInputParameterError("invalid characters %s", string(ps.Invalid)) } - if utils.IsInStringArray(passwd, WEAK_PASSWORDS) || !ps.MeetComplexity() { + if utils.IsInStringArray(passwd, seclib.WEAK_PASSWORDS) || !ps.MeetComplexity() { return httperrors.NewWeakPasswordError() } return nil } func MeetComplxity(passwd string) bool { - if utils.IsInStringArray(passwd, WEAK_PASSWORDS) { - return false - } - ps := AnalyzePasswordStrenth(passwd) - return ps.MeetComplexity() + return seclib.MeetComplxity(passwd) } diff --git a/pkg/util/seclib2/seclib_test.go b/pkg/util/seclib2/seclib_test.go index 8aecc168e5..6300ba47fa 100644 --- a/pkg/util/seclib2/seclib_test.go +++ b/pkg/util/seclib2/seclib_test.go @@ -19,8 +19,9 @@ import ( "testing" "time" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/httputils" ) func TestRandomPassword2(t *testing.T) { diff --git a/pkg/util/shellutils/doc.go b/pkg/util/shellutils/doc.go deleted file mode 100644 index 8db8f1c1c0..0000000000 --- a/pkg/util/shellutils/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// 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 shellutils // import "yunion.io/x/onecloud/pkg/util/shellutils" diff --git a/pkg/util/streamutils/doc.go b/pkg/util/streamutils/doc.go deleted file mode 100644 index 522d85d03f..0000000000 --- a/pkg/util/streamutils/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// 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 streamutils // import "yunion.io/x/onecloud/pkg/util/streamutils" diff --git a/pkg/util/version/doc.go b/pkg/util/version/doc.go deleted file mode 100644 index b5073f21f4..0000000000 --- a/pkg/util/version/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// 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 version // import "yunion.io/x/onecloud/pkg/util/version" diff --git a/pkg/util/version/version_test.go b/pkg/util/version/version_test.go deleted file mode 100644 index 0ec6c90b1a..0000000000 --- a/pkg/util/version/version_test.go +++ /dev/null @@ -1,54 +0,0 @@ -// 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 version - -import "testing" - -func TestVersion(t *testing.T) { - if !LE("1.2.3", "1.2.4") { - t.Errorf(`!LE("1.2.3", "1.2.4")`) - } - if !LE("1.2.4", "1.2.4") { - t.Errorf(`!LE("1.2.4", "1.2.4")`) - } - if LE("1.2.5", "1.2.4") { - t.Errorf(`!LE("1.2.5", "1.2.4")`) - } - if !LT("1.2.3", "1.3.1") { - t.Errorf(`!LT("1.2.3", "1.3.1")`) - } - if LT("1.2.4", "1.2.4") { - t.Errorf(`LT("1.2.4", "1.2.4")`) - } - if LT("1.2.4.1", "1.2.4") { - t.Errorf(`LT("1.2.4.1", "1.2.4")`) - } - - if GT("1.2.3", "2.3.4.1") { - t.Errorf(`GT("1.2.3", "2.3.4.1")`) - } - if !GT("2.12.1", "2.9.2") { - t.Errorf(`GT("2.12.1", "2.9.2")`) - } - if GT("2.12.1", "2.12.1") { - t.Errorf(`GT("2.12.1", "2.12.1")`) - } - if !GE("2.12.1", "2.12.1") { - t.Errorf(`!GE("2.12.1", "2.12.1")`) - } - if !GE("2.12.1", "2.9.2") { - t.Errorf(`GE("2.12.1", "2.9.2")`) - } -} diff --git a/pkg/util/vmdkutils/doc.go b/pkg/util/vmdkutils/doc.go deleted file mode 100644 index eee5bb926d..0000000000 --- a/pkg/util/vmdkutils/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// 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 vmdkutils // import "yunion.io/x/onecloud/pkg/util/vmdkutils" diff --git a/pkg/util/vmdkutils/vmdkutils_test.go b/pkg/util/vmdkutils/vmdkutils_test.go deleted file mode 100644 index 93a7ceecf4..0000000000 --- a/pkg/util/vmdkutils/vmdkutils_test.go +++ /dev/null @@ -1,58 +0,0 @@ -// 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 vmdkutils - -import "testing" - -const ( - VMDKContent = ` version=1 - encoding="UTF-8" - CID=ab798ecb - parentCID=ffffffff - isNativeSnapshot="no" - createType="vmfs" - - # Extent description - RW 62914560 VMFS "c8336ec2-3885-4205-a2f1-095e48228a56-flat.vmdk" - - # The Disk Data Base - #DDB - - ddb.adapterType = "lsilogic" - ddb.deletable = "false" - ddb.geometry.cylinders = "62415" - ddb.geometry.heads = "16" - ddb.geometry.sectors = "63" - ddb.longContentID = "4d1762d22407e6b7e3e63557ab798ecb" - ddb.thinProvisioned = "1" - ddb.uuid = "60 00 C2 97 32 7d ac 2b-ac 97 a4 95 5b a6 0b c0" - ddb.virtualHWVersion = "13" -` -) - -func TestParseStream(t *testing.T) { - info, err := Parse(VMDKContent) - if err != nil { - t.Errorf("parse error %s", err) - } - t.Logf("%#v", info) - - _, err = Parse("") - if err != nil { - t.Logf("parse error %s", err) - } else { - t.Errorf("should parse error") - } -} diff --git a/pkg/vpcagent/ovn/worker.go b/pkg/vpcagent/ovn/worker.go index 88ba5aa538..3756efd9c3 100644 --- a/pkg/vpcagent/ovn/worker.go +++ b/pkg/vpcagent/ovn/worker.go @@ -23,13 +23,13 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/onecloud/pkg/apihelper" apis "yunion.io/x/onecloud/pkg/apis/compute" "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/mcclient/auth" mcclient_modules "yunion.io/x/onecloud/pkg/mcclient/modules/compute" - "yunion.io/x/onecloud/pkg/util/httputils" agentmodels "yunion.io/x/onecloud/pkg/vpcagent/models" "yunion.io/x/onecloud/pkg/vpcagent/options" "yunion.io/x/onecloud/pkg/vpcagent/ovnutil" diff --git a/pkg/vpcagent/service/service.go b/pkg/vpcagent/service/service.go index 58f2394a6e..5913f7581f 100644 --- a/pkg/vpcagent/service/service.go +++ b/pkg/vpcagent/service/service.go @@ -22,8 +22,8 @@ import ( "syscall" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" - "yunion.io/x/onecloud/pkg/appctx" app_common "yunion.io/x/onecloud/pkg/cloudcommon/app" common_options "yunion.io/x/onecloud/pkg/cloudcommon/options" "yunion.io/x/onecloud/pkg/vpcagent/options" diff --git a/pkg/webconsole/server/server.go b/pkg/webconsole/server/server.go index 05b031f400..c8a3ca352f 100644 --- a/pkg/webconsole/server/server.go +++ b/pkg/webconsole/server/server.go @@ -20,9 +20,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/appctx" api "yunion.io/x/onecloud/pkg/apis/compute" - "yunion.io/x/onecloud/pkg/appctx" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/webconsole/session" ) diff --git a/pkg/yunionconf/models/parameters.go b/pkg/yunionconf/models/parameters.go index 781b3381de..14ed83cafc 100644 --- a/pkg/yunionconf/models/parameters.go +++ b/pkg/yunionconf/models/parameters.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/sqlchemy" @@ -32,7 +33,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" modules "yunion.io/x/onecloud/pkg/mcclient/modules/identity" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/yunionconf/options" ) @@ -151,7 +151,7 @@ func getNamespaceInContext(userCred mcclient.TokenCredential, query jsonutils.JS func getNamespace(userCred mcclient.TokenCredential, resource string, query jsonutils.JSONObject, data *jsonutils.JSONDict) (string, string, error) { var namespace, namespace_id string - if userCred.IsAllow(rbacutils.ScopeSystem, consts.GetServiceType(), resource, policy.PolicyActionList).Result.IsAllow() { + if userCred.IsAllow(rbacscope.ScopeSystem, consts.GetServiceType(), resource, policy.PolicyActionList).Result.IsAllow() { if name, nameId, e := getNamespaceInContext(userCred, query, data); e != nil { return "", "", e } else { @@ -170,12 +170,12 @@ func (manager *SParameterManager) CreateByInsertOrUpdate() bool { return false } -func (manager *SParameterManager) NamespaceScope() rbacutils.TRbacScope { - return rbacutils.ScopeUser +func (manager *SParameterManager) NamespaceScope() rbacscope.TRbacScope { + return rbacscope.ScopeUser } -func (manager *SParameterManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeUser +func (manager *SParameterManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeUser } func (manager *SParameterManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) { @@ -213,10 +213,10 @@ func (manager *SParameterManager) ValidateCreateData(ctx context.Context, userCr return data, nil } -func (manager *SParameterManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacutils.TRbacScope) *sqlchemy.SQuery { +func (manager *SParameterManager) FilterByOwner(q *sqlchemy.SQuery, owner mcclient.IIdentityProvider, scope rbacscope.TRbacScope) *sqlchemy.SQuery { if owner != nil { switch scope { - case rbacutils.ScopeUser: + case rbacscope.ScopeUser: if len(owner.GetUserId()) > 0 { q = q.Equals("namespace_id", owner.GetUserId()).Equals("namespace", NAMESPACE_USER) } diff --git a/pkg/yunionconf/models/scopedpolicies.go b/pkg/yunionconf/models/scopedpolicies.go index e6c6e20418..2ee8d81c75 100644 --- a/pkg/yunionconf/models/scopedpolicies.go +++ b/pkg/yunionconf/models/scopedpolicies.go @@ -19,13 +19,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/yunionconf" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -194,12 +194,12 @@ func (policy *SScopedPolicy) PerformBind( input api.ScopedPolicyBindInput, ) (jsonutils.JSONObject, error) { switch input.Scope { - case rbacutils.ScopeSystem: + case rbacscope.ScopeSystem: err := ScopedPolicyBindingManager.bind(ctx, policy.Category, policy.Id, "", "") if err != nil { return nil, errors.Wrap(err, "bind system") } - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: for i := range input.TargetIds { if input.TargetIds[i] == api.ANY_DOMAIN_ID { err := ScopedPolicyBindingManager.bind(ctx, policy.Category, policy.Id, api.ANY_DOMAIN_ID, "") @@ -217,7 +217,7 @@ func (policy *SScopedPolicy) PerformBind( } } } - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: for i := range input.TargetIds { if input.TargetIds[i] == api.ANY_PROJECT_ID { err := ScopedPolicyBindingManager.bind(ctx, policy.Category, policy.Id, api.ANY_DOMAIN_ID, api.ANY_PROJECT_ID) diff --git a/pkg/yunionconf/models/scopedpolicybindings.go b/pkg/yunionconf/models/scopedpolicybindings.go index 41c0f736c8..1dfe5036f4 100644 --- a/pkg/yunionconf/models/scopedpolicybindings.go +++ b/pkg/yunionconf/models/scopedpolicybindings.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/sqlchemy" api "yunion.io/x/onecloud/pkg/apis/yunionconf" @@ -28,7 +29,6 @@ import ( "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/onecloud/pkg/util/stringutils2" ) @@ -142,8 +142,8 @@ func (manager *SScopedPolicyBindingManager) unbind(ctx context.Context, category return nil } -func (manager *SScopedPolicyBindingManager) ResourceScope() rbacutils.TRbacScope { - return rbacutils.ScopeProject +func (manager *SScopedPolicyBindingManager) ResourceScope() rbacscope.TRbacScope { + return rbacscope.ScopeProject } func (manager *SScopedPolicyBindingManager) getReferenceCount(policyId string) (int, error) { @@ -199,39 +199,39 @@ func (manager *SScopedPolicyBindingManager) ListItemFilter( query.DomainId = domainObj.Id } else { if len(query.Scope) == 0 { - query.Scope = rbacutils.ScopeProject + query.Scope = rbacscope.ScopeProject } switch query.Scope { - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: query.ProjectId = userCred.GetProjectId() query.DomainId = userCred.GetProjectDomainId() - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: query.DomainId = userCred.GetProjectDomainId() } } - var requireScope rbacutils.TRbacScope + var requireScope rbacscope.TRbacScope if len(query.ProjectId) > 0 { if query.ProjectId == userCred.GetProjectId() { // require project privileges - requireScope = rbacutils.ScopeProject + requireScope = rbacscope.ScopeProject } else if query.DomainId == userCred.GetProjectDomainId() { // require domain privileges - requireScope = rbacutils.ScopeDomain + requireScope = rbacscope.ScopeDomain } else { // require system privileges - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } } else if len(query.DomainId) > 0 { if query.DomainId == userCred.GetProjectDomainId() { // require domain privileges - requireScope = rbacutils.ScopeDomain + requireScope = rbacscope.ScopeDomain } else { // require system privileges - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } } else { - requireScope = rbacutils.ScopeSystem + requireScope = rbacscope.ScopeSystem } allowScope, _ := policy.PolicyManager.AllowScope(userCred, api.SERVICE_TYPE, manager.KeywordPlural(), policy.PolicyActionList) diff --git a/pkg/yunionconf/policy/defaults.go b/pkg/yunionconf/policy/defaults.go index 9bb9fc7e79..fd0d2caeb6 100644 --- a/pkg/yunionconf/policy/defaults.go +++ b/pkg/yunionconf/policy/defaults.go @@ -15,6 +15,8 @@ package policy import ( + "yunion.io/x/pkg/util/rbacscope" + api "yunion.io/x/onecloud/pkg/apis/yunionconf" common_policy "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/util/rbacutils" @@ -32,7 +34,7 @@ var ( predefinedDefaultPolicies = []rbacutils.SRbacPolicy{ { Auth: true, - Scope: rbacutils.ScopeUser, + Scope: rbacscope.ScopeUser, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -68,7 +70,7 @@ var ( }, { Auth: true, - Scope: rbacutils.ScopeProject, + Scope: rbacscope.ScopeProject, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, @@ -80,7 +82,7 @@ var ( }, { Auth: true, - Scope: rbacutils.ScopeDomain, + Scope: rbacscope.ScopeDomain, Rules: []rbacutils.SRbacRule{ { Service: api.SERVICE_TYPE, diff --git a/vendor/github.com/mozillazg/go-pinyin/.travis.yml b/vendor/github.com/mozillazg/go-pinyin/.travis.yml deleted file mode 100644 index 0ebe7c19f3..0000000000 --- a/vendor/github.com/mozillazg/go-pinyin/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -language: go -go: - - '1.7' - - '1.8' - - '1.9.x' - - '1.10.x' - - '1.11.x' - - '1.12.x' - - 'master' - -sudo: false - -before_install: - - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi - - go get github.com/mattn/go-isatty - - go get github.com/axw/gocov/gocov - - go get github.com/mattn/goveralls - -script: - - go run cmd/pinyin/main.go abc - - go run cmd/pinyin/main.go -s zhao abc - - echo "abc" | go run cmd/pinyin/main.go - - echo "abc" > abc.txt && go run cmd/pinyin/main.go < abc.txt - - $HOME/gopath/bin/goveralls -service=travis-ci -v -package . - -matrix: - allow_failures: - - go: master diff --git a/vendor/github.com/mozillazg/go-pinyin/CHANGELOG.md b/vendor/github.com/mozillazg/go-pinyin/CHANGELOG.md index e743d2b063..72c4811624 100644 --- a/vendor/github.com/mozillazg/go-pinyin/CHANGELOG.md +++ b/vendor/github.com/mozillazg/go-pinyin/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## [0.19.0] (2021-12-11) +* **Changed** 使用 [pinyin-data][pinyin-data] v0.12.0 的拼音数据 + + +## [0.18.0] (2020-06-13) +* **Changed** 使用 [pinyin-data][pinyin-data] v0.9.0 的拼音数据 +* **Bugfixed** 修复自定义的 Fallback 函数可能会导致结果乱码的问题 Fixes [#35] + +## [0.17.0] (2020-04-09) + +* **Changed** 因为依赖的 gojieba 经常出现安装异常,撤销 v0.16.0 的修改,撤销后 v0.17.0 的代码跟 v0.15.0 基本是一样的。 + 如果有需要使用 v0.16.0 新增的 ``func Paragraph(p string) string`` 功能的请使用 v0.16.0 版本或者通过 v0.16.0 中相关代码实现类似的需求。 + +## [0.16.0] (2019-12-05) + +* **NEW** 增加 ``func Paragraph(p string) string`` 用于便捷处理大段文字 +(thanks [@huacnlee] via [#37][#37]) + ## [0.15.0] (2019-04-06) * **Changed** 使用 [pinyin-data][pinyin-data] v0.7.0 的拼音数据 @@ -193,9 +211,12 @@ [pinyin-data]: https://github.com/mozillazg/pinyin-data [@wdscxsj]: https://github.com/wdscxsj +[@huacnlee]: https://github.com/huacnlee [#19]: https://github.com/mozillazg/go-pinyin/pull/19 [#20]: https://github.com/mozillazg/go-pinyin/pull/20 [#30]: https://github.com/mozillazg/go-pinyin/pull/30 +[#37]: https://github.com/mozillazg/go-pinyin/pull/37 +[#35]: https://github.com/mozillazg/go-pinyin/issues/35 [0.1.1]: https://github.com/mozillazg/go-pinyin/compare/v0.1.0...v0.1.1 [0.2.0]: https://github.com/mozillazg/go-pinyin/compare/v0.1.1...v0.2.0 @@ -213,3 +234,7 @@ [0.13.0]: https://github.com/mozillazg/go-pinyin/compare/v0.12.0...v0.13.0 [0.14.0]: https://github.com/mozillazg/go-pinyin/compare/v0.13.0...v0.14.0 [0.15.0]: https://github.com/mozillazg/go-pinyin/compare/v0.14.0...v0.15.0 +[0.16.0]: https://github.com/mozillazg/go-pinyin/compare/v0.15.0...v0.16.0 +[0.17.0]: https://github.com/mozillazg/go-pinyin/compare/v0.16.0...v0.17.0 +[0.18.0]: https://github.com/mozillazg/go-pinyin/compare/v0.17.0...v0.18.0 +[0.19.0]: https://github.com/mozillazg/go-pinyin/compare/v0.18.0...v0.19.0 diff --git a/vendor/github.com/mozillazg/go-pinyin/README.md b/vendor/github.com/mozillazg/go-pinyin/README.md index 6c158b76e2..d1feb97204 100644 --- a/vendor/github.com/mozillazg/go-pinyin/README.md +++ b/vendor/github.com/mozillazg/go-pinyin/README.md @@ -1,7 +1,7 @@ go-pinyin ========= -[![Build Status](https://travis-ci.org/mozillazg/go-pinyin.svg?branch=master)](https://travis-ci.org/mozillazg/go-pinyin) +[![Build Status](https://github.com/mozillazg/go-pinyin/actions/workflows/go.yml/badge.svg?branch=master)](https://github.com/mozillazg/go-pinyin/actions/workflows/ci.yml) [![Coverage Status](https://coveralls.io/repos/mozillazg/go-pinyin/badge.svg?branch=master)](https://coveralls.io/r/mozillazg/go-pinyin?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/mozillazg/go-pinyin)](https://goreportcard.com/report/github.com/mozillazg/go-pinyin) [![GoDoc](https://godoc.org/github.com/mozillazg/go-pinyin?status.svg)](https://godoc.org/github.com/mozillazg/go-pinyin) @@ -81,6 +81,14 @@ func main() { } ``` +注意: + +* 默认情况下会忽略没有拼音的字符(可以通过自定义 `Fallback` 参数的值来自定义如何处理没有拼音的字符, + 详见 [示例](https://godoc.org/github.com/mozillazg/go-pinyin#example-Pinyin--FallbackCustom1))。 +* 根据 [《汉语拼音方案》](http://www.moe.gov.cn/s78/A19/yxs_left/moe_810/s230/195802/t19580201_186000.html) y,w,ü (yu) 都不是声母, + 以及不是所有拼音都有声母,如果这不是你预期的话,你可能需要的是首字母风格 `FirstLetter` +( [详细信息](https://github.com/mozillazg/python-pinyin#%E4%B8%BA%E4%BB%80%E4%B9%88%E6%B2%A1%E6%9C%89-y-w-yu-%E5%87%A0%E4%B8%AA%E5%A3%B0%E6%AF%8D) )。 + Related Projects ----------------- diff --git a/vendor/github.com/mozillazg/go-pinyin/TODO.md b/vendor/github.com/mozillazg/go-pinyin/TODO.md new file mode 100644 index 0000000000..7cb88ec929 --- /dev/null +++ b/vendor/github.com/mozillazg/go-pinyin/TODO.md @@ -0,0 +1,4 @@ + + +* [ ] 重构 +* [ ] diff --git a/vendor/github.com/mozillazg/go-pinyin/pinyin.go b/vendor/github.com/mozillazg/go-pinyin/pinyin.go index f5a31f6f04..15b5938c63 100644 --- a/vendor/github.com/mozillazg/go-pinyin/pinyin.go +++ b/vendor/github.com/mozillazg/go-pinyin/pinyin.go @@ -7,7 +7,7 @@ import ( // Meta const ( - Version = "0.15.0" + Version = "0.19.0" Author = "mozillazg, 闲耘" License = "MIT" Copyright = "Copyright (c) 2016 mozillazg, 闲耘" @@ -19,7 +19,7 @@ const ( Tone = 1 // 声调风格1,拼音声调在韵母第一个字母上。如: zhōng guó Tone2 = 2 // 声调风格2,即拼音声调在各个韵母之后,用数字 [1-4] 进行表示。如: zho1ng guo2 Tone3 = 8 // 声调风格3,即拼音声调在各个拼音之后,用数字 [1-4] 进行表示。如: zhong1 guo2 - Initials = 3 // 声母风格,只返回各个拼音的声母部分。如: zh g + Initials = 3 // 声母风格,只返回各个拼音的声母部分。如: zh g 。注意:不是所有的拼音都有声母 FirstLetter = 4 // 首字母风格,只返回拼音的首字母部分。如: z g Finals = 5 // 韵母风格,只返回各个拼音的韵母部分,不带声调。如: ong uo FinalsTone = 6 // 韵母风格1,带声调,声调在韵母第一个字母上。如: ōng uó @@ -181,7 +181,7 @@ func toFixed(p string, a Args) string { switch a.Style { // 首字母 case FirstLetter: - py = py[:1] + py = string([]rune(py)[0]) // 韵母 case Finals, FinalsTone, FinalsTone2, FinalsTone3: // 转换为 []rune unicode 编码用于获取第一个拼音字符 @@ -219,7 +219,7 @@ func SinglePinyin(r rune, a Args) []string { } if len(pys) > 0 { if !a.Heteronym { - pys = pys[:1] + pys = []string{pys[0]} } return applyStyle(pys, a) } diff --git a/vendor/github.com/mozillazg/go-pinyin/pinyin_dict.go b/vendor/github.com/mozillazg/go-pinyin/pinyin_dict.go index 4799cb4a55..494a290ac8 100644 --- a/vendor/github.com/mozillazg/go-pinyin/pinyin_dict.go +++ b/vendor/github.com/mozillazg/go-pinyin/pinyin_dict.go @@ -94,6 +94,7 @@ var PinyinDict = map[int]string{ 0x3488: "hàn", 0x3489: "tǎng", 0x348A: "sè", + 0x348B: "sī", 0x348C: "qióng", 0x348D: "léi", 0x348E: "sà", @@ -167,6 +168,7 @@ var PinyinDict = map[int]string{ 0x34E9: "xuān,jiē", 0x34EA: "lǎng", 0x34ED: "shé", + 0x34EE: "diāo", 0x34EF: "lí", 0x34F0: "huà", 0x34F1: "tóu,shū", @@ -795,6 +797,7 @@ var PinyinDict = map[int]string{ 0x37D3: "qí", 0x37D4: "hán", 0x37D6: "lòng,lóng", + 0x37D7: "bīn", 0x37D8: "tiáo", 0x37D9: "zé", 0x37DA: "qí", @@ -1034,6 +1037,7 @@ var PinyinDict = map[int]string{ 0x38F5: "tà", 0x38F6: "zhān", 0x38F7: "nìng", + 0x38FA: "xīn", 0x38FB: "yì", 0x38FC: "rěn", 0x38FD: "shù,nù", @@ -1391,6 +1395,7 @@ var PinyinDict = map[int]string{ 0x3A82: "kū", 0x3A83: "hé", 0x3A84: "fú", + 0x3A85: "gèng,gēng", 0x3A86: "dǐ", 0x3A87: "xiàn", 0x3A88: "guì", @@ -1645,6 +1650,7 @@ var PinyinDict = map[int]string{ 0x3BC0: "xuàn", 0x3BC1: "péi", 0x3BC2: "dài", + 0x3BC3: "qī", 0x3BC4: "zhī", 0x3BC5: "pí,bī", 0x3BC6: "chǎn,shàn", @@ -1694,6 +1700,7 @@ var PinyinDict = map[int]string{ 0x3BF9: "biǎo", 0x3BFA: "jiàn", 0x3BFB: "gǔn", + 0x3BFD: "bīn", 0x3BFE: "zāo", 0x3BFF: "liè,là", 0x3C00: "lí", @@ -1934,7 +1941,7 @@ var PinyinDict = map[int]string{ 0x3D11: "sù", 0x3D12: "yì", 0x3D13: "shāi", - 0x3D14: "xī,yì,sè", + 0x3D14: "xī,jí,yì,sè", 0x3D15: "jí", 0x3D16: "luò", 0x3D17: "yōu", @@ -2801,6 +2808,7 @@ var PinyinDict = map[int]string{ 0x4100: "huò", 0x4101: "yì", 0x4102: "liù", + 0x4103: "yāng", 0x4104: "yīn", 0x4105: "juàn", 0x4106: "huó,huàn", @@ -4064,6 +4072,7 @@ var PinyinDict = map[int]string{ 0x4670: "lí", 0x4671: "dú", 0x4673: "biāo,è", + 0x4674: "qiān", 0x4675: "xī", 0x4677: "dé", 0x4678: "dé", @@ -5235,7 +5244,7 @@ var PinyinDict = map[int]string{ 0x4B75: "fán", 0x4B76: "qí", 0x4B77: "máo", - 0x4B78: "fù,bǎo", + 0x4B78: "fù", 0x4B79: "áng", 0x4B7A: "ǎng", 0x4B7B: "fēn,fù", @@ -5381,6 +5390,7 @@ var PinyinDict = map[int]string{ 0x4C14: "pán", 0x4C15: "lú", 0x4C16: "zuǎn", + 0x4C17: "jiū", 0x4C18: "liú,jiǎo", 0x4C19: "yǐ", 0x4C1A: "wén", @@ -5475,6 +5485,7 @@ var PinyinDict = map[int]string{ 0x4C7A: "hái", 0x4C7B: "huá", 0x4C7C: "zhǎn", + 0x4C7D: "chāng", 0x4C7E: "lóu", 0x4C7F: "chàn", 0x4C80: "zhì", @@ -5782,7 +5793,7 @@ var PinyinDict = map[int]string{ 0x4E0B: "xià", 0x4E0C: "jī,qí", 0x4E0D: "bù,fǒu,fōu,fū,bú", - 0x4E0E: "yǔ,yú,yù", + 0x4E0E: "yǔ,yù,yú", 0x4E0F: "miǎn", 0x4E10: "gài", 0x4E11: "chǒu", @@ -5810,7 +5821,7 @@ var PinyinDict = map[int]string{ 0x4E27: "sàng,sāng", 0x4E28: "gǔn", 0x4E29: "jiū", - 0x4E2A: "gè,gàn,gě", + 0x4E2A: "gè,gě,gàn", 0x4E2B: "yā", 0x4E2C: "qiáng", 0x4E2D: "zhōng,zhòng", @@ -5974,7 +5985,7 @@ var PinyinDict = map[int]string{ 0x4ECB: "jiè,gè", 0x4ECC: "bīng", 0x4ECD: "réng", - 0x4ECE: "cóng,cōng", + 0x4ECE: "cóng,zòng", 0x4ECF: "fó", 0x4ED0: "sǎn", 0x4ED1: "lún", @@ -5996,7 +6007,7 @@ var PinyinDict = map[int]string{ 0x4EE1: "gē,yì,wù", 0x4EE2: "bó", 0x4EE3: "dài", - 0x4EE4: "lìng,líng,lián,lǐng", + 0x4EE4: "lìng,líng,lǐng,lián", 0x4EE5: "yǐ,sì", 0x4EE6: "chào", 0x4EE7: "cháng", @@ -6004,7 +6015,7 @@ var PinyinDict = map[int]string{ 0x4EE9: "cháng", 0x4EEA: "yí", 0x4EEB: "mù", - 0x4EEC: "men", + 0x4EEC: "men,mén", 0x4EED: "rèn", 0x4EEE: "fǎn", 0x4EEF: "chào,miǎo", @@ -6015,7 +6026,7 @@ var PinyinDict = map[int]string{ 0x4EF4: "wò", 0x4EF5: "wǔ", 0x4EF6: "jiàn,móu", - 0x4EF7: "jià,jiè,jie", + 0x4EF7: "jià,jie,jiè", 0x4EF8: "yǎo,fó", 0x4EF9: "fēng", 0x4EFA: "cāng", @@ -6071,10 +6082,10 @@ var PinyinDict = map[int]string{ 0x4F2C: "ze", 0x4F2D: "xián", 0x4F2E: "nǔ", - 0x4F2F: "bó,mò,bà,bǎi", + 0x4F2F: "bó,bǎi,mò,bà", 0x4F30: "gū,gù", 0x4F31: "nǐ", - 0x4F32: "nì,nǐ", + 0x4F32: "nì,ní,nǐ", 0x4F33: "xiè", 0x4F34: "bàn,pàn", 0x4F35: "xù", @@ -6107,7 +6118,7 @@ var PinyinDict = map[int]string{ 0x4F50: "zuǒ", 0x4F51: "yòu", 0x4F52: "yǎng,yāng", - 0x4F53: "tǐ,bèn,cuì,tī", + 0x4F53: "tǐ,tī,bèn,cuì", 0x4F54: "zhàn,chān,diān", 0x4F55: "hé,hè", 0x4F56: "bì", @@ -6115,7 +6126,7 @@ var PinyinDict = map[int]string{ 0x4F58: "shé", 0x4F59: "yú,tú,xú,yù", 0x4F5A: "yì,dié", - 0x4F5B: "fú,bó,bì,fó", + 0x4F5B: "fú,fó,bó,bì", 0x4F5C: "zuò,zuō,zuó", 0x4F5D: "gōu,kòu,jū", 0x4F5E: "nìng", @@ -6408,7 +6419,7 @@ var PinyinDict = map[int]string{ 0x507D: "wěi,wéi,é,guì", 0x507E: "fèn", 0x507F: "cháng", - 0x5080: "guī,kuài,kuǐ", + 0x5080: "guī,kuǐ,kuài", 0x5081: "sǒu", 0x5082: "zhì,sī", 0x5083: "sù", @@ -6599,7 +6610,7 @@ var PinyinDict = map[int]string{ 0x513C: "yǎn", 0x513D: "léi,lěi,luǒ", 0x513E: "nàng", - 0x513F: "ér,rén", + 0x513F: "ér,er,rén", 0x5140: "wù,wū", 0x5141: "yǔn,yuán", 0x5142: "zān", @@ -6650,7 +6661,7 @@ var PinyinDict = map[int]string{ 0x5171: "gòng,gōng,gǒng,hóng", 0x5172: "tiān", 0x5173: "guān", - 0x5174: "xìng,xīng", + 0x5174: "xīng,xìng", 0x5175: "bīng", 0x5176: "qí,jī,jì", 0x5177: "jù", @@ -6796,7 +6807,7 @@ var PinyinDict = map[int]string{ 0x5203: "rèn", 0x5204: "rèn", 0x5205: "chuāng", - 0x5206: "fēn,fèn,fén,bàn", + 0x5206: "fēn,fèn,fén", 0x5207: "qiè,qiē,qì", 0x5208: "yì", 0x5209: "jī", @@ -6808,7 +6819,7 @@ var PinyinDict = map[int]string{ 0x520F: "jī", 0x5210: "dǎn", 0x5211: "xíng", - 0x5212: "huà,guò,guǒ,huá,huai", + 0x5212: "huà,huá,guò,guǒ,huai", 0x5213: "wán", 0x5214: "jué", 0x5215: "lí", @@ -6848,7 +6859,7 @@ var PinyinDict = map[int]string{ 0x5237: "shuā,shuà", 0x5238: "quàn,xuàn", 0x5239: "shā,chà", - 0x523A: "cì,qì,cī", + 0x523A: "cì,cī,qì", 0x523B: "kè,kēi", 0x523C: "jié", 0x523D: "guì", @@ -6864,7 +6875,7 @@ var PinyinDict = map[int]string{ 0x5247: "zé", 0x5248: "yuān", 0x5249: "cuò", - 0x524A: "xuē,qiào,xiāo,shào", + 0x524A: "xuē,xiāo,qiào,shào", 0x524B: "kè,kēi", 0x524C: "lá,là", 0x524D: "qián,jiǎn", @@ -6944,7 +6955,7 @@ var PinyinDict = map[int]string{ 0x5297: "jiǎn,zuān", 0x5298: "mó,mí", 0x5299: "lí", - 0x529A: "zhǔ", + 0x529A: "zhú", 0x529B: "lì", 0x529C: "yà", 0x529D: "quàn", @@ -7092,7 +7103,7 @@ var PinyinDict = map[int]string{ 0x532B: "hū", 0x532C: "yǔ", 0x532D: "guǐ", - 0x532E: "kuì", + 0x532E: "kuì,guì", 0x532F: "huì", 0x5330: "dān", 0x5331: "guì,kuì", @@ -7124,7 +7135,7 @@ var PinyinDict = map[int]string{ 0x534B: "shì", 0x534C: "xì", 0x534D: "wàn", - 0x534E: "huá,huà", + 0x534E: "huá,huà,huā", 0x534F: "xié", 0x5350: "wàn", 0x5351: "bēi,bǐ,bì,pí,bān", @@ -7278,15 +7289,15 @@ var PinyinDict = map[int]string{ 0x53E5: "jù,gōu,gòu,qú", 0x53E6: "lìng", 0x53E7: "guǎ", - 0x53E8: "dāo,tāo,dáo", + 0x53E8: "dāo,dáo,tāo", 0x53E9: "kòu", 0x53EA: "zhǐ,zhī", 0x53EB: "jiào", 0x53EC: "zhào,shào", 0x53ED: "bā,pā,ba", 0x53EE: "dīng", - 0x53EF: "kě,gē,kè", - 0x53F0: "tái,yí,sì,tāi", + 0x53EF: "kě,kè,gē", + 0x53F0: "tái,tāi,yí,sì", 0x53F1: "chì,huà,é", 0x53F2: "shǐ", 0x53F3: "yòu", @@ -7303,7 +7314,7 @@ var PinyinDict = map[int]string{ 0x53FE: "liǎo", 0x53FF: "hōng,hóng", 0x5400: "miē", - 0x5401: "xū,yù,yū", + 0x5401: "xū,yū,yù", 0x5402: "máng,màng", 0x5403: "chī,qī", 0x5404: "gè,gě", @@ -7321,7 +7332,7 @@ var PinyinDict = map[int]string{ 0x5410: "tǔ,tù", 0x5411: "xiàng", 0x5412: "zhā,zhà", - 0x5413: "xià,hà,hè", + 0x5413: "xià,hè,hà", 0x5414: "yě,yē", 0x5415: "lǚ", 0x5416: "yā,ā", @@ -7355,7 +7366,7 @@ var PinyinDict = map[int]string{ 0x5432: "yǐn,shěn", 0x5433: "wú,yú", 0x5434: "wú,tūn", - 0x5435: "chǎo,miǎo,chāo,chào", + 0x5435: "chǎo,chāo,miǎo,chào", 0x5436: "nà", 0x5437: "xuè,chuò,jué", 0x5438: "xī", @@ -7366,14 +7377,14 @@ var PinyinDict = map[int]string{ 0x543D: "hōng,ōu,hǒu", 0x543E: "wú,yú,yá", 0x543F: "gào", - 0x5440: "ya,xiā,yā", + 0x5440: "ya,yā,xiā", 0x5441: "jùn", 0x5442: "lǚ", - 0x5443: "è,ài,e", + 0x5443: "è,e,ài", 0x5444: "gé", 0x5445: "méi,wěn", 0x5446: "dāi,bǎo,ái", - 0x5447: "qǐ", + 0x5447: "qǐ,mèn", 0x5448: "chéng,kuáng,chěng", 0x5449: "wú", 0x544A: "gào,jū,gù", @@ -7387,10 +7398,10 @@ var PinyinDict = map[int]string{ 0x5452: "wǔ,ḿ", 0x5453: "yì", 0x5454: "dāi,tǎi", - 0x5455: "ǒu,òu", + 0x5455: "ǒu,ōu,òu", 0x5456: "lì", 0x5457: "bei,bài", - 0x5458: "yuán,yún,yùn", + 0x5458: "yuán,yùn,yún", 0x5459: "guō", 0x545A: "wen", 0x545B: "qiāng,qiàng", @@ -7401,7 +7412,7 @@ var PinyinDict = map[int]string{ 0x5460: "pěn", 0x5461: "wěn,mǐn", 0x5462: "ne,ní,nǐ,nī", - 0x5463: "ḿ,móu,m̀", + 0x5463: "ḿ,m̀,móu", 0x5464: "lìng,líng", 0x5465: "rán", 0x5466: "yōu", @@ -7431,7 +7442,7 @@ var PinyinDict = map[int]string{ 0x547E: "dá,yà,tǎ,dàn", 0x547F: "qù,kā", 0x5480: "jǔ,zuǐ", - 0x5481: "hán,xián,gàn", + 0x5481: "gàn,hán,xián", 0x5482: "zā", 0x5483: "tuō", 0x5484: "duō", @@ -7441,8 +7452,8 @@ var PinyinDict = map[int]string{ 0x5488: "fú", 0x5489: "yāng,yǎng", 0x548A: "hé", - 0x548B: "zǎ,zé,zhà,zhā", - 0x548C: "hé,hè,huò,huó,hú", + 0x548B: "zǎ,zé,zhā,zhà", + 0x548C: "hé,hè,hú,huó,huò,huo", 0x548D: "hāi,tāi", 0x548E: "jiù,gāo", 0x548F: "yǒng", @@ -7450,9 +7461,9 @@ var PinyinDict = map[int]string{ 0x5491: "dā", 0x5492: "zhòu", 0x5493: "wǎ", - 0x5494: "kā,nòng,kǎ", + 0x5494: "kā,kǎ,nòng", 0x5495: "gū,gu", - 0x5496: "kā,jiā,gā", + 0x5496: "kā,gā,jiā", 0x5497: "zuo", 0x5498: "bù", 0x5499: "lóng", @@ -7469,19 +7480,19 @@ var PinyinDict = map[int]string{ 0x54A4: "zhà", 0x54A5: "xì,xī,dié,zhì", 0x54A6: "yí,xī", - 0x54A7: "liě,liè,liē,lié,lie", + 0x54A7: "liě,liē,liè,lié,lie", 0x54A8: "zī", 0x54A9: "miē,mie", - 0x54AA: "mī,miē,mǎi,mǐ", + 0x54AA: "mī,mǐ,miē,mǎi", 0x54AB: "zhǐ", 0x54AC: "yǎo,jiāo,yāo,jiǎo", 0x54AD: "jī,xī,qià", 0x54AE: "zhòu,zhù,zhū,rú", - 0x54AF: "gē,luò,kǎ,kā,lo", + 0x54AF: "gē,kǎ,lo,luò,kā", 0x54B0: "shù,xún", 0x54B1: "zán,zá,zǎ,zan", 0x54B2: "xiào", - 0x54B3: "hāi,hái,ké,gāi", + 0x54B3: "ké,hāi,hái,gāi", 0x54B4: "huī,hái", 0x54B5: "kuǎ", 0x54B6: "huài,shì,guō,guā,huà", @@ -7498,11 +7509,11 @@ var PinyinDict = map[int]string{ 0x54C1: "pǐn", 0x54C2: "shěn", 0x54C3: "tóng", - 0x54C4: "hōng,hòng,hǒng", + 0x54C4: "hǒng,hōng,hòng", 0x54C5: "xiōng,hōng", 0x54C6: "duō,chǐ,zhà,chì,duò,diě", 0x54C7: "wa,wā,guī,huá,wá", - 0x54C8: "hā,hà,hē,hé,hǎ,tà,shà", + 0x54C8: "hā,hǎ,hà,hē,hé,tà,shà", 0x54C9: "zāi", 0x54CA: "yòu", 0x54CB: "diè,dì", @@ -7512,7 +7523,7 @@ var PinyinDict = map[int]string{ 0x54CF: "gén,hěn,ǹ", 0x54D0: "kuāng,qiāng", 0x54D1: "yǎ,yā", - 0x54D2: "dá", + 0x54D2: "dá,dā", 0x54D3: "xiāo", 0x54D4: "bì", 0x54D5: "huì,yuě", @@ -7535,8 +7546,8 @@ var PinyinDict = map[int]string{ 0x54E6: "ó,é,ò", 0x54E7: "chī,xià,hè", 0x54E8: "shào,sāo,xiāo,xiào,sào", - 0x54E9: "lī,lì,li,lǐ,mái,yīng", - 0x54EA: "nǎ,nuó,na,nǎi,nà,niè,né,něi", + 0x54E9: "lī,li,lì,lǐ,mái,yīng", + 0x54EA: "nǎ,na,né,nuó,nǎi,nà,niè,něi", 0x54EB: "zú", 0x54EC: "hé", 0x54ED: "kū", @@ -7567,7 +7578,7 @@ var PinyinDict = map[int]string{ 0x5506: "suō,shuà", 0x5507: "chún,zhēn,zhèn", 0x5508: "yì", - 0x5509: "āi,ǎi,ài", + 0x5509: "āi,ài,ǎi", 0x550A: "jiá,qiǎn", 0x550B: "tū", 0x550C: "xián,yán,dàn", @@ -7585,7 +7596,7 @@ var PinyinDict = map[int]string{ 0x5518: "qǐ", 0x5519: "dí", 0x551A: "qìn,qīn", - 0x551B: "mà", + 0x551B: "mà,mài", 0x551C: "mò", 0x551D: "gòng,hǒng", 0x551E: "dǒu", @@ -7623,7 +7634,7 @@ var PinyinDict = map[int]string{ 0x553E: "tuò", 0x553F: "hū", 0x5540: "ái", - 0x5541: "zhāo,dāo,zhōu,tiáo,diào", + 0x5541: "zhāo,zhōu,dāo,tiáo,diào", 0x5542: "nǒu", 0x5543: "kěn", 0x5544: "zhuó,zhòu", @@ -7632,7 +7643,7 @@ var PinyinDict = map[int]string{ 0x5547: "dì,shì,zhāi", 0x5548: "hēng,hèng,è,zá", 0x5549: "lín,lán,lèn", - 0x554A: "a,è,ā,á,ǎ,à", + 0x554A: "a,ā,á,ǎ,à,è", 0x554B: "cǎi,cāi,xiāo", 0x554C: "xiāng,qiāng", 0x554D: "tūn,zhūn,xiāng,tuī,duǐ", @@ -7670,7 +7681,7 @@ var PinyinDict = map[int]string{ 0x556D: "zhuàn", 0x556E: "niè", 0x556F: "guō", - 0x5570: "luō", + 0x5570: "luō,luó,luo", 0x5571: "yán", 0x5572: "dī", 0x5573: "quán,jué", @@ -7715,13 +7726,13 @@ var PinyinDict = map[int]string{ 0x559A: "huàn", 0x559B: "huàn,yuán,xuǎn,hé", 0x559C: "xǐ,xī,chì", - 0x559D: "hē,yè,hè,kài", + 0x559D: "hē,hè,yè,kài", 0x559E: "jī", 0x559F: "kuì,huài", 0x55A0: "zhǒng,chǒng", 0x55A1: "wéi,wèi", 0x55A2: "shà,chè", - 0x55A3: "xù", + 0x55A3: "xǔ", 0x55A4: "huáng", 0x55A5: "duó,zhà", 0x55A6: "niè,yì", @@ -7737,7 +7748,7 @@ var PinyinDict = map[int]string{ 0x55B0: "cān,sūn,qī", 0x55B1: "lí", 0x55B2: "yō,yo", - 0x55B3: "zhā,zha,chā", + 0x55B3: "zhā,chā,zha", 0x55B4: "wēi", 0x55B5: "miāo", 0x55B6: "yíng", @@ -7796,7 +7807,7 @@ var PinyinDict = map[int]string{ 0x55EC: "hē", 0x55ED: "zhí", 0x55EE: "sài", - 0x55EF: "ń,ńg,ňg,ň,ǹg,ǹ", + 0x55EF: "ń,ńg,ňg,ǹg,ň,ǹ", 0x55F0: "gě", 0x55F1: "ná", 0x55F2: "diē,diǎ", @@ -7839,7 +7850,7 @@ var PinyinDict = map[int]string{ 0x5617: "cháng", 0x5618: "xū,shī", 0x5619: "pó", - 0x561A: "dē,dé,dāi,dēi", + 0x561A: "dē,dēi,dé,dāi", 0x561B: "ma,má", 0x561C: "mà", 0x561D: "hú", @@ -8077,7 +8088,7 @@ var PinyinDict = map[int]string{ 0x5705: "hán", 0x5706: "yuán", 0x5707: "lún", - 0x5708: "quān,juàn,juān,quán,juǎn", + 0x5708: "quān,juān,juàn,quán,juǎn", 0x5709: "yǔ", 0x570A: "qīng", 0x570B: "guó", @@ -8110,14 +8121,14 @@ var PinyinDict = map[int]string{ 0x5726: "kuài", 0x5727: "yā", 0x5728: "zài", - 0x5729: "wéi,yú,xū", + 0x5729: "wéi,xū,yú", 0x572A: "gē,yì", - 0x572B: "yù,zhūn", + 0x572B: "yù,tuō,zhūn", 0x572C: "wū", 0x572D: "guī", 0x572E: "pǐ", 0x572F: "yí", - 0x5730: "de,dì", + 0x5730: "dì,de", 0x5731: "qiān,sú", 0x5732: "qiān", 0x5733: "zhèn,quǎn,chóu,huái", @@ -8177,7 +8188,7 @@ var PinyinDict = map[int]string{ 0x5769: "gān", 0x576A: "píng", 0x576B: "diàn,zhēn", - 0x576C: "guà", + 0x576C: "guà,wā", 0x576D: "ní", 0x576E: "tái", 0x576F: "pī,huài", @@ -8209,7 +8220,7 @@ var PinyinDict = map[int]string{ 0x5789: "páo", 0x578A: "min", 0x578B: "xíng", - 0x578C: "dòng,tǒng,tóng", + 0x578C: "dòng,tóng,tǒng", 0x578D: "jì,jī", 0x578E: "hè", 0x578F: "lǜ", @@ -8250,12 +8261,12 @@ var PinyinDict = map[int]string{ 0x57B2: "kǎi", 0x57B3: "háng", 0x57B4: "nǎo", - 0x57B5: "ǎn", + 0x57B5: "ǎn,ān", 0x57B6: "xīng", 0x57B7: "xiàn", 0x57B8: "yuàn,huán", 0x57B9: "bāng", - 0x57BA: "fū,fóu,pēi,póu", + 0x57BA: "fū,fú,fóu,pēi,póu", 0x57BB: "bà,bèi", 0x57BC: "yì", 0x57BD: "yìn", @@ -8297,14 +8308,14 @@ var PinyinDict = map[int]string{ 0x57E1: "yā,è,wǔ,yà", 0x57E2: "quán,juǎn", 0x57E3: "suì,sù", - 0x57E4: "pí,bì,pì,bēi", + 0x57E4: "pí,pì,bì,bēi", 0x57E5: "qīng,zhēng", 0x57E6: "wǎn,wān", 0x57E7: "jù", 0x57E8: "lǔn,lùn", 0x57E9: "zhēng,chéng", 0x57EA: "kōng", - 0x57EB: "chǒng,shǎng", + 0x57EB: "chǒng,tǎng,shǎng", 0x57EC: "dōng", 0x57ED: "dài", 0x57EE: "tàn,tán", @@ -8365,7 +8376,7 @@ var PinyinDict = map[int]string{ 0x5825: "máo,móu,wǔ", 0x5826: "jiē", 0x5827: "ruán,nuò", - 0x5828: "yè,ài,è", + 0x5828: "yè,è,ài", 0x5829: "gèng", 0x582A: "kān,chěn", 0x582B: "zōng", @@ -8419,7 +8430,7 @@ var PinyinDict = map[int]string{ 0x585B: "lì", 0x585C: "zhǒng,péng", 0x585D: "bàng", - 0x585E: "sāi,sè,sài", + 0x585E: "sāi,sài,sè", 0x585F: "zàng", 0x5860: "duī", 0x5861: "tián", @@ -8474,7 +8485,7 @@ var PinyinDict = map[int]string{ 0x5892: "shāng", 0x5893: "mù", 0x5894: "cuī", - 0x5895: "yàn", + 0x5895: "yàn,yān", 0x5896: "tǎ", 0x5897: "zēng", 0x5898: "qián", @@ -8908,7 +8919,7 @@ var PinyinDict = map[int]string{ 0x5A44: "pǒu,péi,bù", 0x5A45: "jú", 0x5A46: "pó", - 0x5A47: "cǎi,cāi", + 0x5A47: "cǎi", 0x5A48: "líng", 0x5A49: "wǎn", 0x5A4A: "biǎo", @@ -9148,7 +9159,7 @@ var PinyinDict = map[int]string{ 0x5B34: "yíng", 0x5B35: "mián", 0x5B36: "bí", - 0x5B37: "mā", + 0x5B37: "mā,mó", 0x5B38: "shěn", 0x5B39: "xìng,xīng", 0x5B3A: "nì", @@ -9222,7 +9233,7 @@ var PinyinDict = map[int]string{ 0x5B7E: "yīng", 0x5B7F: "luán", 0x5B80: "mián", - 0x5B81: "níng,zhù,nìng", + 0x5B81: "níng,nìng,zhù", 0x5B82: "rǒng", 0x5B83: "tā,tuó,yí", 0x5B84: "guǐ", @@ -9275,7 +9286,7 @@ var PinyinDict = map[int]string{ 0x5BB3: "hài,hé", 0x5BB4: "yàn", 0x5BB5: "xiāo", - 0x5BB6: "jiā,jià,jia,jie,gū", + 0x5BB6: "jiā,jia,jià,jie,gū", 0x5BB7: "shěn", 0x5BB8: "chén", 0x5BB9: "róng,yǒng", @@ -9284,7 +9295,7 @@ var PinyinDict = map[int]string{ 0x5BBC: "kòu", 0x5BBD: "kuān", 0x5BBE: "bīn", - 0x5BBF: "sù,xiù,xiǔ,qī", + 0x5BBF: "sù,xiǔ,xiù,qī", 0x5BC0: "cǎi,cài", 0x5BC1: "zǎn", 0x5BC2: "jì", @@ -9479,7 +9490,7 @@ var PinyinDict = map[int]string{ 0x5C7F: "yǔ", 0x5C80: "chū", 0x5C81: "suì", - 0x5C82: "qǐ", + 0x5C82: "qǐ,kǎi", 0x5C83: "rèn", 0x5C84: "yuè", 0x5C85: "bǎn", @@ -9517,7 +9528,7 @@ var PinyinDict = map[int]string{ 0x5CA5: "pō", 0x5CA6: "lì", 0x5CA7: "tiáo", - 0x5CA8: "qū,zǔ,jǔ", + 0x5CA8: "qū,jū,zǔ,jǔ", 0x5CA9: "yán", 0x5CAA: "fú", 0x5CAB: "xiù", @@ -9568,7 +9579,7 @@ var PinyinDict = map[int]string{ 0x5CD8: "huán", 0x5CD9: "zhì,shì", 0x5CDA: "mì", - 0x5CDB: "lǐ", + 0x5CDB: "lǐ,liè", 0x5CDC: "jì", 0x5CDD: "tóng", 0x5CDE: "wéi,wěi", @@ -9667,7 +9678,7 @@ var PinyinDict = map[int]string{ 0x5D3B: "zhì", 0x5D3C: "shì,dié", 0x5D3D: "zǎi", - 0x5D3E: "yǎo", + 0x5D3E: "yǎo,yào", 0x5D3F: "è", 0x5D40: "zhù", 0x5D41: "kān,zhàn", @@ -9721,7 +9732,7 @@ var PinyinDict = map[int]string{ 0x5D71: "yǒng,yóng", 0x5D72: "niè", 0x5D73: "cuó", - 0x5D74: "jǐ", + 0x5D74: "jǐ,jí", 0x5D75: "shí", 0x5D76: "ruò", 0x5D77: "sǒng", @@ -9843,7 +9854,7 @@ var PinyinDict = map[int]string{ 0x5DEB: "wū", 0x5DEC: "pu", 0x5DED: "pu", - 0x5DEE: "chà,chā,chāi,chài,cī,cuō,jiē", + 0x5DEE: "chà,chā,chāi,cī,chài,cuō,jiē", 0x5DEF: "qiú", 0x5DF0: "qiú", 0x5DF1: "jǐ,qǐ", @@ -9883,7 +9894,7 @@ var PinyinDict = map[int]string{ 0x5E13: "mò,wà", 0x5E14: "pèi,pī", 0x5E15: "pà,mò", - 0x5E16: "tiē,tiè,tiě", + 0x5E16: "tiē,tiě,tiè", 0x5E17: "bō,fú", 0x5E18: "lián,chén", 0x5E19: "zhì", @@ -9900,7 +9911,7 @@ var PinyinDict = map[int]string{ 0x5E24: "rú", 0x5E25: "shuài", 0x5E26: "dài", - 0x5E27: "zhèng", + 0x5E27: "zhēn,zhèng", 0x5E28: "shuì", 0x5E29: "qiào", 0x5E2A: "zhēn", @@ -10059,7 +10070,7 @@ var PinyinDict = map[int]string{ 0x5EC3: "fèi", 0x5EC4: "jiù", 0x5EC5: "è", - 0x5EC6: "guī,huì,wěi", + 0x5EC6: "guī,wěi,huì", 0x5EC7: "liù", 0x5EC8: "shà,xià", 0x5EC9: "lián", @@ -10175,7 +10186,7 @@ var PinyinDict = map[int]string{ 0x5F37: "qiáng,jiàng,qiǎng", 0x5F38: "péng,pēng", 0x5F39: "dàn,tán", - 0x5F3A: "qiáng,qiǎng,jiàng", + 0x5F3A: "qiáng,jiàng,qiǎng", 0x5F3B: "bì", 0x5F3C: "bì", 0x5F3D: "shè", @@ -10228,7 +10239,7 @@ var PinyinDict = map[int]string{ 0x5F6C: "bīn,bān", 0x5F6D: "péng,páng,bāng,pēng", 0x5F6E: "yǒng", - 0x5F6F: "piāo,piǎo,piào,miǎo", + 0x5F6F: "piāo,piào,miǎo", 0x5F70: "zhāng", 0x5F71: "yǐng", 0x5F72: "chī", @@ -10268,7 +10279,7 @@ var PinyinDict = map[int]string{ 0x5F94: "zhi", 0x5F95: "lái,lài", 0x5F96: "cóng", - 0x5F97: "dé,děi,de", + 0x5F97: "dé,de,děi", 0x5F98: "pái", 0x5F99: "xǐ,sī", 0x5F9A: "dōng", @@ -10491,7 +10502,7 @@ var PinyinDict = map[int]string{ 0x6073: "kěn", 0x6074: "dé", 0x6075: "huì", - 0x6076: "è,ě,wū,wù", + 0x6076: "è,ě,wù,wū", 0x6077: "xiao", 0x6078: "tòng", 0x6079: "yān", @@ -10556,7 +10567,7 @@ var PinyinDict = map[int]string{ 0x60B4: "cuì", 0x60B5: "chàng", 0x60B6: "mèn,mēn", - 0x60B7: "lì,sàn", + 0x60B7: "lì", 0x60B8: "jì", 0x60B9: "guàn", 0x60BA: "guàn", @@ -10703,7 +10714,7 @@ var PinyinDict = map[int]string{ 0x6147: "yīn", 0x6148: "cí", 0x6149: "xù,chù", - 0x614A: "qiàn,xián,qiǎn,qiè", + 0x614A: "qiàn,qiè,xián,qiǎn", 0x614B: "tài", 0x614C: "huāng,huǎng,huang", 0x614D: "yùn", @@ -10861,7 +10872,7 @@ var PinyinDict = map[int]string{ 0x61E5: "zhì", 0x61E6: "nuò", 0x61E7: "nuò", - 0x61E8: "yān,chú", + 0x61E8: "yān", 0x61E9: "yǎng", 0x61EA: "bó", 0x61EB: "zhì", @@ -10912,7 +10923,7 @@ var PinyinDict = map[int]string{ 0x6218: "zhàn", 0x6219: "dòng", 0x621A: "qī,cù", - 0x621B: "jiá", + 0x621B: "jiá,gā", 0x621C: "dié", 0x621D: "zéi", 0x621E: "jiá", @@ -10963,11 +10974,11 @@ var PinyinDict = map[int]string{ 0x624B: "shǒu", 0x624C: "shou", 0x624D: "cái,zāi", - 0x624E: "zhā,zhá,zhǎ,zā", + 0x624E: "zhā,zā,zhá,zhǎ", 0x624F: "qiú", 0x6250: "lè,lì,cái", 0x6251: "pū,pì", - 0x6252: "bā,bài,bié,pá", + 0x6252: "bā,pá,bài,bié", 0x6253: "dǎ,dá", 0x6254: "rēng,rèng", 0x6255: "fǎn", @@ -11037,7 +11048,7 @@ var PinyinDict = map[int]string{ 0x6295: "tóu,dòu", 0x6296: "dǒu", 0x6297: "kàng,gāng", - 0x6298: "zhé,shé,tí,zhē", + 0x6298: "zhé,shé,zhē,tí", 0x6299: "póu", 0x629A: "fǔ", 0x629B: "pāo", @@ -11070,7 +11081,7 @@ var PinyinDict = map[int]string{ 0x62B6: "chì", 0x62B7: "pī,pēi", 0x62B8: "jiā", - 0x62B9: "mǒ,mò,mā", + 0x62B9: "mǒ,mā,mò", 0x62BA: "mèi", 0x62BB: "chēn,shēn", 0x62BC: "yā,xiá,jiǎ", @@ -11082,7 +11093,7 @@ var PinyinDict = map[int]string{ 0x62C2: "fú,bì,pì,fèi", 0x62C3: "zhǎ,zhǎn,zhà,zhá", 0x62C4: "zhǔ", - 0x62C5: "dān,dǎn,jiē,dàn", + 0x62C5: "dān,dàn,dǎn,jiē", 0x62C6: "chāi,chè,chì,cā", 0x62C7: "mǔ", 0x62C8: "niān,niǎn,diān", @@ -11096,7 +11107,7 @@ var PinyinDict = map[int]string{ 0x62D0: "guǎi", 0x62D1: "qián", 0x62D2: "jù,jǔ", - 0x62D3: "tà,zhí,tuò", + 0x62D3: "tuò,tà,zhí", 0x62D4: "bá,bō,bié,fá,bèi", 0x62D5: "tuō", 0x62D6: "tuō,chǐ", @@ -11105,7 +11116,7 @@ var PinyinDict = map[int]string{ 0x62D9: "zhuō", 0x62DA: "pàn,biàn,fèn,fān,pīn", 0x62DB: "zhāo,qiáo,sháo", - 0x62DC: "bài", + 0x62DC: "bài,bái", 0x62DD: "bài", 0x62DE: "dǐ", 0x62DF: "nǐ", @@ -11138,7 +11149,7 @@ var PinyinDict = map[int]string{ 0x62FA: "cè,sè,chuò", 0x62FB: "huī", 0x62FC: "pīn,bìng", - 0x62FD: "zhuāi,yè,zhuài", + 0x62FD: "zhuāi,zhuài,yè", 0x62FE: "shí,shè,jiè", 0x62FF: "ná", 0x6300: "bāi", @@ -11219,7 +11230,7 @@ var PinyinDict = map[int]string{ 0x634B: "lǚ,luō", 0x634C: "bā,bié", 0x634D: "hàn,xiàn,gǎn", - 0x634E: "shāo,shǎo,xiāo,qiào,shào", + 0x634E: "shāo,shào,shǎo,xiāo,qiào", 0x634F: "niē", 0x6350: "juān,yuán", 0x6351: "zè", @@ -11287,7 +11298,7 @@ var PinyinDict = map[int]string{ 0x638F: "tāo,táo", 0x6390: "qiā", 0x6391: "qí", - 0x6392: "pái,bài,pǎi", + 0x6392: "pái,pǎi,bài", 0x6393: "shū", 0x6394: "qiān,wàn", 0x6395: "líng", @@ -11349,7 +11360,7 @@ var PinyinDict = map[int]string{ 0x63CD: "zòu,còu", 0x63CE: "xuān", 0x63CF: "miáo,mào", - 0x63D0: "tí,chí,shí,dǐ,dī", + 0x63D0: "tí,dī,chí,shí,dǐ", 0x63D1: "niē", 0x63D2: "chā,zhǎ", 0x63D3: "shì", @@ -11368,7 +11379,7 @@ var PinyinDict = map[int]string{ 0x63E0: "yà", 0x63E1: "wò,òu", 0x63E2: "ké,qiā", - 0x63E3: "chuāi,chuǎi,duǒ,zhuī,tuán,chuài", + 0x63E3: "chuāi,chuǎi,chuài,duǒ,zhuī,tuán", 0x63E4: "jí", 0x63E5: "tì,dì", 0x63E6: "lá,là", @@ -11502,7 +11513,7 @@ var PinyinDict = map[int]string{ 0x6466: "huà", 0x6467: "cuī,zuì,cuò", 0x6468: "nái,zhì", - 0x6469: "mó,mí,mā", + 0x6469: "mó,mā,mí", 0x646A: "jiāng,qiàng", 0x646B: "guī", 0x646C: "yǐng", @@ -11522,7 +11533,7 @@ var PinyinDict = map[int]string{ 0x647A: "zhé,lā,xié", 0x647B: "càn,shǎn,shān,chān,sēn", 0x647C: "kēng,qiān", - 0x647D: "biāo,piāo,biào,pāo", + 0x647D: "biāo,biào,piāo,pāo", 0x647E: "jiàng", 0x647F: "yáo", 0x6480: "gòu", @@ -11532,7 +11543,7 @@ var PinyinDict = map[int]string{ 0x6484: "yīng", 0x6485: "juē,juè,jué,guì", 0x6486: "piē", - 0x6487: "piē,biē,piě", + 0x6487: "piē,piě,biē", 0x6488: "lāo", 0x6489: "dūn", 0x648A: "xiàn", @@ -11571,7 +11582,7 @@ var PinyinDict = map[int]string{ 0x64AB: "fǔ,mó", 0x64AC: "qiào", 0x64AD: "bō,bǒ", - 0x64AE: "cuō,zuì,zuān,chuā,zuǒ", + 0x64AE: "cuō,zuǒ,zuì,zuān,chuā", 0x64AF: "zhuó", 0x64B0: "zhuàn,xuǎn,suàn", 0x64B1: "wěi,tuǒ", @@ -11841,7 +11852,7 @@ var PinyinDict = map[int]string{ 0x65B9: "fāng,fáng,fǎng,páng,wǎng,fēng", 0x65BA: "chǎn,jiè", 0x65BB: "háng", - 0x65BC: "yú,wū,yū", + 0x65BC: "yú,yū,wū", 0x65BD: "shī,yì,shǐ", 0x65BE: "pèi", 0x65BF: "yóu,liú", @@ -11906,7 +11917,7 @@ var PinyinDict = map[int]string{ 0x65FA: "wàng", 0x65FB: "mín", 0x65FC: "mín", - 0x65FD: "tūn,tùn,zhùn", + 0x65FD: "tūn,zhùn", 0x65FE: "chūn", 0x65FF: "wǔ,wù", 0x6600: "yún", @@ -12130,7 +12141,7 @@ var PinyinDict = map[int]string{ 0x66DA: "méng", 0x66DB: "xūn", 0x66DC: "yào", - 0x66DD: "pù", + 0x66DD: "pù,bào", 0x66DE: "lì", 0x66DF: "chén", 0x66E0: "kuàng", @@ -12212,12 +12223,12 @@ var PinyinDict = map[int]string{ 0x672C: "běn,bēn", 0x672D: "zhá,yà", 0x672E: "shù,zhú", - 0x672F: "shù,shú,zhú", + 0x672F: "shù,zhú,shú", 0x6730: "mù", 0x6731: "zhū,shū", 0x6732: "rén", 0x6733: "bā", - 0x6734: "pǔ,pò,pū,pō,piáo", + 0x6734: "pǔ,piáo,pò,pū,pō", 0x6735: "duǒ", 0x6736: "duǒ", 0x6737: "dāo,mù,tiáo", @@ -12235,7 +12246,7 @@ var PinyinDict = map[int]string{ 0x6743: "quán", 0x6744: "qiān", 0x6745: "yú,wū", - 0x6746: "gān,gàn,gǎn", + 0x6746: "gān,gǎn,gàn", 0x6747: "wū", 0x6748: "chā,chà", 0x6749: "shān,shā", @@ -12261,7 +12272,7 @@ var PinyinDict = map[int]string{ 0x675D: "lí,zhì,yí,tuò,duò", 0x675E: "qǐ", 0x675F: "shù", - 0x6760: "gāng,gōng,gàng", + 0x6760: "gāng,gàng,gōng", 0x6761: "tiáo", 0x6762: "jiang", 0x6763: "mián", @@ -12349,7 +12360,7 @@ var PinyinDict = map[int]string{ 0x67B5: "xiāo", 0x67B6: "jià", 0x67B7: "jiā,jià", - 0x67B8: "gǒu,jǔ,gōu,qú", + 0x67B8: "gǒu,gōu,jǔ,qú", 0x67B9: "bāo,fú", 0x67BA: "mò", 0x67BB: "yì,xiè", @@ -12477,7 +12488,7 @@ var PinyinDict = map[int]string{ 0x6835: "liè", 0x6836: "yīn", 0x6837: "yàng,yáng", - 0x6838: "hé,gāi,kài,hú", + 0x6838: "hé,hú,gāi,kài", 0x6839: "gēn", 0x683A: "yì,zhī,zhǐ", 0x683B: "shì", @@ -12583,7 +12594,7 @@ var PinyinDict = map[int]string{ 0x68A0: "lǚ", 0x68A1: "hún,kuǎn", 0x68A2: "shāo,shào,xiāo,sào", - 0x68A3: "cén", + 0x68A3: "cén,chén,qín", 0x68A4: "fén", 0x68A5: "sōng", 0x68A6: "mèng", @@ -12631,7 +12642,7 @@ var PinyinDict = map[int]string{ 0x68D0: "fěi,féi", 0x68D1: "pái,bèi,pèi", 0x68D2: "bàng", - 0x68D3: "bàng,pǒu,bèi,péi,bēi", + 0x68D3: "bàng,bèi,pǒu,péi,bēi", 0x68D4: "hūn", 0x68D5: "zōng", 0x68D6: "chéng,cháng", @@ -12661,7 +12672,7 @@ var PinyinDict = map[int]string{ 0x68EE: "sēn", 0x68EF: "rěn,shěn", 0x68F0: "chuí,duǒ", - 0x68F1: "léng,lèng,lēng,líng,chēng", + 0x68F1: "léng,lēng,líng,lèng,chēng", 0x68F2: "qī,xī", 0x68F3: "zhuō", 0x68F4: "fú,sù", @@ -12795,7 +12806,7 @@ var PinyinDict = map[int]string{ 0x6974: "tì,dǐ,shì", 0x6975: "jí,jǐ", 0x6976: "jié", - 0x6977: "kǎi,jiè,jiē", + 0x6977: "kǎi,jiē,jiè", 0x6978: "qiū", 0x6979: "yíng", 0x697A: "rǒu,ròu", @@ -12913,7 +12924,7 @@ var PinyinDict = map[int]string{ 0x69EA: "gài", 0x69EB: "tuán,shuàn,quán", 0x69EC: "huà", - 0x69ED: "qī,zú,sè", + 0x69ED: "qī,qì,zú,sè", 0x69EE: "sēn,shěn", 0x69EF: "cuī,zuǐ", 0x69F0: "péng", @@ -12943,7 +12954,7 @@ var PinyinDict = map[int]string{ 0x6A08: "qíng", 0x6A09: "shuǎng", 0x6A0A: "fán,fàn", - 0x6A0B: "tōng,tǒng", + 0x6A0B: "tōng", 0x6A0C: "guàn", 0x6A0D: "zé", 0x6A0E: "sù", @@ -13013,7 +13024,7 @@ var PinyinDict = map[int]string{ 0x6A4E: "fán", 0x6A4F: "zhǎn,jiǎn", 0x6A50: "tuó,dù,luò", - 0x6A51: "lǎo", + 0x6A51: "lǎo,liáo", 0x6A52: "yún", 0x6A53: "shùn", 0x6A54: "dūn,tuí", @@ -13150,7 +13161,7 @@ var PinyinDict = map[int]string{ 0x6AD7: "miè,mèi", 0x6AD8: "huì", 0x6AD9: "ōu", - 0x6ADA: "lǘ,lú", + 0x6ADA: "lǘ", 0x6ADB: "zhì", 0x6ADC: "gāo", 0x6ADD: "dú", @@ -13244,8 +13255,8 @@ var PinyinDict = map[int]string{ 0x6B35: "kuǎn", 0x6B36: "shuò,sòu", 0x6B37: "xī", - 0x6B38: "āi,ǎi,xiè,ế,éi,ê̌,ěi,ề,èi,ê̄,ēi", - 0x6B39: "yī", + 0x6B38: "āi,ǎi,ê̄,ế,ê̌,ề,xiè,éi,ěi,èi,ēi", + 0x6B39: "yī,qī", 0x6B3A: "qī", 0x6B3B: "chuā,xū", 0x6B3C: "chǐ,chuài", @@ -13338,7 +13349,7 @@ var PinyinDict = map[int]string{ 0x6B93: "liàn", 0x6B94: "yì", 0x6B95: "fǒu,yè,bó", - 0x6B96: "zhí,shì,shi", + 0x6B96: "zhí,shi,shì", 0x6B97: "yè,yàn,yān", 0x6B98: "cán", 0x6B99: "hūn,mèn", @@ -13371,7 +13382,7 @@ var PinyinDict = map[int]string{ 0x6BB4: "ōu", 0x6BB5: "duàn", 0x6BB6: "zhù", - 0x6BB7: "yīn,yǐn,yān", + 0x6BB7: "yīn,yān,yǐn", 0x6BB8: "qìng,kēng,shēng", 0x6BB9: "yì", 0x6BBA: "shā,shài,sà,xiè,shì", @@ -13507,7 +13518,7 @@ var PinyinDict = map[int]string{ 0x6C3C: "nì,mèi", 0x6C3D: "tǔn,qiú", 0x6C3E: "fàn,fán", - 0x6C3F: "guǐ,qiú,jiǔ", + 0x6C3F: "guǐ,jiǔ,qiú", 0x6C40: "tīng,tìng,dìng", 0x6C41: "zhī,xié,shí", 0x6C42: "qiú", @@ -13584,7 +13595,7 @@ var PinyinDict = map[int]string{ 0x6C89: "chén", 0x6C8A: "dàn", 0x6C8B: "yóu", - 0x6C8C: "dùn,tún,chún,zhuàn", + 0x6C8C: "dùn,zhuàn,tún,chún", 0x6C8D: "hù,hú", 0x6C8E: "huò", 0x6C8F: "qī,qiè", @@ -13812,7 +13823,7 @@ var PinyinDict = map[int]string{ 0x6D6D: "gēng", 0x6D6E: "fú", 0x6D6F: "wú", - 0x6D70: "liàn", + 0x6D70: "liàn,lì", 0x6D71: "chún", 0x6D72: "féng,hóng", 0x6D73: "yì", @@ -13880,7 +13891,7 @@ var PinyinDict = map[int]string{ 0x6DB1: "zhàng", 0x6DB2: "yè,shì", 0x6DB3: "kōng,náng", - 0x6DB4: "wò,wǎn,yuān", + 0x6DB4: "wò,yuān,wǎn", 0x6DB5: "hán,hàn", 0x6DB6: "tuō,tuò", 0x6DB7: "dōng", @@ -14037,7 +14048,7 @@ var PinyinDict = map[int]string{ 0x6E4E: "miǎn", 0x6E4F: "huì,mǐn", 0x6E50: "mò", - 0x6E51: "xū,xǔ,xù", + 0x6E51: "xū,xù,xǔ", 0x6E52: "jí", 0x6E53: "pén,pèn", 0x6E54: "jiān,zàn,zhǎn,qián,jiàn", @@ -14063,7 +14074,7 @@ var PinyinDict = map[int]string{ 0x6E68: "jú", 0x6E69: "dòng,dǒng,tóng", 0x6E6A: "tuàn,nuǎn", - 0x6E6B: "jiǎo,jiù,jiū,qiū,jiāo", + 0x6E6B: "jiǎo,qiū,jiù,jiū,jiāo", 0x6E6C: "jiǎo", 0x6E6D: "qiú", 0x6E6E: "yān,yīn", @@ -14141,7 +14152,7 @@ var PinyinDict = map[int]string{ 0x6EB6: "róng", 0x6EB7: "hùn,hún", 0x6EB8: "sù", - 0x6EB9: "suò,sè", + 0x6EB9: "suò,suǒ,sè", 0x6EBA: "nì,ruò,niào", 0x6EBB: "tā", 0x6EBC: "shī", @@ -14187,7 +14198,7 @@ var PinyinDict = map[int]string{ 0x6EE4: "lǜ", 0x6EE5: "làn", 0x6EE6: "luán", - 0x6EE7: "yáo", + 0x6EE7: "yáo,xiào", 0x6EE8: "bīn", 0x6EE9: "tān", 0x6EEA: "yù", @@ -14214,7 +14225,7 @@ var PinyinDict = map[int]string{ 0x6EFF: "mǎn,mèn", 0x6F00: "qǐng,qīng", 0x6F01: "yú", - 0x6F02: "piào,piāo,piǎo,biāo", + 0x6F02: "piāo,piào,piǎo,biāo", 0x6F03: "jì", 0x6F04: "yá", 0x6F05: "cháo", @@ -14264,7 +14275,7 @@ var PinyinDict = map[int]string{ 0x6F31: "shù", 0x6F32: "zhǎng,zhàng,zhāng", 0x6F33: "zhāng", - 0x6F34: "zhuàng,chuáng,chóng", + 0x6F34: "zhuàng,chóng,shuāng,chuáng", 0x6F35: "xù", 0x6F36: "huàn", 0x6F37: "huǒ,kuò,huò", @@ -14314,7 +14325,7 @@ var PinyinDict = map[int]string{ 0x6F63: "mǐn", 0x6F64: "rùn", 0x6F65: "sù", - 0x6F66: "lǎo,lào,láo,liáo,liǎo", + 0x6F66: "lǎo,liáo,lào,láo,liǎo", 0x6F67: "zhēn", 0x6F68: "cóng,zōng", 0x6F69: "yì", @@ -14397,7 +14408,7 @@ var PinyinDict = map[int]string{ 0x6FB6: "chán,dàn,zhān", 0x6FB7: "màn", 0x6FB8: "dǎn", - 0x6FB9: "dàn,dān,shàn,tán", + 0x6FB9: "dàn,tán,dān,shàn", 0x6FBA: "yì", 0x6FBB: "suì", 0x6FBC: "pì", @@ -14528,7 +14539,7 @@ var PinyinDict = map[int]string{ 0x7039: "yuè,yào", 0x703A: "chán", 0x703B: "dài", - 0x703C: "ráng,nǎng,ràng", + 0x703C: "ráng,ràng,nǎng", 0x703D: "jiǎn", 0x703E: "lán", 0x703F: "fán", @@ -14616,7 +14627,7 @@ var PinyinDict = map[int]string{ 0x7091: "mù", 0x7092: "chǎo", 0x7093: "liào", - 0x7094: "guì,xuè,quē", + 0x7094: "guì,quē,xuè", 0x7095: "kàng,hāng", 0x7096: "dùn,tún", 0x7097: "guāng", @@ -14642,7 +14653,7 @@ var PinyinDict = map[int]string{ 0x70AB: "xuàn", 0x70AC: "jù", 0x70AD: "tàn", - 0x70AE: "pào,páo,bāo", + 0x70AE: "pào,bāo,páo", 0x70AF: "jiǒng", 0x70B0: "páo,fǒu", 0x70B1: "tái", @@ -15074,7 +15085,7 @@ var PinyinDict = map[int]string{ 0x725C: "niú", 0x725D: "pìn", 0x725E: "jiū,lè", - 0x725F: "móu,mào,mù", + 0x725F: "móu,mù,mào", 0x7260: "tā,tuó", 0x7261: "mǔ", 0x7262: "láo,lào,lóu", @@ -15159,11 +15170,11 @@ var PinyinDict = map[int]string{ 0x72B1: "jǐ", 0x72B2: "chái", 0x72B3: "zhuó", - 0x72B4: "àn,án,jiàn,hān", + 0x72B4: "àn,hān,án,jiàn", 0x72B5: "gē,hé", 0x72B6: "zhuàng", 0x72B7: "guǎng", - 0x72B8: "mà", + 0x72B8: "mà,mǎ", 0x72B9: "yóu,yòu", 0x72BA: "kàng,gǎng", 0x72BB: "bó,pèi,fèi", @@ -15449,7 +15460,7 @@ var PinyinDict = map[int]string{ 0x73D3: "jiào", 0x73D4: "jiàn", 0x73D5: "lì", - 0x73D6: "guāng,guàng", + 0x73D6: "guāng", 0x73D7: "xiān", 0x73D8: "zhōu", 0x73D9: "gǒng", @@ -15800,7 +15811,7 @@ var PinyinDict = map[int]string{ 0x7537: "nán", 0x7538: "diān,diàn,tián,shèng,yìng", 0x7539: "pīng", - 0x753A: "tīng,tǐng,zhèng,tiǎn,dīng", + 0x753A: "tīng,dīng,tǐng,zhèng,tiǎn", 0x753B: "huà", 0x753C: "tǐng", 0x753D: "zhèn,quǎn,zhùn", @@ -15848,7 +15859,7 @@ var PinyinDict = map[int]string{ 0x7567: "lüè", 0x7568: "pān,fān", 0x7569: "yī", - 0x756A: "fān,fán,bō,pó,pān,pán,pàn,pí", + 0x756A: "fān,pān,fán,bō,pó,pán,pàn,pí", 0x756B: "huà", 0x756C: "shē,yú", 0x756D: "yú", @@ -16039,7 +16050,7 @@ var PinyinDict = map[int]string{ 0x7626: "shòu", 0x7627: "nüè,yào", 0x7628: "diān,chēn", - 0x7629: "da,dá", + 0x7629: "dā,da,dá", 0x762A: "biě,biē", 0x762B: "tān", 0x762C: "zhàng", @@ -16125,12 +16136,12 @@ var PinyinDict = map[int]string{ 0x767C: "fā,bō", 0x767D: "bái,bó", 0x767E: "bǎi,bó,mò", - 0x767F: "qié", + 0x767F: "qié,bié", 0x7680: "jí,xiāng,bī", 0x7681: "zào", 0x7682: "zào", 0x7683: "mào", - 0x7684: "de,dì,dí", + 0x7684: "de,dī,dí,dì", 0x7685: "pā,bà", 0x7686: "jiē", 0x7687: "huáng,wǎng", @@ -16301,7 +16312,7 @@ var PinyinDict = map[int]string{ 0x772C: "lóng", 0x772D: "suī,huī,xié,wèi", 0x772E: "tóng", - 0x772F: "mī,mǐ,mì,mí", + 0x772F: "mī,mí,mǐ,mì", 0x7730: "diè,zhì", 0x7731: "dì", 0x7732: "nè", @@ -16318,7 +16329,7 @@ var PinyinDict = map[int]string{ 0x773D: "mò,mì", 0x773E: "zhòng", 0x773F: "mò", - 0x7740: "zhe,zhuó,zhāo,zháo", + 0x7740: "zhe,zhāo,zháo,zhuó", 0x7741: "zhēng", 0x7742: "méi", 0x7743: "suō,jùn,juān", @@ -16401,7 +16412,7 @@ var PinyinDict = map[int]string{ 0x7790: "mò", 0x7791: "míng,méng,mián", 0x7792: "mán", - 0x7793: "shuì", + 0x7793: "fèn", 0x7794: "zé", 0x7795: "zhàng", 0x7796: "yì", @@ -16415,7 +16426,7 @@ var PinyinDict = map[int]string{ 0x779E: "mán,mén,mèn", 0x779F: "piǎo,piào,piāo", 0x77A0: "chēng,zhèng", - 0x77A1: "guī,guǐ", + 0x77A1: "guī", 0x77A2: "méng,máng,mèng", 0x77A3: "wàn", 0x77A4: "rún,shùn", @@ -16519,7 +16530,7 @@ var PinyinDict = map[int]string{ 0x7806: "fū", 0x7807: "mín", 0x7808: "ě", - 0x7809: "huò,xū,huā", + 0x7809: "huò,huā,xū", 0x780A: "kāng,kàng", 0x780B: "zhǐ", 0x780C: "qì,qiè", @@ -16539,7 +16550,7 @@ var PinyinDict = map[int]string{ 0x781A: "yàn", 0x781B: "jīn", 0x781C: "fēng", - 0x781D: "fá,jié,gé,fǎ", + 0x781D: "fá,fǎ,jié,gé", 0x781E: "mò", 0x781F: "zhǎ,zhà,zuó", 0x7820: "jū,zū", @@ -16584,17 +16595,17 @@ var PinyinDict = map[int]string{ 0x7847: "náo", 0x7848: "qià", 0x7849: "lù", - 0x784A: "wěi,guì", + 0x784A: "wěi,huì,guì", 0x784B: "ài", 0x784C: "gè,luò,lì", - 0x784D: "xiàn,kèn,kēng,yǐn", + 0x784D: "xiàn,yín,kèn,kēng,yǐn", 0x784E: "xíng,kēng", 0x784F: "yán,yàn", 0x7850: "dòng,tóng,liú", 0x7851: "pēng,píng", 0x7852: "xī", 0x7853: "lǎo", - 0x7854: "hóng", + 0x7854: "hóng,gǒng", 0x7855: "shuò", 0x7856: "xiá", 0x7857: "qiāo", @@ -16637,7 +16648,7 @@ var PinyinDict = map[int]string{ 0x787C: "péng,pēng", 0x787D: "yān,yǎn", 0x787E: "zhuì,duǒ", - 0x787F: "kōng", + 0x787F: "kōng,kòng", 0x7880: "chéng", 0x7881: "qí", 0x7882: "zòng,cóng", @@ -16646,11 +16657,11 @@ var PinyinDict = map[int]string{ 0x7885: "jūn", 0x7886: "bō", 0x7887: "dìng", - 0x7888: "mín", + 0x7888: "mín,hūn", 0x7889: "diāo", 0x788A: "jiān,zhàn", 0x788B: "hè", - 0x788C: "lù,luò,liù", + 0x788C: "lù,liù,luò", 0x788D: "ài", 0x788E: "suì", 0x788F: "què,xī", @@ -16707,7 +16718,7 @@ var PinyinDict = map[int]string{ 0x78C2: "liú,liù", 0x78C3: "sī,tí", 0x78C4: "táng", - 0x78C5: "bàng,pāng,páng", + 0x78C5: "bàng,páng,pāng", 0x78C6: "huá,kě,gū", 0x78C7: "pī", 0x78C8: "wěi,kuǐ", @@ -17144,7 +17155,7 @@ var PinyinDict = map[int]string{ 0x7A77: "qióng", 0x7A78: "xī", 0x7A79: "qióng,qiōng,kōng", - 0x7A7A: "kōng,kǒng,kòng", + 0x7A7A: "kōng,kòng,kǒng", 0x7A7B: "yū,yǔ", 0x7A7C: "shēn", 0x7A7D: "jǐng", @@ -17324,7 +17335,7 @@ var PinyinDict = map[int]string{ 0x7B2B: "zǐ", 0x7B2C: "dì", 0x7B2D: "líng", - 0x7B2E: "zé,zhà,zuó", + 0x7B2E: "zé,zuó,zhà", 0x7B2F: "nú", 0x7B30: "fú,fèi", 0x7B31: "gǒu", @@ -17403,7 +17414,7 @@ var PinyinDict = map[int]string{ 0x7B7A: "kuāng", 0x7B7B: "gàng", 0x7B7C: "yún", - 0x7B7D: "o", + 0x7B7D: "ōu,wú", 0x7B7E: "qiān", 0x7B7F: "xiǎo", 0x7B80: "jiǎn", @@ -17557,7 +17568,7 @@ var PinyinDict = map[int]string{ 0x7C14: "suō", 0x7C15: "lè", 0x7C16: "duàn", - 0x7C17: "liang", + 0x7C17: "zhù", 0x7C18: "xiāo", 0x7C19: "bó", 0x7C1A: "mì", @@ -17837,7 +17848,7 @@ var PinyinDict = map[int]string{ 0x7D2C: "chóu,chōu,zhòu", 0x7D2D: "hóng", 0x7D2E: "zā,zhā", - 0x7D2F: "lèi,lěi,léi,lǜ,liè", + 0x7D2F: "lèi,léi,lěi,lǜ,liè", 0x7D30: "xì", 0x7D31: "fú", 0x7D32: "xiè,yì", @@ -18111,7 +18122,7 @@ var PinyinDict = map[int]string{ 0x7E3E: "jī", 0x7E3F: "shān,xiān,xiāo,sāo,cǎn", 0x7E40: "suì,cuǐ", - 0x7E41: "fán,pán,pó", + 0x7E41: "fán,pó,pán", 0x7E42: "lǜ", 0x7E43: "běng,bēng,bèng", 0x7E44: "yī,yì", @@ -18279,7 +18290,7 @@ var PinyinDict = map[int]string{ 0x7EE6: "tāo", 0x7EE7: "jì", 0x7EE8: "tí,tì", - 0x7EE9: "jī", + 0x7EE9: "jì,jī", 0x7EEA: "xù", 0x7EEB: "líng", 0x7EEC: "yīng", @@ -18389,7 +18400,7 @@ var PinyinDict = map[int]string{ 0x7F54: "wǎng,wáng", 0x7F55: "hǎn,hàn", 0x7F56: "luó", - 0x7F57: "luó", + 0x7F57: "luó,luō", 0x7F58: "fú", 0x7F59: "shēn", 0x7F5A: "fá", @@ -18612,7 +18623,7 @@ var PinyinDict = map[int]string{ 0x8033: "ěr,réng", 0x8034: "yì", 0x8035: "dīng", - 0x8036: "yé,xié,yē", + 0x8036: "yé,yē,xié", 0x8037: "dā,zhé", 0x8038: "sǒng", 0x8039: "qín", @@ -18772,7 +18783,7 @@ var PinyinDict = map[int]string{ 0x80D3: "píng,pēng", 0x80D4: "zì,cí,jí", 0x80D5: "fǔ,fū,fú,zhǒu", - 0x80D6: "pàng,pàn,pán", + 0x80D6: "pàng,pán,pàn", 0x80D7: "zhēn,zhěn,zhūn", 0x80D8: "xián", 0x80D9: "zuò", @@ -18877,7 +18888,7 @@ var PinyinDict = map[int]string{ 0x813C: "liǎng,lǎng", 0x813D: "shuí", 0x813E: "pí,pái,bì,pì", - 0x813F: "biāo,biào,biǎo", + 0x813F: "biāo,biǎo,biào", 0x8140: "lún", 0x8141: "pián", 0x8142: "lěi,guò,huà", @@ -18906,7 +18917,7 @@ var PinyinDict = map[int]string{ 0x8159: "zōng", 0x815A: "dìng", 0x815B: "wò", - 0x815C: "méi,měi", + 0x815C: "méi", 0x815D: "ní,ruǎn,nào,nèn,ér", 0x815E: "zhuàn,dùn,tú", 0x815F: "chì", @@ -18922,7 +18933,7 @@ var PinyinDict = map[int]string{ 0x8169: "nǎn", 0x816A: "yùn", 0x816B: "zhǒng", - 0x816C: "róu,ròu", + 0x816C: "róu", 0x816D: "è", 0x816E: "sāi", 0x816F: "tú,dùn", @@ -18942,7 +18953,7 @@ var PinyinDict = map[int]string{ 0x817D: "wà", 0x817E: "téng", 0x817F: "tuǐ", - 0x8180: "bǎng,páng,pāng,bàng,pǎng", + 0x8180: "bǎng,pāng,páng,bàng,pǎng", 0x8181: "qiǎn,xiàn,yán", 0x8182: "lǚ", 0x8183: "wà", @@ -18960,7 +18971,7 @@ var PinyinDict = map[int]string{ 0x818F: "gāo,gào", 0x8190: "lǚ", 0x8191: "bìn", - 0x8192: "ōu,óu", + 0x8192: "ōu", 0x8193: "cháng", 0x8194: "lù,biāo", 0x8195: "guó,huò", @@ -19191,7 +19202,7 @@ var PinyinDict = map[int]string{ 0x8276: "yàn", 0x8277: "yàn", 0x8278: "cǎo", - 0x8279: "cao", + 0x8279: "cǎo", 0x827A: "yì", 0x827B: "lè,jí", 0x827C: "tīng,dǐng", @@ -19222,7 +19233,7 @@ var PinyinDict = map[int]string{ 0x8295: "suī", 0x8296: "zhì", 0x8297: "xiāng", - 0x8298: "pí,bì", + 0x8298: "pí,bǐ,bì", 0x8299: "fú", 0x829A: "tún,chūn", 0x829B: "wěi", @@ -19236,7 +19247,7 @@ var PinyinDict = map[int]string{ 0x82A3: "fú,fǒu,fū", 0x82A4: "kōu", 0x82A5: "jiè,gài", - 0x82A6: "lú,hù,lǔ", + 0x82A6: "lú,lǔ,hù", 0x82A7: "xù,zhù", 0x82A8: "jī", 0x82A9: "qín,yín", @@ -19337,7 +19348,7 @@ var PinyinDict = map[int]string{ 0x8308: "cí,zǐ,cǐ,chái", 0x8309: "mò", 0x830A: "zī", - 0x830B: "zhǐ", + 0x830B: "zhǐ,dǐ", 0x830C: "chí", 0x830D: "jì", 0x830E: "jīng", @@ -19484,7 +19495,7 @@ var PinyinDict = map[int]string{ 0x839B: "tíng,tǐng", 0x839C: "yóu,diào,dí", 0x839D: "cuò", - 0x839E: "guǎn,guān,wǎn", + 0x839E: "guǎn,wǎn,guān", 0x839F: "hàn", 0x83A0: "yǒu,xiù", 0x83A1: "cuò", @@ -19494,7 +19505,7 @@ var PinyinDict = map[int]string{ 0x83A5: "niǔ,ròu", 0x83A6: "shāo,xiāo", 0x83A7: "xiàn,wàn", - 0x83A8: "làng,láng,liáng", + 0x83A8: "làng,liáng,láng", 0x83A9: "fú,piǎo", 0x83AA: "é", 0x83AB: "mò,mù", @@ -19596,7 +19607,7 @@ var PinyinDict = map[int]string{ 0x840B: "qī", 0x840C: "méng,míng", 0x840D: "píng", - 0x840E: "wēi,wèi,wěi", + 0x840E: "wēi,wěi,wèi", 0x840F: "dàn", 0x8410: "shà", 0x8411: "huán,zhuī", @@ -19669,7 +19680,7 @@ var PinyinDict = map[int]string{ 0x8454: "hóu", 0x8455: "yàn", 0x8456: "tū", - 0x8457: "zhù,zhe,chú,zhuó,zhāo,zháo", + 0x8457: "zhù,zhe,zhuó,chú,zhāo,zháo", 0x8458: "zī", 0x8459: "xiāng", 0x845A: "rèn,shèn", @@ -19727,7 +19738,7 @@ var PinyinDict = map[int]string{ 0x848E: "pài", 0x848F: "you", 0x8490: "sōu,huì", - 0x8491: "yīn,yìn", + 0x8491: "yīn", 0x8492: "shī", 0x8493: "chún", 0x8494: "shí,shì", @@ -19735,7 +19746,7 @@ var PinyinDict = map[int]string{ 0x8496: "zhēn", 0x8497: "làng", 0x8498: "rú,ná", - 0x8499: "méng,měng,mēng", + 0x8499: "méng,mēng,měng", 0x849A: "lì", 0x849B: "quē", 0x849C: "suàn", @@ -19846,9 +19857,9 @@ var PinyinDict = map[int]string{ 0x8505: "yán", 0x8506: "líng", 0x8507: "jì,xì", - 0x8508: "biāo,piǎo,biào", + 0x8508: "biāo,piào,piǎo,biào", 0x8509: "gǔn", - 0x850A: "hǎn", + 0x850A: "hǎn,hàn", 0x850B: "dí", 0x850C: "sù", 0x850D: "lù,cū", @@ -19857,7 +19868,7 @@ var PinyinDict = map[int]string{ 0x8510: "dí", 0x8511: "miè", 0x8512: "xūn", - 0x8513: "màn,wàn,mán", + 0x8513: "màn,mán,wàn", 0x8514: "bó,bo", 0x8515: "dì,dài,chài", 0x8516: "cuó,cǔ,zhā", @@ -19905,7 +19916,7 @@ var PinyinDict = map[int]string{ 0x8540: "jí", 0x8541: "qián,tán,xún", 0x8542: "shèng", - 0x8543: "fān,fán,pí,bō", + 0x8543: "fān,bō,fán,pí", 0x8544: "méng", 0x8545: "ǒu", 0x8546: "chǎn", @@ -19967,10 +19978,10 @@ var PinyinDict = map[int]string{ 0x857E: "lěi", 0x857F: "xuān", 0x8580: "yùn", - 0x8581: "yù", + 0x8581: "yù,ào", 0x8582: "xí,xiào", 0x8583: "hào", - 0x8584: "báo,bó,bù,bò", + 0x8584: "báo,bó,bò,bù", 0x8585: "hāo", 0x8586: "ài", 0x8587: "wēi", @@ -20068,7 +20079,7 @@ var PinyinDict = map[int]string{ 0x85E3: "bēi", 0x85E4: "téng", 0x85E5: "yào,shuò,lüè", - 0x85E6: "mò", + 0x85E6: "mò,mó", 0x85E7: "huàn", 0x85E8: "biāo,pāo", 0x85E9: "fān,fán", @@ -20215,7 +20226,7 @@ var PinyinDict = map[int]string{ 0x8676: "yū", 0x8677: "hán,gān", 0x8678: "zǐ", - 0x8679: "hóng,hòng,gòng,jiàng", + 0x8679: "hóng,jiàng,hòng,gòng", 0x867A: "huī,huǐ", 0x867B: "méng", 0x867C: "gè", @@ -20224,7 +20235,7 @@ var PinyinDict = map[int]string{ 0x867F: "chài", 0x8680: "shí", 0x8681: "yǐ", - 0x8682: "mǎ,mā,mà", + 0x8682: "mǎ,mà,mā", 0x8683: "xiǎng", 0x8684: "fāng,bàng", 0x8685: "è", @@ -20234,7 +20245,7 @@ var PinyinDict = map[int]string{ 0x8689: "wén", 0x868A: "wén", 0x868B: "ruì", - 0x868C: "bàng,pí,fēng,bèng", + 0x868C: "bàng,bèng,pí,fēng", 0x868D: "pí", 0x868E: "yuè", 0x868F: "yuè", @@ -20450,7 +20461,7 @@ var PinyinDict = map[int]string{ 0x8761: "rú,ruǎn", 0x8762: "xié", 0x8763: "yóu", - 0x8764: "qiú,jiū,yóu", + 0x8764: "qiú,yóu,jiū", 0x8765: "máo,wú,wù", 0x8766: "xiā,há,jiǎ", 0x8767: "yīng", @@ -20521,7 +20532,7 @@ var PinyinDict = map[int]string{ 0x87A8: "mǎn", 0x87A9: "tiao", 0x87AA: "shāng", - 0x87AB: "shì", + 0x87AB: "shì,zhē", 0x87AC: "cáo", 0x87AD: "chī", 0x87AE: "dì,dài", @@ -20682,7 +20693,7 @@ var PinyinDict = map[int]string{ 0x8849: "kā", 0x884A: "miè", 0x884B: "xì", - 0x884C: "xíng,háng,xìng,hàng,héng", + 0x884C: "xíng,háng,héng,xìng,hàng", 0x884D: "yǎn,yán", 0x884E: "kàn,kǎn", 0x884F: "yuàn", @@ -20789,7 +20800,7 @@ var PinyinDict = map[int]string{ 0x88B4: "kù", 0x88B5: "rèn", 0x88B6: "jiàng", - 0x88B7: "jiá,jiā,jié,qiā", + 0x88B7: "jiá,qiā,jiā,jié", 0x88B8: "jiàn,zùn", 0x88B9: "bó,mò", 0x88BA: "jié", @@ -20813,7 +20824,7 @@ var PinyinDict = map[int]string{ 0x88CC: "jiá,jiā,xié", 0x88CD: "kǔn", 0x88CE: "chéng,chěng", - 0x88CF: "lǐ,li", + 0x88CF: "lǐ", 0x88D0: "juān", 0x88D1: "shēn", 0x88D2: "póu,bāo", @@ -20831,7 +20842,7 @@ var PinyinDict = map[int]string{ 0x88DE: "shuì", 0x88DF: "shā", 0x88E0: "qún", - 0x88E1: "lǐ,li", + 0x88E1: "lǐ", 0x88E2: "lián,shāo", 0x88E3: "liǎn", 0x88E4: "kù", @@ -20993,7 +21004,7 @@ var PinyinDict = map[int]string{ 0x8980: "xī", 0x8981: "yào,yāo,yǎo", 0x8982: "fěng,bǎn", - 0x8983: "tán,yǎn,qín", + 0x8983: "tán,qín,yǎn", 0x8984: "fù", 0x8985: "fiào", 0x8986: "fù", @@ -21127,7 +21138,7 @@ var PinyinDict = map[int]string{ 0x8A06: "jiào", 0x8A07: "hōng,jùn,hēng", 0x8A08: "jì", - 0x8A09: "fàn,fān", + 0x8A09: "fàn", 0x8A0A: "xùn", 0x8A0B: "diào", 0x8A0C: "hòng", @@ -21412,7 +21423,7 @@ var PinyinDict = map[int]string{ 0x8B23: "yú,xū", 0x8B24: "biāo,piāo", 0x8B25: "còng", - 0x8B26: "qìng,qǐng", + 0x8B26: "qǐng,qìng", 0x8B27: "lí", 0x8B28: "mó", 0x8B29: "mó", @@ -21531,7 +21542,7 @@ var PinyinDict = map[int]string{ 0x8B9A: "zàn", 0x8B9B: "yì", 0x8B9C: "dǎng,dàng", - 0x8B9D: "zhán", + 0x8B9D: "zhán,zhān", 0x8B9E: "yàn", 0x8B9F: "dú", 0x8BA0: "yán", @@ -21602,7 +21613,7 @@ var PinyinDict = map[int]string{ 0x8BE1: "guǐ", 0x8BE2: "xún", 0x8BE3: "yì", - 0x8BE4: "zhēng", + 0x8BE4: "zhèng,zhēng", 0x8BE5: "gāi", 0x8BE6: "xiáng", 0x8BE7: "chà", @@ -21631,7 +21642,7 @@ var PinyinDict = map[int]string{ 0x8BFE: "kè", 0x8BFF: "wěi", 0x8C00: "yú", - 0x8C01: "shéi,shuí", + 0x8C01: "shuí,shéi", 0x8C02: "shěn", 0x8C03: "diào,tiáo", 0x8C04: "chǎn", @@ -21750,7 +21761,7 @@ var PinyinDict = map[int]string{ 0x8C75: "zōng", 0x8C76: "fén", 0x8C77: "yì", - 0x8C78: "zhì", + 0x8C78: "zhì,zhài", 0x8C79: "bào", 0x8C7A: "chái", 0x8C7B: "àn", @@ -21767,7 +21778,7 @@ var PinyinDict = map[int]string{ 0x8C86: "huán,huān", 0x8C87: "kūn,mào,kěn", 0x8C88: "hé,mò", - 0x8C89: "háo,mò,hé,mà", + 0x8C89: "háo,hé,mò,mà", 0x8C8A: "mò,má", 0x8C8B: "àn", 0x8C8C: "mào,mò", @@ -22132,7 +22143,7 @@ var PinyinDict = map[int]string{ 0x8DF3: "tiào,diào,táo", 0x8DF4: "cǎi", 0x8DF5: "jiàn", - 0x8DF6: "dá", + 0x8DF6: "dá,da", 0x8DF7: "qiāo", 0x8DF8: "bì", 0x8DF9: "xiān", @@ -22151,7 +22162,7 @@ var PinyinDict = map[int]string{ 0x8E06: "cūn,qūn,cún,zūn,qiù,zhūn", 0x8E07: "mǔ", 0x8E08: "shū", - 0x8E09: "liáng,láng,liàng,làng", + 0x8E09: "liáng,liàng,láng,làng", 0x8E0A: "yǒng", 0x8E0B: "jiǎo", 0x8E0C: "chóu", @@ -22260,7 +22271,7 @@ var PinyinDict = map[int]string{ 0x8E73: "bō", 0x8E74: "cù,zú,jiu", 0x8E75: "cù", - 0x8E76: "jué,guì,juě", + 0x8E76: "jué,juě,guì", 0x8E77: "jué", 0x8E78: "lìn,lín", 0x8E79: "tá", @@ -22501,12 +22512,12 @@ var PinyinDict = map[int]string{ 0x8F64: "lú", 0x8F65: "lìn", 0x8F66: "chē,jū", - 0x8F67: "yà,gá,zhá", + 0x8F67: "yà,zhá,gá", 0x8F68: "guǐ", 0x8F69: "xuān", 0x8F6A: "dài", 0x8F6B: "rèn", - 0x8F6C: "zhuǎn,zhuǎi,zhuàn", + 0x8F6C: "zhuǎn,zhuàn,zhuǎi", 0x8F6D: "è", 0x8F6E: "lún", 0x8F6F: "ruǎn", @@ -22614,7 +22625,7 @@ var PinyinDict = map[int]string{ 0x8FD5: "wù,wǔ", 0x8FD6: "dá", 0x8FD7: "é", - 0x8FD8: "hái,fú,huán", + 0x8FD8: "hái,huán,fú", 0x8FD9: "zhè,zhèi", 0x8FDA: "dá", 0x8FDB: "jìn", @@ -22647,7 +22658,7 @@ var PinyinDict = map[int]string{ 0x8FF6: "yòu", 0x8FF7: "mí,mì", 0x8FF8: "bèng", - 0x8FF9: "jī", + 0x8FF9: "jì,jī", 0x8FFA: "nǎi", 0x8FFB: "yí", 0x8FFC: "jié", @@ -22752,7 +22763,7 @@ var PinyinDict = map[int]string{ 0x905F: "chí,zhì,xī", 0x9060: "yuǎn,yuàn", 0x9061: "sù", - 0x9062: "tà", + 0x9062: "tà,tā", 0x9063: "qiǎn,qiàn", 0x9064: "mǎ", 0x9065: "yáo", @@ -22817,7 +22828,7 @@ var PinyinDict = map[int]string{ 0x90A0: "bīn", 0x90A1: "fāng,fàng", 0x90A2: "xíng,gěng", - 0x90A3: "nà,nuó,nuò,nèi,nǎ,něi,né,nā,nǎi,nè", + 0x90A3: "nà,nā,nuó,nuò,nèi,nǎ,něi,né,nǎi,nè", 0x90A4: "xīn", 0x90A5: "shěn", 0x90A6: "bāng", @@ -22870,7 +22881,7 @@ var PinyinDict = map[int]string{ 0x90D5: "chéng", 0x90D6: "dòu", 0x90D7: "xī,chī", - 0x90D8: "lǚ,lǘ", + 0x90D8: "lǚ", 0x90D9: "fǔ", 0x90DA: "wú,yú", 0x90DB: "fú", @@ -23012,7 +23023,7 @@ var PinyinDict = map[int]string{ 0x9163: "hān,hàn", 0x9164: "gū", 0x9165: "sū", - 0x9166: "pò,fā,pō", + 0x9166: "pò,pō,fā", 0x9167: "chóu", 0x9168: "zài,zuì", 0x9169: "mǐng", @@ -23678,7 +23689,7 @@ var PinyinDict = map[int]string{ 0x93FD: "xiù", 0x93FE: "sǎn,xiàn,sà", 0x93FF: "chēng", - 0x9400: "kuì", + 0x9400: "kuì,guì", 0x9401: "sī", 0x9402: "liú", 0x9403: "náo,nào", @@ -24376,7 +24387,7 @@ var PinyinDict = map[int]string{ 0x96B7: "lì", 0x96B8: "lì", 0x96B9: "zhuī,cuī,wéi", - 0x96BA: "hú,què,hè", + 0x96BA: "hú,hè,què", 0x96BB: "zhī,huò", 0x96BC: "sǔn", 0x96BD: "juàn,jùn", @@ -24494,7 +24505,7 @@ var PinyinDict = map[int]string{ 0x972D: "ǎi", 0x972E: "dàn", 0x972F: "tèng", - 0x9730: "sǎn,xiàn", + 0x9730: "xiàn,sǎn", 0x9731: "yù", 0x9732: "lù,lòu", 0x9733: "lóng", @@ -24579,7 +24590,7 @@ var PinyinDict = map[int]string{ 0x9782: "jiē", 0x9783: "hóng", 0x9784: "páo", - 0x9785: "yāng,yǎng,yàng", + 0x9785: "yāng,yàng,yǎng", 0x9786: "bǐng", 0x9787: "yīn", 0x9788: "gé,sǎ,tà", @@ -25079,7 +25090,7 @@ var PinyinDict = map[int]string{ 0x9976: "ráo", 0x9977: "xiǎng", 0x9978: "hé", - 0x9979: "le", + 0x9979: "le,gē", 0x997A: "jiǎo", 0x997B: "xī", 0x997C: "bǐng", @@ -25093,7 +25104,7 @@ var PinyinDict = map[int]string{ 0x9984: "hún", 0x9985: "xiàn", 0x9986: "guǎn", - 0x9987: "chā", + 0x9987: "chā,zha", 0x9988: "kuì", 0x9989: "gǔ", 0x998A: "sōu", @@ -25325,7 +25336,7 @@ var PinyinDict = map[int]string{ 0x9A6C: "mǎ", 0x9A6D: "yù", 0x9A6E: "tuó,duò", - 0x9A6F: "xún", + 0x9A6F: "xùn,xún", 0x9A70: "chí", 0x9A71: "qū", 0x9A72: "rì", @@ -25382,7 +25393,7 @@ var PinyinDict = map[int]string{ 0x9AA5: "jì", 0x9AA6: "shuāng", 0x9AA7: "xiāng", - 0x9AA8: "gǔ,gú,gū", + 0x9AA8: "gǔ,gū,gú", 0x9AA9: "wěi", 0x9AAA: "wěi", 0x9AAB: "wěi,wán", @@ -26018,7 +26029,7 @@ var PinyinDict = map[int]string{ 0x9D21: "jū", 0x9D22: "yǎo,āo", 0x9D23: "gū", - 0x9D24: "zhōng,dōng", + 0x9D24: "zhōng", 0x9D25: "yù", 0x9D26: "yāng", 0x9D27: "yù", @@ -26429,7 +26440,7 @@ var PinyinDict = map[int]string{ 0x9EBC: "me", 0x9EBD: "mó,má,ma,me", 0x9EBE: "huī", - 0x9EBF: "mo", + 0x9EBF: "mí", 0x9EC0: "zōu", 0x9EC1: "nún", 0x9EC2: "fén", @@ -26492,7 +26503,7 @@ var PinyinDict = map[int]string{ 0x9EFB: "fú", 0x9EFC: "fǔ", 0x9EFD: "miǎn,měng,mǐn,méng", - 0x9EFE: "miǎn,mǐn", + 0x9EFE: "mǐn,miǎn,měng", 0x9EFF: "yuán", 0x9F00: "cù", 0x9F01: "qù", @@ -26662,7 +26673,7 @@ var PinyinDict = map[int]string{ 0x9FA5: "yù", 0x9FC3: "shǎn", 0x9FCD: "gàng", - 0x9FCE: "tǎ", + 0x9FCE: "tǎ,dá", 0x9FCF: "mài", 0x9FD4: "gē", 0x9FD5: "dān", @@ -26739,6 +26750,7 @@ var PinyinDict = map[int]string{ 0xE862: "pì", 0xE863: "yǎn", 0xE864: "luán", + 0xFA18: "lǐ", 0x20000: "hē", 0x20001: "qī", 0x20003: "qiě,jī", @@ -26758,6 +26770,7 @@ var PinyinDict = map[int]string{ 0x20039: "jūn", 0x2003C: "qián,xià", 0x2003D: "lù", + 0x20041: "dòu", 0x20049: "chū", 0x20057: "shì,hè", 0x20060: "qiè", @@ -26770,6 +26783,7 @@ var PinyinDict = map[int]string{ 0x20088: "jié,tiǎn", 0x20091: "zōu", 0x20094: "zǐ", + 0x2009D: "zā", 0x2009F: "jīn", 0x200A2: "pài", 0x200A4: "duī", @@ -29799,6 +29813,7 @@ var PinyinDict = map[int]string{ 0x228DE: "bó", 0x228E0: "liù", 0x228F3: "ruì", + 0x228F5: "chú", 0x228FB: "lǘ", 0x228FC: "chá", 0x228FF: "chù", @@ -30628,6 +30643,7 @@ var PinyinDict = map[int]string{ 0x23539: "hóu", 0x2353A: "mào", 0x2353B: "tú,chán", + 0x2353C: "gān", 0x2353D: "jì", 0x23541: "yí", 0x23543: "yù", @@ -31657,6 +31673,7 @@ var PinyinDict = map[int]string{ 0x24355: "yǒu", 0x24356: "jiān", 0x2435C: "zào", + 0x24360: "rè", 0x24364: "zhāng", 0x2437D: "ruò", 0x24384: "yān", @@ -31722,6 +31739,7 @@ var PinyinDict = map[int]string{ 0x24500: "ná", 0x24509: "páo", 0x2450B: "jù", + 0x24514: "luàn", 0x24516: "luǒ", 0x24519: "shuǎ", 0x2451A: "shàng", @@ -32758,6 +32776,7 @@ var PinyinDict = map[int]string{ 0x25075: "chōng", 0x25078: "quān", 0x25079: "shè", + 0x25081: "yán", 0x25082: "měng", 0x25083: "jù", 0x2508B: "tú", @@ -33304,6 +33323,7 @@ var PinyinDict = map[int]string{ 0x255F5: "xiàng", 0x255F6: "lèi", 0x255FA: "làn", + 0x255FD: "lán", 0x255FF: "lǎ", 0x25601: "lǎ", 0x25604: "yù", @@ -33798,7 +33818,7 @@ var PinyinDict = map[int]string{ 0x25C1C: "táo", 0x25C1D: "xī", 0x25C1E: "chōu,sǒu", - 0x25C1F: "yuán,gǎn", + 0x25C1F: "yuán", 0x25C20: "lǘ", 0x25C21: "cè", 0x25C22: "shàn", @@ -34837,7 +34857,7 @@ var PinyinDict = map[int]string{ 0x26773: "xù", 0x26774: "yìn", 0x26777: "bèng", - 0x2677C: "lǘ", + 0x2677C: "lǘ,lóu", 0x26781: "zāi", 0x26782: "dā,da", 0x26786: "niè", @@ -35265,7 +35285,7 @@ var PinyinDict = map[int]string{ 0x26C18: "zhǐ", 0x26C19: "bì", 0x26C1B: "fén", - 0x26C21: "nà", + 0x26C21: "nà,nuó", 0x26C25: "bāng", 0x26C2A: "qiú", 0x26C2B: "nǐ", @@ -35615,6 +35635,7 @@ var PinyinDict = map[int]string{ 0x27034: "fū", 0x27035: "jiàn,shǎn", 0x27036: "dì", + 0x27039: "zhè", 0x2703A: "xié", 0x2703B: "dān", 0x2703F: "zhí", @@ -35847,7 +35868,7 @@ var PinyinDict = map[int]string{ 0x272D2: "tóng,shì", 0x272D3: "kào", 0x272D4: "hòng", - 0x272D5: "kùn,kǔn", + 0x272D5: "kùn", 0x272D6: "niè", 0x272D7: "chí", 0x272D8: "tí", @@ -36117,7 +36138,7 @@ var PinyinDict = map[int]string{ 0x27574: "nán", 0x27575: "mì", 0x27578: "huáng", - 0x2757A: "shuāng,shuàng", + 0x2757A: "shuāng", 0x2757C: "xǔ", 0x2757F: "fěi", 0x27581: "xiè,wén", @@ -36472,7 +36493,7 @@ var PinyinDict = map[int]string{ 0x27951: "bì", 0x27953: "chán", 0x27955: "zī", - 0x27956: "lí,lì,shǐ", + 0x27956: "lí,shǐ", 0x2795A: "fó", 0x2795B: "qiǎn", 0x2795C: "yǎn", @@ -36910,6 +36931,7 @@ var PinyinDict = map[int]string{ 0x27DA1: "mì", 0x27DB2: "duǎn,zhuàn", 0x27DB5: "chà", + 0x27DB6: "fàn", 0x27DB7: "zé", 0x27DB8: "chèng", 0x27DBA: "tíng", @@ -37233,7 +37255,7 @@ var PinyinDict = map[int]string{ 0x2809F: "kāng", 0x280A0: "xū,lǚ", 0x280A1: "zòu", - 0x280A2: "jí,jì", + 0x280A2: "jí", 0x280A3: "wù", 0x280A6: "chuàn", 0x280A9: "pò", @@ -37376,7 +37398,7 @@ var PinyinDict = map[int]string{ 0x28241: "huàng", 0x28243: "rèn", 0x28245: "yè", - 0x2824B: "tuō,tuó", + 0x2824B: "tuō", 0x28256: "zuān", 0x28257: "yù", 0x2825A: "ā", @@ -37630,7 +37652,7 @@ var PinyinDict = map[int]string{ 0x284A4: "cǐ", 0x284A6: "yǐn", 0x284A7: "shì", - 0x284A8: "hài,nài", + 0x284A8: "hài", 0x284A9: "ruǎn", 0x284AB: "yáng,nì", 0x284AC: "chī", @@ -38075,6 +38097,7 @@ var PinyinDict = map[int]string{ 0x289B0: "liú", 0x289B1: "cōng", 0x289B3: "nǎn", + 0x289C0: "dù", 0x289D0: "tūn", 0x289D1: "xiàng", 0x289D5: "biàn", @@ -38092,6 +38115,7 @@ var PinyinDict = map[int]string{ 0x289F1: "qū", 0x289F3: "chì", 0x289F5: "zhì", + 0x28A0F: "bō", 0x28A17: "quàn", 0x28A18: "qiān", 0x28A19: "yā", @@ -38172,6 +38196,7 @@ var PinyinDict = map[int]string{ 0x28B45: "zhù", 0x28B46: "hēi", 0x28B49: "bān", + 0x28B4E: "xǐ", 0x28B53: "dié", 0x28B56: "zhǎn", 0x28B57: "guó", @@ -38422,7 +38447,7 @@ var PinyinDict = map[int]string{ 0x28DE6: "lì", 0x28DE9: "tóu", 0x28DEC: "mǐ", - 0x28DED: "chán,chǎn", + 0x28DED: "chán", 0x28DEE: "huō", 0x28DF1: "zhuǎn", 0x28DF2: "yuè", @@ -38460,7 +38485,7 @@ var PinyinDict = map[int]string{ 0x28E2D: "pō", 0x28E2E: "yán,yǔn", 0x28E2F: "gū", - 0x28E30: "jú,jù", + 0x28E30: "jú", 0x28E31: "tiàn,niǎn", 0x28E37: "è", 0x28E3A: "yā", @@ -39061,7 +39086,7 @@ var PinyinDict = map[int]string{ 0x293C7: "duàn", 0x293C8: "ruǎn", 0x293C9: "wéi", - 0x293CF: "wéi,wěi", + 0x293CF: "wéi", 0x293D0: "guì,wěi", 0x293D2: "dá", 0x293D3: "xiá", @@ -39362,7 +39387,7 @@ var PinyinDict = map[int]string{ 0x295F1: "xī", 0x295F2: "zhēng", 0x295F4: "bèng", - 0x295F5: "zhēng,zhěng", + 0x295F5: "zhēng", 0x295F6: "suì", 0x295F7: "yǎn", 0x295FC: "qīng", @@ -39985,7 +40010,7 @@ var PinyinDict = map[int]string{ 0x29B52: "máng", 0x29B53: "jiū", 0x29B58: "xiū", - 0x29B5D: "wǒ,wō", + 0x29B5D: "wǒ", 0x29B5F: "dào", 0x29B61: "xī", 0x29B62: "àn", @@ -41252,7 +41277,7 @@ var PinyinDict = map[int]string{ 0x2A6CE: "pì", 0x2A6D2: "lián", 0x2A79D: "duó", - 0x2A7DD: "jì", + 0x2A7DD: "jì,jī", 0x2A848: "bái", 0x2A84F: "zhān", 0x2A8AE: "luán", @@ -41293,7 +41318,7 @@ var PinyinDict = map[int]string{ 0x2B406: "kuài", 0x2B409: "líng", 0x2B410: "ní", - 0x2B413: "bù", + 0x2B413: "bù,róu", 0x2B461: "méng", 0x2B4B6: "hán", 0x2B4E7: "fū", @@ -41335,45 +41360,58 @@ var PinyinDict = map[int]string{ 0x2B6ED: "kuáng", 0x2B6F6: "chì", 0x2B6F8: "tí", + 0x2B737: "shòu", + 0x2B738: "huà", 0x2B7A9: "mén", 0x2B7C5: "liáng", 0x2B7E6: "suì", + 0x2B7F7: "lì", 0x2B7F9: "hóng", 0x2B7FC: "dá", 0x2B806: "kuǐ", 0x2B80A: "xuán", 0x2B81C: "ní", + 0x2B825: "lòu", 0x2B851: "yīn", 0x2B8B8: "dàn", - 0x2BAC7: "ě", - 0x2BB5F: "ōu", + 0x2BAC7: "ě,è", + 0x2BB5F: "ōu,qū", 0x2BB62: "lǔn", 0x2BB7C: "láo", 0x2BB83: "shàn", + 0x2BBAC: "jiàng", 0x2BC1B: "xíng", 0x2BD77: "lì", 0x2BD87: "dié", 0x2BDF7: "xīn", 0x2BE29: "kōu", + 0x2BF1B: "diào", + 0x2BF6E: "dǎng", 0x2C029: "wěi", 0x2C02A: "xiàn", + 0x2C037: "shāng", 0x2C0A9: "jiā", 0x2C0CA: "zhì", + 0x2C19B: "nǎo", 0x2C1D5: "wàn", - 0x2C1D9: "pèi", + 0x2C1D9: "pèi,bèi", 0x2C1F9: "guó", - 0x2C27C: "ōu", + 0x2C27C: "ōu,ǒu", 0x2C288: "xún", 0x2C2A4: "chǎn", 0x2C317: "hé", 0x2C35B: "lì", 0x2C361: "dàng", 0x2C364: "xún", + 0x2C41A: "hǎi", + 0x2C454: "zhòng", + 0x2C461: "chǒu", 0x2C488: "què", 0x2C494: "gěng", 0x2C497: "lán", + 0x2C498: "xìn", 0x2C4FC: "tuí", - 0x2C542: "gōng", + 0x2C542: "gōng,lǒng", 0x2C613: "xún", 0x2C618: "dǎn", 0x2C621: "yīn", @@ -41385,6 +41423,7 @@ var PinyinDict = map[int]string{ 0x2C642: "yǎn", 0x2C64A: "mò", 0x2C64B: "xiāng", + 0x2C6F8: "niē", 0x2C72C: "màn", 0x2C72F: "liǎng", 0x2C79F: "pín", @@ -41417,18 +41456,21 @@ var PinyinDict = map[int]string{ 0x2CB5B: "bō", 0x2CB64: "hóu", 0x2CB69: "wēng", - 0x2CB6C: "wèi", + 0x2CB6C: "wèi,huì", 0x2CB6F: "piě", 0x2CB73: "xǐ", 0x2CB76: "hēi", 0x2CB78: "lín", 0x2CB7C: "suì", 0x2CBB1: "yīn", - 0x2CBBF: "qí", + 0x2CBBF: "qí,gài", 0x2CBC0: "jī", 0x2CBCE: "tuí", + 0x2CC03: "mù", 0x2CC56: "dí", 0x2CC5F: "wěi", + 0x2CC9C: "chēng", + 0x2CCF2: "chǎn", 0x2CCF5: "pī", 0x2CCF6: "jiōng", 0x2CCFD: "shēn", @@ -41445,7 +41487,7 @@ var PinyinDict = map[int]string{ 0x2CDA8: "jì", 0x2CDAD: "jì", 0x2CDAE: "xǐ", - 0x2CDD5: "bū", + 0x2CDD5: "bū,bǔ", 0x2CE18: "yǎn", 0x2CE1A: "yuè", 0x2CE23: "xiān", @@ -41454,4 +41496,8 @@ var PinyinDict = map[int]string{ 0x2CE7C: "xiè", 0x2CE88: "yǐ", 0x2CE93: "chǔ", + 0x2D016: "lí", + 0x2F835: "huī", + 0x30EDD: "biáng", + 0x30EDE: "biáng", } diff --git a/vendor/github.com/smartystreets/assertions/.gitignore b/vendor/github.com/smartystreets/assertions/.gitignore index 07d3c71ce2..1f088e844d 100644 --- a/vendor/github.com/smartystreets/assertions/.gitignore +++ b/vendor/github.com/smartystreets/assertions/.gitignore @@ -1,5 +1,4 @@ -.DS_Store -Thumbs.db -*.iml /.idea -coverage.out +/coverage.* +.DS_Store +*.iml diff --git a/vendor/github.com/smartystreets/assertions/.travis.yml b/vendor/github.com/smartystreets/assertions/.travis.yml index 72df752f82..d4e3e1f0fb 100644 --- a/vendor/github.com/smartystreets/assertions/.travis.yml +++ b/vendor/github.com/smartystreets/assertions/.travis.yml @@ -1,11 +1,23 @@ +dist: bionic + language: go go: - 1.x -install: - - go get -t ./... +env: + - GO111MODULE=on -script: go test ./... -v +script: + - make build -sudo: false +after_success: + - bash <(curl -s https://codecov.io/bash) + +git: + depth: 1 + +cache: + directories: + - $HOME/.cache/go-build + - $HOME/gopath/pkg/mod diff --git a/vendor/github.com/smartystreets/assertions/Makefile b/vendor/github.com/smartystreets/assertions/Makefile new file mode 100644 index 0000000000..5c27b7ba0d --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/Makefile @@ -0,0 +1,14 @@ +#!/usr/bin/make -f + +test: fmt + go test -timeout=1s -race -cover -short -count=1 ./... + +fmt: + go fmt ./... + +compile: + go build ./... + +build: test compile + +.PHONY: test compile build diff --git a/vendor/github.com/smartystreets/assertions/README.md b/vendor/github.com/smartystreets/assertions/README.md index 58e51e903f..10c8d20138 100644 --- a/vendor/github.com/smartystreets/assertions/README.md +++ b/vendor/github.com/smartystreets/assertions/README.md @@ -1,611 +1,4 @@ -# assertions --- - import "github.com/smartystreets/assertions" - -Package assertions contains the implementations for all assertions which are -referenced in goconvey's `convey` package -(github.com/smartystreets/goconvey/convey) and gunit -(github.com/smartystreets/gunit) for use with the So(...) method. They can also -be used in traditional Go test functions and even in applications. - -https://smartystreets.com - -Many of the assertions lean heavily on work done by Aaron Jacobs in his -excellent oglematchers library. (https://github.com/jacobsa/oglematchers) The -ShouldResemble assertion leans heavily on work done by Daniel Jacques in his -very helpful go-render library. (https://github.com/luci/go-render) - -## Usage - -#### func GoConveyMode - -```go -func GoConveyMode(yes bool) -``` -GoConveyMode provides control over JSON serialization of failures. When using -the assertions in this package from the convey package JSON results are very -helpful and can be rendered in a DIFF view. In that case, this function will be -called with a true value to enable the JSON serialization. By default, the -assertions in this package will not serializer a JSON result, making standalone -usage more convenient. - -#### func ShouldAlmostEqual - -```go -func ShouldAlmostEqual(actual interface{}, expected ...interface{}) string -``` -ShouldAlmostEqual makes sure that two parameters are close enough to being -equal. The acceptable delta may be specified with a third argument, or a very -small default delta will be used. - -#### func ShouldBeBetween - -```go -func ShouldBeBetween(actual interface{}, expected ...interface{}) string -``` -ShouldBeBetween receives exactly three parameters: an actual value, a lower -bound, and an upper bound. It ensures that the actual value is between both -bounds (but not equal to either of them). - -#### func ShouldBeBetweenOrEqual - -```go -func ShouldBeBetweenOrEqual(actual interface{}, expected ...interface{}) string -``` -ShouldBeBetweenOrEqual receives exactly three parameters: an actual value, a -lower bound, and an upper bound. It ensures that the actual value is between -both bounds or equal to one of them. - -#### func ShouldBeBlank - -```go -func ShouldBeBlank(actual interface{}, expected ...interface{}) string -``` -ShouldBeBlank receives exactly 1 string parameter and ensures that it is equal -to "". - -#### func ShouldBeChronological - -```go -func ShouldBeChronological(actual interface{}, expected ...interface{}) string -``` -ShouldBeChronological receives a []time.Time slice and asserts that the are in -chronological order starting with the first time.Time as the earliest. - -#### func ShouldBeEmpty - -```go -func ShouldBeEmpty(actual interface{}, expected ...interface{}) string -``` -ShouldBeEmpty receives a single parameter (actual) and determines whether or not -calling len(actual) would return `0`. It obeys the rules specified by the len -function for determining length: http://golang.org/pkg/builtin/#len - -#### func ShouldBeError - -```go -func ShouldBeError(actual interface{}, expected ...interface{}) string -``` -ShouldBeError asserts that the first argument implements the error interface. It -also compares the first argument against the second argument if provided (which -must be an error message string or another error value). - -#### func ShouldBeFalse - -```go -func ShouldBeFalse(actual interface{}, expected ...interface{}) string -``` -ShouldBeFalse receives a single parameter and ensures that it is false. - -#### func ShouldBeGreaterThan - -```go -func ShouldBeGreaterThan(actual interface{}, expected ...interface{}) string -``` -ShouldBeGreaterThan receives exactly two parameters and ensures that the first -is greater than the second. - -#### func ShouldBeGreaterThanOrEqualTo - -```go -func ShouldBeGreaterThanOrEqualTo(actual interface{}, expected ...interface{}) string -``` -ShouldBeGreaterThanOrEqualTo receives exactly two parameters and ensures that -the first is greater than or equal to the second. - -#### func ShouldBeIn - -```go -func ShouldBeIn(actual interface{}, expected ...interface{}) string -``` -ShouldBeIn receives at least 2 parameters. The first is a proposed member of the -collection that is passed in either as the second parameter, or of the -collection that is comprised of all the remaining parameters. This assertion -ensures that the proposed member is in the collection (using ShouldEqual). - -#### func ShouldBeLessThan - -```go -func ShouldBeLessThan(actual interface{}, expected ...interface{}) string -``` -ShouldBeLessThan receives exactly two parameters and ensures that the first is -less than the second. - -#### func ShouldBeLessThanOrEqualTo - -```go -func ShouldBeLessThanOrEqualTo(actual interface{}, expected ...interface{}) string -``` -ShouldBeLessThan receives exactly two parameters and ensures that the first is -less than or equal to the second. - -#### func ShouldBeNil - -```go -func ShouldBeNil(actual interface{}, expected ...interface{}) string -``` -ShouldBeNil receives a single parameter and ensures that it is nil. - -#### func ShouldBeTrue - -```go -func ShouldBeTrue(actual interface{}, expected ...interface{}) string -``` -ShouldBeTrue receives a single parameter and ensures that it is true. - -#### func ShouldBeZeroValue - -```go -func ShouldBeZeroValue(actual interface{}, expected ...interface{}) string -``` -ShouldBeZeroValue receives a single parameter and ensures that it is the Go -equivalent of the default value, or "zero" value. - -#### func ShouldContain - -```go -func ShouldContain(actual interface{}, expected ...interface{}) string -``` -ShouldContain receives exactly two parameters. The first is a slice and the -second is a proposed member. Membership is determined using ShouldEqual. - -#### func ShouldContainKey - -```go -func ShouldContainKey(actual interface{}, expected ...interface{}) string -``` -ShouldContainKey receives exactly two parameters. The first is a map and the -second is a proposed key. Keys are compared with a simple '=='. - -#### func ShouldContainSubstring - -```go -func ShouldContainSubstring(actual interface{}, expected ...interface{}) string -``` -ShouldContainSubstring receives exactly 2 string parameters and ensures that the -first contains the second as a substring. - -#### func ShouldEndWith - -```go -func ShouldEndWith(actual interface{}, expected ...interface{}) string -``` -ShouldEndWith receives exactly 2 string parameters and ensures that the first -ends with the second. - -#### func ShouldEqual - -```go -func ShouldEqual(actual interface{}, expected ...interface{}) string -``` -ShouldEqual receives exactly two parameters and does an equality check using the -following semantics: 1. If the expected and actual values implement an Equal -method in the form `func (this T) Equal(that T) bool` then call the method. If -true, they are equal. 2. The expected and actual values are judged equal or not -by oglematchers.Equals. - -#### func ShouldEqualJSON - -```go -func ShouldEqualJSON(actual interface{}, expected ...interface{}) string -``` -ShouldEqualJSON receives exactly two parameters and does an equality check by -marshalling to JSON - -#### func ShouldEqualTrimSpace - -```go -func ShouldEqualTrimSpace(actual interface{}, expected ...interface{}) string -``` -ShouldEqualTrimSpace receives exactly 2 string parameters and ensures that the -first is equal to the second after removing all leading and trailing whitespace -using strings.TrimSpace(first). - -#### func ShouldEqualWithout - -```go -func ShouldEqualWithout(actual interface{}, expected ...interface{}) string -``` -ShouldEqualWithout receives exactly 3 string parameters and ensures that the -first is equal to the second after removing all instances of the third from the -first using strings.Replace(first, third, "", -1). - -#### func ShouldHappenAfter - -```go -func ShouldHappenAfter(actual interface{}, expected ...interface{}) string -``` -ShouldHappenAfter receives exactly 2 time.Time arguments and asserts that the -first happens after the second. - -#### func ShouldHappenBefore - -```go -func ShouldHappenBefore(actual interface{}, expected ...interface{}) string -``` -ShouldHappenBefore receives exactly 2 time.Time arguments and asserts that the -first happens before the second. - -#### func ShouldHappenBetween - -```go -func ShouldHappenBetween(actual interface{}, expected ...interface{}) string -``` -ShouldHappenBetween receives exactly 3 time.Time arguments and asserts that the -first happens between (not on) the second and third. - -#### func ShouldHappenOnOrAfter - -```go -func ShouldHappenOnOrAfter(actual interface{}, expected ...interface{}) string -``` -ShouldHappenOnOrAfter receives exactly 2 time.Time arguments and asserts that -the first happens on or after the second. - -#### func ShouldHappenOnOrBefore - -```go -func ShouldHappenOnOrBefore(actual interface{}, expected ...interface{}) string -``` -ShouldHappenOnOrBefore receives exactly 2 time.Time arguments and asserts that -the first happens on or before the second. - -#### func ShouldHappenOnOrBetween - -```go -func ShouldHappenOnOrBetween(actual interface{}, expected ...interface{}) string -``` -ShouldHappenOnOrBetween receives exactly 3 time.Time arguments and asserts that -the first happens between or on the second and third. - -#### func ShouldHappenWithin - -```go -func ShouldHappenWithin(actual interface{}, expected ...interface{}) string -``` -ShouldHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 -arguments) and asserts that the first time.Time happens within or on the -duration specified relative to the other time.Time. - -#### func ShouldHaveLength - -```go -func ShouldHaveLength(actual interface{}, expected ...interface{}) string -``` -ShouldHaveLength receives 2 parameters. The first is a collection to check the -length of, the second being the expected length. It obeys the rules specified by -the len function for determining length: http://golang.org/pkg/builtin/#len - -#### func ShouldHaveSameTypeAs - -```go -func ShouldHaveSameTypeAs(actual interface{}, expected ...interface{}) string -``` -ShouldHaveSameTypeAs receives exactly two parameters and compares their -underlying types for equality. - -#### func ShouldImplement - -```go -func ShouldImplement(actual interface{}, expectedList ...interface{}) string -``` -ShouldImplement receives exactly two parameters and ensures that the first -implements the interface type of the second. - -#### func ShouldNotAlmostEqual - -```go -func ShouldNotAlmostEqual(actual interface{}, expected ...interface{}) string -``` -ShouldNotAlmostEqual is the inverse of ShouldAlmostEqual - -#### func ShouldNotBeBetween - -```go -func ShouldNotBeBetween(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeBetween receives exactly three parameters: an actual value, a lower -bound, and an upper bound. It ensures that the actual value is NOT between both -bounds. - -#### func ShouldNotBeBetweenOrEqual - -```go -func ShouldNotBeBetweenOrEqual(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeBetweenOrEqual receives exactly three parameters: an actual value, a -lower bound, and an upper bound. It ensures that the actual value is nopt -between the bounds nor equal to either of them. - -#### func ShouldNotBeBlank - -```go -func ShouldNotBeBlank(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeBlank receives exactly 1 string parameter and ensures that it is -equal to "". - -#### func ShouldNotBeEmpty - -```go -func ShouldNotBeEmpty(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeEmpty receives a single parameter (actual) and determines whether or -not calling len(actual) would return a value greater than zero. It obeys the -rules specified by the `len` function for determining length: -http://golang.org/pkg/builtin/#len - -#### func ShouldNotBeIn - -```go -func ShouldNotBeIn(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeIn receives at least 2 parameters. The first is a proposed member of -the collection that is passed in either as the second parameter, or of the -collection that is comprised of all the remaining parameters. This assertion -ensures that the proposed member is NOT in the collection (using ShouldEqual). - -#### func ShouldNotBeNil - -```go -func ShouldNotBeNil(actual interface{}, expected ...interface{}) string -``` -ShouldNotBeNil receives a single parameter and ensures that it is not nil. - -#### func ShouldNotBeZeroValue - -```go -func ShouldNotBeZeroValue(actual interface{}, expected ...interface{}) string -``` -ShouldBeZeroValue receives a single parameter and ensures that it is NOT the Go -equivalent of the default value, or "zero" value. - -#### func ShouldNotContain - -```go -func ShouldNotContain(actual interface{}, expected ...interface{}) string -``` -ShouldNotContain receives exactly two parameters. The first is a slice and the -second is a proposed member. Membership is determinied using ShouldEqual. - -#### func ShouldNotContainKey - -```go -func ShouldNotContainKey(actual interface{}, expected ...interface{}) string -``` -ShouldNotContainKey receives exactly two parameters. The first is a map and the -second is a proposed absent key. Keys are compared with a simple '=='. - -#### func ShouldNotContainSubstring - -```go -func ShouldNotContainSubstring(actual interface{}, expected ...interface{}) string -``` -ShouldNotContainSubstring receives exactly 2 string parameters and ensures that -the first does NOT contain the second as a substring. - -#### func ShouldNotEndWith - -```go -func ShouldNotEndWith(actual interface{}, expected ...interface{}) string -``` -ShouldEndWith receives exactly 2 string parameters and ensures that the first -does not end with the second. - -#### func ShouldNotEqual - -```go -func ShouldNotEqual(actual interface{}, expected ...interface{}) string -``` -ShouldNotEqual receives exactly two parameters and does an inequality check. See -ShouldEqual for details on how equality is determined. - -#### func ShouldNotHappenOnOrBetween - -```go -func ShouldNotHappenOnOrBetween(actual interface{}, expected ...interface{}) string -``` -ShouldNotHappenOnOrBetween receives exactly 3 time.Time arguments and asserts -that the first does NOT happen between or on the second or third. - -#### func ShouldNotHappenWithin - -```go -func ShouldNotHappenWithin(actual interface{}, expected ...interface{}) string -``` -ShouldNotHappenWithin receives a time.Time, a time.Duration, and a time.Time (3 -arguments) and asserts that the first time.Time does NOT happen within or on the -duration specified relative to the other time.Time. - -#### func ShouldNotHaveSameTypeAs - -```go -func ShouldNotHaveSameTypeAs(actual interface{}, expected ...interface{}) string -``` -ShouldNotHaveSameTypeAs receives exactly two parameters and compares their -underlying types for inequality. - -#### func ShouldNotImplement - -```go -func ShouldNotImplement(actual interface{}, expectedList ...interface{}) string -``` -ShouldNotImplement receives exactly two parameters and ensures that the first -does NOT implement the interface type of the second. - -#### func ShouldNotPanic - -```go -func ShouldNotPanic(actual interface{}, expected ...interface{}) (message string) -``` -ShouldNotPanic receives a void, niladic function and expects to execute the -function without any panic. - -#### func ShouldNotPanicWith - -```go -func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message string) -``` -ShouldNotPanicWith receives a void, niladic function and expects to recover a -panic whose content differs from the second argument. - -#### func ShouldNotPointTo - -```go -func ShouldNotPointTo(actual interface{}, expected ...interface{}) string -``` -ShouldNotPointTo receives exactly two parameters and checks to see that they -point to different addresess. - -#### func ShouldNotResemble - -```go -func ShouldNotResemble(actual interface{}, expected ...interface{}) string -``` -ShouldNotResemble receives exactly two parameters and does an inverse deep equal -check (see reflect.DeepEqual) - -#### func ShouldNotStartWith - -```go -func ShouldNotStartWith(actual interface{}, expected ...interface{}) string -``` -ShouldNotStartWith receives exactly 2 string parameters and ensures that the -first does not start with the second. - -#### func ShouldPanic - -```go -func ShouldPanic(actual interface{}, expected ...interface{}) (message string) -``` -ShouldPanic receives a void, niladic function and expects to recover a panic. - -#### func ShouldPanicWith - -```go -func ShouldPanicWith(actual interface{}, expected ...interface{}) (message string) -``` -ShouldPanicWith receives a void, niladic function and expects to recover a panic -with the second argument as the content. - -#### func ShouldPointTo - -```go -func ShouldPointTo(actual interface{}, expected ...interface{}) string -``` -ShouldPointTo receives exactly two parameters and checks to see that they point -to the same address. - -#### func ShouldResemble - -```go -func ShouldResemble(actual interface{}, expected ...interface{}) string -``` -ShouldResemble receives exactly two parameters and does a deep equal check (see -reflect.DeepEqual) - -#### func ShouldStartWith - -```go -func ShouldStartWith(actual interface{}, expected ...interface{}) string -``` -ShouldStartWith receives exactly 2 string parameters and ensures that the first -starts with the second. - -#### func So - -```go -func So(actual interface{}, assert assertion, expected ...interface{}) (bool, string) -``` -So is a convenience function (as opposed to an inconvenience function?) for -running assertions on arbitrary arguments in any context, be it for testing or -even application logging. It allows you to perform assertion-like behavior (and -get nicely formatted messages detailing discrepancies) but without the program -blowing up or panicking. All that is required is to import this package and call -`So` with one of the assertions exported by this package as the second -parameter. The first return parameter is a boolean indicating if the assertion -was true. The second return parameter is the well-formatted message showing why -an assertion was incorrect, or blank if the assertion was correct. - -Example: - - if ok, message := So(x, ShouldBeGreaterThan, y); !ok { - log.Println(message) - } - -For an alternative implementation of So (that provides more flexible return -options) see the `So` function in the package at -github.com/smartystreets/assertions/assert. - -#### type Assertion - -```go -type Assertion struct { -} -``` - - -#### func New - -```go -func New(t testingT) *Assertion -``` -New swallows the *testing.T struct and prints failed assertions using t.Error. -Example: assertions.New(t).So(1, should.Equal, 1) - -#### func (*Assertion) Failed - -```go -func (this *Assertion) Failed() bool -``` -Failed reports whether any calls to So (on this Assertion instance) have failed. - -#### func (*Assertion) So - -```go -func (this *Assertion) So(actual interface{}, assert assertion, expected ...interface{}) bool -``` -So calls the standalone So function and additionally, calls t.Error in failure -scenarios. - -#### type FailureView - -```go -type FailureView struct { - Message string `json:"Message"` - Expected string `json:"Expected"` - Actual string `json:"Actual"` -} -``` - -This struct is also declared in -github.com/smartystreets/goconvey/convey/reporting. The json struct tags should -be equal in both declarations. - -#### type Serializer - -```go -type Serializer interface { - // contains filtered or unexported methods -} -``` +[![Build Status](https://travis-ci.org/smartystreets/assertions.svg?branch=master)](https://travis-ci.org/smartystreets/assertions) +[![Code Coverage](https://codecov.io/gh/smartystreets/assertions/branch/master/graph/badge.svg)](https://codecov.io/gh/smartystreets/assertions) +[![Go Report Card](https://goreportcard.com/badge/github.com/smartystreets/assertions)](https://goreportcard.com/report/github.com/smartystreets/assertions) +[![GoDoc](https://godoc.org/github.com/smartystreets/assertions?status.svg)](http://godoc.org/github.com/smartystreets/assertions) diff --git a/vendor/github.com/smartystreets/assertions/doc.go b/vendor/github.com/smartystreets/assertions/doc.go index ba30a9261a..e706db33fa 100644 --- a/vendor/github.com/smartystreets/assertions/doc.go +++ b/vendor/github.com/smartystreets/assertions/doc.go @@ -58,7 +58,7 @@ func (this *Assertion) Failed() bool { } // So calls the standalone So function and additionally, calls t.Error in failure scenarios. -func (this *Assertion) So(actual interface{}, assert assertion, expected ...interface{}) bool { +func (this *Assertion) So(actual interface{}, assert SoFunc, expected ...interface{}) bool { ok, result := So(actual, assert, expected...) if !ok { this.failed = true @@ -86,7 +86,7 @@ func (this *Assertion) So(actual interface{}, assert assertion, expected ...inte // // For an alternative implementation of So (that provides more flexible return options) // see the `So` function in the package at github.com/smartystreets/assertions/assert. -func So(actual interface{}, assert assertion, expected ...interface{}) (bool, string) { +func So(actual interface{}, assert SoFunc, expected ...interface{}) (bool, string) { if result := so(actual, assert, expected...); len(result) == 0 { return true, result } else { @@ -96,14 +96,14 @@ func So(actual interface{}, assert assertion, expected ...interface{}) (bool, st // so is like So, except that it only returns the string message, which is blank if the // assertion passed. Used to facilitate testing. -func so(actual interface{}, assert func(interface{}, ...interface{}) string, expected ...interface{}) string { +func so(actual interface{}, assert SoFunc, expected ...interface{}) string { return assert(actual, expected...) } -// assertion is an alias for a function with a signature that the So() +// SoFunc is an alias for a function with a signature that the So() // function can handle. Any future or custom assertions should conform to this -// method signature. The return value should be an empty string if the assertion +// method signature. The return value should be an empty string if the SoFunc // passes and a well-formed failure message if not. -type assertion func(actual interface{}, expected ...interface{}) string +type SoFunc func(actual interface{}, expected ...interface{}) string //////////////////////////////////////////////////////////////////////////// diff --git a/vendor/github.com/smartystreets/assertions/equality.go b/vendor/github.com/smartystreets/assertions/equality.go index 6c10d24d90..37a49f4e25 100644 --- a/vendor/github.com/smartystreets/assertions/equality.go +++ b/vendor/github.com/smartystreets/assertions/equality.go @@ -26,30 +26,31 @@ func ShouldEqual(actual interface{}, expected ...interface{}) string { func shouldEqual(actual, expected interface{}) (message string) { defer func() { if r := recover(); r != nil { - message = serializer.serialize(expected, actual, fmt.Sprintf(shouldHaveBeenEqual, expected, actual)) + message = serializer.serialize(expected, actual, composeEqualityMismatchMessage(expected, actual)) } }() - if specification := newEqualityMethodSpecification(expected, actual); specification.IsSatisfied() { - if specification.AreEqual() { - return success - } else { - message = fmt.Sprintf(shouldHaveBeenEqual, expected, actual) - return serializer.serialize(expected, actual, message) - } - } - if matchError := oglematchers.Equals(expected).Matches(actual); matchError != nil { - expectedSyntax := fmt.Sprintf("%v", expected) - actualSyntax := fmt.Sprintf("%v", actual) - if expectedSyntax == actualSyntax && reflect.TypeOf(expected) != reflect.TypeOf(actual) { - message = fmt.Sprintf(shouldHaveBeenEqualTypeMismatch, expected, expected, actual, actual) - } else { - message = fmt.Sprintf(shouldHaveBeenEqual, expected, actual) - } - return serializer.serialize(expected, actual, message) + if spec := newEqualityMethodSpecification(expected, actual); spec.IsSatisfied() && spec.AreEqual() { + return success + } else if matchError := oglematchers.Equals(expected).Matches(actual); matchError == nil { + return success } - return success + return serializer.serialize(expected, actual, composeEqualityMismatchMessage(expected, actual)) +} +func composeEqualityMismatchMessage(expected, actual interface{}) string { + var ( + renderedExpected = fmt.Sprintf("%v", expected) + renderedActual = fmt.Sprintf("%v", actual) + ) + + if renderedExpected != renderedActual { + return fmt.Sprintf(shouldHaveBeenEqual+composePrettyDiff(renderedExpected, renderedActual), expected, actual) + } else if reflect.TypeOf(expected) != reflect.TypeOf(actual) { + return fmt.Sprintf(shouldHaveBeenEqualTypeMismatch, expected, expected, actual, actual) + } else { + return fmt.Sprintf(shouldHaveBeenEqualNoResemblance, renderedExpected) + } } // ShouldNotEqual receives exactly two parameters and does an inequality check. @@ -169,7 +170,7 @@ func ShouldEqualJSON(actual interface{}, expected ...interface{}) string { return ShouldEqual(actualString, expectedString) } func remarshal(value string) (string, error) { - var structured map[string]interface{} + var structured interface{} err := json.Unmarshal([]byte(value), &structured) if err != nil { return "", err @@ -185,8 +186,10 @@ func ShouldResemble(actual interface{}, expected ...interface{}) string { } if matchError := oglematchers.DeepEquals(expected[0]).Matches(actual); matchError != nil { - return serializer.serializeDetailed(expected[0], actual, - fmt.Sprintf(shouldHaveResembled, render.Render(expected[0]), render.Render(actual))) + renderedExpected, renderedActual := render.Render(expected[0]), render.Render(actual) + message := fmt.Sprintf(shouldHaveResembled, renderedExpected, renderedActual) + + composePrettyDiff(renderedExpected, renderedActual) + return serializer.serializeDetailed(expected[0], actual, message) } return success diff --git a/vendor/github.com/smartystreets/assertions/equality_diff.go b/vendor/github.com/smartystreets/assertions/equality_diff.go new file mode 100644 index 0000000000..bd698ff62b --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/equality_diff.go @@ -0,0 +1,37 @@ +package assertions + +import ( + "fmt" + + "github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch" +) + +func composePrettyDiff(expected, actual string) string { + diff := diffmatchpatch.New() + diffs := diff.DiffMain(expected, actual, false) + if prettyDiffIsLikelyToBeHelpful(diffs) { + return fmt.Sprintf("\nDiff: '%s'", diff.DiffPrettyText(diffs)) + } + return "" +} + +// prettyDiffIsLikelyToBeHelpful returns true if the diff listing contains +// more 'equal' segments than 'deleted'/'inserted' segments. +func prettyDiffIsLikelyToBeHelpful(diffs []diffmatchpatch.Diff) bool { + equal, deleted, inserted := measureDiffTypeLengths(diffs) + return equal > deleted && equal > inserted +} + +func measureDiffTypeLengths(diffs []diffmatchpatch.Diff) (equal, deleted, inserted int) { + for _, segment := range diffs { + switch segment.Type { + case diffmatchpatch.DiffEqual: + equal += len(segment.Text) + case diffmatchpatch.DiffDelete: + deleted += len(segment.Text) + case diffmatchpatch.DiffInsert: + inserted += len(segment.Text) + } + } + return equal, deleted, inserted +} diff --git a/vendor/github.com/smartystreets/assertions/filter.go b/vendor/github.com/smartystreets/assertions/filter.go index 7c46ab8e35..cbf7566725 100644 --- a/vendor/github.com/smartystreets/assertions/filter.go +++ b/vendor/github.com/smartystreets/assertions/filter.go @@ -17,7 +17,7 @@ func need(needed int, expected []interface{}) string { } func atLeast(minimum int, expected []interface{}) string { - if len(expected) < 1 { + if len(expected) < minimum { return needNonEmptyCollection } return success diff --git a/vendor/github.com/smartystreets/assertions/internal/go-diff/AUTHORS b/vendor/github.com/smartystreets/assertions/internal/go-diff/AUTHORS new file mode 100644 index 0000000000..2d7bb2bf57 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/go-diff/AUTHORS @@ -0,0 +1,25 @@ +# This is the official list of go-diff authors for copyright purposes. +# This file is distinct from the CONTRIBUTORS files. +# See the latter for an explanation. + +# Names should be added to this file as +# Name or Organization +# The email address is not required for organizations. + +# Please keep the list sorted. + +Danny Yoo +James Kolb +Jonathan Amsterdam +Markus Zimmermann +Matt Kovars +Örjan Persson +Osman Masood +Robert Carlsen +Rory Flynn +Sergi Mansilla +Shatrugna Sadhu +Shawn Smith +Stas Maksimov +Tor Arvid Lund +Zac Bergquist diff --git a/vendor/github.com/smartystreets/assertions/internal/go-diff/CONTRIBUTORS b/vendor/github.com/smartystreets/assertions/internal/go-diff/CONTRIBUTORS new file mode 100644 index 0000000000..369e3d5519 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/go-diff/CONTRIBUTORS @@ -0,0 +1,32 @@ +# This is the official list of people who can contribute +# (and typically have contributed) code to the go-diff +# repository. +# +# The AUTHORS file lists the copyright holders; this file +# lists people. For example, ACME Inc. employees would be listed here +# but not in AUTHORS, because ACME Inc. would hold the copyright. +# +# When adding J Random Contributor's name to this file, +# either J's name or J's organization's name should be +# added to the AUTHORS file. +# +# Names should be added to this file like so: +# Name +# +# Please keep the list sorted. + +Danny Yoo +James Kolb +Jonathan Amsterdam +Markus Zimmermann +Matt Kovars +Örjan Persson +Osman Masood +Robert Carlsen +Rory Flynn +Sergi Mansilla +Shatrugna Sadhu +Shawn Smith +Stas Maksimov +Tor Arvid Lund +Zac Bergquist diff --git a/vendor/github.com/smartystreets/assertions/internal/go-diff/LICENSE b/vendor/github.com/smartystreets/assertions/internal/go-diff/LICENSE new file mode 100644 index 0000000000..937942c2b2 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/go-diff/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2012-2016 The go-diff Authors. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + diff --git a/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/diff.go b/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/diff.go new file mode 100644 index 0000000000..cb25b43757 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/diff.go @@ -0,0 +1,1345 @@ +// Copyright (c) 2012-2016 The go-diff authors. All rights reserved. +// https://github.com/sergi/go-diff +// See the included LICENSE file for license details. +// +// go-diff is a Go implementation of Google's Diff, Match, and Patch library +// Original library is Copyright (c) 2006 Google Inc. +// http://code.google.com/p/google-diff-match-patch/ + +package diffmatchpatch + +import ( + "bytes" + "errors" + "fmt" + "html" + "math" + "net/url" + "regexp" + "strconv" + "strings" + "time" + "unicode/utf8" +) + +// Operation defines the operation of a diff item. +type Operation int8 + +//go:generate stringer -type=Operation -trimprefix=Diff + +const ( + // DiffDelete item represents a delete diff. + DiffDelete Operation = -1 + // DiffInsert item represents an insert diff. + DiffInsert Operation = 1 + // DiffEqual item represents an equal diff. + DiffEqual Operation = 0 +) + +// Diff represents one diff operation +type Diff struct { + Type Operation + Text string +} + +// splice removes amount elements from slice at index index, replacing them with elements. +func splice(slice []Diff, index int, amount int, elements ...Diff) []Diff { + if len(elements) == amount { + // Easy case: overwrite the relevant items. + copy(slice[index:], elements) + return slice + } + if len(elements) < amount { + // Fewer new items than old. + // Copy in the new items. + copy(slice[index:], elements) + // Shift the remaining items left. + copy(slice[index+len(elements):], slice[index+amount:]) + // Calculate the new end of the slice. + end := len(slice) - amount + len(elements) + // Zero stranded elements at end so that they can be garbage collected. + tail := slice[end:] + for i := range tail { + tail[i] = Diff{} + } + return slice[:end] + } + // More new items than old. + // Make room in slice for new elements. + // There's probably an even more efficient way to do this, + // but this is simple and clear. + need := len(slice) - amount + len(elements) + for len(slice) < need { + slice = append(slice, Diff{}) + } + // Shift slice elements right to make room for new elements. + copy(slice[index+len(elements):], slice[index+amount:]) + // Copy in new elements. + copy(slice[index:], elements) + return slice +} + +// DiffMain finds the differences between two texts. +// If an invalid UTF-8 sequence is encountered, it will be replaced by the Unicode replacement character. +func (dmp *DiffMatchPatch) DiffMain(text1, text2 string, checklines bool) []Diff { + return dmp.DiffMainRunes([]rune(text1), []rune(text2), checklines) +} + +// DiffMainRunes finds the differences between two rune sequences. +// If an invalid UTF-8 sequence is encountered, it will be replaced by the Unicode replacement character. +func (dmp *DiffMatchPatch) DiffMainRunes(text1, text2 []rune, checklines bool) []Diff { + var deadline time.Time + if dmp.DiffTimeout > 0 { + deadline = time.Now().Add(dmp.DiffTimeout) + } + return dmp.diffMainRunes(text1, text2, checklines, deadline) +} + +func (dmp *DiffMatchPatch) diffMainRunes(text1, text2 []rune, checklines bool, deadline time.Time) []Diff { + if runesEqual(text1, text2) { + var diffs []Diff + if len(text1) > 0 { + diffs = append(diffs, Diff{DiffEqual, string(text1)}) + } + return diffs + } + // Trim off common prefix (speedup). + commonlength := commonPrefixLength(text1, text2) + commonprefix := text1[:commonlength] + text1 = text1[commonlength:] + text2 = text2[commonlength:] + + // Trim off common suffix (speedup). + commonlength = commonSuffixLength(text1, text2) + commonsuffix := text1[len(text1)-commonlength:] + text1 = text1[:len(text1)-commonlength] + text2 = text2[:len(text2)-commonlength] + + // Compute the diff on the middle block. + diffs := dmp.diffCompute(text1, text2, checklines, deadline) + + // Restore the prefix and suffix. + if len(commonprefix) != 0 { + diffs = append([]Diff{Diff{DiffEqual, string(commonprefix)}}, diffs...) + } + if len(commonsuffix) != 0 { + diffs = append(diffs, Diff{DiffEqual, string(commonsuffix)}) + } + + return dmp.DiffCleanupMerge(diffs) +} + +// diffCompute finds the differences between two rune slices. Assumes that the texts do not have any common prefix or suffix. +func (dmp *DiffMatchPatch) diffCompute(text1, text2 []rune, checklines bool, deadline time.Time) []Diff { + diffs := []Diff{} + if len(text1) == 0 { + // Just add some text (speedup). + return append(diffs, Diff{DiffInsert, string(text2)}) + } else if len(text2) == 0 { + // Just delete some text (speedup). + return append(diffs, Diff{DiffDelete, string(text1)}) + } + + var longtext, shorttext []rune + if len(text1) > len(text2) { + longtext = text1 + shorttext = text2 + } else { + longtext = text2 + shorttext = text1 + } + + if i := runesIndex(longtext, shorttext); i != -1 { + op := DiffInsert + // Swap insertions for deletions if diff is reversed. + if len(text1) > len(text2) { + op = DiffDelete + } + // Shorter text is inside the longer text (speedup). + return []Diff{ + Diff{op, string(longtext[:i])}, + Diff{DiffEqual, string(shorttext)}, + Diff{op, string(longtext[i+len(shorttext):])}, + } + } else if len(shorttext) == 1 { + // Single character string. + // After the previous speedup, the character can't be an equality. + return []Diff{ + Diff{DiffDelete, string(text1)}, + Diff{DiffInsert, string(text2)}, + } + // Check to see if the problem can be split in two. + } else if hm := dmp.diffHalfMatch(text1, text2); hm != nil { + // A half-match was found, sort out the return data. + text1A := hm[0] + text1B := hm[1] + text2A := hm[2] + text2B := hm[3] + midCommon := hm[4] + // Send both pairs off for separate processing. + diffsA := dmp.diffMainRunes(text1A, text2A, checklines, deadline) + diffsB := dmp.diffMainRunes(text1B, text2B, checklines, deadline) + // Merge the results. + diffs := diffsA + diffs = append(diffs, Diff{DiffEqual, string(midCommon)}) + diffs = append(diffs, diffsB...) + return diffs + } else if checklines && len(text1) > 100 && len(text2) > 100 { + return dmp.diffLineMode(text1, text2, deadline) + } + return dmp.diffBisect(text1, text2, deadline) +} + +// diffLineMode does a quick line-level diff on both []runes, then rediff the parts for greater accuracy. This speedup can produce non-minimal diffs. +func (dmp *DiffMatchPatch) diffLineMode(text1, text2 []rune, deadline time.Time) []Diff { + // Scan the text on a line-by-line basis first. + text1, text2, linearray := dmp.diffLinesToRunes(text1, text2) + + diffs := dmp.diffMainRunes(text1, text2, false, deadline) + + // Convert the diff back to original text. + diffs = dmp.DiffCharsToLines(diffs, linearray) + // Eliminate freak matches (e.g. blank lines) + diffs = dmp.DiffCleanupSemantic(diffs) + + // Rediff any replacement blocks, this time character-by-character. + // Add a dummy entry at the end. + diffs = append(diffs, Diff{DiffEqual, ""}) + + pointer := 0 + countDelete := 0 + countInsert := 0 + + // NOTE: Rune slices are slower than using strings in this case. + textDelete := "" + textInsert := "" + + for pointer < len(diffs) { + switch diffs[pointer].Type { + case DiffInsert: + countInsert++ + textInsert += diffs[pointer].Text + case DiffDelete: + countDelete++ + textDelete += diffs[pointer].Text + case DiffEqual: + // Upon reaching an equality, check for prior redundancies. + if countDelete >= 1 && countInsert >= 1 { + // Delete the offending records and add the merged ones. + diffs = splice(diffs, pointer-countDelete-countInsert, + countDelete+countInsert) + + pointer = pointer - countDelete - countInsert + a := dmp.diffMainRunes([]rune(textDelete), []rune(textInsert), false, deadline) + for j := len(a) - 1; j >= 0; j-- { + diffs = splice(diffs, pointer, 0, a[j]) + } + pointer = pointer + len(a) + } + + countInsert = 0 + countDelete = 0 + textDelete = "" + textInsert = "" + } + pointer++ + } + + return diffs[:len(diffs)-1] // Remove the dummy entry at the end. +} + +// DiffBisect finds the 'middle snake' of a diff, split the problem in two and return the recursively constructed diff. +// If an invalid UTF-8 sequence is encountered, it will be replaced by the Unicode replacement character. +// See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations. +func (dmp *DiffMatchPatch) DiffBisect(text1, text2 string, deadline time.Time) []Diff { + // Unused in this code, but retained for interface compatibility. + return dmp.diffBisect([]rune(text1), []rune(text2), deadline) +} + +// diffBisect finds the 'middle snake' of a diff, splits the problem in two and returns the recursively constructed diff. +// See Myers's 1986 paper: An O(ND) Difference Algorithm and Its Variations. +func (dmp *DiffMatchPatch) diffBisect(runes1, runes2 []rune, deadline time.Time) []Diff { + // Cache the text lengths to prevent multiple calls. + runes1Len, runes2Len := len(runes1), len(runes2) + + maxD := (runes1Len + runes2Len + 1) / 2 + vOffset := maxD + vLength := 2 * maxD + + v1 := make([]int, vLength) + v2 := make([]int, vLength) + for i := range v1 { + v1[i] = -1 + v2[i] = -1 + } + v1[vOffset+1] = 0 + v2[vOffset+1] = 0 + + delta := runes1Len - runes2Len + // If the total number of characters is odd, then the front path will collide with the reverse path. + front := (delta%2 != 0) + // Offsets for start and end of k loop. Prevents mapping of space beyond the grid. + k1start := 0 + k1end := 0 + k2start := 0 + k2end := 0 + for d := 0; d < maxD; d++ { + // Bail out if deadline is reached. + if !deadline.IsZero() && d%16 == 0 && time.Now().After(deadline) { + break + } + + // Walk the front path one step. + for k1 := -d + k1start; k1 <= d-k1end; k1 += 2 { + k1Offset := vOffset + k1 + var x1 int + + if k1 == -d || (k1 != d && v1[k1Offset-1] < v1[k1Offset+1]) { + x1 = v1[k1Offset+1] + } else { + x1 = v1[k1Offset-1] + 1 + } + + y1 := x1 - k1 + for x1 < runes1Len && y1 < runes2Len { + if runes1[x1] != runes2[y1] { + break + } + x1++ + y1++ + } + v1[k1Offset] = x1 + if x1 > runes1Len { + // Ran off the right of the graph. + k1end += 2 + } else if y1 > runes2Len { + // Ran off the bottom of the graph. + k1start += 2 + } else if front { + k2Offset := vOffset + delta - k1 + if k2Offset >= 0 && k2Offset < vLength && v2[k2Offset] != -1 { + // Mirror x2 onto top-left coordinate system. + x2 := runes1Len - v2[k2Offset] + if x1 >= x2 { + // Overlap detected. + return dmp.diffBisectSplit(runes1, runes2, x1, y1, deadline) + } + } + } + } + // Walk the reverse path one step. + for k2 := -d + k2start; k2 <= d-k2end; k2 += 2 { + k2Offset := vOffset + k2 + var x2 int + if k2 == -d || (k2 != d && v2[k2Offset-1] < v2[k2Offset+1]) { + x2 = v2[k2Offset+1] + } else { + x2 = v2[k2Offset-1] + 1 + } + var y2 = x2 - k2 + for x2 < runes1Len && y2 < runes2Len { + if runes1[runes1Len-x2-1] != runes2[runes2Len-y2-1] { + break + } + x2++ + y2++ + } + v2[k2Offset] = x2 + if x2 > runes1Len { + // Ran off the left of the graph. + k2end += 2 + } else if y2 > runes2Len { + // Ran off the top of the graph. + k2start += 2 + } else if !front { + k1Offset := vOffset + delta - k2 + if k1Offset >= 0 && k1Offset < vLength && v1[k1Offset] != -1 { + x1 := v1[k1Offset] + y1 := vOffset + x1 - k1Offset + // Mirror x2 onto top-left coordinate system. + x2 = runes1Len - x2 + if x1 >= x2 { + // Overlap detected. + return dmp.diffBisectSplit(runes1, runes2, x1, y1, deadline) + } + } + } + } + } + // Diff took too long and hit the deadline or number of diffs equals number of characters, no commonality at all. + return []Diff{ + Diff{DiffDelete, string(runes1)}, + Diff{DiffInsert, string(runes2)}, + } +} + +func (dmp *DiffMatchPatch) diffBisectSplit(runes1, runes2 []rune, x, y int, + deadline time.Time) []Diff { + runes1a := runes1[:x] + runes2a := runes2[:y] + runes1b := runes1[x:] + runes2b := runes2[y:] + + // Compute both diffs serially. + diffs := dmp.diffMainRunes(runes1a, runes2a, false, deadline) + diffsb := dmp.diffMainRunes(runes1b, runes2b, false, deadline) + + return append(diffs, diffsb...) +} + +// DiffLinesToChars splits two texts into a list of strings, and educes the texts to a string of hashes where each Unicode character represents one line. +// It's slightly faster to call DiffLinesToRunes first, followed by DiffMainRunes. +func (dmp *DiffMatchPatch) DiffLinesToChars(text1, text2 string) (string, string, []string) { + chars1, chars2, lineArray := dmp.DiffLinesToRunes(text1, text2) + return string(chars1), string(chars2), lineArray +} + +// DiffLinesToRunes splits two texts into a list of runes. Each rune represents one line. +func (dmp *DiffMatchPatch) DiffLinesToRunes(text1, text2 string) ([]rune, []rune, []string) { + // '\x00' is a valid character, but various debuggers don't like it. So we'll insert a junk entry to avoid generating a null character. + lineArray := []string{""} // e.g. lineArray[4] == 'Hello\n' + lineHash := map[string]int{} // e.g. lineHash['Hello\n'] == 4 + + chars1 := dmp.diffLinesToRunesMunge(text1, &lineArray, lineHash) + chars2 := dmp.diffLinesToRunesMunge(text2, &lineArray, lineHash) + + return chars1, chars2, lineArray +} + +func (dmp *DiffMatchPatch) diffLinesToRunes(text1, text2 []rune) ([]rune, []rune, []string) { + return dmp.DiffLinesToRunes(string(text1), string(text2)) +} + +// diffLinesToRunesMunge splits a text into an array of strings, and reduces the texts to a []rune where each Unicode character represents one line. +// We use strings instead of []runes as input mainly because you can't use []rune as a map key. +func (dmp *DiffMatchPatch) diffLinesToRunesMunge(text string, lineArray *[]string, lineHash map[string]int) []rune { + // Walk the text, pulling out a substring for each line. text.split('\n') would would temporarily double our memory footprint. Modifying text would create many large strings to garbage collect. + lineStart := 0 + lineEnd := -1 + runes := []rune{} + + for lineEnd < len(text)-1 { + lineEnd = indexOf(text, "\n", lineStart) + + if lineEnd == -1 { + lineEnd = len(text) - 1 + } + + line := text[lineStart : lineEnd+1] + lineStart = lineEnd + 1 + lineValue, ok := lineHash[line] + + if ok { + runes = append(runes, rune(lineValue)) + } else { + *lineArray = append(*lineArray, line) + lineHash[line] = len(*lineArray) - 1 + runes = append(runes, rune(len(*lineArray)-1)) + } + } + + return runes +} + +// DiffCharsToLines rehydrates the text in a diff from a string of line hashes to real lines of text. +func (dmp *DiffMatchPatch) DiffCharsToLines(diffs []Diff, lineArray []string) []Diff { + hydrated := make([]Diff, 0, len(diffs)) + for _, aDiff := range diffs { + chars := aDiff.Text + text := make([]string, len(chars)) + + for i, r := range chars { + text[i] = lineArray[r] + } + + aDiff.Text = strings.Join(text, "") + hydrated = append(hydrated, aDiff) + } + return hydrated +} + +// DiffCommonPrefix determines the common prefix length of two strings. +func (dmp *DiffMatchPatch) DiffCommonPrefix(text1, text2 string) int { + // Unused in this code, but retained for interface compatibility. + return commonPrefixLength([]rune(text1), []rune(text2)) +} + +// DiffCommonSuffix determines the common suffix length of two strings. +func (dmp *DiffMatchPatch) DiffCommonSuffix(text1, text2 string) int { + // Unused in this code, but retained for interface compatibility. + return commonSuffixLength([]rune(text1), []rune(text2)) +} + +// commonPrefixLength returns the length of the common prefix of two rune slices. +func commonPrefixLength(text1, text2 []rune) int { + // Linear search. See comment in commonSuffixLength. + n := 0 + for ; n < len(text1) && n < len(text2); n++ { + if text1[n] != text2[n] { + return n + } + } + return n +} + +// commonSuffixLength returns the length of the common suffix of two rune slices. +func commonSuffixLength(text1, text2 []rune) int { + // Use linear search rather than the binary search discussed at https://neil.fraser.name/news/2007/10/09/. + // See discussion at https://github.com/sergi/go-diff/issues/54. + i1 := len(text1) + i2 := len(text2) + for n := 0; ; n++ { + i1-- + i2-- + if i1 < 0 || i2 < 0 || text1[i1] != text2[i2] { + return n + } + } +} + +// DiffCommonOverlap determines if the suffix of one string is the prefix of another. +func (dmp *DiffMatchPatch) DiffCommonOverlap(text1 string, text2 string) int { + // Cache the text lengths to prevent multiple calls. + text1Length := len(text1) + text2Length := len(text2) + // Eliminate the null case. + if text1Length == 0 || text2Length == 0 { + return 0 + } + // Truncate the longer string. + if text1Length > text2Length { + text1 = text1[text1Length-text2Length:] + } else if text1Length < text2Length { + text2 = text2[0:text1Length] + } + textLength := int(math.Min(float64(text1Length), float64(text2Length))) + // Quick check for the worst case. + if text1 == text2 { + return textLength + } + + // Start by looking for a single character match and increase length until no match is found. Performance analysis: http://neil.fraser.name/news/2010/11/04/ + best := 0 + length := 1 + for { + pattern := text1[textLength-length:] + found := strings.Index(text2, pattern) + if found == -1 { + break + } + length += found + if found == 0 || text1[textLength-length:] == text2[0:length] { + best = length + length++ + } + } + + return best +} + +// DiffHalfMatch checks whether the two texts share a substring which is at least half the length of the longer text. This speedup can produce non-minimal diffs. +func (dmp *DiffMatchPatch) DiffHalfMatch(text1, text2 string) []string { + // Unused in this code, but retained for interface compatibility. + runeSlices := dmp.diffHalfMatch([]rune(text1), []rune(text2)) + if runeSlices == nil { + return nil + } + + result := make([]string, len(runeSlices)) + for i, r := range runeSlices { + result[i] = string(r) + } + return result +} + +func (dmp *DiffMatchPatch) diffHalfMatch(text1, text2 []rune) [][]rune { + if dmp.DiffTimeout <= 0 { + // Don't risk returning a non-optimal diff if we have unlimited time. + return nil + } + + var longtext, shorttext []rune + if len(text1) > len(text2) { + longtext = text1 + shorttext = text2 + } else { + longtext = text2 + shorttext = text1 + } + + if len(longtext) < 4 || len(shorttext)*2 < len(longtext) { + return nil // Pointless. + } + + // First check if the second quarter is the seed for a half-match. + hm1 := dmp.diffHalfMatchI(longtext, shorttext, int(float64(len(longtext)+3)/4)) + + // Check again based on the third quarter. + hm2 := dmp.diffHalfMatchI(longtext, shorttext, int(float64(len(longtext)+1)/2)) + + hm := [][]rune{} + if hm1 == nil && hm2 == nil { + return nil + } else if hm2 == nil { + hm = hm1 + } else if hm1 == nil { + hm = hm2 + } else { + // Both matched. Select the longest. + if len(hm1[4]) > len(hm2[4]) { + hm = hm1 + } else { + hm = hm2 + } + } + + // A half-match was found, sort out the return data. + if len(text1) > len(text2) { + return hm + } + + return [][]rune{hm[2], hm[3], hm[0], hm[1], hm[4]} +} + +// diffHalfMatchI checks if a substring of shorttext exist within longtext such that the substring is at least half the length of longtext? +// Returns a slice containing the prefix of longtext, the suffix of longtext, the prefix of shorttext, the suffix of shorttext and the common middle, or null if there was no match. +func (dmp *DiffMatchPatch) diffHalfMatchI(l, s []rune, i int) [][]rune { + var bestCommonA []rune + var bestCommonB []rune + var bestCommonLen int + var bestLongtextA []rune + var bestLongtextB []rune + var bestShorttextA []rune + var bestShorttextB []rune + + // Start with a 1/4 length substring at position i as a seed. + seed := l[i : i+len(l)/4] + + for j := runesIndexOf(s, seed, 0); j != -1; j = runesIndexOf(s, seed, j+1) { + prefixLength := commonPrefixLength(l[i:], s[j:]) + suffixLength := commonSuffixLength(l[:i], s[:j]) + + if bestCommonLen < suffixLength+prefixLength { + bestCommonA = s[j-suffixLength : j] + bestCommonB = s[j : j+prefixLength] + bestCommonLen = len(bestCommonA) + len(bestCommonB) + bestLongtextA = l[:i-suffixLength] + bestLongtextB = l[i+prefixLength:] + bestShorttextA = s[:j-suffixLength] + bestShorttextB = s[j+prefixLength:] + } + } + + if bestCommonLen*2 < len(l) { + return nil + } + + return [][]rune{ + bestLongtextA, + bestLongtextB, + bestShorttextA, + bestShorttextB, + append(bestCommonA, bestCommonB...), + } +} + +// DiffCleanupSemantic reduces the number of edits by eliminating semantically trivial equalities. +func (dmp *DiffMatchPatch) DiffCleanupSemantic(diffs []Diff) []Diff { + changes := false + // Stack of indices where equalities are found. + equalities := make([]int, 0, len(diffs)) + + var lastequality string + // Always equal to diffs[equalities[equalitiesLength - 1]][1] + var pointer int // Index of current position. + // Number of characters that changed prior to the equality. + var lengthInsertions1, lengthDeletions1 int + // Number of characters that changed after the equality. + var lengthInsertions2, lengthDeletions2 int + + for pointer < len(diffs) { + if diffs[pointer].Type == DiffEqual { + // Equality found. + equalities = append(equalities, pointer) + lengthInsertions1 = lengthInsertions2 + lengthDeletions1 = lengthDeletions2 + lengthInsertions2 = 0 + lengthDeletions2 = 0 + lastequality = diffs[pointer].Text + } else { + // An insertion or deletion. + + if diffs[pointer].Type == DiffInsert { + lengthInsertions2 += len(diffs[pointer].Text) + } else { + lengthDeletions2 += len(diffs[pointer].Text) + } + // Eliminate an equality that is smaller or equal to the edits on both sides of it. + difference1 := int(math.Max(float64(lengthInsertions1), float64(lengthDeletions1))) + difference2 := int(math.Max(float64(lengthInsertions2), float64(lengthDeletions2))) + if len(lastequality) > 0 && + (len(lastequality) <= difference1) && + (len(lastequality) <= difference2) { + // Duplicate record. + insPoint := equalities[len(equalities)-1] + diffs = splice(diffs, insPoint, 0, Diff{DiffDelete, lastequality}) + + // Change second copy to insert. + diffs[insPoint+1].Type = DiffInsert + // Throw away the equality we just deleted. + equalities = equalities[:len(equalities)-1] + + if len(equalities) > 0 { + equalities = equalities[:len(equalities)-1] + } + pointer = -1 + if len(equalities) > 0 { + pointer = equalities[len(equalities)-1] + } + + lengthInsertions1 = 0 // Reset the counters. + lengthDeletions1 = 0 + lengthInsertions2 = 0 + lengthDeletions2 = 0 + lastequality = "" + changes = true + } + } + pointer++ + } + + // Normalize the diff. + if changes { + diffs = dmp.DiffCleanupMerge(diffs) + } + diffs = dmp.DiffCleanupSemanticLossless(diffs) + // Find any overlaps between deletions and insertions. + // e.g: abcxxxxxxdef + // -> abcxxxdef + // e.g: xxxabcdefxxx + // -> defxxxabc + // Only extract an overlap if it is as big as the edit ahead or behind it. + pointer = 1 + for pointer < len(diffs) { + if diffs[pointer-1].Type == DiffDelete && + diffs[pointer].Type == DiffInsert { + deletion := diffs[pointer-1].Text + insertion := diffs[pointer].Text + overlapLength1 := dmp.DiffCommonOverlap(deletion, insertion) + overlapLength2 := dmp.DiffCommonOverlap(insertion, deletion) + if overlapLength1 >= overlapLength2 { + if float64(overlapLength1) >= float64(len(deletion))/2 || + float64(overlapLength1) >= float64(len(insertion))/2 { + + // Overlap found. Insert an equality and trim the surrounding edits. + diffs = splice(diffs, pointer, 0, Diff{DiffEqual, insertion[:overlapLength1]}) + diffs[pointer-1].Text = + deletion[0 : len(deletion)-overlapLength1] + diffs[pointer+1].Text = insertion[overlapLength1:] + pointer++ + } + } else { + if float64(overlapLength2) >= float64(len(deletion))/2 || + float64(overlapLength2) >= float64(len(insertion))/2 { + // Reverse overlap found. Insert an equality and swap and trim the surrounding edits. + overlap := Diff{DiffEqual, deletion[:overlapLength2]} + diffs = splice(diffs, pointer, 0, overlap) + diffs[pointer-1].Type = DiffInsert + diffs[pointer-1].Text = insertion[0 : len(insertion)-overlapLength2] + diffs[pointer+1].Type = DiffDelete + diffs[pointer+1].Text = deletion[overlapLength2:] + pointer++ + } + } + pointer++ + } + pointer++ + } + + return diffs +} + +// Define some regex patterns for matching boundaries. +var ( + nonAlphaNumericRegex = regexp.MustCompile(`[^a-zA-Z0-9]`) + whitespaceRegex = regexp.MustCompile(`\s`) + linebreakRegex = regexp.MustCompile(`[\r\n]`) + blanklineEndRegex = regexp.MustCompile(`\n\r?\n$`) + blanklineStartRegex = regexp.MustCompile(`^\r?\n\r?\n`) +) + +// diffCleanupSemanticScore computes a score representing whether the internal boundary falls on logical boundaries. +// Scores range from 6 (best) to 0 (worst). Closure, but does not reference any external variables. +func diffCleanupSemanticScore(one, two string) int { + if len(one) == 0 || len(two) == 0 { + // Edges are the best. + return 6 + } + + // Each port of this function behaves slightly differently due to subtle differences in each language's definition of things like 'whitespace'. Since this function's purpose is largely cosmetic, the choice has been made to use each language's native features rather than force total conformity. + rune1, _ := utf8.DecodeLastRuneInString(one) + rune2, _ := utf8.DecodeRuneInString(two) + char1 := string(rune1) + char2 := string(rune2) + + nonAlphaNumeric1 := nonAlphaNumericRegex.MatchString(char1) + nonAlphaNumeric2 := nonAlphaNumericRegex.MatchString(char2) + whitespace1 := nonAlphaNumeric1 && whitespaceRegex.MatchString(char1) + whitespace2 := nonAlphaNumeric2 && whitespaceRegex.MatchString(char2) + lineBreak1 := whitespace1 && linebreakRegex.MatchString(char1) + lineBreak2 := whitespace2 && linebreakRegex.MatchString(char2) + blankLine1 := lineBreak1 && blanklineEndRegex.MatchString(one) + blankLine2 := lineBreak2 && blanklineEndRegex.MatchString(two) + + if blankLine1 || blankLine2 { + // Five points for blank lines. + return 5 + } else if lineBreak1 || lineBreak2 { + // Four points for line breaks. + return 4 + } else if nonAlphaNumeric1 && !whitespace1 && whitespace2 { + // Three points for end of sentences. + return 3 + } else if whitespace1 || whitespace2 { + // Two points for whitespace. + return 2 + } else if nonAlphaNumeric1 || nonAlphaNumeric2 { + // One point for non-alphanumeric. + return 1 + } + return 0 +} + +// DiffCleanupSemanticLossless looks for single edits surrounded on both sides by equalities which can be shifted sideways to align the edit to a word boundary. +// E.g: The cat came. -> The cat came. +func (dmp *DiffMatchPatch) DiffCleanupSemanticLossless(diffs []Diff) []Diff { + pointer := 1 + + // Intentionally ignore the first and last element (don't need checking). + for pointer < len(diffs)-1 { + if diffs[pointer-1].Type == DiffEqual && + diffs[pointer+1].Type == DiffEqual { + + // This is a single edit surrounded by equalities. + equality1 := diffs[pointer-1].Text + edit := diffs[pointer].Text + equality2 := diffs[pointer+1].Text + + // First, shift the edit as far left as possible. + commonOffset := dmp.DiffCommonSuffix(equality1, edit) + if commonOffset > 0 { + commonString := edit[len(edit)-commonOffset:] + equality1 = equality1[0 : len(equality1)-commonOffset] + edit = commonString + edit[:len(edit)-commonOffset] + equality2 = commonString + equality2 + } + + // Second, step character by character right, looking for the best fit. + bestEquality1 := equality1 + bestEdit := edit + bestEquality2 := equality2 + bestScore := diffCleanupSemanticScore(equality1, edit) + + diffCleanupSemanticScore(edit, equality2) + + for len(edit) != 0 && len(equality2) != 0 { + _, sz := utf8.DecodeRuneInString(edit) + if len(equality2) < sz || edit[:sz] != equality2[:sz] { + break + } + equality1 += edit[:sz] + edit = edit[sz:] + equality2[:sz] + equality2 = equality2[sz:] + score := diffCleanupSemanticScore(equality1, edit) + + diffCleanupSemanticScore(edit, equality2) + // The >= encourages trailing rather than leading whitespace on edits. + if score >= bestScore { + bestScore = score + bestEquality1 = equality1 + bestEdit = edit + bestEquality2 = equality2 + } + } + + if diffs[pointer-1].Text != bestEquality1 { + // We have an improvement, save it back to the diff. + if len(bestEquality1) != 0 { + diffs[pointer-1].Text = bestEquality1 + } else { + diffs = splice(diffs, pointer-1, 1) + pointer-- + } + + diffs[pointer].Text = bestEdit + if len(bestEquality2) != 0 { + diffs[pointer+1].Text = bestEquality2 + } else { + diffs = append(diffs[:pointer+1], diffs[pointer+2:]...) + pointer-- + } + } + } + pointer++ + } + + return diffs +} + +// DiffCleanupEfficiency reduces the number of edits by eliminating operationally trivial equalities. +func (dmp *DiffMatchPatch) DiffCleanupEfficiency(diffs []Diff) []Diff { + changes := false + // Stack of indices where equalities are found. + type equality struct { + data int + next *equality + } + var equalities *equality + // Always equal to equalities[equalitiesLength-1][1] + lastequality := "" + pointer := 0 // Index of current position. + // Is there an insertion operation before the last equality. + preIns := false + // Is there a deletion operation before the last equality. + preDel := false + // Is there an insertion operation after the last equality. + postIns := false + // Is there a deletion operation after the last equality. + postDel := false + for pointer < len(diffs) { + if diffs[pointer].Type == DiffEqual { // Equality found. + if len(diffs[pointer].Text) < dmp.DiffEditCost && + (postIns || postDel) { + // Candidate found. + equalities = &equality{ + data: pointer, + next: equalities, + } + preIns = postIns + preDel = postDel + lastequality = diffs[pointer].Text + } else { + // Not a candidate, and can never become one. + equalities = nil + lastequality = "" + } + postIns = false + postDel = false + } else { // An insertion or deletion. + if diffs[pointer].Type == DiffDelete { + postDel = true + } else { + postIns = true + } + + // Five types to be split: + // ABXYCD + // AXCD + // ABXC + // AXCD + // ABXC + var sumPres int + if preIns { + sumPres++ + } + if preDel { + sumPres++ + } + if postIns { + sumPres++ + } + if postDel { + sumPres++ + } + if len(lastequality) > 0 && + ((preIns && preDel && postIns && postDel) || + ((len(lastequality) < dmp.DiffEditCost/2) && sumPres == 3)) { + + insPoint := equalities.data + + // Duplicate record. + diffs = splice(diffs, insPoint, 0, Diff{DiffDelete, lastequality}) + + // Change second copy to insert. + diffs[insPoint+1].Type = DiffInsert + // Throw away the equality we just deleted. + equalities = equalities.next + lastequality = "" + + if preIns && preDel { + // No changes made which could affect previous entry, keep going. + postIns = true + postDel = true + equalities = nil + } else { + if equalities != nil { + equalities = equalities.next + } + if equalities != nil { + pointer = equalities.data + } else { + pointer = -1 + } + postIns = false + postDel = false + } + changes = true + } + } + pointer++ + } + + if changes { + diffs = dmp.DiffCleanupMerge(diffs) + } + + return diffs +} + +// DiffCleanupMerge reorders and merges like edit sections. Merge equalities. +// Any edit section can move as long as it doesn't cross an equality. +func (dmp *DiffMatchPatch) DiffCleanupMerge(diffs []Diff) []Diff { + // Add a dummy entry at the end. + diffs = append(diffs, Diff{DiffEqual, ""}) + pointer := 0 + countDelete := 0 + countInsert := 0 + commonlength := 0 + textDelete := []rune(nil) + textInsert := []rune(nil) + + for pointer < len(diffs) { + switch diffs[pointer].Type { + case DiffInsert: + countInsert++ + textInsert = append(textInsert, []rune(diffs[pointer].Text)...) + pointer++ + break + case DiffDelete: + countDelete++ + textDelete = append(textDelete, []rune(diffs[pointer].Text)...) + pointer++ + break + case DiffEqual: + // Upon reaching an equality, check for prior redundancies. + if countDelete+countInsert > 1 { + if countDelete != 0 && countInsert != 0 { + // Factor out any common prefixies. + commonlength = commonPrefixLength(textInsert, textDelete) + if commonlength != 0 { + x := pointer - countDelete - countInsert + if x > 0 && diffs[x-1].Type == DiffEqual { + diffs[x-1].Text += string(textInsert[:commonlength]) + } else { + diffs = append([]Diff{Diff{DiffEqual, string(textInsert[:commonlength])}}, diffs...) + pointer++ + } + textInsert = textInsert[commonlength:] + textDelete = textDelete[commonlength:] + } + // Factor out any common suffixies. + commonlength = commonSuffixLength(textInsert, textDelete) + if commonlength != 0 { + insertIndex := len(textInsert) - commonlength + deleteIndex := len(textDelete) - commonlength + diffs[pointer].Text = string(textInsert[insertIndex:]) + diffs[pointer].Text + textInsert = textInsert[:insertIndex] + textDelete = textDelete[:deleteIndex] + } + } + // Delete the offending records and add the merged ones. + if countDelete == 0 { + diffs = splice(diffs, pointer-countInsert, + countDelete+countInsert, + Diff{DiffInsert, string(textInsert)}) + } else if countInsert == 0 { + diffs = splice(diffs, pointer-countDelete, + countDelete+countInsert, + Diff{DiffDelete, string(textDelete)}) + } else { + diffs = splice(diffs, pointer-countDelete-countInsert, + countDelete+countInsert, + Diff{DiffDelete, string(textDelete)}, + Diff{DiffInsert, string(textInsert)}) + } + + pointer = pointer - countDelete - countInsert + 1 + if countDelete != 0 { + pointer++ + } + if countInsert != 0 { + pointer++ + } + } else if pointer != 0 && diffs[pointer-1].Type == DiffEqual { + // Merge this equality with the previous one. + diffs[pointer-1].Text += diffs[pointer].Text + diffs = append(diffs[:pointer], diffs[pointer+1:]...) + } else { + pointer++ + } + countInsert = 0 + countDelete = 0 + textDelete = nil + textInsert = nil + break + } + } + + if len(diffs[len(diffs)-1].Text) == 0 { + diffs = diffs[0 : len(diffs)-1] // Remove the dummy entry at the end. + } + + // Second pass: look for single edits surrounded on both sides by equalities which can be shifted sideways to eliminate an equality. E.g: ABAC -> ABAC + changes := false + pointer = 1 + // Intentionally ignore the first and last element (don't need checking). + for pointer < (len(diffs) - 1) { + if diffs[pointer-1].Type == DiffEqual && + diffs[pointer+1].Type == DiffEqual { + // This is a single edit surrounded by equalities. + if strings.HasSuffix(diffs[pointer].Text, diffs[pointer-1].Text) { + // Shift the edit over the previous equality. + diffs[pointer].Text = diffs[pointer-1].Text + + diffs[pointer].Text[:len(diffs[pointer].Text)-len(diffs[pointer-1].Text)] + diffs[pointer+1].Text = diffs[pointer-1].Text + diffs[pointer+1].Text + diffs = splice(diffs, pointer-1, 1) + changes = true + } else if strings.HasPrefix(diffs[pointer].Text, diffs[pointer+1].Text) { + // Shift the edit over the next equality. + diffs[pointer-1].Text += diffs[pointer+1].Text + diffs[pointer].Text = + diffs[pointer].Text[len(diffs[pointer+1].Text):] + diffs[pointer+1].Text + diffs = splice(diffs, pointer+1, 1) + changes = true + } + } + pointer++ + } + + // If shifts were made, the diff needs reordering and another shift sweep. + if changes { + diffs = dmp.DiffCleanupMerge(diffs) + } + + return diffs +} + +// DiffXIndex returns the equivalent location in s2. +func (dmp *DiffMatchPatch) DiffXIndex(diffs []Diff, loc int) int { + chars1 := 0 + chars2 := 0 + lastChars1 := 0 + lastChars2 := 0 + lastDiff := Diff{} + for i := 0; i < len(diffs); i++ { + aDiff := diffs[i] + if aDiff.Type != DiffInsert { + // Equality or deletion. + chars1 += len(aDiff.Text) + } + if aDiff.Type != DiffDelete { + // Equality or insertion. + chars2 += len(aDiff.Text) + } + if chars1 > loc { + // Overshot the location. + lastDiff = aDiff + break + } + lastChars1 = chars1 + lastChars2 = chars2 + } + if lastDiff.Type == DiffDelete { + // The location was deleted. + return lastChars2 + } + // Add the remaining character length. + return lastChars2 + (loc - lastChars1) +} + +// DiffPrettyHtml converts a []Diff into a pretty HTML report. +// It is intended as an example from which to write one's own display functions. +func (dmp *DiffMatchPatch) DiffPrettyHtml(diffs []Diff) string { + var buff bytes.Buffer + for _, diff := range diffs { + text := strings.Replace(html.EscapeString(diff.Text), "\n", "¶
", -1) + switch diff.Type { + case DiffInsert: + _, _ = buff.WriteString("") + _, _ = buff.WriteString(text) + _, _ = buff.WriteString("") + case DiffDelete: + _, _ = buff.WriteString("") + _, _ = buff.WriteString(text) + _, _ = buff.WriteString("") + case DiffEqual: + _, _ = buff.WriteString("") + _, _ = buff.WriteString(text) + _, _ = buff.WriteString("") + } + } + return buff.String() +} + +// DiffPrettyText converts a []Diff into a colored text report. +func (dmp *DiffMatchPatch) DiffPrettyText(diffs []Diff) string { + var buff bytes.Buffer + for _, diff := range diffs { + text := diff.Text + + switch diff.Type { + case DiffInsert: + _, _ = buff.WriteString("\x1b[32m") + _, _ = buff.WriteString(text) + _, _ = buff.WriteString("\x1b[0m") + case DiffDelete: + _, _ = buff.WriteString("\x1b[31m") + _, _ = buff.WriteString(text) + _, _ = buff.WriteString("\x1b[0m") + case DiffEqual: + _, _ = buff.WriteString(text) + } + } + + return buff.String() +} + +// DiffText1 computes and returns the source text (all equalities and deletions). +func (dmp *DiffMatchPatch) DiffText1(diffs []Diff) string { + //StringBuilder text = new StringBuilder() + var text bytes.Buffer + + for _, aDiff := range diffs { + if aDiff.Type != DiffInsert { + _, _ = text.WriteString(aDiff.Text) + } + } + return text.String() +} + +// DiffText2 computes and returns the destination text (all equalities and insertions). +func (dmp *DiffMatchPatch) DiffText2(diffs []Diff) string { + var text bytes.Buffer + + for _, aDiff := range diffs { + if aDiff.Type != DiffDelete { + _, _ = text.WriteString(aDiff.Text) + } + } + return text.String() +} + +// DiffLevenshtein computes the Levenshtein distance that is the number of inserted, deleted or substituted characters. +func (dmp *DiffMatchPatch) DiffLevenshtein(diffs []Diff) int { + levenshtein := 0 + insertions := 0 + deletions := 0 + + for _, aDiff := range diffs { + switch aDiff.Type { + case DiffInsert: + insertions += utf8.RuneCountInString(aDiff.Text) + case DiffDelete: + deletions += utf8.RuneCountInString(aDiff.Text) + case DiffEqual: + // A deletion and an insertion is one substitution. + levenshtein += max(insertions, deletions) + insertions = 0 + deletions = 0 + } + } + + levenshtein += max(insertions, deletions) + return levenshtein +} + +// DiffToDelta crushes the diff into an encoded string which describes the operations required to transform text1 into text2. +// E.g. =3\t-2\t+ing -> Keep 3 chars, delete 2 chars, insert 'ing'. Operations are tab-separated. Inserted text is escaped using %xx notation. +func (dmp *DiffMatchPatch) DiffToDelta(diffs []Diff) string { + var text bytes.Buffer + for _, aDiff := range diffs { + switch aDiff.Type { + case DiffInsert: + _, _ = text.WriteString("+") + _, _ = text.WriteString(strings.Replace(url.QueryEscape(aDiff.Text), "+", " ", -1)) + _, _ = text.WriteString("\t") + break + case DiffDelete: + _, _ = text.WriteString("-") + _, _ = text.WriteString(strconv.Itoa(utf8.RuneCountInString(aDiff.Text))) + _, _ = text.WriteString("\t") + break + case DiffEqual: + _, _ = text.WriteString("=") + _, _ = text.WriteString(strconv.Itoa(utf8.RuneCountInString(aDiff.Text))) + _, _ = text.WriteString("\t") + break + } + } + delta := text.String() + if len(delta) != 0 { + // Strip off trailing tab character. + delta = delta[0 : utf8.RuneCountInString(delta)-1] + delta = unescaper.Replace(delta) + } + return delta +} + +// DiffFromDelta given the original text1, and an encoded string which describes the operations required to transform text1 into text2, comAdde the full diff. +func (dmp *DiffMatchPatch) DiffFromDelta(text1 string, delta string) (diffs []Diff, err error) { + i := 0 + runes := []rune(text1) + + for _, token := range strings.Split(delta, "\t") { + if len(token) == 0 { + // Blank tokens are ok (from a trailing \t). + continue + } + + // Each token begins with a one character parameter which specifies the operation of this token (delete, insert, equality). + param := token[1:] + + switch op := token[0]; op { + case '+': + // Decode would Diff all "+" to " " + param = strings.Replace(param, "+", "%2b", -1) + param, err = url.QueryUnescape(param) + if err != nil { + return nil, err + } + if !utf8.ValidString(param) { + return nil, fmt.Errorf("invalid UTF-8 token: %q", param) + } + + diffs = append(diffs, Diff{DiffInsert, param}) + case '=', '-': + n, err := strconv.ParseInt(param, 10, 0) + if err != nil { + return nil, err + } else if n < 0 { + return nil, errors.New("Negative number in DiffFromDelta: " + param) + } + + i += int(n) + // Break out if we are out of bounds, go1.6 can't handle this very well + if i > len(runes) { + break + } + // Remember that string slicing is by byte - we want by rune here. + text := string(runes[i-int(n) : i]) + + if op == '=' { + diffs = append(diffs, Diff{DiffEqual, text}) + } else { + diffs = append(diffs, Diff{DiffDelete, text}) + } + default: + // Anything else is an error. + return nil, errors.New("Invalid diff operation in DiffFromDelta: " + string(token[0])) + } + } + + if i != len(runes) { + return nil, fmt.Errorf("Delta length (%v) is different from source text length (%v)", i, len(text1)) + } + + return diffs, nil +} diff --git a/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/diffmatchpatch.go b/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/diffmatchpatch.go new file mode 100644 index 0000000000..d3acc32ce1 --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/diffmatchpatch.go @@ -0,0 +1,46 @@ +// Copyright (c) 2012-2016 The go-diff authors. All rights reserved. +// https://github.com/sergi/go-diff +// See the included LICENSE file for license details. +// +// go-diff is a Go implementation of Google's Diff, Match, and Patch library +// Original library is Copyright (c) 2006 Google Inc. +// http://code.google.com/p/google-diff-match-patch/ + +// Package diffmatchpatch offers robust algorithms to perform the operations required for synchronizing plain text. +package diffmatchpatch + +import ( + "time" +) + +// DiffMatchPatch holds the configuration for diff-match-patch operations. +type DiffMatchPatch struct { + // Number of seconds to map a diff before giving up (0 for infinity). + DiffTimeout time.Duration + // Cost of an empty edit operation in terms of edit characters. + DiffEditCost int + // How far to search for a match (0 = exact location, 1000+ = broad match). A match this many characters away from the expected location will add 1.0 to the score (0.0 is a perfect match). + MatchDistance int + // When deleting a large block of text (over ~64 characters), how close do the contents have to be to match the expected contents. (0.0 = perfection, 1.0 = very loose). Note that MatchThreshold controls how closely the end points of a delete need to match. + PatchDeleteThreshold float64 + // Chunk size for context length. + PatchMargin int + // The number of bits in an int. + MatchMaxBits int + // At what point is no match declared (0.0 = perfection, 1.0 = very loose). + MatchThreshold float64 +} + +// New creates a new DiffMatchPatch object with default parameters. +func New() *DiffMatchPatch { + // Defaults. + return &DiffMatchPatch{ + DiffTimeout: time.Second, + DiffEditCost: 4, + MatchThreshold: 0.5, + MatchDistance: 1000, + PatchDeleteThreshold: 0.5, + PatchMargin: 4, + MatchMaxBits: 32, + } +} diff --git a/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/match.go b/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/match.go new file mode 100644 index 0000000000..17374e109f --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/match.go @@ -0,0 +1,160 @@ +// Copyright (c) 2012-2016 The go-diff authors. All rights reserved. +// https://github.com/sergi/go-diff +// See the included LICENSE file for license details. +// +// go-diff is a Go implementation of Google's Diff, Match, and Patch library +// Original library is Copyright (c) 2006 Google Inc. +// http://code.google.com/p/google-diff-match-patch/ + +package diffmatchpatch + +import ( + "math" +) + +// MatchMain locates the best instance of 'pattern' in 'text' near 'loc'. +// Returns -1 if no match found. +func (dmp *DiffMatchPatch) MatchMain(text, pattern string, loc int) int { + // Check for null inputs not needed since null can't be passed in C#. + + loc = int(math.Max(0, math.Min(float64(loc), float64(len(text))))) + if text == pattern { + // Shortcut (potentially not guaranteed by the algorithm) + return 0 + } else if len(text) == 0 { + // Nothing to match. + return -1 + } else if loc+len(pattern) <= len(text) && text[loc:loc+len(pattern)] == pattern { + // Perfect match at the perfect spot! (Includes case of null pattern) + return loc + } + // Do a fuzzy compare. + return dmp.MatchBitap(text, pattern, loc) +} + +// MatchBitap locates the best instance of 'pattern' in 'text' near 'loc' using the Bitap algorithm. +// Returns -1 if no match was found. +func (dmp *DiffMatchPatch) MatchBitap(text, pattern string, loc int) int { + // Initialise the alphabet. + s := dmp.MatchAlphabet(pattern) + + // Highest score beyond which we give up. + scoreThreshold := dmp.MatchThreshold + // Is there a nearby exact match? (speedup) + bestLoc := indexOf(text, pattern, loc) + if bestLoc != -1 { + scoreThreshold = math.Min(dmp.matchBitapScore(0, bestLoc, loc, + pattern), scoreThreshold) + // What about in the other direction? (speedup) + bestLoc = lastIndexOf(text, pattern, loc+len(pattern)) + if bestLoc != -1 { + scoreThreshold = math.Min(dmp.matchBitapScore(0, bestLoc, loc, + pattern), scoreThreshold) + } + } + + // Initialise the bit arrays. + matchmask := 1 << uint((len(pattern) - 1)) + bestLoc = -1 + + var binMin, binMid int + binMax := len(pattern) + len(text) + lastRd := []int{} + for d := 0; d < len(pattern); d++ { + // Scan for the best match; each iteration allows for one more error. Run a binary search to determine how far from 'loc' we can stray at this error level. + binMin = 0 + binMid = binMax + for binMin < binMid { + if dmp.matchBitapScore(d, loc+binMid, loc, pattern) <= scoreThreshold { + binMin = binMid + } else { + binMax = binMid + } + binMid = (binMax-binMin)/2 + binMin + } + // Use the result from this iteration as the maximum for the next. + binMax = binMid + start := int(math.Max(1, float64(loc-binMid+1))) + finish := int(math.Min(float64(loc+binMid), float64(len(text))) + float64(len(pattern))) + + rd := make([]int, finish+2) + rd[finish+1] = (1 << uint(d)) - 1 + + for j := finish; j >= start; j-- { + var charMatch int + if len(text) <= j-1 { + // Out of range. + charMatch = 0 + } else if _, ok := s[text[j-1]]; !ok { + charMatch = 0 + } else { + charMatch = s[text[j-1]] + } + + if d == 0 { + // First pass: exact match. + rd[j] = ((rd[j+1] << 1) | 1) & charMatch + } else { + // Subsequent passes: fuzzy match. + rd[j] = ((rd[j+1]<<1)|1)&charMatch | (((lastRd[j+1] | lastRd[j]) << 1) | 1) | lastRd[j+1] + } + if (rd[j] & matchmask) != 0 { + score := dmp.matchBitapScore(d, j-1, loc, pattern) + // This match will almost certainly be better than any existing match. But check anyway. + if score <= scoreThreshold { + // Told you so. + scoreThreshold = score + bestLoc = j - 1 + if bestLoc > loc { + // When passing loc, don't exceed our current distance from loc. + start = int(math.Max(1, float64(2*loc-bestLoc))) + } else { + // Already passed loc, downhill from here on in. + break + } + } + } + } + if dmp.matchBitapScore(d+1, loc, loc, pattern) > scoreThreshold { + // No hope for a (better) match at greater error levels. + break + } + lastRd = rd + } + return bestLoc +} + +// matchBitapScore computes and returns the score for a match with e errors and x location. +func (dmp *DiffMatchPatch) matchBitapScore(e, x, loc int, pattern string) float64 { + accuracy := float64(e) / float64(len(pattern)) + proximity := math.Abs(float64(loc - x)) + if dmp.MatchDistance == 0 { + // Dodge divide by zero error. + if proximity == 0 { + return accuracy + } + + return 1.0 + } + return accuracy + (proximity / float64(dmp.MatchDistance)) +} + +// MatchAlphabet initialises the alphabet for the Bitap algorithm. +func (dmp *DiffMatchPatch) MatchAlphabet(pattern string) map[byte]int { + s := map[byte]int{} + charPattern := []byte(pattern) + for _, c := range charPattern { + _, ok := s[c] + if !ok { + s[c] = 0 + } + } + i := 0 + + for _, c := range charPattern { + value := s[c] | int(uint(1)< y { + return x + } + return y +} diff --git a/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/operation_string.go b/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/operation_string.go new file mode 100644 index 0000000000..533ec0da7b --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/operation_string.go @@ -0,0 +1,17 @@ +// Code generated by "stringer -type=Operation -trimprefix=Diff"; DO NOT EDIT. + +package diffmatchpatch + +import "fmt" + +const _Operation_name = "DeleteEqualInsert" + +var _Operation_index = [...]uint8{0, 6, 11, 17} + +func (i Operation) String() string { + i -= -1 + if i < 0 || i >= Operation(len(_Operation_index)-1) { + return fmt.Sprintf("Operation(%d)", i+-1) + } + return _Operation_name[_Operation_index[i]:_Operation_index[i+1]] +} diff --git a/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/patch.go b/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/patch.go new file mode 100644 index 0000000000..0dbe3bdd7d --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/patch.go @@ -0,0 +1,556 @@ +// Copyright (c) 2012-2016 The go-diff authors. All rights reserved. +// https://github.com/sergi/go-diff +// See the included LICENSE file for license details. +// +// go-diff is a Go implementation of Google's Diff, Match, and Patch library +// Original library is Copyright (c) 2006 Google Inc. +// http://code.google.com/p/google-diff-match-patch/ + +package diffmatchpatch + +import ( + "bytes" + "errors" + "math" + "net/url" + "regexp" + "strconv" + "strings" +) + +// Patch represents one patch operation. +type Patch struct { + diffs []Diff + Start1 int + Start2 int + Length1 int + Length2 int +} + +// String emulates GNU diff's format. +// Header: @@ -382,8 +481,9 @@ +// Indices are printed as 1-based, not 0-based. +func (p *Patch) String() string { + var coords1, coords2 string + + if p.Length1 == 0 { + coords1 = strconv.Itoa(p.Start1) + ",0" + } else if p.Length1 == 1 { + coords1 = strconv.Itoa(p.Start1 + 1) + } else { + coords1 = strconv.Itoa(p.Start1+1) + "," + strconv.Itoa(p.Length1) + } + + if p.Length2 == 0 { + coords2 = strconv.Itoa(p.Start2) + ",0" + } else if p.Length2 == 1 { + coords2 = strconv.Itoa(p.Start2 + 1) + } else { + coords2 = strconv.Itoa(p.Start2+1) + "," + strconv.Itoa(p.Length2) + } + + var text bytes.Buffer + _, _ = text.WriteString("@@ -" + coords1 + " +" + coords2 + " @@\n") + + // Escape the body of the patch with %xx notation. + for _, aDiff := range p.diffs { + switch aDiff.Type { + case DiffInsert: + _, _ = text.WriteString("+") + case DiffDelete: + _, _ = text.WriteString("-") + case DiffEqual: + _, _ = text.WriteString(" ") + } + + _, _ = text.WriteString(strings.Replace(url.QueryEscape(aDiff.Text), "+", " ", -1)) + _, _ = text.WriteString("\n") + } + + return unescaper.Replace(text.String()) +} + +// PatchAddContext increases the context until it is unique, but doesn't let the pattern expand beyond MatchMaxBits. +func (dmp *DiffMatchPatch) PatchAddContext(patch Patch, text string) Patch { + if len(text) == 0 { + return patch + } + + pattern := text[patch.Start2 : patch.Start2+patch.Length1] + padding := 0 + + // Look for the first and last matches of pattern in text. If two different matches are found, increase the pattern length. + for strings.Index(text, pattern) != strings.LastIndex(text, pattern) && + len(pattern) < dmp.MatchMaxBits-2*dmp.PatchMargin { + padding += dmp.PatchMargin + maxStart := max(0, patch.Start2-padding) + minEnd := min(len(text), patch.Start2+patch.Length1+padding) + pattern = text[maxStart:minEnd] + } + // Add one chunk for good luck. + padding += dmp.PatchMargin + + // Add the prefix. + prefix := text[max(0, patch.Start2-padding):patch.Start2] + if len(prefix) != 0 { + patch.diffs = append([]Diff{Diff{DiffEqual, prefix}}, patch.diffs...) + } + // Add the suffix. + suffix := text[patch.Start2+patch.Length1 : min(len(text), patch.Start2+patch.Length1+padding)] + if len(suffix) != 0 { + patch.diffs = append(patch.diffs, Diff{DiffEqual, suffix}) + } + + // Roll back the start points. + patch.Start1 -= len(prefix) + patch.Start2 -= len(prefix) + // Extend the lengths. + patch.Length1 += len(prefix) + len(suffix) + patch.Length2 += len(prefix) + len(suffix) + + return patch +} + +// PatchMake computes a list of patches. +func (dmp *DiffMatchPatch) PatchMake(opt ...interface{}) []Patch { + if len(opt) == 1 { + diffs, _ := opt[0].([]Diff) + text1 := dmp.DiffText1(diffs) + return dmp.PatchMake(text1, diffs) + } else if len(opt) == 2 { + text1 := opt[0].(string) + switch t := opt[1].(type) { + case string: + diffs := dmp.DiffMain(text1, t, true) + if len(diffs) > 2 { + diffs = dmp.DiffCleanupSemantic(diffs) + diffs = dmp.DiffCleanupEfficiency(diffs) + } + return dmp.PatchMake(text1, diffs) + case []Diff: + return dmp.patchMake2(text1, t) + } + } else if len(opt) == 3 { + return dmp.PatchMake(opt[0], opt[2]) + } + return []Patch{} +} + +// patchMake2 computes a list of patches to turn text1 into text2. +// text2 is not provided, diffs are the delta between text1 and text2. +func (dmp *DiffMatchPatch) patchMake2(text1 string, diffs []Diff) []Patch { + // Check for null inputs not needed since null can't be passed in C#. + patches := []Patch{} + if len(diffs) == 0 { + return patches // Get rid of the null case. + } + + patch := Patch{} + charCount1 := 0 // Number of characters into the text1 string. + charCount2 := 0 // Number of characters into the text2 string. + // Start with text1 (prepatchText) and apply the diffs until we arrive at text2 (postpatchText). We recreate the patches one by one to determine context info. + prepatchText := text1 + postpatchText := text1 + + for i, aDiff := range diffs { + if len(patch.diffs) == 0 && aDiff.Type != DiffEqual { + // A new patch starts here. + patch.Start1 = charCount1 + patch.Start2 = charCount2 + } + + switch aDiff.Type { + case DiffInsert: + patch.diffs = append(patch.diffs, aDiff) + patch.Length2 += len(aDiff.Text) + postpatchText = postpatchText[:charCount2] + + aDiff.Text + postpatchText[charCount2:] + case DiffDelete: + patch.Length1 += len(aDiff.Text) + patch.diffs = append(patch.diffs, aDiff) + postpatchText = postpatchText[:charCount2] + postpatchText[charCount2+len(aDiff.Text):] + case DiffEqual: + if len(aDiff.Text) <= 2*dmp.PatchMargin && + len(patch.diffs) != 0 && i != len(diffs)-1 { + // Small equality inside a patch. + patch.diffs = append(patch.diffs, aDiff) + patch.Length1 += len(aDiff.Text) + patch.Length2 += len(aDiff.Text) + } + if len(aDiff.Text) >= 2*dmp.PatchMargin { + // Time for a new patch. + if len(patch.diffs) != 0 { + patch = dmp.PatchAddContext(patch, prepatchText) + patches = append(patches, patch) + patch = Patch{} + // Unlike Unidiff, our patch lists have a rolling context. http://code.google.com/p/google-diff-match-patch/wiki/Unidiff Update prepatch text & pos to reflect the application of the just completed patch. + prepatchText = postpatchText + charCount1 = charCount2 + } + } + } + + // Update the current character count. + if aDiff.Type != DiffInsert { + charCount1 += len(aDiff.Text) + } + if aDiff.Type != DiffDelete { + charCount2 += len(aDiff.Text) + } + } + + // Pick up the leftover patch if not empty. + if len(patch.diffs) != 0 { + patch = dmp.PatchAddContext(patch, prepatchText) + patches = append(patches, patch) + } + + return patches +} + +// PatchDeepCopy returns an array that is identical to a given an array of patches. +func (dmp *DiffMatchPatch) PatchDeepCopy(patches []Patch) []Patch { + patchesCopy := []Patch{} + for _, aPatch := range patches { + patchCopy := Patch{} + for _, aDiff := range aPatch.diffs { + patchCopy.diffs = append(patchCopy.diffs, Diff{ + aDiff.Type, + aDiff.Text, + }) + } + patchCopy.Start1 = aPatch.Start1 + patchCopy.Start2 = aPatch.Start2 + patchCopy.Length1 = aPatch.Length1 + patchCopy.Length2 = aPatch.Length2 + patchesCopy = append(patchesCopy, patchCopy) + } + return patchesCopy +} + +// PatchApply merges a set of patches onto the text. Returns a patched text, as well as an array of true/false values indicating which patches were applied. +func (dmp *DiffMatchPatch) PatchApply(patches []Patch, text string) (string, []bool) { + if len(patches) == 0 { + return text, []bool{} + } + + // Deep copy the patches so that no changes are made to originals. + patches = dmp.PatchDeepCopy(patches) + + nullPadding := dmp.PatchAddPadding(patches) + text = nullPadding + text + nullPadding + patches = dmp.PatchSplitMax(patches) + + x := 0 + // delta keeps track of the offset between the expected and actual location of the previous patch. If there are patches expected at positions 10 and 20, but the first patch was found at 12, delta is 2 and the second patch has an effective expected position of 22. + delta := 0 + results := make([]bool, len(patches)) + for _, aPatch := range patches { + expectedLoc := aPatch.Start2 + delta + text1 := dmp.DiffText1(aPatch.diffs) + var startLoc int + endLoc := -1 + if len(text1) > dmp.MatchMaxBits { + // PatchSplitMax will only provide an oversized pattern in the case of a monster delete. + startLoc = dmp.MatchMain(text, text1[:dmp.MatchMaxBits], expectedLoc) + if startLoc != -1 { + endLoc = dmp.MatchMain(text, + text1[len(text1)-dmp.MatchMaxBits:], expectedLoc+len(text1)-dmp.MatchMaxBits) + if endLoc == -1 || startLoc >= endLoc { + // Can't find valid trailing context. Drop this patch. + startLoc = -1 + } + } + } else { + startLoc = dmp.MatchMain(text, text1, expectedLoc) + } + if startLoc == -1 { + // No match found. :( + results[x] = false + // Subtract the delta for this failed patch from subsequent patches. + delta -= aPatch.Length2 - aPatch.Length1 + } else { + // Found a match. :) + results[x] = true + delta = startLoc - expectedLoc + var text2 string + if endLoc == -1 { + text2 = text[startLoc:int(math.Min(float64(startLoc+len(text1)), float64(len(text))))] + } else { + text2 = text[startLoc:int(math.Min(float64(endLoc+dmp.MatchMaxBits), float64(len(text))))] + } + if text1 == text2 { + // Perfect match, just shove the Replacement text in. + text = text[:startLoc] + dmp.DiffText2(aPatch.diffs) + text[startLoc+len(text1):] + } else { + // Imperfect match. Run a diff to get a framework of equivalent indices. + diffs := dmp.DiffMain(text1, text2, false) + if len(text1) > dmp.MatchMaxBits && float64(dmp.DiffLevenshtein(diffs))/float64(len(text1)) > dmp.PatchDeleteThreshold { + // The end points match, but the content is unacceptably bad. + results[x] = false + } else { + diffs = dmp.DiffCleanupSemanticLossless(diffs) + index1 := 0 + for _, aDiff := range aPatch.diffs { + if aDiff.Type != DiffEqual { + index2 := dmp.DiffXIndex(diffs, index1) + if aDiff.Type == DiffInsert { + // Insertion + text = text[:startLoc+index2] + aDiff.Text + text[startLoc+index2:] + } else if aDiff.Type == DiffDelete { + // Deletion + startIndex := startLoc + index2 + text = text[:startIndex] + + text[startIndex+dmp.DiffXIndex(diffs, index1+len(aDiff.Text))-index2:] + } + } + if aDiff.Type != DiffDelete { + index1 += len(aDiff.Text) + } + } + } + } + } + x++ + } + // Strip the padding off. + text = text[len(nullPadding) : len(nullPadding)+(len(text)-2*len(nullPadding))] + return text, results +} + +// PatchAddPadding adds some padding on text start and end so that edges can match something. +// Intended to be called only from within patchApply. +func (dmp *DiffMatchPatch) PatchAddPadding(patches []Patch) string { + paddingLength := dmp.PatchMargin + nullPadding := "" + for x := 1; x <= paddingLength; x++ { + nullPadding += string(rune(x)) + } + + // Bump all the patches forward. + for i := range patches { + patches[i].Start1 += paddingLength + patches[i].Start2 += paddingLength + } + + // Add some padding on start of first diff. + if len(patches[0].diffs) == 0 || patches[0].diffs[0].Type != DiffEqual { + // Add nullPadding equality. + patches[0].diffs = append([]Diff{Diff{DiffEqual, nullPadding}}, patches[0].diffs...) + patches[0].Start1 -= paddingLength // Should be 0. + patches[0].Start2 -= paddingLength // Should be 0. + patches[0].Length1 += paddingLength + patches[0].Length2 += paddingLength + } else if paddingLength > len(patches[0].diffs[0].Text) { + // Grow first equality. + extraLength := paddingLength - len(patches[0].diffs[0].Text) + patches[0].diffs[0].Text = nullPadding[len(patches[0].diffs[0].Text):] + patches[0].diffs[0].Text + patches[0].Start1 -= extraLength + patches[0].Start2 -= extraLength + patches[0].Length1 += extraLength + patches[0].Length2 += extraLength + } + + // Add some padding on end of last diff. + last := len(patches) - 1 + if len(patches[last].diffs) == 0 || patches[last].diffs[len(patches[last].diffs)-1].Type != DiffEqual { + // Add nullPadding equality. + patches[last].diffs = append(patches[last].diffs, Diff{DiffEqual, nullPadding}) + patches[last].Length1 += paddingLength + patches[last].Length2 += paddingLength + } else if paddingLength > len(patches[last].diffs[len(patches[last].diffs)-1].Text) { + // Grow last equality. + lastDiff := patches[last].diffs[len(patches[last].diffs)-1] + extraLength := paddingLength - len(lastDiff.Text) + patches[last].diffs[len(patches[last].diffs)-1].Text += nullPadding[:extraLength] + patches[last].Length1 += extraLength + patches[last].Length2 += extraLength + } + + return nullPadding +} + +// PatchSplitMax looks through the patches and breaks up any which are longer than the maximum limit of the match algorithm. +// Intended to be called only from within patchApply. +func (dmp *DiffMatchPatch) PatchSplitMax(patches []Patch) []Patch { + patchSize := dmp.MatchMaxBits + for x := 0; x < len(patches); x++ { + if patches[x].Length1 <= patchSize { + continue + } + bigpatch := patches[x] + // Remove the big old patch. + patches = append(patches[:x], patches[x+1:]...) + x-- + + Start1 := bigpatch.Start1 + Start2 := bigpatch.Start2 + precontext := "" + for len(bigpatch.diffs) != 0 { + // Create one of several smaller patches. + patch := Patch{} + empty := true + patch.Start1 = Start1 - len(precontext) + patch.Start2 = Start2 - len(precontext) + if len(precontext) != 0 { + patch.Length1 = len(precontext) + patch.Length2 = len(precontext) + patch.diffs = append(patch.diffs, Diff{DiffEqual, precontext}) + } + for len(bigpatch.diffs) != 0 && patch.Length1 < patchSize-dmp.PatchMargin { + diffType := bigpatch.diffs[0].Type + diffText := bigpatch.diffs[0].Text + if diffType == DiffInsert { + // Insertions are harmless. + patch.Length2 += len(diffText) + Start2 += len(diffText) + patch.diffs = append(patch.diffs, bigpatch.diffs[0]) + bigpatch.diffs = bigpatch.diffs[1:] + empty = false + } else if diffType == DiffDelete && len(patch.diffs) == 1 && patch.diffs[0].Type == DiffEqual && len(diffText) > 2*patchSize { + // This is a large deletion. Let it pass in one chunk. + patch.Length1 += len(diffText) + Start1 += len(diffText) + empty = false + patch.diffs = append(patch.diffs, Diff{diffType, diffText}) + bigpatch.diffs = bigpatch.diffs[1:] + } else { + // Deletion or equality. Only take as much as we can stomach. + diffText = diffText[:min(len(diffText), patchSize-patch.Length1-dmp.PatchMargin)] + + patch.Length1 += len(diffText) + Start1 += len(diffText) + if diffType == DiffEqual { + patch.Length2 += len(diffText) + Start2 += len(diffText) + } else { + empty = false + } + patch.diffs = append(patch.diffs, Diff{diffType, diffText}) + if diffText == bigpatch.diffs[0].Text { + bigpatch.diffs = bigpatch.diffs[1:] + } else { + bigpatch.diffs[0].Text = + bigpatch.diffs[0].Text[len(diffText):] + } + } + } + // Compute the head context for the next patch. + precontext = dmp.DiffText2(patch.diffs) + precontext = precontext[max(0, len(precontext)-dmp.PatchMargin):] + + postcontext := "" + // Append the end context for this patch. + if len(dmp.DiffText1(bigpatch.diffs)) > dmp.PatchMargin { + postcontext = dmp.DiffText1(bigpatch.diffs)[:dmp.PatchMargin] + } else { + postcontext = dmp.DiffText1(bigpatch.diffs) + } + + if len(postcontext) != 0 { + patch.Length1 += len(postcontext) + patch.Length2 += len(postcontext) + if len(patch.diffs) != 0 && patch.diffs[len(patch.diffs)-1].Type == DiffEqual { + patch.diffs[len(patch.diffs)-1].Text += postcontext + } else { + patch.diffs = append(patch.diffs, Diff{DiffEqual, postcontext}) + } + } + if !empty { + x++ + patches = append(patches[:x], append([]Patch{patch}, patches[x:]...)...) + } + } + } + return patches +} + +// PatchToText takes a list of patches and returns a textual representation. +func (dmp *DiffMatchPatch) PatchToText(patches []Patch) string { + var text bytes.Buffer + for _, aPatch := range patches { + _, _ = text.WriteString(aPatch.String()) + } + return text.String() +} + +// PatchFromText parses a textual representation of patches and returns a List of Patch objects. +func (dmp *DiffMatchPatch) PatchFromText(textline string) ([]Patch, error) { + patches := []Patch{} + if len(textline) == 0 { + return patches, nil + } + text := strings.Split(textline, "\n") + textPointer := 0 + patchHeader := regexp.MustCompile("^@@ -(\\d+),?(\\d*) \\+(\\d+),?(\\d*) @@$") + + var patch Patch + var sign uint8 + var line string + for textPointer < len(text) { + + if !patchHeader.MatchString(text[textPointer]) { + return patches, errors.New("Invalid patch string: " + text[textPointer]) + } + + patch = Patch{} + m := patchHeader.FindStringSubmatch(text[textPointer]) + + patch.Start1, _ = strconv.Atoi(m[1]) + if len(m[2]) == 0 { + patch.Start1-- + patch.Length1 = 1 + } else if m[2] == "0" { + patch.Length1 = 0 + } else { + patch.Start1-- + patch.Length1, _ = strconv.Atoi(m[2]) + } + + patch.Start2, _ = strconv.Atoi(m[3]) + + if len(m[4]) == 0 { + patch.Start2-- + patch.Length2 = 1 + } else if m[4] == "0" { + patch.Length2 = 0 + } else { + patch.Start2-- + patch.Length2, _ = strconv.Atoi(m[4]) + } + textPointer++ + + for textPointer < len(text) { + if len(text[textPointer]) > 0 { + sign = text[textPointer][0] + } else { + textPointer++ + continue + } + + line = text[textPointer][1:] + line = strings.Replace(line, "+", "%2b", -1) + line, _ = url.QueryUnescape(line) + if sign == '-' { + // Deletion. + patch.diffs = append(patch.diffs, Diff{DiffDelete, line}) + } else if sign == '+' { + // Insertion. + patch.diffs = append(patch.diffs, Diff{DiffInsert, line}) + } else if sign == ' ' { + // Minor equality. + patch.diffs = append(patch.diffs, Diff{DiffEqual, line}) + } else if sign == '@' { + // Start of next patch. + break + } else { + // WTF? + return patches, errors.New("Invalid patch mode '" + string(sign) + "' in: " + string(line)) + } + textPointer++ + } + + patches = append(patches, patch) + } + return patches, nil +} diff --git a/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/stringutil.go b/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/stringutil.go new file mode 100644 index 0000000000..265f29cc7e --- /dev/null +++ b/vendor/github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch/stringutil.go @@ -0,0 +1,88 @@ +// Copyright (c) 2012-2016 The go-diff authors. All rights reserved. +// https://github.com/sergi/go-diff +// See the included LICENSE file for license details. +// +// go-diff is a Go implementation of Google's Diff, Match, and Patch library +// Original library is Copyright (c) 2006 Google Inc. +// http://code.google.com/p/google-diff-match-patch/ + +package diffmatchpatch + +import ( + "strings" + "unicode/utf8" +) + +// unescaper unescapes selected chars for compatibility with JavaScript's encodeURI. +// In speed critical applications this could be dropped since the receiving application will certainly decode these fine. Note that this function is case-sensitive. Thus "%3F" would not be unescaped. But this is ok because it is only called with the output of HttpUtility.UrlEncode which returns lowercase hex. Example: "%3f" -> "?", "%24" -> "$", etc. +var unescaper = strings.NewReplacer( + "%21", "!", "%7E", "~", "%27", "'", + "%28", "(", "%29", ")", "%3B", ";", + "%2F", "/", "%3F", "?", "%3A", ":", + "%40", "@", "%26", "&", "%3D", "=", + "%2B", "+", "%24", "$", "%2C", ",", "%23", "#", "%2A", "*") + +// indexOf returns the first index of pattern in str, starting at str[i]. +func indexOf(str string, pattern string, i int) int { + if i > len(str)-1 { + return -1 + } + if i <= 0 { + return strings.Index(str, pattern) + } + ind := strings.Index(str[i:], pattern) + if ind == -1 { + return -1 + } + return ind + i +} + +// lastIndexOf returns the last index of pattern in str, starting at str[i]. +func lastIndexOf(str string, pattern string, i int) int { + if i < 0 { + return -1 + } + if i >= len(str) { + return strings.LastIndex(str, pattern) + } + _, size := utf8.DecodeRuneInString(str[i:]) + return strings.LastIndex(str[:i+size], pattern) +} + +// runesIndexOf returns the index of pattern in target, starting at target[i]. +func runesIndexOf(target, pattern []rune, i int) int { + if i > len(target)-1 { + return -1 + } + if i <= 0 { + return runesIndex(target, pattern) + } + ind := runesIndex(target[i:], pattern) + if ind == -1 { + return -1 + } + return ind + i +} + +func runesEqual(r1, r2 []rune) bool { + if len(r1) != len(r2) { + return false + } + for i, c := range r1 { + if c != r2[i] { + return false + } + } + return true +} + +// runesIndex is the equivalent of strings.Index for rune slices. +func runesIndex(r1, r2 []rune) int { + last := len(r1) - len(r2) + for i := 0; i <= last; i++ { + if runesEqual(r1[i:i+len(r2)], r2) { + return i + } + } + return -1 +} diff --git a/vendor/github.com/smartystreets/assertions/messages.go b/vendor/github.com/smartystreets/assertions/messages.go index 6ed7dc2ae9..cd2ec900ba 100644 --- a/vendor/github.com/smartystreets/assertions/messages.go +++ b/vendor/github.com/smartystreets/assertions/messages.go @@ -1,76 +1,85 @@ package assertions -const ( // equality - shouldHaveBeenEqual = "Expected: '%v'\nActual: '%v'\n(Should be equal)" - shouldNotHaveBeenEqual = "Expected '%v'\nto NOT equal '%v'\n(but it did)!" - shouldHaveBeenEqualTypeMismatch = "Expected: '%v' (%T)\nActual: '%v' (%T)\n(Should be equal, type mismatch)" - shouldHaveBeenAlmostEqual = "Expected '%v' to almost equal '%v' (but it didn't)!" - shouldHaveNotBeenAlmostEqual = "Expected '%v' to NOT almost equal '%v' (but it did)!" - shouldHaveResembled = "Expected: '%s'\nActual: '%s'\n(Should resemble)!" - shouldNotHaveResembled = "Expected '%#v'\nto NOT resemble '%#v'\n(but it did)!" - shouldBePointers = "Both arguments should be pointers " - shouldHaveBeenNonNilPointer = shouldBePointers + "(the %s was %s)!" - shouldHavePointedTo = "Expected '%+v' (address: '%v') and '%+v' (address: '%v') to be the same address (but their weren't)!" - shouldNotHavePointedTo = "Expected '%+v' and '%+v' to be different references (but they matched: '%v')!" - shouldHaveBeenNil = "Expected: nil\nActual: '%v'" - shouldNotHaveBeenNil = "Expected '%+v' to NOT be nil (but it was)!" - shouldHaveBeenTrue = "Expected: true\nActual: %v" - shouldHaveBeenFalse = "Expected: false\nActual: %v" - shouldHaveBeenZeroValue = "'%+v' should have been the zero value" //"Expected: (zero value)\nActual: %v" - shouldNotHaveBeenZeroValue = "'%+v' should NOT have been the zero value" -) +const ( + shouldHaveBeenEqual = "Expected: '%v'\nActual: '%v'\n(Should be equal)" + shouldHaveBeenEqualNoResemblance = "Both the actual and expected values render equally ('%s') and their types are the same. Try using ShouldResemble instead." + shouldNotHaveBeenEqual = "Expected '%v'\nto NOT equal '%v'\n(but it did)!" + shouldHaveBeenEqualTypeMismatch = "Expected: '%v' (%T)\nActual: '%v' (%T)\n(Should be equal, type mismatch)" + + shouldHaveBeenAlmostEqual = "Expected '%v' to almost equal '%v' (but it didn't)!" + shouldHaveNotBeenAlmostEqual = "Expected '%v' to NOT almost equal '%v' (but it did)!" + + shouldHaveResembled = "Expected: '%s'\nActual: '%s'\n(Should resemble)!" + shouldNotHaveResembled = "Expected '%#v'\nto NOT resemble '%#v'\n(but it did)!" + + shouldBePointers = "Both arguments should be pointers " + shouldHaveBeenNonNilPointer = shouldBePointers + "(the %s was %s)!" + shouldHavePointedTo = "Expected '%+v' (address: '%v') and '%+v' (address: '%v') to be the same address (but their weren't)!" + shouldNotHavePointedTo = "Expected '%+v' and '%+v' to be different references (but they matched: '%v')!" + + shouldHaveBeenNil = "Expected: nil\nActual: '%v'" + shouldNotHaveBeenNil = "Expected '%+v' to NOT be nil (but it was)!" + + shouldHaveBeenTrue = "Expected: true\nActual: %v" + shouldHaveBeenFalse = "Expected: false\nActual: %v" + + shouldHaveBeenZeroValue = "'%+v' should have been the zero value" //"Expected: (zero value)\nActual: %v" + shouldNotHaveBeenZeroValue = "'%+v' should NOT have been the zero value" + + shouldHaveBeenGreater = "Expected '%v' to be greater than '%v' (but it wasn't)!" + shouldHaveBeenGreaterOrEqual = "Expected '%v' to be greater than or equal to '%v' (but it wasn't)!" + + shouldHaveBeenLess = "Expected '%v' to be less than '%v' (but it wasn't)!" + shouldHaveBeenLessOrEqual = "Expected '%v' to be less than or equal to '%v' (but it wasn't)!" -const ( // quantity comparisons - shouldHaveBeenGreater = "Expected '%v' to be greater than '%v' (but it wasn't)!" - shouldHaveBeenGreaterOrEqual = "Expected '%v' to be greater than or equal to '%v' (but it wasn't)!" - shouldHaveBeenLess = "Expected '%v' to be less than '%v' (but it wasn't)!" - shouldHaveBeenLessOrEqual = "Expected '%v' to be less than or equal to '%v' (but it wasn't)!" shouldHaveBeenBetween = "Expected '%v' to be between '%v' and '%v' (but it wasn't)!" shouldNotHaveBeenBetween = "Expected '%v' NOT to be between '%v' and '%v' (but it was)!" shouldHaveDifferentUpperAndLower = "The lower and upper bounds must be different values (they were both '%v')." - shouldHaveBeenBetweenOrEqual = "Expected '%v' to be between '%v' and '%v' or equal to one of them (but it wasn't)!" - shouldNotHaveBeenBetweenOrEqual = "Expected '%v' NOT to be between '%v' and '%v' or equal to one of them (but it was)!" -) -const ( // collections + shouldHaveBeenBetweenOrEqual = "Expected '%v' to be between '%v' and '%v' or equal to one of them (but it wasn't)!" + shouldNotHaveBeenBetweenOrEqual = "Expected '%v' NOT to be between '%v' and '%v' or equal to one of them (but it was)!" + shouldHaveContained = "Expected the container (%v) to contain: '%v' (but it didn't)!" shouldNotHaveContained = "Expected the container (%v) NOT to contain: '%v' (but it did)!" - shouldHaveContainedKey = "Expected the %v to contain the key: %v (but it didn't)!" - shouldNotHaveContainedKey = "Expected the %v NOT to contain the key: %v (but it did)!" - shouldHaveBeenIn = "Expected '%v' to be in the container (%v), but it wasn't!" - shouldNotHaveBeenIn = "Expected '%v' NOT to be in the container (%v), but it was!" shouldHaveBeenAValidCollection = "You must provide a valid container (was %v)!" - shouldHaveBeenAValidMap = "You must provide a valid map type (was %v)!" - shouldHaveBeenEmpty = "Expected %+v to be empty (but it wasn't)!" - shouldNotHaveBeenEmpty = "Expected %+v to NOT be empty (but it was)!" - shouldHaveBeenAValidInteger = "You must provide a valid integer (was %v)!" - shouldHaveBeenAValidLength = "You must provide a valid positive integer (was %v)!" - shouldHaveHadLength = "Expected collection to have length equal to [%v], but it's length was [%v] instead! contents: %+v" -) -const ( // strings - shouldHaveStartedWith = "Expected '%v'\nto start with '%v'\n(but it didn't)!" - shouldNotHaveStartedWith = "Expected '%v'\nNOT to start with '%v'\n(but it did)!" - shouldHaveEndedWith = "Expected '%v'\nto end with '%v'\n(but it didn't)!" - shouldNotHaveEndedWith = "Expected '%v'\nNOT to end with '%v'\n(but it did)!" - shouldAllBeStrings = "All arguments to this assertion must be strings (you provided: %v)." - shouldBothBeStrings = "Both arguments to this assertion must be strings (you provided %v and %v)." - shouldBeString = "The argument to this assertion must be a string (you provided %v)." + shouldHaveContainedKey = "Expected the %v to contain the key: %v (but it didn't)!" + shouldNotHaveContainedKey = "Expected the %v NOT to contain the key: %v (but it did)!" + shouldHaveBeenAValidMap = "You must provide a valid map type (was %v)!" + + shouldHaveBeenIn = "Expected '%v' to be in the container (%v), but it wasn't!" + shouldNotHaveBeenIn = "Expected '%v' NOT to be in the container (%v), but it was!" + + shouldHaveBeenEmpty = "Expected %+v to be empty (but it wasn't)!" + shouldNotHaveBeenEmpty = "Expected %+v to NOT be empty (but it was)!" + + shouldHaveBeenAValidInteger = "You must provide a valid integer (was %v)!" + shouldHaveBeenAValidLength = "You must provide a valid positive integer (was %v)!" + shouldHaveHadLength = "Expected collection to have length equal to [%v], but its length was [%v] instead! contents: %+v" + + shouldHaveStartedWith = "Expected '%v'\nto start with '%v'\n(but it didn't)!" + shouldNotHaveStartedWith = "Expected '%v'\nNOT to start with '%v'\n(but it did)!" + + shouldHaveEndedWith = "Expected '%v'\nto end with '%v'\n(but it didn't)!" + shouldNotHaveEndedWith = "Expected '%v'\nNOT to end with '%v'\n(but it did)!" + + shouldAllBeStrings = "All arguments to this assertion must be strings (you provided: %v)." + shouldBothBeStrings = "Both arguments to this assertion must be strings (you provided %v and %v)." + shouldHaveContainedSubstring = "Expected '%s' to contain substring '%s' (but it didn't)!" shouldNotHaveContainedSubstring = "Expected '%s' NOT to contain substring '%s' (but it did)!" - shouldHaveBeenBlank = "Expected '%s' to be blank (but it wasn't)!" - shouldNotHaveBeenBlank = "Expected value to NOT be blank (but it was)!" -) -const ( // panics + shouldBeString = "The argument to this assertion must be a string (you provided %v)." + shouldHaveBeenBlank = "Expected '%s' to be blank (but it wasn't)!" + shouldNotHaveBeenBlank = "Expected value to NOT be blank (but it was)!" + shouldUseVoidNiladicFunction = "You must provide a void, niladic function as the first argument!" - shouldHavePanickedWith = "Expected func() to panic with '%v' (but it panicked with '%v')!" shouldHavePanicked = "Expected func() to panic (but it didn't)!" shouldNotHavePanicked = "Expected func() NOT to panic (error: '%+v')!" - shouldNotHavePanickedWith = "Expected func() NOT to panic with '%v' (but it did)!" -) -const ( // type checking + shouldHavePanickedWith = "Expected func() to panic with '%v' (but it panicked with '%v')!" + shouldNotHavePanickedWith = "Expected func() NOT to panic with '%v' (but it did)!" + shouldHaveBeenA = "Expected '%v' to be: '%v' (but was: '%v')!" shouldNotHaveBeenA = "Expected '%v' to NOT be: '%v' (but it was)!" @@ -81,17 +90,19 @@ const ( // type checking shouldBeError = "Expected an error value (but was '%v' instead)!" shouldBeErrorInvalidComparisonValue = "The final argument to this assertion must be a string or an error value (you provided: '%v')." -) -const ( // time comparisons - shouldUseTimes = "You must provide time instances as arguments to this assertion." - shouldUseTimeSlice = "You must provide a slice of time instances as the first argument to this assertion." - shouldUseDurationAndTime = "You must provide a duration and a time as arguments to this assertion." + shouldWrapInvalidTypes = "The first and last arguments to this assertion must both be error values (you provided: '%v' and '%v')." + + shouldUseTimes = "You must provide time instances as arguments to this assertion." + shouldUseTimeSlice = "You must provide a slice of time instances as the first argument to this assertion." + shouldUseDurationAndTime = "You must provide a duration and a time as arguments to this assertion." + shouldHaveHappenedBefore = "Expected '%v' to happen before '%v' (it happened '%v' after)!" shouldHaveHappenedAfter = "Expected '%v' to happen after '%v' (it happened '%v' before)!" shouldHaveHappenedBetween = "Expected '%v' to happen between '%v' and '%v' (it happened '%v' outside threshold)!" shouldNotHaveHappenedOnOrBetween = "Expected '%v' to NOT happen on or between '%v' and '%v' (but it did)!" // format params: incorrect-index, previous-index, previous-time, incorrect-index, incorrect-time - shouldHaveBeenChronological = "The 'Time' at index [%d] should have happened after the previous one (but it didn't!):\n [%d]: %s\n [%d]: %s (see, it happened before!)" + shouldHaveBeenChronological = "The 'Time' at index [%d] should have happened after the previous one (but it didn't!):\n [%d]: %s\n [%d]: %s (see, it happened before!)" + shouldNotHaveBeenchronological = "The provided times should NOT be chronological, but they were." ) diff --git a/vendor/github.com/smartystreets/assertions/panic.go b/vendor/github.com/smartystreets/assertions/panic.go index 7e75db1784..ccb1574a31 100644 --- a/vendor/github.com/smartystreets/assertions/panic.go +++ b/vendor/github.com/smartystreets/assertions/panic.go @@ -1,6 +1,9 @@ package assertions -import "fmt" +import ( + "errors" + "fmt" +) // ShouldPanic receives a void, niladic function and expects to recover a panic. func ShouldPanic(actual interface{}, expected ...interface{}) (message string) { @@ -55,6 +58,7 @@ func ShouldNotPanic(actual interface{}, expected ...interface{}) (message string } // ShouldPanicWith receives a void, niladic function and expects to recover a panic with the second argument as the content. +// If the expected value is an error and the recovered value is an error, errors.Is is used to compare them. func ShouldPanicWith(actual interface{}, expected ...interface{}) (message string) { if fail := need(1, expected); fail != success { return fail @@ -72,7 +76,11 @@ func ShouldPanicWith(actual interface{}, expected ...interface{}) (message strin if recovered == nil { message = shouldHavePanicked } else { - if equal := ShouldEqual(recovered, expected[0]); equal != success { + recoveredErr, errFound := recovered.(error) + expectedErr, expectedFound := expected[0].(error) + if errFound && expectedFound && errors.Is(recoveredErr, expectedErr) { + message = success + } else if equal := ShouldEqual(recovered, expected[0]); equal != success { message = serializer.serialize(expected[0], recovered, fmt.Sprintf(shouldHavePanickedWith, expected[0], recovered)) } else { message = success @@ -85,6 +93,7 @@ func ShouldPanicWith(actual interface{}, expected ...interface{}) (message strin } // ShouldNotPanicWith receives a void, niladic function and expects to recover a panic whose content differs from the second argument. +// If the expected value is an error and the recovered value is an error, errors.Is is used to compare them. func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message string) { if fail := need(1, expected); fail != success { return fail @@ -102,7 +111,11 @@ func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message st if recovered == nil { message = success } else { - if equal := ShouldEqual(recovered, expected[0]); equal == success { + recoveredErr, errFound := recovered.(error) + expectedErr, expectedFound := expected[0].(error) + if errFound && expectedFound && errors.Is(recoveredErr, expectedErr) { + message = fmt.Sprintf(shouldNotHavePanickedWith, expected[0]) + } else if equal := ShouldEqual(recovered, expected[0]); equal == success { message = fmt.Sprintf(shouldNotHavePanickedWith, expected[0]) } else { message = success diff --git a/vendor/github.com/smartystreets/assertions/serializer.go b/vendor/github.com/smartystreets/assertions/serializer.go index fa32f9403f..f1e3570edc 100644 --- a/vendor/github.com/smartystreets/assertions/serializer.go +++ b/vendor/github.com/smartystreets/assertions/serializer.go @@ -3,6 +3,7 @@ package assertions import ( "encoding/json" "fmt" + "strings" "github.com/smartystreets/assertions/internal/go-render/render" ) @@ -15,6 +16,9 @@ type Serializer interface { type failureSerializer struct{} func (self *failureSerializer) serializeDetailed(expected, actual interface{}, message string) string { + if index := strings.Index(message, " Diff:"); index > 0 { + message = message[:index] + } view := FailureView{ Message: message, Expected: render.Render(expected), @@ -25,6 +29,9 @@ func (self *failureSerializer) serializeDetailed(expected, actual interface{}, m } func (self *failureSerializer) serialize(expected, actual interface{}, message string) string { + if index := strings.Index(message, " Diff:"); index > 0 { + message = message[:index] + } view := FailureView{ Message: message, Expected: fmt.Sprintf("%+v", expected), diff --git a/vendor/github.com/smartystreets/assertions/time.go b/vendor/github.com/smartystreets/assertions/time.go index 7e05026143..918ee2840e 100644 --- a/vendor/github.com/smartystreets/assertions/time.go +++ b/vendor/github.com/smartystreets/assertions/time.go @@ -178,7 +178,7 @@ func ShouldNotHappenWithin(actual interface{}, expected ...interface{}) string { return ShouldNotHappenOnOrBetween(actualTime, min, max) } -// ShouldBeChronological receives a []time.Time slice and asserts that the are +// ShouldBeChronological receives a []time.Time slice and asserts that they are // in chronological order starting with the first time.Time as the earliest. func ShouldBeChronological(actual interface{}, expected ...interface{}) string { if fail := need(0, expected); fail != success { @@ -200,3 +200,19 @@ func ShouldBeChronological(actual interface{}, expected ...interface{}) string { } return "" } + +// ShouldNotBeChronological receives a []time.Time slice and asserts that they are +// NOT in chronological order. +func ShouldNotBeChronological(actual interface{}, expected ...interface{}) string { + if fail := need(0, expected); fail != success { + return fail + } + if _, ok := actual.([]time.Time); !ok { + return shouldUseTimeSlice + } + result := ShouldBeChronological(actual, expected...) + if result != "" { + return "" + } + return shouldNotHaveBeenchronological +} diff --git a/vendor/github.com/smartystreets/assertions/type.go b/vendor/github.com/smartystreets/assertions/type.go index d2d1dc864b..1984fe8945 100644 --- a/vendor/github.com/smartystreets/assertions/type.go +++ b/vendor/github.com/smartystreets/assertions/type.go @@ -1,6 +1,7 @@ package assertions import ( + "errors" "fmt" "reflect" ) @@ -130,5 +131,24 @@ func ShouldBeError(actual interface{}, expected ...interface{}) string { return ShouldEqual(fmt.Sprint(actual), fmt.Sprint(expected[0])) } +// ShouldWrap asserts that the first argument (which must be an error value) +// 'wraps' the second/final argument (which must also be an error value). +// It relies on errors.Is to make the determination (https://golang.org/pkg/errors/#Is). +func ShouldWrap(actual interface{}, expected ...interface{}) string { + if fail := need(1, expected); fail != success { + return fail + } + + if !isError(actual) || !isError(expected[0]) { + return fmt.Sprintf(shouldWrapInvalidTypes, reflect.TypeOf(actual), reflect.TypeOf(expected[0])) + } + + if !errors.Is(actual.(error), expected[0].(error)) { + return fmt.Sprintf(`Expected error("%s") to wrap error("%s") but it didn't.`, actual, expected[0]) + } + + return success +} + func isString(value interface{}) bool { _, ok := value.(string); return ok } func isError(value interface{}) bool { _, ok := value.(error); return ok } diff --git a/vendor/github.com/smartystreets/goconvey/convey/assertions.go b/vendor/github.com/smartystreets/goconvey/convey/assertions.go index 97e3bec82e..9fad7c2995 100644 --- a/vendor/github.com/smartystreets/goconvey/convey/assertions.go +++ b/vendor/github.com/smartystreets/goconvey/convey/assertions.go @@ -7,6 +7,7 @@ var ( ShouldNotEqual = assertions.ShouldNotEqual ShouldAlmostEqual = assertions.ShouldAlmostEqual ShouldNotAlmostEqual = assertions.ShouldNotAlmostEqual + ShouldEqualJSON = assertions.ShouldEqualJSON ShouldResemble = assertions.ShouldResemble ShouldNotResemble = assertions.ShouldNotResemble ShouldPointTo = assertions.ShouldPointTo @@ -68,4 +69,5 @@ var ( ShouldBeChronological = assertions.ShouldBeChronological ShouldBeError = assertions.ShouldBeError + ShouldWrap = assertions.ShouldWrap ) diff --git a/vendor/github.com/smartystreets/goconvey/convey/context.go b/vendor/github.com/smartystreets/goconvey/convey/context.go index 2c75c2d7b1..4b0d28dc22 100644 --- a/vendor/github.com/smartystreets/goconvey/convey/context.go +++ b/vendor/github.com/smartystreets/goconvey/convey/context.go @@ -79,6 +79,7 @@ type context struct { focus bool failureMode FailureMode + stackMode StackMode } // rootConvey is the main entry point to a test suite. This is called when @@ -101,6 +102,7 @@ func rootConvey(items ...interface{}) { focus: entry.Focus, failureMode: defaultFailureMode.combine(entry.FailMode), + stackMode: defaultStackMode.combine(entry.StackMode), } ctxMgr.SetValues(gls.Values{nodeKey: ctx}, func() { ctx.reporter.BeginStory(reporting.NewStoryReport(entry.Test)) @@ -154,6 +156,7 @@ func (ctx *context) Convey(items ...interface{}) { focus: entry.Focus, failureMode: ctx.failureMode.combine(entry.FailMode), + stackMode: ctx.stackMode.combine(entry.StackMode), } ctx.children[entry.Situation] = inner_ctx } @@ -169,11 +172,22 @@ func (ctx *context) SkipSo(stuff ...interface{}) { ctx.assertionReport(reporting.NewSkipReport()) } -func (ctx *context) So(actual interface{}, assert assertion, expected ...interface{}) { +func (ctx *context) So(actual interface{}, assert Assertion, expected ...interface{}) { if result := assert(actual, expected...); result == assertionSuccess { ctx.assertionReport(reporting.NewSuccessReport()) } else { - ctx.assertionReport(reporting.NewFailureReport(result)) + ctx.assertionReport(reporting.NewFailureReport(result, ctx.shouldShowStack())) + } +} + +func (ctx *context) SoMsg(msg string, actual interface{}, assert Assertion, expected ...interface{}) { + if result := assert(actual, expected...); result == assertionSuccess { + ctx.assertionReport(reporting.NewSuccessReport()) + return + } else { + ctx.reporter.Enter(reporting.NewScopeReport(msg)) + defer ctx.reporter.Exit() + ctx.assertionReport(reporting.NewFailureReport(result, ctx.shouldShowStack())) } } @@ -206,6 +220,10 @@ func (c *context) shouldVisit() bool { return !c.complete && *c.expectChildRun } +func (c *context) shouldShowStack() bool { + return c.stackMode == StackFail +} + // conveyInner is the function which actually executes the user's anonymous test // function body. At this point, Convey or RootConvey has decided that this // function should actually run. diff --git a/vendor/github.com/smartystreets/goconvey/convey/discovery.go b/vendor/github.com/smartystreets/goconvey/convey/discovery.go index eb8d4cb2ce..5e6d1f6866 100644 --- a/vendor/github.com/smartystreets/goconvey/convey/discovery.go +++ b/vendor/github.com/smartystreets/goconvey/convey/discovery.go @@ -14,14 +14,16 @@ type suite struct { Focus bool Func func(C) // nil means skipped FailMode FailureMode + StackMode StackMode } -func newSuite(situation string, failureMode FailureMode, f func(C), test t, specifier actionSpecifier) *suite { +func newSuite(situation string, failureMode FailureMode, stackMode StackMode, f func(C), test t, specifier actionSpecifier) *suite { ret := &suite{ Situation: situation, Test: test, Func: f, FailMode: failureMode, + StackMode: stackMode, } switch specifier { case skipConvey: @@ -36,6 +38,7 @@ func discover(items []interface{}) *suite { name, items := parseName(items) test, items := parseGoTest(items) failure, items := parseFailureMode(items) + stack, items := parseStackMode(items) action, items := parseAction(items) specifier, items := parseSpecifier(items) @@ -43,7 +46,7 @@ func discover(items []interface{}) *suite { conveyPanic(parseError) } - return newSuite(name, failure, action, test, specifier) + return newSuite(name, failure, stack, action, test, specifier) } func item(items []interface{}) interface{} { if len(items) == 0 { @@ -70,6 +73,12 @@ func parseFailureMode(items []interface{}) (FailureMode, []interface{}) { } return FailureInherits, items } +func parseStackMode(items []interface{}) (StackMode, []interface{}) { + if mode, parsed := item(items).(StackMode); parsed { + return mode, items[1:] + } + return StackInherits, items +} func parseAction(items []interface{}) (func(C), []interface{}) { switch x := item(items).(type) { case nil: @@ -100,4 +109,4 @@ type t interface { Fail() } -const parseError = "You must provide a name (string), then a *testing.T (if in outermost scope), an optional FailureMode, and then an action (func())." +const parseError = "You must provide a name (string), then a *testing.T (if in outermost scope), an optional FailureMode and / or StackMode, and then an action (func())." diff --git a/vendor/github.com/smartystreets/goconvey/convey/doc.go b/vendor/github.com/smartystreets/goconvey/convey/doc.go index e4f7b51a86..b852235810 100644 --- a/vendor/github.com/smartystreets/goconvey/convey/doc.go +++ b/vendor/github.com/smartystreets/goconvey/convey/doc.go @@ -23,7 +23,8 @@ type C interface { SkipConvey(items ...interface{}) FocusConvey(items ...interface{}) - So(actual interface{}, assert assertion, expected ...interface{}) + So(actual interface{}, assert Assertion, expected ...interface{}) + SoMsg(msg string, actual interface{}, assert Assertion, expected ...interface{}) SkipSo(stuff ...interface{}) Reset(action func()) @@ -104,11 +105,11 @@ func Reset(action func()) { /////////////////////////////////// Assertions /////////////////////////////////// -// assertion is an alias for a function with a signature that the convey.So() +// Assertion is an alias for a function with a signature that the convey.So() // method can handle. Any future or custom assertions should conform to this // method signature. The return value should be an empty string if the assertion // passes and a well-formed failure message if not. -type assertion func(actual interface{}, expected ...interface{}) string +type Assertion func(actual interface{}, expected ...interface{}) string const assertionSuccess = "" @@ -121,10 +122,15 @@ const assertionSuccess = "" // documentation on specific assertion methods. A failing assertion will // cause t.Fail() to be invoked--you should never call this method (or other // failure-inducing methods) in your test code. Leave that to GoConvey. -func So(actual interface{}, assert assertion, expected ...interface{}) { +func So(actual interface{}, assert Assertion, expected ...interface{}) { mustGetCurrentContext().So(actual, assert, expected...) } +// SoMsg is an extension of So that allows you to specify a message to report on error. +func SoMsg(msg string, actual interface{}, assert Assertion, expected ...interface{}) { + mustGetCurrentContext().SoMsg(msg, actual, assert, expected...) +} + // SkipSo is analogous to So except that the assertion that would have been passed // to So is not executed and the reporter is notified that the assertion was skipped. func SkipSo(stuff ...interface{}) { @@ -135,6 +141,10 @@ func SkipSo(stuff ...interface{}) { // if their assertion fails. See constants further down for acceptable values type FailureMode string +// StackMode is a type which determines whether the So() blocks should report +// stack traces their assertion fails. See constants further down for acceptable values +type StackMode string + const ( // FailureContinues is a failure mode which prevents failing @@ -151,6 +161,19 @@ const ( // default to the failure-mode of the parent block. You should never // need to specify this mode in your tests.. FailureInherits FailureMode = "inherits" + + // StackError is a stack mode which tells Convey to print stack traces + // only for errors and not for test failures + StackError StackMode = "error" + + // StackFail is a stack mode which tells Convey to print stack traces + // for both errors and test failures + StackFail StackMode = "fail" + + // StackInherits is the default setting for stack-mode, it will + // default to the stack-mode of the parent block. You should never + // need to specify this mode in your tests.. + StackInherits StackMode = "inherits" ) func (f FailureMode) combine(other FailureMode) FailureMode { @@ -164,7 +187,7 @@ var defaultFailureMode FailureMode = FailureHalts // SetDefaultFailureMode allows you to specify the default failure mode // for all Convey blocks. It is meant to be used in an init function to -// allow the default mode to be changdd across all tests for an entire packgae +// allow the default mode to be changed across all tests for an entire packgae // but it can be used anywhere. func SetDefaultFailureMode(mode FailureMode) { if mode == FailureContinues || mode == FailureHalts { @@ -174,6 +197,27 @@ func SetDefaultFailureMode(mode FailureMode) { } } +func (s StackMode) combine(other StackMode) StackMode { + if other == StackInherits { + return s + } + return other +} + +var defaultStackMode StackMode = StackError + +// SetDefaultStackMode allows you to specify the default stack mode +// for all Convey blocks. It is meant to be used in an init function to +// allow the default mode to be changed across all tests for an entire packgae +// but it can be used anywhere. +func SetDefaultStackMode(mode StackMode) { + if mode == StackError || mode == StackFail { + defaultStackMode = mode + } else { + panic("You may only use the constants named 'StackError' and 'StackFail' as default stack modes.") + } +} + //////////////////////////////////// Print functions //////////////////////////////////// // Print is analogous to fmt.Print (and it even calls fmt.Print). It ensures that diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/init.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/init.go index 99c3bd6d61..976e8179f7 100644 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/init.go +++ b/vendor/github.com/smartystreets/goconvey/convey/reporting/init.go @@ -56,7 +56,8 @@ var ( dotError = "E" dotSkip = "S" errorTemplate = "* %s \nLine %d: - %v \n%s\n" - failureTemplate = "* %s \nLine %d:\n%s\n%s\n" + failureTemplate = "* %s \nLine %d:\n%s\n" + stackTemplate = "%s\n" ) var ( diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go index 33d5e14767..f119122d9f 100644 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go +++ b/vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go @@ -53,7 +53,10 @@ func (self *problem) showFailures() { self.out.Println("\nFailures:\n") self.out.Indent() } - self.out.Println(failureTemplate, f.File, f.Line, f.Failure, f.StackTrace) + self.out.Println(failureTemplate, f.File, f.Line, f.Failure) + if f.StackTrace != "" { + self.out.Println(stackTemplate, f.StackTrace) + } } } diff --git a/vendor/github.com/smartystreets/goconvey/convey/reporting/reports.go b/vendor/github.com/smartystreets/goconvey/convey/reporting/reports.go index 712e6ade62..f30789f61c 100644 --- a/vendor/github.com/smartystreets/goconvey/convey/reporting/reports.go +++ b/vendor/github.com/smartystreets/goconvey/convey/reporting/reports.go @@ -97,10 +97,12 @@ type AssertionResult struct { Skipped bool } -func NewFailureReport(failure string) *AssertionResult { +func NewFailureReport(failure string, showStack bool) *AssertionResult { report := new(AssertionResult) report.File, report.Line = caller() - report.StackTrace = stackTrace() + if showStack { + report.StackTrace = stackTrace() + } parseFailure(failure, report) return report } diff --git a/vendor/github.com/tredoe/osutil/AUTHORS.md b/vendor/github.com/tredoe/osutil/AUTHORS.md deleted file mode 100644 index 518f194222..0000000000 --- a/vendor/github.com/tredoe/osutil/AUTHORS.md +++ /dev/null @@ -1,16 +0,0 @@ -# Authors - -This is the official list of authors for copyright purposes. -This file is distinct from the 'CONTRIBUTORS' file. See the latter for an explanation. - -Names should be added to this file as: - - Name or Organization / (url address) - -(The email address is not required for organizations) - -Please keep the list sorted. - -## Code - -* Jonas mg (https://github.com/tredoe) diff --git a/vendor/github.com/tredoe/osutil/CONTRIBUTORS.md b/vendor/github.com/tredoe/osutil/CONTRIBUTORS.md deleted file mode 100644 index b630fff1c1..0000000000 --- a/vendor/github.com/tredoe/osutil/CONTRIBUTORS.md +++ /dev/null @@ -1,22 +0,0 @@ -# Contributors - -This is the official list of people who can contribute (and typically -have contributed) to the repository. - -The 'AUTHORS' file lists the copyright holders; this file lists people. For -example, the employees of an organization are listed here but not in 'AUTHORS', -because the organization holds the copyright. - -Names should be added to this file as: - - Name / (url address) - -Please keep the list sorted. - -## Code - -* Jonas mg (https://github.com/tredoe) - -* DJ Gregor -* Jeramey Crawford -* Misha Seltzer (https://github.com/mishas) diff --git a/vendor/github.com/tredoe/osutil/LICENSE-MPL.txt b/vendor/github.com/tredoe/osutil/LICENSE-MPL.txt deleted file mode 100644 index 52d135112e..0000000000 --- a/vendor/github.com/tredoe/osutil/LICENSE-MPL.txt +++ /dev/null @@ -1,374 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. - diff --git a/vendor/github.com/tredoe/osutil/user/crypt/AUTHORS.md b/vendor/github.com/tredoe/osutil/v2/userutil/crypt/AUTHORS.md similarity index 100% rename from vendor/github.com/tredoe/osutil/user/crypt/AUTHORS.md rename to vendor/github.com/tredoe/osutil/v2/userutil/crypt/AUTHORS.md diff --git a/vendor/github.com/tredoe/osutil/user/crypt/LICENSE b/vendor/github.com/tredoe/osutil/v2/userutil/crypt/LICENSE similarity index 100% rename from vendor/github.com/tredoe/osutil/user/crypt/LICENSE rename to vendor/github.com/tredoe/osutil/v2/userutil/crypt/LICENSE diff --git a/vendor/github.com/tredoe/osutil/user/crypt/README.md b/vendor/github.com/tredoe/osutil/v2/userutil/crypt/README.md similarity index 100% rename from vendor/github.com/tredoe/osutil/user/crypt/README.md rename to vendor/github.com/tredoe/osutil/v2/userutil/crypt/README.md diff --git a/vendor/github.com/tredoe/osutil/user/crypt/common/base64.go b/vendor/github.com/tredoe/osutil/v2/userutil/crypt/common/base64.go similarity index 100% rename from vendor/github.com/tredoe/osutil/user/crypt/common/base64.go rename to vendor/github.com/tredoe/osutil/v2/userutil/crypt/common/base64.go diff --git a/vendor/github.com/tredoe/osutil/user/crypt/common/doc.go b/vendor/github.com/tredoe/osutil/v2/userutil/crypt/common/doc.go similarity index 100% rename from vendor/github.com/tredoe/osutil/user/crypt/common/doc.go rename to vendor/github.com/tredoe/osutil/v2/userutil/crypt/common/doc.go diff --git a/vendor/github.com/tredoe/osutil/user/crypt/common/salt.go b/vendor/github.com/tredoe/osutil/v2/userutil/crypt/common/salt.go similarity index 100% rename from vendor/github.com/tredoe/osutil/user/crypt/common/salt.go rename to vendor/github.com/tredoe/osutil/v2/userutil/crypt/common/salt.go diff --git a/vendor/github.com/tredoe/osutil/user/crypt/crypt.go b/vendor/github.com/tredoe/osutil/v2/userutil/crypt/crypt.go similarity index 88% rename from vendor/github.com/tredoe/osutil/user/crypt/crypt.go rename to vendor/github.com/tredoe/osutil/v2/userutil/crypt/crypt.go index 5ded2da8c6..13e7791e65 100644 --- a/vendor/github.com/tredoe/osutil/user/crypt/crypt.go +++ b/vendor/github.com/tredoe/osutil/v2/userutil/crypt/crypt.go @@ -12,7 +12,7 @@ import ( "errors" "strings" - "github.com/tredoe/osutil/user/crypt/common" + "github.com/tredoe/osutil/v2/userutil/crypt/common" ) var ErrKeyMismatch = errors.New("hashed value is not the hash of the given password") @@ -52,10 +52,10 @@ type Crypter interface { type Crypt uint const ( - APR1 Crypt = iota + 1 // import "github.com/tredoe/osutil/user/crypt/apr1_crypt" - MD5 // import "github.com/tredoe/osutil/user/crypt/md5_crypt" - SHA256 // import "github.com/tredoe/osutil/user/crypt/sha256_crypt" - SHA512 // import "github.com/tredoe/osutil/user/crypt/sha512_crypt" + APR1 Crypt = iota + 1 // import "github.com/tredoe/osutil/v2/user/crypt/apr1_crypt" + MD5 // import "github.com/tredoe/osutil/v2/user/crypt/md5_crypt" + SHA256 // import "github.com/tredoe/osutil/v2/user/crypt/sha256_crypt" + SHA512 // import "github.com/tredoe/osutil/v2/user/crypt/sha512_crypt" maxCrypt ) diff --git a/vendor/github.com/tredoe/osutil/user/crypt/sha512_crypt/sha512_crypt.go b/vendor/github.com/tredoe/osutil/v2/userutil/crypt/sha512_crypt/sha512_crypt.go similarity index 98% rename from vendor/github.com/tredoe/osutil/user/crypt/sha512_crypt/sha512_crypt.go rename to vendor/github.com/tredoe/osutil/v2/userutil/crypt/sha512_crypt/sha512_crypt.go index fd55e88124..18ee1630bf 100644 --- a/vendor/github.com/tredoe/osutil/user/crypt/sha512_crypt/sha512_crypt.go +++ b/vendor/github.com/tredoe/osutil/v2/userutil/crypt/sha512_crypt/sha512_crypt.go @@ -17,8 +17,8 @@ import ( "crypto/sha512" "strconv" - "github.com/tredoe/osutil/user/crypt" - "github.com/tredoe/osutil/user/crypt/common" + "github.com/tredoe/osutil/v2/userutil/crypt" + "github.com/tredoe/osutil/v2/userutil/crypt/common" ) func init() { diff --git a/vendor/golang.org/x/crypto/AUTHORS b/vendor/golang.org/x/crypto/AUTHORS deleted file mode 100644 index 2b00ddba0d..0000000000 --- a/vendor/golang.org/x/crypto/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code refers to The Go Authors for copyright purposes. -# The master list of authors is in the main Go distribution, -# visible at https://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/crypto/CONTRIBUTORS b/vendor/golang.org/x/crypto/CONTRIBUTORS deleted file mode 100644 index 1fbd3e976f..0000000000 --- a/vendor/golang.org/x/crypto/CONTRIBUTORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code was written by the Go contributors. -# The master list of contributors is in the main Go distribution, -# visible at https://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/crypto/chacha20/chacha_generic.go b/vendor/golang.org/x/crypto/chacha20/chacha_generic.go index a2ecf5c325..93eb5ae6de 100644 --- a/vendor/golang.org/x/crypto/chacha20/chacha_generic.go +++ b/vendor/golang.org/x/crypto/chacha20/chacha_generic.go @@ -12,7 +12,7 @@ import ( "errors" "math/bits" - "golang.org/x/crypto/internal/subtle" + "golang.org/x/crypto/internal/alias" ) const ( @@ -189,7 +189,7 @@ func (s *Cipher) XORKeyStream(dst, src []byte) { panic("chacha20: output smaller than input") } dst = dst[:len(src)] - if subtle.InexactOverlap(dst, src) { + if alias.InexactOverlap(dst, src) { panic("chacha20: invalid buffer overlap") } diff --git a/vendor/golang.org/x/crypto/curve25519/curve25519.go b/vendor/golang.org/x/crypto/curve25519/curve25519.go index cda3fdd354..bc62161d6e 100644 --- a/vendor/golang.org/x/crypto/curve25519/curve25519.go +++ b/vendor/golang.org/x/crypto/curve25519/curve25519.go @@ -9,7 +9,8 @@ package curve25519 // import "golang.org/x/crypto/curve25519" import ( "crypto/subtle" - "fmt" + "errors" + "strconv" "golang.org/x/crypto/curve25519/internal/field" ) @@ -124,10 +125,10 @@ func X25519(scalar, point []byte) ([]byte, error) { func x25519(dst *[32]byte, scalar, point []byte) ([]byte, error) { var in [32]byte if l := len(scalar); l != 32 { - return nil, fmt.Errorf("bad scalar length: %d, expected %d", l, 32) + return nil, errors.New("bad scalar length: " + strconv.Itoa(l) + ", expected 32") } if l := len(point); l != 32 { - return nil, fmt.Errorf("bad point length: %d, expected %d", l, 32) + return nil, errors.New("bad point length: " + strconv.Itoa(l) + ", expected 32") } copy(in[:], scalar) if &point[0] == &Basepoint[0] { @@ -138,7 +139,7 @@ func x25519(dst *[32]byte, scalar, point []byte) ([]byte, error) { copy(base[:], point) ScalarMult(dst, &in, &base) if subtle.ConstantTimeCompare(dst[:], zero[:]) == 1 { - return nil, fmt.Errorf("bad input point: low order point") + return nil, errors.New("bad input point: low order point") } } return dst[:], nil diff --git a/vendor/golang.org/x/crypto/internal/subtle/aliasing.go b/vendor/golang.org/x/crypto/internal/alias/alias.go similarity index 84% rename from vendor/golang.org/x/crypto/internal/subtle/aliasing.go rename to vendor/golang.org/x/crypto/internal/alias/alias.go index 4fad24f8dc..69c17f822b 100644 --- a/vendor/golang.org/x/crypto/internal/subtle/aliasing.go +++ b/vendor/golang.org/x/crypto/internal/alias/alias.go @@ -5,9 +5,8 @@ //go:build !purego // +build !purego -// Package subtle implements functions that are often useful in cryptographic -// code but require careful thought to use correctly. -package subtle // import "golang.org/x/crypto/internal/subtle" +// Package alias implements memory aliasing tests. +package alias import "unsafe" diff --git a/vendor/golang.org/x/crypto/internal/subtle/aliasing_purego.go b/vendor/golang.org/x/crypto/internal/alias/alias_purego.go similarity index 86% rename from vendor/golang.org/x/crypto/internal/subtle/aliasing_purego.go rename to vendor/golang.org/x/crypto/internal/alias/alias_purego.go index 80ccbed2c0..4775b0a438 100644 --- a/vendor/golang.org/x/crypto/internal/subtle/aliasing_purego.go +++ b/vendor/golang.org/x/crypto/internal/alias/alias_purego.go @@ -5,9 +5,8 @@ //go:build purego // +build purego -// Package subtle implements functions that are often useful in cryptographic -// code but require careful thought to use correctly. -package subtle // import "golang.org/x/crypto/internal/subtle" +// Package alias implements memory aliasing tests. +package alias // This is the Google App Engine standard variant based on reflect // because the unsafe package and cgo are disallowed. diff --git a/vendor/golang.org/x/crypto/pkcs12/crypto.go b/vendor/golang.org/x/crypto/pkcs12/crypto.go index 484ca51b71..96f4a1a56e 100644 --- a/vendor/golang.org/x/crypto/pkcs12/crypto.go +++ b/vendor/golang.org/x/crypto/pkcs12/crypto.go @@ -117,7 +117,7 @@ func pbDecrypt(info decryptable, password []byte) (decrypted []byte, err error) } ps := decrypted[len(decrypted)-psLen:] decrypted = decrypted[:len(decrypted)-psLen] - if bytes.Compare(ps, bytes.Repeat([]byte{byte(psLen)}, psLen)) != 0 { + if !bytes.Equal(ps, bytes.Repeat([]byte{byte(psLen)}, psLen)) { return nil, ErrDecryption } diff --git a/vendor/golang.org/x/crypto/ssh/certs.go b/vendor/golang.org/x/crypto/ssh/certs.go index a69e22491d..fc04d03e19 100644 --- a/vendor/golang.org/x/crypto/ssh/certs.go +++ b/vendor/golang.org/x/crypto/ssh/certs.go @@ -251,7 +251,7 @@ type algorithmOpenSSHCertSigner struct { // private key is held by signer. It returns an error if the public key in cert // doesn't match the key used by signer. func NewCertSigner(cert *Certificate, signer Signer) (Signer, error) { - if bytes.Compare(cert.Key.Marshal(), signer.PublicKey().Marshal()) != 0 { + if !bytes.Equal(cert.Key.Marshal(), signer.PublicKey().Marshal()) { return nil, errors.New("ssh: signer and cert have different public key") } @@ -460,6 +460,8 @@ func (c *Certificate) SignCert(rand io.Reader, authority Signer) error { // certKeyAlgoNames is a mapping from known certificate algorithm names to the // corresponding public key signature algorithm. +// +// This map must be kept in sync with the one in agent/client.go. var certKeyAlgoNames = map[string]string{ CertAlgoRSAv01: KeyAlgoRSA, CertAlgoRSASHA256v01: KeyAlgoRSASHA256, diff --git a/vendor/golang.org/x/crypto/ssh/cipher.go b/vendor/golang.org/x/crypto/ssh/cipher.go index 770e8a6639..87f48552ce 100644 --- a/vendor/golang.org/x/crypto/ssh/cipher.go +++ b/vendor/golang.org/x/crypto/ssh/cipher.go @@ -15,7 +15,6 @@ import ( "fmt" "hash" "io" - "io/ioutil" "golang.org/x/crypto/chacha20" "golang.org/x/crypto/internal/poly1305" @@ -97,13 +96,13 @@ func streamCipherMode(skip int, createFunc func(key, iv []byte) (cipher.Stream, // are not supported and will not be negotiated, even if explicitly requested in // ClientConfig.Crypto.Ciphers. var cipherModes = map[string]*cipherMode{ - // Ciphers from RFC4344, which introduced many CTR-based ciphers. Algorithms + // Ciphers from RFC 4344, which introduced many CTR-based ciphers. Algorithms // are defined in the order specified in the RFC. "aes128-ctr": {16, aes.BlockSize, streamCipherMode(0, newAESCTR)}, "aes192-ctr": {24, aes.BlockSize, streamCipherMode(0, newAESCTR)}, "aes256-ctr": {32, aes.BlockSize, streamCipherMode(0, newAESCTR)}, - // Ciphers from RFC4345, which introduces security-improved arcfour ciphers. + // Ciphers from RFC 4345, which introduces security-improved arcfour ciphers. // They are defined in the order specified in the RFC. "arcfour128": {16, 0, streamCipherMode(1536, newRC4)}, "arcfour256": {32, 0, streamCipherMode(1536, newRC4)}, @@ -111,7 +110,7 @@ var cipherModes = map[string]*cipherMode{ // Cipher defined in RFC 4253, which describes SSH Transport Layer Protocol. // Note that this cipher is not safe, as stated in RFC 4253: "Arcfour (and // RC4) has problems with weak keys, and should be used with caution." - // RFC4345 introduces improved versions of Arcfour. + // RFC 4345 introduces improved versions of Arcfour. "arcfour": {16, 0, streamCipherMode(0, newRC4)}, // AEAD ciphers @@ -497,7 +496,7 @@ func (c *cbcCipher) readCipherPacket(seqNum uint32, r io.Reader) ([]byte, error) // data, to make distinguishing between // failing MAC and failing length check more // difficult. - io.CopyN(ioutil.Discard, r, int64(c.oracleCamouflage)) + io.CopyN(io.Discard, r, int64(c.oracleCamouflage)) } } return p, err @@ -642,7 +641,7 @@ const chacha20Poly1305ID = "chacha20-poly1305@openssh.com" // // https://tools.ietf.org/html/draft-josefsson-ssh-chacha20-poly1305-openssh-00 // -// the methods here also implement padding, which RFC4253 Section 6 +// the methods here also implement padding, which RFC 4253 Section 6 // also requires of stream ciphers. type chacha20Poly1305Cipher struct { lengthKey [32]byte diff --git a/vendor/golang.org/x/crypto/ssh/common.go b/vendor/golang.org/x/crypto/ssh/common.go index 2a47a61ded..7a5ff2d2eb 100644 --- a/vendor/golang.org/x/crypto/ssh/common.go +++ b/vendor/golang.org/x/crypto/ssh/common.go @@ -149,7 +149,7 @@ type directionAlgorithms struct { // rekeyBytes returns a rekeying intervals in bytes. func (a *directionAlgorithms) rekeyBytes() int64 { - // According to RFC4344 block ciphers should rekey after + // According to RFC 4344 block ciphers should rekey after // 2^(BLOCKSIZE/4) blocks. For all AES flavors BLOCKSIZE is // 128. switch a.Cipher { @@ -158,7 +158,7 @@ func (a *directionAlgorithms) rekeyBytes() int64 { } - // For others, stick with RFC4253 recommendation to rekey after 1 Gb of data. + // For others, stick with RFC 4253 recommendation to rekey after 1 Gb of data. return 1 << 30 } diff --git a/vendor/golang.org/x/crypto/ssh/connection.go b/vendor/golang.org/x/crypto/ssh/connection.go index fd6b0681b5..35661a52be 100644 --- a/vendor/golang.org/x/crypto/ssh/connection.go +++ b/vendor/golang.org/x/crypto/ssh/connection.go @@ -52,7 +52,7 @@ type Conn interface { // SendRequest sends a global request, and returns the // reply. If wantReply is true, it returns the response status - // and payload. See also RFC4254, section 4. + // and payload. See also RFC 4254, section 4. SendRequest(name string, wantReply bool, payload []byte) (bool, []byte, error) // OpenChannel tries to open an channel. If the request is diff --git a/vendor/golang.org/x/crypto/ssh/keys.go b/vendor/golang.org/x/crypto/ssh/keys.go index 1c7de1a6dd..7296980413 100644 --- a/vendor/golang.org/x/crypto/ssh/keys.go +++ b/vendor/golang.org/x/crypto/ssh/keys.go @@ -184,7 +184,7 @@ func ParseKnownHosts(in []byte) (marker string, hosts []string, pubKey PublicKey return "", nil, nil, "", nil, io.EOF } -// ParseAuthorizedKeys parses a public key from an authorized_keys +// ParseAuthorizedKey parses a public key from an authorized_keys // file used in OpenSSH according to the sshd(8) manual page. func ParseAuthorizedKey(in []byte) (out PublicKey, comment string, options []string, rest []byte, err error) { for len(in) > 0 { diff --git a/vendor/golang.org/x/crypto/ssh/server.go b/vendor/golang.org/x/crypto/ssh/server.go index 70045bdfd8..2260b20afc 100644 --- a/vendor/golang.org/x/crypto/ssh/server.go +++ b/vendor/golang.org/x/crypto/ssh/server.go @@ -68,8 +68,16 @@ type ServerConfig struct { // NoClientAuth is true if clients are allowed to connect without // authenticating. + // To determine NoClientAuth at runtime, set NoClientAuth to true + // and the optional NoClientAuthCallback to a non-nil value. NoClientAuth bool + // NoClientAuthCallback, if non-nil, is called when a user + // attempts to authenticate with auth method "none". + // NoClientAuth must also be set to true for this be used, or + // this func is unused. + NoClientAuthCallback func(ConnMetadata) (*Permissions, error) + // MaxAuthTries specifies the maximum number of authentication attempts // permitted per connection. If set to a negative number, the number of // attempts are unlimited. If set to zero, the number of attempts are limited @@ -455,7 +463,11 @@ userAuthLoop: switch userAuthReq.Method { case "none": if config.NoClientAuth { - authErr = nil + if config.NoClientAuthCallback != nil { + perms, authErr = config.NoClientAuthCallback(s) + } else { + authErr = nil + } } // allow initial attempt of 'none' without penalty diff --git a/vendor/golang.org/x/crypto/ssh/session.go b/vendor/golang.org/x/crypto/ssh/session.go index eca31a22d5..acef62259f 100644 --- a/vendor/golang.org/x/crypto/ssh/session.go +++ b/vendor/golang.org/x/crypto/ssh/session.go @@ -13,7 +13,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "sync" ) @@ -124,7 +123,7 @@ type Session struct { // output and error. // // If either is nil, Run connects the corresponding file - // descriptor to an instance of ioutil.Discard. There is a + // descriptor to an instance of io.Discard. There is a // fixed amount of buffering that is shared for the two streams. // If either blocks it may eventually cause the remote // command to block. @@ -506,7 +505,7 @@ func (s *Session) stdout() { return } if s.Stdout == nil { - s.Stdout = ioutil.Discard + s.Stdout = io.Discard } s.copyFuncs = append(s.copyFuncs, func() error { _, err := io.Copy(s.Stdout, s.ch) @@ -519,7 +518,7 @@ func (s *Session) stderr() { return } if s.Stderr == nil { - s.Stderr = ioutil.Discard + s.Stderr = io.Discard } s.copyFuncs = append(s.copyFuncs, func() error { _, err := io.Copy(s.Stderr, s.ch.Stderr()) diff --git a/vendor/golang.org/x/mod/internal/lazyregexp/lazyre.go b/vendor/golang.org/x/mod/internal/lazyregexp/lazyre.go new file mode 100644 index 0000000000..2681af35af --- /dev/null +++ b/vendor/golang.org/x/mod/internal/lazyregexp/lazyre.go @@ -0,0 +1,78 @@ +// 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. + +// Package lazyregexp is a thin wrapper over regexp, allowing the use of global +// regexp variables without forcing them to be compiled at init. +package lazyregexp + +import ( + "os" + "regexp" + "strings" + "sync" +) + +// Regexp is a wrapper around regexp.Regexp, where the underlying regexp will be +// compiled the first time it is needed. +type Regexp struct { + str string + once sync.Once + rx *regexp.Regexp +} + +func (r *Regexp) re() *regexp.Regexp { + r.once.Do(r.build) + return r.rx +} + +func (r *Regexp) build() { + r.rx = regexp.MustCompile(r.str) + r.str = "" +} + +func (r *Regexp) FindSubmatch(s []byte) [][]byte { + return r.re().FindSubmatch(s) +} + +func (r *Regexp) FindStringSubmatch(s string) []string { + return r.re().FindStringSubmatch(s) +} + +func (r *Regexp) FindStringSubmatchIndex(s string) []int { + return r.re().FindStringSubmatchIndex(s) +} + +func (r *Regexp) ReplaceAllString(src, repl string) string { + return r.re().ReplaceAllString(src, repl) +} + +func (r *Regexp) FindString(s string) string { + return r.re().FindString(s) +} + +func (r *Regexp) FindAllString(s string, n int) []string { + return r.re().FindAllString(s, n) +} + +func (r *Regexp) MatchString(s string) bool { + return r.re().MatchString(s) +} + +func (r *Regexp) SubexpNames() []string { + return r.re().SubexpNames() +} + +var inTest = len(os.Args) > 0 && strings.HasSuffix(strings.TrimSuffix(os.Args[0], ".exe"), ".test") + +// New creates a new lazy regexp, delaying the compiling work until it is first +// needed. If the code is being run as part of tests, the regexp compiling will +// happen immediately. +func New(str string) *Regexp { + lr := &Regexp{str: str} + if inTest { + // In tests, always compile the regexps early. + lr.re() + } + return lr +} diff --git a/vendor/golang.org/x/mod/module/module.go b/vendor/golang.org/x/mod/module/module.go index 0e03014837..c26d1d29ec 100644 --- a/vendor/golang.org/x/mod/module/module.go +++ b/vendor/golang.org/x/mod/module/module.go @@ -15,7 +15,7 @@ // but additional checking functions, most notably Check, verify that // a particular path, version pair is valid. // -// Escaped Paths +// # Escaped Paths // // Module paths appear as substrings of file system paths // (in the download cache) and of web server URLs in the proxy protocol. @@ -55,7 +55,7 @@ // Import paths have never allowed exclamation marks, so there is no // need to define how to escape a literal !. // -// Unicode Restrictions +// # Unicode Restrictions // // Today, paths are disallowed from using Unicode. // @@ -102,9 +102,9 @@ import ( "strings" "unicode" "unicode/utf8" + "errors" "golang.org/x/mod/semver" - errors "golang.org/x/xerrors" ) // A Version (for clients, a module.Version) is defined by a module path and version pair. @@ -192,6 +192,21 @@ func (e *InvalidVersionError) Error() string { func (e *InvalidVersionError) Unwrap() error { return e.Err } +// An InvalidPathError indicates a module, import, or file path doesn't +// satisfy all naming constraints. See CheckPath, CheckImportPath, +// and CheckFilePath for specific restrictions. +type InvalidPathError struct { + Kind string // "module", "import", or "file" + Path string + Err error +} + +func (e *InvalidPathError) Error() string { + return fmt.Sprintf("malformed %s path %q: %v", e.Kind, e.Path, e.Err) +} + +func (e *InvalidPathError) Unwrap() error { return e.Err } + // Check checks that a given module path, version pair is valid. // In addition to the path being a valid module path // and the version being a valid semantic version, @@ -271,12 +286,7 @@ func fileNameOK(r rune) bool { if '0' <= r && r <= '9' || 'A' <= r && r <= 'Z' || 'a' <= r && r <= 'z' { return true } - for i := 0; i < len(allowed); i++ { - if rune(allowed[i]) == r { - return true - } - } - return false + return strings.ContainsRune(allowed, r) } // It may be OK to add more ASCII punctuation here, but only carefully. // For example Windows disallows < > \, and macOS disallows :, so we must not allow those. @@ -296,30 +306,36 @@ func fileNameOK(r rune) bool { // this second requirement is replaced by a requirement that the path // follow the gopkg.in server's conventions. // Third, no path element may begin with a dot. -func CheckPath(path string) error { +func CheckPath(path string) (err error) { + defer func() { + if err != nil { + err = &InvalidPathError{Kind: "module", Path: path, Err: err} + } + }() + if err := checkPath(path, modulePath); err != nil { - return fmt.Errorf("malformed module path %q: %v", path, err) + return err } i := strings.Index(path, "/") if i < 0 { i = len(path) } if i == 0 { - return fmt.Errorf("malformed module path %q: leading slash", path) + return fmt.Errorf("leading slash") } if !strings.Contains(path[:i], ".") { - return fmt.Errorf("malformed module path %q: missing dot in first path element", path) + return fmt.Errorf("missing dot in first path element") } if path[0] == '-' { - return fmt.Errorf("malformed module path %q: leading dash in first path element", path) + return fmt.Errorf("leading dash in first path element") } for _, r := range path[:i] { if !firstPathOK(r) { - return fmt.Errorf("malformed module path %q: invalid char %q in first path element", path, r) + return fmt.Errorf("invalid char %q in first path element", r) } } if _, _, ok := SplitPathVersion(path); !ok { - return fmt.Errorf("malformed module path %q: invalid version", path) + return fmt.Errorf("invalid version") } return nil } @@ -343,7 +359,7 @@ func CheckPath(path string) error { // subtleties of Unicode. func CheckImportPath(path string) error { if err := checkPath(path, importPath); err != nil { - return fmt.Errorf("malformed import path %q: %v", path, err) + return &InvalidPathError{Kind: "import", Path: path, Err: err} } return nil } @@ -358,12 +374,13 @@ const ( filePath ) -// checkPath checks that a general path is valid. -// It returns an error describing why but not mentioning path. -// Because these checks apply to both module paths and import paths, -// the caller is expected to add the "malformed ___ path %q: " prefix. -// fileName indicates whether the final element of the path is a file name -// (as opposed to a directory name). +// checkPath checks that a general path is valid. kind indicates what +// specific constraints should be applied. +// +// checkPath returns an error describing why the path is not valid. +// Because these checks apply to module, import, and file paths, +// and because other checks may be applied, the caller is expected to wrap +// this error with InvalidPathError. func checkPath(path string, kind pathKind) error { if !utf8.ValidString(path) { return fmt.Errorf("invalid UTF-8") @@ -371,7 +388,7 @@ func checkPath(path string, kind pathKind) error { if path == "" { return fmt.Errorf("empty string") } - if path[0] == '-' { + if path[0] == '-' && kind != filePath { return fmt.Errorf("leading dash") } if strings.Contains(path, "//") { @@ -477,7 +494,7 @@ func checkElem(elem string, kind pathKind) error { // subtleties of Unicode. func CheckFilePath(path string) error { if err := checkPath(path, filePath); err != nil { - return fmt.Errorf("malformed file path %q: %v", path, err) + return &InvalidPathError{Kind: "file", Path: path, Err: err} } return nil } @@ -781,6 +798,7 @@ func unescapeString(escaped string) (string, bool) { // GOPRIVATE environment variable, as described by 'go help module-private'. // // It ignores any empty or malformed patterns in the list. +// Trailing slashes on patterns are ignored. func MatchPrefixPatterns(globs, target string) bool { for globs != "" { // Extract next non-empty glob in comma-separated list. @@ -790,6 +808,7 @@ func MatchPrefixPatterns(globs, target string) bool { } else { glob, globs = globs, "" } + glob = strings.TrimSuffix(glob, "/") if glob == "" { continue } diff --git a/vendor/golang.org/x/mod/module/pseudo.go b/vendor/golang.org/x/mod/module/pseudo.go new file mode 100644 index 0000000000..f04ad37886 --- /dev/null +++ b/vendor/golang.org/x/mod/module/pseudo.go @@ -0,0 +1,250 @@ +// 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. + +// Pseudo-versions +// +// Code authors are expected to tag the revisions they want users to use, +// including prereleases. However, not all authors tag versions at all, +// and not all commits a user might want to try will have tags. +// A pseudo-version is a version with a special form that allows us to +// address an untagged commit and order that version with respect to +// other versions we might encounter. +// +// A pseudo-version takes one of the general forms: +// +// (1) vX.0.0-yyyymmddhhmmss-abcdef123456 +// (2) vX.Y.(Z+1)-0.yyyymmddhhmmss-abcdef123456 +// (3) vX.Y.(Z+1)-0.yyyymmddhhmmss-abcdef123456+incompatible +// (4) vX.Y.Z-pre.0.yyyymmddhhmmss-abcdef123456 +// (5) vX.Y.Z-pre.0.yyyymmddhhmmss-abcdef123456+incompatible +// +// If there is no recently tagged version with the right major version vX, +// then form (1) is used, creating a space of pseudo-versions at the bottom +// of the vX version range, less than any tagged version, including the unlikely v0.0.0. +// +// If the most recent tagged version before the target commit is vX.Y.Z or vX.Y.Z+incompatible, +// then the pseudo-version uses form (2) or (3), making it a prerelease for the next +// possible semantic version after vX.Y.Z. The leading 0 segment in the prerelease string +// ensures that the pseudo-version compares less than possible future explicit prereleases +// like vX.Y.(Z+1)-rc1 or vX.Y.(Z+1)-1. +// +// If the most recent tagged version before the target commit is vX.Y.Z-pre or vX.Y.Z-pre+incompatible, +// then the pseudo-version uses form (4) or (5), making it a slightly later prerelease. + +package module + +import ( + "errors" + "fmt" + "strings" + "time" + + "golang.org/x/mod/internal/lazyregexp" + "golang.org/x/mod/semver" +) + +var pseudoVersionRE = lazyregexp.New(`^v[0-9]+\.(0\.0-|\d+\.\d+-([^+]*\.)?0\.)\d{14}-[A-Za-z0-9]+(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$`) + +const PseudoVersionTimestampFormat = "20060102150405" + +// PseudoVersion returns a pseudo-version for the given major version ("v1") +// preexisting older tagged version ("" or "v1.2.3" or "v1.2.3-pre"), revision time, +// and revision identifier (usually a 12-byte commit hash prefix). +func PseudoVersion(major, older string, t time.Time, rev string) string { + if major == "" { + major = "v0" + } + segment := fmt.Sprintf("%s-%s", t.UTC().Format(PseudoVersionTimestampFormat), rev) + build := semver.Build(older) + older = semver.Canonical(older) + if older == "" { + return major + ".0.0-" + segment // form (1) + } + if semver.Prerelease(older) != "" { + return older + ".0." + segment + build // form (4), (5) + } + + // Form (2), (3). + // Extract patch from vMAJOR.MINOR.PATCH + i := strings.LastIndex(older, ".") + 1 + v, patch := older[:i], older[i:] + + // Reassemble. + return v + incDecimal(patch) + "-0." + segment + build +} + +// ZeroPseudoVersion returns a pseudo-version with a zero timestamp and +// revision, which may be used as a placeholder. +func ZeroPseudoVersion(major string) string { + return PseudoVersion(major, "", time.Time{}, "000000000000") +} + +// incDecimal returns the decimal string incremented by 1. +func incDecimal(decimal string) string { + // Scan right to left turning 9s to 0s until you find a digit to increment. + digits := []byte(decimal) + i := len(digits) - 1 + for ; i >= 0 && digits[i] == '9'; i-- { + digits[i] = '0' + } + if i >= 0 { + digits[i]++ + } else { + // digits is all zeros + digits[0] = '1' + digits = append(digits, '0') + } + return string(digits) +} + +// decDecimal returns the decimal string decremented by 1, or the empty string +// if the decimal is all zeroes. +func decDecimal(decimal string) string { + // Scan right to left turning 0s to 9s until you find a digit to decrement. + digits := []byte(decimal) + i := len(digits) - 1 + for ; i >= 0 && digits[i] == '0'; i-- { + digits[i] = '9' + } + if i < 0 { + // decimal is all zeros + return "" + } + if i == 0 && digits[i] == '1' && len(digits) > 1 { + digits = digits[1:] + } else { + digits[i]-- + } + return string(digits) +} + +// IsPseudoVersion reports whether v is a pseudo-version. +func IsPseudoVersion(v string) bool { + return strings.Count(v, "-") >= 2 && semver.IsValid(v) && pseudoVersionRE.MatchString(v) +} + +// IsZeroPseudoVersion returns whether v is a pseudo-version with a zero base, +// timestamp, and revision, as returned by ZeroPseudoVersion. +func IsZeroPseudoVersion(v string) bool { + return v == ZeroPseudoVersion(semver.Major(v)) +} + +// PseudoVersionTime returns the time stamp of the pseudo-version v. +// It returns an error if v is not a pseudo-version or if the time stamp +// embedded in the pseudo-version is not a valid time. +func PseudoVersionTime(v string) (time.Time, error) { + _, timestamp, _, _, err := parsePseudoVersion(v) + if err != nil { + return time.Time{}, err + } + t, err := time.Parse("20060102150405", timestamp) + if err != nil { + return time.Time{}, &InvalidVersionError{ + Version: v, + Pseudo: true, + Err: fmt.Errorf("malformed time %q", timestamp), + } + } + return t, nil +} + +// PseudoVersionRev returns the revision identifier of the pseudo-version v. +// It returns an error if v is not a pseudo-version. +func PseudoVersionRev(v string) (rev string, err error) { + _, _, rev, _, err = parsePseudoVersion(v) + return +} + +// PseudoVersionBase returns the canonical parent version, if any, upon which +// the pseudo-version v is based. +// +// If v has no parent version (that is, if it is "vX.0.0-[…]"), +// PseudoVersionBase returns the empty string and a nil error. +func PseudoVersionBase(v string) (string, error) { + base, _, _, build, err := parsePseudoVersion(v) + if err != nil { + return "", err + } + + switch pre := semver.Prerelease(base); pre { + case "": + // vX.0.0-yyyymmddhhmmss-abcdef123456 → "" + if build != "" { + // Pseudo-versions of the form vX.0.0-yyyymmddhhmmss-abcdef123456+incompatible + // are nonsensical: the "vX.0.0-" prefix implies that there is no parent tag, + // but the "+incompatible" suffix implies that the major version of + // the parent tag is not compatible with the module's import path. + // + // There are a few such entries in the index generated by proxy.golang.org, + // but we believe those entries were generated by the proxy itself. + return "", &InvalidVersionError{ + Version: v, + Pseudo: true, + Err: fmt.Errorf("lacks base version, but has build metadata %q", build), + } + } + return "", nil + + case "-0": + // vX.Y.(Z+1)-0.yyyymmddhhmmss-abcdef123456 → vX.Y.Z + // vX.Y.(Z+1)-0.yyyymmddhhmmss-abcdef123456+incompatible → vX.Y.Z+incompatible + base = strings.TrimSuffix(base, pre) + i := strings.LastIndexByte(base, '.') + if i < 0 { + panic("base from parsePseudoVersion missing patch number: " + base) + } + patch := decDecimal(base[i+1:]) + if patch == "" { + // vX.0.0-0 is invalid, but has been observed in the wild in the index + // generated by requests to proxy.golang.org. + // + // NOTE(bcmills): I cannot find a historical bug that accounts for + // pseudo-versions of this form, nor have I seen such versions in any + // actual go.mod files. If we find actual examples of this form and a + // reasonable theory of how they came into existence, it seems fine to + // treat them as equivalent to vX.0.0 (especially since the invalid + // pseudo-versions have lower precedence than the real ones). For now, we + // reject them. + return "", &InvalidVersionError{ + Version: v, + Pseudo: true, + Err: fmt.Errorf("version before %s would have negative patch number", base), + } + } + return base[:i+1] + patch + build, nil + + default: + // vX.Y.Z-pre.0.yyyymmddhhmmss-abcdef123456 → vX.Y.Z-pre + // vX.Y.Z-pre.0.yyyymmddhhmmss-abcdef123456+incompatible → vX.Y.Z-pre+incompatible + if !strings.HasSuffix(base, ".0") { + panic(`base from parsePseudoVersion missing ".0" before date: ` + base) + } + return strings.TrimSuffix(base, ".0") + build, nil + } +} + +var errPseudoSyntax = errors.New("syntax error") + +func parsePseudoVersion(v string) (base, timestamp, rev, build string, err error) { + if !IsPseudoVersion(v) { + return "", "", "", "", &InvalidVersionError{ + Version: v, + Pseudo: true, + Err: errPseudoSyntax, + } + } + build = semver.Build(v) + v = strings.TrimSuffix(v, build) + j := strings.LastIndex(v, "-") + v, rev = v[:j], v[j+1:] + i := strings.LastIndex(v, "-") + if j := strings.LastIndex(v, "."); j > i { + base = v[:j] // "vX.Y.Z-pre.0" or "vX.Y.(Z+1)-0" + timestamp = v[j+1:] + } else { + base = v[:i] // "vX.0.0" + timestamp = v[i+1:] + } + return base, timestamp, rev, build, nil +} diff --git a/vendor/golang.org/x/mod/semver/semver.go b/vendor/golang.org/x/mod/semver/semver.go index 4338f35177..a30a22bf20 100644 --- a/vendor/golang.org/x/mod/semver/semver.go +++ b/vendor/golang.org/x/mod/semver/semver.go @@ -22,6 +22,8 @@ // as shorthands for vMAJOR.0.0 and vMAJOR.MINOR.0. package semver +import "sort" + // parsed returns the parsed form of a semantic version string. type parsed struct { major string @@ -30,7 +32,6 @@ type parsed struct { short string prerelease string build string - err string } // IsValid reports whether v is a valid semantic version string. @@ -150,14 +151,30 @@ func Max(v, w string) string { return w } +// ByVersion implements sort.Interface for sorting semantic version strings. +type ByVersion []string + +func (vs ByVersion) Len() int { return len(vs) } +func (vs ByVersion) Swap(i, j int) { vs[i], vs[j] = vs[j], vs[i] } +func (vs ByVersion) Less(i, j int) bool { + cmp := Compare(vs[i], vs[j]) + if cmp != 0 { + return cmp < 0 + } + return vs[i] < vs[j] +} + +// Sort sorts a list of semantic version strings using ByVersion. +func Sort(list []string) { + sort.Sort(ByVersion(list)) +} + func parse(v string) (p parsed, ok bool) { if v == "" || v[0] != 'v' { - p.err = "missing v prefix" return } p.major, v, ok = parseInt(v[1:]) if !ok { - p.err = "bad major version" return } if v == "" { @@ -167,13 +184,11 @@ func parse(v string) (p parsed, ok bool) { return } if v[0] != '.' { - p.err = "bad minor prefix" ok = false return } p.minor, v, ok = parseInt(v[1:]) if !ok { - p.err = "bad minor version" return } if v == "" { @@ -182,31 +197,26 @@ func parse(v string) (p parsed, ok bool) { return } if v[0] != '.' { - p.err = "bad patch prefix" ok = false return } p.patch, v, ok = parseInt(v[1:]) if !ok { - p.err = "bad patch version" return } if len(v) > 0 && v[0] == '-' { p.prerelease, v, ok = parsePrerelease(v) if !ok { - p.err = "bad prerelease" return } } if len(v) > 0 && v[0] == '+' { p.build, v, ok = parseBuild(v) if !ok { - p.err = "bad build" return } } if v != "" { - p.err = "junk on end" ok = false return } diff --git a/vendor/golang.org/x/net/AUTHORS b/vendor/golang.org/x/net/AUTHORS deleted file mode 100644 index 15167cd746..0000000000 --- a/vendor/golang.org/x/net/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code refers to The Go Authors for copyright purposes. -# The master list of authors is in the main Go distribution, -# visible at http://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/net/CONTRIBUTORS b/vendor/golang.org/x/net/CONTRIBUTORS deleted file mode 100644 index 1c4577e968..0000000000 --- a/vendor/golang.org/x/net/CONTRIBUTORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code was written by the Go contributors. -# The master list of contributors is in the main Go distribution, -# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/net/bpf/vm_instructions.go b/vendor/golang.org/x/net/bpf/vm_instructions.go index cf8947c332..0aa307c061 100644 --- a/vendor/golang.org/x/net/bpf/vm_instructions.go +++ b/vendor/golang.org/x/net/bpf/vm_instructions.go @@ -94,7 +94,7 @@ func jumpIfCommon(cond JumpTest, skipTrue, skipFalse uint8, regA uint32, value u func loadAbsolute(ins LoadAbsolute, in []byte) (uint32, bool) { offset := int(ins.Off) - size := int(ins.Size) + size := ins.Size return loadCommon(in, offset, size) } @@ -121,7 +121,7 @@ func loadExtension(ins LoadExtension, in []byte) uint32 { func loadIndirect(ins LoadIndirect, in []byte, regX uint32) (uint32, bool) { offset := int(ins.Off) + int(regX) - size := int(ins.Size) + size := ins.Size return loadCommon(in, offset, size) } diff --git a/vendor/golang.org/x/net/context/go17.go b/vendor/golang.org/x/net/context/go17.go index 0a54bdbcc6..2cb9c408f2 100644 --- a/vendor/golang.org/x/net/context/go17.go +++ b/vendor/golang.org/x/net/context/go17.go @@ -32,7 +32,7 @@ var DeadlineExceeded = context.DeadlineExceeded // call cancel as soon as the operations running in this Context complete. func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { ctx, f := context.WithCancel(parent) - return ctx, CancelFunc(f) + return ctx, f } // WithDeadline returns a copy of the parent context with the deadline adjusted @@ -46,7 +46,7 @@ func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { // call cancel as soon as the operations running in this Context complete. func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { ctx, f := context.WithDeadline(parent, deadline) - return ctx, CancelFunc(f) + return ctx, f } // WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). diff --git a/vendor/golang.org/x/net/html/parse.go b/vendor/golang.org/x/net/html/parse.go index 038941d708..291c91908d 100644 --- a/vendor/golang.org/x/net/html/parse.go +++ b/vendor/golang.org/x/net/html/parse.go @@ -734,7 +734,7 @@ func inHeadIM(p *parser) bool { return false } -// 12.2.6.4.5. +// Section 12.2.6.4.5. func inHeadNoscriptIM(p *parser) bool { switch p.tok.Type { case DoctypeToken: diff --git a/vendor/golang.org/x/net/html/render.go b/vendor/golang.org/x/net/html/render.go index b46d81ca6d..497e132042 100644 --- a/vendor/golang.org/x/net/html/render.go +++ b/vendor/golang.org/x/net/html/render.go @@ -85,7 +85,7 @@ func render1(w writer, n *Node) error { if _, err := w.WriteString(""); err != nil { @@ -96,7 +96,7 @@ func render1(w writer, n *Node) error { if _, err := w.WriteString("" case CommentToken: - return "" + return "" case DoctypeToken: - return "" + return "" } return "Invalid(" + strconv.Itoa(int(t.Type)) + ")" } diff --git a/vendor/golang.org/x/net/http/httpproxy/proxy.go b/vendor/golang.org/x/net/http/httpproxy/proxy.go index 16994ac134..c3bd9a1eeb 100644 --- a/vendor/golang.org/x/net/http/httpproxy/proxy.go +++ b/vendor/golang.org/x/net/http/httpproxy/proxy.go @@ -81,8 +81,7 @@ type config struct { // FromEnvironment returns a Config instance populated from the // environment variables HTTP_PROXY, HTTPS_PROXY and NO_PROXY (or the -// lowercase versions thereof). HTTPS_PROXY takes precedence over -// HTTP_PROXY for https requests. +// lowercase versions thereof). // // The environment values may be either a complete URL or a // "host[:port]", in which case the "http" scheme is assumed. An error diff --git a/vendor/golang.org/x/net/http2/client_conn_pool.go b/vendor/golang.org/x/net/http2/client_conn_pool.go index c936843eaf..780968d6c1 100644 --- a/vendor/golang.org/x/net/http2/client_conn_pool.go +++ b/vendor/golang.org/x/net/http2/client_conn_pool.go @@ -139,7 +139,6 @@ func (p *clientConnPool) getStartDialLocked(ctx context.Context, addr string) *d func (c *dialCall) dial(ctx context.Context, addr string) { const singleUse = false // shared conn c.res, c.err = c.p.t.dialClientConn(ctx, addr, singleUse) - close(c.done) c.p.mu.Lock() delete(c.p.dialing, addr) @@ -147,6 +146,8 @@ func (c *dialCall) dial(ctx context.Context, addr string) { c.p.addConnLocked(addr, c.res) } c.p.mu.Unlock() + + close(c.done) } // addConnIfNeeded makes a NewClientConn out of c if a connection for key doesn't diff --git a/vendor/golang.org/x/net/http2/frame.go b/vendor/golang.org/x/net/http2/frame.go index 0178647ee0..184ac45feb 100644 --- a/vendor/golang.org/x/net/http2/frame.go +++ b/vendor/golang.org/x/net/http2/frame.go @@ -23,7 +23,7 @@ const frameHeaderLen = 9 var padZeros = make([]byte, 255) // zeros for padding // A FrameType is a registered frame type as defined in -// http://http2.github.io/http2-spec/#rfc.section.11.2 +// https://httpwg.org/specs/rfc7540.html#rfc.section.11.2 type FrameType uint8 const ( @@ -146,7 +146,7 @@ func typeFrameParser(t FrameType) frameParser { // A FrameHeader is the 9 byte header of all HTTP/2 frames. // -// See http://http2.github.io/http2-spec/#FrameHeader +// See https://httpwg.org/specs/rfc7540.html#FrameHeader type FrameHeader struct { valid bool // caller can access []byte fields in the Frame @@ -575,7 +575,7 @@ func (fr *Framer) checkFrameOrder(f Frame) error { // A DataFrame conveys arbitrary, variable-length sequences of octets // associated with a stream. -// See http://http2.github.io/http2-spec/#rfc.section.6.1 +// See https://httpwg.org/specs/rfc7540.html#rfc.section.6.1 type DataFrame struct { FrameHeader data []byte @@ -698,7 +698,7 @@ func (f *Framer) WriteDataPadded(streamID uint32, endStream bool, data, pad []by // endpoints communicate, such as preferences and constraints on peer // behavior. // -// See http://http2.github.io/http2-spec/#SETTINGS +// See https://httpwg.org/specs/rfc7540.html#SETTINGS type SettingsFrame struct { FrameHeader p []byte @@ -837,7 +837,7 @@ func (f *Framer) WriteSettingsAck() error { // A PingFrame is a mechanism for measuring a minimal round trip time // from the sender, as well as determining whether an idle connection // is still functional. -// See http://http2.github.io/http2-spec/#rfc.section.6.7 +// See https://httpwg.org/specs/rfc7540.html#rfc.section.6.7 type PingFrame struct { FrameHeader Data [8]byte @@ -870,7 +870,7 @@ func (f *Framer) WritePing(ack bool, data [8]byte) error { } // A GoAwayFrame informs the remote peer to stop creating streams on this connection. -// See http://http2.github.io/http2-spec/#rfc.section.6.8 +// See https://httpwg.org/specs/rfc7540.html#rfc.section.6.8 type GoAwayFrame struct { FrameHeader LastStreamID uint32 @@ -934,7 +934,7 @@ func parseUnknownFrame(_ *frameCache, fh FrameHeader, countError func(string), p } // A WindowUpdateFrame is used to implement flow control. -// See http://http2.github.io/http2-spec/#rfc.section.6.9 +// See https://httpwg.org/specs/rfc7540.html#rfc.section.6.9 type WindowUpdateFrame struct { FrameHeader Increment uint32 // never read with high bit set @@ -1123,7 +1123,7 @@ func (f *Framer) WriteHeaders(p HeadersFrameParam) error { } // A PriorityFrame specifies the sender-advised priority of a stream. -// See http://http2.github.io/http2-spec/#rfc.section.6.3 +// See https://httpwg.org/specs/rfc7540.html#rfc.section.6.3 type PriorityFrame struct { FrameHeader PriorityParam @@ -1193,7 +1193,7 @@ func (f *Framer) WritePriority(streamID uint32, p PriorityParam) error { } // A RSTStreamFrame allows for abnormal termination of a stream. -// See http://http2.github.io/http2-spec/#rfc.section.6.4 +// See https://httpwg.org/specs/rfc7540.html#rfc.section.6.4 type RSTStreamFrame struct { FrameHeader ErrCode ErrCode @@ -1225,7 +1225,7 @@ func (f *Framer) WriteRSTStream(streamID uint32, code ErrCode) error { } // A ContinuationFrame is used to continue a sequence of header block fragments. -// See http://http2.github.io/http2-spec/#rfc.section.6.10 +// See https://httpwg.org/specs/rfc7540.html#rfc.section.6.10 type ContinuationFrame struct { FrameHeader headerFragBuf []byte @@ -1266,7 +1266,7 @@ func (f *Framer) WriteContinuation(streamID uint32, endHeaders bool, headerBlock } // A PushPromiseFrame is used to initiate a server stream. -// See http://http2.github.io/http2-spec/#rfc.section.6.6 +// See https://httpwg.org/specs/rfc7540.html#rfc.section.6.6 type PushPromiseFrame struct { FrameHeader PromiseID uint32 diff --git a/vendor/golang.org/x/net/http2/hpack/encode.go b/vendor/golang.org/x/net/http2/hpack/encode.go index 97f17831fc..6886dc163c 100644 --- a/vendor/golang.org/x/net/http2/hpack/encode.go +++ b/vendor/golang.org/x/net/http2/hpack/encode.go @@ -191,7 +191,7 @@ func appendTableSize(dst []byte, v uint32) []byte { // bit prefix, to dst and returns the extended buffer. // // See -// http://http2.github.io/http2-spec/compression.html#integer.representation +// https://httpwg.org/specs/rfc7541.html#integer.representation func appendVarInt(dst []byte, n byte, i uint64) []byte { k := uint64((1 << n) - 1) if i < k { diff --git a/vendor/golang.org/x/net/http2/hpack/hpack.go b/vendor/golang.org/x/net/http2/hpack/hpack.go index 85f18a2b0a..ebdfbee964 100644 --- a/vendor/golang.org/x/net/http2/hpack/hpack.go +++ b/vendor/golang.org/x/net/http2/hpack/hpack.go @@ -59,7 +59,7 @@ func (hf HeaderField) String() string { // Size returns the size of an entry per RFC 7541 section 4.1. func (hf HeaderField) Size() uint32 { - // http://http2.github.io/http2-spec/compression.html#rfc.section.4.1 + // https://httpwg.org/specs/rfc7541.html#rfc.section.4.1 // "The size of the dynamic table is the sum of the size of // its entries. The size of an entry is the sum of its name's // length in octets (as defined in Section 5.2), its value's @@ -158,7 +158,7 @@ func (d *Decoder) SetAllowedMaxDynamicTableSize(v uint32) { } type dynamicTable struct { - // http://http2.github.io/http2-spec/compression.html#rfc.section.2.3.2 + // https://httpwg.org/specs/rfc7541.html#rfc.section.2.3.2 table headerFieldTable size uint32 // in bytes maxSize uint32 // current maxSize @@ -307,27 +307,27 @@ func (d *Decoder) parseHeaderFieldRepr() error { case b&128 != 0: // Indexed representation. // High bit set? - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.1 + // https://httpwg.org/specs/rfc7541.html#rfc.section.6.1 return d.parseFieldIndexed() case b&192 == 64: // 6.2.1 Literal Header Field with Incremental Indexing // 0b10xxxxxx: top two bits are 10 - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.2.1 + // https://httpwg.org/specs/rfc7541.html#rfc.section.6.2.1 return d.parseFieldLiteral(6, indexedTrue) case b&240 == 0: // 6.2.2 Literal Header Field without Indexing // 0b0000xxxx: top four bits are 0000 - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.2.2 + // https://httpwg.org/specs/rfc7541.html#rfc.section.6.2.2 return d.parseFieldLiteral(4, indexedFalse) case b&240 == 16: // 6.2.3 Literal Header Field never Indexed // 0b0001xxxx: top four bits are 0001 - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.2.3 + // https://httpwg.org/specs/rfc7541.html#rfc.section.6.2.3 return d.parseFieldLiteral(4, indexedNever) case b&224 == 32: // 6.3 Dynamic Table Size Update // Top three bits are '001'. - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.3 + // https://httpwg.org/specs/rfc7541.html#rfc.section.6.3 return d.parseDynamicTableSizeUpdate() } @@ -420,7 +420,7 @@ var errVarintOverflow = DecodingError{errors.New("varint integer overflow")} // readVarInt reads an unsigned variable length integer off the // beginning of p. n is the parameter as described in -// http://http2.github.io/http2-spec/compression.html#rfc.section.5.1. +// https://httpwg.org/specs/rfc7541.html#rfc.section.5.1. // // n must always be between 1 and 8. // diff --git a/vendor/golang.org/x/net/http2/hpack/huffman.go b/vendor/golang.org/x/net/http2/hpack/huffman.go index fe0b84ccd4..20d083a716 100644 --- a/vendor/golang.org/x/net/http2/hpack/huffman.go +++ b/vendor/golang.org/x/net/http2/hpack/huffman.go @@ -169,25 +169,50 @@ func buildRootHuffmanNode() { // AppendHuffmanString appends s, as encoded in Huffman codes, to dst // and returns the extended buffer. func AppendHuffmanString(dst []byte, s string) []byte { - rembits := uint8(8) - + // This relies on the maximum huffman code length being 30 (See tables.go huffmanCodeLen array) + // So if a uint64 buffer has less than 32 valid bits can always accommodate another huffmanCode. + var ( + x uint64 // buffer + n uint // number valid of bits present in x + ) for i := 0; i < len(s); i++ { - if rembits == 8 { - dst = append(dst, 0) + c := s[i] + n += uint(huffmanCodeLen[c]) + x <<= huffmanCodeLen[c] % 64 + x |= uint64(huffmanCodes[c]) + if n >= 32 { + n %= 32 // Normally would be -= 32 but %= 32 informs compiler 0 <= n <= 31 for upcoming shift + y := uint32(x >> n) // Compiler doesn't combine memory writes if y isn't uint32 + dst = append(dst, byte(y>>24), byte(y>>16), byte(y>>8), byte(y)) } - dst, rembits = appendByteToHuffmanCode(dst, rembits, s[i]) } - - if rembits < 8 { - // special EOS symbol - code := uint32(0x3fffffff) - nbits := uint8(30) - - t := uint8(code >> (nbits - rembits)) - dst[len(dst)-1] |= t + // Add padding bits if necessary + if over := n % 8; over > 0 { + const ( + eosCode = 0x3fffffff + eosNBits = 30 + eosPadByte = eosCode >> (eosNBits - 8) + ) + pad := 8 - over + x = (x << pad) | (eosPadByte >> over) + n += pad // 8 now divides into n exactly } - - return dst + // n in (0, 8, 16, 24, 32) + switch n / 8 { + case 0: + return dst + case 1: + return append(dst, byte(x)) + case 2: + y := uint16(x) + return append(dst, byte(y>>8), byte(y)) + case 3: + y := uint16(x >> 8) + return append(dst, byte(y>>8), byte(y), byte(x)) + } + // case 4: + y := uint32(x) + return append(dst, byte(y>>24), byte(y>>16), byte(y>>8), byte(y)) } // HuffmanEncodeLength returns the number of bytes required to encode @@ -199,35 +224,3 @@ func HuffmanEncodeLength(s string) uint64 { } return (n + 7) / 8 } - -// appendByteToHuffmanCode appends Huffman code for c to dst and -// returns the extended buffer and the remaining bits in the last -// element. The appending is not byte aligned and the remaining bits -// in the last element of dst is given in rembits. -func appendByteToHuffmanCode(dst []byte, rembits uint8, c byte) ([]byte, uint8) { - code := huffmanCodes[c] - nbits := huffmanCodeLen[c] - - for { - if rembits > nbits { - t := uint8(code << (rembits - nbits)) - dst[len(dst)-1] |= t - rembits -= nbits - break - } - - t := uint8(code >> (nbits - rembits)) - dst[len(dst)-1] |= t - - nbits -= rembits - rembits = 8 - - if nbits == 0 { - break - } - - dst = append(dst, 0) - } - - return dst, rembits -} diff --git a/vendor/golang.org/x/net/http2/http2.go b/vendor/golang.org/x/net/http2/http2.go index 479ba4b2b1..6f2df28187 100644 --- a/vendor/golang.org/x/net/http2/http2.go +++ b/vendor/golang.org/x/net/http2/http2.go @@ -55,14 +55,14 @@ const ( ClientPreface = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" // SETTINGS_MAX_FRAME_SIZE default - // http://http2.github.io/http2-spec/#rfc.section.6.5.2 + // https://httpwg.org/specs/rfc7540.html#rfc.section.6.5.2 initialMaxFrameSize = 16384 // NextProtoTLS is the NPN/ALPN protocol negotiated during // HTTP/2's TLS setup. NextProtoTLS = "h2" - // http://http2.github.io/http2-spec/#SettingValues + // https://httpwg.org/specs/rfc7540.html#SettingValues initialHeaderTableSize = 4096 initialWindowSize = 65535 // 6.9.2 Initial Flow Control Window Size @@ -111,7 +111,7 @@ func (st streamState) String() string { // Setting is a setting parameter: which setting it is, and its value. type Setting struct { // ID is which setting is being set. - // See http://http2.github.io/http2-spec/#SettingValues + // See https://httpwg.org/specs/rfc7540.html#SettingFormat ID SettingID // Val is the value. @@ -143,7 +143,7 @@ func (s Setting) Valid() error { } // A SettingID is an HTTP/2 setting as defined in -// http://http2.github.io/http2-spec/#iana-settings +// https://httpwg.org/specs/rfc7540.html#iana-settings type SettingID uint16 const ( diff --git a/vendor/golang.org/x/net/http2/server.go b/vendor/golang.org/x/net/http2/server.go index b1c32eb135..43cc2a34ad 100644 --- a/vendor/golang.org/x/net/http2/server.go +++ b/vendor/golang.org/x/net/http2/server.go @@ -143,7 +143,7 @@ type Server struct { } func (s *Server) initialConnRecvWindowSize() int32 { - if s.MaxUploadBufferPerConnection > initialWindowSize { + if s.MaxUploadBufferPerConnection >= initialWindowSize { return s.MaxUploadBufferPerConnection } return 1 << 20 @@ -315,6 +315,20 @@ type ServeConnOpts struct { // requests. If nil, BaseConfig.Handler is used. If BaseConfig // or BaseConfig.Handler is nil, http.DefaultServeMux is used. Handler http.Handler + + // UpgradeRequest is an initial request received on a connection + // undergoing an h2c upgrade. The request body must have been + // completely read from the connection before calling ServeConn, + // and the 101 Switching Protocols response written. + UpgradeRequest *http.Request + + // Settings is the decoded contents of the HTTP2-Settings header + // in an h2c upgrade request. + Settings []byte + + // SawClientPreface is set if the HTTP/2 connection preface + // has already been read from the connection. + SawClientPreface bool } func (o *ServeConnOpts) context() context.Context { @@ -383,6 +397,7 @@ func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) { headerTableSize: initialHeaderTableSize, serveG: newGoroutineLock(), pushEnabled: true, + sawClientPreface: opts.SawClientPreface, } s.state.registerConn(sc) @@ -400,7 +415,7 @@ func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) { if s.NewWriteScheduler != nil { sc.writeSched = s.NewWriteScheduler() } else { - sc.writeSched = NewRandomWriteScheduler() + sc.writeSched = NewPriorityWriteScheduler(nil) } // These start at the RFC-specified defaults. If there is a higher @@ -465,9 +480,27 @@ func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) { } } + if opts.Settings != nil { + fr := &SettingsFrame{ + FrameHeader: FrameHeader{valid: true}, + p: opts.Settings, + } + if err := fr.ForeachSetting(sc.processSetting); err != nil { + sc.rejectConn(ErrCodeProtocol, "invalid settings") + return + } + opts.Settings = nil + } + if hook := testHookGetServerConn; hook != nil { hook(sc) } + + if opts.UpgradeRequest != nil { + sc.upgradeRequest(opts.UpgradeRequest) + opts.UpgradeRequest = nil + } + sc.serve() } @@ -512,6 +545,7 @@ type serverConn struct { // Everything following is owned by the serve loop; use serveG.check(): serveG goroutineLock // used to verify funcs are on serve() pushEnabled bool + sawClientPreface bool // preface has already been read, used in h2c upgrade sawFirstSettings bool // got the initial SETTINGS frame after the preface needToSendSettingsAck bool unackedSettings int // how many SETTINGS have we sent without ACKs? @@ -835,9 +869,7 @@ func (sc *serverConn) serve() { // Each connection starts with initialWindowSize inflow tokens. // If a higher value is configured, we add more tokens. - if diff := sc.srv.initialConnRecvWindowSize() - initialWindowSize; diff > 0 { - sc.sendWindowUpdate(nil, int(diff)) - } + sc.sendWindowUpdate(nil) if err := sc.readPreface(); err != nil { sc.condlogf(err, "http2: server: error reading preface from client %v: %v", sc.conn.RemoteAddr(), err) @@ -974,6 +1006,9 @@ var errPrefaceTimeout = errors.New("timeout waiting for client preface") // returns errPrefaceTimeout on timeout, or an error if the greeting // is invalid. func (sc *serverConn) readPreface() error { + if sc.sawClientPreface { + return nil + } errc := make(chan error, 1) go func() { // Read the client preface @@ -1334,6 +1369,9 @@ func (sc *serverConn) startGracefulShutdownInternal() { func (sc *serverConn) goAway(code ErrCode) { sc.serveG.check() if sc.inGoAway { + if sc.goAwayCode == ErrCodeNo { + sc.goAwayCode = code + } return } sc.inGoAway = true @@ -1548,7 +1586,7 @@ func (sc *serverConn) closeStream(st *stream, err error) { if p := st.body; p != nil { // Return any buffered unread bytes worth of conn-level flow control. // See golang.org/issue/16481 - sc.sendWindowUpdate(nil, p.Len()) + sc.sendWindowUpdate(nil) p.CloseWithError(err) } @@ -1696,7 +1734,7 @@ func (sc *serverConn) processData(f *DataFrame) error { // sendWindowUpdate, which also schedules sending the // frames. sc.inflow.take(int32(f.Length)) - sc.sendWindowUpdate(nil, int(f.Length)) // conn-level + sc.sendWindowUpdate(nil) // conn-level if st != nil && st.resetQueued { // Already have a stream error in flight. Don't send another. @@ -1710,6 +1748,12 @@ func (sc *serverConn) processData(f *DataFrame) error { // Sender sending more than they'd declared? if st.declBodyBytes != -1 && st.bodyBytes+int64(len(data)) > st.declBodyBytes { + if sc.inflow.available() < int32(f.Length) { + return sc.countError("data_flow", streamError(id, ErrCodeFlowControl)) + } + sc.inflow.take(int32(f.Length)) + sc.sendWindowUpdate(nil) // conn-level + st.body.CloseWithError(fmt.Errorf("sender tried to send more than declared Content-Length of %d bytes", st.declBodyBytes)) // RFC 7540, sec 8.1.2.6: A request or response is also malformed if the // value of a content-length header field does not equal the sum of the @@ -1726,7 +1770,7 @@ func (sc *serverConn) processData(f *DataFrame) error { if len(data) > 0 { wrote, err := st.body.Write(data) if err != nil { - sc.sendWindowUpdate(nil, int(f.Length)-wrote) + sc.sendWindowUpdate32(nil, int32(f.Length)-int32(wrote)) return sc.countError("body_write_err", streamError(id, ErrCodeStreamClosed)) } if wrote != len(data) { @@ -1915,6 +1959,26 @@ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error { return nil } +func (sc *serverConn) upgradeRequest(req *http.Request) { + sc.serveG.check() + id := uint32(1) + sc.maxClientStreamID = id + st := sc.newStream(id, 0, stateHalfClosedRemote) + st.reqTrailer = req.Trailer + if st.reqTrailer != nil { + st.trailer = make(http.Header) + } + rw := sc.newResponseWriter(st, req) + + // Disable any read deadline set by the net/http package + // prior to the upgrade. + if sc.hs.ReadTimeout != 0 { + sc.conn.SetReadDeadline(time.Time{}) + } + + go sc.runHandler(rw, req, sc.handler.ServeHTTP) +} + func (st *stream) processTrailerHeaders(f *MetaHeadersFrame) error { sc := st.sc sc.serveG.check() @@ -2033,12 +2097,6 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res return nil, nil, sc.countError("bad_path_method", streamError(f.StreamID, ErrCodeProtocol)) } - bodyOpen := !f.StreamEnded() - if rp.method == "HEAD" && bodyOpen { - // HEAD requests can't have bodies - return nil, nil, sc.countError("head_body", streamError(f.StreamID, ErrCodeProtocol)) - } - rp.header = make(http.Header) for _, hf := range f.RegularFields() { rp.header.Add(sc.canonicalHeader(hf.Name), hf.Value) @@ -2051,6 +2109,7 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res if err != nil { return nil, nil, err } + bodyOpen := !f.StreamEnded() if bodyOpen { if vv, ok := rp.header["Content-Length"]; ok { if cl, err := strconv.ParseUint(vv[0], 10, 63); err == nil { @@ -2145,6 +2204,11 @@ func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp requestParam) (*r } req = req.WithContext(st.ctx) + rw := sc.newResponseWriter(st, req) + return rw, req, nil +} + +func (sc *serverConn) newResponseWriter(st *stream, req *http.Request) *responseWriter { rws := responseWriterStatePool.Get().(*responseWriterState) bwSave := rws.bw *rws = responseWriterState{} // zero all the fields @@ -2153,10 +2217,7 @@ func (sc *serverConn) newWriterAndRequestNoBody(st *stream, rp requestParam) (*r rws.bw.Reset(chunkWriter{rws}) rws.stream = st rws.req = req - rws.body = body - - rw := &responseWriter{rws: rws} - return rw, req, nil + return &responseWriter{rws: rws} } // Run on its own goroutine. @@ -2164,6 +2225,9 @@ func (sc *serverConn) runHandler(rw *responseWriter, req *http.Request, handler didPanic := true defer func() { rw.rws.stream.cancelCtx() + if req.MultipartForm != nil { + req.MultipartForm.RemoveAll() + } if didPanic { e := recover() sc.writeFrameFromHandler(FrameWriteRequest{ @@ -2258,17 +2322,32 @@ func (sc *serverConn) noteBodyReadFromHandler(st *stream, n int, err error) { func (sc *serverConn) noteBodyRead(st *stream, n int) { sc.serveG.check() - sc.sendWindowUpdate(nil, n) // conn-level + sc.sendWindowUpdate(nil) // conn-level if st.state != stateHalfClosedRemote && st.state != stateClosed { // Don't send this WINDOW_UPDATE if the stream is closed // remotely. - sc.sendWindowUpdate(st, n) + sc.sendWindowUpdate(st) } } // st may be nil for conn-level -func (sc *serverConn) sendWindowUpdate(st *stream, n int) { +func (sc *serverConn) sendWindowUpdate(st *stream) { sc.serveG.check() + + var n int32 + if st == nil { + if avail, windowSize := sc.inflow.available(), sc.srv.initialConnRecvWindowSize(); avail > windowSize/2 { + return + } else { + n = windowSize - avail + } + } else { + if avail, windowSize := st.inflow.available(), sc.srv.initialStreamRecvWindowSize(); avail > windowSize/2 { + return + } else { + n = windowSize - avail + } + } // "The legal range for the increment to the flow control // window is 1 to 2^31-1 (2,147,483,647) octets." // A Go Read call on 64-bit machines could in theory read @@ -2371,7 +2450,6 @@ type responseWriterState struct { // immutable within a request: stream *stream req *http.Request - body *requestBody // to close at end of request, if DATA frames didn't conn *serverConn // TODO: adjust buffer writing sizes based on server config, frame size updates from peer, etc @@ -2435,6 +2513,10 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { rws.writeHeader(200) } + if rws.handlerDone { + rws.promoteUndeclaredTrailers() + } + isHeadResp := rws.req.Method == "HEAD" if !rws.sentHeader { rws.sentHeader = true @@ -2506,10 +2588,6 @@ func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { return 0, nil } - if rws.handlerDone { - rws.promoteUndeclaredTrailers() - } - // only send trailers if they have actually been defined by the // server handler. hasNonemptyTrailers := rws.hasNonemptyTrailers() @@ -2645,8 +2723,7 @@ func checkWriteHeaderCode(code int) { // Issue 22880: require valid WriteHeader status codes. // For now we only enforce that it's three digits. // In the future we might block things over 599 (600 and above aren't defined - // at http://httpwg.org/specs/rfc7231.html#status.codes) - // and we might block under 200 (once we have more mature 1xx support). + // at http://httpwg.org/specs/rfc7231.html#status.codes). // But for now any three digits. // // We used to send "HTTP/1.1 000 0" on the wire in responses but there's @@ -2667,13 +2744,41 @@ func (w *responseWriter) WriteHeader(code int) { } func (rws *responseWriterState) writeHeader(code int) { - if !rws.wroteHeader { - checkWriteHeaderCode(code) - rws.wroteHeader = true - rws.status = code - if len(rws.handlerHeader) > 0 { - rws.snapHeader = cloneHeader(rws.handlerHeader) + if rws.wroteHeader { + return + } + + checkWriteHeaderCode(code) + + // Handle informational headers + if code >= 100 && code <= 199 { + // Per RFC 8297 we must not clear the current header map + h := rws.handlerHeader + + _, cl := h["Content-Length"] + _, te := h["Transfer-Encoding"] + if cl || te { + h = h.Clone() + h.Del("Content-Length") + h.Del("Transfer-Encoding") } + + if rws.conn.writeHeaders(rws.stream, &writeResHeaders{ + streamID: rws.stream.id, + httpResCode: code, + h: h, + endStream: rws.handlerDone && !rws.hasTrailers(), + }) != nil { + rws.dirty = true + } + + return + } + + rws.wroteHeader = true + rws.status = code + if len(rws.handlerHeader) > 0 { + rws.snapHeader = cloneHeader(rws.handlerHeader) } } diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index 9180ba3d5c..c5d005bba7 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go @@ -16,7 +16,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "math" mathrand "math/rand" @@ -68,13 +67,23 @@ const ( // A Transport internally caches connections to servers. It is safe // for concurrent use by multiple goroutines. type Transport struct { - // DialTLS specifies an optional dial function for creating - // TLS connections for requests. + // DialTLSContext specifies an optional dial function with context for + // creating TLS connections for requests. // - // If DialTLS is nil, tls.Dial is used. + // If DialTLSContext and DialTLS is nil, tls.Dial is used. // // If the returned net.Conn has a ConnectionState method like tls.Conn, // it will be used to set http.Response.TLS. + DialTLSContext func(ctx context.Context, network, addr string, cfg *tls.Config) (net.Conn, error) + + // DialTLS specifies an optional dial function for creating + // TLS connections for requests. + // + // If DialTLSContext and DialTLS is nil, tls.Dial is used. + // + // Deprecated: Use DialTLSContext instead, which allows the transport + // to cancel dials as soon as they are no longer needed. + // If both are set, DialTLSContext takes priority. DialTLS func(network, addr string, cfg *tls.Config) (net.Conn, error) // TLSClientConfig specifies the TLS configuration to use with @@ -249,7 +258,8 @@ func (t *Transport) initConnPool() { // HTTP/2 server. type ClientConn struct { t *Transport - tconn net.Conn // usually *tls.Conn, except specialized impls + tconn net.Conn // usually *tls.Conn, except specialized impls + tconnClosed bool tlsState *tls.ConnectionState // nil only for specialized impls reused uint32 // whether conn is being reused; atomic singleUse bool // whether being used for a single http.Request @@ -335,8 +345,8 @@ type clientStream struct { readErr error // sticky read error; owned by transportResponseBody.Read reqBody io.ReadCloser - reqBodyContentLength int64 // -1 means unknown - reqBodyClosed bool // body has been closed; guarded by cc.mu + reqBodyContentLength int64 // -1 means unknown + reqBodyClosed chan struct{} // guarded by cc.mu; non-nil on Close, closed when done // owned by writeRequest: sentEndStream bool // sent an END_STREAM flag to the peer @@ -376,9 +386,8 @@ func (cs *clientStream) abortStreamLocked(err error) { cs.abortErr = err close(cs.abort) }) - if cs.reqBody != nil && !cs.reqBodyClosed { - cs.reqBody.Close() - cs.reqBodyClosed = true + if cs.reqBody != nil { + cs.closeReqBodyLocked() } // TODO(dneil): Clean up tests where cs.cc.cond is nil. if cs.cc.cond != nil { @@ -391,13 +400,24 @@ func (cs *clientStream) abortRequestBodyWrite() { cc := cs.cc cc.mu.Lock() defer cc.mu.Unlock() - if cs.reqBody != nil && !cs.reqBodyClosed { - cs.reqBody.Close() - cs.reqBodyClosed = true + if cs.reqBody != nil && cs.reqBodyClosed == nil { + cs.closeReqBodyLocked() cc.cond.Broadcast() } } +func (cs *clientStream) closeReqBodyLocked() { + if cs.reqBodyClosed != nil { + return + } + cs.reqBodyClosed = make(chan struct{}) + reqBodyClosed := cs.reqBodyClosed + go func() { + cs.reqBody.Close() + close(reqBodyClosed) + }() +} + type stickyErrWriter struct { conn net.Conn timeout time.Duration @@ -593,7 +613,7 @@ func (t *Transport) dialClientConn(ctx context.Context, addr string, singleUse b if err != nil { return nil, err } - tconn, err := t.dialTLS(ctx)("tcp", addr, t.newTLSConfig(host)) + tconn, err := t.dialTLS(ctx, "tcp", addr, t.newTLSConfig(host)) if err != nil { return nil, err } @@ -614,24 +634,25 @@ func (t *Transport) newTLSConfig(host string) *tls.Config { return cfg } -func (t *Transport) dialTLS(ctx context.Context) func(string, string, *tls.Config) (net.Conn, error) { - if t.DialTLS != nil { - return t.DialTLS +func (t *Transport) dialTLS(ctx context.Context, network, addr string, tlsCfg *tls.Config) (net.Conn, error) { + if t.DialTLSContext != nil { + return t.DialTLSContext(ctx, network, addr, tlsCfg) + } else if t.DialTLS != nil { + return t.DialTLS(network, addr, tlsCfg) } - return func(network, addr string, cfg *tls.Config) (net.Conn, error) { - tlsCn, err := t.dialTLSWithContext(ctx, network, addr, cfg) - if err != nil { - return nil, err - } - state := tlsCn.ConnectionState() - if p := state.NegotiatedProtocol; p != NextProtoTLS { - return nil, fmt.Errorf("http2: unexpected ALPN protocol %q; want %q", p, NextProtoTLS) - } - if !state.NegotiatedProtocolIsMutual { - return nil, errors.New("http2: could not negotiate protocol mutually") - } - return tlsCn, nil + + tlsCn, err := t.dialTLSWithContext(ctx, network, addr, tlsCfg) + if err != nil { + return nil, err } + state := tlsCn.ConnectionState() + if p := state.NegotiatedProtocol; p != NextProtoTLS { + return nil, fmt.Errorf("http2: unexpected ALPN protocol %q; want %q", p, NextProtoTLS) + } + if !state.NegotiatedProtocolIsMutual { + return nil, errors.New("http2: could not negotiate protocol mutually") + } + return tlsCn, nil } // disableKeepAlives reports whether connections should be closed as @@ -911,10 +932,10 @@ func (cc *ClientConn) onIdleTimeout() { cc.closeIfIdle() } -func (cc *ClientConn) closeConn() error { +func (cc *ClientConn) closeConn() { t := time.AfterFunc(250*time.Millisecond, cc.forceCloseConn) defer t.Stop() - return cc.tconn.Close() + cc.tconn.Close() } // A tls.Conn.Close can hang for a long time if the peer is unresponsive. @@ -980,7 +1001,8 @@ func (cc *ClientConn) Shutdown(ctx context.Context) error { shutdownEnterWaitStateHook() select { case <-done: - return cc.closeConn() + cc.closeConn() + return nil case <-ctx.Done(): cc.mu.Lock() // Free the goroutine above @@ -1017,7 +1039,7 @@ func (cc *ClientConn) sendGoAway() error { // closes the client connection immediately. In-flight requests are interrupted. // err is sent to streams. -func (cc *ClientConn) closeForError(err error) error { +func (cc *ClientConn) closeForError(err error) { cc.mu.Lock() cc.closed = true for _, cs := range cc.streams { @@ -1025,7 +1047,7 @@ func (cc *ClientConn) closeForError(err error) error { } cc.cond.Broadcast() cc.mu.Unlock() - return cc.closeConn() + cc.closeConn() } // Close closes the client connection immediately. @@ -1033,16 +1055,17 @@ func (cc *ClientConn) closeForError(err error) error { // In-flight requests are interrupted. For a graceful shutdown, use Shutdown instead. func (cc *ClientConn) Close() error { err := errors.New("http2: client connection force closed via ClientConn.Close") - return cc.closeForError(err) + cc.closeForError(err) + return nil } // closes the client connection immediately. In-flight requests are interrupted. -func (cc *ClientConn) closeForLostPing() error { +func (cc *ClientConn) closeForLostPing() { err := errors.New("http2: client connection lost") if f := cc.t.CountError; f != nil { f("conn_close_lost_ping") } - return cc.closeForError(err) + cc.closeForError(err) } // errRequestCanceled is a copy of net/http's errRequestCanceled because it's not @@ -1420,11 +1443,19 @@ func (cs *clientStream) cleanupWriteRequest(err error) { // and in multiple cases: server replies <=299 and >299 // while still writing request body cc.mu.Lock() + mustCloseBody := false + if cs.reqBody != nil && cs.reqBodyClosed == nil { + mustCloseBody = true + cs.reqBodyClosed = make(chan struct{}) + } bodyClosed := cs.reqBodyClosed - cs.reqBodyClosed = true cc.mu.Unlock() - if !bodyClosed && cs.reqBody != nil { + if mustCloseBody { cs.reqBody.Close() + close(bodyClosed) + } + if bodyClosed != nil { + <-bodyClosed } if err != nil && cs.sentEndStream { @@ -1604,7 +1635,7 @@ func (cs *clientStream) writeRequestBody(req *http.Request) (err error) { } if err != nil { cc.mu.Lock() - bodyClosed := cs.reqBodyClosed + bodyClosed := cs.reqBodyClosed != nil cc.mu.Unlock() switch { case bodyClosed: @@ -1699,7 +1730,7 @@ func (cs *clientStream) awaitFlowControl(maxBytes int) (taken int32, err error) if cc.closed { return 0, errClientConnClosed } - if cs.reqBodyClosed { + if cs.reqBodyClosed != nil { return 0, errStopReqBodyWrite } select { @@ -1995,7 +2026,7 @@ func (cc *ClientConn) forgetStreamID(id uint32) { // wake up RoundTrip if there is a pending request. cc.cond.Broadcast() - closeOnIdle := cc.singleUse || cc.doNotReuse || cc.t.disableKeepAlives() + closeOnIdle := cc.singleUse || cc.doNotReuse || cc.t.disableKeepAlives() || cc.goAway != nil if closeOnIdle && cc.streamsReserved == 0 && len(cc.streams) == 0 { if VerboseLogs { cc.vlogf("http2: Transport closing idle conn %p (forSingleUse=%v, maxStream=%v)", cc, cc.singleUse, cc.nextStreamID-2) @@ -2071,6 +2102,7 @@ func (rl *clientConnReadLoop) cleanup() { err = io.ErrUnexpectedEOF } cc.closed = true + for _, cs := range cc.streams { select { case <-cs.peerClosed: @@ -2664,7 +2696,6 @@ func (rl *clientConnReadLoop) processGoAway(f *GoAwayFrame) error { if fn := cc.t.CountError; fn != nil { fn("recv_goaway_" + f.ErrCode.stringToken()) } - } cc.setGoAway(f) return nil @@ -2904,7 +2935,12 @@ func (t *Transport) logf(format string, args ...interface{}) { log.Printf(format, args...) } -var noBody io.ReadCloser = ioutil.NopCloser(bytes.NewReader(nil)) +var noBody io.ReadCloser = noBodyReader{} + +type noBodyReader struct{} + +func (noBodyReader) Close() error { return nil } +func (noBodyReader) Read([]byte) (int, error) { return 0, io.EOF } type missingBody struct{} @@ -3013,7 +3049,7 @@ func traceGotConn(req *http.Request, cc *ClientConn, reused bool) { cc.mu.Lock() ci.WasIdle = len(cc.streams) == 0 && reused if ci.WasIdle && !cc.lastActive.IsZero() { - ci.IdleTime = time.Now().Sub(cc.lastActive) + ci.IdleTime = time.Since(cc.lastActive) } cc.mu.Unlock() diff --git a/vendor/golang.org/x/net/http2/writesched_priority.go b/vendor/golang.org/x/net/http2/writesched_priority.go index 2618b2c11d..0a242c669e 100644 --- a/vendor/golang.org/x/net/http2/writesched_priority.go +++ b/vendor/golang.org/x/net/http2/writesched_priority.go @@ -383,16 +383,15 @@ func (ws *priorityWriteScheduler) AdjustStream(streamID uint32, priority Priorit func (ws *priorityWriteScheduler) Push(wr FrameWriteRequest) { var n *priorityNode - if id := wr.StreamID(); id == 0 { + if wr.isControl() { n = &ws.root } else { + id := wr.StreamID() n = ws.nodes[id] if n == nil { // id is an idle or closed stream. wr should not be a HEADERS or - // DATA frame. However, wr can be a RST_STREAM. In this case, we - // push wr onto the root, rather than creating a new priorityNode, - // since RST_STREAM is tiny and the stream's priority is unknown - // anyway. See issue #17919. + // DATA frame. In other case, we push wr onto the root, rather + // than creating a new priorityNode. if wr.DataSize() > 0 { panic("add DATA on non-open stream") } diff --git a/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go b/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go index 0bfcf7afc6..41883c530c 100644 --- a/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go +++ b/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go @@ -172,7 +172,23 @@ type mmsgTmpsPool struct { } func (p *mmsgTmpsPool) Get() *mmsgTmps { - return p.p.Get().(*mmsgTmps) + m := p.p.Get().(*mmsgTmps) + // Clear fields up to the len (not the cap) of the slice, + // assuming that the previous caller only used that many elements. + for i := range m.packer.sockaddrs { + m.packer.sockaddrs[i] = 0 + } + m.packer.sockaddrs = m.packer.sockaddrs[:0] + for i := range m.packer.vs { + m.packer.vs[i] = iovec{} + } + m.packer.vs = m.packer.vs[:0] + for i := range m.packer.hs { + m.packer.hs[i].Len = 0 + m.packer.hs[i].Hdr = msghdr{} + } + m.packer.hs = m.packer.hs[:0] + return m } func (p *mmsgTmpsPool) Put(tmps *mmsgTmps) { diff --git a/vendor/golang.org/x/net/internal/socket/msghdr_linux.go b/vendor/golang.org/x/net/internal/socket/msghdr_linux.go index c3c7cc4c83..5a38798cc0 100644 --- a/vendor/golang.org/x/net/internal/socket/msghdr_linux.go +++ b/vendor/golang.org/x/net/internal/socket/msghdr_linux.go @@ -17,9 +17,6 @@ func (h *msghdr) pack(vs []iovec, bs [][]byte, oob []byte, sa []byte) { if sa != nil { h.Name = (*byte)(unsafe.Pointer(&sa[0])) h.Namelen = uint32(len(sa)) - } else { - h.Name = nil - h.Namelen = 0 } } diff --git a/vendor/golang.org/x/net/internal/socket/rawconn_msg.go b/vendor/golang.org/x/net/internal/socket/rawconn_msg.go index ba53f564bb..f7d0b0d2b8 100644 --- a/vendor/golang.org/x/net/internal/socket/rawconn_msg.go +++ b/vendor/golang.org/x/net/internal/socket/rawconn_msg.go @@ -8,22 +8,21 @@ package socket import ( + "net" "os" ) func (c *Conn) recvMsg(m *Message, flags int) error { m.raceWrite() - var h msghdr - vs := make([]iovec, len(m.Buffers)) - var sa []byte - if c.network != "tcp" { - sa = make([]byte, sizeofSockaddrInet6) - } - h.pack(vs, m.Buffers, m.OOB, sa) - var operr error - var n int + var ( + operr error + n int + oobn int + recvflags int + from net.Addr + ) fn := func(s uintptr) bool { - n, operr = recvmsg(s, &h, flags) + n, oobn, recvflags, from, operr = recvmsg(s, m.Buffers, m.OOB, flags, c.network) return ioComplete(flags, operr) } if err := c.c.Read(fn); err != nil { @@ -32,34 +31,21 @@ func (c *Conn) recvMsg(m *Message, flags int) error { if operr != nil { return os.NewSyscallError("recvmsg", operr) } - if c.network != "tcp" { - var err error - m.Addr, err = parseInetAddr(sa[:], c.network) - if err != nil { - return err - } - } + m.Addr = from m.N = n - m.NN = h.controllen() - m.Flags = h.flags() + m.NN = oobn + m.Flags = recvflags return nil } func (c *Conn) sendMsg(m *Message, flags int) error { m.raceRead() - var h msghdr - vs := make([]iovec, len(m.Buffers)) - var sa []byte - if m.Addr != nil { - var a [sizeofSockaddrInet6]byte - n := marshalInetAddr(m.Addr, a[:]) - sa = a[:n] - } - h.pack(vs, m.Buffers, m.OOB, sa) - var operr error - var n int + var ( + operr error + n int + ) fn := func(s uintptr) bool { - n, operr = sendmsg(s, &h, flags) + n, operr = sendmsg(s, m.Buffers, m.OOB, m.Addr, flags) return ioComplete(flags, operr) } if err := c.c.Write(fn); err != nil { diff --git a/vendor/golang.org/x/net/internal/socket/sys_stub.go b/vendor/golang.org/x/net/internal/socket/sys_stub.go index 381e45e167..7cfb349c0c 100644 --- a/vendor/golang.org/x/net/internal/socket/sys_stub.go +++ b/vendor/golang.org/x/net/internal/socket/sys_stub.go @@ -36,11 +36,11 @@ func setsockopt(s uintptr, level, name int, b []byte) error { return errNotImplemented } -func recvmsg(s uintptr, h *msghdr, flags int) (int, error) { - return 0, errNotImplemented +func recvmsg(s uintptr, buffers [][]byte, oob []byte, flags int, network string) (n, oobn int, recvflags int, from net.Addr, err error) { + return 0, 0, 0, nil, errNotImplemented } -func sendmsg(s uintptr, h *msghdr, flags int) (int, error) { +func sendmsg(s uintptr, buffers [][]byte, oob []byte, to net.Addr, flags int) (int, error) { return 0, errNotImplemented } diff --git a/vendor/golang.org/x/net/internal/socket/sys_unix.go b/vendor/golang.org/x/net/internal/socket/sys_unix.go index d203e2984c..de823932b9 100644 --- a/vendor/golang.org/x/net/internal/socket/sys_unix.go +++ b/vendor/golang.org/x/net/internal/socket/sys_unix.go @@ -8,8 +8,10 @@ package socket import ( - "syscall" + "net" "unsafe" + + "golang.org/x/sys/unix" ) //go:linkname syscall_getsockopt syscall.getsockopt @@ -18,12 +20,6 @@ func syscall_getsockopt(s, level, name int, val unsafe.Pointer, vallen *uint32) //go:linkname syscall_setsockopt syscall.setsockopt func syscall_setsockopt(s, level, name int, val unsafe.Pointer, vallen uintptr) error -//go:linkname syscall_recvmsg syscall.recvmsg -func syscall_recvmsg(s int, msg *syscall.Msghdr, flags int) (int, error) - -//go:linkname syscall_sendmsg syscall.sendmsg -func syscall_sendmsg(s int, msg *syscall.Msghdr, flags int) (int, error) - func getsockopt(s uintptr, level, name int, b []byte) (int, error) { l := uint32(len(b)) err := syscall_getsockopt(int(s), level, name, unsafe.Pointer(&b[0]), &l) @@ -34,10 +30,93 @@ func setsockopt(s uintptr, level, name int, b []byte) error { return syscall_setsockopt(int(s), level, name, unsafe.Pointer(&b[0]), uintptr(len(b))) } -func recvmsg(s uintptr, h *msghdr, flags int) (int, error) { - return syscall_recvmsg(int(s), (*syscall.Msghdr)(unsafe.Pointer(h)), flags) +func recvmsg(s uintptr, buffers [][]byte, oob []byte, flags int, network string) (n, oobn int, recvflags int, from net.Addr, err error) { + var unixFrom unix.Sockaddr + n, oobn, recvflags, unixFrom, err = unix.RecvmsgBuffers(int(s), buffers, oob, flags) + if unixFrom != nil { + from = sockaddrToAddr(unixFrom, network) + } + return } -func sendmsg(s uintptr, h *msghdr, flags int) (int, error) { - return syscall_sendmsg(int(s), (*syscall.Msghdr)(unsafe.Pointer(h)), flags) +func sendmsg(s uintptr, buffers [][]byte, oob []byte, to net.Addr, flags int) (int, error) { + var unixTo unix.Sockaddr + if to != nil { + unixTo = addrToSockaddr(to) + } + return unix.SendmsgBuffers(int(s), buffers, oob, unixTo, flags) +} + +// addrToSockaddr converts a net.Addr to a unix.Sockaddr. +func addrToSockaddr(a net.Addr) unix.Sockaddr { + var ( + ip net.IP + port int + zone string + ) + switch a := a.(type) { + case *net.TCPAddr: + ip = a.IP + port = a.Port + zone = a.Zone + case *net.UDPAddr: + ip = a.IP + port = a.Port + zone = a.Zone + case *net.IPAddr: + ip = a.IP + zone = a.Zone + default: + return nil + } + + if ip4 := ip.To4(); ip4 != nil { + sa := unix.SockaddrInet4{Port: port} + copy(sa.Addr[:], ip4) + return &sa + } + + if ip6 := ip.To16(); ip6 != nil && ip.To4() == nil { + sa := unix.SockaddrInet6{Port: port} + copy(sa.Addr[:], ip6) + if zone != "" { + sa.ZoneId = uint32(zoneCache.index(zone)) + } + return &sa + } + + return nil +} + +// sockaddrToAddr converts a unix.Sockaddr to a net.Addr. +func sockaddrToAddr(sa unix.Sockaddr, network string) net.Addr { + var ( + ip net.IP + port int + zone string + ) + switch sa := sa.(type) { + case *unix.SockaddrInet4: + ip = make(net.IP, net.IPv4len) + copy(ip, sa.Addr[:]) + port = sa.Port + case *unix.SockaddrInet6: + ip = make(net.IP, net.IPv6len) + copy(ip, sa.Addr[:]) + port = sa.Port + if sa.ZoneId > 0 { + zone = zoneCache.name(int(sa.ZoneId)) + } + default: + return nil + } + + switch network { + case "tcp", "tcp4", "tcp6": + return &net.TCPAddr{IP: ip, Port: port, Zone: zone} + case "udp", "udp4", "udp6": + return &net.UDPAddr{IP: ip, Port: port, Zone: zone} + default: + return &net.IPAddr{IP: ip, Zone: zone} + } } diff --git a/vendor/golang.org/x/net/internal/socket/sys_windows.go b/vendor/golang.org/x/net/internal/socket/sys_windows.go index 2de0d68c61..b738b89ddd 100644 --- a/vendor/golang.org/x/net/internal/socket/sys_windows.go +++ b/vendor/golang.org/x/net/internal/socket/sys_windows.go @@ -5,6 +5,7 @@ package socket import ( + "net" "syscall" "unsafe" @@ -37,11 +38,11 @@ func setsockopt(s uintptr, level, name int, b []byte) error { return syscall.Setsockopt(syscall.Handle(s), int32(level), int32(name), (*byte)(unsafe.Pointer(&b[0])), int32(len(b))) } -func recvmsg(s uintptr, h *msghdr, flags int) (int, error) { - return 0, errNotImplemented +func recvmsg(s uintptr, buffers [][]byte, oob []byte, flags int, network string) (n, oobn int, recvflags int, from net.Addr, err error) { + return 0, 0, 0, nil, errNotImplemented } -func sendmsg(s uintptr, h *msghdr, flags int) (int, error) { +func sendmsg(s uintptr, buffers [][]byte, oob []byte, to net.Addr, flags int) (int, error) { return 0, errNotImplemented } diff --git a/vendor/golang.org/x/net/internal/socket/sys_zos_s390x.go b/vendor/golang.org/x/net/internal/socket/sys_zos_s390x.go index 1e38b92232..eaa896cb57 100644 --- a/vendor/golang.org/x/net/internal/socket/sys_zos_s390x.go +++ b/vendor/golang.org/x/net/internal/socket/sys_zos_s390x.go @@ -5,6 +5,7 @@ package socket import ( + "net" "syscall" "unsafe" ) @@ -27,12 +28,39 @@ func setsockopt(s uintptr, level, name int, b []byte) error { return errnoErr(errno) } -func recvmsg(s uintptr, h *msghdr, flags int) (int, error) { - n, _, errno := syscall_syscall(syscall.SYS___RECVMSG_A, s, uintptr(unsafe.Pointer(h)), uintptr(flags)) - return int(n), errnoErr(errno) +func recvmsg(s uintptr, buffers [][]byte, oob []byte, flags int, network string) (n, oobn int, recvflags int, from net.Addr, err error) { + var h msghdr + vs := make([]iovec, len(buffers)) + var sa []byte + if network != "tcp" { + sa = make([]byte, sizeofSockaddrInet6) + } + h.pack(vs, buffers, oob, sa) + sn, _, errno := syscall_syscall(syscall.SYS___RECVMSG_A, s, uintptr(unsafe.Pointer(&h)), uintptr(flags)) + n = int(sn) + oobn = h.controllen() + recvflags = h.flags() + err = errnoErr(errno) + if network != "tcp" { + var err2 error + from, err2 = parseInetAddr(sa, network) + if err2 != nil && err == nil { + err = err2 + } + } + return } -func sendmsg(s uintptr, h *msghdr, flags int) (int, error) { - n, _, errno := syscall_syscall(syscall.SYS___SENDMSG_A, s, uintptr(unsafe.Pointer(h)), uintptr(flags)) +func sendmsg(s uintptr, buffers [][]byte, oob []byte, to net.Addr, flags int) (int, error) { + var h msghdr + vs := make([]iovec, len(buffers)) + var sa []byte + if to != nil { + var a [sizeofSockaddrInet6]byte + n := marshalInetAddr(to, a[:]) + sa = a[:n] + } + h.pack(vs, buffers, oob, sa) + n, _, errno := syscall_syscall(syscall.SYS___SENDMSG_A, s, uintptr(unsafe.Pointer(&h)), uintptr(flags)) return int(n), errnoErr(errno) } diff --git a/vendor/golang.org/x/net/internal/socket/zsys_darwin_386.go b/vendor/golang.org/x/net/internal/socket/zsys_darwin_386.go deleted file mode 100644 index 5acf6db6ea..0000000000 --- a/vendor/golang.org/x/net/internal/socket/zsys_darwin_386.go +++ /dev/null @@ -1,30 +0,0 @@ -// Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs defs_darwin.go - -package socket - -type iovec struct { - Base *byte - Len uint32 -} - -type msghdr struct { - Name *byte - Namelen uint32 - Iov *iovec - Iovlen int32 - Control *byte - Controllen uint32 - Flags int32 -} - -type cmsghdr struct { - Len uint32 - Level int32 - Type int32 -} - -const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c -) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_darwin_arm.go b/vendor/golang.org/x/net/internal/socket/zsys_freebsd_riscv64.go similarity index 79% rename from vendor/golang.org/x/net/internal/socket/zsys_darwin_arm.go rename to vendor/golang.org/x/net/internal/socket/zsys_freebsd_riscv64.go index 5acf6db6ea..965c0b28b5 100644 --- a/vendor/golang.org/x/net/internal/socket/zsys_darwin_arm.go +++ b/vendor/golang.org/x/net/internal/socket/zsys_freebsd_riscv64.go @@ -1,11 +1,11 @@ // Code generated by cmd/cgo -godefs; DO NOT EDIT. -// cgo -godefs defs_darwin.go +// cgo -godefs defs_freebsd.go package socket type iovec struct { Base *byte - Len uint32 + Len uint64 } type msghdr struct { @@ -25,6 +25,6 @@ type cmsghdr struct { } const ( - sizeofIovec = 0x8 - sizeofMsghdr = 0x1c + sizeofIovec = 0x10 + sizeofMsghdr = 0x30 ) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_openbsd_ppc64.go b/vendor/golang.org/x/net/internal/socket/zsys_openbsd_ppc64.go new file mode 100644 index 0000000000..cebde7634f --- /dev/null +++ b/vendor/golang.org/x/net/internal/socket/zsys_openbsd_ppc64.go @@ -0,0 +1,30 @@ +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs defs_openbsd.go + +package socket + +type iovec struct { + Base *byte + Len uint64 +} + +type msghdr struct { + Name *byte + Namelen uint32 + Iov *iovec + Iovlen uint32 + Control *byte + Controllen uint32 + Flags int32 +} + +type cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +const ( + sizeofIovec = 0x10 + sizeofMsghdr = 0x30 +) diff --git a/vendor/golang.org/x/net/internal/socket/zsys_openbsd_riscv64.go b/vendor/golang.org/x/net/internal/socket/zsys_openbsd_riscv64.go new file mode 100644 index 0000000000..cebde7634f --- /dev/null +++ b/vendor/golang.org/x/net/internal/socket/zsys_openbsd_riscv64.go @@ -0,0 +1,30 @@ +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs defs_openbsd.go + +package socket + +type iovec struct { + Base *byte + Len uint64 +} + +type msghdr struct { + Name *byte + Namelen uint32 + Iov *iovec + Iovlen uint32 + Control *byte + Controllen uint32 + Flags int32 +} + +type cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +const ( + sizeofIovec = 0x10 + sizeofMsghdr = 0x30 +) diff --git a/vendor/golang.org/x/net/ipv4/zsys_freebsd_riscv64.go b/vendor/golang.org/x/net/ipv4/zsys_freebsd_riscv64.go new file mode 100644 index 0000000000..0feb9a7536 --- /dev/null +++ b/vendor/golang.org/x/net/ipv4/zsys_freebsd_riscv64.go @@ -0,0 +1,52 @@ +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs defs_freebsd.go + +package ipv4 + +const ( + sizeofSockaddrStorage = 0x80 + sizeofSockaddrInet = 0x10 + + sizeofIPMreq = 0x8 + sizeofIPMreqSource = 0xc + sizeofGroupReq = 0x88 + sizeofGroupSourceReq = 0x108 +) + +type sockaddrStorage struct { + Len uint8 + Family uint8 + X__ss_pad1 [6]uint8 + X__ss_align int64 + X__ss_pad2 [112]uint8 +} + +type sockaddrInet struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]uint8 +} + +type ipMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type ipMreqSource struct { + Multiaddr [4]byte /* in_addr */ + Sourceaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type groupReq struct { + Interface uint32 + Group sockaddrStorage +} + +type groupSourceReq struct { + Interface uint32 + Group sockaddrStorage + Source sockaddrStorage +} diff --git a/vendor/golang.org/x/net/ipv6/zsys_freebsd_riscv64.go b/vendor/golang.org/x/net/ipv6/zsys_freebsd_riscv64.go new file mode 100644 index 0000000000..5b39eb8dfd --- /dev/null +++ b/vendor/golang.org/x/net/ipv6/zsys_freebsd_riscv64.go @@ -0,0 +1,64 @@ +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs defs_freebsd.go + +package ipv6 + +const ( + sizeofSockaddrStorage = 0x80 + sizeofSockaddrInet6 = 0x1c + sizeofInet6Pktinfo = 0x14 + sizeofIPv6Mtuinfo = 0x20 + + sizeofIPv6Mreq = 0x14 + sizeofGroupReq = 0x88 + sizeofGroupSourceReq = 0x108 + + sizeofICMPv6Filter = 0x20 +) + +type sockaddrStorage struct { + Len uint8 + Family uint8 + X__ss_pad1 [6]uint8 + X__ss_align int64 + X__ss_pad2 [112]uint8 +} + +type sockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type ipv6Mtuinfo struct { + Addr sockaddrInet6 + Mtu uint32 +} + +type ipv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type groupReq struct { + Interface uint32 + Group sockaddrStorage +} + +type groupSourceReq struct { + Interface uint32 + Group sockaddrStorage + Source sockaddrStorage +} + +type icmpv6Filter struct { + Filt [8]uint32 +} diff --git a/vendor/golang.org/x/net/publicsuffix/list.go b/vendor/golang.org/x/net/publicsuffix/list.go index e2fddd6459..7caeeaa696 100644 --- a/vendor/golang.org/x/net/publicsuffix/list.go +++ b/vendor/golang.org/x/net/publicsuffix/list.go @@ -101,7 +101,7 @@ loop: break } - u := nodes[f] >> (nodesBitsTextOffset + nodesBitsTextLength) + u := uint32(nodeValue(f) >> (nodesBitsTextOffset + nodesBitsTextLength)) icannNode = u&(1<>= nodesBitsICANN u = children[u&(1<>= nodesBitsTextLength offset := x & (1<' | $CC -x c - -E -dM $ccflags | awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' | - egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' | + grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT' | sort ) @@ -136,7 +136,7 @@ echo '#include ' | $CC -x c - -E -dM $ccflags | sort >_error.grep echo '#include ' | $CC -x c - -E -dM $ccflags | awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' | - egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT)' | + grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT' | sort >_signal.grep echo '// mkerrors.sh' "$@" diff --git a/vendor/golang.org/x/sys/plan9/syscall.go b/vendor/golang.org/x/sys/plan9/syscall.go index a25223b8fd..67e5b0115c 100644 --- a/vendor/golang.org/x/sys/plan9/syscall.go +++ b/vendor/golang.org/x/sys/plan9/syscall.go @@ -29,8 +29,6 @@ import ( "bytes" "strings" "unsafe" - - "golang.org/x/sys/internal/unsafeheader" ) // ByteSliceFromString returns a NUL-terminated slice of bytes @@ -82,13 +80,7 @@ func BytePtrToString(p *byte) string { ptr = unsafe.Pointer(uintptr(ptr) + 1) } - var s []byte - h := (*unsafeheader.Slice)(unsafe.Pointer(&s)) - h.Data = unsafe.Pointer(p) - h.Len = n - h.Cap = n - - return string(s) + return string(unsafe.Slice(p, n)) } // Single-word zero for use when we need a valid pointer to 0 bytes. diff --git a/vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s b/vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s new file mode 100644 index 0000000000..e5b9a84899 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/asm_bsd_ppc64.s @@ -0,0 +1,31 @@ +// Copyright 2022 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. + +//go:build (darwin || freebsd || netbsd || openbsd) && gc +// +build darwin freebsd netbsd openbsd +// +build gc + +#include "textflag.h" + +// +// System call support for ppc64, BSD +// + +// Just jump to package syscall's implementation for all these functions. +// The runtime may know about them. + +TEXT ·Syscall(SB),NOSPLIT,$0-56 + JMP syscall·Syscall(SB) + +TEXT ·Syscall6(SB),NOSPLIT,$0-80 + JMP syscall·Syscall6(SB) + +TEXT ·Syscall9(SB),NOSPLIT,$0-104 + JMP syscall·Syscall9(SB) + +TEXT ·RawSyscall(SB),NOSPLIT,$0-56 + JMP syscall·RawSyscall(SB) + +TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 + JMP syscall·RawSyscall6(SB) diff --git a/vendor/golang.org/x/sys/unix/dirent.go b/vendor/golang.org/x/sys/unix/dirent.go index e74e5eaa3b..2499f977b0 100644 --- a/vendor/golang.org/x/sys/unix/dirent.go +++ b/vendor/golang.org/x/sys/unix/dirent.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris -// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris +//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos package unix diff --git a/vendor/golang.org/x/sys/unix/mkall.sh b/vendor/golang.org/x/sys/unix/mkall.sh index 3b2335d5fc..727cba2127 100644 --- a/vendor/golang.org/x/sys/unix/mkall.sh +++ b/vendor/golang.org/x/sys/unix/mkall.sh @@ -182,6 +182,24 @@ openbsd_mips64) # API consistent across platforms. mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" ;; +openbsd_ppc64) + mkasm="go run mkasm.go" + mkerrors="$mkerrors -m64" + mksyscall="go run mksyscall.go -openbsd -libc" + mksysctl="go run mksysctl_openbsd.go" + # Let the type of C char be signed for making the bare syscall + # API consistent across platforms. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; +openbsd_riscv64) + mkasm="go run mkasm.go" + mkerrors="$mkerrors -m64" + mksyscall="go run mksyscall.go -openbsd -libc" + mksysctl="go run mksysctl_openbsd.go" + # Let the type of C char be signed for making the bare syscall + # API consistent across platforms. + mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" + ;; solaris_amd64) mksyscall="go run mksyscall_solaris.go" mkerrors="$mkerrors -m64" @@ -214,11 +232,6 @@ esac if [ "$GOOSARCH" == "aix_ppc64" ]; then # aix/ppc64 script generates files instead of writing to stdin. echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in && gofmt -w zsyscall_$GOOSARCH.go && gofmt -w zsyscall_"$GOOSARCH"_gccgo.go && gofmt -w zsyscall_"$GOOSARCH"_gc.go " ; - elif [ "$GOOS" == "darwin" ]; then - # 1.12 and later, syscalls via libSystem - echo "$mksyscall -tags $GOOS,$GOARCH,go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go"; - # 1.13 and later, syscalls via libSystem (including syscallPtr) - echo "$mksyscall -tags $GOOS,$GOARCH,go1.13 syscall_darwin.1_13.go |gofmt >zsyscall_$GOOSARCH.1_13.go"; elif [ "$GOOS" == "illumos" ]; then # illumos code generation requires a --illumos switch echo "$mksyscall -illumos -tags illumos,$GOARCH syscall_illumos.go |gofmt > zsyscall_illumos_$GOARCH.go"; diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index 2ab44aa659..7456d9ddde 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -642,7 +642,7 @@ errors=$( signals=$( echo '#include ' | $CC -x c - -E -dM $ccflags | awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' | - egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' | + grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' | sort ) @@ -652,7 +652,7 @@ echo '#include ' | $CC -x c - -E -dM $ccflags | sort >_error.grep echo '#include ' | $CC -x c - -E -dM $ccflags | awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' | - egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' | + grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' | sort >_signal.grep echo '// mkerrors.sh' "$@" diff --git a/vendor/golang.org/x/sys/unix/syscall.go b/vendor/golang.org/x/sys/unix/syscall.go index 649fa87405..63e8c83831 100644 --- a/vendor/golang.org/x/sys/unix/syscall.go +++ b/vendor/golang.org/x/sys/unix/syscall.go @@ -29,8 +29,6 @@ import ( "bytes" "strings" "unsafe" - - "golang.org/x/sys/internal/unsafeheader" ) // ByteSliceFromString returns a NUL-terminated slice of bytes @@ -82,13 +80,7 @@ func BytePtrToString(p *byte) string { ptr = unsafe.Pointer(uintptr(ptr) + 1) } - var s []byte - h := (*unsafeheader.Slice)(unsafe.Pointer(&s)) - h.Data = unsafe.Pointer(p) - h.Len = n - h.Cap = n - - return string(s) + return string(unsafe.Slice(p, n)) } // Single-word zero for use when we need a valid pointer to 0 bytes. diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.1_12.go b/vendor/golang.org/x/sys/unix/syscall_darwin.1_12.go deleted file mode 100644 index b0098607c7..0000000000 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.1_12.go +++ /dev/null @@ -1,32 +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. - -//go:build darwin && go1.12 && !go1.13 -// +build darwin,go1.12,!go1.13 - -package unix - -import ( - "unsafe" -) - -const _SYS_GETDIRENTRIES64 = 344 - -func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { - // To implement this using libSystem we'd need syscall_syscallPtr for - // fdopendir. However, syscallPtr was only added in Go 1.13, so we fall - // back to raw syscalls for this func on Go 1.12. - var p unsafe.Pointer - if len(buf) > 0 { - p = unsafe.Pointer(&buf[0]) - } else { - p = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall6(_SYS_GETDIRENTRIES64, uintptr(fd), uintptr(p), uintptr(len(buf)), uintptr(unsafe.Pointer(basep)), 0, 0) - n = int(r0) - if e1 != 0 { - return n, errnoErr(e1) - } - return n, nil -} diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.1_13.go b/vendor/golang.org/x/sys/unix/syscall_darwin.1_13.go deleted file mode 100644 index 1596426b1e..0000000000 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.1_13.go +++ /dev/null @@ -1,108 +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. - -//go:build darwin && go1.13 -// +build darwin,go1.13 - -package unix - -import ( - "unsafe" - - "golang.org/x/sys/internal/unsafeheader" -) - -//sys closedir(dir uintptr) (err error) -//sys readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) - -func fdopendir(fd int) (dir uintptr, err error) { - r0, _, e1 := syscall_syscallPtr(libc_fdopendir_trampoline_addr, uintptr(fd), 0, 0) - dir = uintptr(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -var libc_fdopendir_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_fdopendir fdopendir "/usr/lib/libSystem.B.dylib" - -func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { - // Simulate Getdirentries using fdopendir/readdir_r/closedir. - // We store the number of entries to skip in the seek - // offset of fd. See issue #31368. - // It's not the full required semantics, but should handle the case - // of calling Getdirentries or ReadDirent repeatedly. - // It won't handle assigning the results of lseek to *basep, or handle - // the directory being edited underfoot. - skip, err := Seek(fd, 0, 1 /* SEEK_CUR */) - if err != nil { - return 0, err - } - - // We need to duplicate the incoming file descriptor - // because the caller expects to retain control of it, but - // fdopendir expects to take control of its argument. - // Just Dup'ing the file descriptor is not enough, as the - // result shares underlying state. Use Openat to make a really - // new file descriptor referring to the same directory. - fd2, err := Openat(fd, ".", O_RDONLY, 0) - if err != nil { - return 0, err - } - d, err := fdopendir(fd2) - if err != nil { - Close(fd2) - return 0, err - } - defer closedir(d) - - var cnt int64 - for { - var entry Dirent - var entryp *Dirent - e := readdir_r(d, &entry, &entryp) - if e != 0 { - return n, errnoErr(e) - } - if entryp == nil { - break - } - if skip > 0 { - skip-- - cnt++ - continue - } - - reclen := int(entry.Reclen) - if reclen > len(buf) { - // Not enough room. Return for now. - // The counter will let us know where we should start up again. - // Note: this strategy for suspending in the middle and - // restarting is O(n^2) in the length of the directory. Oh well. - break - } - - // Copy entry into return buffer. - var s []byte - hdr := (*unsafeheader.Slice)(unsafe.Pointer(&s)) - hdr.Data = unsafe.Pointer(&entry) - hdr.Cap = reclen - hdr.Len = reclen - copy(buf, s) - - buf = buf[reclen:] - n += reclen - cnt++ - } - // Set the seek offset of the input fd to record - // how many files we've already returned. - _, err = Seek(fd, cnt, 0 /* SEEK_SET */) - if err != nil { - return n, err - } - - return n, nil -} diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go index 4f87f16ea7..1f63382182 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -19,6 +19,96 @@ import ( "unsafe" ) +//sys closedir(dir uintptr) (err error) +//sys readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) + +func fdopendir(fd int) (dir uintptr, err error) { + r0, _, e1 := syscall_syscallPtr(libc_fdopendir_trampoline_addr, uintptr(fd), 0, 0) + dir = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fdopendir_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fdopendir fdopendir "/usr/lib/libSystem.B.dylib" + +func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { + // Simulate Getdirentries using fdopendir/readdir_r/closedir. + // We store the number of entries to skip in the seek + // offset of fd. See issue #31368. + // It's not the full required semantics, but should handle the case + // of calling Getdirentries or ReadDirent repeatedly. + // It won't handle assigning the results of lseek to *basep, or handle + // the directory being edited underfoot. + skip, err := Seek(fd, 0, 1 /* SEEK_CUR */) + if err != nil { + return 0, err + } + + // We need to duplicate the incoming file descriptor + // because the caller expects to retain control of it, but + // fdopendir expects to take control of its argument. + // Just Dup'ing the file descriptor is not enough, as the + // result shares underlying state. Use Openat to make a really + // new file descriptor referring to the same directory. + fd2, err := Openat(fd, ".", O_RDONLY, 0) + if err != nil { + return 0, err + } + d, err := fdopendir(fd2) + if err != nil { + Close(fd2) + return 0, err + } + defer closedir(d) + + var cnt int64 + for { + var entry Dirent + var entryp *Dirent + e := readdir_r(d, &entry, &entryp) + if e != 0 { + return n, errnoErr(e) + } + if entryp == nil { + break + } + if skip > 0 { + skip-- + cnt++ + continue + } + + reclen := int(entry.Reclen) + if reclen > len(buf) { + // Not enough room. Return for now. + // The counter will let us know where we should start up again. + // Note: this strategy for suspending in the middle and + // restarting is O(n^2) in the length of the directory. Oh well. + break + } + + // Copy entry into return buffer. + s := unsafe.Slice((*byte)(unsafe.Pointer(&entry)), reclen) + copy(buf, s) + + buf = buf[reclen:] + n += reclen + cnt++ + } + // Set the seek offset of the input fd to record + // how many files we've already returned. + _, err = Seek(fd, cnt, 0 /* SEEK_SET */) + if err != nil { + return n, err + } + + return n, nil +} + // SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets. type SockaddrDatalink struct { Len uint8 diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go index c3c4c698e0..b11ede89a9 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_386.go @@ -61,7 +61,7 @@ func PtraceGetFsBase(pid int, fsbase *int64) (err error) { } func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint32(countin)} + ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint32(countin)} err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) return int(ioDesc.Len), err } diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go index 82be61a2f9..9ed8eec6c2 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go @@ -61,7 +61,7 @@ func PtraceGetFsBase(pid int, fsbase *int64) (err error) { } func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)} + ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint64(countin)} err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) return int(ioDesc.Len), err } diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go index cd58f1026c..f8ac982479 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go @@ -57,7 +57,7 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint32(countin)} + ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint32(countin)} err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) return int(ioDesc.Len), err } diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go index d6f538f9e0..8e932036ec 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_arm64.go @@ -57,7 +57,7 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)} + ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint64(countin)} err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) return int(ioDesc.Len), err } diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go index 8ea6e96100..cbe1222789 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd_riscv64.go @@ -57,7 +57,7 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { - ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint64(countin)} + ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint64(countin)} err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) return int(ioDesc.Len), err } diff --git a/vendor/golang.org/x/sys/unix/syscall_illumos.go b/vendor/golang.org/x/sys/unix/syscall_illumos.go index e48244a9c9..87db5a6a8c 100644 --- a/vendor/golang.org/x/sys/unix/syscall_illumos.go +++ b/vendor/golang.org/x/sys/unix/syscall_illumos.go @@ -10,8 +10,6 @@ package unix import ( - "fmt" - "runtime" "unsafe" ) @@ -79,107 +77,3 @@ func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) { } return } - -//sys putmsg(fd int, clptr *strbuf, dataptr *strbuf, flags int) (err error) - -func Putmsg(fd int, cl []byte, data []byte, flags int) (err error) { - var clp, datap *strbuf - if len(cl) > 0 { - clp = &strbuf{ - Len: int32(len(cl)), - Buf: (*int8)(unsafe.Pointer(&cl[0])), - } - } - if len(data) > 0 { - datap = &strbuf{ - Len: int32(len(data)), - Buf: (*int8)(unsafe.Pointer(&data[0])), - } - } - return putmsg(fd, clp, datap, flags) -} - -//sys getmsg(fd int, clptr *strbuf, dataptr *strbuf, flags *int) (err error) - -func Getmsg(fd int, cl []byte, data []byte) (retCl []byte, retData []byte, flags int, err error) { - var clp, datap *strbuf - if len(cl) > 0 { - clp = &strbuf{ - Maxlen: int32(len(cl)), - Buf: (*int8)(unsafe.Pointer(&cl[0])), - } - } - if len(data) > 0 { - datap = &strbuf{ - Maxlen: int32(len(data)), - Buf: (*int8)(unsafe.Pointer(&data[0])), - } - } - - if err = getmsg(fd, clp, datap, &flags); err != nil { - return nil, nil, 0, err - } - - if len(cl) > 0 { - retCl = cl[:clp.Len] - } - if len(data) > 0 { - retData = data[:datap.Len] - } - return retCl, retData, flags, nil -} - -func IoctlSetIntRetInt(fd int, req uint, arg int) (int, error) { - return ioctlRet(fd, req, uintptr(arg)) -} - -func IoctlSetString(fd int, req uint, val string) error { - bs := make([]byte, len(val)+1) - copy(bs[:len(bs)-1], val) - err := ioctl(fd, req, uintptr(unsafe.Pointer(&bs[0]))) - runtime.KeepAlive(&bs[0]) - return err -} - -// Lifreq Helpers - -func (l *Lifreq) SetName(name string) error { - if len(name) >= len(l.Name) { - return fmt.Errorf("name cannot be more than %d characters", len(l.Name)-1) - } - for i := range name { - l.Name[i] = int8(name[i]) - } - return nil -} - -func (l *Lifreq) SetLifruInt(d int) { - *(*int)(unsafe.Pointer(&l.Lifru[0])) = d -} - -func (l *Lifreq) GetLifruInt() int { - return *(*int)(unsafe.Pointer(&l.Lifru[0])) -} - -func (l *Lifreq) SetLifruUint(d uint) { - *(*uint)(unsafe.Pointer(&l.Lifru[0])) = d -} - -func (l *Lifreq) GetLifruUint() uint { - return *(*uint)(unsafe.Pointer(&l.Lifru[0])) -} - -func IoctlLifreq(fd int, req uint, l *Lifreq) error { - return ioctl(fd, req, uintptr(unsafe.Pointer(l))) -} - -// Strioctl Helpers - -func (s *Strioctl) SetInt(i int) { - s.Len = int32(unsafe.Sizeof(i)) - s.Dp = (*int8)(unsafe.Pointer(&i)) -} - -func IoctlSetStrioctlRetInt(fd int, req uint, s *Strioctl) (int, error) { - return ioctlRet(fd, req, uintptr(unsafe.Pointer(s))) -} diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index eecb58d747..e044d5b546 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -1892,17 +1892,28 @@ func PrctlRetInt(option int, arg2 uintptr, arg3 uintptr, arg4 uintptr, arg5 uint return int(ret), nil } -// issue 1435. -// On linux Setuid and Setgid only affects the current thread, not the process. -// This does not match what most callers expect so we must return an error -// here rather than letting the caller think that the call succeeded. - func Setuid(uid int) (err error) { - return EOPNOTSUPP + return syscall.Setuid(uid) } -func Setgid(uid int) (err error) { - return EOPNOTSUPP +func Setgid(gid int) (err error) { + return syscall.Setgid(gid) +} + +func Setreuid(ruid, euid int) (err error) { + return syscall.Setreuid(ruid, euid) +} + +func Setregid(rgid, egid int) (err error) { + return syscall.Setregid(rgid, egid) +} + +func Setresuid(ruid, euid, suid int) (err error) { + return syscall.Setresuid(ruid, euid, suid) +} + +func Setresgid(rgid, egid, sgid int) (err error) { + return syscall.Setresgid(rgid, egid, sgid) } // SetfsgidRetGid sets fsgid for current thread and returns previous fsgid set. @@ -2241,7 +2252,7 @@ func (fh *FileHandle) Bytes() []byte { if n == 0 { return nil } - return (*[1 << 30]byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&fh.fileHandle.Type)) + 4))[:n:n] + return unsafe.Slice((*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(&fh.fileHandle.Type))+4)), n) } // NameToHandleAt wraps the name_to_handle_at system call; it obtains @@ -2357,6 +2368,16 @@ func Setitimer(which ItimerWhich, it Itimerval) (Itimerval, error) { return prev, nil } +//sysnb rtSigprocmask(how int, set *Sigset_t, oldset *Sigset_t, sigsetsize uintptr) (err error) = SYS_RT_SIGPROCMASK + +func PthreadSigmask(how int, set, oldset *Sigset_t) error { + if oldset != nil { + // Explicitly clear in case Sigset_t is larger than _C__NSIG. + *oldset = Sigset_t{} + } + return rtSigprocmask(how, set, oldset, _C__NSIG/8) +} + /* * Unimplemented */ @@ -2415,7 +2436,6 @@ func Setitimer(which ItimerWhich, it Itimerval) (Itimerval, error) { // RestartSyscall // RtSigaction // RtSigpending -// RtSigprocmask // RtSigqueueinfo // RtSigreturn // RtSigsuspend diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_386.go b/vendor/golang.org/x/sys/unix/syscall_linux_386.go index 518e476e6d..ff5b5899d6 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_386.go @@ -41,10 +41,6 @@ func setTimeval(sec, usec int64) Timeval { //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64 //sys setfsgid(gid int) (prev int, err error) = SYS_SETFSGID32 //sys setfsuid(uid int) (prev int, err error) = SYS_SETFSUID32 -//sysnb Setregid(rgid int, egid int) (err error) = SYS_SETREGID32 -//sysnb Setresgid(rgid int, egid int, sgid int) (err error) = SYS_SETRESGID32 -//sysnb Setresuid(ruid int, euid int, suid int) (err error) = SYS_SETRESUID32 -//sysnb Setreuid(ruid int, euid int) (err error) = SYS_SETREUID32 //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go index f5e9d6bef1..9b27035329 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_amd64.go @@ -46,11 +46,7 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setregid(rgid int, egid int) (err error) -//sysnb Setresgid(rgid int, egid int, sgid int) (err error) -//sysnb Setresuid(ruid int, euid int, suid int) (err error) //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) -//sysnb Setreuid(ruid int, euid int) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go index c1a7778f10..856ad1d635 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm.go @@ -62,10 +62,6 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) = SYS__NEWSELECT //sys setfsgid(gid int) (prev int, err error) = SYS_SETFSGID32 //sys setfsuid(uid int) (prev int, err error) = SYS_SETFSUID32 -//sysnb Setregid(rgid int, egid int) (err error) = SYS_SETREGID32 -//sysnb Setresgid(rgid int, egid int, sgid int) (err error) = SYS_SETRESGID32 -//sysnb Setresuid(ruid int, euid int, suid int) (err error) = SYS_SETRESUID32 -//sysnb Setreuid(ruid int, euid int) (err error) = SYS_SETREUID32 //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go index d83e2c6571..6422704bc5 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go @@ -39,11 +39,7 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setregid(rgid int, egid int) (err error) -//sysnb Setresgid(rgid int, egid int, sgid int) (err error) -//sysnb Setresuid(ruid int, euid int, suid int) (err error) //sysnb setrlimit(resource int, rlim *Rlimit) (err error) -//sysnb Setreuid(ruid int, euid int) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go b/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go index 0b69c3eff9..59dab510e9 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go @@ -34,10 +34,6 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setregid(rgid int, egid int) (err error) -//sysnb Setresgid(rgid int, egid int, sgid int) (err error) -//sysnb Setresuid(ruid int, euid int, suid int) (err error) -//sysnb Setreuid(ruid int, euid int) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go index 98a2660b91..bfef09a39e 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mips64x.go @@ -37,11 +37,7 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setregid(rgid int, egid int) (err error) -//sysnb Setresgid(rgid int, egid int, sgid int) (err error) -//sysnb Setresuid(ruid int, euid int, suid int) (err error) //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) -//sysnb Setreuid(ruid int, euid int) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) //sys Statfs(path string, buf *Statfs_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go b/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go index b8a18c0ad2..ab30250966 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_mipsx.go @@ -32,10 +32,6 @@ func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64 //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setregid(rgid int, egid int) (err error) -//sysnb Setresgid(rgid int, egid int, sgid int) (err error) -//sysnb Setresuid(ruid int, euid int, suid int) (err error) -//sysnb Setreuid(ruid int, euid int) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go index 4ed9e67c6d..eac1cf1acc 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc.go @@ -34,10 +34,6 @@ import ( //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) = SYS_SENDFILE64 //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setregid(rgid int, egid int) (err error) -//sysnb Setresgid(rgid int, egid int, sgid int) (err error) -//sysnb Setresuid(ruid int, euid int, suid int) (err error) -//sysnb Setreuid(ruid int, euid int) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) //sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64 diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go index db63d384c5..4df56616b8 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go @@ -34,11 +34,7 @@ package unix //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setregid(rgid int, egid int) (err error) -//sysnb Setresgid(rgid int, egid int, sgid int) (err error) -//sysnb Setresuid(ruid int, euid int, suid int) (err error) //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) -//sysnb Setreuid(ruid int, euid int) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) //sys Stat(path string, stat *Stat_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go b/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go index 925a748a39..5f4243dea2 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go @@ -38,11 +38,7 @@ func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setregid(rgid int, egid int) (err error) -//sysnb Setresgid(rgid int, egid int, sgid int) (err error) -//sysnb Setresuid(ruid int, euid int, suid int) (err error) //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) -//sysnb Setreuid(ruid int, euid int) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go index 6fcf277b0d..d0a7d40668 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_s390x.go @@ -34,11 +34,7 @@ import ( //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setregid(rgid int, egid int) (err error) -//sysnb Setresgid(rgid int, egid int, sgid int) (err error) -//sysnb Setresuid(ruid int, euid int, suid int) (err error) //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) -//sysnb Setreuid(ruid int, euid int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) //sys Stat(path string, stat *Stat_t) (err error) //sys Statfs(path string, buf *Statfs_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go index 02a45d9cc0..f5c793be26 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux_sparc64.go @@ -31,11 +31,7 @@ package unix //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) //sys setfsgid(gid int) (prev int, err error) //sys setfsuid(uid int) (prev int, err error) -//sysnb Setregid(rgid int, egid int) (err error) -//sysnb Setresgid(rgid int, egid int, sgid int) (err error) -//sysnb Setresuid(ruid int, euid int, suid int) (err error) //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) -//sysnb Setreuid(ruid int, euid int) (err error) //sys Shutdown(fd int, how int) (err error) //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) //sys Stat(path string, stat *Stat_t) (err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_libc.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_libc.go index 5930a8972b..e23c5394ef 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd_libc.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_libc.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build (openbsd && 386) || (openbsd && amd64) || (openbsd && arm) || (openbsd && arm64) -// +build openbsd,386 openbsd,amd64 openbsd,arm openbsd,arm64 +//go:build openbsd && !mips64 +// +build openbsd,!mips64 package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_ppc64.go new file mode 100644 index 0000000000..c2796139c0 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_ppc64.go @@ -0,0 +1,42 @@ +// 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. + +//go:build ppc64 && openbsd +// +build ppc64,openbsd + +package unix + +func setTimespec(sec, nsec int64) Timespec { + return Timespec{Sec: sec, Nsec: nsec} +} + +func setTimeval(sec, usec int64) Timeval { + return Timeval{Sec: sec, Usec: usec} +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint64(fd) + k.Filter = int16(mode) + k.Flags = uint16(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (msghdr *Msghdr) SetIovlen(length int) { + msghdr.Iovlen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} + +// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions +// of openbsd/ppc64 the syscall is called sysctl instead of __sysctl. +const SYS___SYSCTL = SYS_SYSCTL diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/syscall_openbsd_riscv64.go new file mode 100644 index 0000000000..23199a7ff6 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd_riscv64.go @@ -0,0 +1,42 @@ +// 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. + +//go:build riscv64 && openbsd +// +build riscv64,openbsd + +package unix + +func setTimespec(sec, nsec int64) Timespec { + return Timespec{Sec: sec, Nsec: nsec} +} + +func setTimeval(sec, usec int64) Timeval { + return Timeval{Sec: sec, Usec: usec} +} + +func SetKevent(k *Kevent_t, fd, mode, flags int) { + k.Ident = uint64(fd) + k.Filter = int16(mode) + k.Flags = uint16(flags) +} + +func (iov *Iovec) SetLen(length int) { + iov.Len = uint64(length) +} + +func (msghdr *Msghdr) SetControllen(length int) { + msghdr.Controllen = uint32(length) +} + +func (msghdr *Msghdr) SetIovlen(length int) { + msghdr.Iovlen = uint32(length) +} + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = uint32(length) +} + +// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions +// of openbsd/riscv64 the syscall is called sysctl instead of __sysctl. +const SYS___SYSCTL = SYS_SYSCTL diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris.go b/vendor/golang.org/x/sys/unix/syscall_solaris.go index 03fa546ecf..2109e569cc 100644 --- a/vendor/golang.org/x/sys/unix/syscall_solaris.go +++ b/vendor/golang.org/x/sys/unix/syscall_solaris.go @@ -750,8 +750,8 @@ type EventPort struct { // we should handle things gracefully. To do so, we need to keep an extra // reference to the cookie around until the event is processed // thus the otherwise seemingly extraneous "cookies" map - // The key of this map is a pointer to the corresponding &fCookie.cookie - cookies map[*interface{}]*fileObjCookie + // The key of this map is a pointer to the corresponding fCookie + cookies map[*fileObjCookie]struct{} } // PortEvent is an abstraction of the port_event C struct. @@ -778,7 +778,7 @@ func NewEventPort() (*EventPort, error) { port: port, fds: make(map[uintptr]*fileObjCookie), paths: make(map[string]*fileObjCookie), - cookies: make(map[*interface{}]*fileObjCookie), + cookies: make(map[*fileObjCookie]struct{}), } return e, nil } @@ -799,6 +799,7 @@ func (e *EventPort) Close() error { } e.fds = nil e.paths = nil + e.cookies = nil return nil } @@ -826,17 +827,16 @@ func (e *EventPort) AssociatePath(path string, stat os.FileInfo, events int, coo if _, found := e.paths[path]; found { return fmt.Errorf("%v is already associated with this Event Port", path) } - fobj, err := createFileObj(path, stat) + fCookie, err := createFileObjCookie(path, stat, cookie) if err != nil { return err } - fCookie := &fileObjCookie{fobj, cookie} - _, err = port_associate(e.port, PORT_SOURCE_FILE, uintptr(unsafe.Pointer(fobj)), events, (*byte)(unsafe.Pointer(&fCookie.cookie))) + _, err = port_associate(e.port, PORT_SOURCE_FILE, uintptr(unsafe.Pointer(fCookie.fobj)), events, (*byte)(unsafe.Pointer(fCookie))) if err != nil { return err } e.paths[path] = fCookie - e.cookies[&fCookie.cookie] = fCookie + e.cookies[fCookie] = struct{}{} return nil } @@ -858,7 +858,7 @@ func (e *EventPort) DissociatePath(path string) error { if err == nil { // dissociate was successful, safe to delete the cookie fCookie := e.paths[path] - delete(e.cookies, &fCookie.cookie) + delete(e.cookies, fCookie) } delete(e.paths, path) return err @@ -871,13 +871,16 @@ func (e *EventPort) AssociateFd(fd uintptr, events int, cookie interface{}) erro if _, found := e.fds[fd]; found { return fmt.Errorf("%v is already associated with this Event Port", fd) } - fCookie := &fileObjCookie{nil, cookie} - _, err := port_associate(e.port, PORT_SOURCE_FD, fd, events, (*byte)(unsafe.Pointer(&fCookie.cookie))) + fCookie, err := createFileObjCookie("", nil, cookie) + if err != nil { + return err + } + _, err = port_associate(e.port, PORT_SOURCE_FD, fd, events, (*byte)(unsafe.Pointer(fCookie))) if err != nil { return err } e.fds[fd] = fCookie - e.cookies[&fCookie.cookie] = fCookie + e.cookies[fCookie] = struct{}{} return nil } @@ -896,27 +899,31 @@ func (e *EventPort) DissociateFd(fd uintptr) error { if err == nil { // dissociate was successful, safe to delete the cookie fCookie := e.fds[fd] - delete(e.cookies, &fCookie.cookie) + delete(e.cookies, fCookie) } delete(e.fds, fd) return err } -func createFileObj(name string, stat os.FileInfo) (*fileObj, error) { - fobj := new(fileObj) - bs, err := ByteSliceFromString(name) - if err != nil { - return nil, err +func createFileObjCookie(name string, stat os.FileInfo, cookie interface{}) (*fileObjCookie, error) { + fCookie := new(fileObjCookie) + fCookie.cookie = cookie + if name != "" && stat != nil { + fCookie.fobj = new(fileObj) + bs, err := ByteSliceFromString(name) + if err != nil { + return nil, err + } + fCookie.fobj.Name = (*int8)(unsafe.Pointer(&bs[0])) + s := stat.Sys().(*syscall.Stat_t) + fCookie.fobj.Atim.Sec = s.Atim.Sec + fCookie.fobj.Atim.Nsec = s.Atim.Nsec + fCookie.fobj.Mtim.Sec = s.Mtim.Sec + fCookie.fobj.Mtim.Nsec = s.Mtim.Nsec + fCookie.fobj.Ctim.Sec = s.Ctim.Sec + fCookie.fobj.Ctim.Nsec = s.Ctim.Nsec } - fobj.Name = (*int8)(unsafe.Pointer(&bs[0])) - s := stat.Sys().(*syscall.Stat_t) - fobj.Atim.Sec = s.Atim.Sec - fobj.Atim.Nsec = s.Atim.Nsec - fobj.Mtim.Sec = s.Mtim.Sec - fobj.Mtim.Nsec = s.Mtim.Nsec - fobj.Ctim.Sec = s.Ctim.Sec - fobj.Ctim.Nsec = s.Ctim.Nsec - return fobj, nil + return fCookie, nil } // GetOne wraps port_get(3c) and returns a single PortEvent. @@ -929,44 +936,50 @@ func (e *EventPort) GetOne(t *Timespec) (*PortEvent, error) { p := new(PortEvent) e.mu.Lock() defer e.mu.Unlock() - e.peIntToExt(pe, p) + err = e.peIntToExt(pe, p) + if err != nil { + return nil, err + } return p, nil } // peIntToExt converts a cgo portEvent struct into the friendlier PortEvent // NOTE: Always call this function while holding the e.mu mutex -func (e *EventPort) peIntToExt(peInt *portEvent, peExt *PortEvent) { +func (e *EventPort) peIntToExt(peInt *portEvent, peExt *PortEvent) error { + if e.cookies == nil { + return fmt.Errorf("this EventPort is already closed") + } peExt.Events = peInt.Events peExt.Source = peInt.Source - cookie := (*interface{})(unsafe.Pointer(peInt.User)) - peExt.Cookie = *cookie + fCookie := (*fileObjCookie)(unsafe.Pointer(peInt.User)) + _, found := e.cookies[fCookie] + + if !found { + panic("unexpected event port address; may be due to kernel bug; see https://go.dev/issue/54254") + } + peExt.Cookie = fCookie.cookie + delete(e.cookies, fCookie) + switch peInt.Source { case PORT_SOURCE_FD: - delete(e.cookies, cookie) peExt.Fd = uintptr(peInt.Object) // Only remove the fds entry if it exists and this cookie matches if fobj, ok := e.fds[peExt.Fd]; ok { - if &fobj.cookie == cookie { + if fobj == fCookie { delete(e.fds, peExt.Fd) } } case PORT_SOURCE_FILE: - if fCookie, ok := e.cookies[cookie]; ok && uintptr(unsafe.Pointer(fCookie.fobj)) == uintptr(peInt.Object) { - // Use our stashed reference rather than using unsafe on what we got back - // the unsafe version would be (*fileObj)(unsafe.Pointer(uintptr(peInt.Object))) - peExt.fobj = fCookie.fobj - } else { - panic("unexpected event port address; may be due to kernel bug; see https://go.dev/issue/54254") - } - delete(e.cookies, cookie) + peExt.fobj = fCookie.fobj peExt.Path = BytePtrToString((*byte)(unsafe.Pointer(peExt.fobj.Name))) // Only remove the paths entry if it exists and this cookie matches if fobj, ok := e.paths[peExt.Path]; ok { - if &fobj.cookie == cookie { + if fobj == fCookie { delete(e.paths, peExt.Path) } } } + return nil } // Pending wraps port_getn(3c) and returns how many events are pending. @@ -990,7 +1003,7 @@ func (e *EventPort) Get(s []PortEvent, min int, timeout *Timespec) (int, error) got := uint32(min) max := uint32(len(s)) var err error - ps := make([]portEvent, max, max) + ps := make([]portEvent, max) _, err = port_getn(e.port, &ps[0], max, &got, timeout) // got will be trustworthy with ETIME, but not any other error. if err != nil && err != ETIME { @@ -998,8 +1011,122 @@ func (e *EventPort) Get(s []PortEvent, min int, timeout *Timespec) (int, error) } e.mu.Lock() defer e.mu.Unlock() + valid := 0 for i := 0; i < int(got); i++ { - e.peIntToExt(&ps[i], &s[i]) + err2 := e.peIntToExt(&ps[i], &s[i]) + if err2 != nil { + if valid == 0 && err == nil { + // If err2 is the only error and there are no valid events + // to return, return it to the caller. + err = err2 + } + break + } + valid = i + 1 } - return int(got), err + return valid, err +} + +//sys putmsg(fd int, clptr *strbuf, dataptr *strbuf, flags int) (err error) + +func Putmsg(fd int, cl []byte, data []byte, flags int) (err error) { + var clp, datap *strbuf + if len(cl) > 0 { + clp = &strbuf{ + Len: int32(len(cl)), + Buf: (*int8)(unsafe.Pointer(&cl[0])), + } + } + if len(data) > 0 { + datap = &strbuf{ + Len: int32(len(data)), + Buf: (*int8)(unsafe.Pointer(&data[0])), + } + } + return putmsg(fd, clp, datap, flags) +} + +//sys getmsg(fd int, clptr *strbuf, dataptr *strbuf, flags *int) (err error) + +func Getmsg(fd int, cl []byte, data []byte) (retCl []byte, retData []byte, flags int, err error) { + var clp, datap *strbuf + if len(cl) > 0 { + clp = &strbuf{ + Maxlen: int32(len(cl)), + Buf: (*int8)(unsafe.Pointer(&cl[0])), + } + } + if len(data) > 0 { + datap = &strbuf{ + Maxlen: int32(len(data)), + Buf: (*int8)(unsafe.Pointer(&data[0])), + } + } + + if err = getmsg(fd, clp, datap, &flags); err != nil { + return nil, nil, 0, err + } + + if len(cl) > 0 { + retCl = cl[:clp.Len] + } + if len(data) > 0 { + retData = data[:datap.Len] + } + return retCl, retData, flags, nil +} + +func IoctlSetIntRetInt(fd int, req uint, arg int) (int, error) { + return ioctlRet(fd, req, uintptr(arg)) +} + +func IoctlSetString(fd int, req uint, val string) error { + bs := make([]byte, len(val)+1) + copy(bs[:len(bs)-1], val) + err := ioctl(fd, req, uintptr(unsafe.Pointer(&bs[0]))) + runtime.KeepAlive(&bs[0]) + return err +} + +// Lifreq Helpers + +func (l *Lifreq) SetName(name string) error { + if len(name) >= len(l.Name) { + return fmt.Errorf("name cannot be more than %d characters", len(l.Name)-1) + } + for i := range name { + l.Name[i] = int8(name[i]) + } + return nil +} + +func (l *Lifreq) SetLifruInt(d int) { + *(*int)(unsafe.Pointer(&l.Lifru[0])) = d +} + +func (l *Lifreq) GetLifruInt() int { + return *(*int)(unsafe.Pointer(&l.Lifru[0])) +} + +func (l *Lifreq) SetLifruUint(d uint) { + *(*uint)(unsafe.Pointer(&l.Lifru[0])) = d +} + +func (l *Lifreq) GetLifruUint() uint { + return *(*uint)(unsafe.Pointer(&l.Lifru[0])) +} + +func IoctlLifreq(fd int, req uint, l *Lifreq) error { + return ioctl(fd, req, uintptr(unsafe.Pointer(l))) +} + +// Strioctl Helpers + +func (s *Strioctl) SetInt(i int) { + s.Len = int32(unsafe.Sizeof(i)) + s.Dp = (*int8)(unsafe.Pointer(&i)) +} + +func IoctlSetStrioctlRetInt(fd int, req uint, s *Strioctl) (int, error) { + return ioctlRet(fd, req, uintptr(unsafe.Pointer(s))) } diff --git a/vendor/golang.org/x/sys/unix/syscall_unix.go b/vendor/golang.org/x/sys/unix/syscall_unix.go index 1ff5060b51..00bafda865 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -13,8 +13,6 @@ import ( "sync" "syscall" "unsafe" - - "golang.org/x/sys/internal/unsafeheader" ) var ( @@ -117,11 +115,7 @@ func (m *mmapper) Mmap(fd int, offset int64, length int, prot int, flags int) (d } // Use unsafe to convert addr into a []byte. - var b []byte - hdr := (*unsafeheader.Slice)(unsafe.Pointer(&b)) - hdr.Data = unsafe.Pointer(addr) - hdr.Cap = length - hdr.Len = length + b := unsafe.Slice((*byte)(unsafe.Pointer(addr)), length) // Register mapping in m and return it. p := &b[cap(b)-1] @@ -429,11 +423,15 @@ func Send(s int, buf []byte, flags int) (err error) { } func Sendto(fd int, p []byte, flags int, to Sockaddr) (err error) { - ptr, n, err := to.sockaddr() - if err != nil { - return err + var ptr unsafe.Pointer + var salen _Socklen + if to != nil { + ptr, salen, err = to.sockaddr() + if err != nil { + return err + } } - return sendto(fd, p, flags, ptr, n) + return sendto(fd, p, flags, ptr, salen) } func SetsockoptByte(fd, level, opt int, value byte) (err error) { diff --git a/vendor/golang.org/x/sys/unix/syscall_unix_gc.go b/vendor/golang.org/x/sys/unix/syscall_unix_gc.go index 5898e9a52b..b6919ca580 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix_gc.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix_gc.go @@ -2,11 +2,9 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build (darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris) && gc && !ppc64le && !ppc64 -// +build darwin dragonfly freebsd linux netbsd openbsd solaris +//go:build (darwin || dragonfly || freebsd || (linux && !ppc64 && !ppc64le) || netbsd || openbsd || solaris) && gc +// +build darwin dragonfly freebsd linux,!ppc64,!ppc64le netbsd openbsd solaris // +build gc -// +build !ppc64le -// +build !ppc64 package unix diff --git a/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go b/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go index f8616f454e..68b2f3e1cd 100644 --- a/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go @@ -9,8 +9,10 @@ package unix import ( "bytes" + "fmt" "runtime" "sort" + "strings" "sync" "syscall" "unsafe" @@ -55,7 +57,13 @@ func (d *Dirent) NameString() string { if d == nil { return "" } - return string(d.Name[:d.Namlen]) + s := string(d.Name[:]) + idx := strings.IndexByte(s, 0) + if idx == -1 { + return s + } else { + return s[:idx] + } } func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { @@ -1230,6 +1238,14 @@ func Readdir(dir uintptr) (*Dirent, error) { return &ent, err } +func readdir_r(dirp uintptr, entry *direntLE, result **direntLE) (err error) { + r0, _, e1 := syscall_syscall(SYS___READDIR_R_A, dirp, uintptr(unsafe.Pointer(entry)), uintptr(unsafe.Pointer(result))) + if int64(r0) == -1 { + err = errnoErr(Errno(e1)) + } + return +} + func Closedir(dir uintptr) error { _, _, e := syscall_syscall(SYS_CLOSEDIR, dir, 0, 0) if e != 0 { @@ -1821,3 +1837,158 @@ func Unmount(name string, mtm int) (err error) { } return err } + +func fdToPath(dirfd int) (path string, err error) { + var buffer [1024]byte + // w_ctrl() + ret := runtime.CallLeFuncByPtr(runtime.XplinkLibvec+SYS_W_IOCTL<<4, + []uintptr{uintptr(dirfd), 17, 1024, uintptr(unsafe.Pointer(&buffer[0]))}) + if ret == 0 { + zb := bytes.IndexByte(buffer[:], 0) + if zb == -1 { + zb = len(buffer) + } + // __e2a_l() + runtime.CallLeFuncByPtr(runtime.XplinkLibvec+SYS___E2A_L<<4, + []uintptr{uintptr(unsafe.Pointer(&buffer[0])), uintptr(zb)}) + return string(buffer[:zb]), nil + } + // __errno() + errno := int(*(*int32)(unsafe.Pointer(runtime.CallLeFuncByPtr(runtime.XplinkLibvec+SYS___ERRNO<<4, + []uintptr{})))) + // __errno2() + errno2 := int(runtime.CallLeFuncByPtr(runtime.XplinkLibvec+SYS___ERRNO2<<4, + []uintptr{})) + // strerror_r() + ret = runtime.CallLeFuncByPtr(runtime.XplinkLibvec+SYS_STRERROR_R<<4, + []uintptr{uintptr(errno), uintptr(unsafe.Pointer(&buffer[0])), 1024}) + if ret == 0 { + zb := bytes.IndexByte(buffer[:], 0) + if zb == -1 { + zb = len(buffer) + } + return "", fmt.Errorf("%s (errno2=0x%x)", buffer[:zb], errno2) + } else { + return "", fmt.Errorf("fdToPath errno %d (errno2=0x%x)", errno, errno2) + } +} + +func direntLeToDirentUnix(dirent *direntLE, dir uintptr, path string) (Dirent, error) { + var d Dirent + + d.Ino = uint64(dirent.Ino) + offset, err := Telldir(dir) + if err != nil { + return d, err + } + + d.Off = int64(offset) + s := string(bytes.Split(dirent.Name[:], []byte{0})[0]) + copy(d.Name[:], s) + + d.Reclen = uint16(24 + len(d.NameString())) + var st Stat_t + path = path + "/" + s + err = Lstat(path, &st) + if err != nil { + return d, err + } + + d.Type = uint8(st.Mode >> 24) + return d, err +} + +func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { + // Simulation of Getdirentries port from the Darwin implementation. + // COMMENTS FROM DARWIN: + // It's not the full required semantics, but should handle the case + // of calling Getdirentries or ReadDirent repeatedly. + // It won't handle assigning the results of lseek to *basep, or handle + // the directory being edited underfoot. + + skip, err := Seek(fd, 0, 1 /* SEEK_CUR */) + if err != nil { + return 0, err + } + + // Get path from fd to avoid unavailable call (fdopendir) + path, err := fdToPath(fd) + if err != nil { + return 0, err + } + d, err := Opendir(path) + if err != nil { + return 0, err + } + defer Closedir(d) + + var cnt int64 + for { + var entryLE direntLE + var entrypLE *direntLE + e := readdir_r(d, &entryLE, &entrypLE) + if e != nil { + return n, e + } + if entrypLE == nil { + break + } + if skip > 0 { + skip-- + cnt++ + continue + } + + // Dirent on zos has a different structure + entry, e := direntLeToDirentUnix(&entryLE, d, path) + if e != nil { + return n, e + } + + reclen := int(entry.Reclen) + if reclen > len(buf) { + // Not enough room. Return for now. + // The counter will let us know where we should start up again. + // Note: this strategy for suspending in the middle and + // restarting is O(n^2) in the length of the directory. Oh well. + break + } + + // Copy entry into return buffer. + s := unsafe.Slice((*byte)(unsafe.Pointer(&entry)), reclen) + copy(buf, s) + + buf = buf[reclen:] + n += reclen + cnt++ + } + // Set the seek offset of the input fd to record + // how many files we've already returned. + _, err = Seek(fd, cnt, 0 /* SEEK_SET */) + if err != nil { + return n, err + } + + return n, nil +} + +func ReadDirent(fd int, buf []byte) (n int, err error) { + var base = (*uintptr)(unsafe.Pointer(new(uint64))) + return Getdirentries(fd, buf, base) +} + +func direntIno(buf []byte) (uint64, bool) { + return readInt(buf, unsafe.Offsetof(Dirent{}.Ino), unsafe.Sizeof(Dirent{}.Ino)) +} + +func direntReclen(buf []byte) (uint64, bool) { + return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen)) +} + +func direntNamlen(buf []byte) (uint64, bool) { + reclen, ok := direntReclen(buf) + if !ok { + return 0, false + } + return reclen - uint64(unsafe.Offsetof(Dirent{}.Name)), true +} diff --git a/vendor/golang.org/x/sys/unix/sysvshm_unix.go b/vendor/golang.org/x/sys/unix/sysvshm_unix.go index 0bb4c8de55..5bb41d17bc 100644 --- a/vendor/golang.org/x/sys/unix/sysvshm_unix.go +++ b/vendor/golang.org/x/sys/unix/sysvshm_unix.go @@ -7,11 +7,7 @@ package unix -import ( - "unsafe" - - "golang.org/x/sys/internal/unsafeheader" -) +import "unsafe" // SysvShmAttach attaches the Sysv shared memory segment associated with the // shared memory identifier id. @@ -34,12 +30,7 @@ func SysvShmAttach(id int, addr uintptr, flag int) ([]byte, error) { } // Use unsafe to convert addr into a []byte. - // TODO: convert to unsafe.Slice once we can assume Go 1.17 - var b []byte - hdr := (*unsafeheader.Slice)(unsafe.Pointer(&b)) - hdr.Data = unsafe.Pointer(addr) - hdr.Cap = int(info.Segsz) - hdr.Len = int(info.Segsz) + b := unsafe.Slice((*byte)(unsafe.Pointer(addr)), int(info.Segsz)) return b, nil } diff --git a/vendor/golang.org/x/sys/unix/xattr_bsd.go b/vendor/golang.org/x/sys/unix/xattr_bsd.go index 25df1e3780..663b3779de 100644 --- a/vendor/golang.org/x/sys/unix/xattr_bsd.go +++ b/vendor/golang.org/x/sys/unix/xattr_bsd.go @@ -160,13 +160,12 @@ func Lremovexattr(link string, attr string) (err error) { } func Listxattr(file string, dest []byte) (sz int, err error) { - d := initxattrdest(dest, 0) destsiz := len(dest) // FreeBSD won't allow you to list xattrs from multiple namespaces - s := 0 + s, pos := 0, 0 for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} { - stmp, e := ExtattrListFile(file, nsid, uintptr(d), destsiz) + stmp, e := ListxattrNS(file, nsid, dest[pos:]) /* Errors accessing system attrs are ignored so that * we can implement the Linux-like behavior of omitting errors that @@ -175,66 +174,102 @@ func Listxattr(file string, dest []byte) (sz int, err error) { * Linux will still error if we ask for user attributes on a file that * we don't have read permissions on, so don't ignore those errors */ - if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER { - continue - } else if e != nil { + if e != nil { + if e == EPERM && nsid != EXTATTR_NAMESPACE_USER { + continue + } return s, e } s += stmp - destsiz -= s - if destsiz < 0 { - destsiz = 0 + pos = s + if pos > destsiz { + pos = destsiz } - d = initxattrdest(dest, s) + } + + return s, nil +} + +func ListxattrNS(file string, nsid int, dest []byte) (sz int, err error) { + d := initxattrdest(dest, 0) + destsiz := len(dest) + + s, e := ExtattrListFile(file, nsid, uintptr(d), destsiz) + if e != nil { + return 0, err } return s, nil } func Flistxattr(fd int, dest []byte) (sz int, err error) { - d := initxattrdest(dest, 0) destsiz := len(dest) - s := 0 + s, pos := 0, 0 for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} { - stmp, e := ExtattrListFd(fd, nsid, uintptr(d), destsiz) - if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER { - continue - } else if e != nil { + stmp, e := FlistxattrNS(fd, nsid, dest[pos:]) + + if e != nil { + if e == EPERM && nsid != EXTATTR_NAMESPACE_USER { + continue + } return s, e } s += stmp - destsiz -= s - if destsiz < 0 { - destsiz = 0 + pos = s + if pos > destsiz { + pos = destsiz } - d = initxattrdest(dest, s) + } + + return s, nil +} + +func FlistxattrNS(fd int, nsid int, dest []byte) (sz int, err error) { + d := initxattrdest(dest, 0) + destsiz := len(dest) + + s, e := ExtattrListFd(fd, nsid, uintptr(d), destsiz) + if e != nil { + return 0, err } return s, nil } func Llistxattr(link string, dest []byte) (sz int, err error) { - d := initxattrdest(dest, 0) destsiz := len(dest) - s := 0 + s, pos := 0, 0 for _, nsid := range [...]int{EXTATTR_NAMESPACE_USER, EXTATTR_NAMESPACE_SYSTEM} { - stmp, e := ExtattrListLink(link, nsid, uintptr(d), destsiz) - if e != nil && e == EPERM && nsid != EXTATTR_NAMESPACE_USER { - continue - } else if e != nil { + stmp, e := LlistxattrNS(link, nsid, dest[pos:]) + + if e != nil { + if e == EPERM && nsid != EXTATTR_NAMESPACE_USER { + continue + } return s, e } s += stmp - destsiz -= s - if destsiz < 0 { - destsiz = 0 + pos = s + if pos > destsiz { + pos = destsiz } - d = initxattrdest(dest, s) + } + + return s, nil +} + +func LlistxattrNS(link string, nsid int, dest []byte) (sz int, err error) { + d := initxattrdest(dest, 0) + destsiz := len(dest) + + s, e := ExtattrListLink(link, nsid, uintptr(d), destsiz) + if e != nil { + return 0, err } return s, nil diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_ppc64.go new file mode 100644 index 0000000000..8e2c51b1ee --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_ppc64.go @@ -0,0 +1,1905 @@ +// mkerrors.sh -m64 +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build ppc64 && openbsd +// +build ppc64,openbsd + +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_BLUETOOTH = 0x20 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_ENCAP = 0x1c + AF_HYLINK = 0xf + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x18 + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_KEY = 0x1e + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x24 + AF_MPLS = 0x21 + AF_NATM = 0x1b + AF_NS = 0x6 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x11 + AF_SIP = 0x1d + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + ALTWERASE = 0x200 + ARPHRD_ETHER = 0x1 + ARPHRD_FRELAY = 0xf + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B9600 = 0x2580 + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDIRFILT = 0x4004427c + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc010427b + BIOCGETIF = 0x4020426b + BIOCGFILDROP = 0x40044278 + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044273 + BIOCGRTIMEOUT = 0x4010426e + BIOCGSTATS = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCLOCK = 0x20004276 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDIRFILT = 0x8004427d + BIOCSDLT = 0x8004427a + BIOCSETF = 0x80104267 + BIOCSETIF = 0x8020426c + BIOCSETWF = 0x80104277 + BIOCSFILDROP = 0x80044279 + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044272 + BIOCSRTIMEOUT = 0x8010426d + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIRECTION_IN = 0x1 + BPF_DIRECTION_OUT = 0x2 + BPF_DIV = 0x30 + BPF_FILDROP_CAPTURE = 0x1 + BPF_FILDROP_DROP = 0x2 + BPF_FILDROP_PASS = 0x0 + BPF_F_DIR_IN = 0x10 + BPF_F_DIR_MASK = 0x30 + BPF_F_DIR_OUT = 0x20 + BPF_F_DIR_SHIFT = 0x4 + BPF_F_FLOWID = 0x8 + BPF_F_PRI_MASK = 0x7 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x200000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RND = 0xc0 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CLOCK_BOOTTIME = 0x6 + CLOCK_MONOTONIC = 0x3 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_THREAD_CPUTIME_ID = 0x4 + CLOCK_UPTIME = 0x5 + CPUSTATES = 0x6 + CP_IDLE = 0x5 + CP_INTR = 0x4 + CP_NICE = 0x1 + CP_SPIN = 0x3 + CP_SYS = 0x2 + CP_USER = 0x0 + CREAD = 0x800 + CRTSCTS = 0x10000 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0xff + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_HW = 0x6 + CTL_KERN = 0x1 + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + DIOCADDQUEUE = 0xc110445d + DIOCADDRULE = 0xcd604404 + DIOCADDSTATE = 0xc1084425 + DIOCCHANGERULE = 0xcd60441a + DIOCCLRIFFLAG = 0xc028445a + DIOCCLRSRCNODES = 0x20004455 + DIOCCLRSTATES = 0xc0e04412 + DIOCCLRSTATUS = 0xc0284416 + DIOCGETLIMIT = 0xc0084427 + DIOCGETQSTATS = 0xc1204460 + DIOCGETQUEUE = 0xc110445f + DIOCGETQUEUES = 0xc110445e + DIOCGETRULE = 0xcd604407 + DIOCGETRULES = 0xcd604406 + DIOCGETRULESET = 0xc444443b + DIOCGETRULESETS = 0xc444443a + DIOCGETSRCNODES = 0xc0104454 + DIOCGETSTATE = 0xc1084413 + DIOCGETSTATES = 0xc0104419 + DIOCGETSTATUS = 0xc1e84415 + DIOCGETSYNFLWATS = 0xc0084463 + DIOCGETTIMEOUT = 0xc008441e + DIOCIGETIFACES = 0xc0284457 + DIOCKILLSRCNODES = 0xc080445b + DIOCKILLSTATES = 0xc0e04429 + DIOCNATLOOK = 0xc0504417 + DIOCOSFPADD = 0xc088444f + DIOCOSFPFLUSH = 0x2000444e + DIOCOSFPGET = 0xc0884450 + DIOCRADDADDRS = 0xc4504443 + DIOCRADDTABLES = 0xc450443d + DIOCRCLRADDRS = 0xc4504442 + DIOCRCLRASTATS = 0xc4504448 + DIOCRCLRTABLES = 0xc450443c + DIOCRCLRTSTATS = 0xc4504441 + DIOCRDELADDRS = 0xc4504444 + DIOCRDELTABLES = 0xc450443e + DIOCRGETADDRS = 0xc4504446 + DIOCRGETASTATS = 0xc4504447 + DIOCRGETTABLES = 0xc450443f + DIOCRGETTSTATS = 0xc4504440 + DIOCRINADEFINE = 0xc450444d + DIOCRSETADDRS = 0xc4504445 + DIOCRSETTFLAGS = 0xc450444a + DIOCRTSTADDRS = 0xc4504449 + DIOCSETDEBUG = 0xc0044418 + DIOCSETHOSTID = 0xc0044456 + DIOCSETIFFLAG = 0xc0284459 + DIOCSETLIMIT = 0xc0084428 + DIOCSETREASS = 0xc004445c + DIOCSETSTATUSIF = 0xc0284414 + DIOCSETSYNCOOKIES = 0xc0014462 + DIOCSETSYNFLWATS = 0xc0084461 + DIOCSETTIMEOUT = 0xc008441d + DIOCSTART = 0x20004401 + DIOCSTOP = 0x20004402 + DIOCXBEGIN = 0xc0104451 + DIOCXCOMMIT = 0xc0104452 + DIOCXROLLBACK = 0xc0104453 + DLT_ARCNET = 0x7 + DLT_ATM_RFC1483 = 0xb + DLT_AX25 = 0x3 + DLT_CHAOS = 0x5 + DLT_C_HDLC = 0x68 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0xd + DLT_FDDI = 0xa + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_LOOP = 0xc + DLT_MPLS = 0xdb + DLT_NULL = 0x0 + DLT_OPENFLOW = 0x10b + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_SERIAL = 0x32 + DLT_PRONET = 0x4 + DLT_RAW = 0xe + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DLT_USBPCAP = 0xf9 + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EMT_TAGOVF = 0x1 + EMUL_ENABLED = 0x1 + EMUL_NATIVE = 0x2 + ENDRUNDISC = 0x9 + ETH64_8021_RSVD_MASK = 0xfffffffffff0 + ETH64_8021_RSVD_PREFIX = 0x180c2000000 + ETHERMIN = 0x2e + ETHERMTU = 0x5dc + ETHERTYPE_8023 = 0x4 + ETHERTYPE_AARP = 0x80f3 + ETHERTYPE_ACCTON = 0x8390 + ETHERTYPE_AEONIC = 0x8036 + ETHERTYPE_ALPHA = 0x814a + ETHERTYPE_AMBER = 0x6008 + ETHERTYPE_AMOEBA = 0x8145 + ETHERTYPE_AOE = 0x88a2 + ETHERTYPE_APOLLO = 0x80f7 + ETHERTYPE_APOLLODOMAIN = 0x8019 + ETHERTYPE_APPLETALK = 0x809b + ETHERTYPE_APPLITEK = 0x80c7 + ETHERTYPE_ARGONAUT = 0x803a + ETHERTYPE_ARP = 0x806 + ETHERTYPE_AT = 0x809b + ETHERTYPE_ATALK = 0x809b + ETHERTYPE_ATOMIC = 0x86df + ETHERTYPE_ATT = 0x8069 + ETHERTYPE_ATTSTANFORD = 0x8008 + ETHERTYPE_AUTOPHON = 0x806a + ETHERTYPE_AXIS = 0x8856 + ETHERTYPE_BCLOOP = 0x9003 + ETHERTYPE_BOFL = 0x8102 + ETHERTYPE_CABLETRON = 0x7034 + ETHERTYPE_CHAOS = 0x804 + ETHERTYPE_COMDESIGN = 0x806c + ETHERTYPE_COMPUGRAPHIC = 0x806d + ETHERTYPE_COUNTERPOINT = 0x8062 + ETHERTYPE_CRONUS = 0x8004 + ETHERTYPE_CRONUSVLN = 0x8003 + ETHERTYPE_DCA = 0x1234 + ETHERTYPE_DDE = 0x807b + ETHERTYPE_DEBNI = 0xaaaa + ETHERTYPE_DECAM = 0x8048 + ETHERTYPE_DECCUST = 0x6006 + ETHERTYPE_DECDIAG = 0x6005 + ETHERTYPE_DECDNS = 0x803c + ETHERTYPE_DECDTS = 0x803e + ETHERTYPE_DECEXPER = 0x6000 + ETHERTYPE_DECLAST = 0x8041 + ETHERTYPE_DECLTM = 0x803f + ETHERTYPE_DECMUMPS = 0x6009 + ETHERTYPE_DECNETBIOS = 0x8040 + ETHERTYPE_DELTACON = 0x86de + ETHERTYPE_DIDDLE = 0x4321 + ETHERTYPE_DLOG1 = 0x660 + ETHERTYPE_DLOG2 = 0x661 + ETHERTYPE_DN = 0x6003 + ETHERTYPE_DOGFIGHT = 0x1989 + ETHERTYPE_DSMD = 0x8039 + ETHERTYPE_EAPOL = 0x888e + ETHERTYPE_ECMA = 0x803 + ETHERTYPE_ENCRYPT = 0x803d + ETHERTYPE_ES = 0x805d + ETHERTYPE_EXCELAN = 0x8010 + ETHERTYPE_EXPERDATA = 0x8049 + ETHERTYPE_FLIP = 0x8146 + ETHERTYPE_FLOWCONTROL = 0x8808 + ETHERTYPE_FRARP = 0x808 + ETHERTYPE_GENDYN = 0x8068 + ETHERTYPE_HAYES = 0x8130 + ETHERTYPE_HIPPI_FP = 0x8180 + ETHERTYPE_HITACHI = 0x8820 + ETHERTYPE_HP = 0x8005 + ETHERTYPE_IEEEPUP = 0xa00 + ETHERTYPE_IEEEPUPAT = 0xa01 + ETHERTYPE_IMLBL = 0x4c42 + ETHERTYPE_IMLBLDIAG = 0x424c + ETHERTYPE_IP = 0x800 + ETHERTYPE_IPAS = 0x876c + ETHERTYPE_IPV6 = 0x86dd + ETHERTYPE_IPX = 0x8137 + ETHERTYPE_IPXNEW = 0x8037 + ETHERTYPE_KALPANA = 0x8582 + ETHERTYPE_LANBRIDGE = 0x8038 + ETHERTYPE_LANPROBE = 0x8888 + ETHERTYPE_LAT = 0x6004 + ETHERTYPE_LBACK = 0x9000 + ETHERTYPE_LITTLE = 0x8060 + ETHERTYPE_LLDP = 0x88cc + ETHERTYPE_LOGICRAFT = 0x8148 + ETHERTYPE_LOOPBACK = 0x9000 + ETHERTYPE_MACSEC = 0x88e5 + ETHERTYPE_MATRA = 0x807a + ETHERTYPE_MAX = 0xffff + ETHERTYPE_MERIT = 0x807c + ETHERTYPE_MICP = 0x873a + ETHERTYPE_MOPDL = 0x6001 + ETHERTYPE_MOPRC = 0x6002 + ETHERTYPE_MOTOROLA = 0x818d + ETHERTYPE_MPLS = 0x8847 + ETHERTYPE_MPLS_MCAST = 0x8848 + ETHERTYPE_MUMPS = 0x813f + ETHERTYPE_NBPCC = 0x3c04 + ETHERTYPE_NBPCLAIM = 0x3c09 + ETHERTYPE_NBPCLREQ = 0x3c05 + ETHERTYPE_NBPCLRSP = 0x3c06 + ETHERTYPE_NBPCREQ = 0x3c02 + ETHERTYPE_NBPCRSP = 0x3c03 + ETHERTYPE_NBPDG = 0x3c07 + ETHERTYPE_NBPDGB = 0x3c08 + ETHERTYPE_NBPDLTE = 0x3c0a + ETHERTYPE_NBPRAR = 0x3c0c + ETHERTYPE_NBPRAS = 0x3c0b + ETHERTYPE_NBPRST = 0x3c0d + ETHERTYPE_NBPSCD = 0x3c01 + ETHERTYPE_NBPVCD = 0x3c00 + ETHERTYPE_NBS = 0x802 + ETHERTYPE_NCD = 0x8149 + ETHERTYPE_NESTAR = 0x8006 + ETHERTYPE_NETBEUI = 0x8191 + ETHERTYPE_NHRP = 0x2001 + ETHERTYPE_NOVELL = 0x8138 + ETHERTYPE_NS = 0x600 + ETHERTYPE_NSAT = 0x601 + ETHERTYPE_NSCOMPAT = 0x807 + ETHERTYPE_NSH = 0x984f + ETHERTYPE_NTRAILER = 0x10 + ETHERTYPE_OS9 = 0x7007 + ETHERTYPE_OS9NET = 0x7009 + ETHERTYPE_PACER = 0x80c6 + ETHERTYPE_PBB = 0x88e7 + ETHERTYPE_PCS = 0x4242 + ETHERTYPE_PLANNING = 0x8044 + ETHERTYPE_PPP = 0x880b + ETHERTYPE_PPPOE = 0x8864 + ETHERTYPE_PPPOEDISC = 0x8863 + ETHERTYPE_PRIMENTS = 0x7031 + ETHERTYPE_PUP = 0x200 + ETHERTYPE_PUPAT = 0x200 + ETHERTYPE_QINQ = 0x88a8 + ETHERTYPE_RACAL = 0x7030 + ETHERTYPE_RATIONAL = 0x8150 + ETHERTYPE_RAWFR = 0x6559 + ETHERTYPE_RCL = 0x1995 + ETHERTYPE_RDP = 0x8739 + ETHERTYPE_RETIX = 0x80f2 + ETHERTYPE_REVARP = 0x8035 + ETHERTYPE_SCA = 0x6007 + ETHERTYPE_SECTRA = 0x86db + ETHERTYPE_SECUREDATA = 0x876d + ETHERTYPE_SGITW = 0x817e + ETHERTYPE_SG_BOUNCE = 0x8016 + ETHERTYPE_SG_DIAG = 0x8013 + ETHERTYPE_SG_NETGAMES = 0x8014 + ETHERTYPE_SG_RESV = 0x8015 + ETHERTYPE_SIMNET = 0x5208 + ETHERTYPE_SLOW = 0x8809 + ETHERTYPE_SNA = 0x80d5 + ETHERTYPE_SNMP = 0x814c + ETHERTYPE_SONIX = 0xfaf5 + ETHERTYPE_SPIDER = 0x809f + ETHERTYPE_SPRITE = 0x500 + ETHERTYPE_STP = 0x8181 + ETHERTYPE_TALARIS = 0x812b + ETHERTYPE_TALARISMC = 0x852b + ETHERTYPE_TCPCOMP = 0x876b + ETHERTYPE_TCPSM = 0x9002 + ETHERTYPE_TEC = 0x814f + ETHERTYPE_TIGAN = 0x802f + ETHERTYPE_TRAIL = 0x1000 + ETHERTYPE_TRANSETHER = 0x6558 + ETHERTYPE_TYMSHARE = 0x802e + ETHERTYPE_UBBST = 0x7005 + ETHERTYPE_UBDEBUG = 0x900 + ETHERTYPE_UBDIAGLOOP = 0x7002 + ETHERTYPE_UBDL = 0x7000 + ETHERTYPE_UBNIU = 0x7001 + ETHERTYPE_UBNMC = 0x7003 + ETHERTYPE_VALID = 0x1600 + ETHERTYPE_VARIAN = 0x80dd + ETHERTYPE_VAXELN = 0x803b + ETHERTYPE_VEECO = 0x8067 + ETHERTYPE_VEXP = 0x805b + ETHERTYPE_VGLAB = 0x8131 + ETHERTYPE_VINES = 0xbad + ETHERTYPE_VINESECHO = 0xbaf + ETHERTYPE_VINESLOOP = 0xbae + ETHERTYPE_VITAL = 0xff00 + ETHERTYPE_VLAN = 0x8100 + ETHERTYPE_VLTLMAN = 0x8080 + ETHERTYPE_VPROD = 0x805c + ETHERTYPE_VURESERVED = 0x8147 + ETHERTYPE_WATERLOO = 0x8130 + ETHERTYPE_WELLFLEET = 0x8103 + ETHERTYPE_X25 = 0x805 + ETHERTYPE_X75 = 0x801 + ETHERTYPE_XNSSM = 0x9001 + ETHERTYPE_XTP = 0x817d + ETHER_ADDR_LEN = 0x6 + ETHER_ALIGN = 0x2 + ETHER_CRC_LEN = 0x4 + ETHER_CRC_POLY_BE = 0x4c11db6 + ETHER_CRC_POLY_LE = 0xedb88320 + ETHER_HDR_LEN = 0xe + ETHER_MAX_DIX_LEN = 0x600 + ETHER_MAX_HARDMTU_LEN = 0xff9b + ETHER_MAX_LEN = 0x5ee + ETHER_MIN_LEN = 0x40 + ETHER_TYPE_LEN = 0x2 + ETHER_VLAN_ENCAP_LEN = 0x4 + EVFILT_AIO = -0x3 + EVFILT_DEVICE = -0x8 + EVFILT_EXCEPT = -0x9 + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0x9 + EVFILT_TIMER = -0x7 + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EVL_ENCAPLEN = 0x4 + EVL_PRIO_BITS = 0xd + EVL_PRIO_MAX = 0x7 + EVL_VLID_MASK = 0xfff + EVL_VLID_MAX = 0xffe + EVL_VLID_MIN = 0x1 + EVL_VLID_NULL = 0x0 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf800 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0xa + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETOWN = 0x5 + F_ISATTY = 0xb + F_OK = 0x0 + F_RDLCK = 0x1 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_WRLCK = 0x3 + HUPCL = 0x4000 + HW_MACHINE = 0x1 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x8e52 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_STATICARP = 0x20 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + IFT_1822 = 0x2 + IFT_A12MPPSWITCH = 0x82 + IFT_AAL2 = 0xbb + IFT_AAL5 = 0x31 + IFT_ADSL = 0x5e + IFT_AFLANE8023 = 0x3b + IFT_AFLANE8025 = 0x3c + IFT_ARAP = 0x58 + IFT_ARCNET = 0x23 + IFT_ARCNETPLUS = 0x24 + IFT_ASYNC = 0x54 + IFT_ATM = 0x25 + IFT_ATMDXI = 0x69 + IFT_ATMFUNI = 0x6a + IFT_ATMIMA = 0x6b + IFT_ATMLOGICAL = 0x50 + IFT_ATMRADIO = 0xbd + IFT_ATMSUBINTERFACE = 0x86 + IFT_ATMVCIENDPT = 0xc2 + IFT_ATMVIRTUAL = 0x95 + IFT_BGPPOLICYACCOUNTING = 0xa2 + IFT_BLUETOOTH = 0xf8 + IFT_BRIDGE = 0xd1 + IFT_BSC = 0x53 + IFT_CARP = 0xf7 + IFT_CCTEMUL = 0x3d + IFT_CEPT = 0x13 + IFT_CES = 0x85 + IFT_CHANNEL = 0x46 + IFT_CNR = 0x55 + IFT_COFFEE = 0x84 + IFT_COMPOSITELINK = 0x9b + IFT_DCN = 0x8d + IFT_DIGITALPOWERLINE = 0x8a + IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba + IFT_DLSW = 0x4a + IFT_DOCSCABLEDOWNSTREAM = 0x80 + IFT_DOCSCABLEMACLAYER = 0x7f + IFT_DOCSCABLEUPSTREAM = 0x81 + IFT_DOCSCABLEUPSTREAMCHANNEL = 0xcd + IFT_DS0 = 0x51 + IFT_DS0BUNDLE = 0x52 + IFT_DS1FDL = 0xaa + IFT_DS3 = 0x1e + IFT_DTM = 0x8c + IFT_DUMMY = 0xf1 + IFT_DVBASILN = 0xac + IFT_DVBASIOUT = 0xad + IFT_DVBRCCDOWNSTREAM = 0x93 + IFT_DVBRCCMACLAYER = 0x92 + IFT_DVBRCCUPSTREAM = 0x94 + IFT_ECONET = 0xce + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_EPLRS = 0x57 + IFT_ESCON = 0x49 + IFT_ETHER = 0x6 + IFT_FAITH = 0xf3 + IFT_FAST = 0x7d + IFT_FASTETHER = 0x3e + IFT_FASTETHERFX = 0x45 + IFT_FDDI = 0xf + IFT_FIBRECHANNEL = 0x38 + IFT_FRAMERELAYINTERCONNECT = 0x3a + IFT_FRAMERELAYMPI = 0x5c + IFT_FRDLCIENDPT = 0xc1 + IFT_FRELAY = 0x20 + IFT_FRELAYDCE = 0x2c + IFT_FRF16MFRBUNDLE = 0xa3 + IFT_FRFORWARD = 0x9e + IFT_G703AT2MB = 0x43 + IFT_G703AT64K = 0x42 + IFT_GIF = 0xf0 + IFT_GIGABITETHERNET = 0x75 + IFT_GR303IDT = 0xb2 + IFT_GR303RDT = 0xb1 + IFT_H323GATEKEEPER = 0xa4 + IFT_H323PROXY = 0xa5 + IFT_HDH1822 = 0x3 + IFT_HDLC = 0x76 + IFT_HDSL2 = 0xa8 + IFT_HIPERLAN2 = 0xb7 + IFT_HIPPI = 0x2f + IFT_HIPPIINTERFACE = 0x39 + IFT_HOSTPAD = 0x5a + IFT_HSSI = 0x2e + IFT_HY = 0xe + IFT_IBM370PARCHAN = 0x48 + IFT_IDSL = 0x9a + IFT_IEEE1394 = 0x90 + IFT_IEEE80211 = 0x47 + IFT_IEEE80212 = 0x37 + IFT_IEEE8023ADLAG = 0xa1 + IFT_IFGSN = 0x91 + IFT_IMT = 0xbe + IFT_INFINIBAND = 0xc7 + IFT_INTERLEAVE = 0x7c + IFT_IP = 0x7e + IFT_IPFORWARD = 0x8e + IFT_IPOVERATM = 0x72 + IFT_IPOVERCDLC = 0x6d + IFT_IPOVERCLAW = 0x6e + IFT_IPSWITCH = 0x4e + IFT_ISDN = 0x3f + IFT_ISDNBASIC = 0x14 + IFT_ISDNPRIMARY = 0x15 + IFT_ISDNS = 0x4b + IFT_ISDNU = 0x4c + IFT_ISO88022LLC = 0x29 + IFT_ISO88023 = 0x7 + IFT_ISO88024 = 0x8 + IFT_ISO88025 = 0x9 + IFT_ISO88025CRFPINT = 0x62 + IFT_ISO88025DTR = 0x56 + IFT_ISO88025FIBER = 0x73 + IFT_ISO88026 = 0xa + IFT_ISUP = 0xb3 + IFT_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + IFT_L3IPXVLAN = 0x89 + IFT_LAPB = 0x10 + IFT_LAPD = 0x4d + IFT_LAPF = 0x77 + IFT_LINEGROUP = 0xd2 + IFT_LOCALTALK = 0x2a + IFT_LOOP = 0x18 + IFT_MBIM = 0xfa + IFT_MEDIAMAILOVERIP = 0x8b + IFT_MFSIGLINK = 0xa7 + IFT_MIOX25 = 0x26 + IFT_MODEM = 0x30 + IFT_MPC = 0x71 + IFT_MPLS = 0xa6 + IFT_MPLSTUNNEL = 0x96 + IFT_MSDSL = 0x8f + IFT_MVL = 0xbf + IFT_MYRINET = 0x63 + IFT_NFAS = 0xaf + IFT_NSIP = 0x1b + IFT_OPTICALCHANNEL = 0xc3 + IFT_OPTICALTRANSPORT = 0xc4 + IFT_OTHER = 0x1 + IFT_P10 = 0xc + IFT_P80 = 0xd + IFT_PARA = 0x22 + IFT_PFLOG = 0xf5 + IFT_PFLOW = 0xf9 + IFT_PFSYNC = 0xf6 + IFT_PLC = 0xae + IFT_PON155 = 0xcf + IFT_PON622 = 0xd0 + IFT_POS = 0xab + IFT_PPP = 0x17 + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPATM = 0xc5 + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PROPWIRELESSP2P = 0x9d + IFT_PTPSERIAL = 0x16 + IFT_PVC = 0xf2 + IFT_Q2931 = 0xc9 + IFT_QLLC = 0x44 + IFT_RADIOMAC = 0xbc + IFT_RADSL = 0x5f + IFT_REACHDSL = 0xc0 + IFT_RFC1483 = 0x9f + IFT_RS232 = 0x21 + IFT_RSRB = 0x4f + IFT_SDLC = 0x11 + IFT_SDSL = 0x60 + IFT_SHDSL = 0xa9 + IFT_SIP = 0x1f + IFT_SIPSIG = 0xcc + IFT_SIPTG = 0xcb + IFT_SLIP = 0x1c + IFT_SMDSDXI = 0x2b + IFT_SMDSICIP = 0x34 + IFT_SONET = 0x27 + IFT_SONETOVERHEADCHANNEL = 0xb9 + IFT_SONETPATH = 0x32 + IFT_SONETVT = 0x33 + IFT_SRP = 0x97 + IFT_SS7SIGLINK = 0x9c + IFT_STACKTOSTACK = 0x6f + IFT_STARLAN = 0xb + IFT_T1 = 0x12 + IFT_TDLC = 0x74 + IFT_TELINK = 0xc8 + IFT_TERMPAD = 0x5b + IFT_TR008 = 0xb0 + IFT_TRANSPHDLC = 0x7b + IFT_TUNNEL = 0x83 + IFT_ULTRA = 0x1d + IFT_USB = 0xa0 + IFT_V11 = 0x40 + IFT_V35 = 0x2d + IFT_V36 = 0x41 + IFT_V37 = 0x78 + IFT_VDSL = 0x61 + IFT_VIRTUALIPADDRESS = 0x70 + IFT_VIRTUALTG = 0xca + IFT_VOICEDID = 0xd5 + IFT_VOICEEM = 0x64 + IFT_VOICEEMFGD = 0xd3 + IFT_VOICEENCAP = 0x67 + IFT_VOICEFGDEANA = 0xd4 + IFT_VOICEFXO = 0x65 + IFT_VOICEFXS = 0x66 + IFT_VOICEOVERATM = 0x98 + IFT_VOICEOVERCABLE = 0xc6 + IFT_VOICEOVERFRAMERELAY = 0x99 + IFT_VOICEOVERIP = 0x68 + IFT_WIREGUARD = 0xfb + IFT_X213 = 0x5d + IFT_X25 = 0x5 + IFT_X25DDN = 0x4 + IFT_X25HUNTGROUP = 0x7a + IFT_X25MLP = 0x79 + IFT_X25PLE = 0x28 + IFT_XETHER = 0x1a + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IN_RFC3021_HOST = 0x1 + IN_RFC3021_NET = 0xfffffffe + IN_RFC3021_NSHIFT = 0x1f + IPPROTO_AH = 0x33 + IPPROTO_CARP = 0x70 + IPPROTO_DIVERT = 0x102 + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPIP = 0x4 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x103 + IPPROTO_MOBILE = 0x37 + IPPROTO_MPLS = 0x89 + IPPROTO_NONE = 0x3b + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_AUTH_LEVEL = 0x35 + IPV6_AUTOFLOWLABEL = 0x3b + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_ESP_NETWORK_LEVEL = 0x37 + IPV6_ESP_TRANS_LEVEL = 0x36 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xfffffff + IPV6_FLOWLABEL_MASK = 0xfffff + IPV6_FRAGTTL = 0x78 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPCOMP_LEVEL = 0x3c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXPACKET = 0xffff + IPV6_MINHOPCOUNT = 0x41 + IPV6_MMTU = 0x500 + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_OPTIONS = 0x1 + IPV6_PATHMTU = 0x2c + IPV6_PIPEX = 0x3f + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVDSTPORT = 0x40 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RTABLE = 0x1021 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_AUTH_LEVEL = 0x14 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0xd + IP_ESP_NETWORK_LEVEL = 0x16 + IP_ESP_TRANS_LEVEL = 0x15 + IP_HDRINCL = 0x2 + IP_IPCOMP_LEVEL = 0x1d + IP_IPDEFTTL = 0x25 + IP_IPSECFLOWINFO = 0x24 + IP_IPSEC_LOCAL_AUTH = 0x1b + IP_IPSEC_LOCAL_CRED = 0x19 + IP_IPSEC_LOCAL_ID = 0x17 + IP_IPSEC_REMOTE_AUTH = 0x1c + IP_IPSEC_REMOTE_CRED = 0x1a + IP_IPSEC_REMOTE_ID = 0x18 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0xfff + IP_MF = 0x2000 + IP_MINTTL = 0x20 + IP_MIN_MEMBERSHIPS = 0xf + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x1 + IP_PIPEX = 0x22 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVDSTPORT = 0x21 + IP_RECVIF = 0x1e + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVRTABLE = 0x23 + IP_RECVTTL = 0x1f + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RTABLE = 0x1021 + IP_SENDSRCADDR = 0x7 + IP_TOS = 0x3 + IP_TTL = 0x4 + ISIG = 0x80 + ISTRIP = 0x20 + ITIMER_PROF = 0x2 + ITIMER_REAL = 0x0 + ITIMER_VIRTUAL = 0x1 + IUCLC = 0x1000 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + KERN_HOSTNAME = 0xa + KERN_OSRELEASE = 0x2 + KERN_OSTYPE = 0x1 + KERN_VERSION = 0x4 + LCNT_OVERLOAD_FLUSH = 0x6 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x6 + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_SPACEAVAIL = 0x5 + MADV_WILLNEED = 0x3 + MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 + MAP_CONCEAL = 0x8000 + MAP_COPY = 0x2 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_FLAGMASK = 0xfff7 + MAP_HASSEMAPHORE = 0x0 + MAP_INHERIT = 0x0 + MAP_INHERIT_COPY = 0x1 + MAP_INHERIT_NONE = 0x2 + MAP_INHERIT_SHARE = 0x0 + MAP_INHERIT_ZERO = 0x3 + MAP_NOEXTEND = 0x0 + MAP_NORESERVE = 0x0 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x0 + MAP_SHARED = 0x1 + MAP_STACK = 0x4000 + MAP_TRYFIXED = 0x0 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MNT_ASYNC = 0x40 + MNT_DEFEXPORTED = 0x200 + MNT_DELEXPORT = 0x20000 + MNT_DOOMED = 0x8000000 + MNT_EXPORTANON = 0x400 + MNT_EXPORTED = 0x100 + MNT_EXRDONLY = 0x80 + MNT_FORCE = 0x80000 + MNT_LAZY = 0x3 + MNT_LOCAL = 0x1000 + MNT_NOATIME = 0x8000 + MNT_NODEV = 0x10 + MNT_NOEXEC = 0x4 + MNT_NOPERM = 0x20 + MNT_NOSUID = 0x8 + MNT_NOWAIT = 0x2 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELOAD = 0x40000 + MNT_ROOTFS = 0x4000 + MNT_SOFTDEP = 0x4000000 + MNT_STALLED = 0x100000 + MNT_SWAPPABLE = 0x200000 + MNT_SYNCHRONOUS = 0x2 + MNT_UPDATE = 0x10000 + MNT_VISFLAGMASK = 0x400ffff + MNT_WAIT = 0x1 + MNT_WANTRDWR = 0x2000000 + MNT_WXALLOWED = 0x800 + MOUNT_AFS = "afs" + MOUNT_CD9660 = "cd9660" + MOUNT_EXT2FS = "ext2fs" + MOUNT_FFS = "ffs" + MOUNT_FUSEFS = "fuse" + MOUNT_MFS = "mfs" + MOUNT_MSDOS = "msdos" + MOUNT_NCPFS = "ncpfs" + MOUNT_NFS = "nfs" + MOUNT_NTFS = "ntfs" + MOUNT_TMPFS = "tmpfs" + MOUNT_UDF = "udf" + MOUNT_UFS = "ffs" + MSG_BCAST = 0x100 + MSG_CMSG_CLOEXEC = 0x800 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOR = 0x8 + MSG_MCAST = 0x200 + MSG_NOSIGNAL = 0x400 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MSG_WAITFORONE = 0x1000 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x4 + MS_SYNC = 0x2 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_IFNAMES = 0x6 + NET_RT_MAXID = 0x8 + NET_RT_SOURCE = 0x7 + NET_RT_STATS = 0x4 + NET_RT_TABLE = 0x5 + NFDBITS = 0x20 + NOFLSH = 0x80000000 + NOKERNINFO = 0x2000000 + NOTE_ATTRIB = 0x8 + NOTE_CHANGE = 0x1 + NOTE_CHILD = 0x4 + NOTE_DELETE = 0x1 + NOTE_EOF = 0x2 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_OOB = 0x4 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRUNCATE = 0x80 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + OLCUC = 0x20 + ONLCR = 0x2 + ONLRET = 0x80 + ONOCR = 0x40 + ONOEOT = 0x8 + OPOST = 0x1 + OXTABS = 0x4 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x10000 + O_CREAT = 0x200 + O_DIRECTORY = 0x20000 + O_DSYNC = 0x80 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x80 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PF_FLUSH = 0x1 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_MEMLOCK = 0x6 + RLIMIT_NOFILE = 0x8 + RLIMIT_NPROC = 0x7 + RLIMIT_RSS = 0x5 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BFD = 0xb + RTAX_BRD = 0x7 + RTAX_DNS = 0xc + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_LABEL = 0xa + RTAX_MAX = 0xf + RTAX_NETMASK = 0x2 + RTAX_SEARCH = 0xe + RTAX_SRC = 0x8 + RTAX_SRCMASK = 0x9 + RTAX_STATIC = 0xd + RTA_AUTHOR = 0x40 + RTA_BFD = 0x800 + RTA_BRD = 0x80 + RTA_DNS = 0x1000 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_LABEL = 0x400 + RTA_NETMASK = 0x4 + RTA_SEARCH = 0x4000 + RTA_SRC = 0x100 + RTA_SRCMASK = 0x200 + RTA_STATIC = 0x2000 + RTF_ANNOUNCE = 0x4000 + RTF_BFD = 0x1000000 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_CACHED = 0x20000 + RTF_CLONED = 0x10000 + RTF_CLONING = 0x100 + RTF_CONNECTED = 0x800000 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_FMASK = 0x110fc08 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MPATH = 0x40000 + RTF_MPLS = 0x100000 + RTF_MULTICAST = 0x200 + RTF_PERMANENT_ARP = 0x2000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x2000 + RTF_REJECT = 0x8 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_USETRAILERS = 0x8000 + RTM_80211INFO = 0x15 + RTM_ADD = 0x1 + RTM_BFD = 0x12 + RTM_CHANGE = 0x3 + RTM_CHGADDRATTR = 0x14 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DESYNC = 0x10 + RTM_GET = 0x4 + RTM_IFANNOUNCE = 0xf + RTM_IFINFO = 0xe + RTM_INVALIDATE = 0x11 + RTM_LOSING = 0x5 + RTM_MAXSIZE = 0x800 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_PROPOSAL = 0x13 + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_SOURCE = 0x16 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RT_TABLEID_BITS = 0x8 + RT_TABLEID_MASK = 0xff + RT_TABLEID_MAX = 0xff + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x4 + SEEK_CUR = 0x1 + SEEK_END = 0x2 + SEEK_SET = 0x0 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCAIFGROUP = 0x80286987 + SIOCATMARK = 0x40047307 + SIOCBRDGADD = 0x8060693c + SIOCBRDGADDL = 0x80606949 + SIOCBRDGADDS = 0x80606941 + SIOCBRDGARL = 0x808c694d + SIOCBRDGDADDR = 0x81286947 + SIOCBRDGDEL = 0x8060693d + SIOCBRDGDELS = 0x80606942 + SIOCBRDGFLUSH = 0x80606948 + SIOCBRDGFRL = 0x808c694e + SIOCBRDGGCACHE = 0xc0146941 + SIOCBRDGGFD = 0xc0146952 + SIOCBRDGGHT = 0xc0146951 + SIOCBRDGGIFFLGS = 0xc060693e + SIOCBRDGGMA = 0xc0146953 + SIOCBRDGGPARAM = 0xc0406958 + SIOCBRDGGPRI = 0xc0146950 + SIOCBRDGGRL = 0xc030694f + SIOCBRDGGTO = 0xc0146946 + SIOCBRDGIFS = 0xc0606942 + SIOCBRDGRTS = 0xc0206943 + SIOCBRDGSADDR = 0xc1286944 + SIOCBRDGSCACHE = 0x80146940 + SIOCBRDGSFD = 0x80146952 + SIOCBRDGSHT = 0x80146951 + SIOCBRDGSIFCOST = 0x80606955 + SIOCBRDGSIFFLGS = 0x8060693f + SIOCBRDGSIFPRIO = 0x80606954 + SIOCBRDGSIFPROT = 0x8060694a + SIOCBRDGSMA = 0x80146953 + SIOCBRDGSPRI = 0x80146950 + SIOCBRDGSPROTO = 0x8014695a + SIOCBRDGSTO = 0x80146945 + SIOCBRDGSTXHC = 0x80146959 + SIOCDELLABEL = 0x80206997 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFGROUP = 0x80286989 + SIOCDIFPARENT = 0x802069b4 + SIOCDIFPHYADDR = 0x80206949 + SIOCDPWE3NEIGHBOR = 0x802069de + SIOCDVNETID = 0x802069af + SIOCGETKALIVE = 0xc01869a4 + SIOCGETLABEL = 0x8020699a + SIOCGETMPWCFG = 0xc02069ae + SIOCGETPFLOW = 0xc02069fe + SIOCGETPFSYNC = 0xc02069f8 + SIOCGETSGCNT = 0xc0207534 + SIOCGETVIFCNT = 0xc0287533 + SIOCGETVLAN = 0xc0206990 + SIOCGIFADDR = 0xc0206921 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCONF = 0xc0106924 + SIOCGIFDATA = 0xc020691b + SIOCGIFDESCR = 0xc0206981 + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGATTR = 0xc028698b + SIOCGIFGENERIC = 0xc020693a + SIOCGIFGLIST = 0xc028698d + SIOCGIFGMEMB = 0xc028698a + SIOCGIFGROUP = 0xc0286988 + SIOCGIFHARDMTU = 0xc02069a5 + SIOCGIFLLPRIO = 0xc02069b6 + SIOCGIFMEDIA = 0xc0406938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc020697e + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPAIR = 0xc02069b1 + SIOCGIFPARENT = 0xc02069b3 + SIOCGIFPRIORITY = 0xc020699c + SIOCGIFRDOMAIN = 0xc02069a0 + SIOCGIFRTLABEL = 0xc0206983 + SIOCGIFRXR = 0x802069aa + SIOCGIFSFFPAGE = 0xc1126939 + SIOCGIFXFLAGS = 0xc020699e + SIOCGLIFPHYADDR = 0xc218694b + SIOCGLIFPHYDF = 0xc02069c2 + SIOCGLIFPHYECN = 0xc02069c8 + SIOCGLIFPHYRTABLE = 0xc02069a2 + SIOCGLIFPHYTTL = 0xc02069a9 + SIOCGPGRP = 0x40047309 + SIOCGPWE3 = 0xc0206998 + SIOCGPWE3CTRLWORD = 0xc02069dc + SIOCGPWE3FAT = 0xc02069dd + SIOCGPWE3NEIGHBOR = 0xc21869de + SIOCGRXHPRIO = 0xc02069db + SIOCGSPPPPARAMS = 0xc0206994 + SIOCGTXHPRIO = 0xc02069c6 + SIOCGUMBINFO = 0xc02069be + SIOCGUMBPARAM = 0xc02069c0 + SIOCGVH = 0xc02069f6 + SIOCGVNETFLOWID = 0xc02069c4 + SIOCGVNETID = 0xc02069a7 + SIOCIFAFATTACH = 0x801169ab + SIOCIFAFDETACH = 0x801169ac + SIOCIFCREATE = 0x8020697a + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc0106978 + SIOCSETKALIVE = 0x801869a3 + SIOCSETLABEL = 0x80206999 + SIOCSETMPWCFG = 0x802069ad + SIOCSETPFLOW = 0x802069fd + SIOCSETPFSYNC = 0x802069f7 + SIOCSETVLAN = 0x8020698f + SIOCSIFADDR = 0x8020690c + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFDESCR = 0x80206980 + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGATTR = 0x8028698c + SIOCSIFGENERIC = 0x80206939 + SIOCSIFLLADDR = 0x8020691f + SIOCSIFLLPRIO = 0x802069b5 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x8020697f + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPAIR = 0x802069b0 + SIOCSIFPARENT = 0x802069b2 + SIOCSIFPRIORITY = 0x8020699b + SIOCSIFRDOMAIN = 0x8020699f + SIOCSIFRTLABEL = 0x80206982 + SIOCSIFXFLAGS = 0x8020699d + SIOCSLIFPHYADDR = 0x8218694a + SIOCSLIFPHYDF = 0x802069c1 + SIOCSLIFPHYECN = 0x802069c7 + SIOCSLIFPHYRTABLE = 0x802069a1 + SIOCSLIFPHYTTL = 0x802069a8 + SIOCSPGRP = 0x80047308 + SIOCSPWE3CTRLWORD = 0x802069dc + SIOCSPWE3FAT = 0x802069dd + SIOCSPWE3NEIGHBOR = 0x821869de + SIOCSRXHPRIO = 0x802069db + SIOCSSPPPPARAMS = 0x80206993 + SIOCSTXHPRIO = 0x802069c5 + SIOCSUMBPARAM = 0x802069bf + SIOCSVH = 0xc02069f5 + SIOCSVNETFLOWID = 0x802069c3 + SIOCSVNETID = 0x802069a6 + SOCK_CLOEXEC = 0x8000 + SOCK_DGRAM = 0x2 + SOCK_DNS = 0x1000 + SOCK_NONBLOCK = 0x4000 + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_BINDANY = 0x1000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DOMAIN = 0x1024 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LINGER = 0x80 + SO_NETPROC = 0x1020 + SO_OOBINLINE = 0x100 + SO_PEERCRED = 0x1022 + SO_PROTOCOL = 0x1025 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_RTABLE = 0x1021 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_SPLICE = 0x1023 + SO_TIMESTAMP = 0x800 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + SO_ZEROIZE = 0x2000 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISTXT = 0x200 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TCIFLUSH = 0x1 + TCIOFF = 0x3 + TCIOFLUSH = 0x3 + TCION = 0x4 + TCOFLUSH = 0x2 + TCOOFF = 0x1 + TCOON = 0x2 + TCPOPT_EOL = 0x0 + TCPOPT_MAXSEG = 0x2 + TCPOPT_NOP = 0x1 + TCPOPT_SACK = 0x5 + TCPOPT_SACK_HDR = 0x1010500 + TCPOPT_SACK_PERMITTED = 0x4 + TCPOPT_SACK_PERMIT_HDR = 0x1010402 + TCPOPT_SIGNATURE = 0x13 + TCPOPT_TIMESTAMP = 0x8 + TCPOPT_TSTAMP_HDR = 0x101080a + TCPOPT_WINDOW = 0x3 + TCP_INFO = 0x9 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x3 + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0x4 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_NOPUSH = 0x10 + TCP_SACKHOLE_LIMIT = 0x80 + TCP_SACK_ENABLE = 0x8 + TCSAFLUSH = 0x2 + TIMER_ABSTIME = 0x1 + TIMER_RELTIME = 0x0 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCHKVERAUTH = 0x2000741e + TIOCCLRVERAUTH = 0x2000741d + TIOCCONS = 0x80047462 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLAG_CLOCAL = 0x2 + TIOCFLAG_CRTSCTS = 0x4 + TIOCFLAG_MDMBUF = 0x8 + TIOCFLAG_PPS = 0x10 + TIOCFLAG_SOFTCAR = 0x1 + TIOCFLUSH = 0x80047410 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGFLAGS = 0x4004745d + TIOCGPGRP = 0x40047477 + TIOCGSID = 0x40047463 + TIOCGTSTAMP = 0x4010745b + TIOCGWINSZ = 0x40087468 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGET = 0x4004746a + TIOCMODG = 0x4004746a + TIOCMODS = 0x8004746d + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSETVERAUTH = 0x8004741c + TIOCSFLAGS = 0x8004745c + TIOCSIG = 0x8004745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTOP = 0x2000746f + TIOCSTSTAMP = 0x8008745a + TIOCSWINSZ = 0x80087467 + TIOCUCNTL = 0x80047466 + TIOCUCNTL_CBRK = 0x7a + TIOCUCNTL_SBRK = 0x7b + TOSTOP = 0x400000 + UTIME_NOW = -0x2 + UTIME_OMIT = -0x1 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VM_ANONMIN = 0x7 + VM_LOADAVG = 0x2 + VM_MALLOC_CONF = 0xc + VM_MAXID = 0xd + VM_MAXSLP = 0xa + VM_METER = 0x1 + VM_NKMEMPAGES = 0x6 + VM_PSSTRINGS = 0x3 + VM_SWAPENCRYPT = 0x5 + VM_USPACE = 0xb + VM_UVMEXP = 0x4 + VM_VNODEMIN = 0x9 + VM_VTEXTMIN = 0x8 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WALTSIG = 0x4 + WCONTINUED = 0x8 + WCOREFLAG = 0x80 + WNOHANG = 0x1 + WUNTRACED = 0x2 + XCASE = 0x1000000 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADF = syscall.Errno(0x9) + EBADMSG = syscall.Errno(0x5c) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x58) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDOM = syscall.Errno(0x21) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x59) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EIPSEC = syscall.Errno(0x52) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x5f) + ELOOP = syscall.Errno(0x3e) + EMEDIUMTYPE = syscall.Errno(0x56) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x53) + ENOBUFS = syscall.Errno(0x37) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOMEDIUM = syscall.Errno(0x55) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x5a) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTRECOVERABLE = syscall.Errno(0x5d) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x5b) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x2d) + EOVERFLOW = syscall.Errno(0x57) + EOWNERDEAD = syscall.Errno(0x5e) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTO = syscall.Errno(0x5f) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTHR = syscall.Signal(0x20) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errorList = [...]struct { + num syscall.Errno + name string + desc string +}{ + {1, "EPERM", "operation not permitted"}, + {2, "ENOENT", "no such file or directory"}, + {3, "ESRCH", "no such process"}, + {4, "EINTR", "interrupted system call"}, + {5, "EIO", "input/output error"}, + {6, "ENXIO", "device not configured"}, + {7, "E2BIG", "argument list too long"}, + {8, "ENOEXEC", "exec format error"}, + {9, "EBADF", "bad file descriptor"}, + {10, "ECHILD", "no child processes"}, + {11, "EDEADLK", "resource deadlock avoided"}, + {12, "ENOMEM", "cannot allocate memory"}, + {13, "EACCES", "permission denied"}, + {14, "EFAULT", "bad address"}, + {15, "ENOTBLK", "block device required"}, + {16, "EBUSY", "device busy"}, + {17, "EEXIST", "file exists"}, + {18, "EXDEV", "cross-device link"}, + {19, "ENODEV", "operation not supported by device"}, + {20, "ENOTDIR", "not a directory"}, + {21, "EISDIR", "is a directory"}, + {22, "EINVAL", "invalid argument"}, + {23, "ENFILE", "too many open files in system"}, + {24, "EMFILE", "too many open files"}, + {25, "ENOTTY", "inappropriate ioctl for device"}, + {26, "ETXTBSY", "text file busy"}, + {27, "EFBIG", "file too large"}, + {28, "ENOSPC", "no space left on device"}, + {29, "ESPIPE", "illegal seek"}, + {30, "EROFS", "read-only file system"}, + {31, "EMLINK", "too many links"}, + {32, "EPIPE", "broken pipe"}, + {33, "EDOM", "numerical argument out of domain"}, + {34, "ERANGE", "result too large"}, + {35, "EAGAIN", "resource temporarily unavailable"}, + {36, "EINPROGRESS", "operation now in progress"}, + {37, "EALREADY", "operation already in progress"}, + {38, "ENOTSOCK", "socket operation on non-socket"}, + {39, "EDESTADDRREQ", "destination address required"}, + {40, "EMSGSIZE", "message too long"}, + {41, "EPROTOTYPE", "protocol wrong type for socket"}, + {42, "ENOPROTOOPT", "protocol not available"}, + {43, "EPROTONOSUPPORT", "protocol not supported"}, + {44, "ESOCKTNOSUPPORT", "socket type not supported"}, + {45, "EOPNOTSUPP", "operation not supported"}, + {46, "EPFNOSUPPORT", "protocol family not supported"}, + {47, "EAFNOSUPPORT", "address family not supported by protocol family"}, + {48, "EADDRINUSE", "address already in use"}, + {49, "EADDRNOTAVAIL", "can't assign requested address"}, + {50, "ENETDOWN", "network is down"}, + {51, "ENETUNREACH", "network is unreachable"}, + {52, "ENETRESET", "network dropped connection on reset"}, + {53, "ECONNABORTED", "software caused connection abort"}, + {54, "ECONNRESET", "connection reset by peer"}, + {55, "ENOBUFS", "no buffer space available"}, + {56, "EISCONN", "socket is already connected"}, + {57, "ENOTCONN", "socket is not connected"}, + {58, "ESHUTDOWN", "can't send after socket shutdown"}, + {59, "ETOOMANYREFS", "too many references: can't splice"}, + {60, "ETIMEDOUT", "operation timed out"}, + {61, "ECONNREFUSED", "connection refused"}, + {62, "ELOOP", "too many levels of symbolic links"}, + {63, "ENAMETOOLONG", "file name too long"}, + {64, "EHOSTDOWN", "host is down"}, + {65, "EHOSTUNREACH", "no route to host"}, + {66, "ENOTEMPTY", "directory not empty"}, + {67, "EPROCLIM", "too many processes"}, + {68, "EUSERS", "too many users"}, + {69, "EDQUOT", "disk quota exceeded"}, + {70, "ESTALE", "stale NFS file handle"}, + {71, "EREMOTE", "too many levels of remote in path"}, + {72, "EBADRPC", "RPC struct is bad"}, + {73, "ERPCMISMATCH", "RPC version wrong"}, + {74, "EPROGUNAVAIL", "RPC program not available"}, + {75, "EPROGMISMATCH", "program version wrong"}, + {76, "EPROCUNAVAIL", "bad procedure for program"}, + {77, "ENOLCK", "no locks available"}, + {78, "ENOSYS", "function not implemented"}, + {79, "EFTYPE", "inappropriate file type or format"}, + {80, "EAUTH", "authentication error"}, + {81, "ENEEDAUTH", "need authenticator"}, + {82, "EIPSEC", "IPsec processing failure"}, + {83, "ENOATTR", "attribute not found"}, + {84, "EILSEQ", "illegal byte sequence"}, + {85, "ENOMEDIUM", "no medium found"}, + {86, "EMEDIUMTYPE", "wrong medium type"}, + {87, "EOVERFLOW", "value too large to be stored in data type"}, + {88, "ECANCELED", "operation canceled"}, + {89, "EIDRM", "identifier removed"}, + {90, "ENOMSG", "no message of desired type"}, + {91, "ENOTSUP", "not supported"}, + {92, "EBADMSG", "bad message"}, + {93, "ENOTRECOVERABLE", "state not recoverable"}, + {94, "EOWNERDEAD", "previous owner died"}, + {95, "ELAST", "protocol error"}, +} + +// Signal table +var signalList = [...]struct { + num syscall.Signal + name string + desc string +}{ + {1, "SIGHUP", "hangup"}, + {2, "SIGINT", "interrupt"}, + {3, "SIGQUIT", "quit"}, + {4, "SIGILL", "illegal instruction"}, + {5, "SIGTRAP", "trace/BPT trap"}, + {6, "SIGABRT", "abort trap"}, + {7, "SIGEMT", "EMT trap"}, + {8, "SIGFPE", "floating point exception"}, + {9, "SIGKILL", "killed"}, + {10, "SIGBUS", "bus error"}, + {11, "SIGSEGV", "segmentation fault"}, + {12, "SIGSYS", "bad system call"}, + {13, "SIGPIPE", "broken pipe"}, + {14, "SIGALRM", "alarm clock"}, + {15, "SIGTERM", "terminated"}, + {16, "SIGURG", "urgent I/O condition"}, + {17, "SIGSTOP", "suspended (signal)"}, + {18, "SIGTSTP", "suspended"}, + {19, "SIGCONT", "continued"}, + {20, "SIGCHLD", "child exited"}, + {21, "SIGTTIN", "stopped (tty input)"}, + {22, "SIGTTOU", "stopped (tty output)"}, + {23, "SIGIO", "I/O possible"}, + {24, "SIGXCPU", "cputime limit exceeded"}, + {25, "SIGXFSZ", "filesize limit exceeded"}, + {26, "SIGVTALRM", "virtual timer expired"}, + {27, "SIGPROF", "profiling timer expired"}, + {28, "SIGWINCH", "window size changes"}, + {29, "SIGINFO", "information request"}, + {30, "SIGUSR1", "user defined signal 1"}, + {31, "SIGUSR2", "user defined signal 2"}, + {32, "SIGTHR", "thread AST"}, +} diff --git a/vendor/golang.org/x/sys/unix/zerrors_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_openbsd_riscv64.go new file mode 100644 index 0000000000..13d403031e --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zerrors_openbsd_riscv64.go @@ -0,0 +1,1904 @@ +// mkerrors.sh -m64 +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build riscv64 && openbsd +// +build riscv64,openbsd + +// Code generated by cmd/cgo -godefs; DO NOT EDIT. +// cgo -godefs -- -m64 _const.go + +package unix + +import "syscall" + +const ( + AF_APPLETALK = 0x10 + AF_BLUETOOTH = 0x20 + AF_CCITT = 0xa + AF_CHAOS = 0x5 + AF_CNT = 0x15 + AF_COIP = 0x14 + AF_DATAKIT = 0x9 + AF_DECnet = 0xc + AF_DLI = 0xd + AF_E164 = 0x1a + AF_ECMA = 0x8 + AF_ENCAP = 0x1c + AF_HYLINK = 0xf + AF_IMPLINK = 0x3 + AF_INET = 0x2 + AF_INET6 = 0x18 + AF_IPX = 0x17 + AF_ISDN = 0x1a + AF_ISO = 0x7 + AF_KEY = 0x1e + AF_LAT = 0xe + AF_LINK = 0x12 + AF_LOCAL = 0x1 + AF_MAX = 0x24 + AF_MPLS = 0x21 + AF_NATM = 0x1b + AF_NS = 0x6 + AF_OSI = 0x7 + AF_PUP = 0x4 + AF_ROUTE = 0x11 + AF_SIP = 0x1d + AF_SNA = 0xb + AF_UNIX = 0x1 + AF_UNSPEC = 0x0 + ALTWERASE = 0x200 + ARPHRD_ETHER = 0x1 + ARPHRD_FRELAY = 0xf + ARPHRD_IEEE1394 = 0x18 + ARPHRD_IEEE802 = 0x6 + B0 = 0x0 + B110 = 0x6e + B115200 = 0x1c200 + B1200 = 0x4b0 + B134 = 0x86 + B14400 = 0x3840 + B150 = 0x96 + B1800 = 0x708 + B19200 = 0x4b00 + B200 = 0xc8 + B230400 = 0x38400 + B2400 = 0x960 + B28800 = 0x7080 + B300 = 0x12c + B38400 = 0x9600 + B4800 = 0x12c0 + B50 = 0x32 + B57600 = 0xe100 + B600 = 0x258 + B7200 = 0x1c20 + B75 = 0x4b + B76800 = 0x12c00 + B9600 = 0x2580 + BIOCFLUSH = 0x20004268 + BIOCGBLEN = 0x40044266 + BIOCGDIRFILT = 0x4004427c + BIOCGDLT = 0x4004426a + BIOCGDLTLIST = 0xc010427b + BIOCGETIF = 0x4020426b + BIOCGFILDROP = 0x40044278 + BIOCGHDRCMPLT = 0x40044274 + BIOCGRSIG = 0x40044273 + BIOCGRTIMEOUT = 0x4010426e + BIOCGSTATS = 0x4008426f + BIOCIMMEDIATE = 0x80044270 + BIOCLOCK = 0x20004276 + BIOCPROMISC = 0x20004269 + BIOCSBLEN = 0xc0044266 + BIOCSDIRFILT = 0x8004427d + BIOCSDLT = 0x8004427a + BIOCSETF = 0x80104267 + BIOCSETIF = 0x8020426c + BIOCSETWF = 0x80104277 + BIOCSFILDROP = 0x80044279 + BIOCSHDRCMPLT = 0x80044275 + BIOCSRSIG = 0x80044272 + BIOCSRTIMEOUT = 0x8010426d + BIOCVERSION = 0x40044271 + BPF_A = 0x10 + BPF_ABS = 0x20 + BPF_ADD = 0x0 + BPF_ALIGNMENT = 0x4 + BPF_ALU = 0x4 + BPF_AND = 0x50 + BPF_B = 0x10 + BPF_DIRECTION_IN = 0x1 + BPF_DIRECTION_OUT = 0x2 + BPF_DIV = 0x30 + BPF_FILDROP_CAPTURE = 0x1 + BPF_FILDROP_DROP = 0x2 + BPF_FILDROP_PASS = 0x0 + BPF_F_DIR_IN = 0x10 + BPF_F_DIR_MASK = 0x30 + BPF_F_DIR_OUT = 0x20 + BPF_F_DIR_SHIFT = 0x4 + BPF_F_FLOWID = 0x8 + BPF_F_PRI_MASK = 0x7 + BPF_H = 0x8 + BPF_IMM = 0x0 + BPF_IND = 0x40 + BPF_JA = 0x0 + BPF_JEQ = 0x10 + BPF_JGE = 0x30 + BPF_JGT = 0x20 + BPF_JMP = 0x5 + BPF_JSET = 0x40 + BPF_K = 0x0 + BPF_LD = 0x0 + BPF_LDX = 0x1 + BPF_LEN = 0x80 + BPF_LSH = 0x60 + BPF_MAJOR_VERSION = 0x1 + BPF_MAXBUFSIZE = 0x200000 + BPF_MAXINSNS = 0x200 + BPF_MEM = 0x60 + BPF_MEMWORDS = 0x10 + BPF_MINBUFSIZE = 0x20 + BPF_MINOR_VERSION = 0x1 + BPF_MISC = 0x7 + BPF_MSH = 0xa0 + BPF_MUL = 0x20 + BPF_NEG = 0x80 + BPF_OR = 0x40 + BPF_RELEASE = 0x30bb6 + BPF_RET = 0x6 + BPF_RND = 0xc0 + BPF_RSH = 0x70 + BPF_ST = 0x2 + BPF_STX = 0x3 + BPF_SUB = 0x10 + BPF_TAX = 0x0 + BPF_TXA = 0x80 + BPF_W = 0x0 + BPF_X = 0x8 + BRKINT = 0x2 + CFLUSH = 0xf + CLOCAL = 0x8000 + CLOCK_BOOTTIME = 0x6 + CLOCK_MONOTONIC = 0x3 + CLOCK_PROCESS_CPUTIME_ID = 0x2 + CLOCK_REALTIME = 0x0 + CLOCK_THREAD_CPUTIME_ID = 0x4 + CLOCK_UPTIME = 0x5 + CPUSTATES = 0x6 + CP_IDLE = 0x5 + CP_INTR = 0x4 + CP_NICE = 0x1 + CP_SPIN = 0x3 + CP_SYS = 0x2 + CP_USER = 0x0 + CREAD = 0x800 + CRTSCTS = 0x10000 + CS5 = 0x0 + CS6 = 0x100 + CS7 = 0x200 + CS8 = 0x300 + CSIZE = 0x300 + CSTART = 0x11 + CSTATUS = 0xff + CSTOP = 0x13 + CSTOPB = 0x400 + CSUSP = 0x1a + CTL_HW = 0x6 + CTL_KERN = 0x1 + CTL_MAXNAME = 0xc + CTL_NET = 0x4 + DIOCADDQUEUE = 0xc110445d + DIOCADDRULE = 0xcd604404 + DIOCADDSTATE = 0xc1084425 + DIOCCHANGERULE = 0xcd60441a + DIOCCLRIFFLAG = 0xc028445a + DIOCCLRSRCNODES = 0x20004455 + DIOCCLRSTATES = 0xc0e04412 + DIOCCLRSTATUS = 0xc0284416 + DIOCGETLIMIT = 0xc0084427 + DIOCGETQSTATS = 0xc1204460 + DIOCGETQUEUE = 0xc110445f + DIOCGETQUEUES = 0xc110445e + DIOCGETRULE = 0xcd604407 + DIOCGETRULES = 0xcd604406 + DIOCGETRULESET = 0xc444443b + DIOCGETRULESETS = 0xc444443a + DIOCGETSRCNODES = 0xc0104454 + DIOCGETSTATE = 0xc1084413 + DIOCGETSTATES = 0xc0104419 + DIOCGETSTATUS = 0xc1e84415 + DIOCGETSYNFLWATS = 0xc0084463 + DIOCGETTIMEOUT = 0xc008441e + DIOCIGETIFACES = 0xc0284457 + DIOCKILLSRCNODES = 0xc080445b + DIOCKILLSTATES = 0xc0e04429 + DIOCNATLOOK = 0xc0504417 + DIOCOSFPADD = 0xc088444f + DIOCOSFPFLUSH = 0x2000444e + DIOCOSFPGET = 0xc0884450 + DIOCRADDADDRS = 0xc4504443 + DIOCRADDTABLES = 0xc450443d + DIOCRCLRADDRS = 0xc4504442 + DIOCRCLRASTATS = 0xc4504448 + DIOCRCLRTABLES = 0xc450443c + DIOCRCLRTSTATS = 0xc4504441 + DIOCRDELADDRS = 0xc4504444 + DIOCRDELTABLES = 0xc450443e + DIOCRGETADDRS = 0xc4504446 + DIOCRGETASTATS = 0xc4504447 + DIOCRGETTABLES = 0xc450443f + DIOCRGETTSTATS = 0xc4504440 + DIOCRINADEFINE = 0xc450444d + DIOCRSETADDRS = 0xc4504445 + DIOCRSETTFLAGS = 0xc450444a + DIOCRTSTADDRS = 0xc4504449 + DIOCSETDEBUG = 0xc0044418 + DIOCSETHOSTID = 0xc0044456 + DIOCSETIFFLAG = 0xc0284459 + DIOCSETLIMIT = 0xc0084428 + DIOCSETREASS = 0xc004445c + DIOCSETSTATUSIF = 0xc0284414 + DIOCSETSYNCOOKIES = 0xc0014462 + DIOCSETSYNFLWATS = 0xc0084461 + DIOCSETTIMEOUT = 0xc008441d + DIOCSTART = 0x20004401 + DIOCSTOP = 0x20004402 + DIOCXBEGIN = 0xc0104451 + DIOCXCOMMIT = 0xc0104452 + DIOCXROLLBACK = 0xc0104453 + DLT_ARCNET = 0x7 + DLT_ATM_RFC1483 = 0xb + DLT_AX25 = 0x3 + DLT_CHAOS = 0x5 + DLT_C_HDLC = 0x68 + DLT_EN10MB = 0x1 + DLT_EN3MB = 0x2 + DLT_ENC = 0xd + DLT_FDDI = 0xa + DLT_IEEE802 = 0x6 + DLT_IEEE802_11 = 0x69 + DLT_IEEE802_11_RADIO = 0x7f + DLT_LOOP = 0xc + DLT_MPLS = 0xdb + DLT_NULL = 0x0 + DLT_OPENFLOW = 0x10b + DLT_PFLOG = 0x75 + DLT_PFSYNC = 0x12 + DLT_PPP = 0x9 + DLT_PPP_BSDOS = 0x10 + DLT_PPP_ETHER = 0x33 + DLT_PPP_SERIAL = 0x32 + DLT_PRONET = 0x4 + DLT_RAW = 0xe + DLT_SLIP = 0x8 + DLT_SLIP_BSDOS = 0xf + DLT_USBPCAP = 0xf9 + DLT_USER0 = 0x93 + DLT_USER1 = 0x94 + DLT_USER10 = 0x9d + DLT_USER11 = 0x9e + DLT_USER12 = 0x9f + DLT_USER13 = 0xa0 + DLT_USER14 = 0xa1 + DLT_USER15 = 0xa2 + DLT_USER2 = 0x95 + DLT_USER3 = 0x96 + DLT_USER4 = 0x97 + DLT_USER5 = 0x98 + DLT_USER6 = 0x99 + DLT_USER7 = 0x9a + DLT_USER8 = 0x9b + DLT_USER9 = 0x9c + DT_BLK = 0x6 + DT_CHR = 0x2 + DT_DIR = 0x4 + DT_FIFO = 0x1 + DT_LNK = 0xa + DT_REG = 0x8 + DT_SOCK = 0xc + DT_UNKNOWN = 0x0 + ECHO = 0x8 + ECHOCTL = 0x40 + ECHOE = 0x2 + ECHOK = 0x4 + ECHOKE = 0x1 + ECHONL = 0x10 + ECHOPRT = 0x20 + EMT_TAGOVF = 0x1 + EMUL_ENABLED = 0x1 + EMUL_NATIVE = 0x2 + ENDRUNDISC = 0x9 + ETH64_8021_RSVD_MASK = 0xfffffffffff0 + ETH64_8021_RSVD_PREFIX = 0x180c2000000 + ETHERMIN = 0x2e + ETHERMTU = 0x5dc + ETHERTYPE_8023 = 0x4 + ETHERTYPE_AARP = 0x80f3 + ETHERTYPE_ACCTON = 0x8390 + ETHERTYPE_AEONIC = 0x8036 + ETHERTYPE_ALPHA = 0x814a + ETHERTYPE_AMBER = 0x6008 + ETHERTYPE_AMOEBA = 0x8145 + ETHERTYPE_AOE = 0x88a2 + ETHERTYPE_APOLLO = 0x80f7 + ETHERTYPE_APOLLODOMAIN = 0x8019 + ETHERTYPE_APPLETALK = 0x809b + ETHERTYPE_APPLITEK = 0x80c7 + ETHERTYPE_ARGONAUT = 0x803a + ETHERTYPE_ARP = 0x806 + ETHERTYPE_AT = 0x809b + ETHERTYPE_ATALK = 0x809b + ETHERTYPE_ATOMIC = 0x86df + ETHERTYPE_ATT = 0x8069 + ETHERTYPE_ATTSTANFORD = 0x8008 + ETHERTYPE_AUTOPHON = 0x806a + ETHERTYPE_AXIS = 0x8856 + ETHERTYPE_BCLOOP = 0x9003 + ETHERTYPE_BOFL = 0x8102 + ETHERTYPE_CABLETRON = 0x7034 + ETHERTYPE_CHAOS = 0x804 + ETHERTYPE_COMDESIGN = 0x806c + ETHERTYPE_COMPUGRAPHIC = 0x806d + ETHERTYPE_COUNTERPOINT = 0x8062 + ETHERTYPE_CRONUS = 0x8004 + ETHERTYPE_CRONUSVLN = 0x8003 + ETHERTYPE_DCA = 0x1234 + ETHERTYPE_DDE = 0x807b + ETHERTYPE_DEBNI = 0xaaaa + ETHERTYPE_DECAM = 0x8048 + ETHERTYPE_DECCUST = 0x6006 + ETHERTYPE_DECDIAG = 0x6005 + ETHERTYPE_DECDNS = 0x803c + ETHERTYPE_DECDTS = 0x803e + ETHERTYPE_DECEXPER = 0x6000 + ETHERTYPE_DECLAST = 0x8041 + ETHERTYPE_DECLTM = 0x803f + ETHERTYPE_DECMUMPS = 0x6009 + ETHERTYPE_DECNETBIOS = 0x8040 + ETHERTYPE_DELTACON = 0x86de + ETHERTYPE_DIDDLE = 0x4321 + ETHERTYPE_DLOG1 = 0x660 + ETHERTYPE_DLOG2 = 0x661 + ETHERTYPE_DN = 0x6003 + ETHERTYPE_DOGFIGHT = 0x1989 + ETHERTYPE_DSMD = 0x8039 + ETHERTYPE_EAPOL = 0x888e + ETHERTYPE_ECMA = 0x803 + ETHERTYPE_ENCRYPT = 0x803d + ETHERTYPE_ES = 0x805d + ETHERTYPE_EXCELAN = 0x8010 + ETHERTYPE_EXPERDATA = 0x8049 + ETHERTYPE_FLIP = 0x8146 + ETHERTYPE_FLOWCONTROL = 0x8808 + ETHERTYPE_FRARP = 0x808 + ETHERTYPE_GENDYN = 0x8068 + ETHERTYPE_HAYES = 0x8130 + ETHERTYPE_HIPPI_FP = 0x8180 + ETHERTYPE_HITACHI = 0x8820 + ETHERTYPE_HP = 0x8005 + ETHERTYPE_IEEEPUP = 0xa00 + ETHERTYPE_IEEEPUPAT = 0xa01 + ETHERTYPE_IMLBL = 0x4c42 + ETHERTYPE_IMLBLDIAG = 0x424c + ETHERTYPE_IP = 0x800 + ETHERTYPE_IPAS = 0x876c + ETHERTYPE_IPV6 = 0x86dd + ETHERTYPE_IPX = 0x8137 + ETHERTYPE_IPXNEW = 0x8037 + ETHERTYPE_KALPANA = 0x8582 + ETHERTYPE_LANBRIDGE = 0x8038 + ETHERTYPE_LANPROBE = 0x8888 + ETHERTYPE_LAT = 0x6004 + ETHERTYPE_LBACK = 0x9000 + ETHERTYPE_LITTLE = 0x8060 + ETHERTYPE_LLDP = 0x88cc + ETHERTYPE_LOGICRAFT = 0x8148 + ETHERTYPE_LOOPBACK = 0x9000 + ETHERTYPE_MACSEC = 0x88e5 + ETHERTYPE_MATRA = 0x807a + ETHERTYPE_MAX = 0xffff + ETHERTYPE_MERIT = 0x807c + ETHERTYPE_MICP = 0x873a + ETHERTYPE_MOPDL = 0x6001 + ETHERTYPE_MOPRC = 0x6002 + ETHERTYPE_MOTOROLA = 0x818d + ETHERTYPE_MPLS = 0x8847 + ETHERTYPE_MPLS_MCAST = 0x8848 + ETHERTYPE_MUMPS = 0x813f + ETHERTYPE_NBPCC = 0x3c04 + ETHERTYPE_NBPCLAIM = 0x3c09 + ETHERTYPE_NBPCLREQ = 0x3c05 + ETHERTYPE_NBPCLRSP = 0x3c06 + ETHERTYPE_NBPCREQ = 0x3c02 + ETHERTYPE_NBPCRSP = 0x3c03 + ETHERTYPE_NBPDG = 0x3c07 + ETHERTYPE_NBPDGB = 0x3c08 + ETHERTYPE_NBPDLTE = 0x3c0a + ETHERTYPE_NBPRAR = 0x3c0c + ETHERTYPE_NBPRAS = 0x3c0b + ETHERTYPE_NBPRST = 0x3c0d + ETHERTYPE_NBPSCD = 0x3c01 + ETHERTYPE_NBPVCD = 0x3c00 + ETHERTYPE_NBS = 0x802 + ETHERTYPE_NCD = 0x8149 + ETHERTYPE_NESTAR = 0x8006 + ETHERTYPE_NETBEUI = 0x8191 + ETHERTYPE_NHRP = 0x2001 + ETHERTYPE_NOVELL = 0x8138 + ETHERTYPE_NS = 0x600 + ETHERTYPE_NSAT = 0x601 + ETHERTYPE_NSCOMPAT = 0x807 + ETHERTYPE_NSH = 0x984f + ETHERTYPE_NTRAILER = 0x10 + ETHERTYPE_OS9 = 0x7007 + ETHERTYPE_OS9NET = 0x7009 + ETHERTYPE_PACER = 0x80c6 + ETHERTYPE_PBB = 0x88e7 + ETHERTYPE_PCS = 0x4242 + ETHERTYPE_PLANNING = 0x8044 + ETHERTYPE_PPP = 0x880b + ETHERTYPE_PPPOE = 0x8864 + ETHERTYPE_PPPOEDISC = 0x8863 + ETHERTYPE_PRIMENTS = 0x7031 + ETHERTYPE_PUP = 0x200 + ETHERTYPE_PUPAT = 0x200 + ETHERTYPE_QINQ = 0x88a8 + ETHERTYPE_RACAL = 0x7030 + ETHERTYPE_RATIONAL = 0x8150 + ETHERTYPE_RAWFR = 0x6559 + ETHERTYPE_RCL = 0x1995 + ETHERTYPE_RDP = 0x8739 + ETHERTYPE_RETIX = 0x80f2 + ETHERTYPE_REVARP = 0x8035 + ETHERTYPE_SCA = 0x6007 + ETHERTYPE_SECTRA = 0x86db + ETHERTYPE_SECUREDATA = 0x876d + ETHERTYPE_SGITW = 0x817e + ETHERTYPE_SG_BOUNCE = 0x8016 + ETHERTYPE_SG_DIAG = 0x8013 + ETHERTYPE_SG_NETGAMES = 0x8014 + ETHERTYPE_SG_RESV = 0x8015 + ETHERTYPE_SIMNET = 0x5208 + ETHERTYPE_SLOW = 0x8809 + ETHERTYPE_SNA = 0x80d5 + ETHERTYPE_SNMP = 0x814c + ETHERTYPE_SONIX = 0xfaf5 + ETHERTYPE_SPIDER = 0x809f + ETHERTYPE_SPRITE = 0x500 + ETHERTYPE_STP = 0x8181 + ETHERTYPE_TALARIS = 0x812b + ETHERTYPE_TALARISMC = 0x852b + ETHERTYPE_TCPCOMP = 0x876b + ETHERTYPE_TCPSM = 0x9002 + ETHERTYPE_TEC = 0x814f + ETHERTYPE_TIGAN = 0x802f + ETHERTYPE_TRAIL = 0x1000 + ETHERTYPE_TRANSETHER = 0x6558 + ETHERTYPE_TYMSHARE = 0x802e + ETHERTYPE_UBBST = 0x7005 + ETHERTYPE_UBDEBUG = 0x900 + ETHERTYPE_UBDIAGLOOP = 0x7002 + ETHERTYPE_UBDL = 0x7000 + ETHERTYPE_UBNIU = 0x7001 + ETHERTYPE_UBNMC = 0x7003 + ETHERTYPE_VALID = 0x1600 + ETHERTYPE_VARIAN = 0x80dd + ETHERTYPE_VAXELN = 0x803b + ETHERTYPE_VEECO = 0x8067 + ETHERTYPE_VEXP = 0x805b + ETHERTYPE_VGLAB = 0x8131 + ETHERTYPE_VINES = 0xbad + ETHERTYPE_VINESECHO = 0xbaf + ETHERTYPE_VINESLOOP = 0xbae + ETHERTYPE_VITAL = 0xff00 + ETHERTYPE_VLAN = 0x8100 + ETHERTYPE_VLTLMAN = 0x8080 + ETHERTYPE_VPROD = 0x805c + ETHERTYPE_VURESERVED = 0x8147 + ETHERTYPE_WATERLOO = 0x8130 + ETHERTYPE_WELLFLEET = 0x8103 + ETHERTYPE_X25 = 0x805 + ETHERTYPE_X75 = 0x801 + ETHERTYPE_XNSSM = 0x9001 + ETHERTYPE_XTP = 0x817d + ETHER_ADDR_LEN = 0x6 + ETHER_ALIGN = 0x2 + ETHER_CRC_LEN = 0x4 + ETHER_CRC_POLY_BE = 0x4c11db6 + ETHER_CRC_POLY_LE = 0xedb88320 + ETHER_HDR_LEN = 0xe + ETHER_MAX_DIX_LEN = 0x600 + ETHER_MAX_HARDMTU_LEN = 0xff9b + ETHER_MAX_LEN = 0x5ee + ETHER_MIN_LEN = 0x40 + ETHER_TYPE_LEN = 0x2 + ETHER_VLAN_ENCAP_LEN = 0x4 + EVFILT_AIO = -0x3 + EVFILT_DEVICE = -0x8 + EVFILT_EXCEPT = -0x9 + EVFILT_PROC = -0x5 + EVFILT_READ = -0x1 + EVFILT_SIGNAL = -0x6 + EVFILT_SYSCOUNT = 0x9 + EVFILT_TIMER = -0x7 + EVFILT_VNODE = -0x4 + EVFILT_WRITE = -0x2 + EVL_ENCAPLEN = 0x4 + EVL_PRIO_BITS = 0xd + EVL_PRIO_MAX = 0x7 + EVL_VLID_MASK = 0xfff + EVL_VLID_MAX = 0xffe + EVL_VLID_MIN = 0x1 + EVL_VLID_NULL = 0x0 + EV_ADD = 0x1 + EV_CLEAR = 0x20 + EV_DELETE = 0x2 + EV_DISABLE = 0x8 + EV_DISPATCH = 0x80 + EV_ENABLE = 0x4 + EV_EOF = 0x8000 + EV_ERROR = 0x4000 + EV_FLAG1 = 0x2000 + EV_ONESHOT = 0x10 + EV_RECEIPT = 0x40 + EV_SYSFLAGS = 0xf800 + EXTA = 0x4b00 + EXTB = 0x9600 + EXTPROC = 0x800 + FD_CLOEXEC = 0x1 + FD_SETSIZE = 0x400 + FLUSHO = 0x800000 + F_DUPFD = 0x0 + F_DUPFD_CLOEXEC = 0xa + F_GETFD = 0x1 + F_GETFL = 0x3 + F_GETLK = 0x7 + F_GETOWN = 0x5 + F_ISATTY = 0xb + F_OK = 0x0 + F_RDLCK = 0x1 + F_SETFD = 0x2 + F_SETFL = 0x4 + F_SETLK = 0x8 + F_SETLKW = 0x9 + F_SETOWN = 0x6 + F_UNLCK = 0x2 + F_WRLCK = 0x3 + HUPCL = 0x4000 + HW_MACHINE = 0x1 + ICANON = 0x100 + ICMP6_FILTER = 0x12 + ICRNL = 0x100 + IEXTEN = 0x400 + IFAN_ARRIVAL = 0x0 + IFAN_DEPARTURE = 0x1 + IFF_ALLMULTI = 0x200 + IFF_BROADCAST = 0x2 + IFF_CANTCHANGE = 0x8e52 + IFF_DEBUG = 0x4 + IFF_LINK0 = 0x1000 + IFF_LINK1 = 0x2000 + IFF_LINK2 = 0x4000 + IFF_LOOPBACK = 0x8 + IFF_MULTICAST = 0x8000 + IFF_NOARP = 0x80 + IFF_OACTIVE = 0x400 + IFF_POINTOPOINT = 0x10 + IFF_PROMISC = 0x100 + IFF_RUNNING = 0x40 + IFF_SIMPLEX = 0x800 + IFF_STATICARP = 0x20 + IFF_UP = 0x1 + IFNAMSIZ = 0x10 + IFT_1822 = 0x2 + IFT_A12MPPSWITCH = 0x82 + IFT_AAL2 = 0xbb + IFT_AAL5 = 0x31 + IFT_ADSL = 0x5e + IFT_AFLANE8023 = 0x3b + IFT_AFLANE8025 = 0x3c + IFT_ARAP = 0x58 + IFT_ARCNET = 0x23 + IFT_ARCNETPLUS = 0x24 + IFT_ASYNC = 0x54 + IFT_ATM = 0x25 + IFT_ATMDXI = 0x69 + IFT_ATMFUNI = 0x6a + IFT_ATMIMA = 0x6b + IFT_ATMLOGICAL = 0x50 + IFT_ATMRADIO = 0xbd + IFT_ATMSUBINTERFACE = 0x86 + IFT_ATMVCIENDPT = 0xc2 + IFT_ATMVIRTUAL = 0x95 + IFT_BGPPOLICYACCOUNTING = 0xa2 + IFT_BLUETOOTH = 0xf8 + IFT_BRIDGE = 0xd1 + IFT_BSC = 0x53 + IFT_CARP = 0xf7 + IFT_CCTEMUL = 0x3d + IFT_CEPT = 0x13 + IFT_CES = 0x85 + IFT_CHANNEL = 0x46 + IFT_CNR = 0x55 + IFT_COFFEE = 0x84 + IFT_COMPOSITELINK = 0x9b + IFT_DCN = 0x8d + IFT_DIGITALPOWERLINE = 0x8a + IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba + IFT_DLSW = 0x4a + IFT_DOCSCABLEDOWNSTREAM = 0x80 + IFT_DOCSCABLEMACLAYER = 0x7f + IFT_DOCSCABLEUPSTREAM = 0x81 + IFT_DOCSCABLEUPSTREAMCHANNEL = 0xcd + IFT_DS0 = 0x51 + IFT_DS0BUNDLE = 0x52 + IFT_DS1FDL = 0xaa + IFT_DS3 = 0x1e + IFT_DTM = 0x8c + IFT_DUMMY = 0xf1 + IFT_DVBASILN = 0xac + IFT_DVBASIOUT = 0xad + IFT_DVBRCCDOWNSTREAM = 0x93 + IFT_DVBRCCMACLAYER = 0x92 + IFT_DVBRCCUPSTREAM = 0x94 + IFT_ECONET = 0xce + IFT_ENC = 0xf4 + IFT_EON = 0x19 + IFT_EPLRS = 0x57 + IFT_ESCON = 0x49 + IFT_ETHER = 0x6 + IFT_FAITH = 0xf3 + IFT_FAST = 0x7d + IFT_FASTETHER = 0x3e + IFT_FASTETHERFX = 0x45 + IFT_FDDI = 0xf + IFT_FIBRECHANNEL = 0x38 + IFT_FRAMERELAYINTERCONNECT = 0x3a + IFT_FRAMERELAYMPI = 0x5c + IFT_FRDLCIENDPT = 0xc1 + IFT_FRELAY = 0x20 + IFT_FRELAYDCE = 0x2c + IFT_FRF16MFRBUNDLE = 0xa3 + IFT_FRFORWARD = 0x9e + IFT_G703AT2MB = 0x43 + IFT_G703AT64K = 0x42 + IFT_GIF = 0xf0 + IFT_GIGABITETHERNET = 0x75 + IFT_GR303IDT = 0xb2 + IFT_GR303RDT = 0xb1 + IFT_H323GATEKEEPER = 0xa4 + IFT_H323PROXY = 0xa5 + IFT_HDH1822 = 0x3 + IFT_HDLC = 0x76 + IFT_HDSL2 = 0xa8 + IFT_HIPERLAN2 = 0xb7 + IFT_HIPPI = 0x2f + IFT_HIPPIINTERFACE = 0x39 + IFT_HOSTPAD = 0x5a + IFT_HSSI = 0x2e + IFT_HY = 0xe + IFT_IBM370PARCHAN = 0x48 + IFT_IDSL = 0x9a + IFT_IEEE1394 = 0x90 + IFT_IEEE80211 = 0x47 + IFT_IEEE80212 = 0x37 + IFT_IEEE8023ADLAG = 0xa1 + IFT_IFGSN = 0x91 + IFT_IMT = 0xbe + IFT_INFINIBAND = 0xc7 + IFT_INTERLEAVE = 0x7c + IFT_IP = 0x7e + IFT_IPFORWARD = 0x8e + IFT_IPOVERATM = 0x72 + IFT_IPOVERCDLC = 0x6d + IFT_IPOVERCLAW = 0x6e + IFT_IPSWITCH = 0x4e + IFT_ISDN = 0x3f + IFT_ISDNBASIC = 0x14 + IFT_ISDNPRIMARY = 0x15 + IFT_ISDNS = 0x4b + IFT_ISDNU = 0x4c + IFT_ISO88022LLC = 0x29 + IFT_ISO88023 = 0x7 + IFT_ISO88024 = 0x8 + IFT_ISO88025 = 0x9 + IFT_ISO88025CRFPINT = 0x62 + IFT_ISO88025DTR = 0x56 + IFT_ISO88025FIBER = 0x73 + IFT_ISO88026 = 0xa + IFT_ISUP = 0xb3 + IFT_L2VLAN = 0x87 + IFT_L3IPVLAN = 0x88 + IFT_L3IPXVLAN = 0x89 + IFT_LAPB = 0x10 + IFT_LAPD = 0x4d + IFT_LAPF = 0x77 + IFT_LINEGROUP = 0xd2 + IFT_LOCALTALK = 0x2a + IFT_LOOP = 0x18 + IFT_MBIM = 0xfa + IFT_MEDIAMAILOVERIP = 0x8b + IFT_MFSIGLINK = 0xa7 + IFT_MIOX25 = 0x26 + IFT_MODEM = 0x30 + IFT_MPC = 0x71 + IFT_MPLS = 0xa6 + IFT_MPLSTUNNEL = 0x96 + IFT_MSDSL = 0x8f + IFT_MVL = 0xbf + IFT_MYRINET = 0x63 + IFT_NFAS = 0xaf + IFT_NSIP = 0x1b + IFT_OPTICALCHANNEL = 0xc3 + IFT_OPTICALTRANSPORT = 0xc4 + IFT_OTHER = 0x1 + IFT_P10 = 0xc + IFT_P80 = 0xd + IFT_PARA = 0x22 + IFT_PFLOG = 0xf5 + IFT_PFLOW = 0xf9 + IFT_PFSYNC = 0xf6 + IFT_PLC = 0xae + IFT_PON155 = 0xcf + IFT_PON622 = 0xd0 + IFT_POS = 0xab + IFT_PPP = 0x17 + IFT_PPPMULTILINKBUNDLE = 0x6c + IFT_PROPATM = 0xc5 + IFT_PROPBWAP2MP = 0xb8 + IFT_PROPCNLS = 0x59 + IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 + IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 + IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 + IFT_PROPMUX = 0x36 + IFT_PROPVIRTUAL = 0x35 + IFT_PROPWIRELESSP2P = 0x9d + IFT_PTPSERIAL = 0x16 + IFT_PVC = 0xf2 + IFT_Q2931 = 0xc9 + IFT_QLLC = 0x44 + IFT_RADIOMAC = 0xbc + IFT_RADSL = 0x5f + IFT_REACHDSL = 0xc0 + IFT_RFC1483 = 0x9f + IFT_RS232 = 0x21 + IFT_RSRB = 0x4f + IFT_SDLC = 0x11 + IFT_SDSL = 0x60 + IFT_SHDSL = 0xa9 + IFT_SIP = 0x1f + IFT_SIPSIG = 0xcc + IFT_SIPTG = 0xcb + IFT_SLIP = 0x1c + IFT_SMDSDXI = 0x2b + IFT_SMDSICIP = 0x34 + IFT_SONET = 0x27 + IFT_SONETOVERHEADCHANNEL = 0xb9 + IFT_SONETPATH = 0x32 + IFT_SONETVT = 0x33 + IFT_SRP = 0x97 + IFT_SS7SIGLINK = 0x9c + IFT_STACKTOSTACK = 0x6f + IFT_STARLAN = 0xb + IFT_T1 = 0x12 + IFT_TDLC = 0x74 + IFT_TELINK = 0xc8 + IFT_TERMPAD = 0x5b + IFT_TR008 = 0xb0 + IFT_TRANSPHDLC = 0x7b + IFT_TUNNEL = 0x83 + IFT_ULTRA = 0x1d + IFT_USB = 0xa0 + IFT_V11 = 0x40 + IFT_V35 = 0x2d + IFT_V36 = 0x41 + IFT_V37 = 0x78 + IFT_VDSL = 0x61 + IFT_VIRTUALIPADDRESS = 0x70 + IFT_VIRTUALTG = 0xca + IFT_VOICEDID = 0xd5 + IFT_VOICEEM = 0x64 + IFT_VOICEEMFGD = 0xd3 + IFT_VOICEENCAP = 0x67 + IFT_VOICEFGDEANA = 0xd4 + IFT_VOICEFXO = 0x65 + IFT_VOICEFXS = 0x66 + IFT_VOICEOVERATM = 0x98 + IFT_VOICEOVERCABLE = 0xc6 + IFT_VOICEOVERFRAMERELAY = 0x99 + IFT_VOICEOVERIP = 0x68 + IFT_WIREGUARD = 0xfb + IFT_X213 = 0x5d + IFT_X25 = 0x5 + IFT_X25DDN = 0x4 + IFT_X25HUNTGROUP = 0x7a + IFT_X25MLP = 0x79 + IFT_X25PLE = 0x28 + IFT_XETHER = 0x1a + IGNBRK = 0x1 + IGNCR = 0x80 + IGNPAR = 0x4 + IMAXBEL = 0x2000 + INLCR = 0x40 + INPCK = 0x10 + IN_CLASSA_HOST = 0xffffff + IN_CLASSA_MAX = 0x80 + IN_CLASSA_NET = 0xff000000 + IN_CLASSA_NSHIFT = 0x18 + IN_CLASSB_HOST = 0xffff + IN_CLASSB_MAX = 0x10000 + IN_CLASSB_NET = 0xffff0000 + IN_CLASSB_NSHIFT = 0x10 + IN_CLASSC_HOST = 0xff + IN_CLASSC_NET = 0xffffff00 + IN_CLASSC_NSHIFT = 0x8 + IN_CLASSD_HOST = 0xfffffff + IN_CLASSD_NET = 0xf0000000 + IN_CLASSD_NSHIFT = 0x1c + IN_LOOPBACKNET = 0x7f + IN_RFC3021_HOST = 0x1 + IN_RFC3021_NET = 0xfffffffe + IN_RFC3021_NSHIFT = 0x1f + IPPROTO_AH = 0x33 + IPPROTO_CARP = 0x70 + IPPROTO_DIVERT = 0x102 + IPPROTO_DONE = 0x101 + IPPROTO_DSTOPTS = 0x3c + IPPROTO_EGP = 0x8 + IPPROTO_ENCAP = 0x62 + IPPROTO_EON = 0x50 + IPPROTO_ESP = 0x32 + IPPROTO_ETHERIP = 0x61 + IPPROTO_FRAGMENT = 0x2c + IPPROTO_GGP = 0x3 + IPPROTO_GRE = 0x2f + IPPROTO_HOPOPTS = 0x0 + IPPROTO_ICMP = 0x1 + IPPROTO_ICMPV6 = 0x3a + IPPROTO_IDP = 0x16 + IPPROTO_IGMP = 0x2 + IPPROTO_IP = 0x0 + IPPROTO_IPCOMP = 0x6c + IPPROTO_IPIP = 0x4 + IPPROTO_IPV4 = 0x4 + IPPROTO_IPV6 = 0x29 + IPPROTO_MAX = 0x100 + IPPROTO_MAXID = 0x103 + IPPROTO_MOBILE = 0x37 + IPPROTO_MPLS = 0x89 + IPPROTO_NONE = 0x3b + IPPROTO_PFSYNC = 0xf0 + IPPROTO_PIM = 0x67 + IPPROTO_PUP = 0xc + IPPROTO_RAW = 0xff + IPPROTO_ROUTING = 0x2b + IPPROTO_RSVP = 0x2e + IPPROTO_SCTP = 0x84 + IPPROTO_TCP = 0x6 + IPPROTO_TP = 0x1d + IPPROTO_UDP = 0x11 + IPPROTO_UDPLITE = 0x88 + IPV6_AUTH_LEVEL = 0x35 + IPV6_AUTOFLOWLABEL = 0x3b + IPV6_CHECKSUM = 0x1a + IPV6_DEFAULT_MULTICAST_HOPS = 0x1 + IPV6_DEFAULT_MULTICAST_LOOP = 0x1 + IPV6_DEFHLIM = 0x40 + IPV6_DONTFRAG = 0x3e + IPV6_DSTOPTS = 0x32 + IPV6_ESP_NETWORK_LEVEL = 0x37 + IPV6_ESP_TRANS_LEVEL = 0x36 + IPV6_FAITH = 0x1d + IPV6_FLOWINFO_MASK = 0xffffff0f + IPV6_FLOWLABEL_MASK = 0xffff0f00 + IPV6_FRAGTTL = 0x78 + IPV6_HLIMDEC = 0x1 + IPV6_HOPLIMIT = 0x2f + IPV6_HOPOPTS = 0x31 + IPV6_IPCOMP_LEVEL = 0x3c + IPV6_JOIN_GROUP = 0xc + IPV6_LEAVE_GROUP = 0xd + IPV6_MAXHLIM = 0xff + IPV6_MAXPACKET = 0xffff + IPV6_MINHOPCOUNT = 0x41 + IPV6_MMTU = 0x500 + IPV6_MULTICAST_HOPS = 0xa + IPV6_MULTICAST_IF = 0x9 + IPV6_MULTICAST_LOOP = 0xb + IPV6_NEXTHOP = 0x30 + IPV6_OPTIONS = 0x1 + IPV6_PATHMTU = 0x2c + IPV6_PIPEX = 0x3f + IPV6_PKTINFO = 0x2e + IPV6_PORTRANGE = 0xe + IPV6_PORTRANGE_DEFAULT = 0x0 + IPV6_PORTRANGE_HIGH = 0x1 + IPV6_PORTRANGE_LOW = 0x2 + IPV6_RECVDSTOPTS = 0x28 + IPV6_RECVDSTPORT = 0x40 + IPV6_RECVHOPLIMIT = 0x25 + IPV6_RECVHOPOPTS = 0x27 + IPV6_RECVPATHMTU = 0x2b + IPV6_RECVPKTINFO = 0x24 + IPV6_RECVRTHDR = 0x26 + IPV6_RECVTCLASS = 0x39 + IPV6_RTABLE = 0x1021 + IPV6_RTHDR = 0x33 + IPV6_RTHDRDSTOPTS = 0x23 + IPV6_RTHDR_LOOSE = 0x0 + IPV6_RTHDR_STRICT = 0x1 + IPV6_RTHDR_TYPE_0 = 0x0 + IPV6_SOCKOPT_RESERVED1 = 0x3 + IPV6_TCLASS = 0x3d + IPV6_UNICAST_HOPS = 0x4 + IPV6_USE_MIN_MTU = 0x2a + IPV6_V6ONLY = 0x1b + IPV6_VERSION = 0x60 + IPV6_VERSION_MASK = 0xf0 + IP_ADD_MEMBERSHIP = 0xc + IP_AUTH_LEVEL = 0x14 + IP_DEFAULT_MULTICAST_LOOP = 0x1 + IP_DEFAULT_MULTICAST_TTL = 0x1 + IP_DF = 0x4000 + IP_DROP_MEMBERSHIP = 0xd + IP_ESP_NETWORK_LEVEL = 0x16 + IP_ESP_TRANS_LEVEL = 0x15 + IP_HDRINCL = 0x2 + IP_IPCOMP_LEVEL = 0x1d + IP_IPDEFTTL = 0x25 + IP_IPSECFLOWINFO = 0x24 + IP_IPSEC_LOCAL_AUTH = 0x1b + IP_IPSEC_LOCAL_CRED = 0x19 + IP_IPSEC_LOCAL_ID = 0x17 + IP_IPSEC_REMOTE_AUTH = 0x1c + IP_IPSEC_REMOTE_CRED = 0x1a + IP_IPSEC_REMOTE_ID = 0x18 + IP_MAXPACKET = 0xffff + IP_MAX_MEMBERSHIPS = 0xfff + IP_MF = 0x2000 + IP_MINTTL = 0x20 + IP_MIN_MEMBERSHIPS = 0xf + IP_MSS = 0x240 + IP_MULTICAST_IF = 0x9 + IP_MULTICAST_LOOP = 0xb + IP_MULTICAST_TTL = 0xa + IP_OFFMASK = 0x1fff + IP_OPTIONS = 0x1 + IP_PIPEX = 0x22 + IP_PORTRANGE = 0x13 + IP_PORTRANGE_DEFAULT = 0x0 + IP_PORTRANGE_HIGH = 0x1 + IP_PORTRANGE_LOW = 0x2 + IP_RECVDSTADDR = 0x7 + IP_RECVDSTPORT = 0x21 + IP_RECVIF = 0x1e + IP_RECVOPTS = 0x5 + IP_RECVRETOPTS = 0x6 + IP_RECVRTABLE = 0x23 + IP_RECVTTL = 0x1f + IP_RETOPTS = 0x8 + IP_RF = 0x8000 + IP_RTABLE = 0x1021 + IP_SENDSRCADDR = 0x7 + IP_TOS = 0x3 + IP_TTL = 0x4 + ISIG = 0x80 + ISTRIP = 0x20 + ITIMER_PROF = 0x2 + ITIMER_REAL = 0x0 + ITIMER_VIRTUAL = 0x1 + IUCLC = 0x1000 + IXANY = 0x800 + IXOFF = 0x400 + IXON = 0x200 + KERN_HOSTNAME = 0xa + KERN_OSRELEASE = 0x2 + KERN_OSTYPE = 0x1 + KERN_VERSION = 0x4 + LCNT_OVERLOAD_FLUSH = 0x6 + LOCK_EX = 0x2 + LOCK_NB = 0x4 + LOCK_SH = 0x1 + LOCK_UN = 0x8 + MADV_DONTNEED = 0x4 + MADV_FREE = 0x6 + MADV_NORMAL = 0x0 + MADV_RANDOM = 0x1 + MADV_SEQUENTIAL = 0x2 + MADV_SPACEAVAIL = 0x5 + MADV_WILLNEED = 0x3 + MAP_ANON = 0x1000 + MAP_ANONYMOUS = 0x1000 + MAP_CONCEAL = 0x8000 + MAP_COPY = 0x2 + MAP_FILE = 0x0 + MAP_FIXED = 0x10 + MAP_FLAGMASK = 0xfff7 + MAP_HASSEMAPHORE = 0x0 + MAP_INHERIT = 0x0 + MAP_INHERIT_COPY = 0x1 + MAP_INHERIT_NONE = 0x2 + MAP_INHERIT_SHARE = 0x0 + MAP_INHERIT_ZERO = 0x3 + MAP_NOEXTEND = 0x0 + MAP_NORESERVE = 0x0 + MAP_PRIVATE = 0x2 + MAP_RENAME = 0x0 + MAP_SHARED = 0x1 + MAP_STACK = 0x4000 + MAP_TRYFIXED = 0x0 + MCL_CURRENT = 0x1 + MCL_FUTURE = 0x2 + MNT_ASYNC = 0x40 + MNT_DEFEXPORTED = 0x200 + MNT_DELEXPORT = 0x20000 + MNT_DOOMED = 0x8000000 + MNT_EXPORTANON = 0x400 + MNT_EXPORTED = 0x100 + MNT_EXRDONLY = 0x80 + MNT_FORCE = 0x80000 + MNT_LAZY = 0x3 + MNT_LOCAL = 0x1000 + MNT_NOATIME = 0x8000 + MNT_NODEV = 0x10 + MNT_NOEXEC = 0x4 + MNT_NOPERM = 0x20 + MNT_NOSUID = 0x8 + MNT_NOWAIT = 0x2 + MNT_QUOTA = 0x2000 + MNT_RDONLY = 0x1 + MNT_RELOAD = 0x40000 + MNT_ROOTFS = 0x4000 + MNT_SOFTDEP = 0x4000000 + MNT_STALLED = 0x100000 + MNT_SWAPPABLE = 0x200000 + MNT_SYNCHRONOUS = 0x2 + MNT_UPDATE = 0x10000 + MNT_VISFLAGMASK = 0x400ffff + MNT_WAIT = 0x1 + MNT_WANTRDWR = 0x2000000 + MNT_WXALLOWED = 0x800 + MOUNT_AFS = "afs" + MOUNT_CD9660 = "cd9660" + MOUNT_EXT2FS = "ext2fs" + MOUNT_FFS = "ffs" + MOUNT_FUSEFS = "fuse" + MOUNT_MFS = "mfs" + MOUNT_MSDOS = "msdos" + MOUNT_NCPFS = "ncpfs" + MOUNT_NFS = "nfs" + MOUNT_NTFS = "ntfs" + MOUNT_TMPFS = "tmpfs" + MOUNT_UDF = "udf" + MOUNT_UFS = "ffs" + MSG_BCAST = 0x100 + MSG_CMSG_CLOEXEC = 0x800 + MSG_CTRUNC = 0x20 + MSG_DONTROUTE = 0x4 + MSG_DONTWAIT = 0x80 + MSG_EOR = 0x8 + MSG_MCAST = 0x200 + MSG_NOSIGNAL = 0x400 + MSG_OOB = 0x1 + MSG_PEEK = 0x2 + MSG_TRUNC = 0x10 + MSG_WAITALL = 0x40 + MS_ASYNC = 0x1 + MS_INVALIDATE = 0x4 + MS_SYNC = 0x2 + NAME_MAX = 0xff + NET_RT_DUMP = 0x1 + NET_RT_FLAGS = 0x2 + NET_RT_IFLIST = 0x3 + NET_RT_IFNAMES = 0x6 + NET_RT_MAXID = 0x8 + NET_RT_SOURCE = 0x7 + NET_RT_STATS = 0x4 + NET_RT_TABLE = 0x5 + NFDBITS = 0x20 + NOFLSH = 0x80000000 + NOKERNINFO = 0x2000000 + NOTE_ATTRIB = 0x8 + NOTE_CHANGE = 0x1 + NOTE_CHILD = 0x4 + NOTE_DELETE = 0x1 + NOTE_EOF = 0x2 + NOTE_EXEC = 0x20000000 + NOTE_EXIT = 0x80000000 + NOTE_EXTEND = 0x4 + NOTE_FORK = 0x40000000 + NOTE_LINK = 0x10 + NOTE_LOWAT = 0x1 + NOTE_OOB = 0x4 + NOTE_PCTRLMASK = 0xf0000000 + NOTE_PDATAMASK = 0xfffff + NOTE_RENAME = 0x20 + NOTE_REVOKE = 0x40 + NOTE_TRACK = 0x1 + NOTE_TRACKERR = 0x2 + NOTE_TRUNCATE = 0x80 + NOTE_WRITE = 0x2 + OCRNL = 0x10 + OLCUC = 0x20 + ONLCR = 0x2 + ONLRET = 0x80 + ONOCR = 0x40 + ONOEOT = 0x8 + OPOST = 0x1 + OXTABS = 0x4 + O_ACCMODE = 0x3 + O_APPEND = 0x8 + O_ASYNC = 0x40 + O_CLOEXEC = 0x10000 + O_CREAT = 0x200 + O_DIRECTORY = 0x20000 + O_DSYNC = 0x80 + O_EXCL = 0x800 + O_EXLOCK = 0x20 + O_FSYNC = 0x80 + O_NDELAY = 0x4 + O_NOCTTY = 0x8000 + O_NOFOLLOW = 0x100 + O_NONBLOCK = 0x4 + O_RDONLY = 0x0 + O_RDWR = 0x2 + O_RSYNC = 0x80 + O_SHLOCK = 0x10 + O_SYNC = 0x80 + O_TRUNC = 0x400 + O_WRONLY = 0x1 + PARENB = 0x1000 + PARMRK = 0x8 + PARODD = 0x2000 + PENDIN = 0x20000000 + PF_FLUSH = 0x1 + PRIO_PGRP = 0x1 + PRIO_PROCESS = 0x0 + PRIO_USER = 0x2 + PROT_EXEC = 0x4 + PROT_NONE = 0x0 + PROT_READ = 0x1 + PROT_WRITE = 0x2 + RLIMIT_CORE = 0x4 + RLIMIT_CPU = 0x0 + RLIMIT_DATA = 0x2 + RLIMIT_FSIZE = 0x1 + RLIMIT_MEMLOCK = 0x6 + RLIMIT_NOFILE = 0x8 + RLIMIT_NPROC = 0x7 + RLIMIT_RSS = 0x5 + RLIMIT_STACK = 0x3 + RLIM_INFINITY = 0x7fffffffffffffff + RTAX_AUTHOR = 0x6 + RTAX_BFD = 0xb + RTAX_BRD = 0x7 + RTAX_DNS = 0xc + RTAX_DST = 0x0 + RTAX_GATEWAY = 0x1 + RTAX_GENMASK = 0x3 + RTAX_IFA = 0x5 + RTAX_IFP = 0x4 + RTAX_LABEL = 0xa + RTAX_MAX = 0xf + RTAX_NETMASK = 0x2 + RTAX_SEARCH = 0xe + RTAX_SRC = 0x8 + RTAX_SRCMASK = 0x9 + RTAX_STATIC = 0xd + RTA_AUTHOR = 0x40 + RTA_BFD = 0x800 + RTA_BRD = 0x80 + RTA_DNS = 0x1000 + RTA_DST = 0x1 + RTA_GATEWAY = 0x2 + RTA_GENMASK = 0x8 + RTA_IFA = 0x20 + RTA_IFP = 0x10 + RTA_LABEL = 0x400 + RTA_NETMASK = 0x4 + RTA_SEARCH = 0x4000 + RTA_SRC = 0x100 + RTA_SRCMASK = 0x200 + RTA_STATIC = 0x2000 + RTF_ANNOUNCE = 0x4000 + RTF_BFD = 0x1000000 + RTF_BLACKHOLE = 0x1000 + RTF_BROADCAST = 0x400000 + RTF_CACHED = 0x20000 + RTF_CLONED = 0x10000 + RTF_CLONING = 0x100 + RTF_CONNECTED = 0x800000 + RTF_DONE = 0x40 + RTF_DYNAMIC = 0x10 + RTF_FMASK = 0x110fc08 + RTF_GATEWAY = 0x2 + RTF_HOST = 0x4 + RTF_LLINFO = 0x400 + RTF_LOCAL = 0x200000 + RTF_MODIFIED = 0x20 + RTF_MPATH = 0x40000 + RTF_MPLS = 0x100000 + RTF_MULTICAST = 0x200 + RTF_PERMANENT_ARP = 0x2000 + RTF_PROTO1 = 0x8000 + RTF_PROTO2 = 0x4000 + RTF_PROTO3 = 0x2000 + RTF_REJECT = 0x8 + RTF_STATIC = 0x800 + RTF_UP = 0x1 + RTF_USETRAILERS = 0x8000 + RTM_80211INFO = 0x15 + RTM_ADD = 0x1 + RTM_BFD = 0x12 + RTM_CHANGE = 0x3 + RTM_CHGADDRATTR = 0x14 + RTM_DELADDR = 0xd + RTM_DELETE = 0x2 + RTM_DESYNC = 0x10 + RTM_GET = 0x4 + RTM_IFANNOUNCE = 0xf + RTM_IFINFO = 0xe + RTM_INVALIDATE = 0x11 + RTM_LOSING = 0x5 + RTM_MAXSIZE = 0x800 + RTM_MISS = 0x7 + RTM_NEWADDR = 0xc + RTM_PROPOSAL = 0x13 + RTM_REDIRECT = 0x6 + RTM_RESOLVE = 0xb + RTM_SOURCE = 0x16 + RTM_VERSION = 0x5 + RTV_EXPIRE = 0x4 + RTV_HOPCOUNT = 0x2 + RTV_MTU = 0x1 + RTV_RPIPE = 0x8 + RTV_RTT = 0x40 + RTV_RTTVAR = 0x80 + RTV_SPIPE = 0x10 + RTV_SSTHRESH = 0x20 + RT_TABLEID_BITS = 0x8 + RT_TABLEID_MASK = 0xff + RT_TABLEID_MAX = 0xff + RUSAGE_CHILDREN = -0x1 + RUSAGE_SELF = 0x0 + RUSAGE_THREAD = 0x1 + SCM_RIGHTS = 0x1 + SCM_TIMESTAMP = 0x4 + SEEK_CUR = 0x1 + SEEK_END = 0x2 + SEEK_SET = 0x0 + SHUT_RD = 0x0 + SHUT_RDWR = 0x2 + SHUT_WR = 0x1 + SIOCADDMULTI = 0x80206931 + SIOCAIFADDR = 0x8040691a + SIOCAIFGROUP = 0x80286987 + SIOCATMARK = 0x40047307 + SIOCBRDGADD = 0x8060693c + SIOCBRDGADDL = 0x80606949 + SIOCBRDGADDS = 0x80606941 + SIOCBRDGARL = 0x808c694d + SIOCBRDGDADDR = 0x81286947 + SIOCBRDGDEL = 0x8060693d + SIOCBRDGDELS = 0x80606942 + SIOCBRDGFLUSH = 0x80606948 + SIOCBRDGFRL = 0x808c694e + SIOCBRDGGCACHE = 0xc0146941 + SIOCBRDGGFD = 0xc0146952 + SIOCBRDGGHT = 0xc0146951 + SIOCBRDGGIFFLGS = 0xc060693e + SIOCBRDGGMA = 0xc0146953 + SIOCBRDGGPARAM = 0xc0406958 + SIOCBRDGGPRI = 0xc0146950 + SIOCBRDGGRL = 0xc030694f + SIOCBRDGGTO = 0xc0146946 + SIOCBRDGIFS = 0xc0606942 + SIOCBRDGRTS = 0xc0206943 + SIOCBRDGSADDR = 0xc1286944 + SIOCBRDGSCACHE = 0x80146940 + SIOCBRDGSFD = 0x80146952 + SIOCBRDGSHT = 0x80146951 + SIOCBRDGSIFCOST = 0x80606955 + SIOCBRDGSIFFLGS = 0x8060693f + SIOCBRDGSIFPRIO = 0x80606954 + SIOCBRDGSIFPROT = 0x8060694a + SIOCBRDGSMA = 0x80146953 + SIOCBRDGSPRI = 0x80146950 + SIOCBRDGSPROTO = 0x8014695a + SIOCBRDGSTO = 0x80146945 + SIOCBRDGSTXHC = 0x80146959 + SIOCDELLABEL = 0x80206997 + SIOCDELMULTI = 0x80206932 + SIOCDIFADDR = 0x80206919 + SIOCDIFGROUP = 0x80286989 + SIOCDIFPARENT = 0x802069b4 + SIOCDIFPHYADDR = 0x80206949 + SIOCDPWE3NEIGHBOR = 0x802069de + SIOCDVNETID = 0x802069af + SIOCGETKALIVE = 0xc01869a4 + SIOCGETLABEL = 0x8020699a + SIOCGETMPWCFG = 0xc02069ae + SIOCGETPFLOW = 0xc02069fe + SIOCGETPFSYNC = 0xc02069f8 + SIOCGETSGCNT = 0xc0207534 + SIOCGETVIFCNT = 0xc0287533 + SIOCGETVLAN = 0xc0206990 + SIOCGIFADDR = 0xc0206921 + SIOCGIFBRDADDR = 0xc0206923 + SIOCGIFCONF = 0xc0106924 + SIOCGIFDATA = 0xc020691b + SIOCGIFDESCR = 0xc0206981 + SIOCGIFDSTADDR = 0xc0206922 + SIOCGIFFLAGS = 0xc0206911 + SIOCGIFGATTR = 0xc028698b + SIOCGIFGENERIC = 0xc020693a + SIOCGIFGLIST = 0xc028698d + SIOCGIFGMEMB = 0xc028698a + SIOCGIFGROUP = 0xc0286988 + SIOCGIFHARDMTU = 0xc02069a5 + SIOCGIFLLPRIO = 0xc02069b6 + SIOCGIFMEDIA = 0xc0406938 + SIOCGIFMETRIC = 0xc0206917 + SIOCGIFMTU = 0xc020697e + SIOCGIFNETMASK = 0xc0206925 + SIOCGIFPAIR = 0xc02069b1 + SIOCGIFPARENT = 0xc02069b3 + SIOCGIFPRIORITY = 0xc020699c + SIOCGIFRDOMAIN = 0xc02069a0 + SIOCGIFRTLABEL = 0xc0206983 + SIOCGIFRXR = 0x802069aa + SIOCGIFSFFPAGE = 0xc1126939 + SIOCGIFXFLAGS = 0xc020699e + SIOCGLIFPHYADDR = 0xc218694b + SIOCGLIFPHYDF = 0xc02069c2 + SIOCGLIFPHYECN = 0xc02069c8 + SIOCGLIFPHYRTABLE = 0xc02069a2 + SIOCGLIFPHYTTL = 0xc02069a9 + SIOCGPGRP = 0x40047309 + SIOCGPWE3 = 0xc0206998 + SIOCGPWE3CTRLWORD = 0xc02069dc + SIOCGPWE3FAT = 0xc02069dd + SIOCGPWE3NEIGHBOR = 0xc21869de + SIOCGRXHPRIO = 0xc02069db + SIOCGSPPPPARAMS = 0xc0206994 + SIOCGTXHPRIO = 0xc02069c6 + SIOCGUMBINFO = 0xc02069be + SIOCGUMBPARAM = 0xc02069c0 + SIOCGVH = 0xc02069f6 + SIOCGVNETFLOWID = 0xc02069c4 + SIOCGVNETID = 0xc02069a7 + SIOCIFAFATTACH = 0x801169ab + SIOCIFAFDETACH = 0x801169ac + SIOCIFCREATE = 0x8020697a + SIOCIFDESTROY = 0x80206979 + SIOCIFGCLONERS = 0xc0106978 + SIOCSETKALIVE = 0x801869a3 + SIOCSETLABEL = 0x80206999 + SIOCSETMPWCFG = 0x802069ad + SIOCSETPFLOW = 0x802069fd + SIOCSETPFSYNC = 0x802069f7 + SIOCSETVLAN = 0x8020698f + SIOCSIFADDR = 0x8020690c + SIOCSIFBRDADDR = 0x80206913 + SIOCSIFDESCR = 0x80206980 + SIOCSIFDSTADDR = 0x8020690e + SIOCSIFFLAGS = 0x80206910 + SIOCSIFGATTR = 0x8028698c + SIOCSIFGENERIC = 0x80206939 + SIOCSIFLLADDR = 0x8020691f + SIOCSIFLLPRIO = 0x802069b5 + SIOCSIFMEDIA = 0xc0206937 + SIOCSIFMETRIC = 0x80206918 + SIOCSIFMTU = 0x8020697f + SIOCSIFNETMASK = 0x80206916 + SIOCSIFPAIR = 0x802069b0 + SIOCSIFPARENT = 0x802069b2 + SIOCSIFPRIORITY = 0x8020699b + SIOCSIFRDOMAIN = 0x8020699f + SIOCSIFRTLABEL = 0x80206982 + SIOCSIFXFLAGS = 0x8020699d + SIOCSLIFPHYADDR = 0x8218694a + SIOCSLIFPHYDF = 0x802069c1 + SIOCSLIFPHYECN = 0x802069c7 + SIOCSLIFPHYRTABLE = 0x802069a1 + SIOCSLIFPHYTTL = 0x802069a8 + SIOCSPGRP = 0x80047308 + SIOCSPWE3CTRLWORD = 0x802069dc + SIOCSPWE3FAT = 0x802069dd + SIOCSPWE3NEIGHBOR = 0x821869de + SIOCSRXHPRIO = 0x802069db + SIOCSSPPPPARAMS = 0x80206993 + SIOCSTXHPRIO = 0x802069c5 + SIOCSUMBPARAM = 0x802069bf + SIOCSVH = 0xc02069f5 + SIOCSVNETFLOWID = 0x802069c3 + SIOCSVNETID = 0x802069a6 + SOCK_CLOEXEC = 0x8000 + SOCK_DGRAM = 0x2 + SOCK_DNS = 0x1000 + SOCK_NONBLOCK = 0x4000 + SOCK_RAW = 0x3 + SOCK_RDM = 0x4 + SOCK_SEQPACKET = 0x5 + SOCK_STREAM = 0x1 + SOL_SOCKET = 0xffff + SOMAXCONN = 0x80 + SO_ACCEPTCONN = 0x2 + SO_BINDANY = 0x1000 + SO_BROADCAST = 0x20 + SO_DEBUG = 0x1 + SO_DOMAIN = 0x1024 + SO_DONTROUTE = 0x10 + SO_ERROR = 0x1007 + SO_KEEPALIVE = 0x8 + SO_LINGER = 0x80 + SO_NETPROC = 0x1020 + SO_OOBINLINE = 0x100 + SO_PEERCRED = 0x1022 + SO_PROTOCOL = 0x1025 + SO_RCVBUF = 0x1002 + SO_RCVLOWAT = 0x1004 + SO_RCVTIMEO = 0x1006 + SO_REUSEADDR = 0x4 + SO_REUSEPORT = 0x200 + SO_RTABLE = 0x1021 + SO_SNDBUF = 0x1001 + SO_SNDLOWAT = 0x1003 + SO_SNDTIMEO = 0x1005 + SO_SPLICE = 0x1023 + SO_TIMESTAMP = 0x800 + SO_TYPE = 0x1008 + SO_USELOOPBACK = 0x40 + SO_ZEROIZE = 0x2000 + S_BLKSIZE = 0x200 + S_IEXEC = 0x40 + S_IFBLK = 0x6000 + S_IFCHR = 0x2000 + S_IFDIR = 0x4000 + S_IFIFO = 0x1000 + S_IFLNK = 0xa000 + S_IFMT = 0xf000 + S_IFREG = 0x8000 + S_IFSOCK = 0xc000 + S_IREAD = 0x100 + S_IRGRP = 0x20 + S_IROTH = 0x4 + S_IRUSR = 0x100 + S_IRWXG = 0x38 + S_IRWXO = 0x7 + S_IRWXU = 0x1c0 + S_ISGID = 0x400 + S_ISTXT = 0x200 + S_ISUID = 0x800 + S_ISVTX = 0x200 + S_IWGRP = 0x10 + S_IWOTH = 0x2 + S_IWRITE = 0x80 + S_IWUSR = 0x80 + S_IXGRP = 0x8 + S_IXOTH = 0x1 + S_IXUSR = 0x40 + TCIFLUSH = 0x1 + TCIOFF = 0x3 + TCIOFLUSH = 0x3 + TCION = 0x4 + TCOFLUSH = 0x2 + TCOOFF = 0x1 + TCOON = 0x2 + TCPOPT_EOL = 0x0 + TCPOPT_MAXSEG = 0x2 + TCPOPT_NOP = 0x1 + TCPOPT_SACK = 0x5 + TCPOPT_SACK_HDR = 0x1010500 + TCPOPT_SACK_PERMITTED = 0x4 + TCPOPT_SACK_PERMIT_HDR = 0x1010402 + TCPOPT_SIGNATURE = 0x13 + TCPOPT_TIMESTAMP = 0x8 + TCPOPT_TSTAMP_HDR = 0x101080a + TCPOPT_WINDOW = 0x3 + TCP_INFO = 0x9 + TCP_MAXSEG = 0x2 + TCP_MAXWIN = 0xffff + TCP_MAX_SACK = 0x3 + TCP_MAX_WINSHIFT = 0xe + TCP_MD5SIG = 0x4 + TCP_MSS = 0x200 + TCP_NODELAY = 0x1 + TCP_NOPUSH = 0x10 + TCP_SACKHOLE_LIMIT = 0x80 + TCP_SACK_ENABLE = 0x8 + TCSAFLUSH = 0x2 + TIMER_ABSTIME = 0x1 + TIMER_RELTIME = 0x0 + TIOCCBRK = 0x2000747a + TIOCCDTR = 0x20007478 + TIOCCHKVERAUTH = 0x2000741e + TIOCCLRVERAUTH = 0x2000741d + TIOCCONS = 0x80047462 + TIOCDRAIN = 0x2000745e + TIOCEXCL = 0x2000740d + TIOCEXT = 0x80047460 + TIOCFLAG_CLOCAL = 0x2 + TIOCFLAG_CRTSCTS = 0x4 + TIOCFLAG_MDMBUF = 0x8 + TIOCFLAG_PPS = 0x10 + TIOCFLAG_SOFTCAR = 0x1 + TIOCFLUSH = 0x80047410 + TIOCGETA = 0x402c7413 + TIOCGETD = 0x4004741a + TIOCGFLAGS = 0x4004745d + TIOCGPGRP = 0x40047477 + TIOCGSID = 0x40047463 + TIOCGTSTAMP = 0x4010745b + TIOCGWINSZ = 0x40087468 + TIOCMBIC = 0x8004746b + TIOCMBIS = 0x8004746c + TIOCMGET = 0x4004746a + TIOCMODG = 0x4004746a + TIOCMODS = 0x8004746d + TIOCMSET = 0x8004746d + TIOCM_CAR = 0x40 + TIOCM_CD = 0x40 + TIOCM_CTS = 0x20 + TIOCM_DSR = 0x100 + TIOCM_DTR = 0x2 + TIOCM_LE = 0x1 + TIOCM_RI = 0x80 + TIOCM_RNG = 0x80 + TIOCM_RTS = 0x4 + TIOCM_SR = 0x10 + TIOCM_ST = 0x8 + TIOCNOTTY = 0x20007471 + TIOCNXCL = 0x2000740e + TIOCOUTQ = 0x40047473 + TIOCPKT = 0x80047470 + TIOCPKT_DATA = 0x0 + TIOCPKT_DOSTOP = 0x20 + TIOCPKT_FLUSHREAD = 0x1 + TIOCPKT_FLUSHWRITE = 0x2 + TIOCPKT_IOCTL = 0x40 + TIOCPKT_NOSTOP = 0x10 + TIOCPKT_START = 0x8 + TIOCPKT_STOP = 0x4 + TIOCREMOTE = 0x80047469 + TIOCSBRK = 0x2000747b + TIOCSCTTY = 0x20007461 + TIOCSDTR = 0x20007479 + TIOCSETA = 0x802c7414 + TIOCSETAF = 0x802c7416 + TIOCSETAW = 0x802c7415 + TIOCSETD = 0x8004741b + TIOCSETVERAUTH = 0x8004741c + TIOCSFLAGS = 0x8004745c + TIOCSIG = 0x8004745f + TIOCSPGRP = 0x80047476 + TIOCSTART = 0x2000746e + TIOCSTAT = 0x20007465 + TIOCSTOP = 0x2000746f + TIOCSTSTAMP = 0x8008745a + TIOCSWINSZ = 0x80087467 + TIOCUCNTL = 0x80047466 + TIOCUCNTL_CBRK = 0x7a + TIOCUCNTL_SBRK = 0x7b + TOSTOP = 0x400000 + UTIME_NOW = -0x2 + UTIME_OMIT = -0x1 + VDISCARD = 0xf + VDSUSP = 0xb + VEOF = 0x0 + VEOL = 0x1 + VEOL2 = 0x2 + VERASE = 0x3 + VINTR = 0x8 + VKILL = 0x5 + VLNEXT = 0xe + VMIN = 0x10 + VM_ANONMIN = 0x7 + VM_LOADAVG = 0x2 + VM_MALLOC_CONF = 0xc + VM_MAXID = 0xd + VM_MAXSLP = 0xa + VM_METER = 0x1 + VM_NKMEMPAGES = 0x6 + VM_PSSTRINGS = 0x3 + VM_SWAPENCRYPT = 0x5 + VM_USPACE = 0xb + VM_UVMEXP = 0x4 + VM_VNODEMIN = 0x9 + VM_VTEXTMIN = 0x8 + VQUIT = 0x9 + VREPRINT = 0x6 + VSTART = 0xc + VSTATUS = 0x12 + VSTOP = 0xd + VSUSP = 0xa + VTIME = 0x11 + VWERASE = 0x4 + WALTSIG = 0x4 + WCONTINUED = 0x8 + WCOREFLAG = 0x80 + WNOHANG = 0x1 + WUNTRACED = 0x2 + XCASE = 0x1000000 +) + +// Errors +const ( + E2BIG = syscall.Errno(0x7) + EACCES = syscall.Errno(0xd) + EADDRINUSE = syscall.Errno(0x30) + EADDRNOTAVAIL = syscall.Errno(0x31) + EAFNOSUPPORT = syscall.Errno(0x2f) + EAGAIN = syscall.Errno(0x23) + EALREADY = syscall.Errno(0x25) + EAUTH = syscall.Errno(0x50) + EBADF = syscall.Errno(0x9) + EBADMSG = syscall.Errno(0x5c) + EBADRPC = syscall.Errno(0x48) + EBUSY = syscall.Errno(0x10) + ECANCELED = syscall.Errno(0x58) + ECHILD = syscall.Errno(0xa) + ECONNABORTED = syscall.Errno(0x35) + ECONNREFUSED = syscall.Errno(0x3d) + ECONNRESET = syscall.Errno(0x36) + EDEADLK = syscall.Errno(0xb) + EDESTADDRREQ = syscall.Errno(0x27) + EDOM = syscall.Errno(0x21) + EDQUOT = syscall.Errno(0x45) + EEXIST = syscall.Errno(0x11) + EFAULT = syscall.Errno(0xe) + EFBIG = syscall.Errno(0x1b) + EFTYPE = syscall.Errno(0x4f) + EHOSTDOWN = syscall.Errno(0x40) + EHOSTUNREACH = syscall.Errno(0x41) + EIDRM = syscall.Errno(0x59) + EILSEQ = syscall.Errno(0x54) + EINPROGRESS = syscall.Errno(0x24) + EINTR = syscall.Errno(0x4) + EINVAL = syscall.Errno(0x16) + EIO = syscall.Errno(0x5) + EIPSEC = syscall.Errno(0x52) + EISCONN = syscall.Errno(0x38) + EISDIR = syscall.Errno(0x15) + ELAST = syscall.Errno(0x5f) + ELOOP = syscall.Errno(0x3e) + EMEDIUMTYPE = syscall.Errno(0x56) + EMFILE = syscall.Errno(0x18) + EMLINK = syscall.Errno(0x1f) + EMSGSIZE = syscall.Errno(0x28) + ENAMETOOLONG = syscall.Errno(0x3f) + ENEEDAUTH = syscall.Errno(0x51) + ENETDOWN = syscall.Errno(0x32) + ENETRESET = syscall.Errno(0x34) + ENETUNREACH = syscall.Errno(0x33) + ENFILE = syscall.Errno(0x17) + ENOATTR = syscall.Errno(0x53) + ENOBUFS = syscall.Errno(0x37) + ENODEV = syscall.Errno(0x13) + ENOENT = syscall.Errno(0x2) + ENOEXEC = syscall.Errno(0x8) + ENOLCK = syscall.Errno(0x4d) + ENOMEDIUM = syscall.Errno(0x55) + ENOMEM = syscall.Errno(0xc) + ENOMSG = syscall.Errno(0x5a) + ENOPROTOOPT = syscall.Errno(0x2a) + ENOSPC = syscall.Errno(0x1c) + ENOSYS = syscall.Errno(0x4e) + ENOTBLK = syscall.Errno(0xf) + ENOTCONN = syscall.Errno(0x39) + ENOTDIR = syscall.Errno(0x14) + ENOTEMPTY = syscall.Errno(0x42) + ENOTRECOVERABLE = syscall.Errno(0x5d) + ENOTSOCK = syscall.Errno(0x26) + ENOTSUP = syscall.Errno(0x5b) + ENOTTY = syscall.Errno(0x19) + ENXIO = syscall.Errno(0x6) + EOPNOTSUPP = syscall.Errno(0x2d) + EOVERFLOW = syscall.Errno(0x57) + EOWNERDEAD = syscall.Errno(0x5e) + EPERM = syscall.Errno(0x1) + EPFNOSUPPORT = syscall.Errno(0x2e) + EPIPE = syscall.Errno(0x20) + EPROCLIM = syscall.Errno(0x43) + EPROCUNAVAIL = syscall.Errno(0x4c) + EPROGMISMATCH = syscall.Errno(0x4b) + EPROGUNAVAIL = syscall.Errno(0x4a) + EPROTO = syscall.Errno(0x5f) + EPROTONOSUPPORT = syscall.Errno(0x2b) + EPROTOTYPE = syscall.Errno(0x29) + ERANGE = syscall.Errno(0x22) + EREMOTE = syscall.Errno(0x47) + EROFS = syscall.Errno(0x1e) + ERPCMISMATCH = syscall.Errno(0x49) + ESHUTDOWN = syscall.Errno(0x3a) + ESOCKTNOSUPPORT = syscall.Errno(0x2c) + ESPIPE = syscall.Errno(0x1d) + ESRCH = syscall.Errno(0x3) + ESTALE = syscall.Errno(0x46) + ETIMEDOUT = syscall.Errno(0x3c) + ETOOMANYREFS = syscall.Errno(0x3b) + ETXTBSY = syscall.Errno(0x1a) + EUSERS = syscall.Errno(0x44) + EWOULDBLOCK = syscall.Errno(0x23) + EXDEV = syscall.Errno(0x12) +) + +// Signals +const ( + SIGABRT = syscall.Signal(0x6) + SIGALRM = syscall.Signal(0xe) + SIGBUS = syscall.Signal(0xa) + SIGCHLD = syscall.Signal(0x14) + SIGCONT = syscall.Signal(0x13) + SIGEMT = syscall.Signal(0x7) + SIGFPE = syscall.Signal(0x8) + SIGHUP = syscall.Signal(0x1) + SIGILL = syscall.Signal(0x4) + SIGINFO = syscall.Signal(0x1d) + SIGINT = syscall.Signal(0x2) + SIGIO = syscall.Signal(0x17) + SIGIOT = syscall.Signal(0x6) + SIGKILL = syscall.Signal(0x9) + SIGPIPE = syscall.Signal(0xd) + SIGPROF = syscall.Signal(0x1b) + SIGQUIT = syscall.Signal(0x3) + SIGSEGV = syscall.Signal(0xb) + SIGSTOP = syscall.Signal(0x11) + SIGSYS = syscall.Signal(0xc) + SIGTERM = syscall.Signal(0xf) + SIGTHR = syscall.Signal(0x20) + SIGTRAP = syscall.Signal(0x5) + SIGTSTP = syscall.Signal(0x12) + SIGTTIN = syscall.Signal(0x15) + SIGTTOU = syscall.Signal(0x16) + SIGURG = syscall.Signal(0x10) + SIGUSR1 = syscall.Signal(0x1e) + SIGUSR2 = syscall.Signal(0x1f) + SIGVTALRM = syscall.Signal(0x1a) + SIGWINCH = syscall.Signal(0x1c) + SIGXCPU = syscall.Signal(0x18) + SIGXFSZ = syscall.Signal(0x19) +) + +// Error table +var errorList = [...]struct { + num syscall.Errno + name string + desc string +}{ + {1, "EPERM", "operation not permitted"}, + {2, "ENOENT", "no such file or directory"}, + {3, "ESRCH", "no such process"}, + {4, "EINTR", "interrupted system call"}, + {5, "EIO", "input/output error"}, + {6, "ENXIO", "device not configured"}, + {7, "E2BIG", "argument list too long"}, + {8, "ENOEXEC", "exec format error"}, + {9, "EBADF", "bad file descriptor"}, + {10, "ECHILD", "no child processes"}, + {11, "EDEADLK", "resource deadlock avoided"}, + {12, "ENOMEM", "cannot allocate memory"}, + {13, "EACCES", "permission denied"}, + {14, "EFAULT", "bad address"}, + {15, "ENOTBLK", "block device required"}, + {16, "EBUSY", "device busy"}, + {17, "EEXIST", "file exists"}, + {18, "EXDEV", "cross-device link"}, + {19, "ENODEV", "operation not supported by device"}, + {20, "ENOTDIR", "not a directory"}, + {21, "EISDIR", "is a directory"}, + {22, "EINVAL", "invalid argument"}, + {23, "ENFILE", "too many open files in system"}, + {24, "EMFILE", "too many open files"}, + {25, "ENOTTY", "inappropriate ioctl for device"}, + {26, "ETXTBSY", "text file busy"}, + {27, "EFBIG", "file too large"}, + {28, "ENOSPC", "no space left on device"}, + {29, "ESPIPE", "illegal seek"}, + {30, "EROFS", "read-only file system"}, + {31, "EMLINK", "too many links"}, + {32, "EPIPE", "broken pipe"}, + {33, "EDOM", "numerical argument out of domain"}, + {34, "ERANGE", "result too large"}, + {35, "EAGAIN", "resource temporarily unavailable"}, + {36, "EINPROGRESS", "operation now in progress"}, + {37, "EALREADY", "operation already in progress"}, + {38, "ENOTSOCK", "socket operation on non-socket"}, + {39, "EDESTADDRREQ", "destination address required"}, + {40, "EMSGSIZE", "message too long"}, + {41, "EPROTOTYPE", "protocol wrong type for socket"}, + {42, "ENOPROTOOPT", "protocol not available"}, + {43, "EPROTONOSUPPORT", "protocol not supported"}, + {44, "ESOCKTNOSUPPORT", "socket type not supported"}, + {45, "EOPNOTSUPP", "operation not supported"}, + {46, "EPFNOSUPPORT", "protocol family not supported"}, + {47, "EAFNOSUPPORT", "address family not supported by protocol family"}, + {48, "EADDRINUSE", "address already in use"}, + {49, "EADDRNOTAVAIL", "can't assign requested address"}, + {50, "ENETDOWN", "network is down"}, + {51, "ENETUNREACH", "network is unreachable"}, + {52, "ENETRESET", "network dropped connection on reset"}, + {53, "ECONNABORTED", "software caused connection abort"}, + {54, "ECONNRESET", "connection reset by peer"}, + {55, "ENOBUFS", "no buffer space available"}, + {56, "EISCONN", "socket is already connected"}, + {57, "ENOTCONN", "socket is not connected"}, + {58, "ESHUTDOWN", "can't send after socket shutdown"}, + {59, "ETOOMANYREFS", "too many references: can't splice"}, + {60, "ETIMEDOUT", "operation timed out"}, + {61, "ECONNREFUSED", "connection refused"}, + {62, "ELOOP", "too many levels of symbolic links"}, + {63, "ENAMETOOLONG", "file name too long"}, + {64, "EHOSTDOWN", "host is down"}, + {65, "EHOSTUNREACH", "no route to host"}, + {66, "ENOTEMPTY", "directory not empty"}, + {67, "EPROCLIM", "too many processes"}, + {68, "EUSERS", "too many users"}, + {69, "EDQUOT", "disk quota exceeded"}, + {70, "ESTALE", "stale NFS file handle"}, + {71, "EREMOTE", "too many levels of remote in path"}, + {72, "EBADRPC", "RPC struct is bad"}, + {73, "ERPCMISMATCH", "RPC version wrong"}, + {74, "EPROGUNAVAIL", "RPC program not available"}, + {75, "EPROGMISMATCH", "program version wrong"}, + {76, "EPROCUNAVAIL", "bad procedure for program"}, + {77, "ENOLCK", "no locks available"}, + {78, "ENOSYS", "function not implemented"}, + {79, "EFTYPE", "inappropriate file type or format"}, + {80, "EAUTH", "authentication error"}, + {81, "ENEEDAUTH", "need authenticator"}, + {82, "EIPSEC", "IPsec processing failure"}, + {83, "ENOATTR", "attribute not found"}, + {84, "EILSEQ", "illegal byte sequence"}, + {85, "ENOMEDIUM", "no medium found"}, + {86, "EMEDIUMTYPE", "wrong medium type"}, + {87, "EOVERFLOW", "value too large to be stored in data type"}, + {88, "ECANCELED", "operation canceled"}, + {89, "EIDRM", "identifier removed"}, + {90, "ENOMSG", "no message of desired type"}, + {91, "ENOTSUP", "not supported"}, + {92, "EBADMSG", "bad message"}, + {93, "ENOTRECOVERABLE", "state not recoverable"}, + {94, "EOWNERDEAD", "previous owner died"}, + {95, "ELAST", "protocol error"}, +} + +// Signal table +var signalList = [...]struct { + num syscall.Signal + name string + desc string +}{ + {1, "SIGHUP", "hangup"}, + {2, "SIGINT", "interrupt"}, + {3, "SIGQUIT", "quit"}, + {4, "SIGILL", "illegal instruction"}, + {5, "SIGTRAP", "trace/BPT trap"}, + {6, "SIGABRT", "abort trap"}, + {7, "SIGEMT", "EMT trap"}, + {8, "SIGFPE", "floating point exception"}, + {9, "SIGKILL", "killed"}, + {10, "SIGBUS", "bus error"}, + {11, "SIGSEGV", "segmentation fault"}, + {12, "SIGSYS", "bad system call"}, + {13, "SIGPIPE", "broken pipe"}, + {14, "SIGALRM", "alarm clock"}, + {15, "SIGTERM", "terminated"}, + {16, "SIGURG", "urgent I/O condition"}, + {17, "SIGSTOP", "suspended (signal)"}, + {18, "SIGTSTP", "suspended"}, + {19, "SIGCONT", "continued"}, + {20, "SIGCHLD", "child exited"}, + {21, "SIGTTIN", "stopped (tty input)"}, + {22, "SIGTTOU", "stopped (tty output)"}, + {23, "SIGIO", "I/O possible"}, + {24, "SIGXCPU", "cputime limit exceeded"}, + {25, "SIGXFSZ", "filesize limit exceeded"}, + {26, "SIGVTALRM", "virtual timer expired"}, + {27, "SIGPROF", "profiling timer expired"}, + {28, "SIGWINCH", "window size changes"}, + {29, "SIGINFO", "information request"}, + {30, "SIGUSR1", "user defined signal 1"}, + {31, "SIGUSR2", "user defined signal 2"}, + {32, "SIGTHR", "thread AST"}, +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.go deleted file mode 100644 index a06eb09324..0000000000 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.go +++ /dev/null @@ -1,40 +0,0 @@ -// go run mksyscall.go -tags darwin,amd64,go1.13 syscall_darwin.1_13.go -// Code generated by the command above; see README.md. DO NOT EDIT. - -//go:build darwin && amd64 && go1.13 -// +build darwin,amd64,go1.13 - -package unix - -import ( - "syscall" - "unsafe" -) - -var _ syscall.Errno - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func closedir(dir uintptr) (err error) { - _, _, e1 := syscall_syscall(libc_closedir_trampoline_addr, uintptr(dir), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -var libc_closedir_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { - r0, _, _ := syscall_syscall(libc_readdir_r_trampoline_addr, uintptr(dir), uintptr(unsafe.Pointer(entry)), uintptr(unsafe.Pointer(result))) - res = Errno(r0) - return -} - -var libc_readdir_r_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.s deleted file mode 100644 index f5bb40eda9..0000000000 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.s +++ /dev/null @@ -1,25 +0,0 @@ -// go run mkasm.go darwin amd64 -// Code generated by the command above; DO NOT EDIT. - -//go:build go1.13 -// +build go1.13 - -#include "textflag.h" - -TEXT libc_fdopendir_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_fdopendir(SB) - -GLOBL ·libc_fdopendir_trampoline_addr(SB), RODATA, $8 -DATA ·libc_fdopendir_trampoline_addr(SB)/8, $libc_fdopendir_trampoline<>(SB) - -TEXT libc_closedir_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_closedir(SB) - -GLOBL ·libc_closedir_trampoline_addr(SB), RODATA, $8 -DATA ·libc_closedir_trampoline_addr(SB)/8, $libc_closedir_trampoline<>(SB) - -TEXT libc_readdir_r_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_readdir_r(SB) - -GLOBL ·libc_readdir_r_trampoline_addr(SB), RODATA, $8 -DATA ·libc_readdir_r_trampoline_addr(SB)/8, $libc_readdir_r_trampoline<>(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index 467deed763..c2461c4967 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -1,8 +1,8 @@ -// go run mksyscall.go -tags darwin,amd64,go1.12 syscall_bsd.go syscall_darwin.go syscall_darwin_amd64.go +// go run mksyscall.go -tags darwin,amd64 syscall_bsd.go syscall_darwin.go syscall_darwin_amd64.go // Code generated by the command above; see README.md. DO NOT EDIT. -//go:build darwin && amd64 && go1.12 -// +build darwin,amd64,go1.12 +//go:build darwin && amd64 +// +build darwin,amd64 package unix @@ -463,6 +463,32 @@ var libc_munlockall_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func closedir(dir uintptr) (err error) { + _, _, e1 := syscall_syscall(libc_closedir_trampoline_addr, uintptr(dir), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_closedir_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { + r0, _, _ := syscall_syscall(libc_readdir_r_trampoline_addr, uintptr(dir), uintptr(unsafe.Pointer(entry)), uintptr(unsafe.Pointer(result))) + res = Errno(r0) + return +} + +var libc_readdir_r_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func pipe(p *[2]int32) (err error) { _, _, e1 := syscall_rawSyscall(libc_pipe_trampoline_addr, uintptr(unsafe.Pointer(p)), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index b41467a0e5..95fe4c0eb9 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -1,11 +1,14 @@ // go run mkasm.go darwin amd64 // Code generated by the command above; DO NOT EDIT. -//go:build go1.12 -// +build go1.12 - #include "textflag.h" +TEXT libc_fdopendir_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_fdopendir(SB) + +GLOBL ·libc_fdopendir_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fdopendir_trampoline_addr(SB)/8, $libc_fdopendir_trampoline<>(SB) + TEXT libc_getgroups_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_getgroups(SB) @@ -174,6 +177,18 @@ TEXT libc_munlockall_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_munlockall_trampoline_addr(SB), RODATA, $8 DATA ·libc_munlockall_trampoline_addr(SB)/8, $libc_munlockall_trampoline<>(SB) +TEXT libc_closedir_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_closedir(SB) + +GLOBL ·libc_closedir_trampoline_addr(SB), RODATA, $8 +DATA ·libc_closedir_trampoline_addr(SB)/8, $libc_closedir_trampoline<>(SB) + +TEXT libc_readdir_r_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_readdir_r(SB) + +GLOBL ·libc_readdir_r_trampoline_addr(SB), RODATA, $8 +DATA ·libc_readdir_r_trampoline_addr(SB)/8, $libc_readdir_r_trampoline<>(SB) + TEXT libc_pipe_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_pipe(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go deleted file mode 100644 index cec595d553..0000000000 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.go +++ /dev/null @@ -1,40 +0,0 @@ -// go run mksyscall.go -tags darwin,arm64,go1.13 syscall_darwin.1_13.go -// Code generated by the command above; see README.md. DO NOT EDIT. - -//go:build darwin && arm64 && go1.13 -// +build darwin,arm64,go1.13 - -package unix - -import ( - "syscall" - "unsafe" -) - -var _ syscall.Errno - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func closedir(dir uintptr) (err error) { - _, _, e1 := syscall_syscall(libc_closedir_trampoline_addr, uintptr(dir), 0, 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -var libc_closedir_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { - r0, _, _ := syscall_syscall(libc_readdir_r_trampoline_addr, uintptr(dir), uintptr(unsafe.Pointer(entry)), uintptr(unsafe.Pointer(result))) - res = Errno(r0) - return -} - -var libc_readdir_r_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.s deleted file mode 100644 index 0c3f76bc20..0000000000 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.s +++ /dev/null @@ -1,25 +0,0 @@ -// go run mkasm.go darwin arm64 -// Code generated by the command above; DO NOT EDIT. - -//go:build go1.13 -// +build go1.13 - -#include "textflag.h" - -TEXT libc_fdopendir_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_fdopendir(SB) - -GLOBL ·libc_fdopendir_trampoline_addr(SB), RODATA, $8 -DATA ·libc_fdopendir_trampoline_addr(SB)/8, $libc_fdopendir_trampoline<>(SB) - -TEXT libc_closedir_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_closedir(SB) - -GLOBL ·libc_closedir_trampoline_addr(SB), RODATA, $8 -DATA ·libc_closedir_trampoline_addr(SB)/8, $libc_closedir_trampoline<>(SB) - -TEXT libc_readdir_r_trampoline<>(SB),NOSPLIT,$0-0 - JMP libc_readdir_r(SB) - -GLOBL ·libc_readdir_r_trampoline_addr(SB), RODATA, $8 -DATA ·libc_readdir_r_trampoline_addr(SB)/8, $libc_readdir_r_trampoline<>(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 35938d34ff..26a0fdc505 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -1,8 +1,8 @@ -// go run mksyscall.go -tags darwin,arm64,go1.12 syscall_bsd.go syscall_darwin.go syscall_darwin_arm64.go +// go run mksyscall.go -tags darwin,arm64 syscall_bsd.go syscall_darwin.go syscall_darwin_arm64.go // Code generated by the command above; see README.md. DO NOT EDIT. -//go:build darwin && arm64 && go1.12 -// +build darwin,arm64,go1.12 +//go:build darwin && arm64 +// +build darwin,arm64 package unix @@ -463,6 +463,32 @@ var libc_munlockall_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func closedir(dir uintptr) (err error) { + _, _, e1 := syscall_syscall(libc_closedir_trampoline_addr, uintptr(dir), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_closedir_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_closedir closedir "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno) { + r0, _, _ := syscall_syscall(libc_readdir_r_trampoline_addr, uintptr(dir), uintptr(unsafe.Pointer(entry)), uintptr(unsafe.Pointer(result))) + res = Errno(r0) + return +} + +var libc_readdir_r_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_readdir_r readdir_r "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func pipe(p *[2]int32) (err error) { _, _, e1 := syscall_rawSyscall(libc_pipe_trampoline_addr, uintptr(unsafe.Pointer(p)), 0, 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index e1f9204a20..efa5b4c987 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -1,11 +1,14 @@ // go run mkasm.go darwin arm64 // Code generated by the command above; DO NOT EDIT. -//go:build go1.12 -// +build go1.12 - #include "textflag.h" +TEXT libc_fdopendir_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_fdopendir(SB) + +GLOBL ·libc_fdopendir_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fdopendir_trampoline_addr(SB)/8, $libc_fdopendir_trampoline<>(SB) + TEXT libc_getgroups_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_getgroups(SB) @@ -174,6 +177,18 @@ TEXT libc_munlockall_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_munlockall_trampoline_addr(SB), RODATA, $8 DATA ·libc_munlockall_trampoline_addr(SB)/8, $libc_munlockall_trampoline<>(SB) +TEXT libc_closedir_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_closedir(SB) + +GLOBL ·libc_closedir_trampoline_addr(SB), RODATA, $8 +DATA ·libc_closedir_trampoline_addr(SB)/8, $libc_closedir_trampoline<>(SB) + +TEXT libc_readdir_r_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_readdir_r(SB) + +GLOBL ·libc_readdir_r_trampoline_addr(SB), RODATA, $8 +DATA ·libc_readdir_r_trampoline_addr(SB)/8, $libc_readdir_r_trampoline<>(SB) + TEXT libc_pipe_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_pipe(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go index af5cb064ec..b57c7050d7 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go @@ -15,25 +15,19 @@ import ( //go:cgo_import_dynamic libc_writev writev "libc.so" //go:cgo_import_dynamic libc_pwritev pwritev "libc.so" //go:cgo_import_dynamic libc_accept4 accept4 "libsocket.so" -//go:cgo_import_dynamic libc_putmsg putmsg "libc.so" -//go:cgo_import_dynamic libc_getmsg getmsg "libc.so" //go:linkname procreadv libc_readv //go:linkname procpreadv libc_preadv //go:linkname procwritev libc_writev //go:linkname procpwritev libc_pwritev //go:linkname procaccept4 libc_accept4 -//go:linkname procputmsg libc_putmsg -//go:linkname procgetmsg libc_getmsg var ( procreadv, procpreadv, procwritev, procpwritev, - procaccept4, - procputmsg, - procgetmsg syscallFunc + procaccept4 syscallFunc ) // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -106,23 +100,3 @@ func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, } return } - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func putmsg(fd int, clptr *strbuf, dataptr *strbuf, flags int) (err error) { - _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procputmsg)), 4, uintptr(fd), uintptr(unsafe.Pointer(clptr)), uintptr(unsafe.Pointer(dataptr)), uintptr(flags), 0, 0) - if e1 != 0 { - err = e1 - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func getmsg(fd int, clptr *strbuf, dataptr *strbuf, flags *int) (err error) { - _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetmsg)), 4, uintptr(fd), uintptr(unsafe.Pointer(clptr)), uintptr(unsafe.Pointer(dataptr)), uintptr(unsafe.Pointer(flags)), 0, 0) - if e1 != 0 { - err = e1 - } - return -} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/vendor/golang.org/x/sys/unix/zsyscall_linux.go index bc4a275311..293cf36804 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -2151,3 +2151,13 @@ func setitimer(which int, newValue *Itimerval, oldValue *Itimerval) (err error) } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func rtSigprocmask(how int, set *Sigset_t, oldset *Sigset_t, sigsetsize uintptr) (err error) { + _, _, e1 := RawSyscall6(SYS_RT_SIGPROCMASK, uintptr(how), uintptr(unsafe.Pointer(set)), uintptr(unsafe.Pointer(oldset)), uintptr(sigsetsize), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go index 88af526b7e..c81b0ad477 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_386.go @@ -287,46 +287,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID32, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID32, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID32, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID32, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) { r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) n = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go index 2a0c4aa6a6..2206bce7f4 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_amd64.go @@ -334,36 +334,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrlimit(resource int, rlim *Rlimit) (err error) { _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) if e1 != 0 { @@ -374,16 +344,6 @@ func Setrlimit(resource int, rlim *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go index 4882bde3af..edf6b39f16 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm.go @@ -412,46 +412,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID32, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID32, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID32, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID32, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go index 9f8c24e434..190609f214 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_arm64.go @@ -289,36 +289,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func setrlimit(resource int, rlim *Rlimit) (err error) { _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) if e1 != 0 { @@ -329,16 +299,6 @@ func setrlimit(resource int, rlim *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go index 523f2ba03e..806ffd1e12 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_loong64.go @@ -223,46 +223,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go index d7d6f42441..5f984cbb1c 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips.go @@ -248,46 +248,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go index 7f1f8e6533..46fc380a40 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64.go @@ -278,36 +278,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrlimit(resource int, rlim *Rlimit) (err error) { _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) if e1 != 0 { @@ -318,16 +288,6 @@ func Setrlimit(resource int, rlim *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go index f933d0f51a..cbd0d4dadb 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mips64le.go @@ -278,36 +278,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrlimit(resource int, rlim *Rlimit) (err error) { _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) if e1 != 0 { @@ -318,16 +288,6 @@ func Setrlimit(resource int, rlim *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go index 297d0a9982..0c13d15f07 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_mipsle.go @@ -248,46 +248,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go index 2e32e7a449..e01432aed5 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc.go @@ -308,46 +308,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go index 3c53170464..13c7ee7baf 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64.go @@ -349,36 +349,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrlimit(resource int, rlim *Rlimit) (err error) { _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) if e1 != 0 { @@ -389,16 +359,6 @@ func Setrlimit(resource int, rlim *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go index a00c6744ec..02d0c0fd61 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_ppc64le.go @@ -349,36 +349,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrlimit(resource int, rlim *Rlimit) (err error) { _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) if e1 != 0 { @@ -389,16 +359,6 @@ func Setrlimit(resource int, rlim *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go index 1239cc2de9..9fee3b1d23 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_riscv64.go @@ -269,36 +269,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrlimit(resource int, rlim *Rlimit) (err error) { _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) if e1 != 0 { @@ -309,16 +279,6 @@ func Setrlimit(resource int, rlim *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go index e0dabc6027..647bbfecd6 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_s390x.go @@ -319,36 +319,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrlimit(resource int, rlim *Rlimit) (err error) { _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) if e1 != 0 { @@ -359,16 +329,6 @@ func Setrlimit(resource int, rlim *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags)) n = int64(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go index 368623c0f2..ada057f891 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go @@ -329,36 +329,6 @@ func setfsuid(uid int) (prev int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setregid(rgid int, egid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresgid(rgid int, egid int, sgid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - -func Setresuid(ruid int, euid int, suid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Setrlimit(resource int, rlim *Rlimit) (err error) { _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0) if e1 != 0 { @@ -369,16 +339,6 @@ func Setrlimit(resource int, rlim *Rlimit) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Setreuid(ruid int, euid int) (err error) { - _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Shutdown(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go new file mode 100644 index 0000000000..c85de2d976 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -0,0 +1,2221 @@ +// go run mksyscall.go -openbsd -libc -tags openbsd,ppc64 syscall_bsd.go syscall_openbsd.go syscall_openbsd_ppc64.go +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build openbsd && ppc64 +// +build openbsd,ppc64 + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := syscall_rawSyscall(libc_getgroups_trampoline_addr, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getgroups_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getgroups getgroups "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setgroups_trampoline_addr, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setgroups_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setgroups setgroups "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := syscall_syscall6(libc_wait4_trampoline_addr, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_wait4_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_wait4 wait4 "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := syscall_syscall(libc_accept_trampoline_addr, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_accept_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_accept accept "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := syscall_syscall(libc_bind_trampoline_addr, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_bind_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_bind bind "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := syscall_syscall(libc_connect_trampoline_addr, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_connect_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_connect connect "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := syscall_rawSyscall(libc_socket_trampoline_addr, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_socket_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_socket socket "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := syscall_syscall6(libc_getsockopt_trampoline_addr, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getsockopt_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getsockopt getsockopt "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := syscall_syscall6(libc_setsockopt_trampoline_addr, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setsockopt_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setsockopt setsockopt "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := syscall_rawSyscall(libc_getpeername_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getpeername_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getpeername getpeername "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := syscall_rawSyscall(libc_getsockname_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getsockname_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getsockname getsockname "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := syscall_syscall(libc_shutdown_trampoline_addr, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_shutdown_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_shutdown shutdown "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := syscall_rawSyscall6(libc_socketpair_trampoline_addr, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_socketpair_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_socketpair socketpair "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall6(libc_recvfrom_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_recvfrom_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_recvfrom recvfrom "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall6(libc_sendto_trampoline_addr, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_sendto_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_sendto sendto "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_recvmsg_trampoline_addr, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_recvmsg_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_recvmsg recvmsg "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_sendmsg_trampoline_addr, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_sendmsg_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_sendmsg sendmsg "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := syscall_syscall6(libc_kevent_trampoline_addr, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_kevent_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_kevent kevent "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_utimes_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_utimes_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_utimes utimes "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := syscall_syscall(libc_futimes_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_futimes_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_futimes futimes "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_poll_trampoline_addr, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_poll_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_poll poll "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall(libc_madvise_trampoline_addr, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_madvise_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_madvise madvise "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall(libc_mlock_trampoline_addr, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mlock_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mlock mlock "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := syscall_syscall(libc_mlockall_trampoline_addr, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mlockall_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mlockall mlockall "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall(libc_mprotect_trampoline_addr, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mprotect_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mprotect mprotect "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall(libc_msync_trampoline_addr, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_msync_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_msync msync "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall(libc_munlock_trampoline_addr, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_munlock_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_munlock munlock "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := syscall_syscall(libc_munlockall_trampoline_addr, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_munlockall_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_munlockall munlockall "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_pipe2_trampoline_addr, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pipe2_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pipe2 pipe2 "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(libc_getdents_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getdents_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getdents getdents "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(libc_getcwd_trampoline_addr, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getcwd_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getcwd getcwd "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ioctl(fd int, req uint, arg uintptr) (err error) { + _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_ioctl_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_ioctl ioctl "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall6(libc_sysctl_trampoline_addr, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_sysctl_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_sysctl sysctl "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { + r0, _, e1 := syscall_syscall6(libc_ppoll_trampoline_addr, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_ppoll_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_ppoll ppoll "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_access_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_access_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_access access "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := syscall_syscall(libc_adjtime_trampoline_addr, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_adjtime_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_adjtime adjtime "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_chdir_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_chdir_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_chdir chdir "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_chflags_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_chflags_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_chflags chflags "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_chmod_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_chmod_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_chmod chmod "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_chown_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_chown_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_chown chown "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_chroot_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_chroot_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_chroot chroot "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := syscall_syscall(libc_close_trampoline_addr, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_close_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_close close "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := syscall_syscall(libc_dup_trampoline_addr, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_dup_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_dup dup "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := syscall_syscall(libc_dup2_trampoline_addr, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_dup2_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_dup2 dup2 "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(from int, to int, flags int) (err error) { + _, _, e1 := syscall_syscall(libc_dup3_trampoline_addr, uintptr(from), uintptr(to), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_dup3_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_dup3 dup3 "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + syscall_syscall(libc_exit_trampoline_addr, uintptr(code), 0, 0) + return +} + +var libc_exit_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_exit exit "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_faccessat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_faccessat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_faccessat faccessat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := syscall_syscall(libc_fchdir_trampoline_addr, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fchdir_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fchdir fchdir "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := syscall_syscall(libc_fchflags_trampoline_addr, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fchflags_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fchflags fchflags "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := syscall_syscall(libc_fchmod_trampoline_addr, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fchmod_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fchmod fchmod "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_fchmodat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fchmodat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fchmodat fchmodat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := syscall_syscall(libc_fchown_trampoline_addr, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fchown_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fchown fchown "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_fchownat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fchownat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fchownat fchownat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := syscall_syscall(libc_flock_trampoline_addr, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_flock_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_flock flock "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := syscall_syscall(libc_fpathconf_trampoline_addr, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fpathconf_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fpathconf fpathconf "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := syscall_syscall(libc_fstat_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fstat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fstat fstat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_fstatat_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fstatat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fstatat fstatat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + _, _, e1 := syscall_syscall(libc_fstatfs_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fstatfs_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fstatfs fstatfs "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := syscall_syscall(libc_fsync_trampoline_addr, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fsync_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fsync fsync "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := syscall_syscall(libc_ftruncate_trampoline_addr, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_ftruncate_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_ftruncate ftruncate "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := syscall_rawSyscall(libc_getegid_trampoline_addr, 0, 0, 0) + egid = int(r0) + return +} + +var libc_getegid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getegid getegid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := syscall_rawSyscall(libc_geteuid_trampoline_addr, 0, 0, 0) + uid = int(r0) + return +} + +var libc_geteuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_geteuid geteuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := syscall_rawSyscall(libc_getgid_trampoline_addr, 0, 0, 0) + gid = int(r0) + return +} + +var libc_getgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getgid getgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := syscall_rawSyscall(libc_getpgid_trampoline_addr, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getpgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getpgid getpgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := syscall_rawSyscall(libc_getpgrp_trampoline_addr, 0, 0, 0) + pgrp = int(r0) + return +} + +var libc_getpgrp_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getpgrp getpgrp "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := syscall_rawSyscall(libc_getpid_trampoline_addr, 0, 0, 0) + pid = int(r0) + return +} + +var libc_getpid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getpid getpid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := syscall_rawSyscall(libc_getppid_trampoline_addr, 0, 0, 0) + ppid = int(r0) + return +} + +var libc_getppid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getppid getppid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := syscall_syscall(libc_getpriority_trampoline_addr, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getpriority_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getpriority getpriority "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := syscall_rawSyscall(libc_getrlimit_trampoline_addr, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getrlimit_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getrlimit getrlimit "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrtable() (rtable int, err error) { + r0, _, e1 := syscall_rawSyscall(libc_getrtable_trampoline_addr, 0, 0, 0) + rtable = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getrtable_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getrtable getrtable "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := syscall_rawSyscall(libc_getrusage_trampoline_addr, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getrusage_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getrusage getrusage "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := syscall_rawSyscall(libc_getsid_trampoline_addr, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getsid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getsid getsid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := syscall_rawSyscall(libc_gettimeofday_trampoline_addr, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_gettimeofday_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_gettimeofday gettimeofday "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := syscall_rawSyscall(libc_getuid_trampoline_addr, 0, 0, 0) + uid = int(r0) + return +} + +var libc_getuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getuid getuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := syscall_syscall(libc_issetugid_trampoline_addr, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +var libc_issetugid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_issetugid issetugid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, signum syscall.Signal) (err error) { + _, _, e1 := syscall_syscall(libc_kill_trampoline_addr, uintptr(pid), uintptr(signum), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_kill_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_kill kill "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := syscall_syscall(libc_kqueue_trampoline_addr, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_kqueue_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_kqueue kqueue "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_lchown_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_lchown_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_lchown lchown "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_link_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_link_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_link link "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_linkat_trampoline_addr, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_linkat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_linkat linkat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := syscall_syscall(libc_listen_trampoline_addr, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_listen_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_listen listen "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_lstat_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_lstat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_lstat lstat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_mkdir_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mkdir_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mkdir mkdir "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_mkdirat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mkdirat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mkdirat mkdirat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_mkfifo_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mkfifo_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mkfifo mkfifo "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifoat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_mkfifoat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mkfifoat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mkfifoat mkfifoat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_mknod_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mknod_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mknod mknod "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mknodat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mknodat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mknodat mknodat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_nanosleep_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_nanosleep nanosleep "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := syscall_syscall(libc_open_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_open_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_open open "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := syscall_syscall6(libc_openat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_openat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_openat openat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := syscall_syscall(libc_pathconf_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pathconf_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pathconf pathconf "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall6(libc_pread_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pread_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pread pread "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall6(libc_pwrite_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pwrite_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pwrite pwrite "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(libc_read_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_read_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_read read "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(libc_readlink_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_readlink_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_readlink readlink "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall6(libc_readlinkat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_readlinkat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_readlinkat readlinkat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_rename_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_rename_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_rename rename "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(fromfd int, from string, tofd int, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameat_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameat renameat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_revoke_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_revoke_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_revoke revoke "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_rmdir_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_rmdir_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_rmdir rmdir "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, _, e1 := syscall_syscall(libc_lseek_trampoline_addr, uintptr(fd), uintptr(offset), uintptr(whence)) + newoffset = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_lseek_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_lseek lseek "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := syscall_syscall6(libc_select_trampoline_addr, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_select_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_select select "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setegid_trampoline_addr, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setegid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setegid setegid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_seteuid_trampoline_addr, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_seteuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_seteuid seteuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setgid_trampoline_addr, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setgid setgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setlogin(name string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_setlogin_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setlogin_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setlogin setlogin "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setpgid_trampoline_addr, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setpgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setpgid setpgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := syscall_syscall(libc_setpriority_trampoline_addr, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setpriority_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setpriority setpriority "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setregid_trampoline_addr, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setregid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setregid setregid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setreuid_trampoline_addr, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setreuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setreuid setreuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setresgid_trampoline_addr, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setresgid setresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setresuid_trampoline_addr, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setresuid setresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setrlimit_trampoline_addr, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setrlimit_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrtable(rtable int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setrtable_trampoline_addr, uintptr(rtable), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setrtable_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setrtable setrtable "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := syscall_rawSyscall(libc_setsid_trampoline_addr, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setsid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setsid setsid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := syscall_rawSyscall(libc_settimeofday_trampoline_addr, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_settimeofday_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_settimeofday settimeofday "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setuid_trampoline_addr, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setuid setuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_stat_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_stat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_stat stat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, stat *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_statfs_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_statfs_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_statfs statfs "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_symlink_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_symlink_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_symlink symlink "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_symlinkat_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_symlinkat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_symlinkat symlinkat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := syscall_syscall(libc_sync_trampoline_addr, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_sync_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_sync sync "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_truncate_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_truncate_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_truncate truncate "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := syscall_syscall(libc_umask_trampoline_addr, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +var libc_umask_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_umask umask "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_unlink_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_unlink_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_unlink unlink "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_unlinkat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_unlinkat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_unlinkat unlinkat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_unmount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_unmount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_unmount unmount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(libc_write_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_write_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_write write "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := syscall_syscall6(libc_mmap_trampoline_addr, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mmap_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mmap mmap "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := syscall_syscall(libc_munmap_trampoline_addr, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_munmap_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_munmap munmap "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_read_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_write_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_utimensat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_utimensat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_utimensat utimensat "libc.so" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s new file mode 100644 index 0000000000..7c9223b641 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s @@ -0,0 +1,796 @@ +// go run mkasm.go openbsd ppc64 +// Code generated by the command above; DO NOT EDIT. + +#include "textflag.h" + +TEXT libc_getgroups_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getgroups(SB) + RET +GLOBL ·libc_getgroups_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getgroups_trampoline_addr(SB)/8, $libc_getgroups_trampoline<>(SB) + +TEXT libc_setgroups_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setgroups(SB) + RET +GLOBL ·libc_setgroups_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setgroups_trampoline_addr(SB)/8, $libc_setgroups_trampoline<>(SB) + +TEXT libc_wait4_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_wait4(SB) + RET +GLOBL ·libc_wait4_trampoline_addr(SB), RODATA, $8 +DATA ·libc_wait4_trampoline_addr(SB)/8, $libc_wait4_trampoline<>(SB) + +TEXT libc_accept_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_accept(SB) + RET +GLOBL ·libc_accept_trampoline_addr(SB), RODATA, $8 +DATA ·libc_accept_trampoline_addr(SB)/8, $libc_accept_trampoline<>(SB) + +TEXT libc_bind_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_bind(SB) + RET +GLOBL ·libc_bind_trampoline_addr(SB), RODATA, $8 +DATA ·libc_bind_trampoline_addr(SB)/8, $libc_bind_trampoline<>(SB) + +TEXT libc_connect_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_connect(SB) + RET +GLOBL ·libc_connect_trampoline_addr(SB), RODATA, $8 +DATA ·libc_connect_trampoline_addr(SB)/8, $libc_connect_trampoline<>(SB) + +TEXT libc_socket_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_socket(SB) + RET +GLOBL ·libc_socket_trampoline_addr(SB), RODATA, $8 +DATA ·libc_socket_trampoline_addr(SB)/8, $libc_socket_trampoline<>(SB) + +TEXT libc_getsockopt_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getsockopt(SB) + RET +GLOBL ·libc_getsockopt_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getsockopt_trampoline_addr(SB)/8, $libc_getsockopt_trampoline<>(SB) + +TEXT libc_setsockopt_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setsockopt(SB) + RET +GLOBL ·libc_setsockopt_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setsockopt_trampoline_addr(SB)/8, $libc_setsockopt_trampoline<>(SB) + +TEXT libc_getpeername_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getpeername(SB) + RET +GLOBL ·libc_getpeername_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getpeername_trampoline_addr(SB)/8, $libc_getpeername_trampoline<>(SB) + +TEXT libc_getsockname_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getsockname(SB) + RET +GLOBL ·libc_getsockname_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getsockname_trampoline_addr(SB)/8, $libc_getsockname_trampoline<>(SB) + +TEXT libc_shutdown_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_shutdown(SB) + RET +GLOBL ·libc_shutdown_trampoline_addr(SB), RODATA, $8 +DATA ·libc_shutdown_trampoline_addr(SB)/8, $libc_shutdown_trampoline<>(SB) + +TEXT libc_socketpair_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_socketpair(SB) + RET +GLOBL ·libc_socketpair_trampoline_addr(SB), RODATA, $8 +DATA ·libc_socketpair_trampoline_addr(SB)/8, $libc_socketpair_trampoline<>(SB) + +TEXT libc_recvfrom_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_recvfrom(SB) + RET +GLOBL ·libc_recvfrom_trampoline_addr(SB), RODATA, $8 +DATA ·libc_recvfrom_trampoline_addr(SB)/8, $libc_recvfrom_trampoline<>(SB) + +TEXT libc_sendto_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_sendto(SB) + RET +GLOBL ·libc_sendto_trampoline_addr(SB), RODATA, $8 +DATA ·libc_sendto_trampoline_addr(SB)/8, $libc_sendto_trampoline<>(SB) + +TEXT libc_recvmsg_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_recvmsg(SB) + RET +GLOBL ·libc_recvmsg_trampoline_addr(SB), RODATA, $8 +DATA ·libc_recvmsg_trampoline_addr(SB)/8, $libc_recvmsg_trampoline<>(SB) + +TEXT libc_sendmsg_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_sendmsg(SB) + RET +GLOBL ·libc_sendmsg_trampoline_addr(SB), RODATA, $8 +DATA ·libc_sendmsg_trampoline_addr(SB)/8, $libc_sendmsg_trampoline<>(SB) + +TEXT libc_kevent_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_kevent(SB) + RET +GLOBL ·libc_kevent_trampoline_addr(SB), RODATA, $8 +DATA ·libc_kevent_trampoline_addr(SB)/8, $libc_kevent_trampoline<>(SB) + +TEXT libc_utimes_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_utimes(SB) + RET +GLOBL ·libc_utimes_trampoline_addr(SB), RODATA, $8 +DATA ·libc_utimes_trampoline_addr(SB)/8, $libc_utimes_trampoline<>(SB) + +TEXT libc_futimes_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_futimes(SB) + RET +GLOBL ·libc_futimes_trampoline_addr(SB), RODATA, $8 +DATA ·libc_futimes_trampoline_addr(SB)/8, $libc_futimes_trampoline<>(SB) + +TEXT libc_poll_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_poll(SB) + RET +GLOBL ·libc_poll_trampoline_addr(SB), RODATA, $8 +DATA ·libc_poll_trampoline_addr(SB)/8, $libc_poll_trampoline<>(SB) + +TEXT libc_madvise_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_madvise(SB) + RET +GLOBL ·libc_madvise_trampoline_addr(SB), RODATA, $8 +DATA ·libc_madvise_trampoline_addr(SB)/8, $libc_madvise_trampoline<>(SB) + +TEXT libc_mlock_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mlock(SB) + RET +GLOBL ·libc_mlock_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mlock_trampoline_addr(SB)/8, $libc_mlock_trampoline<>(SB) + +TEXT libc_mlockall_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mlockall(SB) + RET +GLOBL ·libc_mlockall_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mlockall_trampoline_addr(SB)/8, $libc_mlockall_trampoline<>(SB) + +TEXT libc_mprotect_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mprotect(SB) + RET +GLOBL ·libc_mprotect_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mprotect_trampoline_addr(SB)/8, $libc_mprotect_trampoline<>(SB) + +TEXT libc_msync_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_msync(SB) + RET +GLOBL ·libc_msync_trampoline_addr(SB), RODATA, $8 +DATA ·libc_msync_trampoline_addr(SB)/8, $libc_msync_trampoline<>(SB) + +TEXT libc_munlock_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_munlock(SB) + RET +GLOBL ·libc_munlock_trampoline_addr(SB), RODATA, $8 +DATA ·libc_munlock_trampoline_addr(SB)/8, $libc_munlock_trampoline<>(SB) + +TEXT libc_munlockall_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_munlockall(SB) + RET +GLOBL ·libc_munlockall_trampoline_addr(SB), RODATA, $8 +DATA ·libc_munlockall_trampoline_addr(SB)/8, $libc_munlockall_trampoline<>(SB) + +TEXT libc_pipe2_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_pipe2(SB) + RET +GLOBL ·libc_pipe2_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pipe2_trampoline_addr(SB)/8, $libc_pipe2_trampoline<>(SB) + +TEXT libc_getdents_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getdents(SB) + RET +GLOBL ·libc_getdents_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getdents_trampoline_addr(SB)/8, $libc_getdents_trampoline<>(SB) + +TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getcwd(SB) + RET +GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getcwd_trampoline_addr(SB)/8, $libc_getcwd_trampoline<>(SB) + +TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_ioctl(SB) + RET +GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 +DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) + +TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_sysctl(SB) + RET +GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 +DATA ·libc_sysctl_trampoline_addr(SB)/8, $libc_sysctl_trampoline<>(SB) + +TEXT libc_ppoll_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_ppoll(SB) + RET +GLOBL ·libc_ppoll_trampoline_addr(SB), RODATA, $8 +DATA ·libc_ppoll_trampoline_addr(SB)/8, $libc_ppoll_trampoline<>(SB) + +TEXT libc_access_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_access(SB) + RET +GLOBL ·libc_access_trampoline_addr(SB), RODATA, $8 +DATA ·libc_access_trampoline_addr(SB)/8, $libc_access_trampoline<>(SB) + +TEXT libc_adjtime_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_adjtime(SB) + RET +GLOBL ·libc_adjtime_trampoline_addr(SB), RODATA, $8 +DATA ·libc_adjtime_trampoline_addr(SB)/8, $libc_adjtime_trampoline<>(SB) + +TEXT libc_chdir_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_chdir(SB) + RET +GLOBL ·libc_chdir_trampoline_addr(SB), RODATA, $8 +DATA ·libc_chdir_trampoline_addr(SB)/8, $libc_chdir_trampoline<>(SB) + +TEXT libc_chflags_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_chflags(SB) + RET +GLOBL ·libc_chflags_trampoline_addr(SB), RODATA, $8 +DATA ·libc_chflags_trampoline_addr(SB)/8, $libc_chflags_trampoline<>(SB) + +TEXT libc_chmod_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_chmod(SB) + RET +GLOBL ·libc_chmod_trampoline_addr(SB), RODATA, $8 +DATA ·libc_chmod_trampoline_addr(SB)/8, $libc_chmod_trampoline<>(SB) + +TEXT libc_chown_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_chown(SB) + RET +GLOBL ·libc_chown_trampoline_addr(SB), RODATA, $8 +DATA ·libc_chown_trampoline_addr(SB)/8, $libc_chown_trampoline<>(SB) + +TEXT libc_chroot_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_chroot(SB) + RET +GLOBL ·libc_chroot_trampoline_addr(SB), RODATA, $8 +DATA ·libc_chroot_trampoline_addr(SB)/8, $libc_chroot_trampoline<>(SB) + +TEXT libc_close_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_close(SB) + RET +GLOBL ·libc_close_trampoline_addr(SB), RODATA, $8 +DATA ·libc_close_trampoline_addr(SB)/8, $libc_close_trampoline<>(SB) + +TEXT libc_dup_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_dup(SB) + RET +GLOBL ·libc_dup_trampoline_addr(SB), RODATA, $8 +DATA ·libc_dup_trampoline_addr(SB)/8, $libc_dup_trampoline<>(SB) + +TEXT libc_dup2_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_dup2(SB) + RET +GLOBL ·libc_dup2_trampoline_addr(SB), RODATA, $8 +DATA ·libc_dup2_trampoline_addr(SB)/8, $libc_dup2_trampoline<>(SB) + +TEXT libc_dup3_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_dup3(SB) + RET +GLOBL ·libc_dup3_trampoline_addr(SB), RODATA, $8 +DATA ·libc_dup3_trampoline_addr(SB)/8, $libc_dup3_trampoline<>(SB) + +TEXT libc_exit_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_exit(SB) + RET +GLOBL ·libc_exit_trampoline_addr(SB), RODATA, $8 +DATA ·libc_exit_trampoline_addr(SB)/8, $libc_exit_trampoline<>(SB) + +TEXT libc_faccessat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_faccessat(SB) + RET +GLOBL ·libc_faccessat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_faccessat_trampoline_addr(SB)/8, $libc_faccessat_trampoline<>(SB) + +TEXT libc_fchdir_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_fchdir(SB) + RET +GLOBL ·libc_fchdir_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fchdir_trampoline_addr(SB)/8, $libc_fchdir_trampoline<>(SB) + +TEXT libc_fchflags_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_fchflags(SB) + RET +GLOBL ·libc_fchflags_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fchflags_trampoline_addr(SB)/8, $libc_fchflags_trampoline<>(SB) + +TEXT libc_fchmod_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_fchmod(SB) + RET +GLOBL ·libc_fchmod_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fchmod_trampoline_addr(SB)/8, $libc_fchmod_trampoline<>(SB) + +TEXT libc_fchmodat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_fchmodat(SB) + RET +GLOBL ·libc_fchmodat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fchmodat_trampoline_addr(SB)/8, $libc_fchmodat_trampoline<>(SB) + +TEXT libc_fchown_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_fchown(SB) + RET +GLOBL ·libc_fchown_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fchown_trampoline_addr(SB)/8, $libc_fchown_trampoline<>(SB) + +TEXT libc_fchownat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_fchownat(SB) + RET +GLOBL ·libc_fchownat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fchownat_trampoline_addr(SB)/8, $libc_fchownat_trampoline<>(SB) + +TEXT libc_flock_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_flock(SB) + RET +GLOBL ·libc_flock_trampoline_addr(SB), RODATA, $8 +DATA ·libc_flock_trampoline_addr(SB)/8, $libc_flock_trampoline<>(SB) + +TEXT libc_fpathconf_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_fpathconf(SB) + RET +GLOBL ·libc_fpathconf_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fpathconf_trampoline_addr(SB)/8, $libc_fpathconf_trampoline<>(SB) + +TEXT libc_fstat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_fstat(SB) + RET +GLOBL ·libc_fstat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fstat_trampoline_addr(SB)/8, $libc_fstat_trampoline<>(SB) + +TEXT libc_fstatat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_fstatat(SB) + RET +GLOBL ·libc_fstatat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fstatat_trampoline_addr(SB)/8, $libc_fstatat_trampoline<>(SB) + +TEXT libc_fstatfs_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_fstatfs(SB) + RET +GLOBL ·libc_fstatfs_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fstatfs_trampoline_addr(SB)/8, $libc_fstatfs_trampoline<>(SB) + +TEXT libc_fsync_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_fsync(SB) + RET +GLOBL ·libc_fsync_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fsync_trampoline_addr(SB)/8, $libc_fsync_trampoline<>(SB) + +TEXT libc_ftruncate_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_ftruncate(SB) + RET +GLOBL ·libc_ftruncate_trampoline_addr(SB), RODATA, $8 +DATA ·libc_ftruncate_trampoline_addr(SB)/8, $libc_ftruncate_trampoline<>(SB) + +TEXT libc_getegid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getegid(SB) + RET +GLOBL ·libc_getegid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getegid_trampoline_addr(SB)/8, $libc_getegid_trampoline<>(SB) + +TEXT libc_geteuid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_geteuid(SB) + RET +GLOBL ·libc_geteuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_geteuid_trampoline_addr(SB)/8, $libc_geteuid_trampoline<>(SB) + +TEXT libc_getgid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getgid(SB) + RET +GLOBL ·libc_getgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getgid_trampoline_addr(SB)/8, $libc_getgid_trampoline<>(SB) + +TEXT libc_getpgid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getpgid(SB) + RET +GLOBL ·libc_getpgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getpgid_trampoline_addr(SB)/8, $libc_getpgid_trampoline<>(SB) + +TEXT libc_getpgrp_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getpgrp(SB) + RET +GLOBL ·libc_getpgrp_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getpgrp_trampoline_addr(SB)/8, $libc_getpgrp_trampoline<>(SB) + +TEXT libc_getpid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getpid(SB) + RET +GLOBL ·libc_getpid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getpid_trampoline_addr(SB)/8, $libc_getpid_trampoline<>(SB) + +TEXT libc_getppid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getppid(SB) + RET +GLOBL ·libc_getppid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getppid_trampoline_addr(SB)/8, $libc_getppid_trampoline<>(SB) + +TEXT libc_getpriority_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getpriority(SB) + RET +GLOBL ·libc_getpriority_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getpriority_trampoline_addr(SB)/8, $libc_getpriority_trampoline<>(SB) + +TEXT libc_getrlimit_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getrlimit(SB) + RET +GLOBL ·libc_getrlimit_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getrlimit_trampoline_addr(SB)/8, $libc_getrlimit_trampoline<>(SB) + +TEXT libc_getrtable_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getrtable(SB) + RET +GLOBL ·libc_getrtable_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getrtable_trampoline_addr(SB)/8, $libc_getrtable_trampoline<>(SB) + +TEXT libc_getrusage_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getrusage(SB) + RET +GLOBL ·libc_getrusage_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getrusage_trampoline_addr(SB)/8, $libc_getrusage_trampoline<>(SB) + +TEXT libc_getsid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getsid(SB) + RET +GLOBL ·libc_getsid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getsid_trampoline_addr(SB)/8, $libc_getsid_trampoline<>(SB) + +TEXT libc_gettimeofday_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_gettimeofday(SB) + RET +GLOBL ·libc_gettimeofday_trampoline_addr(SB), RODATA, $8 +DATA ·libc_gettimeofday_trampoline_addr(SB)/8, $libc_gettimeofday_trampoline<>(SB) + +TEXT libc_getuid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getuid(SB) + RET +GLOBL ·libc_getuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getuid_trampoline_addr(SB)/8, $libc_getuid_trampoline<>(SB) + +TEXT libc_issetugid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_issetugid(SB) + RET +GLOBL ·libc_issetugid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_issetugid_trampoline_addr(SB)/8, $libc_issetugid_trampoline<>(SB) + +TEXT libc_kill_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_kill(SB) + RET +GLOBL ·libc_kill_trampoline_addr(SB), RODATA, $8 +DATA ·libc_kill_trampoline_addr(SB)/8, $libc_kill_trampoline<>(SB) + +TEXT libc_kqueue_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_kqueue(SB) + RET +GLOBL ·libc_kqueue_trampoline_addr(SB), RODATA, $8 +DATA ·libc_kqueue_trampoline_addr(SB)/8, $libc_kqueue_trampoline<>(SB) + +TEXT libc_lchown_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_lchown(SB) + RET +GLOBL ·libc_lchown_trampoline_addr(SB), RODATA, $8 +DATA ·libc_lchown_trampoline_addr(SB)/8, $libc_lchown_trampoline<>(SB) + +TEXT libc_link_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_link(SB) + RET +GLOBL ·libc_link_trampoline_addr(SB), RODATA, $8 +DATA ·libc_link_trampoline_addr(SB)/8, $libc_link_trampoline<>(SB) + +TEXT libc_linkat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_linkat(SB) + RET +GLOBL ·libc_linkat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_linkat_trampoline_addr(SB)/8, $libc_linkat_trampoline<>(SB) + +TEXT libc_listen_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_listen(SB) + RET +GLOBL ·libc_listen_trampoline_addr(SB), RODATA, $8 +DATA ·libc_listen_trampoline_addr(SB)/8, $libc_listen_trampoline<>(SB) + +TEXT libc_lstat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_lstat(SB) + RET +GLOBL ·libc_lstat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_lstat_trampoline_addr(SB)/8, $libc_lstat_trampoline<>(SB) + +TEXT libc_mkdir_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mkdir(SB) + RET +GLOBL ·libc_mkdir_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mkdir_trampoline_addr(SB)/8, $libc_mkdir_trampoline<>(SB) + +TEXT libc_mkdirat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mkdirat(SB) + RET +GLOBL ·libc_mkdirat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mkdirat_trampoline_addr(SB)/8, $libc_mkdirat_trampoline<>(SB) + +TEXT libc_mkfifo_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mkfifo(SB) + RET +GLOBL ·libc_mkfifo_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mkfifo_trampoline_addr(SB)/8, $libc_mkfifo_trampoline<>(SB) + +TEXT libc_mkfifoat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mkfifoat(SB) + RET +GLOBL ·libc_mkfifoat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mkfifoat_trampoline_addr(SB)/8, $libc_mkfifoat_trampoline<>(SB) + +TEXT libc_mknod_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mknod(SB) + RET +GLOBL ·libc_mknod_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mknod_trampoline_addr(SB)/8, $libc_mknod_trampoline<>(SB) + +TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mknodat(SB) + RET +GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) + +TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_nanosleep(SB) + RET +GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 +DATA ·libc_nanosleep_trampoline_addr(SB)/8, $libc_nanosleep_trampoline<>(SB) + +TEXT libc_open_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_open(SB) + RET +GLOBL ·libc_open_trampoline_addr(SB), RODATA, $8 +DATA ·libc_open_trampoline_addr(SB)/8, $libc_open_trampoline<>(SB) + +TEXT libc_openat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_openat(SB) + RET +GLOBL ·libc_openat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_openat_trampoline_addr(SB)/8, $libc_openat_trampoline<>(SB) + +TEXT libc_pathconf_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_pathconf(SB) + RET +GLOBL ·libc_pathconf_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pathconf_trampoline_addr(SB)/8, $libc_pathconf_trampoline<>(SB) + +TEXT libc_pread_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_pread(SB) + RET +GLOBL ·libc_pread_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pread_trampoline_addr(SB)/8, $libc_pread_trampoline<>(SB) + +TEXT libc_pwrite_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_pwrite(SB) + RET +GLOBL ·libc_pwrite_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pwrite_trampoline_addr(SB)/8, $libc_pwrite_trampoline<>(SB) + +TEXT libc_read_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_read(SB) + RET +GLOBL ·libc_read_trampoline_addr(SB), RODATA, $8 +DATA ·libc_read_trampoline_addr(SB)/8, $libc_read_trampoline<>(SB) + +TEXT libc_readlink_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_readlink(SB) + RET +GLOBL ·libc_readlink_trampoline_addr(SB), RODATA, $8 +DATA ·libc_readlink_trampoline_addr(SB)/8, $libc_readlink_trampoline<>(SB) + +TEXT libc_readlinkat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_readlinkat(SB) + RET +GLOBL ·libc_readlinkat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_readlinkat_trampoline_addr(SB)/8, $libc_readlinkat_trampoline<>(SB) + +TEXT libc_rename_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_rename(SB) + RET +GLOBL ·libc_rename_trampoline_addr(SB), RODATA, $8 +DATA ·libc_rename_trampoline_addr(SB)/8, $libc_rename_trampoline<>(SB) + +TEXT libc_renameat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_renameat(SB) + RET +GLOBL ·libc_renameat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameat_trampoline_addr(SB)/8, $libc_renameat_trampoline<>(SB) + +TEXT libc_revoke_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_revoke(SB) + RET +GLOBL ·libc_revoke_trampoline_addr(SB), RODATA, $8 +DATA ·libc_revoke_trampoline_addr(SB)/8, $libc_revoke_trampoline<>(SB) + +TEXT libc_rmdir_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_rmdir(SB) + RET +GLOBL ·libc_rmdir_trampoline_addr(SB), RODATA, $8 +DATA ·libc_rmdir_trampoline_addr(SB)/8, $libc_rmdir_trampoline<>(SB) + +TEXT libc_lseek_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_lseek(SB) + RET +GLOBL ·libc_lseek_trampoline_addr(SB), RODATA, $8 +DATA ·libc_lseek_trampoline_addr(SB)/8, $libc_lseek_trampoline<>(SB) + +TEXT libc_select_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_select(SB) + RET +GLOBL ·libc_select_trampoline_addr(SB), RODATA, $8 +DATA ·libc_select_trampoline_addr(SB)/8, $libc_select_trampoline<>(SB) + +TEXT libc_setegid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setegid(SB) + RET +GLOBL ·libc_setegid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setegid_trampoline_addr(SB)/8, $libc_setegid_trampoline<>(SB) + +TEXT libc_seteuid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_seteuid(SB) + RET +GLOBL ·libc_seteuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_seteuid_trampoline_addr(SB)/8, $libc_seteuid_trampoline<>(SB) + +TEXT libc_setgid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setgid(SB) + RET +GLOBL ·libc_setgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setgid_trampoline_addr(SB)/8, $libc_setgid_trampoline<>(SB) + +TEXT libc_setlogin_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setlogin(SB) + RET +GLOBL ·libc_setlogin_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setlogin_trampoline_addr(SB)/8, $libc_setlogin_trampoline<>(SB) + +TEXT libc_setpgid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setpgid(SB) + RET +GLOBL ·libc_setpgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setpgid_trampoline_addr(SB)/8, $libc_setpgid_trampoline<>(SB) + +TEXT libc_setpriority_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setpriority(SB) + RET +GLOBL ·libc_setpriority_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setpriority_trampoline_addr(SB)/8, $libc_setpriority_trampoline<>(SB) + +TEXT libc_setregid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setregid(SB) + RET +GLOBL ·libc_setregid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setregid_trampoline_addr(SB)/8, $libc_setregid_trampoline<>(SB) + +TEXT libc_setreuid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setreuid(SB) + RET +GLOBL ·libc_setreuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setreuid_trampoline_addr(SB)/8, $libc_setreuid_trampoline<>(SB) + +TEXT libc_setresgid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setresgid(SB) + RET +GLOBL ·libc_setresgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setresgid_trampoline_addr(SB)/8, $libc_setresgid_trampoline<>(SB) + +TEXT libc_setresuid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setresuid(SB) + RET +GLOBL ·libc_setresuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setresuid_trampoline_addr(SB)/8, $libc_setresuid_trampoline<>(SB) + +TEXT libc_setrlimit_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setrlimit(SB) + RET +GLOBL ·libc_setrlimit_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setrlimit_trampoline_addr(SB)/8, $libc_setrlimit_trampoline<>(SB) + +TEXT libc_setrtable_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setrtable(SB) + RET +GLOBL ·libc_setrtable_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setrtable_trampoline_addr(SB)/8, $libc_setrtable_trampoline<>(SB) + +TEXT libc_setsid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setsid(SB) + RET +GLOBL ·libc_setsid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setsid_trampoline_addr(SB)/8, $libc_setsid_trampoline<>(SB) + +TEXT libc_settimeofday_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_settimeofday(SB) + RET +GLOBL ·libc_settimeofday_trampoline_addr(SB), RODATA, $8 +DATA ·libc_settimeofday_trampoline_addr(SB)/8, $libc_settimeofday_trampoline<>(SB) + +TEXT libc_setuid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_setuid(SB) + RET +GLOBL ·libc_setuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setuid_trampoline_addr(SB)/8, $libc_setuid_trampoline<>(SB) + +TEXT libc_stat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_stat(SB) + RET +GLOBL ·libc_stat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_stat_trampoline_addr(SB)/8, $libc_stat_trampoline<>(SB) + +TEXT libc_statfs_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_statfs(SB) + RET +GLOBL ·libc_statfs_trampoline_addr(SB), RODATA, $8 +DATA ·libc_statfs_trampoline_addr(SB)/8, $libc_statfs_trampoline<>(SB) + +TEXT libc_symlink_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_symlink(SB) + RET +GLOBL ·libc_symlink_trampoline_addr(SB), RODATA, $8 +DATA ·libc_symlink_trampoline_addr(SB)/8, $libc_symlink_trampoline<>(SB) + +TEXT libc_symlinkat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_symlinkat(SB) + RET +GLOBL ·libc_symlinkat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_symlinkat_trampoline_addr(SB)/8, $libc_symlinkat_trampoline<>(SB) + +TEXT libc_sync_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_sync(SB) + RET +GLOBL ·libc_sync_trampoline_addr(SB), RODATA, $8 +DATA ·libc_sync_trampoline_addr(SB)/8, $libc_sync_trampoline<>(SB) + +TEXT libc_truncate_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_truncate(SB) + RET +GLOBL ·libc_truncate_trampoline_addr(SB), RODATA, $8 +DATA ·libc_truncate_trampoline_addr(SB)/8, $libc_truncate_trampoline<>(SB) + +TEXT libc_umask_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_umask(SB) + RET +GLOBL ·libc_umask_trampoline_addr(SB), RODATA, $8 +DATA ·libc_umask_trampoline_addr(SB)/8, $libc_umask_trampoline<>(SB) + +TEXT libc_unlink_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_unlink(SB) + RET +GLOBL ·libc_unlink_trampoline_addr(SB), RODATA, $8 +DATA ·libc_unlink_trampoline_addr(SB)/8, $libc_unlink_trampoline<>(SB) + +TEXT libc_unlinkat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_unlinkat(SB) + RET +GLOBL ·libc_unlinkat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_unlinkat_trampoline_addr(SB)/8, $libc_unlinkat_trampoline<>(SB) + +TEXT libc_unmount_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_unmount(SB) + RET +GLOBL ·libc_unmount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_unmount_trampoline_addr(SB)/8, $libc_unmount_trampoline<>(SB) + +TEXT libc_write_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_write(SB) + RET +GLOBL ·libc_write_trampoline_addr(SB), RODATA, $8 +DATA ·libc_write_trampoline_addr(SB)/8, $libc_write_trampoline<>(SB) + +TEXT libc_mmap_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mmap(SB) + RET +GLOBL ·libc_mmap_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mmap_trampoline_addr(SB)/8, $libc_mmap_trampoline<>(SB) + +TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_munmap(SB) + RET +GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $8 +DATA ·libc_munmap_trampoline_addr(SB)/8, $libc_munmap_trampoline<>(SB) + +TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_utimensat(SB) + RET +GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_utimensat_trampoline_addr(SB)/8, $libc_utimensat_trampoline<>(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go new file mode 100644 index 0000000000..8e3e7873f8 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -0,0 +1,2221 @@ +// go run mksyscall.go -openbsd -libc -tags openbsd,riscv64 syscall_bsd.go syscall_openbsd.go syscall_openbsd_riscv64.go +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build openbsd && riscv64 +// +build openbsd,riscv64 + +package unix + +import ( + "syscall" + "unsafe" +) + +var _ syscall.Errno + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getgroups(ngid int, gid *_Gid_t) (n int, err error) { + r0, _, e1 := syscall_rawSyscall(libc_getgroups_trampoline_addr, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getgroups_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getgroups getgroups "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setgroups(ngid int, gid *_Gid_t) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setgroups_trampoline_addr, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setgroups_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setgroups setgroups "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { + r0, _, e1 := syscall_syscall6(libc_wait4_trampoline_addr, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) + wpid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_wait4_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_wait4 wait4 "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { + r0, _, e1 := syscall_syscall(libc_accept_trampoline_addr, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_accept_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_accept accept "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := syscall_syscall(libc_bind_trampoline_addr, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_bind_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_bind bind "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { + _, _, e1 := syscall_syscall(libc_connect_trampoline_addr, uintptr(s), uintptr(addr), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_connect_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_connect connect "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socket(domain int, typ int, proto int) (fd int, err error) { + r0, _, e1 := syscall_rawSyscall(libc_socket_trampoline_addr, uintptr(domain), uintptr(typ), uintptr(proto)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_socket_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_socket socket "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { + _, _, e1 := syscall_syscall6(libc_getsockopt_trampoline_addr, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getsockopt_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getsockopt getsockopt "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { + _, _, e1 := syscall_syscall6(libc_setsockopt_trampoline_addr, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setsockopt_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setsockopt setsockopt "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := syscall_rawSyscall(libc_getpeername_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getpeername_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getpeername getpeername "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { + _, _, e1 := syscall_rawSyscall(libc_getsockname_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getsockname_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getsockname getsockname "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Shutdown(s int, how int) (err error) { + _, _, e1 := syscall_syscall(libc_shutdown_trampoline_addr, uintptr(s), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_shutdown_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_shutdown shutdown "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { + _, _, e1 := syscall_rawSyscall6(libc_socketpair_trampoline_addr, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_socketpair_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_socketpair socketpair "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall6(libc_recvfrom_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_recvfrom_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_recvfrom recvfrom "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall6(libc_sendto_trampoline_addr, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_sendto_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_sendto sendto "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_recvmsg_trampoline_addr, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_recvmsg_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_recvmsg recvmsg "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_sendmsg_trampoline_addr, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_sendmsg_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_sendmsg sendmsg "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { + r0, _, e1 := syscall_syscall6(libc_kevent_trampoline_addr, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_kevent_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_kevent kevent "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimes(path string, timeval *[2]Timeval) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_utimes_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_utimes_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_utimes utimes "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func futimes(fd int, timeval *[2]Timeval) (err error) { + _, _, e1 := syscall_syscall(libc_futimes_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_futimes_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_futimes futimes "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_poll_trampoline_addr, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_poll_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_poll poll "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Madvise(b []byte, behav int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall(libc_madvise_trampoline_addr, uintptr(_p0), uintptr(len(b)), uintptr(behav)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_madvise_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_madvise madvise "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall(libc_mlock_trampoline_addr, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mlock_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mlock mlock "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mlockall(flags int) (err error) { + _, _, e1 := syscall_syscall(libc_mlockall_trampoline_addr, uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mlockall_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mlockall mlockall "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mprotect(b []byte, prot int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall(libc_mprotect_trampoline_addr, uintptr(_p0), uintptr(len(b)), uintptr(prot)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mprotect_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mprotect mprotect "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Msync(b []byte, flags int) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall(libc_msync_trampoline_addr, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_msync_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_msync msync "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlock(b []byte) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall(libc_munlock_trampoline_addr, uintptr(_p0), uintptr(len(b)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_munlock_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_munlock munlock "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Munlockall() (err error) { + _, _, e1 := syscall_syscall(libc_munlockall_trampoline_addr, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_munlockall_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_munlockall munlockall "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pipe2(p *[2]_C_int, flags int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_pipe2_trampoline_addr, uintptr(unsafe.Pointer(p)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pipe2_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pipe2 pipe2 "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getdents(fd int, buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(libc_getdents_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getdents_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getdents getdents "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(libc_getcwd_trampoline_addr, uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getcwd_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getcwd getcwd "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ioctl(fd int, req uint, arg uintptr) (err error) { + _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_ioctl_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_ioctl ioctl "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { + var _p0 unsafe.Pointer + if len(mib) > 0 { + _p0 = unsafe.Pointer(&mib[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall6(libc_sysctl_trampoline_addr, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_sysctl_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_sysctl sysctl "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error) { + r0, _, e1 := syscall_syscall6(libc_ppoll_trampoline_addr, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(unsafe.Pointer(timeout)), uintptr(unsafe.Pointer(sigmask)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_ppoll_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_ppoll ppoll "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Access(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_access_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_access_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_access access "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { + _, _, e1 := syscall_syscall(libc_adjtime_trampoline_addr, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_adjtime_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_adjtime adjtime "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_chdir_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_chdir_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_chdir chdir "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chflags(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_chflags_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_chflags_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_chflags chflags "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chmod(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_chmod_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_chmod_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_chmod chmod "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_chown_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_chown_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_chown chown "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Chroot(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_chroot_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_chroot_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_chroot chroot "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Close(fd int) (err error) { + _, _, e1 := syscall_syscall(libc_close_trampoline_addr, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_close_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_close close "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup(fd int) (nfd int, err error) { + r0, _, e1 := syscall_syscall(libc_dup_trampoline_addr, uintptr(fd), 0, 0) + nfd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_dup_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_dup dup "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup2(from int, to int) (err error) { + _, _, e1 := syscall_syscall(libc_dup2_trampoline_addr, uintptr(from), uintptr(to), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_dup2_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_dup2 dup2 "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Dup3(from int, to int, flags int) (err error) { + _, _, e1 := syscall_syscall(libc_dup3_trampoline_addr, uintptr(from), uintptr(to), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_dup3_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_dup3 dup3 "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Exit(code int) { + syscall_syscall(libc_exit_trampoline_addr, uintptr(code), 0, 0) + return +} + +var libc_exit_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_exit exit "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_faccessat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_faccessat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_faccessat faccessat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchdir(fd int) (err error) { + _, _, e1 := syscall_syscall(libc_fchdir_trampoline_addr, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fchdir_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fchdir fchdir "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchflags(fd int, flags int) (err error) { + _, _, e1 := syscall_syscall(libc_fchflags_trampoline_addr, uintptr(fd), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fchflags_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fchflags fchflags "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmod(fd int, mode uint32) (err error) { + _, _, e1 := syscall_syscall(libc_fchmod_trampoline_addr, uintptr(fd), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fchmod_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fchmod fchmod "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_fchmodat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fchmodat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fchmodat fchmodat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchown(fd int, uid int, gid int) (err error) { + _, _, e1 := syscall_syscall(libc_fchown_trampoline_addr, uintptr(fd), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fchown_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fchown fchown "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_fchownat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fchownat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fchownat fchownat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Flock(fd int, how int) (err error) { + _, _, e1 := syscall_syscall(libc_flock_trampoline_addr, uintptr(fd), uintptr(how), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_flock_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_flock flock "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fpathconf(fd int, name int) (val int, err error) { + r0, _, e1 := syscall_syscall(libc_fpathconf_trampoline_addr, uintptr(fd), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fpathconf_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fpathconf fpathconf "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstat(fd int, stat *Stat_t) (err error) { + _, _, e1 := syscall_syscall(libc_fstat_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fstat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fstat fstat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_fstatat_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fstatat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fstatat fstatat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fstatfs(fd int, stat *Statfs_t) (err error) { + _, _, e1 := syscall_syscall(libc_fstatfs_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fstatfs_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fstatfs fstatfs "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Fsync(fd int) (err error) { + _, _, e1 := syscall_syscall(libc_fsync_trampoline_addr, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_fsync_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_fsync fsync "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Ftruncate(fd int, length int64) (err error) { + _, _, e1 := syscall_syscall(libc_ftruncate_trampoline_addr, uintptr(fd), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_ftruncate_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_ftruncate ftruncate "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getegid() (egid int) { + r0, _, _ := syscall_rawSyscall(libc_getegid_trampoline_addr, 0, 0, 0) + egid = int(r0) + return +} + +var libc_getegid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getegid getegid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Geteuid() (uid int) { + r0, _, _ := syscall_rawSyscall(libc_geteuid_trampoline_addr, 0, 0, 0) + uid = int(r0) + return +} + +var libc_geteuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_geteuid geteuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getgid() (gid int) { + r0, _, _ := syscall_rawSyscall(libc_getgid_trampoline_addr, 0, 0, 0) + gid = int(r0) + return +} + +var libc_getgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getgid getgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgid(pid int) (pgid int, err error) { + r0, _, e1 := syscall_rawSyscall(libc_getpgid_trampoline_addr, uintptr(pid), 0, 0) + pgid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getpgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getpgid getpgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpgrp() (pgrp int) { + r0, _, _ := syscall_rawSyscall(libc_getpgrp_trampoline_addr, 0, 0, 0) + pgrp = int(r0) + return +} + +var libc_getpgrp_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getpgrp getpgrp "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpid() (pid int) { + r0, _, _ := syscall_rawSyscall(libc_getpid_trampoline_addr, 0, 0, 0) + pid = int(r0) + return +} + +var libc_getpid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getpid getpid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getppid() (ppid int) { + r0, _, _ := syscall_rawSyscall(libc_getppid_trampoline_addr, 0, 0, 0) + ppid = int(r0) + return +} + +var libc_getppid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getppid getppid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getpriority(which int, who int) (prio int, err error) { + r0, _, e1 := syscall_syscall(libc_getpriority_trampoline_addr, uintptr(which), uintptr(who), 0) + prio = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getpriority_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getpriority getpriority "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := syscall_rawSyscall(libc_getrlimit_trampoline_addr, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getrlimit_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getrlimit getrlimit "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrtable() (rtable int, err error) { + r0, _, e1 := syscall_rawSyscall(libc_getrtable_trampoline_addr, 0, 0, 0) + rtable = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getrtable_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getrtable getrtable "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getrusage(who int, rusage *Rusage) (err error) { + _, _, e1 := syscall_rawSyscall(libc_getrusage_trampoline_addr, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getrusage_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getrusage getrusage "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getsid(pid int) (sid int, err error) { + r0, _, e1 := syscall_rawSyscall(libc_getsid_trampoline_addr, uintptr(pid), 0, 0) + sid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_getsid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getsid getsid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Gettimeofday(tv *Timeval) (err error) { + _, _, e1 := syscall_rawSyscall(libc_gettimeofday_trampoline_addr, uintptr(unsafe.Pointer(tv)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_gettimeofday_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_gettimeofday gettimeofday "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Getuid() (uid int) { + r0, _, _ := syscall_rawSyscall(libc_getuid_trampoline_addr, 0, 0, 0) + uid = int(r0) + return +} + +var libc_getuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getuid getuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Issetugid() (tainted bool) { + r0, _, _ := syscall_syscall(libc_issetugid_trampoline_addr, 0, 0, 0) + tainted = bool(r0 != 0) + return +} + +var libc_issetugid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_issetugid issetugid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kill(pid int, signum syscall.Signal) (err error) { + _, _, e1 := syscall_syscall(libc_kill_trampoline_addr, uintptr(pid), uintptr(signum), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_kill_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_kill kill "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Kqueue() (fd int, err error) { + r0, _, e1 := syscall_syscall(libc_kqueue_trampoline_addr, 0, 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_kqueue_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_kqueue kqueue "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lchown(path string, uid int, gid int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_lchown_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_lchown_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_lchown lchown "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Link(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_link_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_link_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_link link "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_linkat_trampoline_addr, uintptr(pathfd), uintptr(unsafe.Pointer(_p0)), uintptr(linkfd), uintptr(unsafe.Pointer(_p1)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_linkat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_linkat linkat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Listen(s int, backlog int) (err error) { + _, _, e1 := syscall_syscall(libc_listen_trampoline_addr, uintptr(s), uintptr(backlog), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_listen_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_listen listen "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Lstat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_lstat_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_lstat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_lstat lstat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdir(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_mkdir_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mkdir_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mkdir mkdir "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkdirat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_mkdirat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mkdirat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mkdirat mkdirat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifo(path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_mkfifo_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mkfifo_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mkfifo mkfifo "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mkfifoat(dirfd int, path string, mode uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_mkfifoat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mkfifoat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mkfifoat mkfifoat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknod(path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_mknod_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mknod_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mknod mknod "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mknodat(dirfd int, path string, mode uint32, dev int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mknodat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mknodat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mknodat mknodat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Nanosleep(time *Timespec, leftover *Timespec) (err error) { + _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_nanosleep_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_nanosleep nanosleep "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Open(path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := syscall_syscall(libc_open_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_open_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_open open "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := syscall_syscall6(libc_openat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm), 0, 0) + fd = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_openat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_openat openat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Pathconf(path string, name int) (val int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + r0, _, e1 := syscall_syscall(libc_pathconf_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) + val = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pathconf_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pathconf pathconf "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pread(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall6(libc_pread_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pread_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pread pread "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pwrite(fd int, p []byte, offset int64) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall6(libc_pwrite_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pwrite_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pwrite pwrite "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func read(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(libc_read_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_read_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_read read "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlink(path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(libc_readlink_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_readlink_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_readlink readlink "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Readlinkat(dirfd int, path string, buf []byte) (n int, err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 unsafe.Pointer + if len(buf) > 0 { + _p1 = unsafe.Pointer(&buf[0]) + } else { + _p1 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall6(libc_readlinkat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)), 0, 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_readlinkat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_readlinkat readlinkat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rename(from string, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_rename_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_rename_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_rename rename "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Renameat(fromfd int, from string, tofd int, to string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameat_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameat renameat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Revoke(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_revoke_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_revoke_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_revoke revoke "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Rmdir(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_rmdir_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_rmdir_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_rmdir rmdir "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { + r0, _, e1 := syscall_syscall(libc_lseek_trampoline_addr, uintptr(fd), uintptr(offset), uintptr(whence)) + newoffset = int64(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_lseek_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_lseek lseek "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) { + r0, _, e1 := syscall_syscall6(libc_select_trampoline_addr, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_select_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_select select "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setegid(egid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setegid_trampoline_addr, uintptr(egid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setegid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setegid setegid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Seteuid(euid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_seteuid_trampoline_addr, uintptr(euid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_seteuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_seteuid seteuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setgid(gid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setgid_trampoline_addr, uintptr(gid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setgid setgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setlogin(name string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(name) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_setlogin_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setlogin_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setlogin setlogin "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpgid(pid int, pgid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setpgid_trampoline_addr, uintptr(pid), uintptr(pgid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setpgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setpgid setpgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setpriority(which int, who int, prio int) (err error) { + _, _, e1 := syscall_syscall(libc_setpriority_trampoline_addr, uintptr(which), uintptr(who), uintptr(prio)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setpriority_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setpriority setpriority "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setregid(rgid int, egid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setregid_trampoline_addr, uintptr(rgid), uintptr(egid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setregid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setregid setregid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setreuid(ruid int, euid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setreuid_trampoline_addr, uintptr(ruid), uintptr(euid), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setreuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setreuid setreuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresgid(rgid int, egid int, sgid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setresgid_trampoline_addr, uintptr(rgid), uintptr(egid), uintptr(sgid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setresgid setresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setresuid(ruid int, euid int, suid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setresuid_trampoline_addr, uintptr(ruid), uintptr(euid), uintptr(suid)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setresuid setresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrlimit(which int, lim *Rlimit) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setrlimit_trampoline_addr, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setrlimit_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setrtable(rtable int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setrtable_trampoline_addr, uintptr(rtable), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setrtable_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setrtable setrtable "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setsid() (pid int, err error) { + r0, _, e1 := syscall_rawSyscall(libc_setsid_trampoline_addr, 0, 0, 0) + pid = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setsid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setsid setsid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Settimeofday(tp *Timeval) (err error) { + _, _, e1 := syscall_rawSyscall(libc_settimeofday_trampoline_addr, uintptr(unsafe.Pointer(tp)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_settimeofday_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_settimeofday settimeofday "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Setuid(uid int) (err error) { + _, _, e1 := syscall_rawSyscall(libc_setuid_trampoline_addr, uintptr(uid), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_setuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_setuid setuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Stat(path string, stat *Stat_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_stat_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_stat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_stat stat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Statfs(path string, stat *Statfs_t) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_statfs_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_statfs_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_statfs statfs "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlink(path string, link string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(link) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_symlink_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_symlink_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_symlink symlink "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(oldpath) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(newpath) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_symlinkat_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1))) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_symlinkat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_symlinkat symlinkat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Sync() (err error) { + _, _, e1 := syscall_syscall(libc_sync_trampoline_addr, 0, 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_sync_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_sync sync "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Truncate(path string, length int64) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_truncate_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_truncate_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_truncate truncate "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Umask(newmask int) (oldmask int) { + r0, _, _ := syscall_syscall(libc_umask_trampoline_addr, uintptr(newmask), 0, 0) + oldmask = int(r0) + return +} + +var libc_umask_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_umask umask "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlink(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_unlink_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_unlink_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_unlink unlink "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unlinkat(dirfd int, path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_unlinkat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_unlinkat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_unlinkat unlinkat "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Unmount(path string, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_unmount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_unmount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_unmount unmount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func write(fd int, p []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(p) > 0 { + _p0 = unsafe.Pointer(&p[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(libc_write_trampoline_addr, uintptr(fd), uintptr(_p0), uintptr(len(p))) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_write_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_write write "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { + r0, _, e1 := syscall_syscall6(libc_mmap_trampoline_addr, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos)) + ret = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mmap_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mmap mmap "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func munmap(addr uintptr, length uintptr) (err error) { + _, _, e1 := syscall_syscall(libc_munmap_trampoline_addr, uintptr(addr), uintptr(length), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_munmap_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_munmap munmap "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func readlen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_read_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func writelen(fd int, buf *byte, nbuf int) (n int, err error) { + r0, _, e1 := syscall_syscall(libc_write_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_utimensat_trampoline_addr, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_utimensat_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_utimensat utimensat "libc.so" diff --git a/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s new file mode 100644 index 0000000000..7dba789271 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s @@ -0,0 +1,796 @@ +// go run mkasm.go openbsd riscv64 +// Code generated by the command above; DO NOT EDIT. + +#include "textflag.h" + +TEXT libc_getgroups_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getgroups(SB) + +GLOBL ·libc_getgroups_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getgroups_trampoline_addr(SB)/8, $libc_getgroups_trampoline<>(SB) + +TEXT libc_setgroups_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setgroups(SB) + +GLOBL ·libc_setgroups_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setgroups_trampoline_addr(SB)/8, $libc_setgroups_trampoline<>(SB) + +TEXT libc_wait4_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_wait4(SB) + +GLOBL ·libc_wait4_trampoline_addr(SB), RODATA, $8 +DATA ·libc_wait4_trampoline_addr(SB)/8, $libc_wait4_trampoline<>(SB) + +TEXT libc_accept_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_accept(SB) + +GLOBL ·libc_accept_trampoline_addr(SB), RODATA, $8 +DATA ·libc_accept_trampoline_addr(SB)/8, $libc_accept_trampoline<>(SB) + +TEXT libc_bind_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_bind(SB) + +GLOBL ·libc_bind_trampoline_addr(SB), RODATA, $8 +DATA ·libc_bind_trampoline_addr(SB)/8, $libc_bind_trampoline<>(SB) + +TEXT libc_connect_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_connect(SB) + +GLOBL ·libc_connect_trampoline_addr(SB), RODATA, $8 +DATA ·libc_connect_trampoline_addr(SB)/8, $libc_connect_trampoline<>(SB) + +TEXT libc_socket_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_socket(SB) + +GLOBL ·libc_socket_trampoline_addr(SB), RODATA, $8 +DATA ·libc_socket_trampoline_addr(SB)/8, $libc_socket_trampoline<>(SB) + +TEXT libc_getsockopt_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getsockopt(SB) + +GLOBL ·libc_getsockopt_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getsockopt_trampoline_addr(SB)/8, $libc_getsockopt_trampoline<>(SB) + +TEXT libc_setsockopt_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setsockopt(SB) + +GLOBL ·libc_setsockopt_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setsockopt_trampoline_addr(SB)/8, $libc_setsockopt_trampoline<>(SB) + +TEXT libc_getpeername_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getpeername(SB) + +GLOBL ·libc_getpeername_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getpeername_trampoline_addr(SB)/8, $libc_getpeername_trampoline<>(SB) + +TEXT libc_getsockname_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getsockname(SB) + +GLOBL ·libc_getsockname_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getsockname_trampoline_addr(SB)/8, $libc_getsockname_trampoline<>(SB) + +TEXT libc_shutdown_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_shutdown(SB) + +GLOBL ·libc_shutdown_trampoline_addr(SB), RODATA, $8 +DATA ·libc_shutdown_trampoline_addr(SB)/8, $libc_shutdown_trampoline<>(SB) + +TEXT libc_socketpair_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_socketpair(SB) + +GLOBL ·libc_socketpair_trampoline_addr(SB), RODATA, $8 +DATA ·libc_socketpair_trampoline_addr(SB)/8, $libc_socketpair_trampoline<>(SB) + +TEXT libc_recvfrom_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_recvfrom(SB) + +GLOBL ·libc_recvfrom_trampoline_addr(SB), RODATA, $8 +DATA ·libc_recvfrom_trampoline_addr(SB)/8, $libc_recvfrom_trampoline<>(SB) + +TEXT libc_sendto_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_sendto(SB) + +GLOBL ·libc_sendto_trampoline_addr(SB), RODATA, $8 +DATA ·libc_sendto_trampoline_addr(SB)/8, $libc_sendto_trampoline<>(SB) + +TEXT libc_recvmsg_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_recvmsg(SB) + +GLOBL ·libc_recvmsg_trampoline_addr(SB), RODATA, $8 +DATA ·libc_recvmsg_trampoline_addr(SB)/8, $libc_recvmsg_trampoline<>(SB) + +TEXT libc_sendmsg_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_sendmsg(SB) + +GLOBL ·libc_sendmsg_trampoline_addr(SB), RODATA, $8 +DATA ·libc_sendmsg_trampoline_addr(SB)/8, $libc_sendmsg_trampoline<>(SB) + +TEXT libc_kevent_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_kevent(SB) + +GLOBL ·libc_kevent_trampoline_addr(SB), RODATA, $8 +DATA ·libc_kevent_trampoline_addr(SB)/8, $libc_kevent_trampoline<>(SB) + +TEXT libc_utimes_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_utimes(SB) + +GLOBL ·libc_utimes_trampoline_addr(SB), RODATA, $8 +DATA ·libc_utimes_trampoline_addr(SB)/8, $libc_utimes_trampoline<>(SB) + +TEXT libc_futimes_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_futimes(SB) + +GLOBL ·libc_futimes_trampoline_addr(SB), RODATA, $8 +DATA ·libc_futimes_trampoline_addr(SB)/8, $libc_futimes_trampoline<>(SB) + +TEXT libc_poll_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_poll(SB) + +GLOBL ·libc_poll_trampoline_addr(SB), RODATA, $8 +DATA ·libc_poll_trampoline_addr(SB)/8, $libc_poll_trampoline<>(SB) + +TEXT libc_madvise_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_madvise(SB) + +GLOBL ·libc_madvise_trampoline_addr(SB), RODATA, $8 +DATA ·libc_madvise_trampoline_addr(SB)/8, $libc_madvise_trampoline<>(SB) + +TEXT libc_mlock_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mlock(SB) + +GLOBL ·libc_mlock_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mlock_trampoline_addr(SB)/8, $libc_mlock_trampoline<>(SB) + +TEXT libc_mlockall_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mlockall(SB) + +GLOBL ·libc_mlockall_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mlockall_trampoline_addr(SB)/8, $libc_mlockall_trampoline<>(SB) + +TEXT libc_mprotect_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mprotect(SB) + +GLOBL ·libc_mprotect_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mprotect_trampoline_addr(SB)/8, $libc_mprotect_trampoline<>(SB) + +TEXT libc_msync_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_msync(SB) + +GLOBL ·libc_msync_trampoline_addr(SB), RODATA, $8 +DATA ·libc_msync_trampoline_addr(SB)/8, $libc_msync_trampoline<>(SB) + +TEXT libc_munlock_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_munlock(SB) + +GLOBL ·libc_munlock_trampoline_addr(SB), RODATA, $8 +DATA ·libc_munlock_trampoline_addr(SB)/8, $libc_munlock_trampoline<>(SB) + +TEXT libc_munlockall_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_munlockall(SB) + +GLOBL ·libc_munlockall_trampoline_addr(SB), RODATA, $8 +DATA ·libc_munlockall_trampoline_addr(SB)/8, $libc_munlockall_trampoline<>(SB) + +TEXT libc_pipe2_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pipe2(SB) + +GLOBL ·libc_pipe2_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pipe2_trampoline_addr(SB)/8, $libc_pipe2_trampoline<>(SB) + +TEXT libc_getdents_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getdents(SB) + +GLOBL ·libc_getdents_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getdents_trampoline_addr(SB)/8, $libc_getdents_trampoline<>(SB) + +TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getcwd(SB) + +GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getcwd_trampoline_addr(SB)/8, $libc_getcwd_trampoline<>(SB) + +TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_ioctl(SB) + +GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 +DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) + +TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_sysctl(SB) + +GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 +DATA ·libc_sysctl_trampoline_addr(SB)/8, $libc_sysctl_trampoline<>(SB) + +TEXT libc_ppoll_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_ppoll(SB) + +GLOBL ·libc_ppoll_trampoline_addr(SB), RODATA, $8 +DATA ·libc_ppoll_trampoline_addr(SB)/8, $libc_ppoll_trampoline<>(SB) + +TEXT libc_access_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_access(SB) + +GLOBL ·libc_access_trampoline_addr(SB), RODATA, $8 +DATA ·libc_access_trampoline_addr(SB)/8, $libc_access_trampoline<>(SB) + +TEXT libc_adjtime_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_adjtime(SB) + +GLOBL ·libc_adjtime_trampoline_addr(SB), RODATA, $8 +DATA ·libc_adjtime_trampoline_addr(SB)/8, $libc_adjtime_trampoline<>(SB) + +TEXT libc_chdir_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_chdir(SB) + +GLOBL ·libc_chdir_trampoline_addr(SB), RODATA, $8 +DATA ·libc_chdir_trampoline_addr(SB)/8, $libc_chdir_trampoline<>(SB) + +TEXT libc_chflags_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_chflags(SB) + +GLOBL ·libc_chflags_trampoline_addr(SB), RODATA, $8 +DATA ·libc_chflags_trampoline_addr(SB)/8, $libc_chflags_trampoline<>(SB) + +TEXT libc_chmod_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_chmod(SB) + +GLOBL ·libc_chmod_trampoline_addr(SB), RODATA, $8 +DATA ·libc_chmod_trampoline_addr(SB)/8, $libc_chmod_trampoline<>(SB) + +TEXT libc_chown_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_chown(SB) + +GLOBL ·libc_chown_trampoline_addr(SB), RODATA, $8 +DATA ·libc_chown_trampoline_addr(SB)/8, $libc_chown_trampoline<>(SB) + +TEXT libc_chroot_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_chroot(SB) + +GLOBL ·libc_chroot_trampoline_addr(SB), RODATA, $8 +DATA ·libc_chroot_trampoline_addr(SB)/8, $libc_chroot_trampoline<>(SB) + +TEXT libc_close_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_close(SB) + +GLOBL ·libc_close_trampoline_addr(SB), RODATA, $8 +DATA ·libc_close_trampoline_addr(SB)/8, $libc_close_trampoline<>(SB) + +TEXT libc_dup_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_dup(SB) + +GLOBL ·libc_dup_trampoline_addr(SB), RODATA, $8 +DATA ·libc_dup_trampoline_addr(SB)/8, $libc_dup_trampoline<>(SB) + +TEXT libc_dup2_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_dup2(SB) + +GLOBL ·libc_dup2_trampoline_addr(SB), RODATA, $8 +DATA ·libc_dup2_trampoline_addr(SB)/8, $libc_dup2_trampoline<>(SB) + +TEXT libc_dup3_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_dup3(SB) + +GLOBL ·libc_dup3_trampoline_addr(SB), RODATA, $8 +DATA ·libc_dup3_trampoline_addr(SB)/8, $libc_dup3_trampoline<>(SB) + +TEXT libc_exit_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_exit(SB) + +GLOBL ·libc_exit_trampoline_addr(SB), RODATA, $8 +DATA ·libc_exit_trampoline_addr(SB)/8, $libc_exit_trampoline<>(SB) + +TEXT libc_faccessat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_faccessat(SB) + +GLOBL ·libc_faccessat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_faccessat_trampoline_addr(SB)/8, $libc_faccessat_trampoline<>(SB) + +TEXT libc_fchdir_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_fchdir(SB) + +GLOBL ·libc_fchdir_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fchdir_trampoline_addr(SB)/8, $libc_fchdir_trampoline<>(SB) + +TEXT libc_fchflags_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_fchflags(SB) + +GLOBL ·libc_fchflags_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fchflags_trampoline_addr(SB)/8, $libc_fchflags_trampoline<>(SB) + +TEXT libc_fchmod_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_fchmod(SB) + +GLOBL ·libc_fchmod_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fchmod_trampoline_addr(SB)/8, $libc_fchmod_trampoline<>(SB) + +TEXT libc_fchmodat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_fchmodat(SB) + +GLOBL ·libc_fchmodat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fchmodat_trampoline_addr(SB)/8, $libc_fchmodat_trampoline<>(SB) + +TEXT libc_fchown_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_fchown(SB) + +GLOBL ·libc_fchown_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fchown_trampoline_addr(SB)/8, $libc_fchown_trampoline<>(SB) + +TEXT libc_fchownat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_fchownat(SB) + +GLOBL ·libc_fchownat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fchownat_trampoline_addr(SB)/8, $libc_fchownat_trampoline<>(SB) + +TEXT libc_flock_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_flock(SB) + +GLOBL ·libc_flock_trampoline_addr(SB), RODATA, $8 +DATA ·libc_flock_trampoline_addr(SB)/8, $libc_flock_trampoline<>(SB) + +TEXT libc_fpathconf_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_fpathconf(SB) + +GLOBL ·libc_fpathconf_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fpathconf_trampoline_addr(SB)/8, $libc_fpathconf_trampoline<>(SB) + +TEXT libc_fstat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_fstat(SB) + +GLOBL ·libc_fstat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fstat_trampoline_addr(SB)/8, $libc_fstat_trampoline<>(SB) + +TEXT libc_fstatat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_fstatat(SB) + +GLOBL ·libc_fstatat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fstatat_trampoline_addr(SB)/8, $libc_fstatat_trampoline<>(SB) + +TEXT libc_fstatfs_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_fstatfs(SB) + +GLOBL ·libc_fstatfs_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fstatfs_trampoline_addr(SB)/8, $libc_fstatfs_trampoline<>(SB) + +TEXT libc_fsync_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_fsync(SB) + +GLOBL ·libc_fsync_trampoline_addr(SB), RODATA, $8 +DATA ·libc_fsync_trampoline_addr(SB)/8, $libc_fsync_trampoline<>(SB) + +TEXT libc_ftruncate_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_ftruncate(SB) + +GLOBL ·libc_ftruncate_trampoline_addr(SB), RODATA, $8 +DATA ·libc_ftruncate_trampoline_addr(SB)/8, $libc_ftruncate_trampoline<>(SB) + +TEXT libc_getegid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getegid(SB) + +GLOBL ·libc_getegid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getegid_trampoline_addr(SB)/8, $libc_getegid_trampoline<>(SB) + +TEXT libc_geteuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_geteuid(SB) + +GLOBL ·libc_geteuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_geteuid_trampoline_addr(SB)/8, $libc_geteuid_trampoline<>(SB) + +TEXT libc_getgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getgid(SB) + +GLOBL ·libc_getgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getgid_trampoline_addr(SB)/8, $libc_getgid_trampoline<>(SB) + +TEXT libc_getpgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getpgid(SB) + +GLOBL ·libc_getpgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getpgid_trampoline_addr(SB)/8, $libc_getpgid_trampoline<>(SB) + +TEXT libc_getpgrp_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getpgrp(SB) + +GLOBL ·libc_getpgrp_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getpgrp_trampoline_addr(SB)/8, $libc_getpgrp_trampoline<>(SB) + +TEXT libc_getpid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getpid(SB) + +GLOBL ·libc_getpid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getpid_trampoline_addr(SB)/8, $libc_getpid_trampoline<>(SB) + +TEXT libc_getppid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getppid(SB) + +GLOBL ·libc_getppid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getppid_trampoline_addr(SB)/8, $libc_getppid_trampoline<>(SB) + +TEXT libc_getpriority_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getpriority(SB) + +GLOBL ·libc_getpriority_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getpriority_trampoline_addr(SB)/8, $libc_getpriority_trampoline<>(SB) + +TEXT libc_getrlimit_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getrlimit(SB) + +GLOBL ·libc_getrlimit_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getrlimit_trampoline_addr(SB)/8, $libc_getrlimit_trampoline<>(SB) + +TEXT libc_getrtable_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getrtable(SB) + +GLOBL ·libc_getrtable_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getrtable_trampoline_addr(SB)/8, $libc_getrtable_trampoline<>(SB) + +TEXT libc_getrusage_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getrusage(SB) + +GLOBL ·libc_getrusage_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getrusage_trampoline_addr(SB)/8, $libc_getrusage_trampoline<>(SB) + +TEXT libc_getsid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getsid(SB) + +GLOBL ·libc_getsid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getsid_trampoline_addr(SB)/8, $libc_getsid_trampoline<>(SB) + +TEXT libc_gettimeofday_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_gettimeofday(SB) + +GLOBL ·libc_gettimeofday_trampoline_addr(SB), RODATA, $8 +DATA ·libc_gettimeofday_trampoline_addr(SB)/8, $libc_gettimeofday_trampoline<>(SB) + +TEXT libc_getuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getuid(SB) + +GLOBL ·libc_getuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getuid_trampoline_addr(SB)/8, $libc_getuid_trampoline<>(SB) + +TEXT libc_issetugid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_issetugid(SB) + +GLOBL ·libc_issetugid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_issetugid_trampoline_addr(SB)/8, $libc_issetugid_trampoline<>(SB) + +TEXT libc_kill_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_kill(SB) + +GLOBL ·libc_kill_trampoline_addr(SB), RODATA, $8 +DATA ·libc_kill_trampoline_addr(SB)/8, $libc_kill_trampoline<>(SB) + +TEXT libc_kqueue_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_kqueue(SB) + +GLOBL ·libc_kqueue_trampoline_addr(SB), RODATA, $8 +DATA ·libc_kqueue_trampoline_addr(SB)/8, $libc_kqueue_trampoline<>(SB) + +TEXT libc_lchown_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_lchown(SB) + +GLOBL ·libc_lchown_trampoline_addr(SB), RODATA, $8 +DATA ·libc_lchown_trampoline_addr(SB)/8, $libc_lchown_trampoline<>(SB) + +TEXT libc_link_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_link(SB) + +GLOBL ·libc_link_trampoline_addr(SB), RODATA, $8 +DATA ·libc_link_trampoline_addr(SB)/8, $libc_link_trampoline<>(SB) + +TEXT libc_linkat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_linkat(SB) + +GLOBL ·libc_linkat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_linkat_trampoline_addr(SB)/8, $libc_linkat_trampoline<>(SB) + +TEXT libc_listen_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_listen(SB) + +GLOBL ·libc_listen_trampoline_addr(SB), RODATA, $8 +DATA ·libc_listen_trampoline_addr(SB)/8, $libc_listen_trampoline<>(SB) + +TEXT libc_lstat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_lstat(SB) + +GLOBL ·libc_lstat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_lstat_trampoline_addr(SB)/8, $libc_lstat_trampoline<>(SB) + +TEXT libc_mkdir_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mkdir(SB) + +GLOBL ·libc_mkdir_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mkdir_trampoline_addr(SB)/8, $libc_mkdir_trampoline<>(SB) + +TEXT libc_mkdirat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mkdirat(SB) + +GLOBL ·libc_mkdirat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mkdirat_trampoline_addr(SB)/8, $libc_mkdirat_trampoline<>(SB) + +TEXT libc_mkfifo_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mkfifo(SB) + +GLOBL ·libc_mkfifo_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mkfifo_trampoline_addr(SB)/8, $libc_mkfifo_trampoline<>(SB) + +TEXT libc_mkfifoat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mkfifoat(SB) + +GLOBL ·libc_mkfifoat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mkfifoat_trampoline_addr(SB)/8, $libc_mkfifoat_trampoline<>(SB) + +TEXT libc_mknod_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mknod(SB) + +GLOBL ·libc_mknod_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mknod_trampoline_addr(SB)/8, $libc_mknod_trampoline<>(SB) + +TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mknodat(SB) + +GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) + +TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_nanosleep(SB) + +GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 +DATA ·libc_nanosleep_trampoline_addr(SB)/8, $libc_nanosleep_trampoline<>(SB) + +TEXT libc_open_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_open(SB) + +GLOBL ·libc_open_trampoline_addr(SB), RODATA, $8 +DATA ·libc_open_trampoline_addr(SB)/8, $libc_open_trampoline<>(SB) + +TEXT libc_openat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_openat(SB) + +GLOBL ·libc_openat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_openat_trampoline_addr(SB)/8, $libc_openat_trampoline<>(SB) + +TEXT libc_pathconf_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pathconf(SB) + +GLOBL ·libc_pathconf_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pathconf_trampoline_addr(SB)/8, $libc_pathconf_trampoline<>(SB) + +TEXT libc_pread_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pread(SB) + +GLOBL ·libc_pread_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pread_trampoline_addr(SB)/8, $libc_pread_trampoline<>(SB) + +TEXT libc_pwrite_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pwrite(SB) + +GLOBL ·libc_pwrite_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pwrite_trampoline_addr(SB)/8, $libc_pwrite_trampoline<>(SB) + +TEXT libc_read_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_read(SB) + +GLOBL ·libc_read_trampoline_addr(SB), RODATA, $8 +DATA ·libc_read_trampoline_addr(SB)/8, $libc_read_trampoline<>(SB) + +TEXT libc_readlink_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_readlink(SB) + +GLOBL ·libc_readlink_trampoline_addr(SB), RODATA, $8 +DATA ·libc_readlink_trampoline_addr(SB)/8, $libc_readlink_trampoline<>(SB) + +TEXT libc_readlinkat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_readlinkat(SB) + +GLOBL ·libc_readlinkat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_readlinkat_trampoline_addr(SB)/8, $libc_readlinkat_trampoline<>(SB) + +TEXT libc_rename_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_rename(SB) + +GLOBL ·libc_rename_trampoline_addr(SB), RODATA, $8 +DATA ·libc_rename_trampoline_addr(SB)/8, $libc_rename_trampoline<>(SB) + +TEXT libc_renameat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameat(SB) + +GLOBL ·libc_renameat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameat_trampoline_addr(SB)/8, $libc_renameat_trampoline<>(SB) + +TEXT libc_revoke_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_revoke(SB) + +GLOBL ·libc_revoke_trampoline_addr(SB), RODATA, $8 +DATA ·libc_revoke_trampoline_addr(SB)/8, $libc_revoke_trampoline<>(SB) + +TEXT libc_rmdir_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_rmdir(SB) + +GLOBL ·libc_rmdir_trampoline_addr(SB), RODATA, $8 +DATA ·libc_rmdir_trampoline_addr(SB)/8, $libc_rmdir_trampoline<>(SB) + +TEXT libc_lseek_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_lseek(SB) + +GLOBL ·libc_lseek_trampoline_addr(SB), RODATA, $8 +DATA ·libc_lseek_trampoline_addr(SB)/8, $libc_lseek_trampoline<>(SB) + +TEXT libc_select_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_select(SB) + +GLOBL ·libc_select_trampoline_addr(SB), RODATA, $8 +DATA ·libc_select_trampoline_addr(SB)/8, $libc_select_trampoline<>(SB) + +TEXT libc_setegid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setegid(SB) + +GLOBL ·libc_setegid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setegid_trampoline_addr(SB)/8, $libc_setegid_trampoline<>(SB) + +TEXT libc_seteuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_seteuid(SB) + +GLOBL ·libc_seteuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_seteuid_trampoline_addr(SB)/8, $libc_seteuid_trampoline<>(SB) + +TEXT libc_setgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setgid(SB) + +GLOBL ·libc_setgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setgid_trampoline_addr(SB)/8, $libc_setgid_trampoline<>(SB) + +TEXT libc_setlogin_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setlogin(SB) + +GLOBL ·libc_setlogin_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setlogin_trampoline_addr(SB)/8, $libc_setlogin_trampoline<>(SB) + +TEXT libc_setpgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setpgid(SB) + +GLOBL ·libc_setpgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setpgid_trampoline_addr(SB)/8, $libc_setpgid_trampoline<>(SB) + +TEXT libc_setpriority_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setpriority(SB) + +GLOBL ·libc_setpriority_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setpriority_trampoline_addr(SB)/8, $libc_setpriority_trampoline<>(SB) + +TEXT libc_setregid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setregid(SB) + +GLOBL ·libc_setregid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setregid_trampoline_addr(SB)/8, $libc_setregid_trampoline<>(SB) + +TEXT libc_setreuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setreuid(SB) + +GLOBL ·libc_setreuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setreuid_trampoline_addr(SB)/8, $libc_setreuid_trampoline<>(SB) + +TEXT libc_setresgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setresgid(SB) + +GLOBL ·libc_setresgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setresgid_trampoline_addr(SB)/8, $libc_setresgid_trampoline<>(SB) + +TEXT libc_setresuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setresuid(SB) + +GLOBL ·libc_setresuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setresuid_trampoline_addr(SB)/8, $libc_setresuid_trampoline<>(SB) + +TEXT libc_setrlimit_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setrlimit(SB) + +GLOBL ·libc_setrlimit_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setrlimit_trampoline_addr(SB)/8, $libc_setrlimit_trampoline<>(SB) + +TEXT libc_setrtable_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setrtable(SB) + +GLOBL ·libc_setrtable_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setrtable_trampoline_addr(SB)/8, $libc_setrtable_trampoline<>(SB) + +TEXT libc_setsid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setsid(SB) + +GLOBL ·libc_setsid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setsid_trampoline_addr(SB)/8, $libc_setsid_trampoline<>(SB) + +TEXT libc_settimeofday_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_settimeofday(SB) + +GLOBL ·libc_settimeofday_trampoline_addr(SB), RODATA, $8 +DATA ·libc_settimeofday_trampoline_addr(SB)/8, $libc_settimeofday_trampoline<>(SB) + +TEXT libc_setuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_setuid(SB) + +GLOBL ·libc_setuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_setuid_trampoline_addr(SB)/8, $libc_setuid_trampoline<>(SB) + +TEXT libc_stat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_stat(SB) + +GLOBL ·libc_stat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_stat_trampoline_addr(SB)/8, $libc_stat_trampoline<>(SB) + +TEXT libc_statfs_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_statfs(SB) + +GLOBL ·libc_statfs_trampoline_addr(SB), RODATA, $8 +DATA ·libc_statfs_trampoline_addr(SB)/8, $libc_statfs_trampoline<>(SB) + +TEXT libc_symlink_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_symlink(SB) + +GLOBL ·libc_symlink_trampoline_addr(SB), RODATA, $8 +DATA ·libc_symlink_trampoline_addr(SB)/8, $libc_symlink_trampoline<>(SB) + +TEXT libc_symlinkat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_symlinkat(SB) + +GLOBL ·libc_symlinkat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_symlinkat_trampoline_addr(SB)/8, $libc_symlinkat_trampoline<>(SB) + +TEXT libc_sync_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_sync(SB) + +GLOBL ·libc_sync_trampoline_addr(SB), RODATA, $8 +DATA ·libc_sync_trampoline_addr(SB)/8, $libc_sync_trampoline<>(SB) + +TEXT libc_truncate_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_truncate(SB) + +GLOBL ·libc_truncate_trampoline_addr(SB), RODATA, $8 +DATA ·libc_truncate_trampoline_addr(SB)/8, $libc_truncate_trampoline<>(SB) + +TEXT libc_umask_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_umask(SB) + +GLOBL ·libc_umask_trampoline_addr(SB), RODATA, $8 +DATA ·libc_umask_trampoline_addr(SB)/8, $libc_umask_trampoline<>(SB) + +TEXT libc_unlink_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_unlink(SB) + +GLOBL ·libc_unlink_trampoline_addr(SB), RODATA, $8 +DATA ·libc_unlink_trampoline_addr(SB)/8, $libc_unlink_trampoline<>(SB) + +TEXT libc_unlinkat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_unlinkat(SB) + +GLOBL ·libc_unlinkat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_unlinkat_trampoline_addr(SB)/8, $libc_unlinkat_trampoline<>(SB) + +TEXT libc_unmount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_unmount(SB) + +GLOBL ·libc_unmount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_unmount_trampoline_addr(SB)/8, $libc_unmount_trampoline<>(SB) + +TEXT libc_write_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_write(SB) + +GLOBL ·libc_write_trampoline_addr(SB), RODATA, $8 +DATA ·libc_write_trampoline_addr(SB)/8, $libc_write_trampoline<>(SB) + +TEXT libc_mmap_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mmap(SB) + +GLOBL ·libc_mmap_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mmap_trampoline_addr(SB)/8, $libc_mmap_trampoline<>(SB) + +TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_munmap(SB) + +GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $8 +DATA ·libc_munmap_trampoline_addr(SB)/8, $libc_munmap_trampoline<>(SB) + +TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_utimensat(SB) + +GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $8 +DATA ·libc_utimensat_trampoline_addr(SB)/8, $libc_utimensat_trampoline<>(SB) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go index fdf53f8daf..91f5a2bde2 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go @@ -147,6 +147,8 @@ import ( //go:cgo_import_dynamic libc_port_dissociate port_dissociate "libc.so" //go:cgo_import_dynamic libc_port_get port_get "libc.so" //go:cgo_import_dynamic libc_port_getn port_getn "libc.so" +//go:cgo_import_dynamic libc_putmsg putmsg "libc.so" +//go:cgo_import_dynamic libc_getmsg getmsg "libc.so" //go:linkname procpipe libc_pipe //go:linkname procpipe2 libc_pipe2 @@ -284,6 +286,8 @@ import ( //go:linkname procport_dissociate libc_port_dissociate //go:linkname procport_get libc_port_get //go:linkname procport_getn libc_port_getn +//go:linkname procputmsg libc_putmsg +//go:linkname procgetmsg libc_getmsg var ( procpipe, @@ -421,7 +425,9 @@ var ( procport_associate, procport_dissociate, procport_get, - procport_getn syscallFunc + procport_getn, + procputmsg, + procgetmsg syscallFunc ) // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT @@ -2065,3 +2071,23 @@ func port_getn(port int, pe *portEvent, max uint32, nget *uint32, timeout *Times } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func putmsg(fd int, clptr *strbuf, dataptr *strbuf, flags int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procputmsg)), 4, uintptr(fd), uintptr(unsafe.Pointer(clptr)), uintptr(unsafe.Pointer(dataptr)), uintptr(flags), 0, 0) + if e1 != 0 { + err = e1 + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getmsg(fd int, clptr *strbuf, dataptr *strbuf, flags *int) (err error) { + _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procgetmsg)), 4, uintptr(fd), uintptr(unsafe.Pointer(clptr)), uintptr(unsafe.Pointer(dataptr)), uintptr(unsafe.Pointer(flags)), 0, 0) + if e1 != 0 { + err = e1 + } + return +} diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_ppc64.go new file mode 100644 index 0000000000..e44054470b --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_ppc64.go @@ -0,0 +1,281 @@ +// go run mksysctl_openbsd.go +// Code generated by the command above; DO NOT EDIT. + +//go:build ppc64 && openbsd +// +build ppc64,openbsd + +package unix + +type mibentry struct { + ctlname string + ctloid []_C_int +} + +var sysctlMib = []mibentry{ + {"ddb.console", []_C_int{9, 6}}, + {"ddb.log", []_C_int{9, 7}}, + {"ddb.max_line", []_C_int{9, 3}}, + {"ddb.max_width", []_C_int{9, 2}}, + {"ddb.panic", []_C_int{9, 5}}, + {"ddb.profile", []_C_int{9, 9}}, + {"ddb.radix", []_C_int{9, 1}}, + {"ddb.tab_stop_width", []_C_int{9, 4}}, + {"ddb.trigger", []_C_int{9, 8}}, + {"fs.posix.setuid", []_C_int{3, 1, 1}}, + {"hw.allowpowerdown", []_C_int{6, 22}}, + {"hw.byteorder", []_C_int{6, 4}}, + {"hw.cpuspeed", []_C_int{6, 12}}, + {"hw.diskcount", []_C_int{6, 10}}, + {"hw.disknames", []_C_int{6, 8}}, + {"hw.diskstats", []_C_int{6, 9}}, + {"hw.machine", []_C_int{6, 1}}, + {"hw.model", []_C_int{6, 2}}, + {"hw.ncpu", []_C_int{6, 3}}, + {"hw.ncpufound", []_C_int{6, 21}}, + {"hw.ncpuonline", []_C_int{6, 25}}, + {"hw.pagesize", []_C_int{6, 7}}, + {"hw.perfpolicy", []_C_int{6, 23}}, + {"hw.physmem", []_C_int{6, 19}}, + {"hw.power", []_C_int{6, 26}}, + {"hw.product", []_C_int{6, 15}}, + {"hw.serialno", []_C_int{6, 17}}, + {"hw.setperf", []_C_int{6, 13}}, + {"hw.smt", []_C_int{6, 24}}, + {"hw.usermem", []_C_int{6, 20}}, + {"hw.uuid", []_C_int{6, 18}}, + {"hw.vendor", []_C_int{6, 14}}, + {"hw.version", []_C_int{6, 16}}, + {"kern.allowdt", []_C_int{1, 65}}, + {"kern.allowkmem", []_C_int{1, 52}}, + {"kern.argmax", []_C_int{1, 8}}, + {"kern.audio", []_C_int{1, 84}}, + {"kern.boottime", []_C_int{1, 21}}, + {"kern.bufcachepercent", []_C_int{1, 72}}, + {"kern.ccpu", []_C_int{1, 45}}, + {"kern.clockrate", []_C_int{1, 12}}, + {"kern.consbuf", []_C_int{1, 83}}, + {"kern.consbufsize", []_C_int{1, 82}}, + {"kern.consdev", []_C_int{1, 75}}, + {"kern.cp_time", []_C_int{1, 40}}, + {"kern.cp_time2", []_C_int{1, 71}}, + {"kern.cpustats", []_C_int{1, 85}}, + {"kern.domainname", []_C_int{1, 22}}, + {"kern.file", []_C_int{1, 73}}, + {"kern.forkstat", []_C_int{1, 42}}, + {"kern.fscale", []_C_int{1, 46}}, + {"kern.fsync", []_C_int{1, 33}}, + {"kern.global_ptrace", []_C_int{1, 81}}, + {"kern.hostid", []_C_int{1, 11}}, + {"kern.hostname", []_C_int{1, 10}}, + {"kern.intrcnt.nintrcnt", []_C_int{1, 63, 1}}, + {"kern.job_control", []_C_int{1, 19}}, + {"kern.malloc.buckets", []_C_int{1, 39, 1}}, + {"kern.malloc.kmemnames", []_C_int{1, 39, 3}}, + {"kern.maxclusters", []_C_int{1, 67}}, + {"kern.maxfiles", []_C_int{1, 7}}, + {"kern.maxlocksperuid", []_C_int{1, 70}}, + {"kern.maxpartitions", []_C_int{1, 23}}, + {"kern.maxproc", []_C_int{1, 6}}, + {"kern.maxthread", []_C_int{1, 25}}, + {"kern.maxvnodes", []_C_int{1, 5}}, + {"kern.mbstat", []_C_int{1, 59}}, + {"kern.msgbuf", []_C_int{1, 48}}, + {"kern.msgbufsize", []_C_int{1, 38}}, + {"kern.nchstats", []_C_int{1, 41}}, + {"kern.netlivelocks", []_C_int{1, 76}}, + {"kern.nfiles", []_C_int{1, 56}}, + {"kern.ngroups", []_C_int{1, 18}}, + {"kern.nosuidcoredump", []_C_int{1, 32}}, + {"kern.nprocs", []_C_int{1, 47}}, + {"kern.nthreads", []_C_int{1, 26}}, + {"kern.numvnodes", []_C_int{1, 58}}, + {"kern.osrelease", []_C_int{1, 2}}, + {"kern.osrevision", []_C_int{1, 3}}, + {"kern.ostype", []_C_int{1, 1}}, + {"kern.osversion", []_C_int{1, 27}}, + {"kern.pfstatus", []_C_int{1, 86}}, + {"kern.pool_debug", []_C_int{1, 77}}, + {"kern.posix1version", []_C_int{1, 17}}, + {"kern.proc", []_C_int{1, 66}}, + {"kern.rawpartition", []_C_int{1, 24}}, + {"kern.saved_ids", []_C_int{1, 20}}, + {"kern.securelevel", []_C_int{1, 9}}, + {"kern.seminfo", []_C_int{1, 61}}, + {"kern.shminfo", []_C_int{1, 62}}, + {"kern.somaxconn", []_C_int{1, 28}}, + {"kern.sominconn", []_C_int{1, 29}}, + {"kern.splassert", []_C_int{1, 54}}, + {"kern.stackgap_random", []_C_int{1, 50}}, + {"kern.sysvipc_info", []_C_int{1, 51}}, + {"kern.sysvmsg", []_C_int{1, 34}}, + {"kern.sysvsem", []_C_int{1, 35}}, + {"kern.sysvshm", []_C_int{1, 36}}, + {"kern.timecounter.choice", []_C_int{1, 69, 4}}, + {"kern.timecounter.hardware", []_C_int{1, 69, 3}}, + {"kern.timecounter.tick", []_C_int{1, 69, 1}}, + {"kern.timecounter.timestepwarnings", []_C_int{1, 69, 2}}, + {"kern.timeout_stats", []_C_int{1, 87}}, + {"kern.tty.tk_cancc", []_C_int{1, 44, 4}}, + {"kern.tty.tk_nin", []_C_int{1, 44, 1}}, + {"kern.tty.tk_nout", []_C_int{1, 44, 2}}, + {"kern.tty.tk_rawcc", []_C_int{1, 44, 3}}, + {"kern.tty.ttyinfo", []_C_int{1, 44, 5}}, + {"kern.ttycount", []_C_int{1, 57}}, + {"kern.utc_offset", []_C_int{1, 88}}, + {"kern.version", []_C_int{1, 4}}, + {"kern.video", []_C_int{1, 89}}, + {"kern.watchdog.auto", []_C_int{1, 64, 2}}, + {"kern.watchdog.period", []_C_int{1, 64, 1}}, + {"kern.witnesswatch", []_C_int{1, 53}}, + {"kern.wxabort", []_C_int{1, 74}}, + {"net.bpf.bufsize", []_C_int{4, 31, 1}}, + {"net.bpf.maxbufsize", []_C_int{4, 31, 2}}, + {"net.inet.ah.enable", []_C_int{4, 2, 51, 1}}, + {"net.inet.ah.stats", []_C_int{4, 2, 51, 2}}, + {"net.inet.carp.allow", []_C_int{4, 2, 112, 1}}, + {"net.inet.carp.log", []_C_int{4, 2, 112, 3}}, + {"net.inet.carp.preempt", []_C_int{4, 2, 112, 2}}, + {"net.inet.carp.stats", []_C_int{4, 2, 112, 4}}, + {"net.inet.divert.recvspace", []_C_int{4, 2, 258, 1}}, + {"net.inet.divert.sendspace", []_C_int{4, 2, 258, 2}}, + {"net.inet.divert.stats", []_C_int{4, 2, 258, 3}}, + {"net.inet.esp.enable", []_C_int{4, 2, 50, 1}}, + {"net.inet.esp.stats", []_C_int{4, 2, 50, 4}}, + {"net.inet.esp.udpencap", []_C_int{4, 2, 50, 2}}, + {"net.inet.esp.udpencap_port", []_C_int{4, 2, 50, 3}}, + {"net.inet.etherip.allow", []_C_int{4, 2, 97, 1}}, + {"net.inet.etherip.stats", []_C_int{4, 2, 97, 2}}, + {"net.inet.gre.allow", []_C_int{4, 2, 47, 1}}, + {"net.inet.gre.wccp", []_C_int{4, 2, 47, 2}}, + {"net.inet.icmp.bmcastecho", []_C_int{4, 2, 1, 2}}, + {"net.inet.icmp.errppslimit", []_C_int{4, 2, 1, 3}}, + {"net.inet.icmp.maskrepl", []_C_int{4, 2, 1, 1}}, + {"net.inet.icmp.rediraccept", []_C_int{4, 2, 1, 4}}, + {"net.inet.icmp.redirtimeout", []_C_int{4, 2, 1, 5}}, + {"net.inet.icmp.stats", []_C_int{4, 2, 1, 7}}, + {"net.inet.icmp.tstamprepl", []_C_int{4, 2, 1, 6}}, + {"net.inet.igmp.stats", []_C_int{4, 2, 2, 1}}, + {"net.inet.ip.arpdown", []_C_int{4, 2, 0, 40}}, + {"net.inet.ip.arpqueued", []_C_int{4, 2, 0, 36}}, + {"net.inet.ip.arptimeout", []_C_int{4, 2, 0, 39}}, + {"net.inet.ip.encdebug", []_C_int{4, 2, 0, 12}}, + {"net.inet.ip.forwarding", []_C_int{4, 2, 0, 1}}, + {"net.inet.ip.ifq.congestion", []_C_int{4, 2, 0, 30, 4}}, + {"net.inet.ip.ifq.drops", []_C_int{4, 2, 0, 30, 3}}, + {"net.inet.ip.ifq.len", []_C_int{4, 2, 0, 30, 1}}, + {"net.inet.ip.ifq.maxlen", []_C_int{4, 2, 0, 30, 2}}, + {"net.inet.ip.maxqueue", []_C_int{4, 2, 0, 11}}, + {"net.inet.ip.mforwarding", []_C_int{4, 2, 0, 31}}, + {"net.inet.ip.mrtmfc", []_C_int{4, 2, 0, 37}}, + {"net.inet.ip.mrtproto", []_C_int{4, 2, 0, 34}}, + {"net.inet.ip.mrtstats", []_C_int{4, 2, 0, 35}}, + {"net.inet.ip.mrtvif", []_C_int{4, 2, 0, 38}}, + {"net.inet.ip.mtu", []_C_int{4, 2, 0, 4}}, + {"net.inet.ip.mtudisc", []_C_int{4, 2, 0, 27}}, + {"net.inet.ip.mtudisctimeout", []_C_int{4, 2, 0, 28}}, + {"net.inet.ip.multipath", []_C_int{4, 2, 0, 32}}, + {"net.inet.ip.portfirst", []_C_int{4, 2, 0, 7}}, + {"net.inet.ip.porthifirst", []_C_int{4, 2, 0, 9}}, + {"net.inet.ip.porthilast", []_C_int{4, 2, 0, 10}}, + {"net.inet.ip.portlast", []_C_int{4, 2, 0, 8}}, + {"net.inet.ip.redirect", []_C_int{4, 2, 0, 2}}, + {"net.inet.ip.sourceroute", []_C_int{4, 2, 0, 5}}, + {"net.inet.ip.stats", []_C_int{4, 2, 0, 33}}, + {"net.inet.ip.ttl", []_C_int{4, 2, 0, 3}}, + {"net.inet.ipcomp.enable", []_C_int{4, 2, 108, 1}}, + {"net.inet.ipcomp.stats", []_C_int{4, 2, 108, 2}}, + {"net.inet.ipip.allow", []_C_int{4, 2, 4, 1}}, + {"net.inet.ipip.stats", []_C_int{4, 2, 4, 2}}, + {"net.inet.pfsync.stats", []_C_int{4, 2, 240, 1}}, + {"net.inet.tcp.ackonpush", []_C_int{4, 2, 6, 13}}, + {"net.inet.tcp.always_keepalive", []_C_int{4, 2, 6, 22}}, + {"net.inet.tcp.baddynamic", []_C_int{4, 2, 6, 6}}, + {"net.inet.tcp.drop", []_C_int{4, 2, 6, 19}}, + {"net.inet.tcp.ecn", []_C_int{4, 2, 6, 14}}, + {"net.inet.tcp.ident", []_C_int{4, 2, 6, 9}}, + {"net.inet.tcp.keepidle", []_C_int{4, 2, 6, 3}}, + {"net.inet.tcp.keepinittime", []_C_int{4, 2, 6, 2}}, + {"net.inet.tcp.keepintvl", []_C_int{4, 2, 6, 4}}, + {"net.inet.tcp.mssdflt", []_C_int{4, 2, 6, 11}}, + {"net.inet.tcp.reasslimit", []_C_int{4, 2, 6, 18}}, + {"net.inet.tcp.rfc1323", []_C_int{4, 2, 6, 1}}, + {"net.inet.tcp.rfc3390", []_C_int{4, 2, 6, 17}}, + {"net.inet.tcp.rootonly", []_C_int{4, 2, 6, 24}}, + {"net.inet.tcp.rstppslimit", []_C_int{4, 2, 6, 12}}, + {"net.inet.tcp.sack", []_C_int{4, 2, 6, 10}}, + {"net.inet.tcp.sackholelimit", []_C_int{4, 2, 6, 20}}, + {"net.inet.tcp.slowhz", []_C_int{4, 2, 6, 5}}, + {"net.inet.tcp.stats", []_C_int{4, 2, 6, 21}}, + {"net.inet.tcp.synbucketlimit", []_C_int{4, 2, 6, 16}}, + {"net.inet.tcp.syncachelimit", []_C_int{4, 2, 6, 15}}, + {"net.inet.tcp.synhashsize", []_C_int{4, 2, 6, 25}}, + {"net.inet.tcp.synuselimit", []_C_int{4, 2, 6, 23}}, + {"net.inet.udp.baddynamic", []_C_int{4, 2, 17, 2}}, + {"net.inet.udp.checksum", []_C_int{4, 2, 17, 1}}, + {"net.inet.udp.recvspace", []_C_int{4, 2, 17, 3}}, + {"net.inet.udp.rootonly", []_C_int{4, 2, 17, 6}}, + {"net.inet.udp.sendspace", []_C_int{4, 2, 17, 4}}, + {"net.inet.udp.stats", []_C_int{4, 2, 17, 5}}, + {"net.inet6.divert.recvspace", []_C_int{4, 24, 86, 1}}, + {"net.inet6.divert.sendspace", []_C_int{4, 24, 86, 2}}, + {"net.inet6.divert.stats", []_C_int{4, 24, 86, 3}}, + {"net.inet6.icmp6.errppslimit", []_C_int{4, 24, 30, 14}}, + {"net.inet6.icmp6.mtudisc_hiwat", []_C_int{4, 24, 30, 16}}, + {"net.inet6.icmp6.mtudisc_lowat", []_C_int{4, 24, 30, 17}}, + {"net.inet6.icmp6.nd6_debug", []_C_int{4, 24, 30, 18}}, + {"net.inet6.icmp6.nd6_delay", []_C_int{4, 24, 30, 8}}, + {"net.inet6.icmp6.nd6_maxnudhint", []_C_int{4, 24, 30, 15}}, + {"net.inet6.icmp6.nd6_mmaxtries", []_C_int{4, 24, 30, 10}}, + {"net.inet6.icmp6.nd6_umaxtries", []_C_int{4, 24, 30, 9}}, + {"net.inet6.icmp6.redirtimeout", []_C_int{4, 24, 30, 3}}, + {"net.inet6.ip6.auto_flowlabel", []_C_int{4, 24, 17, 17}}, + {"net.inet6.ip6.dad_count", []_C_int{4, 24, 17, 16}}, + {"net.inet6.ip6.dad_pending", []_C_int{4, 24, 17, 49}}, + {"net.inet6.ip6.defmcasthlim", []_C_int{4, 24, 17, 18}}, + {"net.inet6.ip6.forwarding", []_C_int{4, 24, 17, 1}}, + {"net.inet6.ip6.forwsrcrt", []_C_int{4, 24, 17, 5}}, + {"net.inet6.ip6.hdrnestlimit", []_C_int{4, 24, 17, 15}}, + {"net.inet6.ip6.hlim", []_C_int{4, 24, 17, 3}}, + {"net.inet6.ip6.log_interval", []_C_int{4, 24, 17, 14}}, + {"net.inet6.ip6.maxdynroutes", []_C_int{4, 24, 17, 48}}, + {"net.inet6.ip6.maxfragpackets", []_C_int{4, 24, 17, 9}}, + {"net.inet6.ip6.maxfrags", []_C_int{4, 24, 17, 41}}, + {"net.inet6.ip6.mforwarding", []_C_int{4, 24, 17, 42}}, + {"net.inet6.ip6.mrtmfc", []_C_int{4, 24, 17, 53}}, + {"net.inet6.ip6.mrtmif", []_C_int{4, 24, 17, 52}}, + {"net.inet6.ip6.mrtproto", []_C_int{4, 24, 17, 8}}, + {"net.inet6.ip6.mtudisctimeout", []_C_int{4, 24, 17, 50}}, + {"net.inet6.ip6.multicast_mtudisc", []_C_int{4, 24, 17, 44}}, + {"net.inet6.ip6.multipath", []_C_int{4, 24, 17, 43}}, + {"net.inet6.ip6.neighborgcthresh", []_C_int{4, 24, 17, 45}}, + {"net.inet6.ip6.redirect", []_C_int{4, 24, 17, 2}}, + {"net.inet6.ip6.soiikey", []_C_int{4, 24, 17, 54}}, + {"net.inet6.ip6.sourcecheck", []_C_int{4, 24, 17, 10}}, + {"net.inet6.ip6.sourcecheck_logint", []_C_int{4, 24, 17, 11}}, + {"net.inet6.ip6.use_deprecated", []_C_int{4, 24, 17, 21}}, + {"net.key.sadb_dump", []_C_int{4, 30, 1}}, + {"net.key.spd_dump", []_C_int{4, 30, 2}}, + {"net.mpls.ifq.congestion", []_C_int{4, 33, 3, 4}}, + {"net.mpls.ifq.drops", []_C_int{4, 33, 3, 3}}, + {"net.mpls.ifq.len", []_C_int{4, 33, 3, 1}}, + {"net.mpls.ifq.maxlen", []_C_int{4, 33, 3, 2}}, + {"net.mpls.mapttl_ip", []_C_int{4, 33, 5}}, + {"net.mpls.mapttl_ip6", []_C_int{4, 33, 6}}, + {"net.mpls.ttl", []_C_int{4, 33, 2}}, + {"net.pflow.stats", []_C_int{4, 34, 1}}, + {"net.pipex.enable", []_C_int{4, 35, 1}}, + {"vm.anonmin", []_C_int{2, 7}}, + {"vm.loadavg", []_C_int{2, 2}}, + {"vm.malloc_conf", []_C_int{2, 12}}, + {"vm.maxslp", []_C_int{2, 10}}, + {"vm.nkmempages", []_C_int{2, 6}}, + {"vm.psstrings", []_C_int{2, 3}}, + {"vm.swapencrypt.enable", []_C_int{2, 5, 0}}, + {"vm.swapencrypt.keyscreated", []_C_int{2, 5, 1}}, + {"vm.swapencrypt.keysdeleted", []_C_int{2, 5, 2}}, + {"vm.uspace", []_C_int{2, 11}}, + {"vm.uvmexp", []_C_int{2, 4}}, + {"vm.vmmeter", []_C_int{2, 1}}, + {"vm.vnodemin", []_C_int{2, 9}}, + {"vm.vtextmin", []_C_int{2, 8}}, +} diff --git a/vendor/golang.org/x/sys/unix/zsysctl_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_riscv64.go new file mode 100644 index 0000000000..a0db82fce2 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysctl_openbsd_riscv64.go @@ -0,0 +1,282 @@ +// go run mksysctl_openbsd.go +// Code generated by the command above; DO NOT EDIT. + +//go:build riscv64 && openbsd +// +build riscv64,openbsd + +package unix + +type mibentry struct { + ctlname string + ctloid []_C_int +} + +var sysctlMib = []mibentry{ + {"ddb.console", []_C_int{9, 6}}, + {"ddb.log", []_C_int{9, 7}}, + {"ddb.max_line", []_C_int{9, 3}}, + {"ddb.max_width", []_C_int{9, 2}}, + {"ddb.panic", []_C_int{9, 5}}, + {"ddb.profile", []_C_int{9, 9}}, + {"ddb.radix", []_C_int{9, 1}}, + {"ddb.tab_stop_width", []_C_int{9, 4}}, + {"ddb.trigger", []_C_int{9, 8}}, + {"fs.posix.setuid", []_C_int{3, 1, 1}}, + {"hw.allowpowerdown", []_C_int{6, 22}}, + {"hw.byteorder", []_C_int{6, 4}}, + {"hw.cpuspeed", []_C_int{6, 12}}, + {"hw.diskcount", []_C_int{6, 10}}, + {"hw.disknames", []_C_int{6, 8}}, + {"hw.diskstats", []_C_int{6, 9}}, + {"hw.machine", []_C_int{6, 1}}, + {"hw.model", []_C_int{6, 2}}, + {"hw.ncpu", []_C_int{6, 3}}, + {"hw.ncpufound", []_C_int{6, 21}}, + {"hw.ncpuonline", []_C_int{6, 25}}, + {"hw.pagesize", []_C_int{6, 7}}, + {"hw.perfpolicy", []_C_int{6, 23}}, + {"hw.physmem", []_C_int{6, 19}}, + {"hw.power", []_C_int{6, 26}}, + {"hw.product", []_C_int{6, 15}}, + {"hw.serialno", []_C_int{6, 17}}, + {"hw.setperf", []_C_int{6, 13}}, + {"hw.smt", []_C_int{6, 24}}, + {"hw.usermem", []_C_int{6, 20}}, + {"hw.uuid", []_C_int{6, 18}}, + {"hw.vendor", []_C_int{6, 14}}, + {"hw.version", []_C_int{6, 16}}, + {"kern.allowdt", []_C_int{1, 65}}, + {"kern.allowkmem", []_C_int{1, 52}}, + {"kern.argmax", []_C_int{1, 8}}, + {"kern.audio", []_C_int{1, 84}}, + {"kern.boottime", []_C_int{1, 21}}, + {"kern.bufcachepercent", []_C_int{1, 72}}, + {"kern.ccpu", []_C_int{1, 45}}, + {"kern.clockrate", []_C_int{1, 12}}, + {"kern.consbuf", []_C_int{1, 83}}, + {"kern.consbufsize", []_C_int{1, 82}}, + {"kern.consdev", []_C_int{1, 75}}, + {"kern.cp_time", []_C_int{1, 40}}, + {"kern.cp_time2", []_C_int{1, 71}}, + {"kern.cpustats", []_C_int{1, 85}}, + {"kern.domainname", []_C_int{1, 22}}, + {"kern.file", []_C_int{1, 73}}, + {"kern.forkstat", []_C_int{1, 42}}, + {"kern.fscale", []_C_int{1, 46}}, + {"kern.fsync", []_C_int{1, 33}}, + {"kern.global_ptrace", []_C_int{1, 81}}, + {"kern.hostid", []_C_int{1, 11}}, + {"kern.hostname", []_C_int{1, 10}}, + {"kern.intrcnt.nintrcnt", []_C_int{1, 63, 1}}, + {"kern.job_control", []_C_int{1, 19}}, + {"kern.malloc.buckets", []_C_int{1, 39, 1}}, + {"kern.malloc.kmemnames", []_C_int{1, 39, 3}}, + {"kern.maxclusters", []_C_int{1, 67}}, + {"kern.maxfiles", []_C_int{1, 7}}, + {"kern.maxlocksperuid", []_C_int{1, 70}}, + {"kern.maxpartitions", []_C_int{1, 23}}, + {"kern.maxproc", []_C_int{1, 6}}, + {"kern.maxthread", []_C_int{1, 25}}, + {"kern.maxvnodes", []_C_int{1, 5}}, + {"kern.mbstat", []_C_int{1, 59}}, + {"kern.msgbuf", []_C_int{1, 48}}, + {"kern.msgbufsize", []_C_int{1, 38}}, + {"kern.nchstats", []_C_int{1, 41}}, + {"kern.netlivelocks", []_C_int{1, 76}}, + {"kern.nfiles", []_C_int{1, 56}}, + {"kern.ngroups", []_C_int{1, 18}}, + {"kern.nosuidcoredump", []_C_int{1, 32}}, + {"kern.nprocs", []_C_int{1, 47}}, + {"kern.nselcoll", []_C_int{1, 43}}, + {"kern.nthreads", []_C_int{1, 26}}, + {"kern.numvnodes", []_C_int{1, 58}}, + {"kern.osrelease", []_C_int{1, 2}}, + {"kern.osrevision", []_C_int{1, 3}}, + {"kern.ostype", []_C_int{1, 1}}, + {"kern.osversion", []_C_int{1, 27}}, + {"kern.pfstatus", []_C_int{1, 86}}, + {"kern.pool_debug", []_C_int{1, 77}}, + {"kern.posix1version", []_C_int{1, 17}}, + {"kern.proc", []_C_int{1, 66}}, + {"kern.rawpartition", []_C_int{1, 24}}, + {"kern.saved_ids", []_C_int{1, 20}}, + {"kern.securelevel", []_C_int{1, 9}}, + {"kern.seminfo", []_C_int{1, 61}}, + {"kern.shminfo", []_C_int{1, 62}}, + {"kern.somaxconn", []_C_int{1, 28}}, + {"kern.sominconn", []_C_int{1, 29}}, + {"kern.splassert", []_C_int{1, 54}}, + {"kern.stackgap_random", []_C_int{1, 50}}, + {"kern.sysvipc_info", []_C_int{1, 51}}, + {"kern.sysvmsg", []_C_int{1, 34}}, + {"kern.sysvsem", []_C_int{1, 35}}, + {"kern.sysvshm", []_C_int{1, 36}}, + {"kern.timecounter.choice", []_C_int{1, 69, 4}}, + {"kern.timecounter.hardware", []_C_int{1, 69, 3}}, + {"kern.timecounter.tick", []_C_int{1, 69, 1}}, + {"kern.timecounter.timestepwarnings", []_C_int{1, 69, 2}}, + {"kern.timeout_stats", []_C_int{1, 87}}, + {"kern.tty.tk_cancc", []_C_int{1, 44, 4}}, + {"kern.tty.tk_nin", []_C_int{1, 44, 1}}, + {"kern.tty.tk_nout", []_C_int{1, 44, 2}}, + {"kern.tty.tk_rawcc", []_C_int{1, 44, 3}}, + {"kern.tty.ttyinfo", []_C_int{1, 44, 5}}, + {"kern.ttycount", []_C_int{1, 57}}, + {"kern.utc_offset", []_C_int{1, 88}}, + {"kern.version", []_C_int{1, 4}}, + {"kern.video", []_C_int{1, 89}}, + {"kern.watchdog.auto", []_C_int{1, 64, 2}}, + {"kern.watchdog.period", []_C_int{1, 64, 1}}, + {"kern.witnesswatch", []_C_int{1, 53}}, + {"kern.wxabort", []_C_int{1, 74}}, + {"net.bpf.bufsize", []_C_int{4, 31, 1}}, + {"net.bpf.maxbufsize", []_C_int{4, 31, 2}}, + {"net.inet.ah.enable", []_C_int{4, 2, 51, 1}}, + {"net.inet.ah.stats", []_C_int{4, 2, 51, 2}}, + {"net.inet.carp.allow", []_C_int{4, 2, 112, 1}}, + {"net.inet.carp.log", []_C_int{4, 2, 112, 3}}, + {"net.inet.carp.preempt", []_C_int{4, 2, 112, 2}}, + {"net.inet.carp.stats", []_C_int{4, 2, 112, 4}}, + {"net.inet.divert.recvspace", []_C_int{4, 2, 258, 1}}, + {"net.inet.divert.sendspace", []_C_int{4, 2, 258, 2}}, + {"net.inet.divert.stats", []_C_int{4, 2, 258, 3}}, + {"net.inet.esp.enable", []_C_int{4, 2, 50, 1}}, + {"net.inet.esp.stats", []_C_int{4, 2, 50, 4}}, + {"net.inet.esp.udpencap", []_C_int{4, 2, 50, 2}}, + {"net.inet.esp.udpencap_port", []_C_int{4, 2, 50, 3}}, + {"net.inet.etherip.allow", []_C_int{4, 2, 97, 1}}, + {"net.inet.etherip.stats", []_C_int{4, 2, 97, 2}}, + {"net.inet.gre.allow", []_C_int{4, 2, 47, 1}}, + {"net.inet.gre.wccp", []_C_int{4, 2, 47, 2}}, + {"net.inet.icmp.bmcastecho", []_C_int{4, 2, 1, 2}}, + {"net.inet.icmp.errppslimit", []_C_int{4, 2, 1, 3}}, + {"net.inet.icmp.maskrepl", []_C_int{4, 2, 1, 1}}, + {"net.inet.icmp.rediraccept", []_C_int{4, 2, 1, 4}}, + {"net.inet.icmp.redirtimeout", []_C_int{4, 2, 1, 5}}, + {"net.inet.icmp.stats", []_C_int{4, 2, 1, 7}}, + {"net.inet.icmp.tstamprepl", []_C_int{4, 2, 1, 6}}, + {"net.inet.igmp.stats", []_C_int{4, 2, 2, 1}}, + {"net.inet.ip.arpdown", []_C_int{4, 2, 0, 40}}, + {"net.inet.ip.arpqueued", []_C_int{4, 2, 0, 36}}, + {"net.inet.ip.arptimeout", []_C_int{4, 2, 0, 39}}, + {"net.inet.ip.encdebug", []_C_int{4, 2, 0, 12}}, + {"net.inet.ip.forwarding", []_C_int{4, 2, 0, 1}}, + {"net.inet.ip.ifq.congestion", []_C_int{4, 2, 0, 30, 4}}, + {"net.inet.ip.ifq.drops", []_C_int{4, 2, 0, 30, 3}}, + {"net.inet.ip.ifq.len", []_C_int{4, 2, 0, 30, 1}}, + {"net.inet.ip.ifq.maxlen", []_C_int{4, 2, 0, 30, 2}}, + {"net.inet.ip.maxqueue", []_C_int{4, 2, 0, 11}}, + {"net.inet.ip.mforwarding", []_C_int{4, 2, 0, 31}}, + {"net.inet.ip.mrtmfc", []_C_int{4, 2, 0, 37}}, + {"net.inet.ip.mrtproto", []_C_int{4, 2, 0, 34}}, + {"net.inet.ip.mrtstats", []_C_int{4, 2, 0, 35}}, + {"net.inet.ip.mrtvif", []_C_int{4, 2, 0, 38}}, + {"net.inet.ip.mtu", []_C_int{4, 2, 0, 4}}, + {"net.inet.ip.mtudisc", []_C_int{4, 2, 0, 27}}, + {"net.inet.ip.mtudisctimeout", []_C_int{4, 2, 0, 28}}, + {"net.inet.ip.multipath", []_C_int{4, 2, 0, 32}}, + {"net.inet.ip.portfirst", []_C_int{4, 2, 0, 7}}, + {"net.inet.ip.porthifirst", []_C_int{4, 2, 0, 9}}, + {"net.inet.ip.porthilast", []_C_int{4, 2, 0, 10}}, + {"net.inet.ip.portlast", []_C_int{4, 2, 0, 8}}, + {"net.inet.ip.redirect", []_C_int{4, 2, 0, 2}}, + {"net.inet.ip.sourceroute", []_C_int{4, 2, 0, 5}}, + {"net.inet.ip.stats", []_C_int{4, 2, 0, 33}}, + {"net.inet.ip.ttl", []_C_int{4, 2, 0, 3}}, + {"net.inet.ipcomp.enable", []_C_int{4, 2, 108, 1}}, + {"net.inet.ipcomp.stats", []_C_int{4, 2, 108, 2}}, + {"net.inet.ipip.allow", []_C_int{4, 2, 4, 1}}, + {"net.inet.ipip.stats", []_C_int{4, 2, 4, 2}}, + {"net.inet.pfsync.stats", []_C_int{4, 2, 240, 1}}, + {"net.inet.tcp.ackonpush", []_C_int{4, 2, 6, 13}}, + {"net.inet.tcp.always_keepalive", []_C_int{4, 2, 6, 22}}, + {"net.inet.tcp.baddynamic", []_C_int{4, 2, 6, 6}}, + {"net.inet.tcp.drop", []_C_int{4, 2, 6, 19}}, + {"net.inet.tcp.ecn", []_C_int{4, 2, 6, 14}}, + {"net.inet.tcp.ident", []_C_int{4, 2, 6, 9}}, + {"net.inet.tcp.keepidle", []_C_int{4, 2, 6, 3}}, + {"net.inet.tcp.keepinittime", []_C_int{4, 2, 6, 2}}, + {"net.inet.tcp.keepintvl", []_C_int{4, 2, 6, 4}}, + {"net.inet.tcp.mssdflt", []_C_int{4, 2, 6, 11}}, + {"net.inet.tcp.reasslimit", []_C_int{4, 2, 6, 18}}, + {"net.inet.tcp.rfc1323", []_C_int{4, 2, 6, 1}}, + {"net.inet.tcp.rfc3390", []_C_int{4, 2, 6, 17}}, + {"net.inet.tcp.rootonly", []_C_int{4, 2, 6, 24}}, + {"net.inet.tcp.rstppslimit", []_C_int{4, 2, 6, 12}}, + {"net.inet.tcp.sack", []_C_int{4, 2, 6, 10}}, + {"net.inet.tcp.sackholelimit", []_C_int{4, 2, 6, 20}}, + {"net.inet.tcp.slowhz", []_C_int{4, 2, 6, 5}}, + {"net.inet.tcp.stats", []_C_int{4, 2, 6, 21}}, + {"net.inet.tcp.synbucketlimit", []_C_int{4, 2, 6, 16}}, + {"net.inet.tcp.syncachelimit", []_C_int{4, 2, 6, 15}}, + {"net.inet.tcp.synhashsize", []_C_int{4, 2, 6, 25}}, + {"net.inet.tcp.synuselimit", []_C_int{4, 2, 6, 23}}, + {"net.inet.udp.baddynamic", []_C_int{4, 2, 17, 2}}, + {"net.inet.udp.checksum", []_C_int{4, 2, 17, 1}}, + {"net.inet.udp.recvspace", []_C_int{4, 2, 17, 3}}, + {"net.inet.udp.rootonly", []_C_int{4, 2, 17, 6}}, + {"net.inet.udp.sendspace", []_C_int{4, 2, 17, 4}}, + {"net.inet.udp.stats", []_C_int{4, 2, 17, 5}}, + {"net.inet6.divert.recvspace", []_C_int{4, 24, 86, 1}}, + {"net.inet6.divert.sendspace", []_C_int{4, 24, 86, 2}}, + {"net.inet6.divert.stats", []_C_int{4, 24, 86, 3}}, + {"net.inet6.icmp6.errppslimit", []_C_int{4, 24, 30, 14}}, + {"net.inet6.icmp6.mtudisc_hiwat", []_C_int{4, 24, 30, 16}}, + {"net.inet6.icmp6.mtudisc_lowat", []_C_int{4, 24, 30, 17}}, + {"net.inet6.icmp6.nd6_debug", []_C_int{4, 24, 30, 18}}, + {"net.inet6.icmp6.nd6_delay", []_C_int{4, 24, 30, 8}}, + {"net.inet6.icmp6.nd6_maxnudhint", []_C_int{4, 24, 30, 15}}, + {"net.inet6.icmp6.nd6_mmaxtries", []_C_int{4, 24, 30, 10}}, + {"net.inet6.icmp6.nd6_umaxtries", []_C_int{4, 24, 30, 9}}, + {"net.inet6.icmp6.redirtimeout", []_C_int{4, 24, 30, 3}}, + {"net.inet6.ip6.auto_flowlabel", []_C_int{4, 24, 17, 17}}, + {"net.inet6.ip6.dad_count", []_C_int{4, 24, 17, 16}}, + {"net.inet6.ip6.dad_pending", []_C_int{4, 24, 17, 49}}, + {"net.inet6.ip6.defmcasthlim", []_C_int{4, 24, 17, 18}}, + {"net.inet6.ip6.forwarding", []_C_int{4, 24, 17, 1}}, + {"net.inet6.ip6.forwsrcrt", []_C_int{4, 24, 17, 5}}, + {"net.inet6.ip6.hdrnestlimit", []_C_int{4, 24, 17, 15}}, + {"net.inet6.ip6.hlim", []_C_int{4, 24, 17, 3}}, + {"net.inet6.ip6.log_interval", []_C_int{4, 24, 17, 14}}, + {"net.inet6.ip6.maxdynroutes", []_C_int{4, 24, 17, 48}}, + {"net.inet6.ip6.maxfragpackets", []_C_int{4, 24, 17, 9}}, + {"net.inet6.ip6.maxfrags", []_C_int{4, 24, 17, 41}}, + {"net.inet6.ip6.mforwarding", []_C_int{4, 24, 17, 42}}, + {"net.inet6.ip6.mrtmfc", []_C_int{4, 24, 17, 53}}, + {"net.inet6.ip6.mrtmif", []_C_int{4, 24, 17, 52}}, + {"net.inet6.ip6.mrtproto", []_C_int{4, 24, 17, 8}}, + {"net.inet6.ip6.mtudisctimeout", []_C_int{4, 24, 17, 50}}, + {"net.inet6.ip6.multicast_mtudisc", []_C_int{4, 24, 17, 44}}, + {"net.inet6.ip6.multipath", []_C_int{4, 24, 17, 43}}, + {"net.inet6.ip6.neighborgcthresh", []_C_int{4, 24, 17, 45}}, + {"net.inet6.ip6.redirect", []_C_int{4, 24, 17, 2}}, + {"net.inet6.ip6.soiikey", []_C_int{4, 24, 17, 54}}, + {"net.inet6.ip6.sourcecheck", []_C_int{4, 24, 17, 10}}, + {"net.inet6.ip6.sourcecheck_logint", []_C_int{4, 24, 17, 11}}, + {"net.inet6.ip6.use_deprecated", []_C_int{4, 24, 17, 21}}, + {"net.key.sadb_dump", []_C_int{4, 30, 1}}, + {"net.key.spd_dump", []_C_int{4, 30, 2}}, + {"net.mpls.ifq.congestion", []_C_int{4, 33, 3, 4}}, + {"net.mpls.ifq.drops", []_C_int{4, 33, 3, 3}}, + {"net.mpls.ifq.len", []_C_int{4, 33, 3, 1}}, + {"net.mpls.ifq.maxlen", []_C_int{4, 33, 3, 2}}, + {"net.mpls.mapttl_ip", []_C_int{4, 33, 5}}, + {"net.mpls.mapttl_ip6", []_C_int{4, 33, 6}}, + {"net.mpls.ttl", []_C_int{4, 33, 2}}, + {"net.pflow.stats", []_C_int{4, 34, 1}}, + {"net.pipex.enable", []_C_int{4, 35, 1}}, + {"vm.anonmin", []_C_int{2, 7}}, + {"vm.loadavg", []_C_int{2, 2}}, + {"vm.malloc_conf", []_C_int{2, 12}}, + {"vm.maxslp", []_C_int{2, 10}}, + {"vm.nkmempages", []_C_int{2, 6}}, + {"vm.psstrings", []_C_int{2, 3}}, + {"vm.swapencrypt.enable", []_C_int{2, 5, 0}}, + {"vm.swapencrypt.keyscreated", []_C_int{2, 5, 1}}, + {"vm.swapencrypt.keysdeleted", []_C_int{2, 5, 2}}, + {"vm.uspace", []_C_int{2, 11}}, + {"vm.uvmexp", []_C_int{2, 4}}, + {"vm.vmmeter", []_C_int{2, 1}}, + {"vm.vnodemin", []_C_int{2, 9}}, + {"vm.vtextmin", []_C_int{2, 8}}, +} diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_ppc64.go new file mode 100644 index 0000000000..f258cfa24e --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_ppc64.go @@ -0,0 +1,218 @@ +// go run mksysnum.go https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build ppc64 && openbsd +// +build ppc64,openbsd + +package unix + +const ( + SYS_EXIT = 1 // { void sys_exit(int rval); } + SYS_FORK = 2 // { int sys_fork(void); } + SYS_READ = 3 // { ssize_t sys_read(int fd, void *buf, size_t nbyte); } + SYS_WRITE = 4 // { ssize_t sys_write(int fd, const void *buf, size_t nbyte); } + SYS_OPEN = 5 // { int sys_open(const char *path, int flags, ... mode_t mode); } + SYS_CLOSE = 6 // { int sys_close(int fd); } + SYS_GETENTROPY = 7 // { int sys_getentropy(void *buf, size_t nbyte); } + SYS___TFORK = 8 // { int sys___tfork(const struct __tfork *param, size_t psize); } + SYS_LINK = 9 // { int sys_link(const char *path, const char *link); } + SYS_UNLINK = 10 // { int sys_unlink(const char *path); } + SYS_WAIT4 = 11 // { pid_t sys_wait4(pid_t pid, int *status, int options, struct rusage *rusage); } + SYS_CHDIR = 12 // { int sys_chdir(const char *path); } + SYS_FCHDIR = 13 // { int sys_fchdir(int fd); } + SYS_MKNOD = 14 // { int sys_mknod(const char *path, mode_t mode, dev_t dev); } + SYS_CHMOD = 15 // { int sys_chmod(const char *path, mode_t mode); } + SYS_CHOWN = 16 // { int sys_chown(const char *path, uid_t uid, gid_t gid); } + SYS_OBREAK = 17 // { int sys_obreak(char *nsize); } break + SYS_GETDTABLECOUNT = 18 // { int sys_getdtablecount(void); } + SYS_GETRUSAGE = 19 // { int sys_getrusage(int who, struct rusage *rusage); } + SYS_GETPID = 20 // { pid_t sys_getpid(void); } + SYS_MOUNT = 21 // { int sys_mount(const char *type, const char *path, int flags, void *data); } + SYS_UNMOUNT = 22 // { int sys_unmount(const char *path, int flags); } + SYS_SETUID = 23 // { int sys_setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t sys_getuid(void); } + SYS_GETEUID = 25 // { uid_t sys_geteuid(void); } + SYS_PTRACE = 26 // { int sys_ptrace(int req, pid_t pid, caddr_t addr, int data); } + SYS_RECVMSG = 27 // { ssize_t sys_recvmsg(int s, struct msghdr *msg, int flags); } + SYS_SENDMSG = 28 // { ssize_t sys_sendmsg(int s, const struct msghdr *msg, int flags); } + SYS_RECVFROM = 29 // { ssize_t sys_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlenaddr); } + SYS_ACCEPT = 30 // { int sys_accept(int s, struct sockaddr *name, socklen_t *anamelen); } + SYS_GETPEERNAME = 31 // { int sys_getpeername(int fdes, struct sockaddr *asa, socklen_t *alen); } + SYS_GETSOCKNAME = 32 // { int sys_getsockname(int fdes, struct sockaddr *asa, socklen_t *alen); } + SYS_ACCESS = 33 // { int sys_access(const char *path, int amode); } + SYS_CHFLAGS = 34 // { int sys_chflags(const char *path, u_int flags); } + SYS_FCHFLAGS = 35 // { int sys_fchflags(int fd, u_int flags); } + SYS_SYNC = 36 // { void sys_sync(void); } + SYS_STAT = 38 // { int sys_stat(const char *path, struct stat *ub); } + SYS_GETPPID = 39 // { pid_t sys_getppid(void); } + SYS_LSTAT = 40 // { int sys_lstat(const char *path, struct stat *ub); } + SYS_DUP = 41 // { int sys_dup(int fd); } + SYS_FSTATAT = 42 // { int sys_fstatat(int fd, const char *path, struct stat *buf, int flag); } + SYS_GETEGID = 43 // { gid_t sys_getegid(void); } + SYS_PROFIL = 44 // { int sys_profil(caddr_t samples, size_t size, u_long offset, u_int scale); } + SYS_KTRACE = 45 // { int sys_ktrace(const char *fname, int ops, int facs, pid_t pid); } + SYS_SIGACTION = 46 // { int sys_sigaction(int signum, const struct sigaction *nsa, struct sigaction *osa); } + SYS_GETGID = 47 // { gid_t sys_getgid(void); } + SYS_SIGPROCMASK = 48 // { int sys_sigprocmask(int how, sigset_t mask); } + SYS_SETLOGIN = 50 // { int sys_setlogin(const char *namebuf); } + SYS_ACCT = 51 // { int sys_acct(const char *path); } + SYS_SIGPENDING = 52 // { int sys_sigpending(void); } + SYS_FSTAT = 53 // { int sys_fstat(int fd, struct stat *sb); } + SYS_IOCTL = 54 // { int sys_ioctl(int fd, u_long com, ... void *data); } + SYS_REBOOT = 55 // { int sys_reboot(int opt); } + SYS_REVOKE = 56 // { int sys_revoke(const char *path); } + SYS_SYMLINK = 57 // { int sys_symlink(const char *path, const char *link); } + SYS_READLINK = 58 // { ssize_t sys_readlink(const char *path, char *buf, size_t count); } + SYS_EXECVE = 59 // { int sys_execve(const char *path, char * const *argp, char * const *envp); } + SYS_UMASK = 60 // { mode_t sys_umask(mode_t newmask); } + SYS_CHROOT = 61 // { int sys_chroot(const char *path); } + SYS_GETFSSTAT = 62 // { int sys_getfsstat(struct statfs *buf, size_t bufsize, int flags); } + SYS_STATFS = 63 // { int sys_statfs(const char *path, struct statfs *buf); } + SYS_FSTATFS = 64 // { int sys_fstatfs(int fd, struct statfs *buf); } + SYS_FHSTATFS = 65 // { int sys_fhstatfs(const fhandle_t *fhp, struct statfs *buf); } + SYS_VFORK = 66 // { int sys_vfork(void); } + SYS_GETTIMEOFDAY = 67 // { int sys_gettimeofday(struct timeval *tp, struct timezone *tzp); } + SYS_SETTIMEOFDAY = 68 // { int sys_settimeofday(const struct timeval *tv, const struct timezone *tzp); } + SYS_SETITIMER = 69 // { int sys_setitimer(int which, const struct itimerval *itv, struct itimerval *oitv); } + SYS_GETITIMER = 70 // { int sys_getitimer(int which, struct itimerval *itv); } + SYS_SELECT = 71 // { int sys_select(int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timeval *tv); } + SYS_KEVENT = 72 // { int sys_kevent(int fd, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout); } + SYS_MUNMAP = 73 // { int sys_munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int sys_mprotect(void *addr, size_t len, int prot); } + SYS_MADVISE = 75 // { int sys_madvise(void *addr, size_t len, int behav); } + SYS_UTIMES = 76 // { int sys_utimes(const char *path, const struct timeval *tptr); } + SYS_FUTIMES = 77 // { int sys_futimes(int fd, const struct timeval *tptr); } + SYS_GETGROUPS = 79 // { int sys_getgroups(int gidsetsize, gid_t *gidset); } + SYS_SETGROUPS = 80 // { int sys_setgroups(int gidsetsize, const gid_t *gidset); } + SYS_GETPGRP = 81 // { int sys_getpgrp(void); } + SYS_SETPGID = 82 // { int sys_setpgid(pid_t pid, pid_t pgid); } + SYS_FUTEX = 83 // { int sys_futex(uint32_t *f, int op, int val, const struct timespec *timeout, uint32_t *g); } + SYS_UTIMENSAT = 84 // { int sys_utimensat(int fd, const char *path, const struct timespec *times, int flag); } + SYS_FUTIMENS = 85 // { int sys_futimens(int fd, const struct timespec *times); } + SYS_KBIND = 86 // { int sys_kbind(const struct __kbind *param, size_t psize, int64_t proc_cookie); } + SYS_CLOCK_GETTIME = 87 // { int sys_clock_gettime(clockid_t clock_id, struct timespec *tp); } + SYS_CLOCK_SETTIME = 88 // { int sys_clock_settime(clockid_t clock_id, const struct timespec *tp); } + SYS_CLOCK_GETRES = 89 // { int sys_clock_getres(clockid_t clock_id, struct timespec *tp); } + SYS_DUP2 = 90 // { int sys_dup2(int from, int to); } + SYS_NANOSLEEP = 91 // { int sys_nanosleep(const struct timespec *rqtp, struct timespec *rmtp); } + SYS_FCNTL = 92 // { int sys_fcntl(int fd, int cmd, ... void *arg); } + SYS_ACCEPT4 = 93 // { int sys_accept4(int s, struct sockaddr *name, socklen_t *anamelen, int flags); } + SYS___THRSLEEP = 94 // { int sys___thrsleep(const volatile void *ident, clockid_t clock_id, const struct timespec *tp, void *lock, const int *abort); } + SYS_FSYNC = 95 // { int sys_fsync(int fd); } + SYS_SETPRIORITY = 96 // { int sys_setpriority(int which, id_t who, int prio); } + SYS_SOCKET = 97 // { int sys_socket(int domain, int type, int protocol); } + SYS_CONNECT = 98 // { int sys_connect(int s, const struct sockaddr *name, socklen_t namelen); } + SYS_GETDENTS = 99 // { int sys_getdents(int fd, void *buf, size_t buflen); } + SYS_GETPRIORITY = 100 // { int sys_getpriority(int which, id_t who); } + SYS_PIPE2 = 101 // { int sys_pipe2(int *fdp, int flags); } + SYS_DUP3 = 102 // { int sys_dup3(int from, int to, int flags); } + SYS_SIGRETURN = 103 // { int sys_sigreturn(struct sigcontext *sigcntxp); } + SYS_BIND = 104 // { int sys_bind(int s, const struct sockaddr *name, socklen_t namelen); } + SYS_SETSOCKOPT = 105 // { int sys_setsockopt(int s, int level, int name, const void *val, socklen_t valsize); } + SYS_LISTEN = 106 // { int sys_listen(int s, int backlog); } + SYS_CHFLAGSAT = 107 // { int sys_chflagsat(int fd, const char *path, u_int flags, int atflags); } + SYS_PLEDGE = 108 // { int sys_pledge(const char *promises, const char *execpromises); } + SYS_PPOLL = 109 // { int sys_ppoll(struct pollfd *fds, u_int nfds, const struct timespec *ts, const sigset_t *mask); } + SYS_PSELECT = 110 // { int sys_pselect(int nd, fd_set *in, fd_set *ou, fd_set *ex, const struct timespec *ts, const sigset_t *mask); } + SYS_SIGSUSPEND = 111 // { int sys_sigsuspend(int mask); } + SYS_SENDSYSLOG = 112 // { int sys_sendsyslog(const char *buf, size_t nbyte, int flags); } + SYS_UNVEIL = 114 // { int sys_unveil(const char *path, const char *permissions); } + SYS_GETSOCKOPT = 118 // { int sys_getsockopt(int s, int level, int name, void *val, socklen_t *avalsize); } + SYS_THRKILL = 119 // { int sys_thrkill(pid_t tid, int signum, void *tcb); } + SYS_READV = 120 // { ssize_t sys_readv(int fd, const struct iovec *iovp, int iovcnt); } + SYS_WRITEV = 121 // { ssize_t sys_writev(int fd, const struct iovec *iovp, int iovcnt); } + SYS_KILL = 122 // { int sys_kill(int pid, int signum); } + SYS_FCHOWN = 123 // { int sys_fchown(int fd, uid_t uid, gid_t gid); } + SYS_FCHMOD = 124 // { int sys_fchmod(int fd, mode_t mode); } + SYS_SETREUID = 126 // { int sys_setreuid(uid_t ruid, uid_t euid); } + SYS_SETREGID = 127 // { int sys_setregid(gid_t rgid, gid_t egid); } + SYS_RENAME = 128 // { int sys_rename(const char *from, const char *to); } + SYS_FLOCK = 131 // { int sys_flock(int fd, int how); } + SYS_MKFIFO = 132 // { int sys_mkfifo(const char *path, mode_t mode); } + SYS_SENDTO = 133 // { ssize_t sys_sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); } + SYS_SHUTDOWN = 134 // { int sys_shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int sys_socketpair(int domain, int type, int protocol, int *rsv); } + SYS_MKDIR = 136 // { int sys_mkdir(const char *path, mode_t mode); } + SYS_RMDIR = 137 // { int sys_rmdir(const char *path); } + SYS_ADJTIME = 140 // { int sys_adjtime(const struct timeval *delta, struct timeval *olddelta); } + SYS_GETLOGIN_R = 141 // { int sys_getlogin_r(char *namebuf, u_int namelen); } + SYS_SETSID = 147 // { int sys_setsid(void); } + SYS_QUOTACTL = 148 // { int sys_quotactl(const char *path, int cmd, int uid, char *arg); } + SYS_NFSSVC = 155 // { int sys_nfssvc(int flag, void *argp); } + SYS_GETFH = 161 // { int sys_getfh(const char *fname, fhandle_t *fhp); } + SYS_SYSARCH = 165 // { int sys_sysarch(int op, void *parms); } + SYS_PREAD = 173 // { ssize_t sys_pread(int fd, void *buf, size_t nbyte, int pad, off_t offset); } + SYS_PWRITE = 174 // { ssize_t sys_pwrite(int fd, const void *buf, size_t nbyte, int pad, off_t offset); } + SYS_SETGID = 181 // { int sys_setgid(gid_t gid); } + SYS_SETEGID = 182 // { int sys_setegid(gid_t egid); } + SYS_SETEUID = 183 // { int sys_seteuid(uid_t euid); } + SYS_PATHCONF = 191 // { long sys_pathconf(const char *path, int name); } + SYS_FPATHCONF = 192 // { long sys_fpathconf(int fd, int name); } + SYS_SWAPCTL = 193 // { int sys_swapctl(int cmd, const void *arg, int misc); } + SYS_GETRLIMIT = 194 // { int sys_getrlimit(int which, struct rlimit *rlp); } + SYS_SETRLIMIT = 195 // { int sys_setrlimit(int which, const struct rlimit *rlp); } + SYS_MMAP = 197 // { void *sys_mmap(void *addr, size_t len, int prot, int flags, int fd, long pad, off_t pos); } + SYS_LSEEK = 199 // { off_t sys_lseek(int fd, int pad, off_t offset, int whence); } + SYS_TRUNCATE = 200 // { int sys_truncate(const char *path, int pad, off_t length); } + SYS_FTRUNCATE = 201 // { int sys_ftruncate(int fd, int pad, off_t length); } + SYS_SYSCTL = 202 // { int sys_sysctl(const int *name, u_int namelen, void *old, size_t *oldlenp, void *new, size_t newlen); } + SYS_MLOCK = 203 // { int sys_mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int sys_munlock(const void *addr, size_t len); } + SYS_GETPGID = 207 // { pid_t sys_getpgid(pid_t pid); } + SYS_UTRACE = 209 // { int sys_utrace(const char *label, const void *addr, size_t len); } + SYS_SEMGET = 221 // { int sys_semget(key_t key, int nsems, int semflg); } + SYS_MSGGET = 225 // { int sys_msgget(key_t key, int msgflg); } + SYS_MSGSND = 226 // { int sys_msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg); } + SYS_MSGRCV = 227 // { int sys_msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); } + SYS_SHMAT = 228 // { void *sys_shmat(int shmid, const void *shmaddr, int shmflg); } + SYS_SHMDT = 230 // { int sys_shmdt(const void *shmaddr); } + SYS_MINHERIT = 250 // { int sys_minherit(void *addr, size_t len, int inherit); } + SYS_POLL = 252 // { int sys_poll(struct pollfd *fds, u_int nfds, int timeout); } + SYS_ISSETUGID = 253 // { int sys_issetugid(void); } + SYS_LCHOWN = 254 // { int sys_lchown(const char *path, uid_t uid, gid_t gid); } + SYS_GETSID = 255 // { pid_t sys_getsid(pid_t pid); } + SYS_MSYNC = 256 // { int sys_msync(void *addr, size_t len, int flags); } + SYS_PIPE = 263 // { int sys_pipe(int *fdp); } + SYS_FHOPEN = 264 // { int sys_fhopen(const fhandle_t *fhp, int flags); } + SYS_PREADV = 267 // { ssize_t sys_preadv(int fd, const struct iovec *iovp, int iovcnt, int pad, off_t offset); } + SYS_PWRITEV = 268 // { ssize_t sys_pwritev(int fd, const struct iovec *iovp, int iovcnt, int pad, off_t offset); } + SYS_KQUEUE = 269 // { int sys_kqueue(void); } + SYS_MLOCKALL = 271 // { int sys_mlockall(int flags); } + SYS_MUNLOCKALL = 272 // { int sys_munlockall(void); } + SYS_GETRESUID = 281 // { int sys_getresuid(uid_t *ruid, uid_t *euid, uid_t *suid); } + SYS_SETRESUID = 282 // { int sys_setresuid(uid_t ruid, uid_t euid, uid_t suid); } + SYS_GETRESGID = 283 // { int sys_getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); } + SYS_SETRESGID = 284 // { int sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid); } + SYS_MQUERY = 286 // { void *sys_mquery(void *addr, size_t len, int prot, int flags, int fd, long pad, off_t pos); } + SYS_CLOSEFROM = 287 // { int sys_closefrom(int fd); } + SYS_SIGALTSTACK = 288 // { int sys_sigaltstack(const struct sigaltstack *nss, struct sigaltstack *oss); } + SYS_SHMGET = 289 // { int sys_shmget(key_t key, size_t size, int shmflg); } + SYS_SEMOP = 290 // { int sys_semop(int semid, struct sembuf *sops, size_t nsops); } + SYS_FHSTAT = 294 // { int sys_fhstat(const fhandle_t *fhp, struct stat *sb); } + SYS___SEMCTL = 295 // { int sys___semctl(int semid, int semnum, int cmd, union semun *arg); } + SYS_SHMCTL = 296 // { int sys_shmctl(int shmid, int cmd, struct shmid_ds *buf); } + SYS_MSGCTL = 297 // { int sys_msgctl(int msqid, int cmd, struct msqid_ds *buf); } + SYS_SCHED_YIELD = 298 // { int sys_sched_yield(void); } + SYS_GETTHRID = 299 // { pid_t sys_getthrid(void); } + SYS___THRWAKEUP = 301 // { int sys___thrwakeup(const volatile void *ident, int n); } + SYS___THREXIT = 302 // { void sys___threxit(pid_t *notdead); } + SYS___THRSIGDIVERT = 303 // { int sys___thrsigdivert(sigset_t sigmask, siginfo_t *info, const struct timespec *timeout); } + SYS___GETCWD = 304 // { int sys___getcwd(char *buf, size_t len); } + SYS_ADJFREQ = 305 // { int sys_adjfreq(const int64_t *freq, int64_t *oldfreq); } + SYS_SETRTABLE = 310 // { int sys_setrtable(int rtableid); } + SYS_GETRTABLE = 311 // { int sys_getrtable(void); } + SYS_FACCESSAT = 313 // { int sys_faccessat(int fd, const char *path, int amode, int flag); } + SYS_FCHMODAT = 314 // { int sys_fchmodat(int fd, const char *path, mode_t mode, int flag); } + SYS_FCHOWNAT = 315 // { int sys_fchownat(int fd, const char *path, uid_t uid, gid_t gid, int flag); } + SYS_LINKAT = 317 // { int sys_linkat(int fd1, const char *path1, int fd2, const char *path2, int flag); } + SYS_MKDIRAT = 318 // { int sys_mkdirat(int fd, const char *path, mode_t mode); } + SYS_MKFIFOAT = 319 // { int sys_mkfifoat(int fd, const char *path, mode_t mode); } + SYS_MKNODAT = 320 // { int sys_mknodat(int fd, const char *path, mode_t mode, dev_t dev); } + SYS_OPENAT = 321 // { int sys_openat(int fd, const char *path, int flags, ... mode_t mode); } + SYS_READLINKAT = 322 // { ssize_t sys_readlinkat(int fd, const char *path, char *buf, size_t count); } + SYS_RENAMEAT = 323 // { int sys_renameat(int fromfd, const char *from, int tofd, const char *to); } + SYS_SYMLINKAT = 324 // { int sys_symlinkat(const char *path, int fd, const char *link); } + SYS_UNLINKAT = 325 // { int sys_unlinkat(int fd, const char *path, int flag); } + SYS___SET_TCB = 329 // { void sys___set_tcb(void *tcb); } + SYS___GET_TCB = 330 // { void *sys___get_tcb(void); } +) diff --git a/vendor/golang.org/x/sys/unix/zsysnum_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_riscv64.go new file mode 100644 index 0000000000..07919e0ecc --- /dev/null +++ b/vendor/golang.org/x/sys/unix/zsysnum_openbsd_riscv64.go @@ -0,0 +1,219 @@ +// go run mksysnum.go https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build riscv64 && openbsd +// +build riscv64,openbsd + +package unix + +// Deprecated: Use libc wrappers instead of direct syscalls. +const ( + SYS_EXIT = 1 // { void sys_exit(int rval); } + SYS_FORK = 2 // { int sys_fork(void); } + SYS_READ = 3 // { ssize_t sys_read(int fd, void *buf, size_t nbyte); } + SYS_WRITE = 4 // { ssize_t sys_write(int fd, const void *buf, size_t nbyte); } + SYS_OPEN = 5 // { int sys_open(const char *path, int flags, ... mode_t mode); } + SYS_CLOSE = 6 // { int sys_close(int fd); } + SYS_GETENTROPY = 7 // { int sys_getentropy(void *buf, size_t nbyte); } + SYS___TFORK = 8 // { int sys___tfork(const struct __tfork *param, size_t psize); } + SYS_LINK = 9 // { int sys_link(const char *path, const char *link); } + SYS_UNLINK = 10 // { int sys_unlink(const char *path); } + SYS_WAIT4 = 11 // { pid_t sys_wait4(pid_t pid, int *status, int options, struct rusage *rusage); } + SYS_CHDIR = 12 // { int sys_chdir(const char *path); } + SYS_FCHDIR = 13 // { int sys_fchdir(int fd); } + SYS_MKNOD = 14 // { int sys_mknod(const char *path, mode_t mode, dev_t dev); } + SYS_CHMOD = 15 // { int sys_chmod(const char *path, mode_t mode); } + SYS_CHOWN = 16 // { int sys_chown(const char *path, uid_t uid, gid_t gid); } + SYS_OBREAK = 17 // { int sys_obreak(char *nsize); } break + SYS_GETDTABLECOUNT = 18 // { int sys_getdtablecount(void); } + SYS_GETRUSAGE = 19 // { int sys_getrusage(int who, struct rusage *rusage); } + SYS_GETPID = 20 // { pid_t sys_getpid(void); } + SYS_MOUNT = 21 // { int sys_mount(const char *type, const char *path, int flags, void *data); } + SYS_UNMOUNT = 22 // { int sys_unmount(const char *path, int flags); } + SYS_SETUID = 23 // { int sys_setuid(uid_t uid); } + SYS_GETUID = 24 // { uid_t sys_getuid(void); } + SYS_GETEUID = 25 // { uid_t sys_geteuid(void); } + SYS_PTRACE = 26 // { int sys_ptrace(int req, pid_t pid, caddr_t addr, int data); } + SYS_RECVMSG = 27 // { ssize_t sys_recvmsg(int s, struct msghdr *msg, int flags); } + SYS_SENDMSG = 28 // { ssize_t sys_sendmsg(int s, const struct msghdr *msg, int flags); } + SYS_RECVFROM = 29 // { ssize_t sys_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlenaddr); } + SYS_ACCEPT = 30 // { int sys_accept(int s, struct sockaddr *name, socklen_t *anamelen); } + SYS_GETPEERNAME = 31 // { int sys_getpeername(int fdes, struct sockaddr *asa, socklen_t *alen); } + SYS_GETSOCKNAME = 32 // { int sys_getsockname(int fdes, struct sockaddr *asa, socklen_t *alen); } + SYS_ACCESS = 33 // { int sys_access(const char *path, int amode); } + SYS_CHFLAGS = 34 // { int sys_chflags(const char *path, u_int flags); } + SYS_FCHFLAGS = 35 // { int sys_fchflags(int fd, u_int flags); } + SYS_SYNC = 36 // { void sys_sync(void); } + SYS_STAT = 38 // { int sys_stat(const char *path, struct stat *ub); } + SYS_GETPPID = 39 // { pid_t sys_getppid(void); } + SYS_LSTAT = 40 // { int sys_lstat(const char *path, struct stat *ub); } + SYS_DUP = 41 // { int sys_dup(int fd); } + SYS_FSTATAT = 42 // { int sys_fstatat(int fd, const char *path, struct stat *buf, int flag); } + SYS_GETEGID = 43 // { gid_t sys_getegid(void); } + SYS_PROFIL = 44 // { int sys_profil(caddr_t samples, size_t size, u_long offset, u_int scale); } + SYS_KTRACE = 45 // { int sys_ktrace(const char *fname, int ops, int facs, pid_t pid); } + SYS_SIGACTION = 46 // { int sys_sigaction(int signum, const struct sigaction *nsa, struct sigaction *osa); } + SYS_GETGID = 47 // { gid_t sys_getgid(void); } + SYS_SIGPROCMASK = 48 // { int sys_sigprocmask(int how, sigset_t mask); } + SYS_SETLOGIN = 50 // { int sys_setlogin(const char *namebuf); } + SYS_ACCT = 51 // { int sys_acct(const char *path); } + SYS_SIGPENDING = 52 // { int sys_sigpending(void); } + SYS_FSTAT = 53 // { int sys_fstat(int fd, struct stat *sb); } + SYS_IOCTL = 54 // { int sys_ioctl(int fd, u_long com, ... void *data); } + SYS_REBOOT = 55 // { int sys_reboot(int opt); } + SYS_REVOKE = 56 // { int sys_revoke(const char *path); } + SYS_SYMLINK = 57 // { int sys_symlink(const char *path, const char *link); } + SYS_READLINK = 58 // { ssize_t sys_readlink(const char *path, char *buf, size_t count); } + SYS_EXECVE = 59 // { int sys_execve(const char *path, char * const *argp, char * const *envp); } + SYS_UMASK = 60 // { mode_t sys_umask(mode_t newmask); } + SYS_CHROOT = 61 // { int sys_chroot(const char *path); } + SYS_GETFSSTAT = 62 // { int sys_getfsstat(struct statfs *buf, size_t bufsize, int flags); } + SYS_STATFS = 63 // { int sys_statfs(const char *path, struct statfs *buf); } + SYS_FSTATFS = 64 // { int sys_fstatfs(int fd, struct statfs *buf); } + SYS_FHSTATFS = 65 // { int sys_fhstatfs(const fhandle_t *fhp, struct statfs *buf); } + SYS_VFORK = 66 // { int sys_vfork(void); } + SYS_GETTIMEOFDAY = 67 // { int sys_gettimeofday(struct timeval *tp, struct timezone *tzp); } + SYS_SETTIMEOFDAY = 68 // { int sys_settimeofday(const struct timeval *tv, const struct timezone *tzp); } + SYS_SETITIMER = 69 // { int sys_setitimer(int which, const struct itimerval *itv, struct itimerval *oitv); } + SYS_GETITIMER = 70 // { int sys_getitimer(int which, struct itimerval *itv); } + SYS_SELECT = 71 // { int sys_select(int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timeval *tv); } + SYS_KEVENT = 72 // { int sys_kevent(int fd, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout); } + SYS_MUNMAP = 73 // { int sys_munmap(void *addr, size_t len); } + SYS_MPROTECT = 74 // { int sys_mprotect(void *addr, size_t len, int prot); } + SYS_MADVISE = 75 // { int sys_madvise(void *addr, size_t len, int behav); } + SYS_UTIMES = 76 // { int sys_utimes(const char *path, const struct timeval *tptr); } + SYS_FUTIMES = 77 // { int sys_futimes(int fd, const struct timeval *tptr); } + SYS_GETGROUPS = 79 // { int sys_getgroups(int gidsetsize, gid_t *gidset); } + SYS_SETGROUPS = 80 // { int sys_setgroups(int gidsetsize, const gid_t *gidset); } + SYS_GETPGRP = 81 // { int sys_getpgrp(void); } + SYS_SETPGID = 82 // { int sys_setpgid(pid_t pid, pid_t pgid); } + SYS_FUTEX = 83 // { int sys_futex(uint32_t *f, int op, int val, const struct timespec *timeout, uint32_t *g); } + SYS_UTIMENSAT = 84 // { int sys_utimensat(int fd, const char *path, const struct timespec *times, int flag); } + SYS_FUTIMENS = 85 // { int sys_futimens(int fd, const struct timespec *times); } + SYS_KBIND = 86 // { int sys_kbind(const struct __kbind *param, size_t psize, int64_t proc_cookie); } + SYS_CLOCK_GETTIME = 87 // { int sys_clock_gettime(clockid_t clock_id, struct timespec *tp); } + SYS_CLOCK_SETTIME = 88 // { int sys_clock_settime(clockid_t clock_id, const struct timespec *tp); } + SYS_CLOCK_GETRES = 89 // { int sys_clock_getres(clockid_t clock_id, struct timespec *tp); } + SYS_DUP2 = 90 // { int sys_dup2(int from, int to); } + SYS_NANOSLEEP = 91 // { int sys_nanosleep(const struct timespec *rqtp, struct timespec *rmtp); } + SYS_FCNTL = 92 // { int sys_fcntl(int fd, int cmd, ... void *arg); } + SYS_ACCEPT4 = 93 // { int sys_accept4(int s, struct sockaddr *name, socklen_t *anamelen, int flags); } + SYS___THRSLEEP = 94 // { int sys___thrsleep(const volatile void *ident, clockid_t clock_id, const struct timespec *tp, void *lock, const int *abort); } + SYS_FSYNC = 95 // { int sys_fsync(int fd); } + SYS_SETPRIORITY = 96 // { int sys_setpriority(int which, id_t who, int prio); } + SYS_SOCKET = 97 // { int sys_socket(int domain, int type, int protocol); } + SYS_CONNECT = 98 // { int sys_connect(int s, const struct sockaddr *name, socklen_t namelen); } + SYS_GETDENTS = 99 // { int sys_getdents(int fd, void *buf, size_t buflen); } + SYS_GETPRIORITY = 100 // { int sys_getpriority(int which, id_t who); } + SYS_PIPE2 = 101 // { int sys_pipe2(int *fdp, int flags); } + SYS_DUP3 = 102 // { int sys_dup3(int from, int to, int flags); } + SYS_SIGRETURN = 103 // { int sys_sigreturn(struct sigcontext *sigcntxp); } + SYS_BIND = 104 // { int sys_bind(int s, const struct sockaddr *name, socklen_t namelen); } + SYS_SETSOCKOPT = 105 // { int sys_setsockopt(int s, int level, int name, const void *val, socklen_t valsize); } + SYS_LISTEN = 106 // { int sys_listen(int s, int backlog); } + SYS_CHFLAGSAT = 107 // { int sys_chflagsat(int fd, const char *path, u_int flags, int atflags); } + SYS_PLEDGE = 108 // { int sys_pledge(const char *promises, const char *execpromises); } + SYS_PPOLL = 109 // { int sys_ppoll(struct pollfd *fds, u_int nfds, const struct timespec *ts, const sigset_t *mask); } + SYS_PSELECT = 110 // { int sys_pselect(int nd, fd_set *in, fd_set *ou, fd_set *ex, const struct timespec *ts, const sigset_t *mask); } + SYS_SIGSUSPEND = 111 // { int sys_sigsuspend(int mask); } + SYS_SENDSYSLOG = 112 // { int sys_sendsyslog(const char *buf, size_t nbyte, int flags); } + SYS_UNVEIL = 114 // { int sys_unveil(const char *path, const char *permissions); } + SYS_GETSOCKOPT = 118 // { int sys_getsockopt(int s, int level, int name, void *val, socklen_t *avalsize); } + SYS_THRKILL = 119 // { int sys_thrkill(pid_t tid, int signum, void *tcb); } + SYS_READV = 120 // { ssize_t sys_readv(int fd, const struct iovec *iovp, int iovcnt); } + SYS_WRITEV = 121 // { ssize_t sys_writev(int fd, const struct iovec *iovp, int iovcnt); } + SYS_KILL = 122 // { int sys_kill(int pid, int signum); } + SYS_FCHOWN = 123 // { int sys_fchown(int fd, uid_t uid, gid_t gid); } + SYS_FCHMOD = 124 // { int sys_fchmod(int fd, mode_t mode); } + SYS_SETREUID = 126 // { int sys_setreuid(uid_t ruid, uid_t euid); } + SYS_SETREGID = 127 // { int sys_setregid(gid_t rgid, gid_t egid); } + SYS_RENAME = 128 // { int sys_rename(const char *from, const char *to); } + SYS_FLOCK = 131 // { int sys_flock(int fd, int how); } + SYS_MKFIFO = 132 // { int sys_mkfifo(const char *path, mode_t mode); } + SYS_SENDTO = 133 // { ssize_t sys_sendto(int s, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen); } + SYS_SHUTDOWN = 134 // { int sys_shutdown(int s, int how); } + SYS_SOCKETPAIR = 135 // { int sys_socketpair(int domain, int type, int protocol, int *rsv); } + SYS_MKDIR = 136 // { int sys_mkdir(const char *path, mode_t mode); } + SYS_RMDIR = 137 // { int sys_rmdir(const char *path); } + SYS_ADJTIME = 140 // { int sys_adjtime(const struct timeval *delta, struct timeval *olddelta); } + SYS_GETLOGIN_R = 141 // { int sys_getlogin_r(char *namebuf, u_int namelen); } + SYS_SETSID = 147 // { int sys_setsid(void); } + SYS_QUOTACTL = 148 // { int sys_quotactl(const char *path, int cmd, int uid, char *arg); } + SYS_NFSSVC = 155 // { int sys_nfssvc(int flag, void *argp); } + SYS_GETFH = 161 // { int sys_getfh(const char *fname, fhandle_t *fhp); } + SYS_SYSARCH = 165 // { int sys_sysarch(int op, void *parms); } + SYS_PREAD = 173 // { ssize_t sys_pread(int fd, void *buf, size_t nbyte, int pad, off_t offset); } + SYS_PWRITE = 174 // { ssize_t sys_pwrite(int fd, const void *buf, size_t nbyte, int pad, off_t offset); } + SYS_SETGID = 181 // { int sys_setgid(gid_t gid); } + SYS_SETEGID = 182 // { int sys_setegid(gid_t egid); } + SYS_SETEUID = 183 // { int sys_seteuid(uid_t euid); } + SYS_PATHCONF = 191 // { long sys_pathconf(const char *path, int name); } + SYS_FPATHCONF = 192 // { long sys_fpathconf(int fd, int name); } + SYS_SWAPCTL = 193 // { int sys_swapctl(int cmd, const void *arg, int misc); } + SYS_GETRLIMIT = 194 // { int sys_getrlimit(int which, struct rlimit *rlp); } + SYS_SETRLIMIT = 195 // { int sys_setrlimit(int which, const struct rlimit *rlp); } + SYS_MMAP = 197 // { void *sys_mmap(void *addr, size_t len, int prot, int flags, int fd, long pad, off_t pos); } + SYS_LSEEK = 199 // { off_t sys_lseek(int fd, int pad, off_t offset, int whence); } + SYS_TRUNCATE = 200 // { int sys_truncate(const char *path, int pad, off_t length); } + SYS_FTRUNCATE = 201 // { int sys_ftruncate(int fd, int pad, off_t length); } + SYS_SYSCTL = 202 // { int sys_sysctl(const int *name, u_int namelen, void *old, size_t *oldlenp, void *new, size_t newlen); } + SYS_MLOCK = 203 // { int sys_mlock(const void *addr, size_t len); } + SYS_MUNLOCK = 204 // { int sys_munlock(const void *addr, size_t len); } + SYS_GETPGID = 207 // { pid_t sys_getpgid(pid_t pid); } + SYS_UTRACE = 209 // { int sys_utrace(const char *label, const void *addr, size_t len); } + SYS_SEMGET = 221 // { int sys_semget(key_t key, int nsems, int semflg); } + SYS_MSGGET = 225 // { int sys_msgget(key_t key, int msgflg); } + SYS_MSGSND = 226 // { int sys_msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg); } + SYS_MSGRCV = 227 // { int sys_msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); } + SYS_SHMAT = 228 // { void *sys_shmat(int shmid, const void *shmaddr, int shmflg); } + SYS_SHMDT = 230 // { int sys_shmdt(const void *shmaddr); } + SYS_MINHERIT = 250 // { int sys_minherit(void *addr, size_t len, int inherit); } + SYS_POLL = 252 // { int sys_poll(struct pollfd *fds, u_int nfds, int timeout); } + SYS_ISSETUGID = 253 // { int sys_issetugid(void); } + SYS_LCHOWN = 254 // { int sys_lchown(const char *path, uid_t uid, gid_t gid); } + SYS_GETSID = 255 // { pid_t sys_getsid(pid_t pid); } + SYS_MSYNC = 256 // { int sys_msync(void *addr, size_t len, int flags); } + SYS_PIPE = 263 // { int sys_pipe(int *fdp); } + SYS_FHOPEN = 264 // { int sys_fhopen(const fhandle_t *fhp, int flags); } + SYS_PREADV = 267 // { ssize_t sys_preadv(int fd, const struct iovec *iovp, int iovcnt, int pad, off_t offset); } + SYS_PWRITEV = 268 // { ssize_t sys_pwritev(int fd, const struct iovec *iovp, int iovcnt, int pad, off_t offset); } + SYS_KQUEUE = 269 // { int sys_kqueue(void); } + SYS_MLOCKALL = 271 // { int sys_mlockall(int flags); } + SYS_MUNLOCKALL = 272 // { int sys_munlockall(void); } + SYS_GETRESUID = 281 // { int sys_getresuid(uid_t *ruid, uid_t *euid, uid_t *suid); } + SYS_SETRESUID = 282 // { int sys_setresuid(uid_t ruid, uid_t euid, uid_t suid); } + SYS_GETRESGID = 283 // { int sys_getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); } + SYS_SETRESGID = 284 // { int sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid); } + SYS_MQUERY = 286 // { void *sys_mquery(void *addr, size_t len, int prot, int flags, int fd, long pad, off_t pos); } + SYS_CLOSEFROM = 287 // { int sys_closefrom(int fd); } + SYS_SIGALTSTACK = 288 // { int sys_sigaltstack(const struct sigaltstack *nss, struct sigaltstack *oss); } + SYS_SHMGET = 289 // { int sys_shmget(key_t key, size_t size, int shmflg); } + SYS_SEMOP = 290 // { int sys_semop(int semid, struct sembuf *sops, size_t nsops); } + SYS_FHSTAT = 294 // { int sys_fhstat(const fhandle_t *fhp, struct stat *sb); } + SYS___SEMCTL = 295 // { int sys___semctl(int semid, int semnum, int cmd, union semun *arg); } + SYS_SHMCTL = 296 // { int sys_shmctl(int shmid, int cmd, struct shmid_ds *buf); } + SYS_MSGCTL = 297 // { int sys_msgctl(int msqid, int cmd, struct msqid_ds *buf); } + SYS_SCHED_YIELD = 298 // { int sys_sched_yield(void); } + SYS_GETTHRID = 299 // { pid_t sys_getthrid(void); } + SYS___THRWAKEUP = 301 // { int sys___thrwakeup(const volatile void *ident, int n); } + SYS___THREXIT = 302 // { void sys___threxit(pid_t *notdead); } + SYS___THRSIGDIVERT = 303 // { int sys___thrsigdivert(sigset_t sigmask, siginfo_t *info, const struct timespec *timeout); } + SYS___GETCWD = 304 // { int sys___getcwd(char *buf, size_t len); } + SYS_ADJFREQ = 305 // { int sys_adjfreq(const int64_t *freq, int64_t *oldfreq); } + SYS_SETRTABLE = 310 // { int sys_setrtable(int rtableid); } + SYS_GETRTABLE = 311 // { int sys_getrtable(void); } + SYS_FACCESSAT = 313 // { int sys_faccessat(int fd, const char *path, int amode, int flag); } + SYS_FCHMODAT = 314 // { int sys_fchmodat(int fd, const char *path, mode_t mode, int flag); } + SYS_FCHOWNAT = 315 // { int sys_fchownat(int fd, const char *path, uid_t uid, gid_t gid, int flag); } + SYS_LINKAT = 317 // { int sys_linkat(int fd1, const char *path1, int fd2, const char *path2, int flag); } + SYS_MKDIRAT = 318 // { int sys_mkdirat(int fd, const char *path, mode_t mode); } + SYS_MKFIFOAT = 319 // { int sys_mkfifoat(int fd, const char *path, mode_t mode); } + SYS_MKNODAT = 320 // { int sys_mknodat(int fd, const char *path, mode_t mode, dev_t dev); } + SYS_OPENAT = 321 // { int sys_openat(int fd, const char *path, int flags, ... mode_t mode); } + SYS_READLINKAT = 322 // { ssize_t sys_readlinkat(int fd, const char *path, char *buf, size_t count); } + SYS_RENAMEAT = 323 // { int sys_renameat(int fromfd, const char *from, int tofd, const char *to); } + SYS_SYMLINKAT = 324 // { int sys_symlinkat(const char *path, int fd, const char *link); } + SYS_UNLINKAT = 325 // { int sys_unlinkat(int fd, const char *path, int flag); } + SYS___SET_TCB = 329 // { void sys___set_tcb(void *tcb); } + SYS___GET_TCB = 330 // { void *sys___get_tcb(void); } +) diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go index dea0c9a607..d9c78cdcbc 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go @@ -294,7 +294,7 @@ type PtraceLwpInfoStruct struct { Flags int32 Sigmask Sigset_t Siglist Sigset_t - Siginfo __Siginfo + Siginfo __PtraceSiginfo Tdname [20]int8 Child_pid int32 Syscall_code uint32 @@ -312,6 +312,17 @@ type __Siginfo struct { Value [4]byte _ [32]byte } +type __PtraceSiginfo struct { + Signo int32 + Errno int32 + Code int32 + Pid int32 + Uid uint32 + Status int32 + Addr uintptr + Value [4]byte + _ [32]byte +} type Sigset_t struct { Val [4]uint32 @@ -350,8 +361,8 @@ type FpExtendedPrecision struct{} type PtraceIoDesc struct { Op int32 - Offs *byte - Addr *byte + Offs uintptr + Addr uintptr Len uint32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go index da0ea0d608..26991b1655 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go @@ -291,7 +291,7 @@ type PtraceLwpInfoStruct struct { Flags int32 Sigmask Sigset_t Siglist Sigset_t - Siginfo __Siginfo + Siginfo __PtraceSiginfo Tdname [20]int8 Child_pid int32 Syscall_code uint32 @@ -310,6 +310,18 @@ type __Siginfo struct { _ [40]byte } +type __PtraceSiginfo struct { + Signo int32 + Errno int32 + Code int32 + Pid int32 + Uid uint32 + Status int32 + Addr uintptr + Value [8]byte + _ [40]byte +} + type Sigset_t struct { Val [4]uint32 } @@ -354,8 +366,8 @@ type FpExtendedPrecision struct{} type PtraceIoDesc struct { Op int32 - Offs *byte - Addr *byte + Offs uintptr + Addr uintptr Len uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go index da8f740450..f8324e7e7f 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go @@ -293,7 +293,7 @@ type PtraceLwpInfoStruct struct { Flags int32 Sigmask Sigset_t Siglist Sigset_t - Siginfo __Siginfo + Siginfo __PtraceSiginfo Tdname [20]int8 Child_pid int32 Syscall_code uint32 @@ -312,6 +312,18 @@ type __Siginfo struct { _ [32]byte } +type __PtraceSiginfo struct { + Signo int32 + Errno int32 + Code int32 + Pid int32 + Uid uint32 + Status int32 + Addr uintptr + Value [4]byte + _ [32]byte +} + type Sigset_t struct { Val [4]uint32 } @@ -337,8 +349,8 @@ type FpExtendedPrecision struct { type PtraceIoDesc struct { Op int32 - Offs *byte - Addr *byte + Offs uintptr + Addr uintptr Len uint32 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go index d69988e5e5..4220411f34 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go @@ -291,7 +291,7 @@ type PtraceLwpInfoStruct struct { Flags int32 Sigmask Sigset_t Siglist Sigset_t - Siginfo __Siginfo + Siginfo __PtraceSiginfo Tdname [20]int8 Child_pid int32 Syscall_code uint32 @@ -310,6 +310,18 @@ type __Siginfo struct { _ [40]byte } +type __PtraceSiginfo struct { + Signo int32 + Errno int32 + Code int32 + Pid int32 + Uid uint32 + Status int32 + Addr uintptr + Value [8]byte + _ [40]byte +} + type Sigset_t struct { Val [4]uint32 } @@ -334,8 +346,8 @@ type FpExtendedPrecision struct{} type PtraceIoDesc struct { Op int32 - Offs *byte - Addr *byte + Offs uintptr + Addr uintptr Len uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go index d6fd9e8838..0660fd45c7 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go @@ -291,7 +291,7 @@ type PtraceLwpInfoStruct struct { Flags int32 Sigmask Sigset_t Siglist Sigset_t - Siginfo __Siginfo + Siginfo __PtraceSiginfo Tdname [20]int8 Child_pid int32 Syscall_code uint32 @@ -310,6 +310,18 @@ type __Siginfo struct { _ [40]byte } +type __PtraceSiginfo struct { + Signo int32 + Errno int32 + Code int32 + Pid int32 + Uid uint32 + Status int32 + Addr uintptr + Value [8]byte + _ [40]byte +} + type Sigset_t struct { Val [4]uint32 } @@ -335,8 +347,8 @@ type FpExtendedPrecision struct{} type PtraceIoDesc struct { Op int32 - Offs *byte - Addr *byte + Offs uintptr + Addr uintptr Len uint64 } diff --git a/vendor/golang.org/x/sys/unix/ztypes_illumos_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_illumos_amd64.go deleted file mode 100644 index 4c485261d6..0000000000 --- a/vendor/golang.org/x/sys/unix/ztypes_illumos_amd64.go +++ /dev/null @@ -1,42 +0,0 @@ -// cgo -godefs types_illumos.go | go run mkpost.go -// Code generated by the command above; see README.md. DO NOT EDIT. - -//go:build amd64 && illumos -// +build amd64,illumos - -package unix - -const ( - TUNNEWPPA = 0x540001 - TUNSETPPA = 0x540002 - - I_STR = 0x5308 - I_POP = 0x5303 - I_PUSH = 0x5302 - I_LINK = 0x530c - I_UNLINK = 0x530d - I_PLINK = 0x5316 - I_PUNLINK = 0x5317 - - IF_UNITSEL = -0x7ffb8cca -) - -type strbuf struct { - Maxlen int32 - Len int32 - Buf *int8 -} - -type Strioctl struct { - Cmd int32 - Timout int32 - Len int32 - Dp *int8 -} - -type Lifreq struct { - Name [32]int8 - Lifru1 [4]byte - Type uint32 - Lifru [336]byte -} diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go index 2636044018..89c516a29a 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_386.go @@ -254,6 +254,12 @@ type Sigset_t struct { const _C__NSIG = 0x41 +const ( + SIG_BLOCK = 0x0 + SIG_UNBLOCK = 0x1 + SIG_SETMASK = 0x2 +) + type Siginfo struct { Signo int32 Errno int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go index 8187489d16..62b4fb2699 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_amd64.go @@ -269,6 +269,12 @@ type Sigset_t struct { const _C__NSIG = 0x41 +const ( + SIG_BLOCK = 0x0 + SIG_UNBLOCK = 0x1 + SIG_SETMASK = 0x2 +) + type Siginfo struct { Signo int32 Errno int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go index d1612335f4..e86b35893e 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm.go @@ -245,6 +245,12 @@ type Sigset_t struct { const _C__NSIG = 0x41 +const ( + SIG_BLOCK = 0x0 + SIG_UNBLOCK = 0x1 + SIG_SETMASK = 0x2 +) + type Siginfo struct { Signo int32 Errno int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go index c28e5556b0..6c6be4c911 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_arm64.go @@ -248,6 +248,12 @@ type Sigset_t struct { const _C__NSIG = 0x41 +const ( + SIG_BLOCK = 0x0 + SIG_UNBLOCK = 0x1 + SIG_SETMASK = 0x2 +) + type Siginfo struct { Signo int32 Errno int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go index 187061f9f8..4982ea355a 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_loong64.go @@ -249,6 +249,12 @@ type Sigset_t struct { const _C__NSIG = 0x41 +const ( + SIG_BLOCK = 0x0 + SIG_UNBLOCK = 0x1 + SIG_SETMASK = 0x2 +) + type Siginfo struct { Signo int32 Errno int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go index 369129917a..173141a670 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips.go @@ -250,6 +250,12 @@ type Sigset_t struct { const _C__NSIG = 0x80 +const ( + SIG_BLOCK = 0x1 + SIG_UNBLOCK = 0x2 + SIG_SETMASK = 0x3 +) + type Siginfo struct { Signo int32 Code int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go index 7473468d71..93ae4c5167 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64.go @@ -251,6 +251,12 @@ type Sigset_t struct { const _C__NSIG = 0x80 +const ( + SIG_BLOCK = 0x1 + SIG_UNBLOCK = 0x2 + SIG_SETMASK = 0x3 +) + type Siginfo struct { Signo int32 Code int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go index ed9448524b..4e4e510ca5 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go @@ -251,6 +251,12 @@ type Sigset_t struct { const _C__NSIG = 0x80 +const ( + SIG_BLOCK = 0x1 + SIG_UNBLOCK = 0x2 + SIG_SETMASK = 0x3 +) + type Siginfo struct { Signo int32 Code int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go index 0892a73a4b..3f5ba013d9 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go @@ -250,6 +250,12 @@ type Sigset_t struct { const _C__NSIG = 0x80 +const ( + SIG_BLOCK = 0x1 + SIG_UNBLOCK = 0x2 + SIG_SETMASK = 0x3 +) + type Siginfo struct { Signo int32 Code int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go index e1dd483333..71dfe7cdb4 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc.go @@ -257,6 +257,12 @@ type Sigset_t struct { const _C__NSIG = 0x41 +const ( + SIG_BLOCK = 0x0 + SIG_UNBLOCK = 0x1 + SIG_SETMASK = 0x2 +) + type Siginfo struct { Signo int32 Errno int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go index d9f654c7b1..3a2b7f0a66 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go @@ -258,6 +258,12 @@ type Sigset_t struct { const _C__NSIG = 0x41 +const ( + SIG_BLOCK = 0x0 + SIG_UNBLOCK = 0x1 + SIG_SETMASK = 0x2 +) + type Siginfo struct { Signo int32 Errno int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go index 74acda9fe4..a52d627563 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go @@ -258,6 +258,12 @@ type Sigset_t struct { const _C__NSIG = 0x41 +const ( + SIG_BLOCK = 0x0 + SIG_UNBLOCK = 0x1 + SIG_SETMASK = 0x2 +) + type Siginfo struct { Signo int32 Errno int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go index 50ebe69ebc..dfc007d8a6 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go @@ -276,6 +276,12 @@ type Sigset_t struct { const _C__NSIG = 0x41 +const ( + SIG_BLOCK = 0x0 + SIG_UNBLOCK = 0x1 + SIG_SETMASK = 0x2 +) + type Siginfo struct { Signo int32 Errno int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go index 75b34c2599..b53cb9103d 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_s390x.go @@ -271,6 +271,12 @@ type Sigset_t struct { const _C__NSIG = 0x41 +const ( + SIG_BLOCK = 0x0 + SIG_UNBLOCK = 0x1 + SIG_SETMASK = 0x2 +) + type Siginfo struct { Signo int32 Errno int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go index 429c3bf7dd..fe0aa35472 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go @@ -253,6 +253,12 @@ type Sigset_t struct { const _C__NSIG = 0x41 +const ( + SIG_BLOCK = 0x1 + SIG_UNBLOCK = 0x2 + SIG_SETMASK = 0x4 +) + type Siginfo struct { Signo int32 Errno int32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_ppc64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_ppc64.go new file mode 100644 index 0000000000..d6724c0102 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_ppc64.go @@ -0,0 +1,571 @@ +// cgo -godefs -- -fsigned-char types_openbsd.go | go run mkpost.go +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build ppc64 && openbsd +// +build ppc64,openbsd + +package unix + +const ( + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Mode uint32 + Dev int32 + Ino uint64 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev int32 + Atim Timespec + Mtim Timespec + Ctim Timespec + Size int64 + Blocks int64 + Blksize int32 + Flags uint32 + Gen uint32 + _ Timespec +} + +type Statfs_t struct { + F_flags uint32 + F_bsize uint32 + F_iosize uint32 + F_blocks uint64 + F_bfree uint64 + F_bavail int64 + F_files uint64 + F_ffree uint64 + F_favail int64 + F_syncwrites uint64 + F_syncreads uint64 + F_asyncwrites uint64 + F_asyncreads uint64 + F_fsid Fsid + F_namemax uint32 + F_owner uint32 + F_ctime uint64 + F_fstypename [16]byte + F_mntonname [90]byte + F_mntfromname [90]byte + F_mntfromspec [90]byte + _ [2]byte + Mount_info [160]byte +} + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 +} + +type Dirent struct { + Fileno uint64 + Off int64 + Reclen uint16 + Type uint8 + Namlen uint8 + _ [4]uint8 + Name [256]int8 +} + +type Fsid struct { + Val [2]int32 +} + +const ( + PathMax = 0x400 +) + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [24]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Iov *Iovec + Iovlen uint32 + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x20 + SizeofLinger = 0x8 + SizeofIovec = 0x10 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x30 + SizeofCmsghdr = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint64 + Filter int16 + Flags uint16 + Fflags uint32 + Data int64 + Udata *byte +} + +type FdSet struct { + Bits [32]uint32 +} + +const ( + SizeofIfMsghdr = 0xa8 + SizeofIfData = 0x90 + SizeofIfaMsghdr = 0x18 + SizeofIfAnnounceMsghdr = 0x1a + SizeofRtMsghdr = 0x60 + SizeofRtMetrics = 0x38 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Pad1 uint8 + Pad2 uint8 + Addrs int32 + Flags int32 + Xflags int32 + Data IfData +} + +type IfData struct { + Type uint8 + Addrlen uint8 + Hdrlen uint8 + Link_state uint8 + Mtu uint32 + Metric uint32 + Rdomain uint32 + Baudrate uint64 + Ipackets uint64 + Ierrors uint64 + Opackets uint64 + Oerrors uint64 + Collisions uint64 + Ibytes uint64 + Obytes uint64 + Imcasts uint64 + Omcasts uint64 + Iqdrops uint64 + Oqdrops uint64 + Noproto uint64 + Capabilities uint32 + Lastchange Timeval +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Pad1 uint8 + Pad2 uint8 + Addrs int32 + Flags int32 + Metric int32 +} + +type IfAnnounceMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + What uint16 + Name [16]int8 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Priority uint8 + Mpls uint8 + Addrs int32 + Flags int32 + Fmask int32 + Pid int32 + Seq int32 + Errno int32 + Inits uint32 + Rmx RtMetrics +} + +type RtMetrics struct { + Pksent uint64 + Expire int64 + Locks uint32 + Mtu uint32 + Refcnt uint32 + Hopcount uint32 + Recvpipe uint32 + Sendpipe uint32 + Ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Pad uint32 +} + +type Mclpool struct{} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x8 + SizeofBpfProgram = 0x10 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x18 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint32 + Drop uint32 +} + +type BpfProgram struct { + Len uint32 + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp BpfTimeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Ifidx uint16 + Flowid uint16 + Flags uint8 + Drops uint8 +} + +type BpfTimeval struct { + Sec uint32 + Usec uint32 +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed int32 + Ospeed int32 +} + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} + +const ( + AT_FDCWD = -0x64 + AT_EACCESS = 0x1 + AT_SYMLINK_NOFOLLOW = 0x2 + AT_SYMLINK_FOLLOW = 0x4 + AT_REMOVEDIR = 0x8 +) + +type PollFd struct { + Fd int32 + Events int16 + Revents int16 +} + +const ( + POLLERR = 0x8 + POLLHUP = 0x10 + POLLIN = 0x1 + POLLNVAL = 0x20 + POLLOUT = 0x4 + POLLPRI = 0x2 + POLLRDBAND = 0x80 + POLLRDNORM = 0x40 + POLLWRBAND = 0x100 + POLLWRNORM = 0x4 +) + +type Sigset_t uint32 + +type Utsname struct { + Sysname [256]byte + Nodename [256]byte + Release [256]byte + Version [256]byte + Machine [256]byte +} + +const SizeofUvmexp = 0x158 + +type Uvmexp struct { + Pagesize int32 + Pagemask int32 + Pageshift int32 + Npages int32 + Free int32 + Active int32 + Inactive int32 + Paging int32 + Wired int32 + Zeropages int32 + Reserve_pagedaemon int32 + Reserve_kernel int32 + Unused01 int32 + Vnodepages int32 + Vtextpages int32 + Freemin int32 + Freetarg int32 + Inactarg int32 + Wiredmax int32 + Anonmin int32 + Vtextmin int32 + Vnodemin int32 + Anonminpct int32 + Vtextminpct int32 + Vnodeminpct int32 + Nswapdev int32 + Swpages int32 + Swpginuse int32 + Swpgonly int32 + Nswget int32 + Nanon int32 + Unused05 int32 + Unused06 int32 + Faults int32 + Traps int32 + Intrs int32 + Swtch int32 + Softs int32 + Syscalls int32 + Pageins int32 + Unused07 int32 + Unused08 int32 + Pgswapin int32 + Pgswapout int32 + Forks int32 + Forks_ppwait int32 + Forks_sharevm int32 + Pga_zerohit int32 + Pga_zeromiss int32 + Unused09 int32 + Fltnoram int32 + Fltnoanon int32 + Fltnoamap int32 + Fltpgwait int32 + Fltpgrele int32 + Fltrelck int32 + Fltrelckok int32 + Fltanget int32 + Fltanretry int32 + Fltamcopy int32 + Fltnamap int32 + Fltnomap int32 + Fltlget int32 + Fltget int32 + Flt_anon int32 + Flt_acow int32 + Flt_obj int32 + Flt_prcopy int32 + Flt_przero int32 + Pdwoke int32 + Pdrevs int32 + Pdswout int32 + Pdfreed int32 + Pdscans int32 + Pdanscan int32 + Pdobscan int32 + Pdreact int32 + Pdbusy int32 + Pdpageouts int32 + Pdpending int32 + Pddeact int32 + Unused11 int32 + Unused12 int32 + Unused13 int32 + Fpswtch int32 + Kmapent int32 +} + +const SizeofClockinfo = 0x10 + +type Clockinfo struct { + Hz int32 + Tick int32 + Stathz int32 + Profhz int32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_openbsd_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_openbsd_riscv64.go new file mode 100644 index 0000000000..ddfd27a434 --- /dev/null +++ b/vendor/golang.org/x/sys/unix/ztypes_openbsd_riscv64.go @@ -0,0 +1,571 @@ +// cgo -godefs -- -fsigned-char types_openbsd.go | go run mkpost.go +// Code generated by the command above; see README.md. DO NOT EDIT. + +//go:build riscv64 && openbsd +// +build riscv64,openbsd + +package unix + +const ( + SizeofPtr = 0x8 + SizeofShort = 0x2 + SizeofInt = 0x4 + SizeofLong = 0x8 + SizeofLongLong = 0x8 +) + +type ( + _C_short int16 + _C_int int32 + _C_long int64 + _C_long_long int64 +) + +type Timespec struct { + Sec int64 + Nsec int64 +} + +type Timeval struct { + Sec int64 + Usec int64 +} + +type Rusage struct { + Utime Timeval + Stime Timeval + Maxrss int64 + Ixrss int64 + Idrss int64 + Isrss int64 + Minflt int64 + Majflt int64 + Nswap int64 + Inblock int64 + Oublock int64 + Msgsnd int64 + Msgrcv int64 + Nsignals int64 + Nvcsw int64 + Nivcsw int64 +} + +type Rlimit struct { + Cur uint64 + Max uint64 +} + +type _Gid_t uint32 + +type Stat_t struct { + Mode uint32 + Dev int32 + Ino uint64 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev int32 + Atim Timespec + Mtim Timespec + Ctim Timespec + Size int64 + Blocks int64 + Blksize int32 + Flags uint32 + Gen uint32 + _ Timespec +} + +type Statfs_t struct { + F_flags uint32 + F_bsize uint32 + F_iosize uint32 + F_blocks uint64 + F_bfree uint64 + F_bavail int64 + F_files uint64 + F_ffree uint64 + F_favail int64 + F_syncwrites uint64 + F_syncreads uint64 + F_asyncwrites uint64 + F_asyncreads uint64 + F_fsid Fsid + F_namemax uint32 + F_owner uint32 + F_ctime uint64 + F_fstypename [16]byte + F_mntonname [90]byte + F_mntfromname [90]byte + F_mntfromspec [90]byte + _ [2]byte + Mount_info [160]byte +} + +type Flock_t struct { + Start int64 + Len int64 + Pid int32 + Type int16 + Whence int16 +} + +type Dirent struct { + Fileno uint64 + Off int64 + Reclen uint16 + Type uint8 + Namlen uint8 + _ [4]uint8 + Name [256]int8 +} + +type Fsid struct { + Val [2]int32 +} + +const ( + PathMax = 0x400 +) + +type RawSockaddrInet4 struct { + Len uint8 + Family uint8 + Port uint16 + Addr [4]byte /* in_addr */ + Zero [8]int8 +} + +type RawSockaddrInet6 struct { + Len uint8 + Family uint8 + Port uint16 + Flowinfo uint32 + Addr [16]byte /* in6_addr */ + Scope_id uint32 +} + +type RawSockaddrUnix struct { + Len uint8 + Family uint8 + Path [104]int8 +} + +type RawSockaddrDatalink struct { + Len uint8 + Family uint8 + Index uint16 + Type uint8 + Nlen uint8 + Alen uint8 + Slen uint8 + Data [24]int8 +} + +type RawSockaddr struct { + Len uint8 + Family uint8 + Data [14]int8 +} + +type RawSockaddrAny struct { + Addr RawSockaddr + Pad [92]int8 +} + +type _Socklen uint32 + +type Linger struct { + Onoff int32 + Linger int32 +} + +type Iovec struct { + Base *byte + Len uint64 +} + +type IPMreq struct { + Multiaddr [4]byte /* in_addr */ + Interface [4]byte /* in_addr */ +} + +type IPv6Mreq struct { + Multiaddr [16]byte /* in6_addr */ + Interface uint32 +} + +type Msghdr struct { + Name *byte + Namelen uint32 + Iov *Iovec + Iovlen uint32 + Control *byte + Controllen uint32 + Flags int32 +} + +type Cmsghdr struct { + Len uint32 + Level int32 + Type int32 +} + +type Inet6Pktinfo struct { + Addr [16]byte /* in6_addr */ + Ifindex uint32 +} + +type IPv6MTUInfo struct { + Addr RawSockaddrInet6 + Mtu uint32 +} + +type ICMPv6Filter struct { + Filt [8]uint32 +} + +const ( + SizeofSockaddrInet4 = 0x10 + SizeofSockaddrInet6 = 0x1c + SizeofSockaddrAny = 0x6c + SizeofSockaddrUnix = 0x6a + SizeofSockaddrDatalink = 0x20 + SizeofLinger = 0x8 + SizeofIovec = 0x10 + SizeofIPMreq = 0x8 + SizeofIPv6Mreq = 0x14 + SizeofMsghdr = 0x30 + SizeofCmsghdr = 0xc + SizeofInet6Pktinfo = 0x14 + SizeofIPv6MTUInfo = 0x20 + SizeofICMPv6Filter = 0x20 +) + +const ( + PTRACE_TRACEME = 0x0 + PTRACE_CONT = 0x7 + PTRACE_KILL = 0x8 +) + +type Kevent_t struct { + Ident uint64 + Filter int16 + Flags uint16 + Fflags uint32 + Data int64 + Udata *byte +} + +type FdSet struct { + Bits [32]uint32 +} + +const ( + SizeofIfMsghdr = 0xa8 + SizeofIfData = 0x90 + SizeofIfaMsghdr = 0x18 + SizeofIfAnnounceMsghdr = 0x1a + SizeofRtMsghdr = 0x60 + SizeofRtMetrics = 0x38 +) + +type IfMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Pad1 uint8 + Pad2 uint8 + Addrs int32 + Flags int32 + Xflags int32 + Data IfData +} + +type IfData struct { + Type uint8 + Addrlen uint8 + Hdrlen uint8 + Link_state uint8 + Mtu uint32 + Metric uint32 + Rdomain uint32 + Baudrate uint64 + Ipackets uint64 + Ierrors uint64 + Opackets uint64 + Oerrors uint64 + Collisions uint64 + Ibytes uint64 + Obytes uint64 + Imcasts uint64 + Omcasts uint64 + Iqdrops uint64 + Oqdrops uint64 + Noproto uint64 + Capabilities uint32 + Lastchange Timeval +} + +type IfaMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Pad1 uint8 + Pad2 uint8 + Addrs int32 + Flags int32 + Metric int32 +} + +type IfAnnounceMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + What uint16 + Name [16]int8 +} + +type RtMsghdr struct { + Msglen uint16 + Version uint8 + Type uint8 + Hdrlen uint16 + Index uint16 + Tableid uint16 + Priority uint8 + Mpls uint8 + Addrs int32 + Flags int32 + Fmask int32 + Pid int32 + Seq int32 + Errno int32 + Inits uint32 + Rmx RtMetrics +} + +type RtMetrics struct { + Pksent uint64 + Expire int64 + Locks uint32 + Mtu uint32 + Refcnt uint32 + Hopcount uint32 + Recvpipe uint32 + Sendpipe uint32 + Ssthresh uint32 + Rtt uint32 + Rttvar uint32 + Pad uint32 +} + +type Mclpool struct{} + +const ( + SizeofBpfVersion = 0x4 + SizeofBpfStat = 0x8 + SizeofBpfProgram = 0x10 + SizeofBpfInsn = 0x8 + SizeofBpfHdr = 0x18 +) + +type BpfVersion struct { + Major uint16 + Minor uint16 +} + +type BpfStat struct { + Recv uint32 + Drop uint32 +} + +type BpfProgram struct { + Len uint32 + Insns *BpfInsn +} + +type BpfInsn struct { + Code uint16 + Jt uint8 + Jf uint8 + K uint32 +} + +type BpfHdr struct { + Tstamp BpfTimeval + Caplen uint32 + Datalen uint32 + Hdrlen uint16 + Ifidx uint16 + Flowid uint16 + Flags uint8 + Drops uint8 +} + +type BpfTimeval struct { + Sec uint32 + Usec uint32 +} + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]uint8 + Ispeed int32 + Ospeed int32 +} + +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} + +const ( + AT_FDCWD = -0x64 + AT_EACCESS = 0x1 + AT_SYMLINK_NOFOLLOW = 0x2 + AT_SYMLINK_FOLLOW = 0x4 + AT_REMOVEDIR = 0x8 +) + +type PollFd struct { + Fd int32 + Events int16 + Revents int16 +} + +const ( + POLLERR = 0x8 + POLLHUP = 0x10 + POLLIN = 0x1 + POLLNVAL = 0x20 + POLLOUT = 0x4 + POLLPRI = 0x2 + POLLRDBAND = 0x80 + POLLRDNORM = 0x40 + POLLWRBAND = 0x100 + POLLWRNORM = 0x4 +) + +type Sigset_t uint32 + +type Utsname struct { + Sysname [256]byte + Nodename [256]byte + Release [256]byte + Version [256]byte + Machine [256]byte +} + +const SizeofUvmexp = 0x158 + +type Uvmexp struct { + Pagesize int32 + Pagemask int32 + Pageshift int32 + Npages int32 + Free int32 + Active int32 + Inactive int32 + Paging int32 + Wired int32 + Zeropages int32 + Reserve_pagedaemon int32 + Reserve_kernel int32 + Unused01 int32 + Vnodepages int32 + Vtextpages int32 + Freemin int32 + Freetarg int32 + Inactarg int32 + Wiredmax int32 + Anonmin int32 + Vtextmin int32 + Vnodemin int32 + Anonminpct int32 + Vtextminpct int32 + Vnodeminpct int32 + Nswapdev int32 + Swpages int32 + Swpginuse int32 + Swpgonly int32 + Nswget int32 + Nanon int32 + Unused05 int32 + Unused06 int32 + Faults int32 + Traps int32 + Intrs int32 + Swtch int32 + Softs int32 + Syscalls int32 + Pageins int32 + Unused07 int32 + Unused08 int32 + Pgswapin int32 + Pgswapout int32 + Forks int32 + Forks_ppwait int32 + Forks_sharevm int32 + Pga_zerohit int32 + Pga_zeromiss int32 + Unused09 int32 + Fltnoram int32 + Fltnoanon int32 + Fltnoamap int32 + Fltpgwait int32 + Fltpgrele int32 + Fltrelck int32 + Fltrelckok int32 + Fltanget int32 + Fltanretry int32 + Fltamcopy int32 + Fltnamap int32 + Fltnomap int32 + Fltlget int32 + Fltget int32 + Flt_anon int32 + Flt_acow int32 + Flt_obj int32 + Flt_prcopy int32 + Flt_przero int32 + Pdwoke int32 + Pdrevs int32 + Pdswout int32 + Pdfreed int32 + Pdscans int32 + Pdanscan int32 + Pdobscan int32 + Pdreact int32 + Pdbusy int32 + Pdpageouts int32 + Pdpending int32 + Pddeact int32 + Unused11 int32 + Unused12 int32 + Unused13 int32 + Fpswtch int32 + Kmapent int32 +} + +const SizeofClockinfo = 0x10 + +type Clockinfo struct { + Hz int32 + Tick int32 + Stathz int32 + Profhz int32 +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go index c1a9b83ad5..0400747c67 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go @@ -480,3 +480,38 @@ const ( MOUNTEDOVER = 0x40000000 FILE_EXCEPTION = 0x60000070 ) + +const ( + TUNNEWPPA = 0x540001 + TUNSETPPA = 0x540002 + + I_STR = 0x5308 + I_POP = 0x5303 + I_PUSH = 0x5302 + I_LINK = 0x530c + I_UNLINK = 0x530d + I_PLINK = 0x5316 + I_PUNLINK = 0x5317 + + IF_UNITSEL = -0x7ffb8cca +) + +type strbuf struct { + Maxlen int32 + Len int32 + Buf *int8 +} + +type Strioctl struct { + Cmd int32 + Timout int32 + Len int32 + Dp *int8 +} + +type Lifreq struct { + Name [32]int8 + Lifru1 [4]byte + Type uint32 + Lifru [336]byte +} diff --git a/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go b/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go index 4ab638cb94..aec1efcb30 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/ztypes_zos_s390x.go @@ -339,7 +339,7 @@ type Statfs_t struct { Flags uint64 } -type Dirent struct { +type direntLE struct { Reclen uint16 Namlen uint16 Ino uint32 @@ -347,6 +347,15 @@ type Dirent struct { Name [256]byte } +type Dirent struct { + Ino uint64 + Off int64 + Reclen uint16 + Type uint8 + Name [256]uint8 + _ [5]byte +} + type FdSet struct { Bits [64]int32 } diff --git a/vendor/golang.org/x/sys/windows/syscall.go b/vendor/golang.org/x/sys/windows/syscall.go index 72074d582f..8732cdb957 100644 --- a/vendor/golang.org/x/sys/windows/syscall.go +++ b/vendor/golang.org/x/sys/windows/syscall.go @@ -30,8 +30,6 @@ import ( "strings" "syscall" "unsafe" - - "golang.org/x/sys/internal/unsafeheader" ) // ByteSliceFromString returns a NUL-terminated slice of bytes @@ -83,13 +81,7 @@ func BytePtrToString(p *byte) string { ptr = unsafe.Pointer(uintptr(ptr) + 1) } - var s []byte - h := (*unsafeheader.Slice)(unsafe.Pointer(&s)) - h.Data = unsafe.Pointer(p) - h.Len = n - h.Cap = n - - return string(s) + return string(unsafe.Slice(p, n)) } // Single-word zero for use when we need a valid pointer to 0 bytes. diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index e27913817a..7a6ba43a7e 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -138,13 +138,7 @@ func UTF16PtrToString(p *uint16) string { ptr = unsafe.Pointer(uintptr(ptr) + unsafe.Sizeof(*p)) } - var s []uint16 - h := (*unsafeheader.Slice)(unsafe.Pointer(&s)) - h.Data = unsafe.Pointer(p) - h.Len = n - h.Cap = n - - return string(utf16.Decode(s)) + return string(utf16.Decode(unsafe.Slice(p, n))) } func Getpagesize() int { return 4096 } @@ -364,6 +358,15 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) //sys GetActiveProcessorCount(groupNumber uint16) (ret uint32) //sys GetMaximumProcessorCount(groupNumber uint16) (ret uint32) +//sys EnumWindows(enumFunc uintptr, param unsafe.Pointer) (err error) = user32.EnumWindows +//sys EnumChildWindows(hwnd HWND, enumFunc uintptr, param unsafe.Pointer) = user32.EnumChildWindows +//sys GetClassName(hwnd HWND, className *uint16, maxCount int32) (copied int32, err error) = user32.GetClassNameW +//sys GetDesktopWindow() (hwnd HWND) = user32.GetDesktopWindow +//sys GetForegroundWindow() (hwnd HWND) = user32.GetForegroundWindow +//sys IsWindow(hwnd HWND) (isWindow bool) = user32.IsWindow +//sys IsWindowUnicode(hwnd HWND) (isUnicode bool) = user32.IsWindowUnicode +//sys IsWindowVisible(hwnd HWND) (isVisible bool) = user32.IsWindowVisible +//sys GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) = user32.GetGUIThreadInfo // Volume Management Functions //sys DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) = DefineDosDeviceW @@ -439,6 +442,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys RtlAddFunctionTable(functionTable *RUNTIME_FUNCTION, entryCount uint32, baseAddress uintptr) (ret bool) = ntdll.RtlAddFunctionTable //sys RtlDeleteFunctionTable(functionTable *RUNTIME_FUNCTION) (ret bool) = ntdll.RtlDeleteFunctionTable +// Desktop Window Manager API (Dwmapi) +//sys DwmGetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) = dwmapi.DwmGetWindowAttribute +//sys DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) = dwmapi.DwmSetWindowAttribute + // syscall interface implementation for other packages // GetCurrentProcess returns the handle for the current process. @@ -748,7 +755,7 @@ func Utimes(path string, tv []Timeval) (err error) { if e != nil { return e } - defer Close(h) + defer CloseHandle(h) a := NsecToFiletime(tv[0].Nanoseconds()) w := NsecToFiletime(tv[1].Nanoseconds()) return SetFileTime(h, nil, &a, &w) @@ -768,7 +775,7 @@ func UtimesNano(path string, ts []Timespec) (err error) { if e != nil { return e } - defer Close(h) + defer CloseHandle(h) a := NsecToFiletime(TimespecToNsec(ts[0])) w := NsecToFiletime(TimespecToNsec(ts[1])) return SetFileTime(h, nil, &a, &w) @@ -1108,9 +1115,13 @@ func Shutdown(fd Handle, how int) (err error) { } func WSASendto(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to Sockaddr, overlapped *Overlapped, croutine *byte) (err error) { - rsa, l, err := to.sockaddr() - if err != nil { - return err + var rsa unsafe.Pointer + var l int32 + if to != nil { + rsa, l, err = to.sockaddr() + if err != nil { + return err + } } return WSASendTo(s, bufs, bufcnt, sent, flags, (*RawSockaddrAny)(unsafe.Pointer(rsa)), l, overlapped, croutine) } diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go index f9eaca528e..0c4add9741 100644 --- a/vendor/golang.org/x/sys/windows/types_windows.go +++ b/vendor/golang.org/x/sys/windows/types_windows.go @@ -3213,3 +3213,48 @@ type ModuleInfo struct { } const ALL_PROCESSOR_GROUPS = 0xFFFF + +type Rect struct { + Left int32 + Top int32 + Right int32 + Bottom int32 +} + +type GUIThreadInfo struct { + Size uint32 + Flags uint32 + Active HWND + Focus HWND + Capture HWND + MenuOwner HWND + MoveSize HWND + CaretHandle HWND + CaretRect Rect +} + +const ( + DWMWA_NCRENDERING_ENABLED = 1 + DWMWA_NCRENDERING_POLICY = 2 + DWMWA_TRANSITIONS_FORCEDISABLED = 3 + DWMWA_ALLOW_NCPAINT = 4 + DWMWA_CAPTION_BUTTON_BOUNDS = 5 + DWMWA_NONCLIENT_RTL_LAYOUT = 6 + DWMWA_FORCE_ICONIC_REPRESENTATION = 7 + DWMWA_FLIP3D_POLICY = 8 + DWMWA_EXTENDED_FRAME_BOUNDS = 9 + DWMWA_HAS_ICONIC_BITMAP = 10 + DWMWA_DISALLOW_PEEK = 11 + DWMWA_EXCLUDED_FROM_PEEK = 12 + DWMWA_CLOAK = 13 + DWMWA_CLOAKED = 14 + DWMWA_FREEZE_REPRESENTATION = 15 + DWMWA_PASSIVE_UPDATE_MODE = 16 + DWMWA_USE_HOSTBACKDROPBRUSH = 17 + DWMWA_USE_IMMERSIVE_DARK_MODE = 20 + DWMWA_WINDOW_CORNER_PREFERENCE = 33 + DWMWA_BORDER_COLOR = 34 + DWMWA_CAPTION_COLOR = 35 + DWMWA_TEXT_COLOR = 36 + DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37 +) diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index 52d4742cb9..96ba8559c3 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -40,6 +40,7 @@ var ( modadvapi32 = NewLazySystemDLL("advapi32.dll") modcrypt32 = NewLazySystemDLL("crypt32.dll") moddnsapi = NewLazySystemDLL("dnsapi.dll") + moddwmapi = NewLazySystemDLL("dwmapi.dll") modiphlpapi = NewLazySystemDLL("iphlpapi.dll") modkernel32 = NewLazySystemDLL("kernel32.dll") modmswsock = NewLazySystemDLL("mswsock.dll") @@ -175,6 +176,8 @@ var ( procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W") procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W") procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree") + procDwmGetWindowAttribute = moddwmapi.NewProc("DwmGetWindowAttribute") + procDwmSetWindowAttribute = moddwmapi.NewProc("DwmSetWindowAttribute") procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses") procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo") procGetBestInterfaceEx = modiphlpapi.NewProc("GetBestInterfaceEx") @@ -444,9 +447,18 @@ var ( procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW") procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath") procShellExecuteW = modshell32.NewProc("ShellExecuteW") + procEnumChildWindows = moduser32.NewProc("EnumChildWindows") + procEnumWindows = moduser32.NewProc("EnumWindows") procExitWindowsEx = moduser32.NewProc("ExitWindowsEx") + procGetClassNameW = moduser32.NewProc("GetClassNameW") + procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow") + procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow") + procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo") procGetShellWindow = moduser32.NewProc("GetShellWindow") procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId") + procIsWindow = moduser32.NewProc("IsWindow") + procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode") + procIsWindowVisible = moduser32.NewProc("IsWindowVisible") procMessageBoxW = moduser32.NewProc("MessageBoxW") procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") @@ -1525,6 +1537,22 @@ func DnsRecordListFree(rl *DNSRecord, freetype uint32) { return } +func DwmGetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) { + r0, _, _ := syscall.Syscall6(procDwmGetWindowAttribute.Addr(), 4, uintptr(hwnd), uintptr(attribute), uintptr(value), uintptr(size), 0, 0) + if r0 != 0 { + ret = syscall.Errno(r0) + } + return +} + +func DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) { + r0, _, _ := syscall.Syscall6(procDwmSetWindowAttribute.Addr(), 4, uintptr(hwnd), uintptr(attribute), uintptr(value), uintptr(size), 0, 0) + if r0 != 0 { + ret = syscall.Errno(r0) + } + return +} + func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) { r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0) if r0 != 0 { @@ -3802,6 +3830,19 @@ func ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *ui return } +func EnumChildWindows(hwnd HWND, enumFunc uintptr, param unsafe.Pointer) { + syscall.Syscall(procEnumChildWindows.Addr(), 3, uintptr(hwnd), uintptr(enumFunc), uintptr(param)) + return +} + +func EnumWindows(enumFunc uintptr, param unsafe.Pointer) (err error) { + r1, _, e1 := syscall.Syscall(procEnumWindows.Addr(), 2, uintptr(enumFunc), uintptr(param), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func ExitWindowsEx(flags uint32, reason uint32) (err error) { r1, _, e1 := syscall.Syscall(procExitWindowsEx.Addr(), 2, uintptr(flags), uintptr(reason), 0) if r1 == 0 { @@ -3810,6 +3851,35 @@ func ExitWindowsEx(flags uint32, reason uint32) (err error) { return } +func GetClassName(hwnd HWND, className *uint16, maxCount int32) (copied int32, err error) { + r0, _, e1 := syscall.Syscall(procGetClassNameW.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(className)), uintptr(maxCount)) + copied = int32(r0) + if copied == 0 { + err = errnoErr(e1) + } + return +} + +func GetDesktopWindow() (hwnd HWND) { + r0, _, _ := syscall.Syscall(procGetDesktopWindow.Addr(), 0, 0, 0, 0) + hwnd = HWND(r0) + return +} + +func GetForegroundWindow() (hwnd HWND) { + r0, _, _ := syscall.Syscall(procGetForegroundWindow.Addr(), 0, 0, 0, 0) + hwnd = HWND(r0) + return +} + +func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) { + r1, _, e1 := syscall.Syscall(procGetGUIThreadInfo.Addr(), 2, uintptr(thread), uintptr(unsafe.Pointer(info)), 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func GetShellWindow() (shellWindow HWND) { r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0) shellWindow = HWND(r0) @@ -3825,6 +3895,24 @@ func GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) { return } +func IsWindow(hwnd HWND) (isWindow bool) { + r0, _, _ := syscall.Syscall(procIsWindow.Addr(), 1, uintptr(hwnd), 0, 0) + isWindow = r0 != 0 + return +} + +func IsWindowUnicode(hwnd HWND) (isUnicode bool) { + r0, _, _ := syscall.Syscall(procIsWindowUnicode.Addr(), 1, uintptr(hwnd), 0, 0) + isUnicode = r0 != 0 + return +} + +func IsWindowVisible(hwnd HWND) (isVisible bool) { + r0, _, _ := syscall.Syscall(procIsWindowVisible.Addr(), 1, uintptr(hwnd), 0, 0) + isVisible = r0 != 0 + return +} + func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) ret = int32(r0) diff --git a/vendor/golang.org/x/term/AUTHORS b/vendor/golang.org/x/term/AUTHORS deleted file mode 100644 index 15167cd746..0000000000 --- a/vendor/golang.org/x/term/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code refers to The Go Authors for copyright purposes. -# The master list of authors is in the main Go distribution, -# visible at http://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/term/CONTRIBUTORS b/vendor/golang.org/x/term/CONTRIBUTORS deleted file mode 100644 index 1c4577e968..0000000000 --- a/vendor/golang.org/x/term/CONTRIBUTORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code was written by the Go contributors. -# The master list of contributors is in the main Go distribution, -# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/term/term.go b/vendor/golang.org/x/term/term.go index d592708808..1a40d10125 100644 --- a/vendor/golang.org/x/term/term.go +++ b/vendor/golang.org/x/term/term.go @@ -7,11 +7,11 @@ // // Putting a terminal into raw mode is the most common requirement: // -// oldState, err := term.MakeRaw(int(os.Stdin.Fd())) -// if err != nil { -// panic(err) -// } -// defer term.Restore(int(os.Stdin.Fd()), oldState) +// oldState, err := term.MakeRaw(int(os.Stdin.Fd())) +// if err != nil { +// panic(err) +// } +// defer term.Restore(int(os.Stdin.Fd()), oldState) // // Note that on non-Unix systems os.Stdin.Fd() may not be 0. package term diff --git a/vendor/golang.org/x/term/terminal.go b/vendor/golang.org/x/term/terminal.go index 535ab8257c..4b48a5899d 100644 --- a/vendor/golang.org/x/term/terminal.go +++ b/vendor/golang.org/x/term/terminal.go @@ -935,7 +935,7 @@ func (s *stRingBuffer) Add(a string) { // next most recent, and so on. If such an element doesn't exist then ok is // false. func (s *stRingBuffer) NthPreviousEntry(n int) (value string, ok bool) { - if n >= s.size { + if n < 0 || n >= s.size { return "", false } index := s.head - n diff --git a/vendor/golang.org/x/text/AUTHORS b/vendor/golang.org/x/text/AUTHORS deleted file mode 100644 index 15167cd746..0000000000 --- a/vendor/golang.org/x/text/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code refers to The Go Authors for copyright purposes. -# The master list of authors is in the main Go distribution, -# visible at http://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/text/CONTRIBUTORS b/vendor/golang.org/x/text/CONTRIBUTORS deleted file mode 100644 index 1c4577e968..0000000000 --- a/vendor/golang.org/x/text/CONTRIBUTORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code was written by the Go contributors. -# The master list of contributors is in the main Go distribution, -# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/text/encoding/htmlindex/tables.go b/vendor/golang.org/x/text/encoding/htmlindex/tables.go index f074e2c6da..9e6daa8965 100644 --- a/vendor/golang.org/x/text/encoding/htmlindex/tables.go +++ b/vendor/golang.org/x/text/encoding/htmlindex/tables.go @@ -93,8 +93,11 @@ var canonical = [numEncodings]string{ var nameMap = map[string]htmlEncoding{ "unicode-1-1-utf-8": utf8, + "unicode11utf8": utf8, + "unicode20utf8": utf8, "utf-8": utf8, "utf8": utf8, + "x-unicode20utf8": utf8, "866": ibm866, "cp866": ibm866, "csibm866": ibm866, @@ -307,7 +310,13 @@ var nameMap = map[string]htmlEncoding{ "iso-2022-cn-ext": replacement, "iso-2022-kr": replacement, "replacement": replacement, + "unicodefffe": utf16be, "utf-16be": utf16be, + "csunicode": utf16le, + "iso-10646-ucs-2": utf16le, + "ucs-2": utf16le, + "unicode": utf16le, + "unicodefeff": utf16le, "utf-16": utf16le, "utf-16le": utf16le, "x-user-defined": xUserDefined, diff --git a/vendor/golang.org/x/text/encoding/internal/identifier/mib.go b/vendor/golang.org/x/text/encoding/internal/identifier/mib.go index fc7df1bc71..351fb86e29 100644 --- a/vendor/golang.org/x/text/encoding/internal/identifier/mib.go +++ b/vendor/golang.org/x/text/encoding/internal/identifier/mib.go @@ -905,6 +905,14 @@ const ( // https://www.unicode.org/notes/tn6/ BOCU1 MIB = 1020 + // UTF7IMAP is the MIB identifier with IANA name UTF-7-IMAP. + // + // Note: This charset is used to encode Unicode in IMAP mailbox names; + // see section 5.1.3 of rfc3501 . It should never be used + // outside this context. A name has been assigned so that charset processing + // implementations can refer to it in a consistent way. + UTF7IMAP MIB = 1021 + // Windows30Latin1 is the MIB identifier with IANA name ISO-8859-1-Windows-3.0-Latin-1. // // Extended ISO 8859-1 Latin-1 for Windows 3.0. diff --git a/vendor/golang.org/x/text/encoding/simplifiedchinese/gbk.go b/vendor/golang.org/x/text/encoding/simplifiedchinese/gbk.go index b89c45b03d..0e0fabfd6b 100644 --- a/vendor/golang.org/x/text/encoding/simplifiedchinese/gbk.go +++ b/vendor/golang.org/x/text/encoding/simplifiedchinese/gbk.go @@ -55,6 +55,8 @@ loop: // Microsoft's Code Page 936 extends GBK 1.0 to encode the euro sign U+20AC // as 0x80. The HTML5 specification at http://encoding.spec.whatwg.org/#gbk // says to treat "gbk" as Code Page 936. + // GBK’s decoder is gb18030’s decoder. https://encoding.spec.whatwg.org/#gbk-decoder + // If byte is 0x80, return code point U+20AC. https://encoding.spec.whatwg.org/#gb18030-decoder case c0 == 0x80: r, size = '€', 1 @@ -180,7 +182,9 @@ func (e gbkEncoder) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err // Microsoft's Code Page 936 extends GBK 1.0 to encode the euro sign U+20AC // as 0x80. The HTML5 specification at http://encoding.spec.whatwg.org/#gbk // says to treat "gbk" as Code Page 936. - if r == '€' { + // GBK’s encoder is gb18030’s encoder with its _is GBK_ set to true. https://encoding.spec.whatwg.org/#gbk-encoder + // If _is GBK_ is true and code point is U+20AC, return byte 0x80. https://encoding.spec.whatwg.org/#gb18030-encoder + if !e.gb18030 && r == '€' { r = 0x80 goto write1 } diff --git a/vendor/golang.org/x/text/feature/plural/message.go b/vendor/golang.org/x/text/feature/plural/message.go index f931f8a6a3..56d518cc34 100644 --- a/vendor/golang.org/x/text/feature/plural/message.go +++ b/vendor/golang.org/x/text/feature/plural/message.go @@ -6,7 +6,7 @@ package plural import ( "fmt" - "io/ioutil" + "io" "reflect" "strconv" @@ -35,13 +35,13 @@ type Interface interface { // The cases argument are pairs of selectors and messages. Selectors are of type // string or Form. Messages are of type string or catalog.Message. A selector // matches an argument if: -// - it is "other" or Other -// - it matches the plural form of the argument: "zero", "one", "two", "few", -// or "many", or the equivalent Form -// - it is of the form "=x" where x is an integer that matches the value of -// the argument. -// - it is of the form " 1. -// - Otherwise the result is i % 10^nMod. +// - Let i be asInt(digits[start:end]), where out-of-range digits are assumed +// to be zero. +// - Result n is big if i / 10^nMod > 1. +// - Otherwise the result is i % 10^nMod. // // For example, if digits is {1, 2, 3} and start:end is 0:5, then the result // for various values of nMod is: -// - when nMod == 2, n == big -// - when nMod == 3, n == big -// - when nMod == 4, n == big -// - when nMod == 5, n == 12300 -// - when nMod == 6, n == 12300 -// - when nMod == 7, n == 12300 +// - when nMod == 2, n == big +// - when nMod == 3, n == big +// - when nMod == 4, n == big +// - when nMod == 5, n == 12300 +// - when nMod == 6, n == 12300 +// - when nMod == 7, n == 12300 func getIntApprox(digits []byte, start, end, nMod, big int) (n int) { // Leading 0 digits just result in 0. p := start @@ -107,12 +106,13 @@ func getIntApprox(digits []byte, start, end, nMod, big int) (n int) { // // The following table contains examples of possible arguments to represent // the given numbers. -// decimal digits exp scale -// 123 []byte{1, 2, 3} 3 0 -// 123.4 []byte{1, 2, 3, 4} 3 1 -// 123.40 []byte{1, 2, 3, 4} 3 2 -// 100000 []byte{1} 6 0 -// 100000.00 []byte{1} 6 3 +// +// decimal digits exp scale +// 123 []byte{1, 2, 3} 3 0 +// 123.4 []byte{1, 2, 3, 4} 3 1 +// 123.40 []byte{1, 2, 3, 4} 3 2 +// 100000 []byte{1} 6 0 +// 100000.00 []byte{1} 6 3 func (p *Rules) MatchDigits(t language.Tag, digits []byte, exp, scale int) Form { index := tagToID(t) @@ -152,14 +152,15 @@ func (p *Rules) matchComponents(t language.Tag, n, f, scale int) Form { // MatchPlural returns the plural form for the given language and plural // operands (as defined in // https://unicode.org/reports/tr35/tr35-numbers.html#Language_Plural_Rules): -// where -// n absolute value of the source number (integer and decimals) -// input -// i integer digits of n. -// v number of visible fraction digits in n, with trailing zeros. -// w number of visible fraction digits in n, without trailing zeros. -// f visible fractional digits in n, with trailing zeros (f = t * 10^(v-w)) -// t visible fractional digits in n, without trailing zeros. +// +// where +// n absolute value of the source number (integer and decimals) +// input +// i integer digits of n. +// v number of visible fraction digits in n, with trailing zeros. +// w number of visible fraction digits in n, without trailing zeros. +// f visible fractional digits in n, with trailing zeros (f = t * 10^(v-w)) +// t visible fractional digits in n, without trailing zeros. // // If any of the operand values is too large to fit in an int, it is okay to // pass the value modulo 10,000,000. diff --git a/vendor/golang.org/x/text/internal/catmsg/catmsg.go b/vendor/golang.org/x/text/internal/catmsg/catmsg.go index c0bf86f092..1b257a7b4d 100644 --- a/vendor/golang.org/x/text/internal/catmsg/catmsg.go +++ b/vendor/golang.org/x/text/internal/catmsg/catmsg.go @@ -9,8 +9,7 @@ // own. For instance, the plural package provides functionality for selecting // translation strings based on the plural category of substitution arguments. // -// -// Encoding and Decoding +// # Encoding and Decoding // // Catalogs store Messages encoded as a single string. Compiling a message into // a string both results in compacter representation and speeds up evaluation. @@ -25,8 +24,7 @@ // the message. This decoder takes a Decoder argument which provides the // counterparts for the decoding. // -// -// Renderers +// # Renderers // // A Decoder must be initialized with a Renderer implementation. These // implementations must be provided by packages that use Catalogs, typically @@ -38,22 +36,22 @@ // as sequence of substrings passed to the Renderer. The following snippet shows // how to express the above example using the message package. // -// message.Set(language.English, "You are %d minute(s) late.", -// catalog.Var("minutes", plural.Select(1, "one", "minute")), -// catalog.String("You are %[1]d ${minutes} late.")) +// message.Set(language.English, "You are %d minute(s) late.", +// catalog.Var("minutes", plural.Select(1, "one", "minute")), +// catalog.String("You are %[1]d ${minutes} late.")) // -// p := message.NewPrinter(language.English) -// p.Printf("You are %d minute(s) late.", 5) // always 5 minutes late. +// p := message.NewPrinter(language.English) +// p.Printf("You are %d minute(s) late.", 5) // always 5 minutes late. // // To evaluate the Printf, package message wraps the arguments in a Renderer // that is passed to the catalog for message decoding. The call sequence that // results from evaluating the above message, assuming the person is rather // tardy, is: // -// Render("You are %[1]d ") -// Arg(1) -// Render("minutes") -// Render(" late.") +// Render("You are %[1]d ") +// Arg(1) +// Render("minutes") +// Render(" late.") // // The calls to Arg is caused by the plural.Select execution, which evaluates // the argument to determine whether the singular or plural message form should @@ -267,10 +265,12 @@ func (s FirstOf) Compile(e *Encoder) error { // Var defines a message that can be substituted for a placeholder of the same // name. If an expression does not result in a string after evaluation, Name is // used as the substitution. For example: -// Var{ -// Name: "minutes", -// Message: plural.Select(1, "one", "minute"), -// } +// +// Var{ +// Name: "minutes", +// Message: plural.Select(1, "one", "minute"), +// } +// // will resolve to minute for singular and minutes for plural forms. type Var struct { Name string @@ -318,13 +318,15 @@ func (r Raw) Compile(e *Encoder) (err error) { // calls for each placeholder and interstitial string. For example, for the // message: "%[1]v ${invites} %[2]v to ${their} party." The sequence of calls // is: -// d.Render("%[1]v ") -// d.Arg(1) -// d.Render(resultOfInvites) -// d.Render(" %[2]v to ") -// d.Arg(2) -// d.Render(resultOfTheir) -// d.Render(" party.") +// +// d.Render("%[1]v ") +// d.Arg(1) +// d.Render(resultOfInvites) +// d.Render(" %[2]v to ") +// d.Arg(2) +// d.Render(resultOfTheir) +// d.Render(" party.") +// // where the messages for "invites" and "their" both use a plural.Select // referring to the first argument. // diff --git a/vendor/golang.org/x/text/internal/language/compact/tables.go b/vendor/golang.org/x/text/internal/language/compact/tables.go index fe7ad9ea7c..32af9de599 100644 --- a/vendor/golang.org/x/text/internal/language/compact/tables.go +++ b/vendor/golang.org/x/text/internal/language/compact/tables.go @@ -966,7 +966,7 @@ var coreTags = []language.CompactCoreInfo{ // 773 elements 0x3fd00000, 0x3fd00072, 0x3fd000da, 0x3fd0010c, 0x3ff00000, 0x3ff000d1, 0x40100000, 0x401000c3, 0x40200000, 0x4020004c, 0x40700000, 0x40800000, - 0x4085a000, 0x4085a0ba, 0x408e3000, 0x408e30ba, + 0x4085a000, 0x4085a0ba, 0x408e8000, 0x408e80ba, 0x40c00000, 0x40c000b3, 0x41200000, 0x41200111, 0x41600000, 0x4160010f, 0x41c00000, 0x41d00000, // Entry 280 - 29F @@ -994,7 +994,7 @@ var coreTags = []language.CompactCoreInfo{ // 773 elements 0x4ae00130, 0x4b400000, 0x4b400099, 0x4b4000e8, 0x4bc00000, 0x4bc05000, 0x4bc05024, 0x4bc20000, 0x4bc20137, 0x4bc5a000, 0x4bc5a137, 0x4be00000, - 0x4be5a000, 0x4be5a0b4, 0x4beeb000, 0x4beeb0b4, + 0x4be5a000, 0x4be5a0b4, 0x4bef1000, 0x4bef10b4, 0x4c000000, 0x4c300000, 0x4c30013e, 0x4c900000, // Entry 2E0 - 2FF 0x4c900001, 0x4cc00000, 0x4cc0012f, 0x4ce00000, @@ -1012,4 +1012,4 @@ var coreTags = []language.CompactCoreInfo{ // 773 elements const specialTagsStr string = "ca-ES-valencia en-US-u-va-posix" -// Total table size 3147 bytes (3KiB); checksum: BE816D44 +// Total table size 3147 bytes (3KiB); checksum: 6772C83C diff --git a/vendor/golang.org/x/text/internal/language/lookup.go b/vendor/golang.org/x/text/internal/language/lookup.go index 6294b81524..231b4fbdeb 100644 --- a/vendor/golang.org/x/text/internal/language/lookup.go +++ b/vendor/golang.org/x/text/internal/language/lookup.go @@ -50,7 +50,7 @@ func (id Language) Canonicalize() (Language, AliasType) { return normLang(id) } -// mapLang returns the mapped langID of id according to mapping m. +// normLang returns the mapped langID of id according to mapping m. func normLang(id Language) (Language, AliasType) { k := sort.Search(len(AliasMap), func(i int) bool { return AliasMap[i].From >= uint16(id) @@ -328,7 +328,7 @@ func (r Region) IsPrivateUse() bool { return r.typ()&iso3166UserAssigned != 0 } -type Script uint8 +type Script uint16 // getScriptID returns the script id for string s. It assumes that s // is of the format [A-Z][a-z]{3}. diff --git a/vendor/golang.org/x/text/internal/language/parse.go b/vendor/golang.org/x/text/internal/language/parse.go index 47ee0fed17..aad1e0acf7 100644 --- a/vendor/golang.org/x/text/internal/language/parse.go +++ b/vendor/golang.org/x/text/internal/language/parse.go @@ -270,7 +270,7 @@ func parse(scan *scanner, s string) (t Tag, err error) { } else if n >= 4 { return Und, ErrSyntax } else { // the usual case - t, end = parseTag(scan) + t, end = parseTag(scan, true) if n := len(scan.token); n == 1 { t.pExt = uint16(end) end = parseExtensions(scan) @@ -296,7 +296,8 @@ func parse(scan *scanner, s string) (t Tag, err error) { // parseTag parses language, script, region and variants. // It returns a Tag and the end position in the input that was parsed. -func parseTag(scan *scanner) (t Tag, end int) { +// If doNorm is true, then - will be normalized to . +func parseTag(scan *scanner, doNorm bool) (t Tag, end int) { var e error // TODO: set an error if an unknown lang, script or region is encountered. t.LangID, e = getLangID(scan.token) @@ -307,14 +308,17 @@ func parseTag(scan *scanner) (t Tag, end int) { for len(scan.token) == 3 && isAlpha(scan.token[0]) { // From http://tools.ietf.org/html/bcp47, - tags are equivalent // to a tag of the form . - lang, e := getLangID(scan.token) - if lang != 0 { - t.LangID = lang - copy(scan.b[langStart:], lang.String()) - scan.b[langStart+3] = '-' - scan.start = langStart + 4 + if doNorm { + lang, e := getLangID(scan.token) + if lang != 0 { + t.LangID = lang + langStr := lang.String() + copy(scan.b[langStart:], langStr) + scan.b[langStart+len(langStr)] = '-' + scan.start = langStart + len(langStr) + 1 + } + scan.gobble(e) } - scan.gobble(e) end = scan.scan() } if len(scan.token) == 4 && isAlpha(scan.token[0]) { @@ -559,7 +563,7 @@ func parseExtension(scan *scanner) int { case 't': // https://www.ietf.org/rfc/rfc6497.txt scan.scan() if n := len(scan.token); n >= 2 && n <= 3 && isAlpha(scan.token[1]) { - _, end = parseTag(scan) + _, end = parseTag(scan, false) scan.toLower(start, end) } for len(scan.token) == 2 && !isAlpha(scan.token[1]) { diff --git a/vendor/golang.org/x/text/internal/language/tables.go b/vendor/golang.org/x/text/internal/language/tables.go index a19480c5ba..fb6b58378b 100644 --- a/vendor/golang.org/x/text/internal/language/tables.go +++ b/vendor/golang.org/x/text/internal/language/tables.go @@ -7,9 +7,9 @@ import "golang.org/x/text/internal/tag" // CLDRVersion is the CLDR version from which the tables in this package are derived. const CLDRVersion = "32" -const NumLanguages = 8717 +const NumLanguages = 8752 -const NumScripts = 251 +const NumScripts = 258 const NumRegions = 357 @@ -121,9 +121,10 @@ const langPrivateEnd = 0x3179 // lang holds an alphabetically sorted list of ISO-639 language identifiers. // All entries are 4 bytes. The index of the identifier (divided by 4) is the language tag. // For 2-byte language identifiers, the two successive bytes have the following meaning: -// - if the first letter of the 2- and 3-letter ISO codes are the same: -// the second and third letter of the 3-letter ISO code. -// - otherwise: a 0 and a by 2 bits right-shifted index into altLangISO3. +// - if the first letter of the 2- and 3-letter ISO codes are the same: +// the second and third letter of the 3-letter ISO code. +// - otherwise: a 0 and a by 2 bits right-shifted index into altLangISO3. +// // For 3-byte language identifiers the 4th byte is 0. const lang tag.Index = "" + // Size: 5324 bytes "---\x00aaaraai\x00aak\x00aau\x00abbkabi\x00abq\x00abr\x00abt\x00aby\x00a" + @@ -265,7 +266,7 @@ var langNoIndex = [2197]uint8{ 0xad, 0x03, 0xff, 0xff, 0xcf, 0x05, 0x84, 0x62, 0xe9, 0xbf, 0xfd, 0xbf, 0xbf, 0xf7, 0xfd, 0x77, 0x0f, 0xff, 0xef, 0x6f, 0xff, 0xfb, 0xdf, 0xe2, - 0xc9, 0xf8, 0x7f, 0x7e, 0x4d, 0xb8, 0x0a, 0x6a, + 0xc9, 0xf8, 0x7f, 0x7e, 0x4d, 0xbc, 0x0a, 0x6a, 0x7c, 0xea, 0xe3, 0xfa, 0x7a, 0xbf, 0x67, 0xff, // Entry 40 - 7F 0xff, 0xff, 0xff, 0xdf, 0x2a, 0x54, 0x91, 0xc0, @@ -277,7 +278,7 @@ var langNoIndex = [2197]uint8{ 0xa8, 0xff, 0x1f, 0x67, 0x7d, 0xeb, 0xef, 0xce, 0xff, 0xff, 0x9f, 0xff, 0xb7, 0xef, 0xfe, 0xcf, // Entry 80 - BF - 0xdb, 0xff, 0xf3, 0xcd, 0xfb, 0x2f, 0xff, 0xff, + 0xdb, 0xff, 0xf3, 0xcd, 0xfb, 0x6f, 0xff, 0xff, 0xbb, 0xee, 0xf7, 0xbd, 0xdb, 0xff, 0x5f, 0xf7, 0xfd, 0xf2, 0xfd, 0xff, 0x5e, 0x2f, 0x3b, 0xba, 0x7e, 0xff, 0xff, 0xfe, 0xf7, 0xff, 0xdd, 0xff, @@ -290,15 +291,15 @@ var langNoIndex = [2197]uint8{ 0x1b, 0x14, 0x08, 0xf3, 0x2b, 0xe7, 0x17, 0x56, 0x05, 0x7d, 0x0e, 0x1c, 0x37, 0x7b, 0xf3, 0xef, 0x97, 0xff, 0x5d, 0x38, 0x64, 0x08, 0x00, 0x10, - 0xbc, 0x85, 0xaf, 0xdf, 0xff, 0xff, 0x73, 0x35, - 0x3e, 0x87, 0xc7, 0xdf, 0xff, 0x01, 0x81, 0x00, + 0xbc, 0x85, 0xaf, 0xdf, 0xff, 0xff, 0x7b, 0x35, + 0x3e, 0xc7, 0xc7, 0xdf, 0xff, 0x01, 0x81, 0x00, 0xb0, 0x05, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x40, 0x00, 0x40, 0x92, 0x21, 0x50, 0xb1, 0x5d, // Entry 100 - 13F 0xfd, 0xdc, 0xbe, 0x5e, 0x00, 0x00, 0x02, 0x64, 0x0d, 0x19, 0x41, 0xdf, 0x79, 0x22, 0x00, 0x00, 0x00, 0x5e, 0x64, 0xdc, 0x24, 0xe5, 0xd9, 0xe3, - 0xfe, 0xff, 0xfd, 0xcb, 0x9f, 0x14, 0x01, 0x0c, + 0xfe, 0xff, 0xfd, 0xcb, 0x9f, 0x14, 0x41, 0x0c, 0x86, 0x00, 0xd1, 0x00, 0xf0, 0xc7, 0x67, 0x5f, 0x56, 0x99, 0x5e, 0xb5, 0x6c, 0xaf, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0xc0, 0x37, 0xda, 0x56, @@ -309,9 +310,9 @@ var langNoIndex = [2197]uint8{ 0x0a, 0x00, 0x01, 0x00, 0x00, 0x10, 0x11, 0x09, 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x44, 0x00, 0x00, 0x10, 0x00, 0x04, - 0x08, 0x00, 0x00, 0x04, 0x00, 0x80, 0x28, 0x04, + 0x08, 0x00, 0x00, 0x05, 0x00, 0x80, 0x28, 0x04, 0x00, 0x00, 0x40, 0xd5, 0x2d, 0x00, 0x64, 0x35, - 0x24, 0x52, 0xf4, 0xd4, 0xbd, 0x62, 0xc9, 0x03, + 0x24, 0x52, 0xf4, 0xd5, 0xbf, 0x62, 0xc9, 0x03, // Entry 180 - 1BF 0x00, 0x80, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x13, 0x39, 0x01, 0xdd, 0x57, 0x98, @@ -333,20 +334,20 @@ var langNoIndex = [2197]uint8{ // Entry 200 - 23F 0xdf, 0xc3, 0x83, 0x82, 0xc0, 0xfb, 0x57, 0x27, 0xed, 0x55, 0xe7, 0x01, 0x00, 0x20, 0xb2, 0xc5, - 0xa4, 0x45, 0x25, 0x9b, 0x02, 0xdf, 0xe0, 0xdf, - 0x03, 0x44, 0x08, 0x90, 0x01, 0x04, 0x01, 0xe3, + 0xa4, 0x45, 0x25, 0x9b, 0x02, 0xdf, 0xe1, 0xdf, + 0x03, 0x44, 0x08, 0x90, 0x01, 0x04, 0x81, 0xe3, 0x92, 0x54, 0xdb, 0x28, 0xd3, 0x5f, 0xfe, 0x6d, 0x79, 0xed, 0x1c, 0x7d, 0x04, 0x08, 0x00, 0x01, 0x21, 0x12, 0x64, 0x5f, 0xdd, 0x0e, 0x85, 0x4f, 0x40, 0x40, 0x00, 0x04, 0xf1, 0xfd, 0x3d, 0x54, // Entry 240 - 27F 0xe8, 0x03, 0xb4, 0x27, 0x23, 0x0d, 0x00, 0x00, - 0x20, 0x7b, 0x78, 0x02, 0x05, 0x84, 0x00, 0xf0, + 0x20, 0x7b, 0x78, 0x02, 0x07, 0x84, 0x00, 0xf0, 0xbb, 0x7e, 0x5a, 0x00, 0x18, 0x04, 0x81, 0x00, 0x00, 0x00, 0x80, 0x10, 0x90, 0x1c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x04, 0x08, 0xa0, 0x70, 0xa5, 0x0c, 0x40, 0x00, 0x00, - 0x11, 0x24, 0x04, 0x68, 0x00, 0x20, 0x70, 0xff, + 0x91, 0x24, 0x04, 0x68, 0x00, 0x20, 0x70, 0xff, 0x7b, 0x7f, 0x70, 0x00, 0x05, 0x9b, 0xdd, 0x66, // Entry 280 - 2BF 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, 0x40, 0x05, @@ -365,12 +366,12 @@ var langNoIndex = [2197]uint8{ 0xa7, 0x81, 0x47, 0x97, 0xfb, 0x00, 0x10, 0x00, 0x08, 0x00, 0x80, 0x00, 0x40, 0x04, 0x00, 0x01, 0x02, 0x00, 0x01, 0x40, 0x80, 0x00, 0x00, 0x08, - 0xd8, 0xeb, 0xf6, 0x39, 0xc4, 0x89, 0x12, 0x00, + 0xd8, 0xeb, 0xf6, 0x39, 0xc4, 0x8d, 0x12, 0x00, // Entry 300 - 33F 0x00, 0x0c, 0x04, 0x01, 0x20, 0x20, 0xdd, 0xa0, 0x01, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x04, 0x10, 0xd0, 0x9d, 0x95, 0x13, 0x04, 0x80, - 0x00, 0x01, 0xd0, 0x12, 0x40, 0x00, 0x10, 0xb0, + 0x00, 0x01, 0xd0, 0x16, 0x40, 0x00, 0x10, 0xb0, 0x10, 0x62, 0x4c, 0xd2, 0x02, 0x01, 0x4a, 0x00, 0x46, 0x04, 0x00, 0x08, 0x02, 0x00, 0x20, 0x80, 0x00, 0x80, 0x06, 0x00, 0x08, 0x00, 0x00, 0x00, @@ -397,9 +398,9 @@ var langNoIndex = [2197]uint8{ 0x02, 0x30, 0x9f, 0x7a, 0x16, 0xbd, 0x7f, 0x57, 0xf2, 0xff, 0x31, 0xff, 0xf2, 0x1e, 0x90, 0xf7, 0xf1, 0xf9, 0x45, 0x80, 0x01, 0x02, 0x00, 0x00, - 0x40, 0x54, 0x9f, 0x8a, 0xd9, 0xf9, 0x2e, 0x11, + 0x40, 0x54, 0x9f, 0x8a, 0xdb, 0xf9, 0x2e, 0x11, 0x86, 0x51, 0xc0, 0xf3, 0xfb, 0x47, 0x40, 0x01, - 0x05, 0xd1, 0x50, 0x5c, 0x00, 0x00, 0x00, 0x10, + 0x05, 0xd1, 0x50, 0x5c, 0x00, 0x40, 0x00, 0x10, 0x04, 0x02, 0x00, 0x00, 0x0a, 0x00, 0x17, 0xd2, 0xb9, 0xfd, 0xfc, 0xba, 0xfe, 0xef, 0xc7, 0xbe, // Entry 400 - 43F @@ -421,19 +422,19 @@ var langNoIndex = [2197]uint8{ 0xcd, 0xff, 0xfb, 0xff, 0xdf, 0xd7, 0xea, 0xff, 0xe5, 0x5f, 0x6d, 0x0f, 0xa7, 0x51, 0x06, 0xc4, // Entry 480 - 4BF - 0x13, 0x50, 0x5d, 0xaf, 0xa6, 0xff, 0x99, 0xfb, + 0x93, 0x50, 0x5d, 0xaf, 0xa6, 0xff, 0x99, 0xfb, 0x63, 0x1d, 0x53, 0xff, 0xef, 0xb7, 0x35, 0x20, 0x14, 0x00, 0x55, 0x51, 0x82, 0x65, 0xf5, 0x41, 0xe2, 0xff, 0xfc, 0xdf, 0x02, 0x05, 0xc5, 0x05, - 0x00, 0x22, 0x00, 0x74, 0x69, 0x10, 0x08, 0x04, + 0x00, 0x22, 0x00, 0x74, 0x69, 0x10, 0x08, 0x05, 0x41, 0x00, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x20, 0x05, 0x04, 0x01, 0x00, 0x00, - 0x06, 0x01, 0x20, 0x00, 0x18, 0x01, 0x92, 0xb1, + 0x06, 0x01, 0x20, 0x00, 0x18, 0x01, 0x92, 0xf1, // Entry 4C0 - 4FF - 0xfd, 0x47, 0x49, 0x06, 0x95, 0x06, 0x57, 0xed, - 0xfb, 0x4c, 0x1c, 0x6b, 0x83, 0x04, 0x62, 0x40, + 0xfd, 0x47, 0x69, 0x06, 0x95, 0x06, 0x57, 0xed, + 0xfb, 0x4d, 0x1c, 0x6b, 0x83, 0x04, 0x62, 0x40, 0x00, 0x11, 0x42, 0x00, 0x00, 0x00, 0x54, 0x83, - 0xb8, 0x4f, 0x10, 0x8c, 0x89, 0x46, 0xde, 0xf7, + 0xb8, 0x4f, 0x10, 0x8e, 0x89, 0x46, 0xde, 0xf7, 0x13, 0x31, 0x00, 0x20, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x10, 0x00, 0x01, 0x00, 0x00, 0xf0, 0x5b, 0xf4, 0xbe, 0x3d, @@ -470,7 +471,7 @@ var langNoIndex = [2197]uint8{ 0xaa, 0x10, 0x5d, 0x98, 0x52, 0x00, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x02, 0x02, 0x19, 0x00, 0x10, 0x02, 0x10, 0x61, 0x5a, 0x9d, - 0x31, 0x00, 0x00, 0x00, 0x01, 0x10, 0x02, 0x20, + 0x31, 0x00, 0x00, 0x00, 0x01, 0x18, 0x02, 0x20, 0x00, 0x00, 0x01, 0x00, 0x42, 0x00, 0x20, 0x00, 0x00, 0x1f, 0xdf, 0xd2, 0xb9, 0xff, 0xfd, 0x3f, 0x1f, 0x98, 0xcf, 0x9c, 0xff, 0xaf, 0x5f, 0xfe, @@ -479,9 +480,9 @@ var langNoIndex = [2197]uint8{ 0xb7, 0xf6, 0xfb, 0xb3, 0xc7, 0xff, 0x6f, 0xf1, 0x73, 0xb1, 0x7f, 0x9f, 0x7f, 0xbd, 0xfc, 0xb7, 0xee, 0x1c, 0xfa, 0xcb, 0xef, 0xdd, 0xf9, 0xbd, - 0x6e, 0xae, 0x55, 0xfd, 0x6e, 0x81, 0x76, 0x1f, + 0x6e, 0xae, 0x55, 0xfd, 0x6e, 0x81, 0x76, 0x9f, 0xd4, 0x77, 0xf5, 0x7d, 0xfb, 0xff, 0xeb, 0xfe, - 0xbe, 0x5f, 0x46, 0x1b, 0xe9, 0x5f, 0x50, 0x18, + 0xbe, 0x5f, 0x46, 0x5b, 0xe9, 0x5f, 0x50, 0x18, 0x02, 0xfa, 0xf7, 0x9d, 0x15, 0x97, 0x05, 0x0f, // Entry 640 - 67F 0x75, 0xc4, 0x7d, 0x81, 0x92, 0xf5, 0x57, 0x6c, @@ -495,14 +496,14 @@ var langNoIndex = [2197]uint8{ // Entry 680 - 6BF 0x97, 0x9d, 0xbf, 0x9f, 0xf7, 0xc7, 0xfd, 0x37, 0xce, 0x7f, 0x04, 0x1d, 0x73, 0x7f, 0xf8, 0xda, - 0x5d, 0xce, 0x7d, 0x06, 0xb9, 0xea, 0x69, 0xa0, + 0x5d, 0xce, 0x7d, 0x06, 0xb9, 0xea, 0x79, 0xa0, 0x1a, 0x20, 0x00, 0x30, 0x02, 0x04, 0x24, 0x08, 0x04, 0x00, 0x00, 0x40, 0xd4, 0x02, 0x04, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x20, 0x01, 0x06, 0x50, 0x00, 0x08, 0x00, 0x00, 0x00, 0x24, 0x00, 0x04, 0x00, 0x10, 0xdc, 0x58, 0xd7, 0x0d, 0x0f, // Entry 6C0 - 6FF - 0x14, 0x4d, 0xf1, 0x16, 0x44, 0xd1, 0x42, 0x08, + 0x14, 0x4d, 0xf1, 0x16, 0x44, 0xd5, 0x42, 0x08, 0x40, 0x00, 0x00, 0x40, 0x00, 0x08, 0x00, 0x00, 0x00, 0xdc, 0xfb, 0xcb, 0x0e, 0x58, 0x48, 0x41, 0x24, 0x20, 0x04, 0x00, 0x30, 0x12, 0x40, 0x00, @@ -513,7 +514,7 @@ var langNoIndex = [2197]uint8{ // Entry 700 - 73F 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x80, 0x86, 0xc2, 0x00, 0x00, 0x00, 0x00, 0x01, - 0xdf, 0x18, 0x00, 0x00, 0x02, 0xf0, 0xfd, 0x79, + 0xff, 0x18, 0x02, 0x00, 0x02, 0xf0, 0xfd, 0x79, 0x3b, 0x00, 0x25, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x03, 0x00, 0x09, 0x20, 0x00, 0x00, 0x01, 0x00, @@ -525,7 +526,7 @@ var langNoIndex = [2197]uint8{ 0xcd, 0xf9, 0x5c, 0x00, 0x01, 0x00, 0x30, 0x04, 0x04, 0x55, 0x00, 0x01, 0x04, 0xf4, 0x3f, 0x4a, 0x01, 0x00, 0x00, 0xb0, 0x80, 0x20, 0x55, 0x75, - 0x97, 0x7c, 0x9f, 0x31, 0xcc, 0x68, 0xd1, 0x03, + 0x97, 0x7c, 0xdf, 0x31, 0xcc, 0x68, 0xd1, 0x03, 0xd5, 0x57, 0x27, 0x14, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0xf7, 0xcb, 0x1f, 0x14, 0x60, // Entry 780 - 7BF @@ -538,7 +539,7 @@ var langNoIndex = [2197]uint8{ 0xe8, 0x30, 0x90, 0x6a, 0x92, 0x00, 0x00, 0x02, 0xff, 0xef, 0xff, 0x4b, 0x85, 0x53, 0xf4, 0xed, // Entry 7C0 - 7FF - 0xdd, 0xbf, 0x72, 0x1d, 0xc7, 0x0c, 0xd5, 0x42, + 0xdd, 0xbf, 0xf2, 0x5d, 0xc7, 0x0c, 0xd5, 0x42, 0xfc, 0xff, 0xf7, 0x1f, 0x00, 0x80, 0x40, 0x56, 0xcc, 0x16, 0x9e, 0xea, 0x35, 0x7d, 0xef, 0xff, 0xbd, 0xa4, 0xaf, 0x01, 0x44, 0x18, 0x01, 0x4d, @@ -552,15 +553,15 @@ var langNoIndex = [2197]uint8{ 0x40, 0x9c, 0x44, 0xdf, 0xf5, 0x8f, 0x66, 0xb3, 0x55, 0x20, 0xd4, 0xc1, 0xd8, 0x30, 0x3d, 0x80, 0x00, 0x00, 0x00, 0x04, 0xd4, 0x11, 0xc5, 0x84, - 0x2e, 0x50, 0x00, 0x22, 0x50, 0x6e, 0xbd, 0x93, + 0x2f, 0x50, 0x00, 0x22, 0x50, 0x6e, 0xbd, 0x93, 0x07, 0x00, 0x20, 0x10, 0x84, 0xb2, 0x45, 0x10, 0x06, 0x44, 0x00, 0x00, 0x12, 0x02, 0x11, 0x00, // Entry 840 - 87F - 0xf0, 0xfb, 0xfd, 0x7f, 0x05, 0x00, 0x12, 0x81, + 0xf0, 0xfb, 0xfd, 0x7f, 0x05, 0x00, 0x16, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x30, 0x02, 0x28, 0x84, 0x00, 0x21, 0xc0, 0x23, 0x24, 0x00, 0x00, - 0x00, 0xcb, 0xe4, 0x3a, 0x42, 0x88, 0x14, 0xf1, + 0x00, 0xcb, 0xe4, 0x3a, 0x46, 0x88, 0x14, 0xf1, 0xef, 0xff, 0x7f, 0x12, 0x01, 0x01, 0x84, 0x50, 0x07, 0xfc, 0xff, 0xff, 0x0f, 0x01, 0x00, 0x40, 0x10, 0x38, 0x01, 0x01, 0x1c, 0x12, 0x40, 0xe1, @@ -582,8 +583,8 @@ var altLangIndex = [6]uint16{ } // AliasMap maps langIDs to their suggested replacements. -// Size: 704 bytes, 176 elements -var AliasMap = [176]FromTo{ +// Size: 716 bytes, 179 elements +var AliasMap = [179]FromTo{ 0: {From: 0x82, To: 0x88}, 1: {From: 0x187, To: 0x1ae}, 2: {From: 0x1f3, To: 0x1e1}, @@ -612,172 +613,176 @@ var AliasMap = [176]FromTo{ 25: {From: 0x80c, To: 0x5a}, 26: {From: 0x815, To: 0x8d}, 27: {From: 0x87e, To: 0x810}, - 28: {From: 0x8c3, To: 0xee3}, - 29: {From: 0x9ef, To: 0x331}, - 30: {From: 0xa36, To: 0x2c5}, - 31: {From: 0xa3d, To: 0xbf}, - 32: {From: 0xabe, To: 0x3322}, - 33: {From: 0xb38, To: 0x529}, - 34: {From: 0xb75, To: 0x265a}, - 35: {From: 0xb7e, To: 0xbc3}, - 36: {From: 0xb9b, To: 0x44e}, - 37: {From: 0xbbc, To: 0x4229}, - 38: {From: 0xbbf, To: 0x529}, - 39: {From: 0xbfe, To: 0x2da7}, - 40: {From: 0xc2e, To: 0x3181}, - 41: {From: 0xcb9, To: 0xf3}, - 42: {From: 0xd08, To: 0xfa}, - 43: {From: 0xdc8, To: 0x11a}, - 44: {From: 0xdd7, To: 0x32d}, - 45: {From: 0xdf8, To: 0xdfb}, - 46: {From: 0xdfe, To: 0x531}, - 47: {From: 0xe01, To: 0xdf3}, - 48: {From: 0xedf, To: 0x205a}, - 49: {From: 0xee9, To: 0x222e}, - 50: {From: 0xeee, To: 0x2e9a}, - 51: {From: 0xf39, To: 0x367}, - 52: {From: 0x10d0, To: 0x140}, - 53: {From: 0x1104, To: 0x2d0}, - 54: {From: 0x11a0, To: 0x1ec}, - 55: {From: 0x1279, To: 0x21}, - 56: {From: 0x1424, To: 0x15e}, - 57: {From: 0x1470, To: 0x14e}, - 58: {From: 0x151f, To: 0xd9b}, - 59: {From: 0x1523, To: 0x390}, - 60: {From: 0x1532, To: 0x19f}, - 61: {From: 0x1580, To: 0x210}, - 62: {From: 0x1583, To: 0x10d}, - 63: {From: 0x15a3, To: 0x3caf}, - 64: {From: 0x1630, To: 0x222e}, - 65: {From: 0x166a, To: 0x19b}, - 66: {From: 0x16c8, To: 0x136}, - 67: {From: 0x1700, To: 0x29f8}, - 68: {From: 0x1718, To: 0x194}, - 69: {From: 0x1727, To: 0xf3f}, - 70: {From: 0x177a, To: 0x178}, - 71: {From: 0x1809, To: 0x17b6}, - 72: {From: 0x1816, To: 0x18f3}, - 73: {From: 0x188a, To: 0x436}, - 74: {From: 0x1979, To: 0x1d01}, - 75: {From: 0x1a74, To: 0x2bb0}, - 76: {From: 0x1a8a, To: 0x1f8}, - 77: {From: 0x1b5a, To: 0x1fa}, - 78: {From: 0x1b86, To: 0x1515}, - 79: {From: 0x1d64, To: 0x2c9b}, - 80: {From: 0x2038, To: 0x37b1}, - 81: {From: 0x203d, To: 0x20dd}, - 82: {From: 0x205a, To: 0x30b}, - 83: {From: 0x20e3, To: 0x274}, - 84: {From: 0x20ee, To: 0x263}, - 85: {From: 0x20f2, To: 0x22d}, - 86: {From: 0x20f9, To: 0x256}, - 87: {From: 0x210f, To: 0x21eb}, - 88: {From: 0x2135, To: 0x27d}, - 89: {From: 0x2160, To: 0x913}, - 90: {From: 0x2199, To: 0x121}, - 91: {From: 0x21ce, To: 0x1561}, - 92: {From: 0x21e6, To: 0x504}, - 93: {From: 0x21f4, To: 0x49f}, - 94: {From: 0x21fb, To: 0x269}, - 95: {From: 0x222d, To: 0x121}, - 96: {From: 0x2237, To: 0x121}, - 97: {From: 0x2262, To: 0x92a}, - 98: {From: 0x2316, To: 0x3226}, - 99: {From: 0x236a, To: 0x2835}, - 100: {From: 0x2382, To: 0x3365}, - 101: {From: 0x2472, To: 0x2c7}, - 102: {From: 0x24e4, To: 0x2ff}, - 103: {From: 0x24f0, To: 0x2fa}, - 104: {From: 0x24fa, To: 0x31f}, - 105: {From: 0x2550, To: 0xb5b}, - 106: {From: 0x25a9, To: 0xe2}, - 107: {From: 0x263e, To: 0x2d0}, - 108: {From: 0x26c9, To: 0x26b4}, - 109: {From: 0x26f9, To: 0x3c8}, - 110: {From: 0x2727, To: 0x3caf}, - 111: {From: 0x2755, To: 0x6a4}, - 112: {From: 0x2765, To: 0x26b4}, - 113: {From: 0x2789, To: 0x4358}, - 114: {From: 0x27c9, To: 0x2001}, - 115: {From: 0x28ea, To: 0x27b1}, - 116: {From: 0x28ef, To: 0x2837}, - 117: {From: 0x2914, To: 0x351}, - 118: {From: 0x2986, To: 0x2da7}, - 119: {From: 0x29f0, To: 0x96b}, - 120: {From: 0x2b1a, To: 0x38d}, - 121: {From: 0x2bfc, To: 0x395}, - 122: {From: 0x2c3f, To: 0x3caf}, - 123: {From: 0x2cfc, To: 0x3be}, - 124: {From: 0x2d13, To: 0x597}, - 125: {From: 0x2d47, To: 0x148}, - 126: {From: 0x2d48, To: 0x148}, - 127: {From: 0x2dff, To: 0x2f1}, - 128: {From: 0x2e08, To: 0x19cc}, - 129: {From: 0x2e1a, To: 0x2d95}, - 130: {From: 0x2e21, To: 0x292}, - 131: {From: 0x2e54, To: 0x7d}, - 132: {From: 0x2e65, To: 0x2282}, - 133: {From: 0x2ea0, To: 0x2e9b}, - 134: {From: 0x2eef, To: 0x2ed7}, - 135: {From: 0x3193, To: 0x3c4}, - 136: {From: 0x3366, To: 0x338e}, - 137: {From: 0x342a, To: 0x3dc}, - 138: {From: 0x34ee, To: 0x18d0}, - 139: {From: 0x35c8, To: 0x2c9b}, - 140: {From: 0x35e6, To: 0x412}, - 141: {From: 0x3658, To: 0x246}, - 142: {From: 0x3676, To: 0x3f4}, - 143: {From: 0x36fd, To: 0x445}, - 144: {From: 0x37c0, To: 0x121}, - 145: {From: 0x3816, To: 0x38f2}, - 146: {From: 0x382a, To: 0x2b48}, - 147: {From: 0x382b, To: 0x2c9b}, - 148: {From: 0x382f, To: 0xa9}, - 149: {From: 0x3832, To: 0x3228}, - 150: {From: 0x386c, To: 0x39a6}, - 151: {From: 0x3892, To: 0x3fc0}, - 152: {From: 0x38a5, To: 0x39d7}, - 153: {From: 0x38b4, To: 0x1fa4}, - 154: {From: 0x38b5, To: 0x2e9a}, - 155: {From: 0x395c, To: 0x47e}, - 156: {From: 0x3b4e, To: 0xd91}, - 157: {From: 0x3b78, To: 0x137}, - 158: {From: 0x3c99, To: 0x4bc}, - 159: {From: 0x3fbd, To: 0x100}, - 160: {From: 0x4208, To: 0xa91}, - 161: {From: 0x42be, To: 0x573}, - 162: {From: 0x42f9, To: 0x3f60}, - 163: {From: 0x4378, To: 0x25a}, - 164: {From: 0x43b8, To: 0xe6c}, - 165: {From: 0x43cd, To: 0x10f}, - 166: {From: 0x44af, To: 0x3322}, - 167: {From: 0x44e3, To: 0x512}, - 168: {From: 0x45ca, To: 0x2409}, - 169: {From: 0x45dd, To: 0x26dc}, - 170: {From: 0x4610, To: 0x48ae}, - 171: {From: 0x46ae, To: 0x46a0}, - 172: {From: 0x473e, To: 0x4745}, - 173: {From: 0x4817, To: 0x3503}, - 174: {From: 0x4916, To: 0x31f}, - 175: {From: 0x49a7, To: 0x523}, + 28: {From: 0x8a8, To: 0x8b7}, + 29: {From: 0x8c3, To: 0xee3}, + 30: {From: 0x8fa, To: 0x1dc}, + 31: {From: 0x9ef, To: 0x331}, + 32: {From: 0xa36, To: 0x2c5}, + 33: {From: 0xa3d, To: 0xbf}, + 34: {From: 0xabe, To: 0x3322}, + 35: {From: 0xb38, To: 0x529}, + 36: {From: 0xb75, To: 0x265a}, + 37: {From: 0xb7e, To: 0xbc3}, + 38: {From: 0xb9b, To: 0x44e}, + 39: {From: 0xbbc, To: 0x4229}, + 40: {From: 0xbbf, To: 0x529}, + 41: {From: 0xbfe, To: 0x2da7}, + 42: {From: 0xc2e, To: 0x3181}, + 43: {From: 0xcb9, To: 0xf3}, + 44: {From: 0xd08, To: 0xfa}, + 45: {From: 0xdc8, To: 0x11a}, + 46: {From: 0xdd7, To: 0x32d}, + 47: {From: 0xdf8, To: 0xdfb}, + 48: {From: 0xdfe, To: 0x531}, + 49: {From: 0xe01, To: 0xdf3}, + 50: {From: 0xedf, To: 0x205a}, + 51: {From: 0xee9, To: 0x222e}, + 52: {From: 0xeee, To: 0x2e9a}, + 53: {From: 0xf39, To: 0x367}, + 54: {From: 0x10d0, To: 0x140}, + 55: {From: 0x1104, To: 0x2d0}, + 56: {From: 0x11a0, To: 0x1ec}, + 57: {From: 0x1279, To: 0x21}, + 58: {From: 0x1424, To: 0x15e}, + 59: {From: 0x1470, To: 0x14e}, + 60: {From: 0x151f, To: 0xd9b}, + 61: {From: 0x1523, To: 0x390}, + 62: {From: 0x1532, To: 0x19f}, + 63: {From: 0x1580, To: 0x210}, + 64: {From: 0x1583, To: 0x10d}, + 65: {From: 0x15a3, To: 0x3caf}, + 66: {From: 0x1630, To: 0x222e}, + 67: {From: 0x166a, To: 0x19b}, + 68: {From: 0x16c8, To: 0x136}, + 69: {From: 0x1700, To: 0x29f8}, + 70: {From: 0x1718, To: 0x194}, + 71: {From: 0x1727, To: 0xf3f}, + 72: {From: 0x177a, To: 0x178}, + 73: {From: 0x1809, To: 0x17b6}, + 74: {From: 0x1816, To: 0x18f3}, + 75: {From: 0x188a, To: 0x436}, + 76: {From: 0x1979, To: 0x1d01}, + 77: {From: 0x1a74, To: 0x2bb0}, + 78: {From: 0x1a8a, To: 0x1f8}, + 79: {From: 0x1b5a, To: 0x1fa}, + 80: {From: 0x1b86, To: 0x1515}, + 81: {From: 0x1d64, To: 0x2c9b}, + 82: {From: 0x2038, To: 0x37b1}, + 83: {From: 0x203d, To: 0x20dd}, + 84: {From: 0x205a, To: 0x30b}, + 85: {From: 0x20e3, To: 0x274}, + 86: {From: 0x20ee, To: 0x263}, + 87: {From: 0x20f2, To: 0x22d}, + 88: {From: 0x20f9, To: 0x256}, + 89: {From: 0x210f, To: 0x21eb}, + 90: {From: 0x2135, To: 0x27d}, + 91: {From: 0x2160, To: 0x913}, + 92: {From: 0x2199, To: 0x121}, + 93: {From: 0x21ce, To: 0x1561}, + 94: {From: 0x21e6, To: 0x504}, + 95: {From: 0x21f4, To: 0x49f}, + 96: {From: 0x21fb, To: 0x269}, + 97: {From: 0x222d, To: 0x121}, + 98: {From: 0x2237, To: 0x121}, + 99: {From: 0x2262, To: 0x92a}, + 100: {From: 0x2316, To: 0x3226}, + 101: {From: 0x236a, To: 0x2835}, + 102: {From: 0x2382, To: 0x3365}, + 103: {From: 0x2472, To: 0x2c7}, + 104: {From: 0x24e4, To: 0x2ff}, + 105: {From: 0x24f0, To: 0x2fa}, + 106: {From: 0x24fa, To: 0x31f}, + 107: {From: 0x2550, To: 0xb5b}, + 108: {From: 0x25a9, To: 0xe2}, + 109: {From: 0x263e, To: 0x2d0}, + 110: {From: 0x26c9, To: 0x26b4}, + 111: {From: 0x26f9, To: 0x3c8}, + 112: {From: 0x2727, To: 0x3caf}, + 113: {From: 0x2755, To: 0x6a4}, + 114: {From: 0x2765, To: 0x26b4}, + 115: {From: 0x2789, To: 0x4358}, + 116: {From: 0x27c9, To: 0x2001}, + 117: {From: 0x28ea, To: 0x27b1}, + 118: {From: 0x28ef, To: 0x2837}, + 119: {From: 0x2914, To: 0x351}, + 120: {From: 0x2986, To: 0x2da7}, + 121: {From: 0x29f0, To: 0x96b}, + 122: {From: 0x2b1a, To: 0x38d}, + 123: {From: 0x2bfc, To: 0x395}, + 124: {From: 0x2c3f, To: 0x3caf}, + 125: {From: 0x2ce1, To: 0x2201}, + 126: {From: 0x2cfc, To: 0x3be}, + 127: {From: 0x2d13, To: 0x597}, + 128: {From: 0x2d47, To: 0x148}, + 129: {From: 0x2d48, To: 0x148}, + 130: {From: 0x2dff, To: 0x2f1}, + 131: {From: 0x2e08, To: 0x19cc}, + 132: {From: 0x2e1a, To: 0x2d95}, + 133: {From: 0x2e21, To: 0x292}, + 134: {From: 0x2e54, To: 0x7d}, + 135: {From: 0x2e65, To: 0x2282}, + 136: {From: 0x2ea0, To: 0x2e9b}, + 137: {From: 0x2eef, To: 0x2ed7}, + 138: {From: 0x3193, To: 0x3c4}, + 139: {From: 0x3366, To: 0x338e}, + 140: {From: 0x342a, To: 0x3dc}, + 141: {From: 0x34ee, To: 0x18d0}, + 142: {From: 0x35c8, To: 0x2c9b}, + 143: {From: 0x35e6, To: 0x412}, + 144: {From: 0x3658, To: 0x246}, + 145: {From: 0x3676, To: 0x3f4}, + 146: {From: 0x36fd, To: 0x445}, + 147: {From: 0x37c0, To: 0x121}, + 148: {From: 0x3816, To: 0x38f2}, + 149: {From: 0x382a, To: 0x2b48}, + 150: {From: 0x382b, To: 0x2c9b}, + 151: {From: 0x382f, To: 0xa9}, + 152: {From: 0x3832, To: 0x3228}, + 153: {From: 0x386c, To: 0x39a6}, + 154: {From: 0x3892, To: 0x3fc0}, + 155: {From: 0x38a5, To: 0x39d7}, + 156: {From: 0x38b4, To: 0x1fa4}, + 157: {From: 0x38b5, To: 0x2e9a}, + 158: {From: 0x395c, To: 0x47e}, + 159: {From: 0x3b4e, To: 0xd91}, + 160: {From: 0x3b78, To: 0x137}, + 161: {From: 0x3c99, To: 0x4bc}, + 162: {From: 0x3fbd, To: 0x100}, + 163: {From: 0x4208, To: 0xa91}, + 164: {From: 0x42be, To: 0x573}, + 165: {From: 0x42f9, To: 0x3f60}, + 166: {From: 0x4378, To: 0x25a}, + 167: {From: 0x43b8, To: 0xe6c}, + 168: {From: 0x43cd, To: 0x10f}, + 169: {From: 0x44af, To: 0x3322}, + 170: {From: 0x44e3, To: 0x512}, + 171: {From: 0x45ca, To: 0x2409}, + 172: {From: 0x45dd, To: 0x26dc}, + 173: {From: 0x4610, To: 0x48ae}, + 174: {From: 0x46ae, To: 0x46a0}, + 175: {From: 0x473e, To: 0x4745}, + 176: {From: 0x4817, To: 0x3503}, + 177: {From: 0x4916, To: 0x31f}, + 178: {From: 0x49a7, To: 0x523}, } -// Size: 176 bytes, 176 elements -var AliasTypes = [176]AliasType{ +// Size: 179 bytes, 179 elements +var AliasTypes = [179]AliasType{ // Entry 0 - 3F 1, 0, 0, 0, 0, 0, 0, 1, 2, 2, 0, 1, 0, 0, 1, 2, - 1, 1, 2, 0, 0, 1, 0, 1, 2, 1, 1, 0, 0, 2, 1, 1, - 0, 2, 0, 0, 1, 0, 1, 0, 0, 1, 2, 1, 1, 1, 1, 0, - 0, 0, 0, 2, 1, 1, 1, 1, 2, 1, 0, 1, 1, 2, 2, 0, + 1, 1, 2, 0, 0, 1, 0, 1, 2, 1, 1, 0, 0, 0, 0, 2, + 1, 1, 0, 2, 0, 0, 1, 0, 1, 0, 0, 1, 2, 1, 1, 1, + 1, 0, 0, 0, 0, 2, 1, 1, 1, 1, 2, 1, 0, 1, 1, 2, // Entry 40 - 7F - 0, 1, 2, 0, 1, 0, 1, 1, 1, 1, 0, 0, 2, 1, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 0, 0, 0, 1, 2, 2, 2, 0, 1, 1, 0, 1, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 2, 1, 1, + 2, 0, 0, 1, 2, 0, 1, 0, 1, 1, 1, 1, 0, 0, 2, 1, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 2, 0, 1, 1, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, // Entry 80 - BF - 0, 0, 1, 0, 0, 0, 0, 1, 1, 2, 0, 0, 2, 1, 1, 1, - 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 2, - 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, + 2, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 2, 0, 0, 2, + 1, 1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, + 0, 1, 2, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, + 0, 1, 1, } const ( @@ -785,17 +790,17 @@ const ( _Hani = 57 _Hans = 59 _Hant = 60 - _Qaaa = 143 - _Qaai = 151 - _Qabx = 192 - _Zinh = 245 - _Zyyy = 250 - _Zzzz = 251 + _Qaaa = 147 + _Qaai = 155 + _Qabx = 196 + _Zinh = 252 + _Zyyy = 257 + _Zzzz = 258 ) // script is an alphabetically sorted list of ISO 15924 codes. The index // of the script in the string, divided by 4, is the internal scriptID. -const script tag.Index = "" + // Size: 1012 bytes +const script tag.Index = "" + // Size: 1040 bytes "----AdlmAfakAghbAhomArabAranArmiArmnAvstBaliBamuBassBatkBengBhksBlisBopo" + "BrahBraiBugiBuhdCakmCansCariChamCherChrsCirtCoptCpmnCprtCyrlCyrsDevaDiak" + "DogrDsrtDuplEgydEgyhEgypElbaElymEthiGeokGeorGlagGongGonmGothGranGrekGujr" + @@ -803,14 +808,14 @@ const script tag.Index = "" + // Size: 1012 bytes "JavaJpanJurcKaliKanaKharKhmrKhojKitlKitsKndaKoreKpelKthiLanaLaooLatfLatg" + "LatnLekeLepcLimbLinaLinbLisuLomaLyciLydiMahjMakaMandManiMarcMayaMedfMend" + "MercMeroMlymModiMongMoonMrooMteiMultMymrNandNarbNbatNewaNkdbNkgbNkooNshu" + - "OgamOlckOrkhOryaOsgeOsmaPalmPaucPermPhagPhliPhlpPhlvPhnxPiqdPlrdPrtiQaaa" + - "QaabQaacQaadQaaeQaafQaagQaahQaaiQaajQaakQaalQaamQaanQaaoQaapQaaqQaarQaas" + - "QaatQaauQaavQaawQaaxQaayQaazQabaQabbQabcQabdQabeQabfQabgQabhQabiQabjQabk" + - "QablQabmQabnQaboQabpQabqQabrQabsQabtQabuQabvQabwQabxRjngRohgRoroRunrSamr" + - "SaraSarbSaurSgnwShawShrdShuiSiddSindSinhSogdSogoSoraSoyoSundSyloSyrcSyre" + - "SyrjSyrnTagbTakrTaleTaluTamlTangTavtTeluTengTfngTglgThaaThaiTibtTirhToto" + - "UgarVaiiVispWaraWchoWoleXpeoXsuxYeziYiiiZanbZinhZmthZsyeZsymZxxxZyyyZzzz" + - "\xff\xff\xff\xff" + "OgamOlckOrkhOryaOsgeOsmaOugrPalmPaucPcunPelmPermPhagPhliPhlpPhlvPhnxPiqd" + + "PlrdPrtiPsinQaaaQaabQaacQaadQaaeQaafQaagQaahQaaiQaajQaakQaalQaamQaanQaao" + + "QaapQaaqQaarQaasQaatQaauQaavQaawQaaxQaayQaazQabaQabbQabcQabdQabeQabfQabg" + + "QabhQabiQabjQabkQablQabmQabnQaboQabpQabqQabrQabsQabtQabuQabvQabwQabxRanj" + + "RjngRohgRoroRunrSamrSaraSarbSaurSgnwShawShrdShuiSiddSindSinhSogdSogoSora" + + "SoyoSundSyloSyrcSyreSyrjSyrnTagbTakrTaleTaluTamlTangTavtTeluTengTfngTglg" + + "ThaaThaiTibtTirhTnsaTotoUgarVaiiVispVithWaraWchoWoleXpeoXsuxYeziYiiiZanb" + + "ZinhZmthZsyeZsymZxxxZyyyZzzz\xff\xff\xff\xff" // suppressScript is an index from langID to the dominant script for that language, // if it exists. If a script is given, it should be suppressed from the language tag. @@ -858,7 +863,7 @@ var suppressScript = [1330]uint8{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xe5, 0x00, 0x00, 0x00, 0x00, 0xe7, 0x00, 0x00, + 0xea, 0x00, 0x00, 0x00, 0x00, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x5a, 0x00, 0x5a, 0x00, // Entry 140 - 17F @@ -962,7 +967,7 @@ var suppressScript = [1330]uint8{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Entry 400 - 43F 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0xcf, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -972,10 +977,10 @@ var suppressScript = [1330]uint8{ // Entry 440 - 47F 0x00, 0x00, 0x00, 0x00, 0x5a, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xde, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xe1, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xe6, 0x00, 0x00, 0x00, 0x2c, + 0x00, 0xe6, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xeb, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x5a, 0x00, // Entry 480 - 4BF @@ -1086,9 +1091,9 @@ var regionTypes = [358]uint8{ // regionISO holds a list of alphabetically sorted 2-letter ISO region codes. // Each 2-letter codes is followed by two bytes with the following meaning: -// - [A-Z}{2}: the first letter of the 2-letter code plus these two -// letters form the 3-letter ISO code. -// - 0, n: index into altRegionISO3. +// - [A-Z}{2}: the first letter of the 2-letter code plus these two +// letters form the 3-letter ISO code. +// - 0, n: index into altRegionISO3. const regionISO tag.Index = "" + // Size: 1308 bytes "AAAAACSCADNDAEREAFFGAGTGAIIAALLBAMRMANNTAOGOAQTAARRGASSMATUTAUUSAWBWAXLA" + "AZZEBAIHBBRBBDGDBEELBFFABGGRBHHRBIDIBJENBLLMBMMUBNRNBOOLBQESBRRABSHSBTTN" + @@ -1206,7 +1211,9 @@ var m49 = [358]int16{ // m49Index gives indexes into fromM49 based on the three most significant bits // of a 10-bit UN.M49 code. To search an UN.M49 code in fromM49, search in -// fromM49[m49Index[msb39(code)]:m49Index[msb3(code)+1]] +// +// fromM49[m49Index[msb39(code)]:m49Index[msb3(code)+1]] +// // for an entry where the first 7 bits match the 7 lsb of the UN.M49 code. // The region code is stored in the 9 lsb of the indexed value. // Size: 18 bytes, 9 elements @@ -1268,117 +1275,118 @@ var fromM49 = [333]uint16{ 0xc759, 0xc95a, 0xcb5b, 0xcd5c, 0xcf65, } -// Size: 1995 bytes +// Size: 2014 bytes var variantIndex = map[string]uint8{ "1606nict": 0x0, "1694acad": 0x1, "1901": 0x2, "1959acad": 0x3, - "1994": 0x60, + "1994": 0x61, "1996": 0x4, "abl1943": 0x5, "akuapem": 0x6, - "alalc97": 0x62, + "alalc97": 0x63, "aluku": 0x7, "ao1990": 0x8, "aranes": 0x9, "arevela": 0xa, "arevmda": 0xb, - "asante": 0xc, - "auvern": 0xd, - "baku1926": 0xe, - "balanka": 0xf, - "barla": 0x10, - "basiceng": 0x11, - "bauddha": 0x12, - "biscayan": 0x13, - "biske": 0x5b, - "bohoric": 0x14, - "boont": 0x15, - "bornholm": 0x16, - "cisaup": 0x17, - "colb1945": 0x18, - "cornu": 0x19, - "creiss": 0x1a, - "dajnko": 0x1b, - "ekavsk": 0x1c, - "emodeng": 0x1d, - "fonipa": 0x63, - "fonkirsh": 0x64, - "fonnapa": 0x65, - "fonupa": 0x66, - "fonxsamp": 0x67, - "gascon": 0x1e, - "grclass": 0x1f, - "grital": 0x20, - "grmistr": 0x21, - "hepburn": 0x22, - "heploc": 0x61, - "hognorsk": 0x23, - "hsistemo": 0x24, - "ijekavsk": 0x25, - "itihasa": 0x26, - "ivanchov": 0x27, - "jauer": 0x28, - "jyutping": 0x29, - "kkcor": 0x2a, - "kociewie": 0x2b, - "kscor": 0x2c, - "laukika": 0x2d, - "lemosin": 0x2e, - "lengadoc": 0x2f, - "lipaw": 0x5c, - "luna1918": 0x30, - "metelko": 0x31, - "monoton": 0x32, - "ndyuka": 0x33, - "nedis": 0x34, - "newfound": 0x35, - "nicard": 0x36, - "njiva": 0x5d, - "nulik": 0x37, - "osojs": 0x5e, - "oxendict": 0x38, - "pahawh2": 0x39, - "pahawh3": 0x3a, - "pahawh4": 0x3b, - "pamaka": 0x3c, - "peano": 0x3d, - "petr1708": 0x3e, - "pinyin": 0x3f, - "polyton": 0x40, - "provenc": 0x41, - "puter": 0x42, - "rigik": 0x43, - "rozaj": 0x44, - "rumgr": 0x45, - "scotland": 0x46, - "scouse": 0x47, - "simple": 0x68, - "solba": 0x5f, - "sotav": 0x48, - "spanglis": 0x49, - "surmiran": 0x4a, - "sursilv": 0x4b, - "sutsilv": 0x4c, - "tarask": 0x4d, - "tongyong": 0x4e, - "tunumiit": 0x4f, - "uccor": 0x50, - "ucrcor": 0x51, - "ulster": 0x52, - "unifon": 0x53, - "vaidika": 0x54, - "valencia": 0x55, - "vallader": 0x56, - "vecdruka": 0x57, - "vivaraup": 0x58, - "wadegile": 0x59, - "xsistemo": 0x5a, + "arkaika": 0xc, + "asante": 0xd, + "auvern": 0xe, + "baku1926": 0xf, + "balanka": 0x10, + "barla": 0x11, + "basiceng": 0x12, + "bauddha": 0x13, + "biscayan": 0x14, + "biske": 0x5c, + "bohoric": 0x15, + "boont": 0x16, + "bornholm": 0x17, + "cisaup": 0x18, + "colb1945": 0x19, + "cornu": 0x1a, + "creiss": 0x1b, + "dajnko": 0x1c, + "ekavsk": 0x1d, + "emodeng": 0x1e, + "fonipa": 0x64, + "fonkirsh": 0x65, + "fonnapa": 0x66, + "fonupa": 0x67, + "fonxsamp": 0x68, + "gascon": 0x1f, + "grclass": 0x20, + "grital": 0x21, + "grmistr": 0x22, + "hepburn": 0x23, + "heploc": 0x62, + "hognorsk": 0x24, + "hsistemo": 0x25, + "ijekavsk": 0x26, + "itihasa": 0x27, + "ivanchov": 0x28, + "jauer": 0x29, + "jyutping": 0x2a, + "kkcor": 0x2b, + "kociewie": 0x2c, + "kscor": 0x2d, + "laukika": 0x2e, + "lemosin": 0x2f, + "lengadoc": 0x30, + "lipaw": 0x5d, + "luna1918": 0x31, + "metelko": 0x32, + "monoton": 0x33, + "ndyuka": 0x34, + "nedis": 0x35, + "newfound": 0x36, + "nicard": 0x37, + "njiva": 0x5e, + "nulik": 0x38, + "osojs": 0x5f, + "oxendict": 0x39, + "pahawh2": 0x3a, + "pahawh3": 0x3b, + "pahawh4": 0x3c, + "pamaka": 0x3d, + "peano": 0x3e, + "petr1708": 0x3f, + "pinyin": 0x40, + "polyton": 0x41, + "provenc": 0x42, + "puter": 0x43, + "rigik": 0x44, + "rozaj": 0x45, + "rumgr": 0x46, + "scotland": 0x47, + "scouse": 0x48, + "simple": 0x69, + "solba": 0x60, + "sotav": 0x49, + "spanglis": 0x4a, + "surmiran": 0x4b, + "sursilv": 0x4c, + "sutsilv": 0x4d, + "tarask": 0x4e, + "tongyong": 0x4f, + "tunumiit": 0x50, + "uccor": 0x51, + "ucrcor": 0x52, + "ulster": 0x53, + "unifon": 0x54, + "vaidika": 0x55, + "valencia": 0x56, + "vallader": 0x57, + "vecdruka": 0x58, + "vivaraup": 0x59, + "wadegile": 0x5a, + "xsistemo": 0x5b, } // variantNumSpecialized is the number of specialized variants in variants. -const variantNumSpecialized = 98 +const variantNumSpecialized = 99 // nRegionGroups is the number of region groups. const nRegionGroups = 33 @@ -1390,8 +1398,8 @@ type likelyLangRegion struct { // likelyScript is a lookup table, indexed by scriptID, for the most likely // languages and regions given a script. -// Size: 1012 bytes, 253 elements -var likelyScript = [253]likelyLangRegion{ +// Size: 1040 bytes, 260 elements +var likelyScript = [260]likelyLangRegion{ 1: {lang: 0x14e, region: 0x84}, 3: {lang: 0x2a2, region: 0x106}, 4: {lang: 0x1f, region: 0x99}, @@ -1489,57 +1497,57 @@ var likelyScript = [253]likelyLangRegion{ 129: {lang: 0x395, region: 0x99}, 130: {lang: 0x399, region: 0x135}, 131: {lang: 0x429, region: 0x115}, - 132: {lang: 0x3b, region: 0x11c}, - 133: {lang: 0xfd, region: 0xc4}, - 134: {lang: 0x27d, region: 0x106}, - 135: {lang: 0x2c9, region: 0x53}, - 136: {lang: 0x39f, region: 0x9c}, - 137: {lang: 0x39f, region: 0x53}, - 139: {lang: 0x3ad, region: 0xb0}, - 141: {lang: 0x1c6, region: 0x53}, - 142: {lang: 0x4fd, region: 0x9c}, - 193: {lang: 0x3cb, region: 0x95}, - 196: {lang: 0x372, region: 0x10c}, - 197: {lang: 0x420, region: 0x97}, - 199: {lang: 0x4ff, region: 0x15e}, - 200: {lang: 0x3f0, region: 0x99}, - 201: {lang: 0x45, region: 0x135}, - 202: {lang: 0x139, region: 0x7b}, - 203: {lang: 0x3e9, region: 0x99}, - 205: {lang: 0x3e9, region: 0x99}, - 206: {lang: 0x3fa, region: 0x99}, - 207: {lang: 0x40c, region: 0xb3}, - 210: {lang: 0x433, region: 0x99}, - 211: {lang: 0xef, region: 0xc5}, - 212: {lang: 0x43e, region: 0x95}, - 213: {lang: 0x44d, region: 0x35}, - 214: {lang: 0x44e, region: 0x9b}, - 218: {lang: 0x45a, region: 0xe7}, - 219: {lang: 0x11a, region: 0x99}, - 220: {lang: 0x45e, region: 0x53}, - 221: {lang: 0x232, region: 0x53}, - 222: {lang: 0x450, region: 0x99}, - 223: {lang: 0x4a5, region: 0x53}, - 224: {lang: 0x9f, region: 0x13e}, - 225: {lang: 0x461, region: 0x99}, - 227: {lang: 0x528, region: 0xba}, - 228: {lang: 0x153, region: 0xe7}, - 229: {lang: 0x128, region: 0xcd}, - 230: {lang: 0x46b, region: 0x123}, - 231: {lang: 0xa9, region: 0x53}, - 232: {lang: 0x2ce, region: 0x99}, - 234: {lang: 0x4ad, region: 0x11c}, - 235: {lang: 0x4be, region: 0xb4}, - 237: {lang: 0x1ce, region: 0x99}, - 240: {lang: 0x3a9, region: 0x9c}, - 241: {lang: 0x22, region: 0x9b}, - 243: {lang: 0x1ea, region: 0x53}, - 244: {lang: 0xef, region: 0xc5}, + 133: {lang: 0x3b, region: 0x11c}, + 134: {lang: 0xfd, region: 0xc4}, + 137: {lang: 0x27d, region: 0x106}, + 138: {lang: 0x2c9, region: 0x53}, + 139: {lang: 0x39f, region: 0x9c}, + 140: {lang: 0x39f, region: 0x53}, + 142: {lang: 0x3ad, region: 0xb0}, + 144: {lang: 0x1c6, region: 0x53}, + 145: {lang: 0x4fd, region: 0x9c}, + 198: {lang: 0x3cb, region: 0x95}, + 201: {lang: 0x372, region: 0x10c}, + 202: {lang: 0x420, region: 0x97}, + 204: {lang: 0x4ff, region: 0x15e}, + 205: {lang: 0x3f0, region: 0x99}, + 206: {lang: 0x45, region: 0x135}, + 207: {lang: 0x139, region: 0x7b}, + 208: {lang: 0x3e9, region: 0x99}, + 210: {lang: 0x3e9, region: 0x99}, + 211: {lang: 0x3fa, region: 0x99}, + 212: {lang: 0x40c, region: 0xb3}, + 215: {lang: 0x433, region: 0x99}, + 216: {lang: 0xef, region: 0xc5}, + 217: {lang: 0x43e, region: 0x95}, + 218: {lang: 0x44d, region: 0x35}, + 219: {lang: 0x44e, region: 0x9b}, + 223: {lang: 0x45a, region: 0xe7}, + 224: {lang: 0x11a, region: 0x99}, + 225: {lang: 0x45e, region: 0x53}, + 226: {lang: 0x232, region: 0x53}, + 227: {lang: 0x450, region: 0x99}, + 228: {lang: 0x4a5, region: 0x53}, + 229: {lang: 0x9f, region: 0x13e}, + 230: {lang: 0x461, region: 0x99}, + 232: {lang: 0x528, region: 0xba}, + 233: {lang: 0x153, region: 0xe7}, + 234: {lang: 0x128, region: 0xcd}, + 235: {lang: 0x46b, region: 0x123}, + 236: {lang: 0xa9, region: 0x53}, + 237: {lang: 0x2ce, region: 0x99}, + 240: {lang: 0x4ad, region: 0x11c}, + 241: {lang: 0x4be, region: 0xb4}, + 244: {lang: 0x1ce, region: 0x99}, + 247: {lang: 0x3a9, region: 0x9c}, + 248: {lang: 0x22, region: 0x9b}, + 250: {lang: 0x1ea, region: 0x53}, + 251: {lang: 0xef, region: 0xc5}, } type likelyScriptRegion struct { region uint16 - script uint8 + script uint16 flags uint8 } @@ -1547,7 +1555,7 @@ type likelyScriptRegion struct { // scripts and regions given incomplete information. If more entries exist for a // given language, region and script are the index and size respectively // of the list in likelyLangList. -// Size: 5320 bytes, 1330 elements +// Size: 7980 bytes, 1330 elements var likelyLang = [1330]likelyScriptRegion{ 0: {region: 0x135, script: 0x5a, flags: 0x0}, 1: {region: 0x6f, script: 0x5a, flags: 0x0}, @@ -1583,7 +1591,7 @@ var likelyLang = [1330]likelyScriptRegion{ 31: {region: 0x99, script: 0x4, flags: 0x0}, 32: {region: 0x165, script: 0x5a, flags: 0x0}, 33: {region: 0x80, script: 0x5a, flags: 0x0}, - 34: {region: 0x9b, script: 0xf1, flags: 0x0}, + 34: {region: 0x9b, script: 0xf8, flags: 0x0}, 35: {region: 0x165, script: 0x5a, flags: 0x0}, 36: {region: 0x165, script: 0x5a, flags: 0x0}, 37: {region: 0x14d, script: 0x5a, flags: 0x0}, @@ -1616,7 +1624,7 @@ var likelyLang = [1330]likelyScriptRegion{ 66: {region: 0x6b, script: 0x5, flags: 0x0}, 67: {region: 0x99, script: 0xe, flags: 0x0}, 68: {region: 0x12f, script: 0x5a, flags: 0x0}, - 69: {region: 0x135, script: 0xc9, flags: 0x0}, + 69: {region: 0x135, script: 0xce, flags: 0x0}, 70: {region: 0x165, script: 0x5a, flags: 0x0}, 71: {region: 0x165, script: 0x5a, flags: 0x0}, 72: {region: 0x6e, script: 0x5a, flags: 0x0}, @@ -1670,7 +1678,7 @@ var likelyLang = [1330]likelyScriptRegion{ 120: {region: 0x165, script: 0x5a, flags: 0x0}, 121: {region: 0x12f, script: 0x5a, flags: 0x0}, 122: {region: 0x52, script: 0x5a, flags: 0x0}, - 123: {region: 0x99, script: 0xde, flags: 0x0}, + 123: {region: 0x99, script: 0xe3, flags: 0x0}, 124: {region: 0xe8, script: 0x5, flags: 0x0}, 125: {region: 0x99, script: 0x22, flags: 0x0}, 126: {region: 0x38, script: 0x20, flags: 0x0}, @@ -1705,7 +1713,7 @@ var likelyLang = [1330]likelyScriptRegion{ 156: {region: 0x165, script: 0x5a, flags: 0x0}, 157: {region: 0xe7, script: 0x5a, flags: 0x0}, 158: {region: 0x165, script: 0x5a, flags: 0x0}, - 159: {region: 0x13e, script: 0xe0, flags: 0x0}, + 159: {region: 0x13e, script: 0xe5, flags: 0x0}, 160: {region: 0xc3, script: 0x5a, flags: 0x0}, 161: {region: 0x165, script: 0x5a, flags: 0x0}, 162: {region: 0x165, script: 0x5a, flags: 0x0}, @@ -1715,7 +1723,7 @@ var likelyLang = [1330]likelyScriptRegion{ 166: {region: 0x165, script: 0x5a, flags: 0x0}, 167: {region: 0x165, script: 0x5a, flags: 0x0}, 168: {region: 0x165, script: 0x5a, flags: 0x0}, - 169: {region: 0x53, script: 0xe7, flags: 0x0}, + 169: {region: 0x53, script: 0xec, flags: 0x0}, 170: {region: 0x165, script: 0x5a, flags: 0x0}, 171: {region: 0x165, script: 0x5a, flags: 0x0}, 172: {region: 0x165, script: 0x5a, flags: 0x0}, @@ -1785,7 +1793,7 @@ var likelyLang = [1330]likelyScriptRegion{ 236: {region: 0x165, script: 0x5a, flags: 0x0}, 237: {region: 0x165, script: 0x5a, flags: 0x0}, 238: {region: 0x165, script: 0x5a, flags: 0x0}, - 239: {region: 0xc5, script: 0xd3, flags: 0x0}, + 239: {region: 0xc5, script: 0xd8, flags: 0x0}, 240: {region: 0x78, script: 0x5a, flags: 0x0}, 241: {region: 0x6b, script: 0x1d, flags: 0x0}, 242: {region: 0xe7, script: 0x5a, flags: 0x0}, @@ -1799,7 +1807,7 @@ var likelyLang = [1330]likelyScriptRegion{ 250: {region: 0x5e, script: 0x5a, flags: 0x0}, 251: {region: 0xe9, script: 0x5a, flags: 0x0}, 252: {region: 0x49, script: 0x17, flags: 0x0}, - 253: {region: 0xc4, script: 0x85, flags: 0x0}, + 253: {region: 0xc4, script: 0x86, flags: 0x0}, 254: {region: 0x8, script: 0x2, flags: 0x1}, 255: {region: 0x106, script: 0x20, flags: 0x0}, 256: {region: 0x7b, script: 0x5a, flags: 0x0}, @@ -1842,12 +1850,12 @@ var likelyLang = [1330]likelyScriptRegion{ 293: {region: 0x165, script: 0x5a, flags: 0x0}, 294: {region: 0x165, script: 0x5a, flags: 0x0}, 295: {region: 0x165, script: 0x5a, flags: 0x0}, - 296: {region: 0xcd, script: 0xe5, flags: 0x0}, + 296: {region: 0xcd, script: 0xea, flags: 0x0}, 297: {region: 0x165, script: 0x5a, flags: 0x0}, 298: {region: 0x165, script: 0x5a, flags: 0x0}, 299: {region: 0x114, script: 0x5a, flags: 0x0}, 300: {region: 0x37, script: 0x5a, flags: 0x0}, - 301: {region: 0x43, script: 0xe7, flags: 0x0}, + 301: {region: 0x43, script: 0xec, flags: 0x0}, 302: {region: 0x165, script: 0x5a, flags: 0x0}, 303: {region: 0xa4, script: 0x5a, flags: 0x0}, 304: {region: 0x80, script: 0x5a, flags: 0x0}, @@ -1957,7 +1965,7 @@ var likelyLang = [1330]likelyScriptRegion{ 408: {region: 0x165, script: 0x2c, flags: 0x0}, 409: {region: 0x165, script: 0x5a, flags: 0x0}, 410: {region: 0x99, script: 0x22, flags: 0x0}, - 411: {region: 0x99, script: 0xe1, flags: 0x0}, + 411: {region: 0x99, script: 0xe6, flags: 0x0}, 412: {region: 0x95, script: 0x5a, flags: 0x0}, 413: {region: 0xd9, script: 0x5a, flags: 0x0}, 414: {region: 0x130, script: 0x32, flags: 0x0}, @@ -2000,7 +2008,7 @@ var likelyLang = [1330]likelyScriptRegion{ 451: {region: 0xe7, script: 0x5a, flags: 0x0}, 452: {region: 0x165, script: 0x5a, flags: 0x0}, 453: {region: 0x12b, script: 0x40, flags: 0x0}, - 454: {region: 0x53, script: 0x8d, flags: 0x0}, + 454: {region: 0x53, script: 0x90, flags: 0x0}, 455: {region: 0x165, script: 0x5a, flags: 0x0}, 456: {region: 0xe8, script: 0x5, flags: 0x0}, 457: {region: 0x99, script: 0x22, flags: 0x0}, @@ -2035,7 +2043,7 @@ var likelyLang = [1330]likelyScriptRegion{ 487: {region: 0xd6, script: 0x5a, flags: 0x0}, 488: {region: 0x165, script: 0x5a, flags: 0x0}, 489: {region: 0x165, script: 0x5a, flags: 0x0}, - 490: {region: 0x53, script: 0xf3, flags: 0x0}, + 490: {region: 0x53, script: 0xfa, flags: 0x0}, 491: {region: 0x165, script: 0x5a, flags: 0x0}, 492: {region: 0x135, script: 0x5a, flags: 0x0}, 493: {region: 0x165, script: 0x5a, flags: 0x0}, @@ -2095,7 +2103,7 @@ var likelyLang = [1330]likelyScriptRegion{ 547: {region: 0x12f, script: 0x5a, flags: 0x0}, 548: {region: 0x122, script: 0x5, flags: 0x0}, 549: {region: 0x165, script: 0x5a, flags: 0x0}, - 550: {region: 0x123, script: 0xe6, flags: 0x0}, + 550: {region: 0x123, script: 0xeb, flags: 0x0}, 551: {region: 0x5a, script: 0x5a, flags: 0x0}, 552: {region: 0x52, script: 0x5a, flags: 0x0}, 553: {region: 0x165, script: 0x5a, flags: 0x0}, @@ -2107,7 +2115,7 @@ var likelyLang = [1330]likelyScriptRegion{ 559: {region: 0x165, script: 0x5a, flags: 0x0}, 560: {region: 0x41, script: 0x5a, flags: 0x0}, 561: {region: 0x99, script: 0x5a, flags: 0x0}, - 562: {region: 0x53, script: 0xdd, flags: 0x0}, + 562: {region: 0x53, script: 0xe2, flags: 0x0}, 563: {region: 0x99, script: 0x22, flags: 0x0}, 564: {region: 0xc3, script: 0x5a, flags: 0x0}, 565: {region: 0x165, script: 0x5a, flags: 0x0}, @@ -2191,7 +2199,7 @@ var likelyLang = [1330]likelyScriptRegion{ 643: {region: 0x165, script: 0x5a, flags: 0x0}, 644: {region: 0x165, script: 0x5a, flags: 0x0}, 645: {region: 0x165, script: 0x2c, flags: 0x0}, - 646: {region: 0x123, script: 0xe6, flags: 0x0}, + 646: {region: 0x123, script: 0xeb, flags: 0x0}, 647: {region: 0xe8, script: 0x5, flags: 0x0}, 648: {region: 0x165, script: 0x5a, flags: 0x0}, 649: {region: 0x165, script: 0x5a, flags: 0x0}, @@ -2211,7 +2219,7 @@ var likelyLang = [1330]likelyScriptRegion{ 663: {region: 0x165, script: 0x5a, flags: 0x0}, 664: {region: 0x95, script: 0x5a, flags: 0x0}, 665: {region: 0x165, script: 0x5a, flags: 0x0}, - 666: {region: 0x53, script: 0xe6, flags: 0x0}, + 666: {region: 0x53, script: 0xeb, flags: 0x0}, 667: {region: 0x165, script: 0x5a, flags: 0x0}, 668: {region: 0x165, script: 0x5a, flags: 0x0}, 669: {region: 0x165, script: 0x5a, flags: 0x0}, @@ -2235,7 +2243,7 @@ var likelyLang = [1330]likelyScriptRegion{ 687: {region: 0x135, script: 0x5a, flags: 0x0}, 688: {region: 0x165, script: 0x5a, flags: 0x0}, 689: {region: 0x165, script: 0x5a, flags: 0x0}, - 690: {region: 0x99, script: 0xe1, flags: 0x0}, + 690: {region: 0x99, script: 0xe6, flags: 0x0}, 691: {region: 0x9e, script: 0x5a, flags: 0x0}, 692: {region: 0x165, script: 0x5a, flags: 0x0}, 693: {region: 0x4b, script: 0x5a, flags: 0x0}, @@ -2257,7 +2265,7 @@ var likelyLang = [1330]likelyScriptRegion{ 709: {region: 0xa4, script: 0x5a, flags: 0x0}, 710: {region: 0x9c, script: 0x5, flags: 0x0}, 711: {region: 0xb8, script: 0x5a, flags: 0x0}, - 712: {region: 0x123, script: 0xe6, flags: 0x0}, + 712: {region: 0x123, script: 0xeb, flags: 0x0}, 713: {region: 0x53, script: 0x3b, flags: 0x0}, 714: {region: 0x12b, script: 0x5a, flags: 0x0}, 715: {region: 0x95, script: 0x5a, flags: 0x0}, @@ -2424,7 +2432,7 @@ var likelyLang = [1330]likelyScriptRegion{ 879: {region: 0xda, script: 0x5a, flags: 0x0}, 880: {region: 0x123, script: 0x56, flags: 0x0}, 881: {region: 0x99, script: 0x22, flags: 0x0}, - 882: {region: 0x10c, script: 0xc4, flags: 0x0}, + 882: {region: 0x10c, script: 0xc9, flags: 0x0}, 883: {region: 0x165, script: 0x5a, flags: 0x0}, 884: {region: 0x165, script: 0x5a, flags: 0x0}, 885: {region: 0x84, script: 0x7c, flags: 0x0}, @@ -2478,11 +2486,11 @@ var likelyLang = [1330]likelyScriptRegion{ 934: {region: 0x135, script: 0x5a, flags: 0x0}, 935: {region: 0x49, script: 0x5a, flags: 0x0}, 936: {region: 0x165, script: 0x5a, flags: 0x0}, - 937: {region: 0x9c, script: 0xf0, flags: 0x0}, + 937: {region: 0x9c, script: 0xf7, flags: 0x0}, 938: {region: 0x165, script: 0x5a, flags: 0x0}, 939: {region: 0x60, script: 0x5a, flags: 0x0}, 940: {region: 0x165, script: 0x5, flags: 0x0}, - 941: {region: 0xb0, script: 0x8b, flags: 0x0}, + 941: {region: 0xb0, script: 0x8e, flags: 0x0}, 943: {region: 0x165, script: 0x5a, flags: 0x0}, 944: {region: 0x165, script: 0x5a, flags: 0x0}, 945: {region: 0x99, script: 0x12, flags: 0x0}, @@ -2548,7 +2556,7 @@ var likelyLang = [1330]likelyScriptRegion{ 1005: {region: 0x95, script: 0x5a, flags: 0x0}, 1006: {region: 0x99, script: 0x5a, flags: 0x0}, 1007: {region: 0x114, script: 0x5a, flags: 0x0}, - 1008: {region: 0x99, script: 0xc8, flags: 0x0}, + 1008: {region: 0x99, script: 0xcd, flags: 0x0}, 1009: {region: 0x165, script: 0x5a, flags: 0x0}, 1010: {region: 0x165, script: 0x5a, flags: 0x0}, 1011: {region: 0x12f, script: 0x5a, flags: 0x0}, @@ -2571,11 +2579,11 @@ var likelyLang = [1330]likelyScriptRegion{ 1028: {region: 0xb6, script: 0x5a, flags: 0x0}, 1029: {region: 0x165, script: 0x2c, flags: 0x0}, 1030: {region: 0x165, script: 0x5a, flags: 0x0}, - 1032: {region: 0xba, script: 0xe3, flags: 0x0}, + 1032: {region: 0xba, script: 0xe8, flags: 0x0}, 1033: {region: 0x165, script: 0x5a, flags: 0x0}, 1034: {region: 0xc4, script: 0x75, flags: 0x0}, 1035: {region: 0x165, script: 0x5, flags: 0x0}, - 1036: {region: 0xb3, script: 0xcf, flags: 0x0}, + 1036: {region: 0xb3, script: 0xd4, flags: 0x0}, 1037: {region: 0x6f, script: 0x5a, flags: 0x0}, 1038: {region: 0x165, script: 0x5a, flags: 0x0}, 1039: {region: 0x165, script: 0x5a, flags: 0x0}, @@ -2594,7 +2602,7 @@ var likelyLang = [1330]likelyScriptRegion{ 1052: {region: 0x10c, script: 0x5a, flags: 0x0}, 1054: {region: 0x10c, script: 0x5a, flags: 0x0}, 1055: {region: 0x72, script: 0x5a, flags: 0x0}, - 1056: {region: 0x97, script: 0xc5, flags: 0x0}, + 1056: {region: 0x97, script: 0xca, flags: 0x0}, 1057: {region: 0x165, script: 0x5a, flags: 0x0}, 1058: {region: 0x72, script: 0x5a, flags: 0x0}, 1059: {region: 0x164, script: 0x5a, flags: 0x0}, @@ -2606,14 +2614,14 @@ var likelyLang = [1330]likelyScriptRegion{ 1065: {region: 0x115, script: 0x5a, flags: 0x0}, 1066: {region: 0x165, script: 0x5a, flags: 0x0}, 1067: {region: 0x165, script: 0x5a, flags: 0x0}, - 1068: {region: 0x123, script: 0xe6, flags: 0x0}, + 1068: {region: 0x123, script: 0xeb, flags: 0x0}, 1069: {region: 0x165, script: 0x5a, flags: 0x0}, 1070: {region: 0x165, script: 0x5a, flags: 0x0}, 1071: {region: 0x165, script: 0x5a, flags: 0x0}, 1072: {region: 0x165, script: 0x5a, flags: 0x0}, 1073: {region: 0x27, script: 0x5a, flags: 0x0}, 1074: {region: 0x37, script: 0x5, flags: 0x1}, - 1075: {region: 0x99, script: 0xd2, flags: 0x0}, + 1075: {region: 0x99, script: 0xd7, flags: 0x0}, 1076: {region: 0x116, script: 0x5a, flags: 0x0}, 1077: {region: 0x114, script: 0x5a, flags: 0x0}, 1078: {region: 0x99, script: 0x22, flags: 0x0}, @@ -2640,9 +2648,9 @@ var likelyLang = [1330]likelyScriptRegion{ 1099: {region: 0x95, script: 0x5a, flags: 0x0}, 1100: {region: 0x165, script: 0x5a, flags: 0x0}, 1101: {region: 0x35, script: 0xe, flags: 0x0}, - 1102: {region: 0x9b, script: 0xd6, flags: 0x0}, + 1102: {region: 0x9b, script: 0xdb, flags: 0x0}, 1103: {region: 0xe9, script: 0x5a, flags: 0x0}, - 1104: {region: 0x99, script: 0xde, flags: 0x0}, + 1104: {region: 0x99, script: 0xe3, flags: 0x0}, 1105: {region: 0xdb, script: 0x22, flags: 0x0}, 1106: {region: 0x165, script: 0x5a, flags: 0x0}, 1107: {region: 0x165, script: 0x5a, flags: 0x0}, @@ -2656,10 +2664,10 @@ var likelyLang = [1330]likelyScriptRegion{ 1115: {region: 0x165, script: 0x5a, flags: 0x0}, 1116: {region: 0x165, script: 0x5a, flags: 0x0}, 1117: {region: 0x99, script: 0x52, flags: 0x0}, - 1118: {region: 0x53, script: 0xdc, flags: 0x0}, + 1118: {region: 0x53, script: 0xe1, flags: 0x0}, 1119: {region: 0xdb, script: 0x22, flags: 0x0}, 1120: {region: 0xdb, script: 0x22, flags: 0x0}, - 1121: {region: 0x99, script: 0xe1, flags: 0x0}, + 1121: {region: 0x99, script: 0xe6, flags: 0x0}, 1122: {region: 0x165, script: 0x5a, flags: 0x0}, 1123: {region: 0x112, script: 0x5a, flags: 0x0}, 1124: {region: 0x131, script: 0x5a, flags: 0x0}, @@ -2669,7 +2677,7 @@ var likelyLang = [1330]likelyScriptRegion{ 1128: {region: 0x165, script: 0x5a, flags: 0x0}, 1129: {region: 0x165, script: 0x5a, flags: 0x0}, 1130: {region: 0x165, script: 0x5a, flags: 0x0}, - 1131: {region: 0x123, script: 0xe6, flags: 0x0}, + 1131: {region: 0x123, script: 0xeb, flags: 0x0}, 1132: {region: 0xdb, script: 0x22, flags: 0x0}, 1133: {region: 0xdb, script: 0x22, flags: 0x0}, 1134: {region: 0xdb, script: 0x22, flags: 0x0}, @@ -2708,14 +2716,14 @@ var likelyLang = [1330]likelyScriptRegion{ 1167: {region: 0x87, script: 0x34, flags: 0x0}, 1168: {region: 0xdb, script: 0x22, flags: 0x0}, 1169: {region: 0xe7, script: 0x5a, flags: 0x0}, - 1170: {region: 0x43, script: 0xe7, flags: 0x0}, + 1170: {region: 0x43, script: 0xec, flags: 0x0}, 1171: {region: 0x165, script: 0x5a, flags: 0x0}, 1172: {region: 0x106, script: 0x20, flags: 0x0}, 1173: {region: 0x165, script: 0x5a, flags: 0x0}, 1174: {region: 0x165, script: 0x5a, flags: 0x0}, 1175: {region: 0x131, script: 0x5a, flags: 0x0}, 1176: {region: 0x165, script: 0x5a, flags: 0x0}, - 1177: {region: 0x123, script: 0xe6, flags: 0x0}, + 1177: {region: 0x123, script: 0xeb, flags: 0x0}, 1178: {region: 0x32, script: 0x5a, flags: 0x0}, 1179: {region: 0x165, script: 0x5a, flags: 0x0}, 1180: {region: 0x165, script: 0x5a, flags: 0x0}, @@ -2726,7 +2734,7 @@ var likelyLang = [1330]likelyScriptRegion{ 1185: {region: 0x165, script: 0x5a, flags: 0x0}, 1187: {region: 0x165, script: 0x5a, flags: 0x0}, 1188: {region: 0xd4, script: 0x5a, flags: 0x0}, - 1189: {region: 0x53, script: 0xdf, flags: 0x0}, + 1189: {region: 0x53, script: 0xe4, flags: 0x0}, 1190: {region: 0xe5, script: 0x5a, flags: 0x0}, 1191: {region: 0x165, script: 0x5a, flags: 0x0}, 1192: {region: 0x106, script: 0x20, flags: 0x0}, @@ -2734,7 +2742,7 @@ var likelyLang = [1330]likelyScriptRegion{ 1194: {region: 0x165, script: 0x5a, flags: 0x0}, 1195: {region: 0x106, script: 0x20, flags: 0x0}, 1196: {region: 0x3f, script: 0x4, flags: 0x1}, - 1197: {region: 0x11c, script: 0xea, flags: 0x0}, + 1197: {region: 0x11c, script: 0xf0, flags: 0x0}, 1198: {region: 0x130, script: 0x20, flags: 0x0}, 1199: {region: 0x75, script: 0x5a, flags: 0x0}, 1200: {region: 0x2a, script: 0x5a, flags: 0x0}, @@ -2750,7 +2758,7 @@ var likelyLang = [1330]likelyScriptRegion{ 1211: {region: 0x165, script: 0x5a, flags: 0x0}, 1212: {region: 0x46, script: 0x4, flags: 0x1}, 1213: {region: 0x165, script: 0x5a, flags: 0x0}, - 1214: {region: 0xb4, script: 0xeb, flags: 0x0}, + 1214: {region: 0xb4, script: 0xf1, flags: 0x0}, 1215: {region: 0x165, script: 0x5a, flags: 0x0}, 1216: {region: 0x161, script: 0x5a, flags: 0x0}, 1217: {region: 0x9e, script: 0x5a, flags: 0x0}, @@ -2773,7 +2781,7 @@ var likelyLang = [1330]likelyScriptRegion{ 1234: {region: 0x165, script: 0x5a, flags: 0x0}, 1235: {region: 0xe7, script: 0x5a, flags: 0x0}, 1236: {region: 0x2f, script: 0x5a, flags: 0x0}, - 1237: {region: 0x99, script: 0xe1, flags: 0x0}, + 1237: {region: 0x99, script: 0xe6, flags: 0x0}, 1238: {region: 0x99, script: 0x22, flags: 0x0}, 1239: {region: 0x165, script: 0x5a, flags: 0x0}, 1240: {region: 0x165, script: 0x5a, flags: 0x0}, @@ -2813,9 +2821,9 @@ var likelyLang = [1330]likelyScriptRegion{ 1274: {region: 0x99, script: 0x22, flags: 0x0}, 1275: {region: 0x131, script: 0x5a, flags: 0x0}, 1276: {region: 0x165, script: 0x5a, flags: 0x0}, - 1277: {region: 0x9c, script: 0x8e, flags: 0x0}, + 1277: {region: 0x9c, script: 0x91, flags: 0x0}, 1278: {region: 0x165, script: 0x5a, flags: 0x0}, - 1279: {region: 0x15e, script: 0xc7, flags: 0x0}, + 1279: {region: 0x15e, script: 0xcc, flags: 0x0}, 1280: {region: 0x165, script: 0x5a, flags: 0x0}, 1281: {region: 0x165, script: 0x5a, flags: 0x0}, 1282: {region: 0xdb, script: 0x22, flags: 0x0}, @@ -2855,7 +2863,7 @@ var likelyLang = [1330]likelyScriptRegion{ 1316: {region: 0x10b, script: 0x5a, flags: 0x0}, 1318: {region: 0xa8, script: 0x5, flags: 0x0}, 1319: {region: 0xd9, script: 0x5a, flags: 0x0}, - 1320: {region: 0xba, script: 0xe3, flags: 0x0}, + 1320: {region: 0xba, script: 0xe8, flags: 0x0}, 1321: {region: 0x4d, script: 0x14, flags: 0x1}, 1322: {region: 0x53, script: 0x7d, flags: 0x0}, 1323: {region: 0x165, script: 0x5a, flags: 0x0}, @@ -2867,11 +2875,11 @@ var likelyLang = [1330]likelyScriptRegion{ } // likelyLangList holds lists info associated with likelyLang. -// Size: 388 bytes, 97 elements +// Size: 582 bytes, 97 elements var likelyLangList = [97]likelyScriptRegion{ 0: {region: 0x9c, script: 0x7, flags: 0x0}, 1: {region: 0xa1, script: 0x78, flags: 0x2}, - 2: {region: 0x11c, script: 0x84, flags: 0x2}, + 2: {region: 0x11c, script: 0x85, flags: 0x2}, 3: {region: 0x32, script: 0x5a, flags: 0x0}, 4: {region: 0x9b, script: 0x5, flags: 0x4}, 5: {region: 0x9c, script: 0x5, flags: 0x4}, @@ -2880,7 +2888,7 @@ var likelyLangList = [97]likelyScriptRegion{ 8: {region: 0x106, script: 0x20, flags: 0x0}, 9: {region: 0x38, script: 0x2f, flags: 0x2}, 10: {region: 0x135, script: 0x5a, flags: 0x0}, - 11: {region: 0x7b, script: 0xca, flags: 0x2}, + 11: {region: 0x7b, script: 0xcf, flags: 0x2}, 12: {region: 0x114, script: 0x5a, flags: 0x0}, 13: {region: 0x84, script: 0x1, flags: 0x2}, 14: {region: 0x5d, script: 0x1f, flags: 0x0}, @@ -2916,14 +2924,14 @@ var likelyLangList = [97]likelyScriptRegion{ 44: {region: 0x99, script: 0x36, flags: 0x0}, 45: {region: 0xe8, script: 0x5, flags: 0x4}, 46: {region: 0xe8, script: 0x5, flags: 0x2}, - 47: {region: 0x9c, script: 0x88, flags: 0x0}, - 48: {region: 0x53, script: 0x89, flags: 0x2}, - 49: {region: 0xba, script: 0xe3, flags: 0x0}, + 47: {region: 0x9c, script: 0x8b, flags: 0x0}, + 48: {region: 0x53, script: 0x8c, flags: 0x2}, + 49: {region: 0xba, script: 0xe8, flags: 0x0}, 50: {region: 0xd9, script: 0x5a, flags: 0x4}, 51: {region: 0xe8, script: 0x5, flags: 0x0}, 52: {region: 0x99, script: 0x22, flags: 0x2}, 53: {region: 0x99, script: 0x4f, flags: 0x2}, - 54: {region: 0x99, script: 0xce, flags: 0x2}, + 54: {region: 0x99, script: 0xd3, flags: 0x2}, 55: {region: 0x105, script: 0x20, flags: 0x0}, 56: {region: 0xbd, script: 0x5a, flags: 0x4}, 57: {region: 0x104, script: 0x5a, flags: 0x4}, @@ -2970,7 +2978,7 @@ var likelyLangList = [97]likelyScriptRegion{ type likelyLangScript struct { lang uint16 - script uint8 + script uint16 flags uint8 } @@ -2979,7 +2987,7 @@ type likelyLangScript struct { // for a given regionID, lang and script are the index and size respectively // of the list in likelyRegionList. // TODO: exclude containers and user-definable regions from the list. -// Size: 1432 bytes, 358 elements +// Size: 2148 bytes, 358 elements var likelyRegion = [358]likelyLangScript{ 34: {lang: 0xd7, script: 0x5a, flags: 0x0}, 35: {lang: 0x3a, script: 0x5, flags: 0x0}, @@ -3086,7 +3094,7 @@ var likelyRegion = [358]likelyLangScript{ 175: {lang: 0x27, script: 0x2, flags: 0x1}, 176: {lang: 0x3a, script: 0x5, flags: 0x0}, 178: {lang: 0x10d, script: 0x5a, flags: 0x0}, - 179: {lang: 0x40c, script: 0xcf, flags: 0x0}, + 179: {lang: 0x40c, script: 0xd4, flags: 0x0}, 181: {lang: 0x43b, script: 0x5a, flags: 0x0}, 182: {lang: 0x2c0, script: 0x5a, flags: 0x0}, 183: {lang: 0x15e, script: 0x5a, flags: 0x0}, @@ -3107,7 +3115,7 @@ var likelyRegion = [358]likelyLangScript{ 201: {lang: 0x35, script: 0x2, flags: 0x1}, 203: {lang: 0x320, script: 0x5a, flags: 0x0}, 204: {lang: 0x37, script: 0x3, flags: 0x1}, - 205: {lang: 0x128, script: 0xe5, flags: 0x0}, + 205: {lang: 0x128, script: 0xea, flags: 0x0}, 207: {lang: 0x13e, script: 0x5a, flags: 0x0}, 208: {lang: 0x31f, script: 0x5a, flags: 0x0}, 209: {lang: 0x3c0, script: 0x5a, flags: 0x0}, @@ -3185,7 +3193,7 @@ var likelyRegion = [358]likelyLangScript{ } // likelyRegionList holds lists info associated with likelyRegion. -// Size: 372 bytes, 93 elements +// Size: 558 bytes, 93 elements var likelyRegionList = [93]likelyLangScript{ 0: {lang: 0x148, script: 0x5, flags: 0x0}, 1: {lang: 0x476, script: 0x5a, flags: 0x0}, @@ -3195,12 +3203,12 @@ var likelyRegionList = [93]likelyLangScript{ 5: {lang: 0x274, script: 0x5a, flags: 0x0}, 6: {lang: 0xb7, script: 0x5a, flags: 0x0}, 7: {lang: 0x432, script: 0x20, flags: 0x0}, - 8: {lang: 0x12d, script: 0xe7, flags: 0x0}, + 8: {lang: 0x12d, script: 0xec, flags: 0x0}, 9: {lang: 0x351, script: 0x22, flags: 0x0}, 10: {lang: 0x529, script: 0x3b, flags: 0x0}, 11: {lang: 0x4ac, script: 0x5, flags: 0x0}, 12: {lang: 0x523, script: 0x5a, flags: 0x0}, - 13: {lang: 0x29a, script: 0xe6, flags: 0x0}, + 13: {lang: 0x29a, script: 0xeb, flags: 0x0}, 14: {lang: 0x136, script: 0x34, flags: 0x0}, 15: {lang: 0x48a, script: 0x5a, flags: 0x0}, 16: {lang: 0x3a, script: 0x5, flags: 0x0}, @@ -3223,11 +3231,11 @@ var likelyRegionList = [93]likelyLangScript{ 33: {lang: 0x476, script: 0x5a, flags: 0x0}, 34: {lang: 0x24a, script: 0x4e, flags: 0x0}, 35: {lang: 0xe6, script: 0x5, flags: 0x0}, - 36: {lang: 0x226, script: 0xe6, flags: 0x0}, + 36: {lang: 0x226, script: 0xeb, flags: 0x0}, 37: {lang: 0x3a, script: 0x5, flags: 0x0}, 38: {lang: 0x15e, script: 0x5a, flags: 0x0}, 39: {lang: 0x2b8, script: 0x57, flags: 0x0}, - 40: {lang: 0x226, script: 0xe6, flags: 0x0}, + 40: {lang: 0x226, script: 0xeb, flags: 0x0}, 41: {lang: 0x3a, script: 0x5, flags: 0x0}, 42: {lang: 0x15e, script: 0x5a, flags: 0x0}, 43: {lang: 0x3dc, script: 0x5a, flags: 0x0}, @@ -3260,7 +3268,7 @@ var likelyRegionList = [93]likelyLangScript{ 70: {lang: 0x15e, script: 0x5a, flags: 0x0}, 71: {lang: 0x15e, script: 0x5a, flags: 0x0}, 72: {lang: 0x35, script: 0x5, flags: 0x0}, - 73: {lang: 0x46b, script: 0xe6, flags: 0x0}, + 73: {lang: 0x46b, script: 0xeb, flags: 0x0}, 74: {lang: 0x2ec, script: 0x5, flags: 0x0}, 75: {lang: 0x30f, script: 0x75, flags: 0x0}, 76: {lang: 0x467, script: 0x20, flags: 0x0}, @@ -3285,7 +3293,7 @@ var likelyRegionList = [93]likelyLangScript{ type likelyTag struct { lang uint16 region uint16 - script uint8 + script uint16 } // Size: 198 bytes, 33 elements @@ -3446,8 +3454,8 @@ var regionInclusionNext = [73]uint8{ type parentRel struct { lang uint16 - script uint8 - maxScript uint8 + script uint16 + maxScript uint16 toRegion uint16 fromRegion []uint16 } @@ -3461,4 +3469,4 @@ var parents = [5]parentRel{ 4: {lang: 0x529, script: 0x3c, maxScript: 0x3c, toRegion: 0x8d, fromRegion: []uint16{0xc6}}, } -// Total table size 26398 bytes (25KiB); checksum: 1C859EA7 +// Total table size 30244 bytes (29KiB); checksum: B6B15F30 diff --git a/vendor/golang.org/x/text/internal/number/decimal.go b/vendor/golang.org/x/text/internal/number/decimal.go index cb656db6c1..37e0c4b988 100644 --- a/vendor/golang.org/x/text/internal/number/decimal.go +++ b/vendor/golang.org/x/text/internal/number/decimal.go @@ -33,13 +33,14 @@ const maxIntDigits = 20 // may point outside a valid position in Digits. // // Examples: -// Number Decimal -// 12345 Digits: [1, 2, 3, 4, 5], Exp: 5 -// 12.345 Digits: [1, 2, 3, 4, 5], Exp: 2 -// 12000 Digits: [1, 2], Exp: 5 -// 12000.00 Digits: [1, 2], Exp: 5 -// 0.00123 Digits: [1, 2, 3], Exp: -2 -// 0 Digits: [], Exp: 0 +// +// Number Decimal +// 12345 Digits: [1, 2, 3, 4, 5], Exp: 5 +// 12.345 Digits: [1, 2, 3, 4, 5], Exp: 2 +// 12000 Digits: [1, 2], Exp: 5 +// 12000.00 Digits: [1, 2], Exp: 5 +// 0.00123 Digits: [1, 2, 3], Exp: -2 +// 0 Digits: [], Exp: 0 type Decimal struct { digits @@ -60,22 +61,23 @@ type digits struct { // engineering notation. Digits must have at least one digit. // // Examples: -// Number Decimal -// decimal -// 12345 Digits: [1, 2, 3, 4, 5], Exp: 5 End: 5 -// 12.345 Digits: [1, 2, 3, 4, 5], Exp: 2 End: 5 -// 12000 Digits: [1, 2], Exp: 5 End: 5 -// 12000.00 Digits: [1, 2], Exp: 5 End: 7 -// 0.00123 Digits: [1, 2, 3], Exp: -2 End: 3 -// 0 Digits: [], Exp: 0 End: 1 -// scientific (actual exp is Exp - Comma) -// 0e0 Digits: [0], Exp: 1, End: 1, Comma: 1 -// .0e0 Digits: [0], Exp: 0, End: 1, Comma: 0 -// 0.0e0 Digits: [0], Exp: 1, End: 2, Comma: 1 -// 1.23e4 Digits: [1, 2, 3], Exp: 5, End: 3, Comma: 1 -// .123e5 Digits: [1, 2, 3], Exp: 5, End: 3, Comma: 0 -// engineering -// 12.3e3 Digits: [1, 2, 3], Exp: 5, End: 3, Comma: 2 +// +// Number Decimal +// decimal +// 12345 Digits: [1, 2, 3, 4, 5], Exp: 5 End: 5 +// 12.345 Digits: [1, 2, 3, 4, 5], Exp: 2 End: 5 +// 12000 Digits: [1, 2], Exp: 5 End: 5 +// 12000.00 Digits: [1, 2], Exp: 5 End: 7 +// 0.00123 Digits: [1, 2, 3], Exp: -2 End: 3 +// 0 Digits: [], Exp: 0 End: 1 +// scientific (actual exp is Exp - Comma) +// 0e0 Digits: [0], Exp: 1, End: 1, Comma: 1 +// .0e0 Digits: [0], Exp: 0, End: 1, Comma: 0 +// 0.0e0 Digits: [0], Exp: 1, End: 2, Comma: 1 +// 1.23e4 Digits: [1, 2, 3], Exp: 5, End: 3, Comma: 1 +// .123e5 Digits: [1, 2, 3], Exp: 5, End: 3, Comma: 0 +// engineering +// 12.3e3 Digits: [1, 2, 3], Exp: 5, End: 3, Comma: 2 type Digits struct { digits // End indicates the end position of the number. diff --git a/vendor/golang.org/x/text/internal/utf8internal/utf8internal.go b/vendor/golang.org/x/text/internal/utf8internal/utf8internal.go index 575cea8707..e5c53b1b3e 100644 --- a/vendor/golang.org/x/text/internal/utf8internal/utf8internal.go +++ b/vendor/golang.org/x/text/internal/utf8internal/utf8internal.go @@ -74,7 +74,7 @@ type AcceptRange struct { // AcceptRanges is a slice of AcceptRange values. For a given byte sequence b // -// AcceptRanges[First[b[0]]>>AcceptShift] +// AcceptRanges[First[b[0]]>>AcceptShift] // // will give the value of AcceptRange for the multi-byte UTF-8 sequence starting // at b[0]. diff --git a/vendor/golang.org/x/text/language/doc.go b/vendor/golang.org/x/text/language/doc.go index 8afecd50e1..212b77c906 100644 --- a/vendor/golang.org/x/text/language/doc.go +++ b/vendor/golang.org/x/text/language/doc.go @@ -10,18 +10,17 @@ // and provides the user with the best experience // (see https://blog.golang.org/matchlang). // -// -// Matching preferred against supported languages +// # Matching preferred against supported languages // // A Matcher for an application that supports English, Australian English, // Danish, and standard Mandarin can be created as follows: // -// var matcher = language.NewMatcher([]language.Tag{ -// language.English, // The first language is used as fallback. -// language.MustParse("en-AU"), -// language.Danish, -// language.Chinese, -// }) +// var matcher = language.NewMatcher([]language.Tag{ +// language.English, // The first language is used as fallback. +// language.MustParse("en-AU"), +// language.Danish, +// language.Chinese, +// }) // // This list of supported languages is typically implied by the languages for // which there exists translations of the user interface. @@ -30,14 +29,14 @@ // language tags. // The MatchString finds best matches for such strings: // -// handler(w http.ResponseWriter, r *http.Request) { -// lang, _ := r.Cookie("lang") -// accept := r.Header.Get("Accept-Language") -// tag, _ := language.MatchStrings(matcher, lang.String(), accept) +// handler(w http.ResponseWriter, r *http.Request) { +// lang, _ := r.Cookie("lang") +// accept := r.Header.Get("Accept-Language") +// tag, _ := language.MatchStrings(matcher, lang.String(), accept) // -// // tag should now be used for the initialization of any -// // locale-specific service. -// } +// // tag should now be used for the initialization of any +// // locale-specific service. +// } // // The Matcher's Match method can be used to match Tags directly. // @@ -48,8 +47,7 @@ // For instance, it will know that a reader of Bokmål Danish can read Norwegian // and will know that Cantonese ("yue") is a good match for "zh-HK". // -// -// Using match results +// # Using match results // // To guarantee a consistent user experience to the user it is important to // use the same language tag for the selection of any locale-specific services. @@ -58,9 +56,9 @@ // More subtly confusing is using the wrong sorting order or casing // algorithm for a certain language. // -// All the packages in x/text that provide locale-specific services -// (e.g. collate, cases) should be initialized with the tag that was -// obtained at the start of an interaction with the user. +// All the packages in x/text that provide locale-specific services +// (e.g. collate, cases) should be initialized with the tag that was +// obtained at the start of an interaction with the user. // // Note that Tag that is returned by Match and MatchString may differ from any // of the supported languages, as it may contain carried over settings from @@ -70,8 +68,7 @@ // Match and MatchString both return the index of the matched supported tag // to simplify associating such data with the matched tag. // -// -// Canonicalization +// # Canonicalization // // If one uses the Matcher to compare languages one does not need to // worry about canonicalization. @@ -92,10 +89,9 @@ // equivalence relations. The CanonType type can be used to alter the // canonicalization form. // -// References +// # References // // BCP 47 - Tags for Identifying Languages http://tools.ietf.org/html/bcp47 -// package language // import "golang.org/x/text/language" // TODO: explanation on how to match languages for your own locale-specific diff --git a/vendor/golang.org/x/text/language/go1_1.go b/vendor/golang.org/x/text/language/go1_1.go deleted file mode 100644 index c7435583b5..0000000000 --- a/vendor/golang.org/x/text/language/go1_1.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2013 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. - -//go:build !go1.2 -// +build !go1.2 - -package language - -import "sort" - -func sortStable(s sort.Interface) { - ss := stableSort{ - s: s, - pos: make([]int, s.Len()), - } - for i := range ss.pos { - ss.pos[i] = i - } - sort.Sort(&ss) -} - -type stableSort struct { - s sort.Interface - pos []int -} - -func (s *stableSort) Len() int { - return len(s.pos) -} - -func (s *stableSort) Less(i, j int) bool { - return s.s.Less(i, j) || !s.s.Less(j, i) && s.pos[i] < s.pos[j] -} - -func (s *stableSort) Swap(i, j int) { - s.s.Swap(i, j) - s.pos[i], s.pos[j] = s.pos[j], s.pos[i] -} diff --git a/vendor/golang.org/x/text/language/go1_2.go b/vendor/golang.org/x/text/language/go1_2.go deleted file mode 100644 index 77aaaa299e..0000000000 --- a/vendor/golang.org/x/text/language/go1_2.go +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2013 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. - -//go:build go1.2 -// +build go1.2 - -package language - -import "sort" - -var sortStable = sort.Stable diff --git a/vendor/golang.org/x/text/language/match.go b/vendor/golang.org/x/text/language/match.go index f734921349..ee45f49474 100644 --- a/vendor/golang.org/x/text/language/match.go +++ b/vendor/golang.org/x/text/language/match.go @@ -545,7 +545,7 @@ type bestMatch struct { // match as the preferred match. // // If pin is true and have and tag are a strong match, it will henceforth only -// consider matches for this language. This corresponds to the nothing that most +// consider matches for this language. This corresponds to the idea that most // users have a strong preference for the first defined language. A user can // still prefer a second language over a dialect of the preferred language by // explicitly specifying dialects, e.g. "en, nl, en-GB". In this case pin should diff --git a/vendor/golang.org/x/text/language/parse.go b/vendor/golang.org/x/text/language/parse.go index 59b0410080..4d57222e77 100644 --- a/vendor/golang.org/x/text/language/parse.go +++ b/vendor/golang.org/x/text/language/parse.go @@ -6,6 +6,7 @@ package language import ( "errors" + "sort" "strconv" "strings" @@ -147,6 +148,7 @@ func update(b *language.Builder, part ...interface{}) (err error) { } var errInvalidWeight = errors.New("ParseAcceptLanguage: invalid weight") +var errTagListTooLarge = errors.New("tag list exceeds max length") // ParseAcceptLanguage parses the contents of an Accept-Language header as // defined in http://www.ietf.org/rfc/rfc2616.txt and returns a list of Tags and @@ -164,6 +166,10 @@ func ParseAcceptLanguage(s string) (tag []Tag, q []float32, err error) { } }() + if strings.Count(s, "-") > 1000 { + return nil, nil, errTagListTooLarge + } + var entry string for s != "" { if entry, s = split(s, ','); entry == "" { @@ -201,7 +207,7 @@ func ParseAcceptLanguage(s string) (tag []Tag, q []float32, err error) { tag = append(tag, t) q = append(q, float32(w)) } - sortStable(&tagSort{tag, q}) + sort.Stable(&tagSort{tag, q}) return tag, q, nil } diff --git a/vendor/golang.org/x/text/language/tables.go b/vendor/golang.org/x/text/language/tables.go index 96b57f610a..34a732b699 100644 --- a/vendor/golang.org/x/text/language/tables.go +++ b/vendor/golang.org/x/text/language/tables.go @@ -39,12 +39,12 @@ const ( _Hani = 57 _Hans = 59 _Hant = 60 - _Qaaa = 143 - _Qaai = 151 - _Qabx = 192 - _Zinh = 245 - _Zyyy = 250 - _Zzzz = 251 + _Qaaa = 147 + _Qaai = 155 + _Qabx = 196 + _Zinh = 252 + _Zyyy = 257 + _Zzzz = 258 ) var regionToGroups = []uint8{ // 358 elements @@ -265,9 +265,9 @@ var matchScript = []scriptIntelligibility{ // 26 elements 13: {wantLang: 0x39d, haveLang: 0x139, wantScript: 0x36, haveScript: 0x5a, distance: 0xa}, 14: {wantLang: 0x3be, haveLang: 0x139, wantScript: 0x5, haveScript: 0x5a, distance: 0xa}, 15: {wantLang: 0x3fa, haveLang: 0x139, wantScript: 0x5, haveScript: 0x5a, distance: 0xa}, - 16: {wantLang: 0x40c, haveLang: 0x139, wantScript: 0xcf, haveScript: 0x5a, distance: 0xa}, - 17: {wantLang: 0x450, haveLang: 0x139, wantScript: 0xde, haveScript: 0x5a, distance: 0xa}, - 18: {wantLang: 0x461, haveLang: 0x139, wantScript: 0xe1, haveScript: 0x5a, distance: 0xa}, + 16: {wantLang: 0x40c, haveLang: 0x139, wantScript: 0xd4, haveScript: 0x5a, distance: 0xa}, + 17: {wantLang: 0x450, haveLang: 0x139, wantScript: 0xe3, haveScript: 0x5a, distance: 0xa}, + 18: {wantLang: 0x461, haveLang: 0x139, wantScript: 0xe6, haveScript: 0x5a, distance: 0xa}, 19: {wantLang: 0x46f, haveLang: 0x139, wantScript: 0x2c, haveScript: 0x5a, distance: 0xa}, 20: {wantLang: 0x476, haveLang: 0x3e2, wantScript: 0x5a, haveScript: 0x20, distance: 0xa}, 21: {wantLang: 0x4b4, haveLang: 0x139, wantScript: 0x5, haveScript: 0x5a, distance: 0xa}, diff --git a/vendor/golang.org/x/text/message/catalog/catalog.go b/vendor/golang.org/x/text/message/catalog/catalog.go index de595b5102..96955d0752 100644 --- a/vendor/golang.org/x/text/message/catalog/catalog.go +++ b/vendor/golang.org/x/text/message/catalog/catalog.go @@ -13,8 +13,7 @@ // language. The Loader interface defines a source of dictionaries. A // translation of a format string is represented by a Message. // -// -// Catalogs +// # Catalogs // // A Catalog defines a programmatic interface for setting message translations. // It maintains a set of per-language dictionaries with translations for a set @@ -24,8 +23,7 @@ // the key. For example, a Dictionary for "en-GB" could leave out entries that // are identical to those in a dictionary for "en". // -// -// Messages +// # Messages // // A Message is a format string which varies on the value of substitution // variables. For instance, to indicate the number of results one could want "no @@ -39,8 +37,7 @@ // to selected string. This separation of concerns allows Catalog to be used to // store any kind of formatting strings. // -// -// Selecting messages based on linguistic features of substitution arguments +// # Selecting messages based on linguistic features of substitution arguments // // Messages may vary based on any linguistic features of the argument values. // The most common one is plural form, but others exist. @@ -48,10 +45,10 @@ // Selection messages are provided in packages that provide support for a // specific linguistic feature. The following snippet uses plural.Selectf: // -// catalog.Set(language.English, "You are %d minute(s) late.", -// plural.Selectf(1, "", -// plural.One, "You are 1 minute late.", -// plural.Other, "You are %d minutes late.")) +// catalog.Set(language.English, "You are %d minute(s) late.", +// plural.Selectf(1, "", +// plural.One, "You are 1 minute late.", +// plural.Other, "You are %d minutes late.")) // // In this example, a message is stored in the Catalog where one of two messages // is selected based on the first argument, a number. The first message is @@ -64,47 +61,46 @@ // Selects can be nested. This allows selecting sentences based on features of // multiple arguments or multiple linguistic properties of a single argument. // -// -// String interpolation +// # String interpolation // // There is often a lot of commonality between the possible variants of a // message. For instance, in the example above the word "minute" varies based on // the plural catogory of the argument, but the rest of the sentence is // identical. Using interpolation the above message can be rewritten as: // -// catalog.Set(language.English, "You are %d minute(s) late.", -// catalog.Var("minutes", -// plural.Selectf(1, "", plural.One, "minute", plural.Other, "minutes")), -// catalog.String("You are %[1]d ${minutes} late.")) +// catalog.Set(language.English, "You are %d minute(s) late.", +// catalog.Var("minutes", +// plural.Selectf(1, "", plural.One, "minute", plural.Other, "minutes")), +// catalog.String("You are %[1]d ${minutes} late.")) // // Var is defined to return the variable name if the message does not yield a // match. This allows us to further simplify this snippet to // -// catalog.Set(language.English, "You are %d minute(s) late.", -// catalog.Var("minutes", plural.Selectf(1, "", plural.One, "minute")), -// catalog.String("You are %d ${minutes} late.")) +// catalog.Set(language.English, "You are %d minute(s) late.", +// catalog.Var("minutes", plural.Selectf(1, "", plural.One, "minute")), +// catalog.String("You are %d ${minutes} late.")) // // Overall this is still only a minor improvement, but things can get a lot more // unwieldy if more than one linguistic feature is used to determine a message // variant. Consider the following example: // -// // argument 1: list of hosts, argument 2: list of guests -// catalog.Set(language.English, "%[1]v invite(s) %[2]v to their party.", -// catalog.Var("their", -// plural.Selectf(1, "" -// plural.One, gender.Select(1, "female", "her", "other", "his"))), -// catalog.Var("invites", plural.Selectf(1, "", plural.One, "invite")) -// catalog.String("%[1]v ${invites} %[2]v to ${their} party.")), +// // argument 1: list of hosts, argument 2: list of guests +// catalog.Set(language.English, "%[1]v invite(s) %[2]v to their party.", +// catalog.Var("their", +// plural.Selectf(1, "" +// plural.One, gender.Select(1, "female", "her", "other", "his"))), +// catalog.Var("invites", plural.Selectf(1, "", plural.One, "invite")) +// catalog.String("%[1]v ${invites} %[2]v to ${their} party.")), // // Without variable substitution, this would have to be written as // -// // argument 1: list of hosts, argument 2: list of guests -// catalog.Set(language.English, "%[1]v invite(s) %[2]v to their party.", -// plural.Selectf(1, "", -// plural.One, gender.Select(1, -// "female", "%[1]v invites %[2]v to her party." -// "other", "%[1]v invites %[2]v to his party."), -// plural.Other, "%[1]v invites %[2]v to their party.") +// // argument 1: list of hosts, argument 2: list of guests +// catalog.Set(language.English, "%[1]v invite(s) %[2]v to their party.", +// plural.Selectf(1, "", +// plural.One, gender.Select(1, +// "female", "%[1]v invites %[2]v to her party." +// "other", "%[1]v invites %[2]v to his party."), +// plural.Other, "%[1]v invites %[2]v to their party.")) // // Not necessarily shorter, but using variables there is less duplication and // the messages are more maintenance friendly. Moreover, languages may have up @@ -113,33 +109,32 @@ // Different messages using the same inflections can reuse variables by moving // them to macros. Using macros we can rewrite the message as: // -// // argument 1: list of hosts, argument 2: list of guests -// catalog.SetString(language.English, "%[1]v invite(s) %[2]v to their party.", -// "%[1]v ${invites(1)} %[2]v to ${their(1)} party.") +// // argument 1: list of hosts, argument 2: list of guests +// catalog.SetString(language.English, "%[1]v invite(s) %[2]v to their party.", +// "%[1]v ${invites(1)} %[2]v to ${their(1)} party.") // // Where the following macros were defined separately. // -// catalog.SetMacro(language.English, "invites", plural.Selectf(1, "", -// plural.One, "invite")) -// catalog.SetMacro(language.English, "their", plural.Selectf(1, "", -// plural.One, gender.Select(1, "female", "her", "other", "his"))), +// catalog.SetMacro(language.English, "invites", plural.Selectf(1, "", +// plural.One, "invite")) +// catalog.SetMacro(language.English, "their", plural.Selectf(1, "", +// plural.One, gender.Select(1, "female", "her", "other", "his"))), // // Placeholders use parentheses and the arguments to invoke a macro. // -// -// Looking up messages +// # Looking up messages // // Message lookup using Catalogs is typically only done by specialized packages // and is not something the user should be concerned with. For instance, to // express the tardiness of a user using the related message we defined earlier, // the user may use the package message like so: // -// p := message.NewPrinter(language.English) -// p.Printf("You are %d minute(s) late.", 5) +// p := message.NewPrinter(language.English) +// p.Printf("You are %d minute(s) late.", 5) // // Which would print: -// You are 5 minutes late. // +// You are 5 minutes late. // // This package is UNDER CONSTRUCTION and its API may change. package catalog // import "golang.org/x/text/message/catalog" diff --git a/vendor/golang.org/x/text/message/doc.go b/vendor/golang.org/x/text/message/doc.go index 72e8fde71c..4bf7bdcac3 100644 --- a/vendor/golang.org/x/text/message/doc.go +++ b/vendor/golang.org/x/text/message/doc.go @@ -5,22 +5,21 @@ // Package message implements formatted I/O for localized strings with functions // analogous to the fmt's print functions. It is a drop-in replacement for fmt. // -// -// Localized Formatting +// # Localized Formatting // // A format string can be localized by replacing any of the print functions of // fmt with an equivalent call to a Printer. // -// p := message.NewPrinter(message.MatchLanguage("en")) -// p.Println(123456.78) // Prints 123,456.78 +// p := message.NewPrinter(message.MatchLanguage("en")) +// p.Println(123456.78) // Prints 123,456.78 // -// p.Printf("%d ducks in a row", 4331) // Prints 4,331 ducks in a row +// p.Printf("%d ducks in a row", 4331) // Prints 4,331 ducks in a row // -// p := message.NewPrinter(message.MatchLanguage("nl")) -// p.Printf("Hoogte: %.1f meter", 1244.9) // Prints Hoogte: 1,244.9 meter +// p := message.NewPrinter(message.MatchLanguage("nl")) +// p.Printf("Hoogte: %.1f meter", 1244.9) // Prints Hoogte: 1,244.9 meter // -// p := message.NewPrinter(message.MatchLanguage("bn")) -// p.Println(123456.78) // Prints ১,২৩,৪৫৬.৭৮ +// p := message.NewPrinter(message.MatchLanguage("bn")) +// p.Println(123456.78) // Prints ১,২৩,৪৫৬.৭৮ // // Printer currently supports numbers and specialized types for which packages // exist in x/text. Other builtin types such as time.Time and slices are @@ -35,8 +34,7 @@ // // See package fmt for more options. // -// -// Translation +// # Translation // // The format strings that are passed to Printf, Sprintf, Fprintf, or Errorf // are used as keys to look up translations for the specified languages. @@ -44,34 +42,36 @@ // // One can use arbitrary keys to distinguish between otherwise ambiguous // strings: -// p := message.NewPrinter(language.English) -// p.Printf("archive(noun)") // Prints "archive" -// p.Printf("archive(verb)") // Prints "archive" // -// p := message.NewPrinter(language.German) -// p.Printf("archive(noun)") // Prints "Archiv" -// p.Printf("archive(verb)") // Prints "archivieren" +// p := message.NewPrinter(language.English) +// p.Printf("archive(noun)") // Prints "archive" +// p.Printf("archive(verb)") // Prints "archive" +// +// p := message.NewPrinter(language.German) +// p.Printf("archive(noun)") // Prints "Archiv" +// p.Printf("archive(verb)") // Prints "archivieren" // // To retain the fallback functionality, use Key: -// p.Printf(message.Key("archive(noun)", "archive")) -// p.Printf(message.Key("archive(verb)", "archive")) // +// p.Printf(message.Key("archive(noun)", "archive")) +// p.Printf(message.Key("archive(verb)", "archive")) // -// Translation Pipeline +// # Translation Pipeline // // Format strings that contain text need to be translated to support different // locales. The first step is to extract strings that need to be translated. // // 1. Install gotext -// go get -u golang.org/x/text/cmd/gotext -// gotext -help +// +// go get -u golang.org/x/text/cmd/gotext +// gotext -help // // 2. Mark strings in your source to be translated by using message.Printer, // instead of the functions of the fmt package. // // 3. Extract the strings from your source // -// gotext extract +// gotext extract // // The output will be written to the textdata directory. // @@ -89,13 +89,11 @@ // see also package golang.org/x/text/message/catalog can be used to implement // either dynamic or static loading of messages. // -// -// Plural and Gender Forms +// # Plural and Gender Forms // // Translated messages can vary based on the plural and gender forms of // substitution values. In general, it is up to the translators to provide // alternative translations for such forms. See the packages in // golang.org/x/text/feature and golang.org/x/text/message/catalog for more // information. -// package message diff --git a/vendor/golang.org/x/text/runes/runes.go b/vendor/golang.org/x/text/runes/runes.go index 71933696f5..930e87fedb 100644 --- a/vendor/golang.org/x/text/runes/runes.go +++ b/vendor/golang.org/x/text/runes/runes.go @@ -33,7 +33,7 @@ func In(rt *unicode.RangeTable) Set { return setFunc(func(r rune) bool { return unicode.Is(rt, r) }) } -// In creates a Set with a Contains method that returns true for all runes not +// NotIn creates a Set with a Contains method that returns true for all runes not // in the given RangeTable. func NotIn(rt *unicode.RangeTable) Set { return setFunc(func(r rune) bool { return !unicode.Is(rt, r) }) diff --git a/vendor/golang.org/x/text/unicode/bidi/core.go b/vendor/golang.org/x/text/unicode/bidi/core.go index e4c0811016..9d2ae547b5 100644 --- a/vendor/golang.org/x/text/unicode/bidi/core.go +++ b/vendor/golang.org/x/text/unicode/bidi/core.go @@ -193,14 +193,14 @@ func (p *paragraph) run() { // // At the end of this function: // -// - The member variable matchingPDI is set to point to the index of the -// matching PDI character for each isolate initiator character. If there is -// no matching PDI, it is set to the length of the input text. For other -// characters, it is set to -1. -// - The member variable matchingIsolateInitiator is set to point to the -// index of the matching isolate initiator character for each PDI character. -// If there is no matching isolate initiator, or the character is not a PDI, -// it is set to -1. +// - The member variable matchingPDI is set to point to the index of the +// matching PDI character for each isolate initiator character. If there is +// no matching PDI, it is set to the length of the input text. For other +// characters, it is set to -1. +// - The member variable matchingIsolateInitiator is set to point to the +// index of the matching isolate initiator character for each PDI character. +// If there is no matching isolate initiator, or the character is not a PDI, +// it is set to -1. func (p *paragraph) determineMatchingIsolates() { p.matchingPDI = make([]int, p.Len()) p.matchingIsolateInitiator = make([]int, p.Len()) @@ -435,7 +435,7 @@ func maxLevel(a, b level) level { } // Rule X10, second bullet: Determine the start-of-sequence (sos) and end-of-sequence (eos) types, -// either L or R, for each isolating run sequence. +// either L or R, for each isolating run sequence. func (p *paragraph) isolatingRunSequence(indexes []int) *isolatingRunSequence { length := len(indexes) types := make([]Class, length) @@ -495,9 +495,9 @@ func (s *isolatingRunSequence) resolveWeakTypes() { if t == NSM { s.types[i] = precedingCharacterType } else { - if t.in(LRI, RLI, FSI, PDI) { - precedingCharacterType = ON - } + // if t.in(LRI, RLI, FSI, PDI) { + // precedingCharacterType = ON + // } precedingCharacterType = t } } @@ -905,7 +905,7 @@ func (p *paragraph) getLevels(linebreaks []int) []level { // Lines are concatenated from left to right. So for example, the fifth // character from the left on the third line is // -// getReordering(linebreaks)[linebreaks[1] + 4] +// getReordering(linebreaks)[linebreaks[1] + 4] // // (linebreaks[1] is the position after the last character of the second // line, which is also the index of the first character on the third line, diff --git a/vendor/golang.org/x/text/unicode/norm/forminfo.go b/vendor/golang.org/x/text/unicode/norm/forminfo.go index 526c7033ac..d69ccb4f97 100644 --- a/vendor/golang.org/x/text/unicode/norm/forminfo.go +++ b/vendor/golang.org/x/text/unicode/norm/forminfo.go @@ -110,10 +110,11 @@ func (p Properties) BoundaryAfter() bool { } // We pack quick check data in 4 bits: -// 5: Combines forward (0 == false, 1 == true) -// 4..3: NFC_QC Yes(00), No (10), or Maybe (11) -// 2: NFD_QC Yes (0) or No (1). No also means there is a decomposition. -// 1..0: Number of trailing non-starters. +// +// 5: Combines forward (0 == false, 1 == true) +// 4..3: NFC_QC Yes(00), No (10), or Maybe (11) +// 2: NFD_QC Yes (0) or No (1). No also means there is a decomposition. +// 1..0: Number of trailing non-starters. // // When all 4 bits are zero, the character is inert, meaning it is never // influenced by normalization. diff --git a/vendor/golang.org/x/text/unicode/norm/normalize.go b/vendor/golang.org/x/text/unicode/norm/normalize.go index 95efcf26e8..4747ad07a8 100644 --- a/vendor/golang.org/x/text/unicode/norm/normalize.go +++ b/vendor/golang.org/x/text/unicode/norm/normalize.go @@ -18,16 +18,17 @@ import ( // A Form denotes a canonical representation of Unicode code points. // The Unicode-defined normalization and equivalence forms are: // -// NFC Unicode Normalization Form C -// NFD Unicode Normalization Form D -// NFKC Unicode Normalization Form KC -// NFKD Unicode Normalization Form KD +// NFC Unicode Normalization Form C +// NFD Unicode Normalization Form D +// NFKC Unicode Normalization Form KC +// NFKD Unicode Normalization Form KD // // For a Form f, this documentation uses the notation f(x) to mean // the bytes or string x converted to the given form. // A position n in x is called a boundary if conversion to the form can // proceed independently on both sides: -// f(x) == append(f(x[0:n]), f(x[n:])...) +// +// f(x) == append(f(x[0:n]), f(x[n:])...) // // References: https://unicode.org/reports/tr15/ and // https://unicode.org/notes/tn5/. diff --git a/vendor/golang.org/x/text/unicode/norm/tables13.0.0.go b/vendor/golang.org/x/text/unicode/norm/tables13.0.0.go index 96a130d30e..9115ef257e 100644 --- a/vendor/golang.org/x/text/unicode/norm/tables13.0.0.go +++ b/vendor/golang.org/x/text/unicode/norm/tables13.0.0.go @@ -7315,7 +7315,7 @@ const recompMapPacked = "" + "\x00V\x03\x03\x00\x00\x1e|" + // 0x00560303: 0x00001E7C "\x00v\x03\x03\x00\x00\x1e}" + // 0x00760303: 0x00001E7D "\x00V\x03#\x00\x00\x1e~" + // 0x00560323: 0x00001E7E - "\x00v\x03#\x00\x00\x1e\u007f" + // 0x00760323: 0x00001E7F + "\x00v\x03#\x00\x00\x1e\x7f" + // 0x00760323: 0x00001E7F "\x00W\x03\x00\x00\x00\x1e\x80" + // 0x00570300: 0x00001E80 "\x00w\x03\x00\x00\x00\x1e\x81" + // 0x00770300: 0x00001E81 "\x00W\x03\x01\x00\x00\x1e\x82" + // 0x00570301: 0x00001E82 @@ -7342,7 +7342,7 @@ const recompMapPacked = "" + "\x00t\x03\b\x00\x00\x1e\x97" + // 0x00740308: 0x00001E97 "\x00w\x03\n\x00\x00\x1e\x98" + // 0x0077030A: 0x00001E98 "\x00y\x03\n\x00\x00\x1e\x99" + // 0x0079030A: 0x00001E99 - "\x01\u007f\x03\a\x00\x00\x1e\x9b" + // 0x017F0307: 0x00001E9B + "\x01\x7f\x03\a\x00\x00\x1e\x9b" + // 0x017F0307: 0x00001E9B "\x00A\x03#\x00\x00\x1e\xa0" + // 0x00410323: 0x00001EA0 "\x00a\x03#\x00\x00\x1e\xa1" + // 0x00610323: 0x00001EA1 "\x00A\x03\t\x00\x00\x1e\xa2" + // 0x00410309: 0x00001EA2 diff --git a/vendor/golang.org/x/tools/AUTHORS b/vendor/golang.org/x/tools/AUTHORS deleted file mode 100644 index 15167cd746..0000000000 --- a/vendor/golang.org/x/tools/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code refers to The Go Authors for copyright purposes. -# The master list of authors is in the main Go distribution, -# visible at http://tip.golang.org/AUTHORS. diff --git a/vendor/golang.org/x/tools/CONTRIBUTORS b/vendor/golang.org/x/tools/CONTRIBUTORS deleted file mode 100644 index 1c4577e968..0000000000 --- a/vendor/golang.org/x/tools/CONTRIBUTORS +++ /dev/null @@ -1,3 +0,0 @@ -# This source code was written by the Go contributors. -# The master list of contributors is in the main Go distribution, -# visible at http://tip.golang.org/CONTRIBUTORS. diff --git a/vendor/golang.org/x/tools/cmd/goimports/doc.go b/vendor/golang.org/x/tools/cmd/goimports/doc.go index f344d8014a..18a3ad448e 100644 --- a/vendor/golang.org/x/tools/cmd/goimports/doc.go +++ b/vendor/golang.org/x/tools/cmd/goimports/doc.go @@ -3,29 +3,33 @@ // license that can be found in the LICENSE file. /* - Command goimports updates your Go import lines, adding missing ones and removing unreferenced ones. - $ go get golang.org/x/tools/cmd/goimports + $ go install golang.org/x/tools/cmd/goimports@latest In addition to fixing imports, goimports also formats your code in the same style as gofmt so it can be used as a replacement for your editor's gofmt-on-save hook. For emacs, make sure you have the latest go-mode.el: - https://github.com/dominikh/go-mode.el + + https://github.com/dominikh/go-mode.el + Then in your .emacs file: - (setq gofmt-command "goimports") - (add-hook 'before-save-hook 'gofmt-before-save) + + (setq gofmt-command "goimports") + (add-hook 'before-save-hook 'gofmt-before-save) For vim, set "gofmt_command" to "goimports": - https://golang.org/change/39c724dd7f252 - https://golang.org/wiki/IDEsAndTextEditorPlugins - etc + + https://golang.org/change/39c724dd7f252 + https://golang.org/wiki/IDEsAndTextEditorPlugins + etc For GoSublime, follow the steps described here: - http://michaelwhatcott.com/gosublime-goimports/ + + http://michaelwhatcott.com/gosublime-goimports/ For other editors, you probably know what to do. @@ -39,9 +43,8 @@ working and see what goimports is doing. File bugs or feature requests at: - https://golang.org/issues/new?title=x/tools/cmd/goimports:+ + https://golang.org/issues/new?title=x/tools/cmd/goimports:+ Happy hacking! - */ package main // import "golang.org/x/tools/cmd/goimports" diff --git a/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go b/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go index 6b7052b892..9fa5aa192c 100644 --- a/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go +++ b/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go @@ -11,6 +11,8 @@ import ( "go/ast" "go/token" "sort" + + "golang.org/x/tools/internal/typeparams" ) // PathEnclosingInterval returns the node that encloses the source @@ -20,9 +22,9 @@ import ( // additional whitespace abutting a node to be enclosed by it. // In this example: // -// z := x + y // add them -// <-A-> -// <----B-----> +// z := x + y // add them +// <-A-> +// <----B-----> // // the ast.BinaryExpr(+) node is considered to enclose interval B // even though its [Pos()..End()) is actually only interval A. @@ -41,10 +43,10 @@ import ( // interior whitespace of path[0]. // In this example: // -// z := x + y // add them -// <--C--> <---E--> -// ^ -// D +// z := x + y // add them +// <--C--> <---E--> +// ^ +// D // // intervals C, D and E are inexact. C is contained by the // z-assignment statement, because it spans three of its children (:=, @@ -52,12 +54,11 @@ import ( // interior whitespace of the assignment. E is considered interior // whitespace of the BlockStmt containing the assignment. // -// Precondition: [start, end) both lie within the same file as root. -// TODO(adonovan): return (nil, false) in this case and remove precond. -// Requires FileSet; see loader.tokenFileContainsPos. -// -// Postcondition: path is never nil; it always contains at least 'root'. -// +// The resulting path is never empty; it always contains at least the +// 'root' *ast.File. Ideally PathEnclosingInterval would reject +// intervals that lie wholly or partially outside the range of the +// file, but unfortunately ast.File records only the token.Pos of +// the 'package' keyword, but not of the start of the file itself. func PathEnclosingInterval(root *ast.File, start, end token.Pos) (path []ast.Node, exact bool) { // fmt.Printf("EnclosingInterval %d %d\n", start, end) // debugging @@ -133,6 +134,7 @@ func PathEnclosingInterval(root *ast.File, start, end token.Pos) (path []ast.Nod return false // inexact: overlaps multiple children } + // Ensure [start,end) is nondecreasing. if start > end { start, end = end, start } @@ -160,7 +162,6 @@ func PathEnclosingInterval(root *ast.File, start, end token.Pos) (path []ast.Nod // tokenNode is a dummy implementation of ast.Node for a single token. // They are used transiently by PathEnclosingInterval but never escape // this package. -// type tokenNode struct { pos token.Pos end token.Pos @@ -181,7 +182,6 @@ func tok(pos token.Pos, len int) ast.Node { // childrenOf returns the direct non-nil children of ast.Node n. // It may include fake ast.Node implementations for bare tokens. // it is not safe to call (e.g.) ast.Walk on such nodes. -// func childrenOf(n ast.Node) []ast.Node { var children []ast.Node @@ -294,8 +294,8 @@ func childrenOf(n ast.Node) []ast.Node { case *ast.FieldList: children = append(children, - tok(n.Opening, len("(")), - tok(n.Closing, len(")"))) + tok(n.Opening, len("(")), // or len("[") + tok(n.Closing, len(")"))) // or len("]") case *ast.File: // TODO test: Doc @@ -322,6 +322,9 @@ func childrenOf(n ast.Node) []ast.Node { children = append(children, n.Recv) } children = append(children, n.Name) + if tparams := typeparams.ForFuncType(n.Type); tparams != nil { + children = append(children, tparams) + } if n.Type.Params != nil { children = append(children, n.Type.Params) } @@ -371,8 +374,13 @@ func childrenOf(n ast.Node) []ast.Node { case *ast.IndexExpr: children = append(children, - tok(n.Lbrack, len("{")), - tok(n.Rbrack, len("}"))) + tok(n.Lbrack, len("[")), + tok(n.Rbrack, len("]"))) + + case *typeparams.IndexListExpr: + children = append(children, + tok(n.Lbrack, len("[")), + tok(n.Rbrack, len("]"))) case *ast.InterfaceType: children = append(children, @@ -478,7 +486,6 @@ func (sl byPos) Swap(i, j int) { // TODO(adonovan): in some cases (e.g. Field, FieldList, Ident, // StarExpr) we could be much more specific given the path to the AST // root. Perhaps we should do that. -// func NodeDescription(n ast.Node) string { switch n := n.(type) { case *ast.ArrayType: @@ -581,6 +588,8 @@ func NodeDescription(n ast.Node) string { return "decrement statement" case *ast.IndexExpr: return "index expression" + case *typeparams.IndexListExpr: + return "index list expression" case *ast.InterfaceType: return "interface type" case *ast.KeyValueExpr: diff --git a/vendor/golang.org/x/tools/go/ast/astutil/imports.go b/vendor/golang.org/x/tools/go/ast/astutil/imports.go index 2087ceec9c..18d1adb05d 100644 --- a/vendor/golang.org/x/tools/go/ast/astutil/imports.go +++ b/vendor/golang.org/x/tools/go/ast/astutil/imports.go @@ -22,8 +22,11 @@ func AddImport(fset *token.FileSet, f *ast.File, path string) (added bool) { // If name is not empty, it is used to rename the import. // // For example, calling +// // AddNamedImport(fset, f, "pathpkg", "path") +// // adds +// // import pathpkg "path" func AddNamedImport(fset *token.FileSet, f *ast.File, name, path string) (added bool) { if imports(f, name, path) { @@ -270,8 +273,8 @@ func DeleteNamedImport(fset *token.FileSet, f *ast.File, name, path string) (del } if j > 0 { lastImpspec := gen.Specs[j-1].(*ast.ImportSpec) - lastLine := fset.Position(lastImpspec.Path.ValuePos).Line - line := fset.Position(impspec.Path.ValuePos).Line + lastLine := fset.PositionFor(lastImpspec.Path.ValuePos, false).Line + line := fset.PositionFor(impspec.Path.ValuePos, false).Line // We deleted an entry but now there may be // a blank line-sized hole where the import was. diff --git a/vendor/golang.org/x/tools/go/ast/astutil/rewrite.go b/vendor/golang.org/x/tools/go/ast/astutil/rewrite.go index cf72ea990b..f430b21b9b 100644 --- a/vendor/golang.org/x/tools/go/ast/astutil/rewrite.go +++ b/vendor/golang.org/x/tools/go/ast/astutil/rewrite.go @@ -9,6 +9,8 @@ import ( "go/ast" "reflect" "sort" + + "golang.org/x/tools/internal/typeparams" ) // An ApplyFunc is invoked by Apply for each node n, even if n is nil, @@ -39,7 +41,6 @@ type ApplyFunc func(*Cursor) bool // Children are traversed in the order in which they appear in the // respective node's struct definition. A package's files are // traversed in the filenames' alphabetical order. -// func Apply(root ast.Node, pre, post ApplyFunc) (result ast.Node) { parent := &struct{ ast.Node }{root} defer func() { @@ -63,8 +64,8 @@ var abort = new(int) // singleton, to signal termination of Apply // c.Parent(), and f is the field identifier with name c.Name(), // the following invariants hold: // -// p.f == c.Node() if c.Index() < 0 -// p.f[c.Index()] == c.Node() if c.Index() >= 0 +// p.f == c.Node() if c.Index() < 0 +// p.f[c.Index()] == c.Node() if c.Index() >= 0 // // The methods Replace, Delete, InsertBefore, and InsertAfter // can be used to change the AST without disrupting Apply. @@ -251,6 +252,10 @@ func (a *application) apply(parent ast.Node, name string, iter *iterator, n ast. a.apply(n, "X", nil, n.X) a.apply(n, "Index", nil, n.Index) + case *typeparams.IndexListExpr: + a.apply(n, "X", nil, n.X) + a.applyList(n, "Indices") + case *ast.SliceExpr: a.apply(n, "X", nil, n.X) a.apply(n, "Low", nil, n.Low) @@ -288,6 +293,9 @@ func (a *application) apply(parent ast.Node, name string, iter *iterator, n ast. a.apply(n, "Fields", nil, n.Fields) case *ast.FuncType: + if tparams := typeparams.ForFuncType(n); tparams != nil { + a.apply(n, "TypeParams", nil, tparams) + } a.apply(n, "Params", nil, n.Params) a.apply(n, "Results", nil, n.Results) @@ -400,6 +408,9 @@ func (a *application) apply(parent ast.Node, name string, iter *iterator, n ast. case *ast.TypeSpec: a.apply(n, "Doc", nil, n.Doc) a.apply(n, "Name", nil, n.Name) + if tparams := typeparams.ForTypeSpec(n); tparams != nil { + a.apply(n, "TypeParams", nil, tparams) + } a.apply(n, "Type", nil, n.Type) a.apply(n, "Comment", nil, n.Comment) diff --git a/vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go b/vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go index fc8beea5d8..2ed25a7502 100644 --- a/vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go +++ b/vendor/golang.org/x/tools/go/gcexportdata/gcexportdata.go @@ -17,32 +17,47 @@ // developer tools, which will then be able to consume both Go 1.7 and // Go 1.8 export data files, so they will work before and after the // Go update. (See discussion at https://golang.org/issue/15651.) -// package gcexportdata // import "golang.org/x/tools/go/gcexportdata" import ( "bufio" "bytes" + "encoding/json" "fmt" "go/token" "go/types" "io" "io/ioutil" + "os/exec" "golang.org/x/tools/go/internal/gcimporter" ) // Find returns the name of an object (.o) or archive (.a) file // containing type information for the specified import path, -// using the workspace layout conventions of go/build. +// using the go command. // If no file was found, an empty filename is returned. // // A relative srcDir is interpreted relative to the current working directory. // // Find also returns the package's resolved (canonical) import path, // reflecting the effects of srcDir and vendoring on importPath. +// +// Deprecated: Use the higher-level API in golang.org/x/tools/go/packages, +// which is more efficient. func Find(importPath, srcDir string) (filename, path string) { - return gcimporter.FindPkg(importPath, srcDir) + cmd := exec.Command("go", "list", "-json", "-export", "--", importPath) + cmd.Dir = srcDir + out, err := cmd.CombinedOutput() + if err != nil { + return "", "" + } + var data struct { + ImportPath string + Export string + } + json.Unmarshal(out, &data) + return data.Export, data.ImportPath } // NewReader returns a reader for the export data section of an object @@ -50,11 +65,24 @@ func Find(importPath, srcDir string) (filename, path string) { // additional trailing data beyond the end of the export data. func NewReader(r io.Reader) (io.Reader, error) { buf := bufio.NewReader(r) - _, err := gcimporter.FindExportData(buf) - // If we ever switch to a zip-like archive format with the ToC - // at the end, we can return the correct portion of export data, - // but for now we must return the entire rest of the file. - return buf, err + _, size, err := gcimporter.FindExportData(buf) + if err != nil { + return nil, err + } + + if size >= 0 { + // We were given an archive and found the __.PKGDEF in it. + // This tells us the size of the export data, and we don't + // need to return the entire file. + return &io.LimitedReader{ + R: buf, + N: size, + }, nil + } else { + // We were given an object file. As such, we don't know how large + // the export data is and must return the entire file. + return buf, nil + } } // Read reads export data from in, decodes it, and returns type @@ -88,13 +116,29 @@ func Read(in io.Reader, fset *token.FileSet, imports map[string]*types.Package, // The indexed export format starts with an 'i'; the older // binary export format starts with a 'c', 'd', or 'v' // (from "version"). Select appropriate importer. - if len(data) > 0 && data[0] == 'i' { - _, pkg, err := gcimporter.IImportData(fset, imports, data[1:], path) - return pkg, err - } + if len(data) > 0 { + switch data[0] { + case 'i': + _, pkg, err := gcimporter.IImportData(fset, imports, data[1:], path) + return pkg, err - _, pkg, err := gcimporter.BImportData(fset, imports, data, path) - return pkg, err + case 'v', 'c', 'd': + _, pkg, err := gcimporter.BImportData(fset, imports, data, path) + return pkg, err + + case 'u': + _, pkg, err := gcimporter.UImportData(fset, imports, data[1:], path) + return pkg, err + + default: + l := len(data) + if l > 10 { + l = 10 + } + return nil, fmt.Errorf("unexpected export data with prefix %q for path %s", string(data[:l]), path) + } + } + return nil, fmt.Errorf("empty export data for %s", path) } // Write writes encoded type information for the specified package to out. diff --git a/vendor/golang.org/x/tools/go/gcexportdata/importer.go b/vendor/golang.org/x/tools/go/gcexportdata/importer.go index efe221e7e1..37a7247e26 100644 --- a/vendor/golang.org/x/tools/go/gcexportdata/importer.go +++ b/vendor/golang.org/x/tools/go/gcexportdata/importer.go @@ -23,6 +23,8 @@ import ( // or to control the FileSet or access the imports map populated during // package loading. // +// Deprecated: Use the higher-level API in golang.org/x/tools/go/packages, +// which is more efficient. func NewImporter(fset *token.FileSet, imports map[string]*types.Package) types.ImporterFrom { return importer{fset, imports} } diff --git a/vendor/golang.org/x/tools/go/internal/gcimporter/bexport.go b/vendor/golang.org/x/tools/go/internal/gcimporter/bexport.go index a807d0aaa2..196cb3f9b4 100644 --- a/vendor/golang.org/x/tools/go/internal/gcimporter/bexport.go +++ b/vendor/golang.org/x/tools/go/internal/gcimporter/bexport.go @@ -34,20 +34,19 @@ import ( // (suspected) format errors, and whenever a change is made to the format. const debugFormat = false // default: false -// If trace is set, debugging output is printed to std out. -const trace = false // default: false - // Current export format version. Increase with each format change. +// // Note: The latest binary (non-indexed) export format is at version 6. -// This exporter is still at level 4, but it doesn't matter since -// the binary importer can handle older versions just fine. -// 6: package height (CL 105038) -- NOT IMPLEMENTED HERE -// 5: improved position encoding efficiency (issue 20080, CL 41619) -- NOT IMPLEMEMTED HERE -// 4: type name objects support type aliases, uses aliasTag -// 3: Go1.8 encoding (same as version 2, aliasTag defined but never used) -// 2: removed unused bool in ODCL export (compiler only) -// 1: header format change (more regular), export package for _ struct fields -// 0: Go1.7 encoding +// This exporter is still at level 4, but it doesn't matter since +// the binary importer can handle older versions just fine. +// +// 6: package height (CL 105038) -- NOT IMPLEMENTED HERE +// 5: improved position encoding efficiency (issue 20080, CL 41619) -- NOT IMPLEMENTED HERE +// 4: type name objects support type aliases, uses aliasTag +// 3: Go1.8 encoding (same as version 2, aliasTag defined but never used) +// 2: removed unused bool in ODCL export (compiler only) +// 1: header format change (more regular), export package for _ struct fields +// 0: Go1.7 encoding const exportVersion = 4 // trackAllTypes enables cycle tracking for all types, not just named @@ -92,16 +91,18 @@ func internalErrorf(format string, args ...interface{}) error { // BExportData returns binary export data for pkg. // If no file set is provided, position info will be missing. func BExportData(fset *token.FileSet, pkg *types.Package) (b []byte, err error) { - defer func() { - if e := recover(); e != nil { - if ierr, ok := e.(internalError); ok { - err = ierr - return + if !debug { + defer func() { + if e := recover(); e != nil { + if ierr, ok := e.(internalError); ok { + err = ierr + return + } + // Not an internal error; panic again. + panic(e) } - // Not an internal error; panic again. - panic(e) - } - }() + }() + } p := exporter{ fset: fset, diff --git a/vendor/golang.org/x/tools/go/internal/gcimporter/bimport.go b/vendor/golang.org/x/tools/go/internal/gcimporter/bimport.go index e9f73d14a1..b85de01470 100644 --- a/vendor/golang.org/x/tools/go/internal/gcimporter/bimport.go +++ b/vendor/golang.org/x/tools/go/internal/gcimporter/bimport.go @@ -74,9 +74,10 @@ func BImportData(fset *token.FileSet, imports map[string]*types.Package, data [] pathList: []string{""}, // empty string is mapped to 0 fake: fakeFileSet{ fset: fset, - files: make(map[string]*token.File), + files: make(map[string]*fileInfo), }, } + defer p.fake.setLines() // set lines for files in fset // read version info var versionstr string @@ -338,37 +339,49 @@ func (p *importer) pos() token.Pos { // Synthesize a token.Pos type fakeFileSet struct { fset *token.FileSet - files map[string]*token.File + files map[string]*fileInfo } +type fileInfo struct { + file *token.File + lastline int +} + +const maxlines = 64 * 1024 + func (s *fakeFileSet) pos(file string, line, column int) token.Pos { // TODO(mdempsky): Make use of column. - // Since we don't know the set of needed file positions, we - // reserve maxlines positions per file. - const maxlines = 64 * 1024 + // Since we don't know the set of needed file positions, we reserve maxlines + // positions per file. We delay calling token.File.SetLines until all + // positions have been calculated (by way of fakeFileSet.setLines), so that + // we can avoid setting unnecessary lines. See also golang/go#46586. f := s.files[file] if f == nil { - f = s.fset.AddFile(file, -1, maxlines) + f = &fileInfo{file: s.fset.AddFile(file, -1, maxlines)} s.files[file] = f - // Allocate the fake linebreak indices on first use. - // TODO(adonovan): opt: save ~512KB using a more complex scheme? - fakeLinesOnce.Do(func() { - fakeLines = make([]int, maxlines) - for i := range fakeLines { - fakeLines[i] = i - } - }) - f.SetLines(fakeLines) } - if line > maxlines { line = 1 } + if line > f.lastline { + f.lastline = line + } - // Treat the file as if it contained only newlines - // and column=1: use the line number as the offset. - return f.Pos(line - 1) + // Return a fake position assuming that f.file consists only of newlines. + return token.Pos(f.file.Base() + line - 1) +} + +func (s *fakeFileSet) setLines() { + fakeLinesOnce.Do(func() { + fakeLines = make([]int, maxlines) + for i := range fakeLines { + fakeLines[i] = i + } + }) + for _, f := range s.files { + f.file.SetLines(fakeLines[:f.lastline]) + } } var ( @@ -1029,6 +1042,7 @@ func predeclared() []types.Type { // used internally by gc; never used by this package or in .a files anyType{}, } + predecl = append(predecl, additionalPredeclared()...) }) return predecl } diff --git a/vendor/golang.org/x/tools/go/internal/gcimporter/exportdata.go b/vendor/golang.org/x/tools/go/internal/gcimporter/exportdata.go index f33dc5613e..f6437feb1c 100644 --- a/vendor/golang.org/x/tools/go/internal/gcimporter/exportdata.go +++ b/vendor/golang.org/x/tools/go/internal/gcimporter/exportdata.go @@ -16,7 +16,7 @@ import ( "strings" ) -func readGopackHeader(r *bufio.Reader) (name string, size int, err error) { +func readGopackHeader(r *bufio.Reader) (name string, size int64, err error) { // See $GOROOT/include/ar.h. hdr := make([]byte, 16+12+6+6+8+10+2) _, err = io.ReadFull(r, hdr) @@ -28,7 +28,8 @@ func readGopackHeader(r *bufio.Reader) (name string, size int, err error) { fmt.Printf("header: %s", hdr) } s := strings.TrimSpace(string(hdr[16+12+6+6+8:][:10])) - size, err = strconv.Atoi(s) + length, err := strconv.Atoi(s) + size = int64(length) if err != nil || hdr[len(hdr)-2] != '`' || hdr[len(hdr)-1] != '\n' { err = fmt.Errorf("invalid archive header") return @@ -42,8 +43,8 @@ func readGopackHeader(r *bufio.Reader) (name string, size int, err error) { // file by reading from it. The reader must be positioned at the // start of the file before calling this function. The hdr result // is the string before the export data, either "$$" or "$$B". -// -func FindExportData(r *bufio.Reader) (hdr string, err error) { +// The size result is the length of the export data in bytes, or -1 if not known. +func FindExportData(r *bufio.Reader) (hdr string, size int64, err error) { // Read first line to make sure this is an object file. line, err := r.ReadSlice('\n') if err != nil { @@ -54,7 +55,7 @@ func FindExportData(r *bufio.Reader) (hdr string, err error) { if string(line) == "!\n" { // Archive file. Scan to __.PKGDEF. var name string - if name, _, err = readGopackHeader(r); err != nil { + if name, size, err = readGopackHeader(r); err != nil { return } @@ -70,6 +71,7 @@ func FindExportData(r *bufio.Reader) (hdr string, err error) { err = fmt.Errorf("can't find export data (%v)", err) return } + size -= int64(len(line)) } // Now at __.PKGDEF in archive or still at beginning of file. @@ -86,8 +88,12 @@ func FindExportData(r *bufio.Reader) (hdr string, err error) { err = fmt.Errorf("can't find export data (%v)", err) return } + size -= int64(len(line)) } hdr = string(line) + if size < 0 { + size = -1 + } return } diff --git a/vendor/golang.org/x/tools/go/internal/gcimporter/gcimporter.go b/vendor/golang.org/x/tools/go/internal/gcimporter/gcimporter.go index e8cba6b237..e96c39600d 100644 --- a/vendor/golang.org/x/tools/go/internal/gcimporter/gcimporter.go +++ b/vendor/golang.org/x/tools/go/internal/gcimporter/gcimporter.go @@ -29,8 +29,14 @@ import ( "text/scanner" ) -// debugging/development support -const debug = false +const ( + // Enable debug during development: it adds some additional checks, and + // prevents errors from being recovered. + debug = false + + // If trace is set, debugging output is printed to std out. + trace = false +) var pkgExts = [...]string{".a", ".o"} @@ -39,7 +45,6 @@ var pkgExts = [...]string{".a", ".o"} // the build.Default build.Context). A relative srcDir is interpreted // relative to the current working directory. // If no file was found, an empty filename is returned. -// func FindPkg(path, srcDir string) (filename, id string) { if path == "" { return @@ -103,7 +108,6 @@ func FindPkg(path, srcDir string) (filename, id string) { // If packages[id] contains the completely imported package, that package // can be used directly, and there is no need to call this function (but // there is also no harm but for extra time used). -// func ImportData(packages map[string]*types.Package, filename, id string, data io.Reader) (pkg *types.Package, err error) { // support for parser error handling defer func() { @@ -127,7 +131,6 @@ func ImportData(packages map[string]*types.Package, filename, id string, data io // Import imports a gc-generated package given its import path and srcDir, adds // the corresponding package object to the packages map, and returns the object. // The packages map must contain all packages already imported. -// func Import(packages map[string]*types.Package, path, srcDir string, lookup func(path string) (io.ReadCloser, error)) (pkg *types.Package, err error) { var rc io.ReadCloser var filename, id string @@ -178,8 +181,9 @@ func Import(packages map[string]*types.Package, path, srcDir string, lookup func defer rc.Close() var hdr string + var size int64 buf := bufio.NewReader(rc) - if hdr, err = FindExportData(buf); err != nil { + if hdr, size, err = FindExportData(buf); err != nil { return } @@ -207,10 +211,27 @@ func Import(packages map[string]*types.Package, path, srcDir string, lookup func // The indexed export format starts with an 'i'; the older // binary export format starts with a 'c', 'd', or 'v' // (from "version"). Select appropriate importer. - if len(data) > 0 && data[0] == 'i' { - _, pkg, err = IImportData(fset, packages, data[1:], id) - } else { - _, pkg, err = BImportData(fset, packages, data, id) + if len(data) > 0 { + switch data[0] { + case 'i': + _, pkg, err := IImportData(fset, packages, data[1:], id) + return pkg, err + + case 'v', 'c', 'd': + _, pkg, err := BImportData(fset, packages, data, id) + return pkg, err + + case 'u': + _, pkg, err := UImportData(fset, packages, data[1:size], id) + return pkg, err + + default: + l := len(data) + if l > 10 { + l = 10 + } + return nil, fmt.Errorf("unexpected export data with prefix %q for path %s", string(data[:l]), id) + } } default: @@ -342,8 +363,9 @@ func (p *parser) expectKeyword(keyword string) { // ---------------------------------------------------------------------------- // Qualified and unqualified names -// PackageId = string_lit . +// parsePackageID parses a PackageId: // +// PackageId = string_lit . func (p *parser) parsePackageID() string { id, err := strconv.Unquote(p.expect(scanner.String)) if err != nil { @@ -357,13 +379,16 @@ func (p *parser) parsePackageID() string { return id } -// PackageName = ident . +// parsePackageName parse a PackageName: // +// PackageName = ident . func (p *parser) parsePackageName() string { return p.expect(scanner.Ident) } -// dotIdentifier = ( ident | '·' ) { ident | int | '·' } . +// parseDotIdent parses a dotIdentifier: +// +// dotIdentifier = ( ident | '·' ) { ident | int | '·' } . func (p *parser) parseDotIdent() string { ident := "" if p.tok != scanner.Int { @@ -380,8 +405,9 @@ func (p *parser) parseDotIdent() string { return ident } -// QualifiedName = "@" PackageId "." ( "?" | dotIdentifier ) . +// parseQualifiedName parses a QualifiedName: // +// QualifiedName = "@" PackageId "." ( "?" | dotIdentifier ) . func (p *parser) parseQualifiedName() (id, name string) { p.expect('@') id = p.parsePackageID() @@ -404,7 +430,6 @@ func (p *parser) parseQualifiedName() (id, name string) { // id identifies a package, usually by a canonical package path like // "encoding/json" but possibly by a non-canonical import path like // "./json". -// func (p *parser) getPkg(id, name string) *types.Package { // package unsafe is not in the packages maps - handle explicitly if id == "unsafe" { @@ -440,7 +465,6 @@ func (p *parser) getPkg(id, name string) *types.Package { // parseExportedName is like parseQualifiedName, but // the package id is resolved to an imported *types.Package. -// func (p *parser) parseExportedName() (pkg *types.Package, name string) { id, name := p.parseQualifiedName() pkg = p.getPkg(id, "") @@ -450,8 +474,9 @@ func (p *parser) parseExportedName() (pkg *types.Package, name string) { // ---------------------------------------------------------------------------- // Types -// BasicType = identifier . +// parseBasicType parses a BasicType: // +// BasicType = identifier . func (p *parser) parseBasicType() types.Type { id := p.expect(scanner.Ident) obj := types.Universe.Lookup(id) @@ -462,8 +487,9 @@ func (p *parser) parseBasicType() types.Type { return nil } -// ArrayType = "[" int_lit "]" Type . +// parseArrayType parses an ArrayType: // +// ArrayType = "[" int_lit "]" Type . func (p *parser) parseArrayType(parent *types.Package) types.Type { // "[" already consumed and lookahead known not to be "]" lit := p.expect(scanner.Int) @@ -476,8 +502,9 @@ func (p *parser) parseArrayType(parent *types.Package) types.Type { return types.NewArray(elem, n) } -// MapType = "map" "[" Type "]" Type . +// parseMapType parses a MapType: // +// MapType = "map" "[" Type "]" Type . func (p *parser) parseMapType(parent *types.Package) types.Type { p.expectKeyword("map") p.expect('[') @@ -487,7 +514,9 @@ func (p *parser) parseMapType(parent *types.Package) types.Type { return types.NewMap(key, elem) } -// Name = identifier | "?" | QualifiedName . +// parseName parses a Name: +// +// Name = identifier | "?" | QualifiedName . // // For unqualified and anonymous names, the returned package is the parent // package unless parent == nil, in which case the returned package is the @@ -499,7 +528,6 @@ func (p *parser) parseMapType(parent *types.Package) types.Type { // it doesn't exist yet) unless materializePkg is set (which creates an // unnamed package with valid package path). In the latter case, a // subsequent import clause is expected to provide a name for the package. -// func (p *parser) parseName(parent *types.Package, materializePkg bool) (pkg *types.Package, name string) { pkg = parent if pkg == nil { @@ -533,8 +561,9 @@ func deref(typ types.Type) types.Type { return typ } -// Field = Name Type [ string_lit ] . +// parseField parses a Field: // +// Field = Name Type [ string_lit ] . func (p *parser) parseField(parent *types.Package) (*types.Var, string) { pkg, name := p.parseName(parent, true) @@ -577,9 +606,10 @@ func (p *parser) parseField(parent *types.Package) (*types.Var, string) { return types.NewField(token.NoPos, pkg, name, typ, anonymous), tag } -// StructType = "struct" "{" [ FieldList ] "}" . -// FieldList = Field { ";" Field } . +// parseStructType parses a StructType: // +// StructType = "struct" "{" [ FieldList ] "}" . +// FieldList = Field { ";" Field } . func (p *parser) parseStructType(parent *types.Package) types.Type { var fields []*types.Var var tags []string @@ -604,8 +634,9 @@ func (p *parser) parseStructType(parent *types.Package) types.Type { return types.NewStruct(fields, tags) } -// Parameter = ( identifier | "?" ) [ "..." ] Type [ string_lit ] . +// parseParameter parses a Parameter: // +// Parameter = ( identifier | "?" ) [ "..." ] Type [ string_lit ] . func (p *parser) parseParameter() (par *types.Var, isVariadic bool) { _, name := p.parseName(nil, false) // remove gc-specific parameter numbering @@ -629,9 +660,10 @@ func (p *parser) parseParameter() (par *types.Var, isVariadic bool) { return } -// Parameters = "(" [ ParameterList ] ")" . -// ParameterList = { Parameter "," } Parameter . +// parseParameters parses a Parameters: // +// Parameters = "(" [ ParameterList ] ")" . +// ParameterList = { Parameter "," } Parameter . func (p *parser) parseParameters() (list []*types.Var, isVariadic bool) { p.expect('(') for p.tok != ')' && p.tok != scanner.EOF { @@ -652,9 +684,10 @@ func (p *parser) parseParameters() (list []*types.Var, isVariadic bool) { return } -// Signature = Parameters [ Result ] . -// Result = Type | Parameters . +// parseSignature parses a Signature: // +// Signature = Parameters [ Result ] . +// Result = Type | Parameters . func (p *parser) parseSignature(recv *types.Var) *types.Signature { params, isVariadic := p.parseParameters() @@ -671,14 +704,15 @@ func (p *parser) parseSignature(recv *types.Var) *types.Signature { return types.NewSignature(recv, types.NewTuple(params...), types.NewTuple(results...), isVariadic) } -// InterfaceType = "interface" "{" [ MethodList ] "}" . -// MethodList = Method { ";" Method } . -// Method = Name Signature . +// parseInterfaceType parses an InterfaceType: +// +// InterfaceType = "interface" "{" [ MethodList ] "}" . +// MethodList = Method { ";" Method } . +// Method = Name Signature . // // The methods of embedded interfaces are always "inlined" // by the compiler and thus embedded interfaces are never // visible in the export data. -// func (p *parser) parseInterfaceType(parent *types.Package) types.Type { var methods []*types.Func @@ -699,8 +733,9 @@ func (p *parser) parseInterfaceType(parent *types.Package) types.Type { return newInterface(methods, nil).Complete() } -// ChanType = ( "chan" [ "<-" ] | "<-" "chan" ) Type . +// parseChanType parses a ChanType: // +// ChanType = ( "chan" [ "<-" ] | "<-" "chan" ) Type . func (p *parser) parseChanType(parent *types.Package) types.Type { dir := types.SendRecv if p.tok == scanner.Ident { @@ -718,17 +753,18 @@ func (p *parser) parseChanType(parent *types.Package) types.Type { return types.NewChan(dir, elem) } -// Type = -// BasicType | TypeName | ArrayType | SliceType | StructType | -// PointerType | FuncType | InterfaceType | MapType | ChanType | -// "(" Type ")" . +// parseType parses a Type: // -// BasicType = ident . -// TypeName = ExportedName . -// SliceType = "[" "]" Type . -// PointerType = "*" Type . -// FuncType = "func" Signature . +// Type = +// BasicType | TypeName | ArrayType | SliceType | StructType | +// PointerType | FuncType | InterfaceType | MapType | ChanType | +// "(" Type ")" . // +// BasicType = ident . +// TypeName = ExportedName . +// SliceType = "[" "]" Type . +// PointerType = "*" Type . +// FuncType = "func" Signature . func (p *parser) parseType(parent *types.Package) types.Type { switch p.tok { case scanner.Ident: @@ -780,16 +816,18 @@ func (p *parser) parseType(parent *types.Package) types.Type { // ---------------------------------------------------------------------------- // Declarations -// ImportDecl = "import" PackageName PackageId . +// parseImportDecl parses an ImportDecl: // +// ImportDecl = "import" PackageName PackageId . func (p *parser) parseImportDecl() { p.expectKeyword("import") name := p.parsePackageName() p.getPkg(p.parsePackageID(), name) } -// int_lit = [ "+" | "-" ] { "0" ... "9" } . +// parseInt parses an int_lit: // +// int_lit = [ "+" | "-" ] { "0" ... "9" } . func (p *parser) parseInt() string { s := "" switch p.tok { @@ -802,8 +840,9 @@ func (p *parser) parseInt() string { return s + p.expect(scanner.Int) } -// number = int_lit [ "p" int_lit ] . +// parseNumber parses a number: // +// number = int_lit [ "p" int_lit ] . func (p *parser) parseNumber() (typ *types.Basic, val constant.Value) { // mantissa mant := constant.MakeFromLiteral(p.parseInt(), token.INT, 0) @@ -838,13 +877,14 @@ func (p *parser) parseNumber() (typ *types.Basic, val constant.Value) { return } -// ConstDecl = "const" ExportedName [ Type ] "=" Literal . -// Literal = bool_lit | int_lit | float_lit | complex_lit | rune_lit | string_lit . -// bool_lit = "true" | "false" . -// complex_lit = "(" float_lit "+" float_lit "i" ")" . -// rune_lit = "(" int_lit "+" int_lit ")" . -// string_lit = `"` { unicode_char } `"` . +// parseConstDecl parses a ConstDecl: // +// ConstDecl = "const" ExportedName [ Type ] "=" Literal . +// Literal = bool_lit | int_lit | float_lit | complex_lit | rune_lit | string_lit . +// bool_lit = "true" | "false" . +// complex_lit = "(" float_lit "+" float_lit "i" ")" . +// rune_lit = "(" int_lit "+" int_lit ")" . +// string_lit = `"` { unicode_char } `"` . func (p *parser) parseConstDecl() { p.expectKeyword("const") pkg, name := p.parseExportedName() @@ -914,8 +954,9 @@ func (p *parser) parseConstDecl() { pkg.Scope().Insert(types.NewConst(token.NoPos, pkg, name, typ0, val)) } -// TypeDecl = "type" ExportedName Type . +// parseTypeDecl parses a TypeDecl: // +// TypeDecl = "type" ExportedName Type . func (p *parser) parseTypeDecl() { p.expectKeyword("type") pkg, name := p.parseExportedName() @@ -933,8 +974,9 @@ func (p *parser) parseTypeDecl() { } } -// VarDecl = "var" ExportedName Type . +// parseVarDecl parses a VarDecl: // +// VarDecl = "var" ExportedName Type . func (p *parser) parseVarDecl() { p.expectKeyword("var") pkg, name := p.parseExportedName() @@ -942,9 +984,10 @@ func (p *parser) parseVarDecl() { pkg.Scope().Insert(types.NewVar(token.NoPos, pkg, name, typ)) } -// Func = Signature [ Body ] . -// Body = "{" ... "}" . +// parseFunc parses a Func: // +// Func = Signature [ Body ] . +// Body = "{" ... "}" . func (p *parser) parseFunc(recv *types.Var) *types.Signature { sig := p.parseSignature(recv) if p.tok == '{' { @@ -961,9 +1004,10 @@ func (p *parser) parseFunc(recv *types.Var) *types.Signature { return sig } -// MethodDecl = "func" Receiver Name Func . -// Receiver = "(" ( identifier | "?" ) [ "*" ] ExportedName ")" . +// parseMethodDecl parses a MethodDecl: // +// MethodDecl = "func" Receiver Name Func . +// Receiver = "(" ( identifier | "?" ) [ "*" ] ExportedName ")" . func (p *parser) parseMethodDecl() { // "func" already consumed p.expect('(') @@ -986,8 +1030,9 @@ func (p *parser) parseMethodDecl() { base.AddMethod(types.NewFunc(token.NoPos, pkg, name, sig)) } -// FuncDecl = "func" ExportedName Func . +// parseFuncDecl parses a FuncDecl: // +// FuncDecl = "func" ExportedName Func . func (p *parser) parseFuncDecl() { // "func" already consumed pkg, name := p.parseExportedName() @@ -995,8 +1040,9 @@ func (p *parser) parseFuncDecl() { pkg.Scope().Insert(types.NewFunc(token.NoPos, pkg, name, typ)) } -// Decl = [ ImportDecl | ConstDecl | TypeDecl | VarDecl | FuncDecl | MethodDecl ] "\n" . +// parseDecl parses a Decl: // +// Decl = [ ImportDecl | ConstDecl | TypeDecl | VarDecl | FuncDecl | MethodDecl ] "\n" . func (p *parser) parseDecl() { if p.tok == scanner.Ident { switch p.lit { @@ -1023,9 +1069,10 @@ func (p *parser) parseDecl() { // ---------------------------------------------------------------------------- // Export -// Export = "PackageClause { Decl } "$$" . -// PackageClause = "package" PackageName [ "safe" ] "\n" . +// parseExport parses an Export: // +// Export = "PackageClause { Decl } "$$" . +// PackageClause = "package" PackageName [ "safe" ] "\n" . func (p *parser) parseExport() *types.Package { p.expectKeyword("package") name := p.parsePackageName() diff --git a/vendor/golang.org/x/tools/go/internal/gcimporter/iexport.go b/vendor/golang.org/x/tools/go/internal/gcimporter/iexport.go index d2fc8b6fa3..9a4ff329e1 100644 --- a/vendor/golang.org/x/tools/go/internal/gcimporter/iexport.go +++ b/vendor/golang.org/x/tools/go/internal/gcimporter/iexport.go @@ -11,6 +11,7 @@ package gcimporter import ( "bytes" "encoding/binary" + "fmt" "go/ast" "go/constant" "go/token" @@ -19,11 +20,11 @@ import ( "math/big" "reflect" "sort" -) + "strconv" + "strings" -// Current indexed export format version. Increase with each format change. -// 0: Go1.11 encoding -const iexportVersion = 0 + "golang.org/x/tools/internal/typeparams" +) // Current bundled export format version. Increase with each format change. // 0: initial implementation @@ -35,31 +36,35 @@ const bundleVersion = 0 // The package path of the top-level package will not be recorded, // so that calls to IImportData can override with a provided package path. func IExportData(out io.Writer, fset *token.FileSet, pkg *types.Package) error { - return iexportCommon(out, fset, false, []*types.Package{pkg}) + return iexportCommon(out, fset, false, iexportVersion, []*types.Package{pkg}) } // IExportBundle writes an indexed export bundle for pkgs to out. func IExportBundle(out io.Writer, fset *token.FileSet, pkgs []*types.Package) error { - return iexportCommon(out, fset, true, pkgs) + return iexportCommon(out, fset, true, iexportVersion, pkgs) } -func iexportCommon(out io.Writer, fset *token.FileSet, bundle bool, pkgs []*types.Package) (err error) { - defer func() { - if e := recover(); e != nil { - if ierr, ok := e.(internalError); ok { - err = ierr - return +func iexportCommon(out io.Writer, fset *token.FileSet, bundle bool, version int, pkgs []*types.Package) (err error) { + if !debug { + defer func() { + if e := recover(); e != nil { + if ierr, ok := e.(internalError); ok { + err = ierr + return + } + // Not an internal error; panic again. + panic(e) } - // Not an internal error; panic again. - panic(e) - } - }() + }() + } p := iexporter{ fset: fset, + version: version, allPkgs: map[*types.Package]bool{}, stringIndex: map[string]uint64{}, declIndex: map[types.Object]uint64{}, + tparamNames: map[types.Object]string{}, typIndex: map[types.Type]uint64{}, } if !bundle { @@ -119,7 +124,7 @@ func iexportCommon(out io.Writer, fset *token.FileSet, bundle bool, pkgs []*type if bundle { hdr.uint64(bundleVersion) } - hdr.uint64(iexportVersion) + hdr.uint64(uint64(p.version)) hdr.uint64(uint64(p.strings.Len())) hdr.uint64(dataLen) @@ -136,8 +141,12 @@ func iexportCommon(out io.Writer, fset *token.FileSet, bundle bool, pkgs []*type // non-compiler tools and includes a complete package description // (i.e., name and height). func (w *exportWriter) writeIndex(index map[types.Object]uint64) { + type pkgObj struct { + obj types.Object + name string // qualified name; differs from obj.Name for type params + } // Build a map from packages to objects from that package. - pkgObjs := map[*types.Package][]types.Object{} + pkgObjs := map[*types.Package][]pkgObj{} // For the main index, make sure to include every package that // we reference, even if we're not exporting (or reexporting) @@ -150,7 +159,8 @@ func (w *exportWriter) writeIndex(index map[types.Object]uint64) { } for obj := range index { - pkgObjs[obj.Pkg()] = append(pkgObjs[obj.Pkg()], obj) + name := w.p.exportName(obj) + pkgObjs[obj.Pkg()] = append(pkgObjs[obj.Pkg()], pkgObj{obj, name}) } var pkgs []*types.Package @@ -158,7 +168,7 @@ func (w *exportWriter) writeIndex(index map[types.Object]uint64) { pkgs = append(pkgs, pkg) sort.Slice(objs, func(i, j int) bool { - return objs[i].Name() < objs[j].Name() + return objs[i].name < objs[j].name }) } @@ -175,15 +185,25 @@ func (w *exportWriter) writeIndex(index map[types.Object]uint64) { objs := pkgObjs[pkg] w.uint64(uint64(len(objs))) for _, obj := range objs { - w.string(obj.Name()) - w.uint64(index[obj]) + w.string(obj.name) + w.uint64(index[obj.obj]) } } } +// exportName returns the 'exported' name of an object. It differs from +// obj.Name() only for type parameters (see tparamExportName for details). +func (p *iexporter) exportName(obj types.Object) (res string) { + if name := p.tparamNames[obj]; name != "" { + return name + } + return obj.Name() +} + type iexporter struct { - fset *token.FileSet - out *bytes.Buffer + fset *token.FileSet + out *bytes.Buffer + version int localpkg *types.Package @@ -197,9 +217,21 @@ type iexporter struct { strings intWriter stringIndex map[string]uint64 - data0 intWriter - declIndex map[types.Object]uint64 - typIndex map[types.Type]uint64 + data0 intWriter + declIndex map[types.Object]uint64 + tparamNames map[types.Object]string // typeparam->exported name + typIndex map[types.Type]uint64 + + indent int // for tracing support +} + +func (p *iexporter) trace(format string, args ...interface{}) { + if !trace { + // Call sites should also be guarded, but having this check here allows + // easily enabling/disabling debug trace statements. + return + } + fmt.Printf(strings.Repeat("..", p.indent)+format+"\n", args...) } // stringOff returns the offset of s within the string section. @@ -219,13 +251,16 @@ func (p *iexporter) stringOff(s string) uint64 { // pushDecl adds n to the declaration work queue, if not already present. func (p *iexporter) pushDecl(obj types.Object) { // Package unsafe is known to the compiler and predeclared. - assert(obj.Pkg() != types.Unsafe) + // Caller should not ask us to do export it. + if obj.Pkg() == types.Unsafe { + panic("cannot export package unsafe") + } if _, ok := p.declIndex[obj]; ok { return } - p.declIndex[obj] = ^uint64(0) // mark n present in work queue + p.declIndex[obj] = ^uint64(0) // mark obj present in work queue p.declTodo.pushTail(obj) } @@ -233,10 +268,11 @@ func (p *iexporter) pushDecl(obj types.Object) { type exportWriter struct { p *iexporter - data intWriter - currPkg *types.Package - prevFile string - prevLine int64 + data intWriter + currPkg *types.Package + prevFile string + prevLine int64 + prevColumn int64 } func (w *exportWriter) exportPath(pkg *types.Package) string { @@ -247,6 +283,14 @@ func (w *exportWriter) exportPath(pkg *types.Package) string { } func (p *iexporter) doDecl(obj types.Object) { + if trace { + p.trace("exporting decl %v (%T)", obj, obj) + p.indent++ + defer func() { + p.indent-- + p.trace("=> %s", obj) + }() + } w := p.newWriter() w.setPkg(obj.Pkg(), false) @@ -261,8 +305,24 @@ func (p *iexporter) doDecl(obj types.Object) { if sig.Recv() != nil { panic(internalErrorf("unexpected method: %v", sig)) } - w.tag('F') + + // Function. + if typeparams.ForSignature(sig).Len() == 0 { + w.tag('F') + } else { + w.tag('G') + } w.pos(obj.Pos()) + // The tparam list of the function type is the declaration of the type + // params. So, write out the type params right now. Then those type params + // will be referenced via their type offset (via typOff) in all other + // places in the signature and function where they are used. + // + // While importing the type parameters, tparamList computes and records + // their export name, so that it can be later used when writing the index. + if tparams := typeparams.ForSignature(sig); tparams.Len() > 0 { + w.tparamList(obj.Name(), tparams, obj.Pkg()) + } w.signature(sig) case *types.Const: @@ -271,30 +331,56 @@ func (p *iexporter) doDecl(obj types.Object) { w.value(obj.Type(), obj.Val()) case *types.TypeName: + t := obj.Type() + + if tparam, ok := t.(*typeparams.TypeParam); ok { + w.tag('P') + w.pos(obj.Pos()) + constraint := tparam.Constraint() + if p.version >= iexportVersionGo1_18 { + implicit := false + if iface, _ := constraint.(*types.Interface); iface != nil { + implicit = typeparams.IsImplicit(iface) + } + w.bool(implicit) + } + w.typ(constraint, obj.Pkg()) + break + } + if obj.IsAlias() { w.tag('A') w.pos(obj.Pos()) - w.typ(obj.Type(), obj.Pkg()) + w.typ(t, obj.Pkg()) break } // Defined type. - w.tag('T') + named, ok := t.(*types.Named) + if !ok { + panic(internalErrorf("%s is not a defined type", t)) + } + + if typeparams.ForNamed(named).Len() == 0 { + w.tag('T') + } else { + w.tag('U') + } w.pos(obj.Pos()) + if typeparams.ForNamed(named).Len() > 0 { + // While importing the type parameters, tparamList computes and records + // their export name, so that it can be later used when writing the index. + w.tparamList(obj.Name(), typeparams.ForNamed(named), obj.Pkg()) + } + underlying := obj.Type().Underlying() w.typ(underlying, obj.Pkg()) - t := obj.Type() if types.IsInterface(t) { break } - named, ok := t.(*types.Named) - if !ok { - panic(internalErrorf("%s is not a defined type", t)) - } - n := named.NumMethods() w.uint64(uint64(n)) for i := 0; i < n; i++ { @@ -302,6 +388,17 @@ func (p *iexporter) doDecl(obj types.Object) { w.pos(m.Pos()) w.string(m.Name()) sig, _ := m.Type().(*types.Signature) + + // Receiver type parameters are type arguments of the receiver type, so + // their name must be qualified before exporting recv. + if rparams := typeparams.RecvTypeParams(sig); rparams.Len() > 0 { + prefix := obj.Name() + "." + m.Name() + for i := 0; i < rparams.Len(); i++ { + rparam := rparams.At(i) + name := tparamExportName(prefix, rparam) + w.p.tparamNames[rparam.Obj()] = name + } + } w.param(sig.Recv()) w.signature(sig) } @@ -318,6 +415,48 @@ func (w *exportWriter) tag(tag byte) { } func (w *exportWriter) pos(pos token.Pos) { + if w.p.version >= iexportVersionPosCol { + w.posV1(pos) + } else { + w.posV0(pos) + } +} + +func (w *exportWriter) posV1(pos token.Pos) { + if w.p.fset == nil { + w.int64(0) + return + } + + p := w.p.fset.Position(pos) + file := p.Filename + line := int64(p.Line) + column := int64(p.Column) + + deltaColumn := (column - w.prevColumn) << 1 + deltaLine := (line - w.prevLine) << 1 + + if file != w.prevFile { + deltaLine |= 1 + } + if deltaLine != 0 { + deltaColumn |= 1 + } + + w.int64(deltaColumn) + if deltaColumn&1 != 0 { + w.int64(deltaLine) + if deltaLine&1 != 0 { + w.string(file) + } + } + + w.prevFile = file + w.prevLine = line + w.prevColumn = column +} + +func (w *exportWriter) posV0(pos token.Pos) { if w.p.fset == nil { w.int64(0) return @@ -359,10 +498,11 @@ func (w *exportWriter) pkg(pkg *types.Package) { } func (w *exportWriter) qualifiedIdent(obj types.Object) { + name := w.p.exportName(obj) + // Ensure any referenced declarations are written out too. w.p.pushDecl(obj) - - w.string(obj.Name()) + w.string(name) w.pkg(obj.Pkg()) } @@ -396,11 +536,32 @@ func (w *exportWriter) startType(k itag) { } func (w *exportWriter) doTyp(t types.Type, pkg *types.Package) { + if trace { + w.p.trace("exporting type %s (%T)", t, t) + w.p.indent++ + defer func() { + w.p.indent-- + w.p.trace("=> %s", t) + }() + } switch t := t.(type) { case *types.Named: + if targs := typeparams.NamedTypeArgs(t); targs.Len() > 0 { + w.startType(instanceType) + // TODO(rfindley): investigate if this position is correct, and if it + // matters. + w.pos(t.Obj().Pos()) + w.typeList(targs, pkg) + w.typ(typeparams.NamedTypeOrigin(t), pkg) + return + } w.startType(definedType) w.qualifiedIdent(t.Obj()) + case *typeparams.TypeParam: + w.startType(typeParamType) + w.qualifiedIdent(t.Obj()) + case *types.Pointer: w.startType(pointerType) w.typ(t.Elem(), pkg) @@ -461,9 +622,14 @@ func (w *exportWriter) doTyp(t types.Type, pkg *types.Package) { n := t.NumEmbeddeds() w.uint64(uint64(n)) for i := 0; i < n; i++ { - f := t.Embedded(i) - w.pos(f.Obj().Pos()) - w.typ(f.Obj().Type(), f.Obj().Pkg()) + ft := t.EmbeddedType(i) + tPkg := pkg + if named, _ := ft.(*types.Named); named != nil { + w.pos(named.Obj().Pos()) + } else { + w.pos(token.NoPos) + } + w.typ(ft, tPkg) } n = t.NumExplicitMethods() @@ -476,6 +642,16 @@ func (w *exportWriter) doTyp(t types.Type, pkg *types.Package) { w.signature(sig) } + case *typeparams.Union: + w.startType(unionType) + nt := t.Len() + w.uint64(uint64(nt)) + for i := 0; i < nt; i++ { + term := t.Term(i) + w.bool(term.Tilde()) + w.typ(term.Type(), pkg) + } + default: panic(internalErrorf("unexpected type: %v, %v", t, reflect.TypeOf(t))) } @@ -497,6 +673,56 @@ func (w *exportWriter) signature(sig *types.Signature) { } } +func (w *exportWriter) typeList(ts *typeparams.TypeList, pkg *types.Package) { + w.uint64(uint64(ts.Len())) + for i := 0; i < ts.Len(); i++ { + w.typ(ts.At(i), pkg) + } +} + +func (w *exportWriter) tparamList(prefix string, list *typeparams.TypeParamList, pkg *types.Package) { + ll := uint64(list.Len()) + w.uint64(ll) + for i := 0; i < list.Len(); i++ { + tparam := list.At(i) + // Set the type parameter exportName before exporting its type. + exportName := tparamExportName(prefix, tparam) + w.p.tparamNames[tparam.Obj()] = exportName + w.typ(list.At(i), pkg) + } +} + +const blankMarker = "$" + +// tparamExportName returns the 'exported' name of a type parameter, which +// differs from its actual object name: it is prefixed with a qualifier, and +// blank type parameter names are disambiguated by their index in the type +// parameter list. +func tparamExportName(prefix string, tparam *typeparams.TypeParam) string { + assert(prefix != "") + name := tparam.Obj().Name() + if name == "_" { + name = blankMarker + strconv.Itoa(tparam.Index()) + } + return prefix + "." + name +} + +// tparamName returns the real name of a type parameter, after stripping its +// qualifying prefix and reverting blank-name encoding. See tparamExportName +// for details. +func tparamName(exportName string) string { + // Remove the "path" from the type param name that makes it unique. + ix := strings.LastIndex(exportName, ".") + if ix < 0 { + errorf("malformed type parameter export name %s: missing prefix", exportName) + } + name := exportName[ix+1:] + if strings.HasPrefix(name, blankMarker) { + return "_" + } + return name +} + func (w *exportWriter) paramList(tup *types.Tuple) { n := tup.Len() w.uint64(uint64(n)) @@ -513,6 +739,9 @@ func (w *exportWriter) param(obj types.Object) { func (w *exportWriter) value(typ types.Type, v constant.Value) { w.typ(typ, nil) + if w.p.version >= iexportVersionGo1_18 { + w.int64(int64(v.Kind())) + } switch b := typ.Underlying().(*types.Basic); b.Info() & types.IsConstType { case types.IsBoolean: diff --git a/vendor/golang.org/x/tools/go/internal/gcimporter/iimport.go b/vendor/golang.org/x/tools/go/internal/gcimporter/iimport.go index 8ed8bc62d6..4caa0f55d9 100644 --- a/vendor/golang.org/x/tools/go/internal/gcimporter/iimport.go +++ b/vendor/golang.org/x/tools/go/internal/gcimporter/iimport.go @@ -17,7 +17,11 @@ import ( "go/token" "go/types" "io" + "math/big" "sort" + "strings" + + "golang.org/x/tools/internal/typeparams" ) type intReader struct { @@ -41,6 +45,19 @@ func (r *intReader) uint64() uint64 { return i } +// Keep this in sync with constants in iexport.go. +const ( + iexportVersionGo1_11 = 0 + iexportVersionPosCol = 1 + iexportVersionGo1_18 = 2 + iexportVersionGenerics = 2 +) + +type ident struct { + pkg *types.Package + name string +} + const predeclReserved = 32 type itag uint64 @@ -56,6 +73,9 @@ const ( signatureType structType interfaceType + typeParamType + instanceType + unionType ) // IImportData imports a package from the serialized package data @@ -78,15 +98,19 @@ func IImportBundle(fset *token.FileSet, imports map[string]*types.Package, data func iimportCommon(fset *token.FileSet, imports map[string]*types.Package, data []byte, bundle bool, path string) (pkgs []*types.Package, err error) { const currentVersion = 1 version := int64(-1) - defer func() { - if e := recover(); e != nil { - if version > currentVersion { - err = fmt.Errorf("cannot import %q (%v), export data is newer version - update tool", path, e) - } else { - err = fmt.Errorf("cannot import %q (%v), possibly version skew - reinstall package", path, e) + if !debug { + defer func() { + if e := recover(); e != nil { + if bundle { + err = fmt.Errorf("%v", e) + } else if version > currentVersion { + err = fmt.Errorf("cannot import %q (%v), export data is newer version - update tool", path, e) + } else { + err = fmt.Errorf("cannot import %q (%v), possibly version skew - reinstall package", path, e) + } } - } - }() + }() + } r := &intReader{bytes.NewReader(data), path} @@ -101,9 +125,13 @@ func iimportCommon(fset *token.FileSet, imports map[string]*types.Package, data version = int64(r.uint64()) switch version { - case currentVersion, 0: + case iexportVersionGo1_18, iexportVersionPosCol, iexportVersionGo1_11: default: - errorf("unknown iexport format version %d", version) + if version > iexportVersionGo1_18 { + errorf("unstable iexport format version %d, just rebuild compiler and std library", version) + } else { + errorf("unknown iexport format version %d", version) + } } sLen := int64(r.uint64()) @@ -115,8 +143,8 @@ func iimportCommon(fset *token.FileSet, imports map[string]*types.Package, data r.Seek(sLen+dLen, io.SeekCurrent) p := iimporter{ - ipath: path, version: int(version), + ipath: path, stringData: stringData, stringCache: make(map[uint64]string), @@ -125,12 +153,16 @@ func iimportCommon(fset *token.FileSet, imports map[string]*types.Package, data declData: declData, pkgIndex: make(map[*types.Package]map[string]uint64), typCache: make(map[uint64]types.Type), + // Separate map for typeparams, keyed by their package and unique + // name. + tparamIndex: make(map[ident]types.Type), fake: fakeFileSet{ fset: fset, - files: make(map[string]*token.File), + files: make(map[string]*fileInfo), }, } + defer p.fake.setLines() // set lines for files in fset for i, pt := range predeclared() { p.typCache[uint64(i)] = pt @@ -208,6 +240,15 @@ func iimportCommon(fset *token.FileSet, imports map[string]*types.Package, data pkg.MarkComplete() } + // SetConstraint can't be called if the constraint type is not yet complete. + // When type params are created in the 'P' case of (*importReader).obj(), + // the associated constraint type may not be complete due to recursion. + // Therefore, we defer calling SetConstraint there, and call it here instead + // after all types are complete. + for _, d := range p.later { + typeparams.SetTypeParamConstraint(d.t, d.constraint) + } + for _, typ := range p.interfaceList { typ.Complete() } @@ -215,23 +256,51 @@ func iimportCommon(fset *token.FileSet, imports map[string]*types.Package, data return pkgs, nil } +type setConstraintArgs struct { + t *typeparams.TypeParam + constraint types.Type +} + type iimporter struct { - ipath string version int + ipath string stringData []byte stringCache map[uint64]string pkgCache map[uint64]*types.Package - declData []byte - pkgIndex map[*types.Package]map[string]uint64 - typCache map[uint64]types.Type + declData []byte + pkgIndex map[*types.Package]map[string]uint64 + typCache map[uint64]types.Type + tparamIndex map[ident]types.Type fake fakeFileSet interfaceList []*types.Interface + + // Arguments for calls to SetConstraint that are deferred due to recursive types + later []setConstraintArgs + + indent int // for tracing support +} + +func (p *iimporter) trace(format string, args ...interface{}) { + if !trace { + // Call sites should also be guarded, but having this check here allows + // easily enabling/disabling debug trace statements. + return + } + fmt.Printf(strings.Repeat("..", p.indent)+format+"\n", args...) } func (p *iimporter) doDecl(pkg *types.Package, name string) { + if debug { + p.trace("import decl %s", name) + p.indent++ + defer func() { + p.indent-- + p.trace("=> %s", name) + }() + } // See if we've already imported this declaration. if obj := pkg.Scope().Lookup(name); obj != nil { return @@ -273,7 +342,7 @@ func (p *iimporter) pkgAt(off uint64) *types.Package { } func (p *iimporter) typAt(off uint64, base *types.Named) types.Type { - if t, ok := p.typCache[off]; ok && (base == nil || !isInterface(t)) { + if t, ok := p.typCache[off]; ok && canReuse(base, t) { return t } @@ -285,12 +354,30 @@ func (p *iimporter) typAt(off uint64, base *types.Named) types.Type { r.declReader.Reset(p.declData[off-predeclReserved:]) t := r.doType(base) - if base == nil || !isInterface(t) { + if canReuse(base, t) { p.typCache[off] = t } return t } +// canReuse reports whether the type rhs on the RHS of the declaration for def +// may be re-used. +// +// Specifically, if def is non-nil and rhs is an interface type with methods, it +// may not be re-used because we have a convention of setting the receiver type +// for interface methods to def. +func canReuse(def *types.Named, rhs types.Type) bool { + if def == nil { + return true + } + iface, _ := rhs.(*types.Interface) + if iface == nil { + return true + } + // Don't use iface.Empty() here as iface may not be complete. + return iface.NumEmbeddeds() == 0 && iface.NumExplicitMethods() == 0 +} + type importReader struct { p *iimporter declReader bytes.Reader @@ -315,17 +402,26 @@ func (r *importReader) obj(name string) { r.declare(types.NewConst(pos, r.currPkg, name, typ, val)) - case 'F': - sig := r.signature(nil) - + case 'F', 'G': + var tparams []*typeparams.TypeParam + if tag == 'G' { + tparams = r.tparamList() + } + sig := r.signature(nil, nil, tparams) r.declare(types.NewFunc(pos, r.currPkg, name, sig)) - case 'T': + case 'T', 'U': // Types can be recursive. We need to setup a stub // declaration before recursing. obj := types.NewTypeName(pos, r.currPkg, name, nil) named := types.NewNamed(obj, nil, nil) + // Declare obj before calling r.tparamList, so the new type name is recognized + // if used in the constraint of one of its own typeparams (see #48280). r.declare(obj) + if tag == 'U' { + tparams := r.tparamList() + typeparams.SetForNamed(named, tparams) + } underlying := r.p.typAt(r.uint64(), named).Underlying() named.SetUnderlying(underlying) @@ -335,12 +431,59 @@ func (r *importReader) obj(name string) { mpos := r.pos() mname := r.ident() recv := r.param() - msig := r.signature(recv) + + // If the receiver has any targs, set those as the + // rparams of the method (since those are the + // typeparams being used in the method sig/body). + base := baseType(recv.Type()) + assert(base != nil) + targs := typeparams.NamedTypeArgs(base) + var rparams []*typeparams.TypeParam + if targs.Len() > 0 { + rparams = make([]*typeparams.TypeParam, targs.Len()) + for i := range rparams { + rparams[i] = targs.At(i).(*typeparams.TypeParam) + } + } + msig := r.signature(recv, rparams, nil) named.AddMethod(types.NewFunc(mpos, r.currPkg, mname, msig)) } } + case 'P': + // We need to "declare" a typeparam in order to have a name that + // can be referenced recursively (if needed) in the type param's + // bound. + if r.p.version < iexportVersionGenerics { + errorf("unexpected type param type") + } + name0 := tparamName(name) + tn := types.NewTypeName(pos, r.currPkg, name0, nil) + t := typeparams.NewTypeParam(tn, nil) + + // To handle recursive references to the typeparam within its + // bound, save the partial type in tparamIndex before reading the bounds. + id := ident{r.currPkg, name} + r.p.tparamIndex[id] = t + var implicit bool + if r.p.version >= iexportVersionGo1_18 { + implicit = r.bool() + } + constraint := r.typ() + if implicit { + iface, _ := constraint.(*types.Interface) + if iface == nil { + errorf("non-interface constraint marked implicit") + } + typeparams.MarkImplicit(iface) + } + // The constraint type may not be complete, if we + // are in the middle of a type recursion involving type + // constraints. So, we defer SetConstraint until we have + // completely set up all types in ImportData. + r.p.later = append(r.p.later, setConstraintArgs{t: t, constraint: constraint}) + case 'V': typ := r.typ() @@ -357,6 +500,10 @@ func (r *importReader) declare(obj types.Object) { func (r *importReader) value() (typ types.Type, val constant.Value) { typ = r.typ() + if r.p.version >= iexportVersionGo1_18 { + // TODO: add support for using the kind. + _ = constant.Kind(r.int64()) + } switch b := typ.Underlying().(*types.Basic); b.Info() & types.IsConstType { case types.IsBoolean: @@ -366,7 +513,9 @@ func (r *importReader) value() (typ types.Type, val constant.Value) { val = constant.MakeString(r.string()) case types.IsInteger: - val = r.mpint(b) + var x big.Int + r.mpint(&x, b) + val = constant.Make(&x) case types.IsFloat: val = r.mpfloat(b) @@ -415,8 +564,8 @@ func intSize(b *types.Basic) (signed bool, maxBytes uint) { return } -func (r *importReader) mpint(b *types.Basic) constant.Value { - signed, maxBytes := intSize(b) +func (r *importReader) mpint(x *big.Int, typ *types.Basic) { + signed, maxBytes := intSize(typ) maxSmall := 256 - maxBytes if signed { @@ -435,7 +584,8 @@ func (r *importReader) mpint(b *types.Basic) constant.Value { v = ^v } } - return constant.MakeInt64(v) + x.SetInt64(v) + return } v := -n @@ -445,47 +595,23 @@ func (r *importReader) mpint(b *types.Basic) constant.Value { if v < 1 || uint(v) > maxBytes { errorf("weird decoding: %v, %v => %v", n, signed, v) } - - buf := make([]byte, v) - io.ReadFull(&r.declReader, buf) - - // convert to little endian - // TODO(gri) go/constant should have a more direct conversion function - // (e.g., once it supports a big.Float based implementation) - for i, j := 0, len(buf)-1; i < j; i, j = i+1, j-1 { - buf[i], buf[j] = buf[j], buf[i] - } - - x := constant.MakeFromBytes(buf) + b := make([]byte, v) + io.ReadFull(&r.declReader, b) + x.SetBytes(b) if signed && n&1 != 0 { - x = constant.UnaryOp(token.SUB, x, 0) + x.Neg(x) } - return x } -func (r *importReader) mpfloat(b *types.Basic) constant.Value { - x := r.mpint(b) - if constant.Sign(x) == 0 { - return x +func (r *importReader) mpfloat(typ *types.Basic) constant.Value { + var mant big.Int + r.mpint(&mant, typ) + var f big.Float + f.SetInt(&mant) + if f.Sign() != 0 { + f.SetMantExp(&f, int(r.int64())) } - - exp := r.int64() - switch { - case exp > 0: - x = constant.Shift(x, token.SHL, uint(exp)) - // Ensure that the imported Kind is Float, else this constant may run into - // bitsize limits on overlarge integers. Eventually we can instead adopt - // the approach of CL 288632, but that CL relies on go/constant APIs that - // were introduced in go1.13. - // - // TODO(rFindley): sync the logic here with tip Go once we no longer - // support go1.12. - x = constant.ToFloat(x) - case exp < 0: - d := constant.Shift(constant.MakeInt64(1), token.SHL, uint(-exp)) - x = constant.BinaryOp(x, token.QUO, d) - } - return x + return constant.Make(&f) } func (r *importReader) ident() string { @@ -499,7 +625,7 @@ func (r *importReader) qualifiedIdent() (*types.Package, string) { } func (r *importReader) pos() token.Pos { - if r.p.version >= 1 { + if r.p.version >= iexportVersionPosCol { r.posv1() } else { r.posv0() @@ -547,8 +673,17 @@ func isInterface(t types.Type) bool { func (r *importReader) pkg() *types.Package { return r.p.pkgAt(r.uint64()) } func (r *importReader) string() string { return r.p.stringAt(r.uint64()) } -func (r *importReader) doType(base *types.Named) types.Type { - switch k := r.kind(); k { +func (r *importReader) doType(base *types.Named) (res types.Type) { + k := r.kind() + if debug { + r.p.trace("importing type %d (base: %s)", k, base) + r.p.indent++ + defer func() { + r.p.indent-- + r.p.trace("=> %s", res) + }() + } + switch k { default: errorf("unexpected kind tag in %q: %v", r.p.ipath, k) return nil @@ -571,7 +706,7 @@ func (r *importReader) doType(base *types.Named) types.Type { return types.NewMap(r.typ(), r.typ()) case signatureType: r.currPkg = r.pkg() - return r.signature(nil) + return r.signature(nil, nil, nil) case structType: r.currPkg = r.pkg() @@ -611,13 +746,56 @@ func (r *importReader) doType(base *types.Named) types.Type { recv = types.NewVar(token.NoPos, r.currPkg, "", base) } - msig := r.signature(recv) + msig := r.signature(recv, nil, nil) methods[i] = types.NewFunc(mpos, r.currPkg, mname, msig) } typ := newInterface(methods, embeddeds) r.p.interfaceList = append(r.p.interfaceList, typ) return typ + + case typeParamType: + if r.p.version < iexportVersionGenerics { + errorf("unexpected type param type") + } + pkg, name := r.qualifiedIdent() + id := ident{pkg, name} + if t, ok := r.p.tparamIndex[id]; ok { + // We're already in the process of importing this typeparam. + return t + } + // Otherwise, import the definition of the typeparam now. + r.p.doDecl(pkg, name) + return r.p.tparamIndex[id] + + case instanceType: + if r.p.version < iexportVersionGenerics { + errorf("unexpected instantiation type") + } + // pos does not matter for instances: they are positioned on the original + // type. + _ = r.pos() + len := r.uint64() + targs := make([]types.Type, len) + for i := range targs { + targs[i] = r.typ() + } + baseType := r.typ() + // The imported instantiated type doesn't include any methods, so + // we must always use the methods of the base (orig) type. + // TODO provide a non-nil *Environment + t, _ := typeparams.Instantiate(nil, baseType, targs, false) + return t + + case unionType: + if r.p.version < iexportVersionGenerics { + errorf("unexpected instantiation type") + } + terms := make([]*typeparams.Term, r.uint64()) + for i := range terms { + terms[i] = typeparams.NewTerm(r.bool(), r.typ()) + } + return typeparams.NewUnion(terms) } } @@ -625,11 +803,25 @@ func (r *importReader) kind() itag { return itag(r.uint64()) } -func (r *importReader) signature(recv *types.Var) *types.Signature { +func (r *importReader) signature(recv *types.Var, rparams []*typeparams.TypeParam, tparams []*typeparams.TypeParam) *types.Signature { params := r.paramList() results := r.paramList() variadic := params.Len() > 0 && r.bool() - return types.NewSignature(recv, params, results, variadic) + return typeparams.NewSignatureType(recv, rparams, tparams, params, results, variadic) +} + +func (r *importReader) tparamList() []*typeparams.TypeParam { + n := r.uint64() + if n == 0 { + return nil + } + xs := make([]*typeparams.TypeParam, n) + for i := range xs { + // Note: the standard library importer is tolerant of nil types here, + // though would panic in SetTypeParams. + xs[i] = r.typ().(*typeparams.TypeParam) + } + return xs } func (r *importReader) paramList() *types.Tuple { @@ -674,3 +866,13 @@ func (r *importReader) byte() byte { } return x } + +func baseType(typ types.Type) *types.Named { + // pointer receivers are never types.Named types + if p, _ := typ.(*types.Pointer); p != nil { + typ = p.Elem() + } + // receiver base types are always (possibly generic) types.Named types + n, _ := typ.(*types.Named) + return n +} diff --git a/vendor/golang.org/x/tools/go/internal/gcimporter/support_go117.go b/vendor/golang.org/x/tools/go/internal/gcimporter/support_go117.go new file mode 100644 index 0000000000..d892273efb --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/gcimporter/support_go117.go @@ -0,0 +1,16 @@ +// Copyright 2021 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. + +//go:build !go1.18 +// +build !go1.18 + +package gcimporter + +import "go/types" + +const iexportVersion = iexportVersionGo1_11 + +func additionalPredeclared() []types.Type { + return nil +} diff --git a/vendor/golang.org/x/tools/go/internal/gcimporter/support_go118.go b/vendor/golang.org/x/tools/go/internal/gcimporter/support_go118.go new file mode 100644 index 0000000000..a993843230 --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/gcimporter/support_go118.go @@ -0,0 +1,23 @@ +// Copyright 2021 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. + +//go:build go1.18 +// +build go1.18 + +package gcimporter + +import "go/types" + +const iexportVersion = iexportVersionGenerics + +// additionalPredeclared returns additional predeclared types in go.1.18. +func additionalPredeclared() []types.Type { + return []types.Type{ + // comparable + types.Universe.Lookup("comparable").Type(), + + // any + types.Universe.Lookup("any").Type(), + } +} diff --git a/vendor/golang.org/x/tools/go/internal/gcimporter/unified_no.go b/vendor/golang.org/x/tools/go/internal/gcimporter/unified_no.go new file mode 100644 index 0000000000..286bf44548 --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/gcimporter/unified_no.go @@ -0,0 +1,10 @@ +// Copyright 2022 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. + +//go:build !(go1.18 && goexperiment.unified) +// +build !go1.18 !goexperiment.unified + +package gcimporter + +const unifiedIR = false diff --git a/vendor/golang.org/x/tools/go/internal/gcimporter/unified_yes.go b/vendor/golang.org/x/tools/go/internal/gcimporter/unified_yes.go new file mode 100644 index 0000000000..b5d69ffbe6 --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/gcimporter/unified_yes.go @@ -0,0 +1,10 @@ +// Copyright 2022 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. + +//go:build go1.18 && goexperiment.unified +// +build go1.18,goexperiment.unified + +package gcimporter + +const unifiedIR = true diff --git a/vendor/golang.org/x/tools/go/internal/gcimporter/ureader_no.go b/vendor/golang.org/x/tools/go/internal/gcimporter/ureader_no.go new file mode 100644 index 0000000000..8eb20729c2 --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/gcimporter/ureader_no.go @@ -0,0 +1,19 @@ +// Copyright 2022 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. + +//go:build !go1.18 +// +build !go1.18 + +package gcimporter + +import ( + "fmt" + "go/token" + "go/types" +) + +func UImportData(fset *token.FileSet, imports map[string]*types.Package, data []byte, path string) (_ int, pkg *types.Package, err error) { + err = fmt.Errorf("go/tools compiled with a Go version earlier than 1.18 cannot read unified IR export data") + return +} diff --git a/vendor/golang.org/x/tools/go/internal/gcimporter/ureader_yes.go b/vendor/golang.org/x/tools/go/internal/gcimporter/ureader_yes.go new file mode 100644 index 0000000000..3c1a437543 --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/gcimporter/ureader_yes.go @@ -0,0 +1,612 @@ +// Copyright 2021 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. + +// Derived from go/internal/gcimporter/ureader.go + +//go:build go1.18 +// +build go1.18 + +package gcimporter + +import ( + "go/token" + "go/types" + "strings" + + "golang.org/x/tools/go/internal/pkgbits" +) + +// A pkgReader holds the shared state for reading a unified IR package +// description. +type pkgReader struct { + pkgbits.PkgDecoder + + fake fakeFileSet + + ctxt *types.Context + imports map[string]*types.Package // previously imported packages, indexed by path + + // lazily initialized arrays corresponding to the unified IR + // PosBase, Pkg, and Type sections, respectively. + posBases []string // position bases (i.e., file names) + pkgs []*types.Package + typs []types.Type + + // laterFns holds functions that need to be invoked at the end of + // import reading. + laterFns []func() +} + +// later adds a function to be invoked at the end of import reading. +func (pr *pkgReader) later(fn func()) { + pr.laterFns = append(pr.laterFns, fn) +} + +// See cmd/compile/internal/noder.derivedInfo. +type derivedInfo struct { + idx pkgbits.Index + needed bool +} + +// See cmd/compile/internal/noder.typeInfo. +type typeInfo struct { + idx pkgbits.Index + derived bool +} + +func UImportData(fset *token.FileSet, imports map[string]*types.Package, data []byte, path string) (_ int, pkg *types.Package, err error) { + s := string(data) + s = s[:strings.LastIndex(s, "\n$$\n")] + input := pkgbits.NewPkgDecoder(path, s) + pkg = readUnifiedPackage(fset, nil, imports, input) + return +} + +// readUnifiedPackage reads a package description from the given +// unified IR export data decoder. +func readUnifiedPackage(fset *token.FileSet, ctxt *types.Context, imports map[string]*types.Package, input pkgbits.PkgDecoder) *types.Package { + pr := pkgReader{ + PkgDecoder: input, + + fake: fakeFileSet{ + fset: fset, + files: make(map[string]*fileInfo), + }, + + ctxt: ctxt, + imports: imports, + + posBases: make([]string, input.NumElems(pkgbits.RelocPosBase)), + pkgs: make([]*types.Package, input.NumElems(pkgbits.RelocPkg)), + typs: make([]types.Type, input.NumElems(pkgbits.RelocType)), + } + defer pr.fake.setLines() + + r := pr.newReader(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic) + pkg := r.pkg() + r.Bool() // has init + + for i, n := 0, r.Len(); i < n; i++ { + // As if r.obj(), but avoiding the Scope.Lookup call, + // to avoid eager loading of imports. + r.Sync(pkgbits.SyncObject) + assert(!r.Bool()) + r.p.objIdx(r.Reloc(pkgbits.RelocObj)) + assert(r.Len() == 0) + } + + r.Sync(pkgbits.SyncEOF) + + for _, fn := range pr.laterFns { + fn() + } + + pkg.MarkComplete() + return pkg +} + +// A reader holds the state for reading a single unified IR element +// within a package. +type reader struct { + pkgbits.Decoder + + p *pkgReader + + dict *readerDict +} + +// A readerDict holds the state for type parameters that parameterize +// the current unified IR element. +type readerDict struct { + // bounds is a slice of typeInfos corresponding to the underlying + // bounds of the element's type parameters. + bounds []typeInfo + + // tparams is a slice of the constructed TypeParams for the element. + tparams []*types.TypeParam + + // devived is a slice of types derived from tparams, which may be + // instantiated while reading the current element. + derived []derivedInfo + derivedTypes []types.Type // lazily instantiated from derived +} + +func (pr *pkgReader) newReader(k pkgbits.RelocKind, idx pkgbits.Index, marker pkgbits.SyncMarker) *reader { + return &reader{ + Decoder: pr.NewDecoder(k, idx, marker), + p: pr, + } +} + +// @@@ Positions + +func (r *reader) pos() token.Pos { + r.Sync(pkgbits.SyncPos) + if !r.Bool() { + return token.NoPos + } + + // TODO(mdempsky): Delta encoding. + posBase := r.posBase() + line := r.Uint() + col := r.Uint() + return r.p.fake.pos(posBase, int(line), int(col)) +} + +func (r *reader) posBase() string { + return r.p.posBaseIdx(r.Reloc(pkgbits.RelocPosBase)) +} + +func (pr *pkgReader) posBaseIdx(idx pkgbits.Index) string { + if b := pr.posBases[idx]; b != "" { + return b + } + + r := pr.newReader(pkgbits.RelocPosBase, idx, pkgbits.SyncPosBase) + + // Within types2, position bases have a lot more details (e.g., + // keeping track of where //line directives appeared exactly). + // + // For go/types, we just track the file name. + + filename := r.String() + + if r.Bool() { // file base + // Was: "b = token.NewTrimmedFileBase(filename, true)" + } else { // line base + pos := r.pos() + line := r.Uint() + col := r.Uint() + + // Was: "b = token.NewLineBase(pos, filename, true, line, col)" + _, _, _ = pos, line, col + } + + b := filename + pr.posBases[idx] = b + return b +} + +// @@@ Packages + +func (r *reader) pkg() *types.Package { + r.Sync(pkgbits.SyncPkg) + return r.p.pkgIdx(r.Reloc(pkgbits.RelocPkg)) +} + +func (pr *pkgReader) pkgIdx(idx pkgbits.Index) *types.Package { + // TODO(mdempsky): Consider using some non-nil pointer to indicate + // the universe scope, so we don't need to keep re-reading it. + if pkg := pr.pkgs[idx]; pkg != nil { + return pkg + } + + pkg := pr.newReader(pkgbits.RelocPkg, idx, pkgbits.SyncPkgDef).doPkg() + pr.pkgs[idx] = pkg + return pkg +} + +func (r *reader) doPkg() *types.Package { + path := r.String() + switch path { + case "": + path = r.p.PkgPath() + case "builtin": + return nil // universe + case "unsafe": + return types.Unsafe + } + + if pkg := r.p.imports[path]; pkg != nil { + return pkg + } + + name := r.String() + + pkg := types.NewPackage(path, name) + r.p.imports[path] = pkg + + imports := make([]*types.Package, r.Len()) + for i := range imports { + imports[i] = r.pkg() + } + pkg.SetImports(imports) + + return pkg +} + +// @@@ Types + +func (r *reader) typ() types.Type { + return r.p.typIdx(r.typInfo(), r.dict) +} + +func (r *reader) typInfo() typeInfo { + r.Sync(pkgbits.SyncType) + if r.Bool() { + return typeInfo{idx: pkgbits.Index(r.Len()), derived: true} + } + return typeInfo{idx: r.Reloc(pkgbits.RelocType), derived: false} +} + +func (pr *pkgReader) typIdx(info typeInfo, dict *readerDict) types.Type { + idx := info.idx + var where *types.Type + if info.derived { + where = &dict.derivedTypes[idx] + idx = dict.derived[idx].idx + } else { + where = &pr.typs[idx] + } + + if typ := *where; typ != nil { + return typ + } + + r := pr.newReader(pkgbits.RelocType, idx, pkgbits.SyncTypeIdx) + r.dict = dict + + typ := r.doTyp() + assert(typ != nil) + + // See comment in pkgReader.typIdx explaining how this happens. + if prev := *where; prev != nil { + return prev + } + + *where = typ + return typ +} + +func (r *reader) doTyp() (res types.Type) { + switch tag := pkgbits.CodeType(r.Code(pkgbits.SyncType)); tag { + default: + errorf("unhandled type tag: %v", tag) + panic("unreachable") + + case pkgbits.TypeBasic: + return types.Typ[r.Len()] + + case pkgbits.TypeNamed: + obj, targs := r.obj() + name := obj.(*types.TypeName) + if len(targs) != 0 { + t, _ := types.Instantiate(r.p.ctxt, name.Type(), targs, false) + return t + } + return name.Type() + + case pkgbits.TypeTypeParam: + return r.dict.tparams[r.Len()] + + case pkgbits.TypeArray: + len := int64(r.Uint64()) + return types.NewArray(r.typ(), len) + case pkgbits.TypeChan: + dir := types.ChanDir(r.Len()) + return types.NewChan(dir, r.typ()) + case pkgbits.TypeMap: + return types.NewMap(r.typ(), r.typ()) + case pkgbits.TypePointer: + return types.NewPointer(r.typ()) + case pkgbits.TypeSignature: + return r.signature(nil, nil, nil) + case pkgbits.TypeSlice: + return types.NewSlice(r.typ()) + case pkgbits.TypeStruct: + return r.structType() + case pkgbits.TypeInterface: + return r.interfaceType() + case pkgbits.TypeUnion: + return r.unionType() + } +} + +func (r *reader) structType() *types.Struct { + fields := make([]*types.Var, r.Len()) + var tags []string + for i := range fields { + pos := r.pos() + pkg, name := r.selector() + ftyp := r.typ() + tag := r.String() + embedded := r.Bool() + + fields[i] = types.NewField(pos, pkg, name, ftyp, embedded) + if tag != "" { + for len(tags) < i { + tags = append(tags, "") + } + tags = append(tags, tag) + } + } + return types.NewStruct(fields, tags) +} + +func (r *reader) unionType() *types.Union { + terms := make([]*types.Term, r.Len()) + for i := range terms { + terms[i] = types.NewTerm(r.Bool(), r.typ()) + } + return types.NewUnion(terms) +} + +func (r *reader) interfaceType() *types.Interface { + methods := make([]*types.Func, r.Len()) + embeddeds := make([]types.Type, r.Len()) + implicit := len(methods) == 0 && len(embeddeds) == 1 && r.Bool() + + for i := range methods { + pos := r.pos() + pkg, name := r.selector() + mtyp := r.signature(nil, nil, nil) + methods[i] = types.NewFunc(pos, pkg, name, mtyp) + } + + for i := range embeddeds { + embeddeds[i] = r.typ() + } + + iface := types.NewInterfaceType(methods, embeddeds) + if implicit { + iface.MarkImplicit() + } + return iface +} + +func (r *reader) signature(recv *types.Var, rtparams, tparams []*types.TypeParam) *types.Signature { + r.Sync(pkgbits.SyncSignature) + + params := r.params() + results := r.params() + variadic := r.Bool() + + return types.NewSignatureType(recv, rtparams, tparams, params, results, variadic) +} + +func (r *reader) params() *types.Tuple { + r.Sync(pkgbits.SyncParams) + + params := make([]*types.Var, r.Len()) + for i := range params { + params[i] = r.param() + } + + return types.NewTuple(params...) +} + +func (r *reader) param() *types.Var { + r.Sync(pkgbits.SyncParam) + + pos := r.pos() + pkg, name := r.localIdent() + typ := r.typ() + + return types.NewParam(pos, pkg, name, typ) +} + +// @@@ Objects + +func (r *reader) obj() (types.Object, []types.Type) { + r.Sync(pkgbits.SyncObject) + + assert(!r.Bool()) + + pkg, name := r.p.objIdx(r.Reloc(pkgbits.RelocObj)) + obj := pkgScope(pkg).Lookup(name) + + targs := make([]types.Type, r.Len()) + for i := range targs { + targs[i] = r.typ() + } + + return obj, targs +} + +func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types.Package, string) { + rname := pr.newReader(pkgbits.RelocName, idx, pkgbits.SyncObject1) + + objPkg, objName := rname.qualifiedIdent() + assert(objName != "") + + tag := pkgbits.CodeObj(rname.Code(pkgbits.SyncCodeObj)) + + if tag == pkgbits.ObjStub { + assert(objPkg == nil || objPkg == types.Unsafe) + return objPkg, objName + } + + if objPkg.Scope().Lookup(objName) == nil { + dict := pr.objDictIdx(idx) + + r := pr.newReader(pkgbits.RelocObj, idx, pkgbits.SyncObject1) + r.dict = dict + + declare := func(obj types.Object) { + objPkg.Scope().Insert(obj) + } + + switch tag { + default: + panic("weird") + + case pkgbits.ObjAlias: + pos := r.pos() + typ := r.typ() + declare(types.NewTypeName(pos, objPkg, objName, typ)) + + case pkgbits.ObjConst: + pos := r.pos() + typ := r.typ() + val := r.Value() + declare(types.NewConst(pos, objPkg, objName, typ, val)) + + case pkgbits.ObjFunc: + pos := r.pos() + tparams := r.typeParamNames() + sig := r.signature(nil, nil, tparams) + declare(types.NewFunc(pos, objPkg, objName, sig)) + + case pkgbits.ObjType: + pos := r.pos() + + obj := types.NewTypeName(pos, objPkg, objName, nil) + named := types.NewNamed(obj, nil, nil) + declare(obj) + + named.SetTypeParams(r.typeParamNames()) + + // TODO(mdempsky): Rewrite receiver types to underlying is an + // Interface? The go/types importer does this (I think because + // unit tests expected that), but cmd/compile doesn't care + // about it, so maybe we can avoid worrying about that here. + rhs := r.typ() + r.p.later(func() { + underlying := rhs.Underlying() + named.SetUnderlying(underlying) + }) + + for i, n := 0, r.Len(); i < n; i++ { + named.AddMethod(r.method()) + } + + case pkgbits.ObjVar: + pos := r.pos() + typ := r.typ() + declare(types.NewVar(pos, objPkg, objName, typ)) + } + } + + return objPkg, objName +} + +func (pr *pkgReader) objDictIdx(idx pkgbits.Index) *readerDict { + r := pr.newReader(pkgbits.RelocObjDict, idx, pkgbits.SyncObject1) + + var dict readerDict + + if implicits := r.Len(); implicits != 0 { + errorf("unexpected object with %v implicit type parameter(s)", implicits) + } + + dict.bounds = make([]typeInfo, r.Len()) + for i := range dict.bounds { + dict.bounds[i] = r.typInfo() + } + + dict.derived = make([]derivedInfo, r.Len()) + dict.derivedTypes = make([]types.Type, len(dict.derived)) + for i := range dict.derived { + dict.derived[i] = derivedInfo{r.Reloc(pkgbits.RelocType), r.Bool()} + } + + // function references follow, but reader doesn't need those + + return &dict +} + +func (r *reader) typeParamNames() []*types.TypeParam { + r.Sync(pkgbits.SyncTypeParamNames) + + // Note: This code assumes it only processes objects without + // implement type parameters. This is currently fine, because + // reader is only used to read in exported declarations, which are + // always package scoped. + + if len(r.dict.bounds) == 0 { + return nil + } + + // Careful: Type parameter lists may have cycles. To allow for this, + // we construct the type parameter list in two passes: first we + // create all the TypeNames and TypeParams, then we construct and + // set the bound type. + + r.dict.tparams = make([]*types.TypeParam, len(r.dict.bounds)) + for i := range r.dict.bounds { + pos := r.pos() + pkg, name := r.localIdent() + + tname := types.NewTypeName(pos, pkg, name, nil) + r.dict.tparams[i] = types.NewTypeParam(tname, nil) + } + + typs := make([]types.Type, len(r.dict.bounds)) + for i, bound := range r.dict.bounds { + typs[i] = r.p.typIdx(bound, r.dict) + } + + // TODO(mdempsky): This is subtle, elaborate further. + // + // We have to save tparams outside of the closure, because + // typeParamNames() can be called multiple times with the same + // dictionary instance. + // + // Also, this needs to happen later to make sure SetUnderlying has + // been called. + // + // TODO(mdempsky): Is it safe to have a single "later" slice or do + // we need to have multiple passes? See comments on CL 386002 and + // go.dev/issue/52104. + tparams := r.dict.tparams + r.p.later(func() { + for i, typ := range typs { + tparams[i].SetConstraint(typ) + } + }) + + return r.dict.tparams +} + +func (r *reader) method() *types.Func { + r.Sync(pkgbits.SyncMethod) + pos := r.pos() + pkg, name := r.selector() + + rparams := r.typeParamNames() + sig := r.signature(r.param(), rparams, nil) + + _ = r.pos() // TODO(mdempsky): Remove; this is a hacker for linker.go. + return types.NewFunc(pos, pkg, name, sig) +} + +func (r *reader) qualifiedIdent() (*types.Package, string) { return r.ident(pkgbits.SyncSym) } +func (r *reader) localIdent() (*types.Package, string) { return r.ident(pkgbits.SyncLocalIdent) } +func (r *reader) selector() (*types.Package, string) { return r.ident(pkgbits.SyncSelector) } + +func (r *reader) ident(marker pkgbits.SyncMarker) (*types.Package, string) { + r.Sync(marker) + return r.pkg(), r.String() +} + +// pkgScope returns pkg.Scope(). +// If pkg is nil, it returns types.Universe instead. +// +// TODO(mdempsky): Remove after x/tools can depend on Go 1.19. +func pkgScope(pkg *types.Package) *types.Scope { + if pkg != nil { + return pkg.Scope() + } + return types.Universe +} diff --git a/vendor/golang.org/x/tools/go/internal/pkgbits/codes.go b/vendor/golang.org/x/tools/go/internal/pkgbits/codes.go new file mode 100644 index 0000000000..f0cabde96e --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/pkgbits/codes.go @@ -0,0 +1,77 @@ +// Copyright 2021 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. + +package pkgbits + +// A Code is an enum value that can be encoded into bitstreams. +// +// Code types are preferable for enum types, because they allow +// Decoder to detect desyncs. +type Code interface { + // Marker returns the SyncMarker for the Code's dynamic type. + Marker() SyncMarker + + // Value returns the Code's ordinal value. + Value() int +} + +// A CodeVal distinguishes among go/constant.Value encodings. +type CodeVal int + +func (c CodeVal) Marker() SyncMarker { return SyncVal } +func (c CodeVal) Value() int { return int(c) } + +// Note: These values are public and cannot be changed without +// updating the go/types importers. + +const ( + ValBool CodeVal = iota + ValString + ValInt64 + ValBigInt + ValBigRat + ValBigFloat +) + +// A CodeType distinguishes among go/types.Type encodings. +type CodeType int + +func (c CodeType) Marker() SyncMarker { return SyncType } +func (c CodeType) Value() int { return int(c) } + +// Note: These values are public and cannot be changed without +// updating the go/types importers. + +const ( + TypeBasic CodeType = iota + TypeNamed + TypePointer + TypeSlice + TypeArray + TypeChan + TypeMap + TypeSignature + TypeStruct + TypeInterface + TypeUnion + TypeTypeParam +) + +// A CodeObj distinguishes among go/types.Object encodings. +type CodeObj int + +func (c CodeObj) Marker() SyncMarker { return SyncCodeObj } +func (c CodeObj) Value() int { return int(c) } + +// Note: These values are public and cannot be changed without +// updating the go/types importers. + +const ( + ObjAlias CodeObj = iota + ObjConst + ObjType + ObjFunc + ObjVar + ObjStub +) diff --git a/vendor/golang.org/x/tools/go/internal/pkgbits/decoder.go b/vendor/golang.org/x/tools/go/internal/pkgbits/decoder.go new file mode 100644 index 0000000000..2bc793668e --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/pkgbits/decoder.go @@ -0,0 +1,433 @@ +// Copyright 2021 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. + +package pkgbits + +import ( + "encoding/binary" + "fmt" + "go/constant" + "go/token" + "math/big" + "os" + "runtime" + "strings" +) + +// A PkgDecoder provides methods for decoding a package's Unified IR +// export data. +type PkgDecoder struct { + // version is the file format version. + version uint32 + + // sync indicates whether the file uses sync markers. + sync bool + + // pkgPath is the package path for the package to be decoded. + // + // TODO(mdempsky): Remove; unneeded since CL 391014. + pkgPath string + + // elemData is the full data payload of the encoded package. + // Elements are densely and contiguously packed together. + // + // The last 8 bytes of elemData are the package fingerprint. + elemData string + + // elemEnds stores the byte-offset end positions of element + // bitstreams within elemData. + // + // For example, element I's bitstream data starts at elemEnds[I-1] + // (or 0, if I==0) and ends at elemEnds[I]. + // + // Note: elemEnds is indexed by absolute indices, not + // section-relative indices. + elemEnds []uint32 + + // elemEndsEnds stores the index-offset end positions of relocation + // sections within elemEnds. + // + // For example, section K's end positions start at elemEndsEnds[K-1] + // (or 0, if K==0) and end at elemEndsEnds[K]. + elemEndsEnds [numRelocs]uint32 +} + +// PkgPath returns the package path for the package +// +// TODO(mdempsky): Remove; unneeded since CL 391014. +func (pr *PkgDecoder) PkgPath() string { return pr.pkgPath } + +// SyncMarkers reports whether pr uses sync markers. +func (pr *PkgDecoder) SyncMarkers() bool { return pr.sync } + +// NewPkgDecoder returns a PkgDecoder initialized to read the Unified +// IR export data from input. pkgPath is the package path for the +// compilation unit that produced the export data. +// +// TODO(mdempsky): Remove pkgPath parameter; unneeded since CL 391014. +func NewPkgDecoder(pkgPath, input string) PkgDecoder { + pr := PkgDecoder{ + pkgPath: pkgPath, + } + + // TODO(mdempsky): Implement direct indexing of input string to + // avoid copying the position information. + + r := strings.NewReader(input) + + assert(binary.Read(r, binary.LittleEndian, &pr.version) == nil) + + switch pr.version { + default: + panic(fmt.Errorf("unsupported version: %v", pr.version)) + case 0: + // no flags + case 1: + var flags uint32 + assert(binary.Read(r, binary.LittleEndian, &flags) == nil) + pr.sync = flags&flagSyncMarkers != 0 + } + + assert(binary.Read(r, binary.LittleEndian, pr.elemEndsEnds[:]) == nil) + + pr.elemEnds = make([]uint32, pr.elemEndsEnds[len(pr.elemEndsEnds)-1]) + assert(binary.Read(r, binary.LittleEndian, pr.elemEnds[:]) == nil) + + pos, err := r.Seek(0, os.SEEK_CUR) + assert(err == nil) + + pr.elemData = input[pos:] + assert(len(pr.elemData)-8 == int(pr.elemEnds[len(pr.elemEnds)-1])) + + return pr +} + +// NumElems returns the number of elements in section k. +func (pr *PkgDecoder) NumElems(k RelocKind) int { + count := int(pr.elemEndsEnds[k]) + if k > 0 { + count -= int(pr.elemEndsEnds[k-1]) + } + return count +} + +// TotalElems returns the total number of elements across all sections. +func (pr *PkgDecoder) TotalElems() int { + return len(pr.elemEnds) +} + +// Fingerprint returns the package fingerprint. +func (pr *PkgDecoder) Fingerprint() [8]byte { + var fp [8]byte + copy(fp[:], pr.elemData[len(pr.elemData)-8:]) + return fp +} + +// AbsIdx returns the absolute index for the given (section, index) +// pair. +func (pr *PkgDecoder) AbsIdx(k RelocKind, idx Index) int { + absIdx := int(idx) + if k > 0 { + absIdx += int(pr.elemEndsEnds[k-1]) + } + if absIdx >= int(pr.elemEndsEnds[k]) { + errorf("%v:%v is out of bounds; %v", k, idx, pr.elemEndsEnds) + } + return absIdx +} + +// DataIdx returns the raw element bitstream for the given (section, +// index) pair. +func (pr *PkgDecoder) DataIdx(k RelocKind, idx Index) string { + absIdx := pr.AbsIdx(k, idx) + + var start uint32 + if absIdx > 0 { + start = pr.elemEnds[absIdx-1] + } + end := pr.elemEnds[absIdx] + + return pr.elemData[start:end] +} + +// StringIdx returns the string value for the given string index. +func (pr *PkgDecoder) StringIdx(idx Index) string { + return pr.DataIdx(RelocString, idx) +} + +// NewDecoder returns a Decoder for the given (section, index) pair, +// and decodes the given SyncMarker from the element bitstream. +func (pr *PkgDecoder) NewDecoder(k RelocKind, idx Index, marker SyncMarker) Decoder { + r := pr.NewDecoderRaw(k, idx) + r.Sync(marker) + return r +} + +// NewDecoderRaw returns a Decoder for the given (section, index) pair. +// +// Most callers should use NewDecoder instead. +func (pr *PkgDecoder) NewDecoderRaw(k RelocKind, idx Index) Decoder { + r := Decoder{ + common: pr, + k: k, + Idx: idx, + } + + // TODO(mdempsky) r.data.Reset(...) after #44505 is resolved. + r.Data = *strings.NewReader(pr.DataIdx(k, idx)) + + r.Sync(SyncRelocs) + r.Relocs = make([]RelocEnt, r.Len()) + for i := range r.Relocs { + r.Sync(SyncReloc) + r.Relocs[i] = RelocEnt{RelocKind(r.Len()), Index(r.Len())} + } + + return r +} + +// A Decoder provides methods for decoding an individual element's +// bitstream data. +type Decoder struct { + common *PkgDecoder + + Relocs []RelocEnt + Data strings.Reader + + k RelocKind + Idx Index +} + +func (r *Decoder) checkErr(err error) { + if err != nil { + errorf("unexpected decoding error: %w", err) + } +} + +func (r *Decoder) rawUvarint() uint64 { + x, err := binary.ReadUvarint(&r.Data) + r.checkErr(err) + return x +} + +func (r *Decoder) rawVarint() int64 { + ux := r.rawUvarint() + + // Zig-zag decode. + x := int64(ux >> 1) + if ux&1 != 0 { + x = ^x + } + return x +} + +func (r *Decoder) rawReloc(k RelocKind, idx int) Index { + e := r.Relocs[idx] + assert(e.Kind == k) + return e.Idx +} + +// Sync decodes a sync marker from the element bitstream and asserts +// that it matches the expected marker. +// +// If r.common.sync is false, then Sync is a no-op. +func (r *Decoder) Sync(mWant SyncMarker) { + if !r.common.sync { + return + } + + pos, _ := r.Data.Seek(0, os.SEEK_CUR) // TODO(mdempsky): io.SeekCurrent after #44505 is resolved + mHave := SyncMarker(r.rawUvarint()) + writerPCs := make([]int, r.rawUvarint()) + for i := range writerPCs { + writerPCs[i] = int(r.rawUvarint()) + } + + if mHave == mWant { + return + } + + // There's some tension here between printing: + // + // (1) full file paths that tools can recognize (e.g., so emacs + // hyperlinks the "file:line" text for easy navigation), or + // + // (2) short file paths that are easier for humans to read (e.g., by + // omitting redundant or irrelevant details, so it's easier to + // focus on the useful bits that remain). + // + // The current formatting favors the former, as it seems more + // helpful in practice. But perhaps the formatting could be improved + // to better address both concerns. For example, use relative file + // paths if they would be shorter, or rewrite file paths to contain + // "$GOROOT" (like objabi.AbsFile does) if tools can be taught how + // to reliably expand that again. + + fmt.Printf("export data desync: package %q, section %v, index %v, offset %v\n", r.common.pkgPath, r.k, r.Idx, pos) + + fmt.Printf("\nfound %v, written at:\n", mHave) + if len(writerPCs) == 0 { + fmt.Printf("\t[stack trace unavailable; recompile package %q with -d=syncframes]\n", r.common.pkgPath) + } + for _, pc := range writerPCs { + fmt.Printf("\t%s\n", r.common.StringIdx(r.rawReloc(RelocString, pc))) + } + + fmt.Printf("\nexpected %v, reading at:\n", mWant) + var readerPCs [32]uintptr // TODO(mdempsky): Dynamically size? + n := runtime.Callers(2, readerPCs[:]) + for _, pc := range fmtFrames(readerPCs[:n]...) { + fmt.Printf("\t%s\n", pc) + } + + // We already printed a stack trace for the reader, so now we can + // simply exit. Printing a second one with panic or base.Fatalf + // would just be noise. + os.Exit(1) +} + +// Bool decodes and returns a bool value from the element bitstream. +func (r *Decoder) Bool() bool { + r.Sync(SyncBool) + x, err := r.Data.ReadByte() + r.checkErr(err) + assert(x < 2) + return x != 0 +} + +// Int64 decodes and returns an int64 value from the element bitstream. +func (r *Decoder) Int64() int64 { + r.Sync(SyncInt64) + return r.rawVarint() +} + +// Int64 decodes and returns a uint64 value from the element bitstream. +func (r *Decoder) Uint64() uint64 { + r.Sync(SyncUint64) + return r.rawUvarint() +} + +// Len decodes and returns a non-negative int value from the element bitstream. +func (r *Decoder) Len() int { x := r.Uint64(); v := int(x); assert(uint64(v) == x); return v } + +// Int decodes and returns an int value from the element bitstream. +func (r *Decoder) Int() int { x := r.Int64(); v := int(x); assert(int64(v) == x); return v } + +// Uint decodes and returns a uint value from the element bitstream. +func (r *Decoder) Uint() uint { x := r.Uint64(); v := uint(x); assert(uint64(v) == x); return v } + +// Code decodes a Code value from the element bitstream and returns +// its ordinal value. It's the caller's responsibility to convert the +// result to an appropriate Code type. +// +// TODO(mdempsky): Ideally this method would have signature "Code[T +// Code] T" instead, but we don't allow generic methods and the +// compiler can't depend on generics yet anyway. +func (r *Decoder) Code(mark SyncMarker) int { + r.Sync(mark) + return r.Len() +} + +// Reloc decodes a relocation of expected section k from the element +// bitstream and returns an index to the referenced element. +func (r *Decoder) Reloc(k RelocKind) Index { + r.Sync(SyncUseReloc) + return r.rawReloc(k, r.Len()) +} + +// String decodes and returns a string value from the element +// bitstream. +func (r *Decoder) String() string { + r.Sync(SyncString) + return r.common.StringIdx(r.Reloc(RelocString)) +} + +// Strings decodes and returns a variable-length slice of strings from +// the element bitstream. +func (r *Decoder) Strings() []string { + res := make([]string, r.Len()) + for i := range res { + res[i] = r.String() + } + return res +} + +// Value decodes and returns a constant.Value from the element +// bitstream. +func (r *Decoder) Value() constant.Value { + r.Sync(SyncValue) + isComplex := r.Bool() + val := r.scalar() + if isComplex { + val = constant.BinaryOp(val, token.ADD, constant.MakeImag(r.scalar())) + } + return val +} + +func (r *Decoder) scalar() constant.Value { + switch tag := CodeVal(r.Code(SyncVal)); tag { + default: + panic(fmt.Errorf("unexpected scalar tag: %v", tag)) + + case ValBool: + return constant.MakeBool(r.Bool()) + case ValString: + return constant.MakeString(r.String()) + case ValInt64: + return constant.MakeInt64(r.Int64()) + case ValBigInt: + return constant.Make(r.bigInt()) + case ValBigRat: + num := r.bigInt() + denom := r.bigInt() + return constant.Make(new(big.Rat).SetFrac(num, denom)) + case ValBigFloat: + return constant.Make(r.bigFloat()) + } +} + +func (r *Decoder) bigInt() *big.Int { + v := new(big.Int).SetBytes([]byte(r.String())) + if r.Bool() { + v.Neg(v) + } + return v +} + +func (r *Decoder) bigFloat() *big.Float { + v := new(big.Float).SetPrec(512) + assert(v.UnmarshalText([]byte(r.String())) == nil) + return v +} + +// @@@ Helpers + +// TODO(mdempsky): These should probably be removed. I think they're a +// smell that the export data format is not yet quite right. + +// PeekPkgPath returns the package path for the specified package +// index. +func (pr *PkgDecoder) PeekPkgPath(idx Index) string { + r := pr.NewDecoder(RelocPkg, idx, SyncPkgDef) + path := r.String() + if path == "" { + path = pr.pkgPath + } + return path +} + +// PeekObj returns the package path, object name, and CodeObj for the +// specified object index. +func (pr *PkgDecoder) PeekObj(idx Index) (string, string, CodeObj) { + r := pr.NewDecoder(RelocName, idx, SyncObject1) + r.Sync(SyncSym) + r.Sync(SyncPkg) + path := pr.PeekPkgPath(r.Reloc(RelocPkg)) + name := r.String() + assert(name != "") + + tag := CodeObj(r.Code(SyncCodeObj)) + + return path, name, tag +} diff --git a/vendor/golang.org/x/tools/go/internal/pkgbits/doc.go b/vendor/golang.org/x/tools/go/internal/pkgbits/doc.go new file mode 100644 index 0000000000..c8a2796b5e --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/pkgbits/doc.go @@ -0,0 +1,32 @@ +// Copyright 2022 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. + +// Package pkgbits implements low-level coding abstractions for +// Unified IR's export data format. +// +// At a low-level, a package is a collection of bitstream elements. +// Each element has a "kind" and a dense, non-negative index. +// Elements can be randomly accessed given their kind and index. +// +// Individual elements are sequences of variable-length values (e.g., +// integers, booleans, strings, go/constant values, cross-references +// to other elements). Package pkgbits provides APIs for encoding and +// decoding these low-level values, but the details of mapping +// higher-level Go constructs into elements is left to higher-level +// abstractions. +// +// Elements may cross-reference each other with "relocations." For +// example, an element representing a pointer type has a relocation +// referring to the element type. +// +// Go constructs may be composed as a constellation of multiple +// elements. For example, a declared function may have one element to +// describe the object (e.g., its name, type, position), and a +// separate element to describe its function body. This allows readers +// some flexibility in efficiently seeking or re-reading data (e.g., +// inlining requires re-reading the function body for each inlined +// call, without needing to re-read the object-level details). +// +// This is a copy of internal/pkgbits in the Go implementation. +package pkgbits diff --git a/vendor/golang.org/x/tools/go/internal/pkgbits/encoder.go b/vendor/golang.org/x/tools/go/internal/pkgbits/encoder.go new file mode 100644 index 0000000000..c50c838caa --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/pkgbits/encoder.go @@ -0,0 +1,379 @@ +// Copyright 2021 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. + +package pkgbits + +import ( + "bytes" + "crypto/md5" + "encoding/binary" + "go/constant" + "io" + "math/big" + "runtime" +) + +// currentVersion is the current version number. +// +// - v0: initial prototype +// +// - v1: adds the flags uint32 word +const currentVersion uint32 = 1 + +// A PkgEncoder provides methods for encoding a package's Unified IR +// export data. +type PkgEncoder struct { + // elems holds the bitstream for previously encoded elements. + elems [numRelocs][]string + + // stringsIdx maps previously encoded strings to their index within + // the RelocString section, to allow deduplication. That is, + // elems[RelocString][stringsIdx[s]] == s (if present). + stringsIdx map[string]Index + + // syncFrames is the number of frames to write at each sync + // marker. A negative value means sync markers are omitted. + syncFrames int +} + +// SyncMarkers reports whether pw uses sync markers. +func (pw *PkgEncoder) SyncMarkers() bool { return pw.syncFrames >= 0 } + +// NewPkgEncoder returns an initialized PkgEncoder. +// +// syncFrames is the number of caller frames that should be serialized +// at Sync points. Serializing additional frames results in larger +// export data files, but can help diagnosing desync errors in +// higher-level Unified IR reader/writer code. If syncFrames is +// negative, then sync markers are omitted entirely. +func NewPkgEncoder(syncFrames int) PkgEncoder { + return PkgEncoder{ + stringsIdx: make(map[string]Index), + syncFrames: syncFrames, + } +} + +// DumpTo writes the package's encoded data to out0 and returns the +// package fingerprint. +func (pw *PkgEncoder) DumpTo(out0 io.Writer) (fingerprint [8]byte) { + h := md5.New() + out := io.MultiWriter(out0, h) + + writeUint32 := func(x uint32) { + assert(binary.Write(out, binary.LittleEndian, x) == nil) + } + + writeUint32(currentVersion) + + var flags uint32 + if pw.SyncMarkers() { + flags |= flagSyncMarkers + } + writeUint32(flags) + + // Write elemEndsEnds. + var sum uint32 + for _, elems := range &pw.elems { + sum += uint32(len(elems)) + writeUint32(sum) + } + + // Write elemEnds. + sum = 0 + for _, elems := range &pw.elems { + for _, elem := range elems { + sum += uint32(len(elem)) + writeUint32(sum) + } + } + + // Write elemData. + for _, elems := range &pw.elems { + for _, elem := range elems { + _, err := io.WriteString(out, elem) + assert(err == nil) + } + } + + // Write fingerprint. + copy(fingerprint[:], h.Sum(nil)) + _, err := out0.Write(fingerprint[:]) + assert(err == nil) + + return +} + +// StringIdx adds a string value to the strings section, if not +// already present, and returns its index. +func (pw *PkgEncoder) StringIdx(s string) Index { + if idx, ok := pw.stringsIdx[s]; ok { + assert(pw.elems[RelocString][idx] == s) + return idx + } + + idx := Index(len(pw.elems[RelocString])) + pw.elems[RelocString] = append(pw.elems[RelocString], s) + pw.stringsIdx[s] = idx + return idx +} + +// NewEncoder returns an Encoder for a new element within the given +// section, and encodes the given SyncMarker as the start of the +// element bitstream. +func (pw *PkgEncoder) NewEncoder(k RelocKind, marker SyncMarker) Encoder { + e := pw.NewEncoderRaw(k) + e.Sync(marker) + return e +} + +// NewEncoderRaw returns an Encoder for a new element within the given +// section. +// +// Most callers should use NewEncoder instead. +func (pw *PkgEncoder) NewEncoderRaw(k RelocKind) Encoder { + idx := Index(len(pw.elems[k])) + pw.elems[k] = append(pw.elems[k], "") // placeholder + + return Encoder{ + p: pw, + k: k, + Idx: idx, + } +} + +// An Encoder provides methods for encoding an individual element's +// bitstream data. +type Encoder struct { + p *PkgEncoder + + Relocs []RelocEnt + Data bytes.Buffer // accumulated element bitstream data + + encodingRelocHeader bool + + k RelocKind + Idx Index // index within relocation section +} + +// Flush finalizes the element's bitstream and returns its Index. +func (w *Encoder) Flush() Index { + var sb bytes.Buffer // TODO(mdempsky): strings.Builder after #44505 is resolved + + // Backup the data so we write the relocations at the front. + var tmp bytes.Buffer + io.Copy(&tmp, &w.Data) + + // TODO(mdempsky): Consider writing these out separately so they're + // easier to strip, along with function bodies, so that we can prune + // down to just the data that's relevant to go/types. + if w.encodingRelocHeader { + panic("encodingRelocHeader already true; recursive flush?") + } + w.encodingRelocHeader = true + w.Sync(SyncRelocs) + w.Len(len(w.Relocs)) + for _, rEnt := range w.Relocs { + w.Sync(SyncReloc) + w.Len(int(rEnt.Kind)) + w.Len(int(rEnt.Idx)) + } + + io.Copy(&sb, &w.Data) + io.Copy(&sb, &tmp) + w.p.elems[w.k][w.Idx] = sb.String() + + return w.Idx +} + +func (w *Encoder) checkErr(err error) { + if err != nil { + errorf("unexpected encoding error: %v", err) + } +} + +func (w *Encoder) rawUvarint(x uint64) { + var buf [binary.MaxVarintLen64]byte + n := binary.PutUvarint(buf[:], x) + _, err := w.Data.Write(buf[:n]) + w.checkErr(err) +} + +func (w *Encoder) rawVarint(x int64) { + // Zig-zag encode. + ux := uint64(x) << 1 + if x < 0 { + ux = ^ux + } + + w.rawUvarint(ux) +} + +func (w *Encoder) rawReloc(r RelocKind, idx Index) int { + // TODO(mdempsky): Use map for lookup; this takes quadratic time. + for i, rEnt := range w.Relocs { + if rEnt.Kind == r && rEnt.Idx == idx { + return i + } + } + + i := len(w.Relocs) + w.Relocs = append(w.Relocs, RelocEnt{r, idx}) + return i +} + +func (w *Encoder) Sync(m SyncMarker) { + if !w.p.SyncMarkers() { + return + } + + // Writing out stack frame string references requires working + // relocations, but writing out the relocations themselves involves + // sync markers. To prevent infinite recursion, we simply trim the + // stack frame for sync markers within the relocation header. + var frames []string + if !w.encodingRelocHeader && w.p.syncFrames > 0 { + pcs := make([]uintptr, w.p.syncFrames) + n := runtime.Callers(2, pcs) + frames = fmtFrames(pcs[:n]...) + } + + // TODO(mdempsky): Save space by writing out stack frames as a + // linked list so we can share common stack frames. + w.rawUvarint(uint64(m)) + w.rawUvarint(uint64(len(frames))) + for _, frame := range frames { + w.rawUvarint(uint64(w.rawReloc(RelocString, w.p.StringIdx(frame)))) + } +} + +// Bool encodes and writes a bool value into the element bitstream, +// and then returns the bool value. +// +// For simple, 2-alternative encodings, the idiomatic way to call Bool +// is something like: +// +// if w.Bool(x != 0) { +// // alternative #1 +// } else { +// // alternative #2 +// } +// +// For multi-alternative encodings, use Code instead. +func (w *Encoder) Bool(b bool) bool { + w.Sync(SyncBool) + var x byte + if b { + x = 1 + } + err := w.Data.WriteByte(x) + w.checkErr(err) + return b +} + +// Int64 encodes and writes an int64 value into the element bitstream. +func (w *Encoder) Int64(x int64) { + w.Sync(SyncInt64) + w.rawVarint(x) +} + +// Uint64 encodes and writes a uint64 value into the element bitstream. +func (w *Encoder) Uint64(x uint64) { + w.Sync(SyncUint64) + w.rawUvarint(x) +} + +// Len encodes and writes a non-negative int value into the element bitstream. +func (w *Encoder) Len(x int) { assert(x >= 0); w.Uint64(uint64(x)) } + +// Int encodes and writes an int value into the element bitstream. +func (w *Encoder) Int(x int) { w.Int64(int64(x)) } + +// Len encodes and writes a uint value into the element bitstream. +func (w *Encoder) Uint(x uint) { w.Uint64(uint64(x)) } + +// Reloc encodes and writes a relocation for the given (section, +// index) pair into the element bitstream. +// +// Note: Only the index is formally written into the element +// bitstream, so bitstream decoders must know from context which +// section an encoded relocation refers to. +func (w *Encoder) Reloc(r RelocKind, idx Index) { + w.Sync(SyncUseReloc) + w.Len(w.rawReloc(r, idx)) +} + +// Code encodes and writes a Code value into the element bitstream. +func (w *Encoder) Code(c Code) { + w.Sync(c.Marker()) + w.Len(c.Value()) +} + +// String encodes and writes a string value into the element +// bitstream. +// +// Internally, strings are deduplicated by adding them to the strings +// section (if not already present), and then writing a relocation +// into the element bitstream. +func (w *Encoder) String(s string) { + w.Sync(SyncString) + w.Reloc(RelocString, w.p.StringIdx(s)) +} + +// Strings encodes and writes a variable-length slice of strings into +// the element bitstream. +func (w *Encoder) Strings(ss []string) { + w.Len(len(ss)) + for _, s := range ss { + w.String(s) + } +} + +// Value encodes and writes a constant.Value into the element +// bitstream. +func (w *Encoder) Value(val constant.Value) { + w.Sync(SyncValue) + if w.Bool(val.Kind() == constant.Complex) { + w.scalar(constant.Real(val)) + w.scalar(constant.Imag(val)) + } else { + w.scalar(val) + } +} + +func (w *Encoder) scalar(val constant.Value) { + switch v := constant.Val(val).(type) { + default: + errorf("unhandled %v (%v)", val, val.Kind()) + case bool: + w.Code(ValBool) + w.Bool(v) + case string: + w.Code(ValString) + w.String(v) + case int64: + w.Code(ValInt64) + w.Int64(v) + case *big.Int: + w.Code(ValBigInt) + w.bigInt(v) + case *big.Rat: + w.Code(ValBigRat) + w.bigInt(v.Num()) + w.bigInt(v.Denom()) + case *big.Float: + w.Code(ValBigFloat) + w.bigFloat(v) + } +} + +func (w *Encoder) bigInt(v *big.Int) { + b := v.Bytes() + w.String(string(b)) // TODO: More efficient encoding. + w.Bool(v.Sign() < 0) +} + +func (w *Encoder) bigFloat(v *big.Float) { + b := v.Append(nil, 'p', -1) + w.String(string(b)) // TODO: More efficient encoding. +} diff --git a/vendor/golang.org/x/tools/go/internal/pkgbits/flags.go b/vendor/golang.org/x/tools/go/internal/pkgbits/flags.go new file mode 100644 index 0000000000..654222745f --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/pkgbits/flags.go @@ -0,0 +1,9 @@ +// Copyright 2022 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. + +package pkgbits + +const ( + flagSyncMarkers = 1 << iota // file format contains sync markers +) diff --git a/vendor/golang.org/x/tools/go/internal/pkgbits/frames_go1.go b/vendor/golang.org/x/tools/go/internal/pkgbits/frames_go1.go new file mode 100644 index 0000000000..5294f6a63e --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/pkgbits/frames_go1.go @@ -0,0 +1,21 @@ +// Copyright 2021 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. + +//go:build !go1.7 +// +build !go1.7 + +// TODO(mdempsky): Remove after #44505 is resolved + +package pkgbits + +import "runtime" + +func walkFrames(pcs []uintptr, visit frameVisitor) { + for _, pc := range pcs { + fn := runtime.FuncForPC(pc) + file, line := fn.FileLine(pc) + + visit(file, line, fn.Name(), pc-fn.Entry()) + } +} diff --git a/vendor/golang.org/x/tools/go/internal/pkgbits/frames_go17.go b/vendor/golang.org/x/tools/go/internal/pkgbits/frames_go17.go new file mode 100644 index 0000000000..2324ae7adf --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/pkgbits/frames_go17.go @@ -0,0 +1,28 @@ +// Copyright 2021 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. + +//go:build go1.7 +// +build go1.7 + +package pkgbits + +import "runtime" + +// walkFrames calls visit for each call frame represented by pcs. +// +// pcs should be a slice of PCs, as returned by runtime.Callers. +func walkFrames(pcs []uintptr, visit frameVisitor) { + if len(pcs) == 0 { + return + } + + frames := runtime.CallersFrames(pcs) + for { + frame, more := frames.Next() + visit(frame.File, frame.Line, frame.Function, frame.PC-frame.Entry) + if !more { + return + } + } +} diff --git a/vendor/golang.org/x/tools/go/internal/pkgbits/reloc.go b/vendor/golang.org/x/tools/go/internal/pkgbits/reloc.go new file mode 100644 index 0000000000..7a8f04ab3f --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/pkgbits/reloc.go @@ -0,0 +1,42 @@ +// Copyright 2021 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. + +package pkgbits + +// A RelocKind indicates a particular section within a unified IR export. +type RelocKind int + +// An Index represents a bitstream element index within a particular +// section. +type Index int + +// A relocEnt (relocation entry) is an entry in an element's local +// reference table. +// +// TODO(mdempsky): Rename this too. +type RelocEnt struct { + Kind RelocKind + Idx Index +} + +// Reserved indices within the meta relocation section. +const ( + PublicRootIdx Index = 0 + PrivateRootIdx Index = 1 +) + +const ( + RelocString RelocKind = iota + RelocMeta + RelocPosBase + RelocPkg + RelocName + RelocType + RelocObj + RelocObjExt + RelocObjDict + RelocBody + + numRelocs = iota +) diff --git a/vendor/golang.org/x/tools/go/internal/pkgbits/support.go b/vendor/golang.org/x/tools/go/internal/pkgbits/support.go new file mode 100644 index 0000000000..ad26d3b28c --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/pkgbits/support.go @@ -0,0 +1,17 @@ +// Copyright 2022 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. + +package pkgbits + +import "fmt" + +func assert(b bool) { + if !b { + panic("assertion failed") + } +} + +func errorf(format string, args ...interface{}) { + panic(fmt.Errorf(format, args...)) +} diff --git a/vendor/golang.org/x/tools/go/internal/pkgbits/sync.go b/vendor/golang.org/x/tools/go/internal/pkgbits/sync.go new file mode 100644 index 0000000000..5bd51ef717 --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/pkgbits/sync.go @@ -0,0 +1,113 @@ +// Copyright 2021 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. + +package pkgbits + +import ( + "fmt" + "strings" +) + +// fmtFrames formats a backtrace for reporting reader/writer desyncs. +func fmtFrames(pcs ...uintptr) []string { + res := make([]string, 0, len(pcs)) + walkFrames(pcs, func(file string, line int, name string, offset uintptr) { + // Trim package from function name. It's just redundant noise. + name = strings.TrimPrefix(name, "cmd/compile/internal/noder.") + + res = append(res, fmt.Sprintf("%s:%v: %s +0x%v", file, line, name, offset)) + }) + return res +} + +type frameVisitor func(file string, line int, name string, offset uintptr) + +// SyncMarker is an enum type that represents markers that may be +// written to export data to ensure the reader and writer stay +// synchronized. +type SyncMarker int + +//go:generate stringer -type=SyncMarker -trimprefix=Sync + +const ( + _ SyncMarker = iota + + // Public markers (known to go/types importers). + + // Low-level coding markers. + SyncEOF + SyncBool + SyncInt64 + SyncUint64 + SyncString + SyncValue + SyncVal + SyncRelocs + SyncReloc + SyncUseReloc + + // Higher-level object and type markers. + SyncPublic + SyncPos + SyncPosBase + SyncObject + SyncObject1 + SyncPkg + SyncPkgDef + SyncMethod + SyncType + SyncTypeIdx + SyncTypeParamNames + SyncSignature + SyncParams + SyncParam + SyncCodeObj + SyncSym + SyncLocalIdent + SyncSelector + + // Private markers (only known to cmd/compile). + SyncPrivate + + SyncFuncExt + SyncVarExt + SyncTypeExt + SyncPragma + + SyncExprList + SyncExprs + SyncExpr + SyncExprType + SyncAssign + SyncOp + SyncFuncLit + SyncCompLit + + SyncDecl + SyncFuncBody + SyncOpenScope + SyncCloseScope + SyncCloseAnotherScope + SyncDeclNames + SyncDeclName + + SyncStmts + SyncBlockStmt + SyncIfStmt + SyncForStmt + SyncSwitchStmt + SyncRangeStmt + SyncCaseClause + SyncCommClause + SyncSelectStmt + SyncDecls + SyncLabeledStmt + SyncUseObjLocal + SyncAddLocal + SyncLinkname + SyncStmt1 + SyncStmtsEnd + SyncLabel + SyncOptLabel +) diff --git a/vendor/golang.org/x/tools/go/internal/pkgbits/syncmarker_string.go b/vendor/golang.org/x/tools/go/internal/pkgbits/syncmarker_string.go new file mode 100644 index 0000000000..4a5b0ca5f2 --- /dev/null +++ b/vendor/golang.org/x/tools/go/internal/pkgbits/syncmarker_string.go @@ -0,0 +1,89 @@ +// Code generated by "stringer -type=SyncMarker -trimprefix=Sync"; DO NOT EDIT. + +package pkgbits + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[SyncEOF-1] + _ = x[SyncBool-2] + _ = x[SyncInt64-3] + _ = x[SyncUint64-4] + _ = x[SyncString-5] + _ = x[SyncValue-6] + _ = x[SyncVal-7] + _ = x[SyncRelocs-8] + _ = x[SyncReloc-9] + _ = x[SyncUseReloc-10] + _ = x[SyncPublic-11] + _ = x[SyncPos-12] + _ = x[SyncPosBase-13] + _ = x[SyncObject-14] + _ = x[SyncObject1-15] + _ = x[SyncPkg-16] + _ = x[SyncPkgDef-17] + _ = x[SyncMethod-18] + _ = x[SyncType-19] + _ = x[SyncTypeIdx-20] + _ = x[SyncTypeParamNames-21] + _ = x[SyncSignature-22] + _ = x[SyncParams-23] + _ = x[SyncParam-24] + _ = x[SyncCodeObj-25] + _ = x[SyncSym-26] + _ = x[SyncLocalIdent-27] + _ = x[SyncSelector-28] + _ = x[SyncPrivate-29] + _ = x[SyncFuncExt-30] + _ = x[SyncVarExt-31] + _ = x[SyncTypeExt-32] + _ = x[SyncPragma-33] + _ = x[SyncExprList-34] + _ = x[SyncExprs-35] + _ = x[SyncExpr-36] + _ = x[SyncExprType-37] + _ = x[SyncAssign-38] + _ = x[SyncOp-39] + _ = x[SyncFuncLit-40] + _ = x[SyncCompLit-41] + _ = x[SyncDecl-42] + _ = x[SyncFuncBody-43] + _ = x[SyncOpenScope-44] + _ = x[SyncCloseScope-45] + _ = x[SyncCloseAnotherScope-46] + _ = x[SyncDeclNames-47] + _ = x[SyncDeclName-48] + _ = x[SyncStmts-49] + _ = x[SyncBlockStmt-50] + _ = x[SyncIfStmt-51] + _ = x[SyncForStmt-52] + _ = x[SyncSwitchStmt-53] + _ = x[SyncRangeStmt-54] + _ = x[SyncCaseClause-55] + _ = x[SyncCommClause-56] + _ = x[SyncSelectStmt-57] + _ = x[SyncDecls-58] + _ = x[SyncLabeledStmt-59] + _ = x[SyncUseObjLocal-60] + _ = x[SyncAddLocal-61] + _ = x[SyncLinkname-62] + _ = x[SyncStmt1-63] + _ = x[SyncStmtsEnd-64] + _ = x[SyncLabel-65] + _ = x[SyncOptLabel-66] +} + +const _SyncMarker_name = "EOFBoolInt64Uint64StringValueValRelocsRelocUseRelocPublicPosPosBaseObjectObject1PkgPkgDefMethodTypeTypeIdxTypeParamNamesSignatureParamsParamCodeObjSymLocalIdentSelectorPrivateFuncExtVarExtTypeExtPragmaExprListExprsExprExprTypeAssignOpFuncLitCompLitDeclFuncBodyOpenScopeCloseScopeCloseAnotherScopeDeclNamesDeclNameStmtsBlockStmtIfStmtForStmtSwitchStmtRangeStmtCaseClauseCommClauseSelectStmtDeclsLabeledStmtUseObjLocalAddLocalLinknameStmt1StmtsEndLabelOptLabel" + +var _SyncMarker_index = [...]uint16{0, 3, 7, 12, 18, 24, 29, 32, 38, 43, 51, 57, 60, 67, 73, 80, 83, 89, 95, 99, 106, 120, 129, 135, 140, 147, 150, 160, 168, 175, 182, 188, 195, 201, 209, 214, 218, 226, 232, 234, 241, 248, 252, 260, 269, 279, 296, 305, 313, 318, 327, 333, 340, 350, 359, 369, 379, 389, 394, 405, 416, 424, 432, 437, 445, 450, 458} + +func (i SyncMarker) String() string { + i -= 1 + if i < 0 || i >= SyncMarker(len(_SyncMarker_index)-1) { + return "SyncMarker(" + strconv.FormatInt(int64(i+1), 10) + ")" + } + return _SyncMarker_name[_SyncMarker_index[i]:_SyncMarker_index[i+1]] +} diff --git a/vendor/golang.org/x/tools/internal/fastwalk/fastwalk.go b/vendor/golang.org/x/tools/internal/fastwalk/fastwalk.go index 9887f7e7a0..798fe599be 100644 --- a/vendor/golang.org/x/tools/internal/fastwalk/fastwalk.go +++ b/vendor/golang.org/x/tools/internal/fastwalk/fastwalk.go @@ -40,12 +40,12 @@ var ErrSkipFiles = errors.New("fastwalk: skip remaining files in directory") // If fastWalk returns filepath.SkipDir, the directory is skipped. // // Unlike filepath.Walk: -// * file stat calls must be done by the user. +// - file stat calls must be done by the user. // The only provided metadata is the file type, which does not include // any permission bits. -// * multiple goroutines stat the filesystem concurrently. The provided +// - multiple goroutines stat the filesystem concurrently. The provided // walkFn must be safe for concurrent use. -// * fastWalk can follow symlinks if walkFn returns the TraverseLink +// - fastWalk can follow symlinks if walkFn returns the TraverseLink // sentinel error. It is the walkFn's responsibility to prevent // fastWalk from going into symlink cycles. func Walk(root string, walkFn func(path string, typ os.FileMode) error) error { diff --git a/vendor/golang.org/x/tools/internal/gocommand/invoke.go b/vendor/golang.org/x/tools/internal/gocommand/invoke.go index 8659a0c5da..67256dc397 100644 --- a/vendor/golang.org/x/tools/internal/gocommand/invoke.go +++ b/vendor/golang.org/x/tools/internal/gocommand/invoke.go @@ -9,7 +9,6 @@ import ( "bytes" "context" "fmt" - exec "golang.org/x/sys/execabs" "io" "os" "regexp" @@ -18,6 +17,8 @@ import ( "sync" "time" + exec "golang.org/x/sys/execabs" + "golang.org/x/tools/internal/event" ) @@ -131,9 +132,16 @@ type Invocation struct { Verb string Args []string BuildFlags []string - ModFlag string - ModFile string - Overlay string + + // If ModFlag is set, the go command is invoked with -mod=ModFlag. + ModFlag string + + // If ModFile is set, the go command is invoked with -modfile=ModFile. + ModFile string + + // If Overlay is set, the go command is invoked with -overlay=Overlay. + Overlay string + // If CleanEnv is set, the invocation will run only with the environment // in Env, not starting with os.Environ. CleanEnv bool @@ -256,8 +264,10 @@ func cmdDebugStr(cmd *exec.Cmd) string { env := make(map[string]string) for _, kv := range cmd.Env { split := strings.SplitN(kv, "=", 2) - k, v := split[0], split[1] - env[k] = v + if len(split) == 2 { + k, v := split[0], split[1] + env[k] = v + } } var args []string diff --git a/vendor/golang.org/x/tools/internal/gocommand/vendor.go b/vendor/golang.org/x/tools/internal/gocommand/vendor.go index 5e75bd6d8f..2d3d408c0b 100644 --- a/vendor/golang.org/x/tools/internal/gocommand/vendor.go +++ b/vendor/golang.org/x/tools/internal/gocommand/vendor.go @@ -38,10 +38,10 @@ var modFlagRegexp = regexp.MustCompile(`-mod[ =](\w+)`) // with the supplied context.Context and Invocation. The Invocation can contain pre-defined fields, // of which only Verb and Args are modified to run the appropriate Go command. // Inspired by setDefaultBuildMod in modload/init.go -func VendorEnabled(ctx context.Context, inv Invocation, r *Runner) (*ModuleJSON, bool, error) { +func VendorEnabled(ctx context.Context, inv Invocation, r *Runner) (bool, *ModuleJSON, error) { mainMod, go114, err := getMainModuleAnd114(ctx, inv, r) if err != nil { - return nil, false, err + return false, nil, err } // We check the GOFLAGS to see if there is anything overridden or not. @@ -49,7 +49,7 @@ func VendorEnabled(ctx context.Context, inv Invocation, r *Runner) (*ModuleJSON, inv.Args = []string{"GOFLAGS"} stdout, err := r.Run(ctx, inv) if err != nil { - return nil, false, err + return false, nil, err } goflags := string(bytes.TrimSpace(stdout.Bytes())) matches := modFlagRegexp.FindStringSubmatch(goflags) @@ -57,25 +57,27 @@ func VendorEnabled(ctx context.Context, inv Invocation, r *Runner) (*ModuleJSON, if len(matches) != 0 { modFlag = matches[1] } - if modFlag != "" { - // Don't override an explicit '-mod=' argument. - return mainMod, modFlag == "vendor", nil + // Don't override an explicit '-mod=' argument. + if modFlag == "vendor" { + return true, mainMod, nil + } else if modFlag != "" { + return false, nil, nil } if mainMod == nil || !go114 { - return mainMod, false, nil + return false, nil, nil } // Check 1.14's automatic vendor mode. if fi, err := os.Stat(filepath.Join(mainMod.Dir, "vendor")); err == nil && fi.IsDir() { if mainMod.GoVersion != "" && semver.Compare("v"+mainMod.GoVersion, "v1.14") >= 0 { // The Go version is at least 1.14, and a vendor directory exists. // Set -mod=vendor by default. - return mainMod, true, nil + return true, mainMod, nil } } - return mainMod, false, nil + return false, nil, nil } -// getMainModuleAnd114 gets the main module's information and whether the +// getMainModuleAnd114 gets one of the main modules' information and whether the // go command in use is 1.14+. This is the information needed to figure out // if vendoring should be enabled. func getMainModuleAnd114(ctx context.Context, inv Invocation, r *Runner) (*ModuleJSON, bool, error) { diff --git a/vendor/golang.org/x/tools/internal/gocommand/version.go b/vendor/golang.org/x/tools/internal/gocommand/version.go index 0cebac6e66..7130436802 100644 --- a/vendor/golang.org/x/tools/internal/gocommand/version.go +++ b/vendor/golang.org/x/tools/internal/gocommand/version.go @@ -14,7 +14,7 @@ import ( // It returns the X in Go 1.X. func GoVersion(ctx context.Context, inv Invocation, r *Runner) (int, error) { inv.Verb = "list" - inv.Args = []string{"-e", "-f", `{{context.ReleaseTags}}`} + inv.Args = []string{"-e", "-f", `{{context.ReleaseTags}}`, `--`, `unsafe`} inv.Env = append(append([]string{}, inv.Env...), "GO111MODULE=off") // Unset any unneeded flags, and remove them from BuildFlags, if they're // present. diff --git a/vendor/golang.org/x/tools/internal/gopathwalk/walk.go b/vendor/golang.org/x/tools/internal/gopathwalk/walk.go index 925ff53560..1684053226 100644 --- a/vendor/golang.org/x/tools/internal/gopathwalk/walk.go +++ b/vendor/golang.org/x/tools/internal/gopathwalk/walk.go @@ -175,8 +175,8 @@ func (w *walker) shouldSkipDir(fi os.FileInfo, dir string) bool { // walk walks through the given path. func (w *walker) walk(path string, typ os.FileMode) error { - dir := filepath.Dir(path) if typ.IsRegular() { + dir := filepath.Dir(path) if dir == w.root.Path && (w.root.Type == RootGOROOT || w.root.Type == RootGOPATH) { // Doesn't make sense to have regular files // directly in your $GOPATH/src or $GOROOT/src. @@ -209,12 +209,7 @@ func (w *walker) walk(path string, typ os.FileMode) error { // Emacs noise. return nil } - fi, err := os.Lstat(path) - if err != nil { - // Just ignore it. - return nil - } - if w.shouldTraverse(dir, fi) { + if w.shouldTraverse(path) { return fastwalk.ErrTraverseLink } } @@ -224,13 +219,8 @@ func (w *walker) walk(path string, typ os.FileMode) error { // shouldTraverse reports whether the symlink fi, found in dir, // should be followed. It makes sure symlinks were never visited // before to avoid symlink loops. -func (w *walker) shouldTraverse(dir string, fi os.FileInfo) bool { - path := filepath.Join(dir, fi.Name()) - target, err := filepath.EvalSymlinks(path) - if err != nil { - return false - } - ts, err := os.Stat(target) +func (w *walker) shouldTraverse(path string) bool { + ts, err := os.Stat(path) if err != nil { fmt.Fprintln(os.Stderr, err) return false @@ -238,7 +228,7 @@ func (w *walker) shouldTraverse(dir string, fi os.FileInfo) bool { if !ts.IsDir() { return false } - if w.shouldSkipDir(ts, dir) { + if w.shouldSkipDir(ts, filepath.Dir(path)) { return false } // Check for symlink loops by statting each directory component diff --git a/vendor/golang.org/x/tools/internal/imports/fix.go b/vendor/golang.org/x/tools/internal/imports/fix.go index d859617b77..9e373d64eb 100644 --- a/vendor/golang.org/x/tools/internal/imports/fix.go +++ b/vendor/golang.org/x/tools/internal/imports/fix.go @@ -796,7 +796,7 @@ func GetPackageExports(ctx context.Context, wrapped func(PackageExport), searchP return getCandidatePkgs(ctx, callback, filename, filePkg, env) } -var RequiredGoEnvVars = []string{"GO111MODULE", "GOFLAGS", "GOINSECURE", "GOMOD", "GOMODCACHE", "GONOPROXY", "GONOSUMDB", "GOPATH", "GOPROXY", "GOROOT", "GOSUMDB"} +var RequiredGoEnvVars = []string{"GO111MODULE", "GOFLAGS", "GOINSECURE", "GOMOD", "GOMODCACHE", "GONOPROXY", "GONOSUMDB", "GOPATH", "GOPROXY", "GOROOT", "GOSUMDB", "GOWORK"} // ProcessEnv contains environment variables and settings that affect the use of // the go command, the go/build package, etc. @@ -906,7 +906,7 @@ func (e *ProcessEnv) GetResolver() (Resolver, error) { if err := e.init(); err != nil { return nil, err } - if len(e.Env["GOMOD"]) == 0 { + if len(e.Env["GOMOD"]) == 0 && len(e.Env["GOWORK"]) == 0 { e.resolver = newGopathResolver(e) return e.resolver, nil } diff --git a/vendor/golang.org/x/tools/internal/imports/imports.go b/vendor/golang.org/x/tools/internal/imports/imports.go index 2815edc33d..95a88383a7 100644 --- a/vendor/golang.org/x/tools/internal/imports/imports.go +++ b/vendor/golang.org/x/tools/internal/imports/imports.go @@ -103,12 +103,17 @@ func ApplyFixes(fixes []*ImportFix, filename string, src []byte, opt *Options, e return formatFile(fileSet, file, src, nil, opt) } -func formatFile(fileSet *token.FileSet, file *ast.File, src []byte, adjust func(orig []byte, src []byte) []byte, opt *Options) ([]byte, error) { - mergeImports(fileSet, file) - sortImports(opt.LocalPrefix, fileSet, file) - imps := astutil.Imports(fileSet, file) +// formatFile formats the file syntax tree. +// It may mutate the token.FileSet. +// +// If an adjust function is provided, it is called after formatting +// with the original source (formatFile's src parameter) and the +// formatted file, and returns the postpocessed result. +func formatFile(fset *token.FileSet, file *ast.File, src []byte, adjust func(orig []byte, src []byte) []byte, opt *Options) ([]byte, error) { + mergeImports(file) + sortImports(opt.LocalPrefix, fset.File(file.Pos()), file) var spacesBefore []string // import paths we need spaces before - for _, impSection := range imps { + for _, impSection := range astutil.Imports(fset, file) { // Within each block of contiguous imports, see if any // import lines are in different group numbers. If so, // we'll need to put a space between them so it's @@ -132,7 +137,7 @@ func formatFile(fileSet *token.FileSet, file *ast.File, src []byte, adjust func( printConfig := &printer.Config{Mode: printerMode, Tabwidth: opt.TabWidth} var buf bytes.Buffer - err := printConfig.Fprint(&buf, fileSet, file) + err := printConfig.Fprint(&buf, fset, file) if err != nil { return nil, err } @@ -276,11 +281,11 @@ func cutSpace(b []byte) (before, middle, after []byte) { } // matchSpace reformats src to use the same space context as orig. -// 1) If orig begins with blank lines, matchSpace inserts them at the beginning of src. -// 2) matchSpace copies the indentation of the first non-blank line in orig -// to every non-blank line in src. -// 3) matchSpace copies the trailing space from orig and uses it in place -// of src's trailing space. +// 1. If orig begins with blank lines, matchSpace inserts them at the beginning of src. +// 2. matchSpace copies the indentation of the first non-blank line in orig +// to every non-blank line in src. +// 3. matchSpace copies the trailing space from orig and uses it in place +// of src's trailing space. func matchSpace(orig []byte, src []byte) []byte { before, _, after := cutSpace(orig) i := bytes.LastIndex(before, []byte{'\n'}) @@ -306,7 +311,7 @@ func matchSpace(orig []byte, src []byte) []byte { return b.Bytes() } -var impLine = regexp.MustCompile(`^\s+(?:[\w\.]+\s+)?"(.+)"`) +var impLine = regexp.MustCompile(`^\s+(?:[\w\.]+\s+)?"(.+?)"`) func addImportSpaces(r io.Reader, breaks []string) ([]byte, error) { var out bytes.Buffer diff --git a/vendor/golang.org/x/tools/internal/imports/mod.go b/vendor/golang.org/x/tools/internal/imports/mod.go index dff6d55362..46693f2433 100644 --- a/vendor/golang.org/x/tools/internal/imports/mod.go +++ b/vendor/golang.org/x/tools/internal/imports/mod.go @@ -34,7 +34,8 @@ type ModuleResolver struct { scannedRoots map[gopathwalk.Root]bool initialized bool - main *gocommand.ModuleJSON + mains []*gocommand.ModuleJSON + mainByDir map[string]*gocommand.ModuleJSON modsByModPath []*gocommand.ModuleJSON // All modules, ordered by # of path components in module Path... modsByDir []*gocommand.ModuleJSON // ...or Dir. @@ -69,21 +70,29 @@ func (r *ModuleResolver) init() error { Logf: r.env.Logf, WorkingDir: r.env.WorkingDir, } - mainMod, vendorEnabled, err := gocommand.VendorEnabled(context.TODO(), inv, r.env.GocmdRunner) - if err != nil { - return err + + vendorEnabled := false + var mainModVendor *gocommand.ModuleJSON + + // Module vendor directories are ignored in workspace mode: + // https://go.googlesource.com/proposal/+/master/design/45713-workspace.md + if len(r.env.Env["GOWORK"]) == 0 { + vendorEnabled, mainModVendor, err = gocommand.VendorEnabled(context.TODO(), inv, r.env.GocmdRunner) + if err != nil { + return err + } } - if mainMod != nil && vendorEnabled { + if mainModVendor != nil && vendorEnabled { // Vendor mode is on, so all the non-Main modules are irrelevant, // and we need to search /vendor for everything. - r.main = mainMod + r.mains = []*gocommand.ModuleJSON{mainModVendor} r.dummyVendorMod = &gocommand.ModuleJSON{ Path: "", - Dir: filepath.Join(mainMod.Dir, "vendor"), + Dir: filepath.Join(mainModVendor.Dir, "vendor"), } - r.modsByModPath = []*gocommand.ModuleJSON{mainMod, r.dummyVendorMod} - r.modsByDir = []*gocommand.ModuleJSON{mainMod, r.dummyVendorMod} + r.modsByModPath = []*gocommand.ModuleJSON{mainModVendor, r.dummyVendorMod} + r.modsByDir = []*gocommand.ModuleJSON{mainModVendor, r.dummyVendorMod} } else { // Vendor mode is off, so run go list -m ... to find everything. err := r.initAllMods() @@ -122,8 +131,10 @@ func (r *ModuleResolver) init() error { r.roots = []gopathwalk.Root{ {filepath.Join(goenv["GOROOT"], "/src"), gopathwalk.RootGOROOT}, } - if r.main != nil { - r.roots = append(r.roots, gopathwalk.Root{r.main.Dir, gopathwalk.RootCurrentModule}) + r.mainByDir = make(map[string]*gocommand.ModuleJSON) + for _, main := range r.mains { + r.roots = append(r.roots, gopathwalk.Root{main.Dir, gopathwalk.RootCurrentModule}) + r.mainByDir[main.Dir] = main } if vendorEnabled { r.roots = append(r.roots, gopathwalk.Root{r.dummyVendorMod.Dir, gopathwalk.RootOther}) @@ -189,7 +200,7 @@ func (r *ModuleResolver) initAllMods() error { r.modsByModPath = append(r.modsByModPath, mod) r.modsByDir = append(r.modsByDir, mod) if mod.Main { - r.main = mod + r.mains = append(r.mains, mod) } } return nil @@ -609,7 +620,7 @@ func (r *ModuleResolver) scanDirForPackage(root gopathwalk.Root, dir string) dir } switch root.Type { case gopathwalk.RootCurrentModule: - importPath = path.Join(r.main.Path, filepath.ToSlash(subdir)) + importPath = path.Join(r.mainByDir[root.Path].Path, filepath.ToSlash(subdir)) case gopathwalk.RootModuleCache: matches := modCacheRegexp.FindStringSubmatch(subdir) if len(matches) == 0 { diff --git a/vendor/golang.org/x/tools/internal/imports/sortimports.go b/vendor/golang.org/x/tools/internal/imports/sortimports.go index be8ffa25fe..85144db1df 100644 --- a/vendor/golang.org/x/tools/internal/imports/sortimports.go +++ b/vendor/golang.org/x/tools/internal/imports/sortimports.go @@ -3,19 +3,23 @@ // license that can be found in the LICENSE file. // Hacked up copy of go/ast/import.go +// Modified to use a single token.File in preference to a FileSet. package imports import ( "go/ast" "go/token" + "log" "sort" "strconv" ) // sortImports sorts runs of consecutive import lines in import blocks in f. // It also removes duplicate imports when it is possible to do so without data loss. -func sortImports(localPrefix string, fset *token.FileSet, f *ast.File) { +// +// It may mutate the token.File. +func sortImports(localPrefix string, tokFile *token.File, f *ast.File) { for i, d := range f.Decls { d, ok := d.(*ast.GenDecl) if !ok || d.Tok != token.IMPORT { @@ -38,21 +42,21 @@ func sortImports(localPrefix string, fset *token.FileSet, f *ast.File) { i := 0 specs := d.Specs[:0] for j, s := range d.Specs { - if j > i && fset.Position(s.Pos()).Line > 1+fset.Position(d.Specs[j-1].End()).Line { + if j > i && tokFile.Line(s.Pos()) > 1+tokFile.Line(d.Specs[j-1].End()) { // j begins a new run. End this one. - specs = append(specs, sortSpecs(localPrefix, fset, f, d.Specs[i:j])...) + specs = append(specs, sortSpecs(localPrefix, tokFile, f, d.Specs[i:j])...) i = j } } - specs = append(specs, sortSpecs(localPrefix, fset, f, d.Specs[i:])...) + specs = append(specs, sortSpecs(localPrefix, tokFile, f, d.Specs[i:])...) d.Specs = specs // Deduping can leave a blank line before the rparen; clean that up. if len(d.Specs) > 0 { lastSpec := d.Specs[len(d.Specs)-1] - lastLine := fset.Position(lastSpec.Pos()).Line - if rParenLine := fset.Position(d.Rparen).Line; rParenLine > lastLine+1 { - fset.File(d.Rparen).MergeLine(rParenLine - 1) + lastLine := tokFile.PositionFor(lastSpec.Pos(), false).Line + if rParenLine := tokFile.PositionFor(d.Rparen, false).Line; rParenLine > lastLine+1 { + tokFile.MergeLine(rParenLine - 1) // has side effects! } } } @@ -60,7 +64,8 @@ func sortImports(localPrefix string, fset *token.FileSet, f *ast.File) { // mergeImports merges all the import declarations into the first one. // Taken from golang.org/x/tools/ast/astutil. -func mergeImports(fset *token.FileSet, f *ast.File) { +// This does not adjust line numbers properly +func mergeImports(f *ast.File) { if len(f.Decls) <= 1 { return } @@ -142,7 +147,9 @@ type posSpan struct { End token.Pos } -func sortSpecs(localPrefix string, fset *token.FileSet, f *ast.File, specs []ast.Spec) []ast.Spec { +// sortSpecs sorts the import specs within each import decl. +// It may mutate the token.File. +func sortSpecs(localPrefix string, tokFile *token.File, f *ast.File, specs []ast.Spec) []ast.Spec { // Can't short-circuit here even if specs are already sorted, // since they might yet need deduplication. // A lone import, however, may be safely ignored. @@ -158,7 +165,7 @@ func sortSpecs(localPrefix string, fset *token.FileSet, f *ast.File, specs []ast // Identify comments in this range. // Any comment from pos[0].Start to the final line counts. - lastLine := fset.Position(pos[len(pos)-1].End).Line + lastLine := tokFile.Line(pos[len(pos)-1].End) cstart := len(f.Comments) cend := len(f.Comments) for i, g := range f.Comments { @@ -168,7 +175,7 @@ func sortSpecs(localPrefix string, fset *token.FileSet, f *ast.File, specs []ast if i < cstart { cstart = i } - if fset.Position(g.End()).Line > lastLine { + if tokFile.Line(g.End()) > lastLine { cend = i break } @@ -201,7 +208,7 @@ func sortSpecs(localPrefix string, fset *token.FileSet, f *ast.File, specs []ast deduped = append(deduped, s) } else { p := s.Pos() - fset.File(p).MergeLine(fset.Position(p).Line) + tokFile.MergeLine(tokFile.Line(p)) // has side effects! } } specs = deduped @@ -232,13 +239,22 @@ func sortSpecs(localPrefix string, fset *token.FileSet, f *ast.File, specs []ast // Fixup comments can insert blank lines, because import specs are on different lines. // We remove those blank lines here by merging import spec to the first import spec line. - firstSpecLine := fset.Position(specs[0].Pos()).Line + firstSpecLine := tokFile.Line(specs[0].Pos()) for _, s := range specs[1:] { p := s.Pos() - line := fset.File(p).Line(p) + line := tokFile.Line(p) for previousLine := line - 1; previousLine >= firstSpecLine; { - fset.File(p).MergeLine(previousLine) - previousLine-- + // MergeLine can panic. Avoid the panic at the cost of not removing the blank line + // golang/go#50329 + if previousLine > 0 && previousLine < tokFile.LineCount() { + tokFile.MergeLine(previousLine) // has side effects! + previousLine-- + } else { + // try to gather some data to diagnose how this could happen + req := "Please report what the imports section of your go file looked like." + log.Printf("panic avoided: first:%d line:%d previous:%d max:%d. %s", + firstSpecLine, line, previousLine, tokFile.LineCount(), req) + } } } return specs diff --git a/vendor/golang.org/x/tools/internal/imports/zstdlib.go b/vendor/golang.org/x/tools/internal/imports/zstdlib.go index ccdd4e0ffc..437fbb78db 100644 --- a/vendor/golang.org/x/tools/internal/imports/zstdlib.go +++ b/vendor/golang.org/x/tools/internal/imports/zstdlib.go @@ -88,6 +88,7 @@ var stdlib = map[string][]string{ "ContainsAny", "ContainsRune", "Count", + "Cut", "Equal", "EqualFold", "ErrTooLarge", @@ -180,6 +181,8 @@ var stdlib = map[string][]string{ "NewReader", "NewWriter", "Order", + "Reader", + "Writer", }, "compress/zlib": []string{ "BestCompression", @@ -641,7 +644,9 @@ var stdlib = map[string][]string{ "Named", "NamedArg", "NullBool", + "NullByte", "NullFloat64", + "NullInt16", "NullInt32", "NullInt64", "NullString", @@ -707,6 +712,11 @@ var stdlib = map[string][]string{ "ValueConverter", "Valuer", }, + "debug/buildinfo": []string{ + "BuildInfo", + "Read", + "ReadFile", + }, "debug/dwarf": []string{ "AddrType", "ArrayType", @@ -1940,6 +1950,7 @@ var stdlib = map[string][]string{ "R_PPC64_REL24_NOTOC", "R_PPC64_REL32", "R_PPC64_REL64", + "R_PPC64_RELATIVE", "R_PPC64_SECTOFF_DS", "R_PPC64_SECTOFF_LO_DS", "R_PPC64_TLS", @@ -2248,6 +2259,7 @@ var stdlib = map[string][]string{ "SHT_LOOS", "SHT_LOPROC", "SHT_LOUSER", + "SHT_MIPS_ABIFLAGS", "SHT_NOBITS", "SHT_NOTE", "SHT_NULL", @@ -2542,6 +2554,7 @@ var stdlib = map[string][]string{ "Symbol", }, "debug/plan9obj": []string{ + "ErrNoSymbols", "File", "FileHeader", "Magic386", @@ -2901,6 +2914,7 @@ var stdlib = map[string][]string{ "Importer", "IncDecStmt", "IndexExpr", + "IndexListExpr", "Inspect", "InterfaceType", "IsExported", @@ -3061,6 +3075,7 @@ var stdlib = map[string][]string{ "ParseExpr", "ParseExprFrom", "ParseFile", + "SkipObjectResolution", "SpuriousErrors", "Trace", }, @@ -3173,6 +3188,7 @@ var stdlib = map[string][]string{ "SUB", "SUB_ASSIGN", "SWITCH", + "TILDE", "TYPE", "Token", "UnaryPrec", @@ -3181,6 +3197,7 @@ var stdlib = map[string][]string{ "XOR_ASSIGN", }, "go/types": []string{ + "ArgumentError", "Array", "AssertableTo", "AssignableTo", @@ -3199,6 +3216,7 @@ var stdlib = map[string][]string{ "Complex64", "Config", "Const", + "Context", "ConvertibleTo", "DefPredeclaredTestFuncs", "Default", @@ -3218,6 +3236,8 @@ var stdlib = map[string][]string{ "ImporterFrom", "Info", "Initializer", + "Instance", + "Instantiate", "Int", "Int16", "Int32", @@ -3248,6 +3268,7 @@ var stdlib = map[string][]string{ "NewChan", "NewChecker", "NewConst", + "NewContext", "NewField", "NewFunc", "NewInterface", @@ -3262,10 +3283,14 @@ var stdlib = map[string][]string{ "NewPointer", "NewScope", "NewSignature", + "NewSignatureType", "NewSlice", "NewStruct", + "NewTerm", "NewTuple", "NewTypeName", + "NewTypeParam", + "NewUnion", "NewVar", "Nil", "Object", @@ -3290,11 +3315,15 @@ var stdlib = map[string][]string{ "StdSizes", "String", "Struct", + "Term", "Tuple", "Typ", "Type", "TypeAndValue", + "TypeList", "TypeName", + "TypeParam", + "TypeParamList", "TypeString", "Uint", "Uint16", @@ -3302,6 +3331,7 @@ var stdlib = map[string][]string{ "Uint64", "Uint8", "Uintptr", + "Union", "Universe", "Unsafe", "UnsafePointer", @@ -3441,6 +3471,7 @@ var stdlib = map[string][]string{ "Pt", "RGBA", "RGBA64", + "RGBA64Image", "Rect", "Rectangle", "RegisterFormat", @@ -3507,6 +3538,7 @@ var stdlib = map[string][]string{ "Op", "Over", "Quantizer", + "RGBA64Image", "Src", }, "image/gif": []string{ @@ -3612,6 +3644,7 @@ var stdlib = map[string][]string{ "FS", "File", "FileInfo", + "FileInfoToDirEntry", "FileMode", "Glob", "GlobFS", @@ -3772,15 +3805,18 @@ var stdlib = map[string][]string{ "Max", "MaxFloat32", "MaxFloat64", + "MaxInt", "MaxInt16", "MaxInt32", "MaxInt64", "MaxInt8", + "MaxUint", "MaxUint16", "MaxUint32", "MaxUint64", "MaxUint8", "Min", + "MinInt", "MinInt16", "MinInt32", "MinInt64", @@ -4068,9 +4104,11 @@ var stdlib = map[string][]string{ "SRV", "SplitHostPort", "TCPAddr", + "TCPAddrFromAddrPort", "TCPConn", "TCPListener", "UDPAddr", + "UDPAddrFromAddrPort", "UDPConn", "UnixAddr", "UnixConn", @@ -4078,6 +4116,7 @@ var stdlib = map[string][]string{ "UnknownNetworkError", }, "net/http": []string{ + "AllowQuerySemicolons", "CanonicalHeaderKey", "Client", "CloseNotifier", @@ -4129,6 +4168,7 @@ var stdlib = map[string][]string{ "ListenAndServe", "ListenAndServeTLS", "LocalAddrContextKey", + "MaxBytesHandler", "MaxBytesReader", "MethodConnect", "MethodDelete", @@ -4325,6 +4365,25 @@ var stdlib = map[string][]string{ "ParseDate", "ReadMessage", }, + "net/netip": []string{ + "Addr", + "AddrFrom16", + "AddrFrom4", + "AddrFromSlice", + "AddrPort", + "AddrPortFrom", + "IPv4Unspecified", + "IPv6LinkLocalAllNodes", + "IPv6Unspecified", + "MustParseAddr", + "MustParseAddrPort", + "MustParsePrefix", + "ParseAddr", + "ParseAddrPort", + "ParsePrefix", + "Prefix", + "PrefixFrom", + }, "net/rpc": []string{ "Accept", "Call", @@ -4628,6 +4687,8 @@ var stdlib = map[string][]string{ "Method", "New", "NewAt", + "Pointer", + "PointerTo", "Ptr", "PtrTo", "RecvDir", @@ -4660,6 +4721,7 @@ var stdlib = map[string][]string{ "Value", "ValueError", "ValueOf", + "VisibleFields", "Zero", }, "regexp": []string{ @@ -4799,11 +4861,17 @@ var stdlib = map[string][]string{ "UnlockOSThread", "Version", }, + "runtime/cgo": []string{ + "Handle", + "NewHandle", + }, "runtime/debug": []string{ "BuildInfo", + "BuildSetting", "FreeOSMemory", "GCStats", "Module", + "ParseBuildInfo", "PrintStack", "ReadBuildInfo", "ReadGCStats", @@ -4915,16 +4983,19 @@ var stdlib = map[string][]string{ "QuoteRuneToGraphic", "QuoteToASCII", "QuoteToGraphic", + "QuotedPrefix", "Unquote", "UnquoteChar", }, "strings": []string{ "Builder", + "Clone", "Compare", "Contains", "ContainsAny", "ContainsRune", "Count", + "Cut", "EqualFold", "Fields", "FieldsFunc", @@ -9774,6 +9845,7 @@ var stdlib = map[string][]string{ "Syscall18", "Syscall6", "Syscall9", + "SyscallN", "Sysctl", "SysctlUint32", "Sysctlnode", @@ -10183,7 +10255,6 @@ var stdlib = map[string][]string{ "Value", "ValueError", "ValueOf", - "Wrapper", }, "testing": []string{ "AllocsPerRun", @@ -10194,9 +10265,11 @@ var stdlib = map[string][]string{ "CoverBlock", "CoverMode", "Coverage", + "F", "Init", "InternalBenchmark", "InternalExample", + "InternalFuzzTarget", "InternalTest", "M", "Main", @@ -10294,9 +10367,11 @@ var stdlib = map[string][]string{ "ActionNode", "BoolNode", "BranchNode", + "BreakNode", "ChainNode", "CommandNode", "CommentNode", + "ContinueNode", "DotNode", "FieldNode", "IdentifierNode", @@ -10310,9 +10385,11 @@ var stdlib = map[string][]string{ "Node", "NodeAction", "NodeBool", + "NodeBreak", "NodeChain", "NodeCommand", "NodeComment", + "NodeContinue", "NodeDot", "NodeField", "NodeIdentifier", @@ -10334,6 +10411,7 @@ var stdlib = map[string][]string{ "PipeNode", "Pos", "RangeNode", + "SkipFuncCheck", "StringNode", "TemplateNode", "TextNode", @@ -10358,6 +10436,7 @@ var stdlib = map[string][]string{ "July", "June", "Kitchen", + "Layout", "LoadLocation", "LoadLocationFromTZData", "Local", @@ -10406,6 +10485,8 @@ var stdlib = map[string][]string{ "UTC", "Unix", "UnixDate", + "UnixMicro", + "UnixMilli", "Until", "Wednesday", "Weekday", @@ -10704,6 +10785,7 @@ var stdlib = map[string][]string{ "IsSurrogate", }, "unicode/utf8": []string{ + "AppendRune", "DecodeLastRune", "DecodeLastRuneInString", "DecodeRune", diff --git a/vendor/golang.org/x/tools/internal/typeparams/common.go b/vendor/golang.org/x/tools/internal/typeparams/common.go new file mode 100644 index 0000000000..25a1426d30 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/typeparams/common.go @@ -0,0 +1,179 @@ +// Copyright 2021 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. + +// Package typeparams contains common utilities for writing tools that interact +// with generic Go code, as introduced with Go 1.18. +// +// Many of the types and functions in this package are proxies for the new APIs +// introduced in the standard library with Go 1.18. For example, the +// typeparams.Union type is an alias for go/types.Union, and the ForTypeSpec +// function returns the value of the go/ast.TypeSpec.TypeParams field. At Go +// versions older than 1.18 these helpers are implemented as stubs, allowing +// users of this package to write code that handles generic constructs inline, +// even if the Go version being used to compile does not support generics. +// +// Additionally, this package contains common utilities for working with the +// new generic constructs, to supplement the standard library APIs. Notably, +// the StructuralTerms API computes a minimal representation of the structural +// restrictions on a type parameter. +// +// An external version of these APIs is available in the +// golang.org/x/exp/typeparams module. +package typeparams + +import ( + "go/ast" + "go/token" + "go/types" +) + +// UnpackIndexExpr extracts data from AST nodes that represent index +// expressions. +// +// For an ast.IndexExpr, the resulting indices slice will contain exactly one +// index expression. For an ast.IndexListExpr (go1.18+), it may have a variable +// number of index expressions. +// +// For nodes that don't represent index expressions, the first return value of +// UnpackIndexExpr will be nil. +func UnpackIndexExpr(n ast.Node) (x ast.Expr, lbrack token.Pos, indices []ast.Expr, rbrack token.Pos) { + switch e := n.(type) { + case *ast.IndexExpr: + return e.X, e.Lbrack, []ast.Expr{e.Index}, e.Rbrack + case *IndexListExpr: + return e.X, e.Lbrack, e.Indices, e.Rbrack + } + return nil, token.NoPos, nil, token.NoPos +} + +// PackIndexExpr returns an *ast.IndexExpr or *ast.IndexListExpr, depending on +// the cardinality of indices. Calling PackIndexExpr with len(indices) == 0 +// will panic. +func PackIndexExpr(x ast.Expr, lbrack token.Pos, indices []ast.Expr, rbrack token.Pos) ast.Expr { + switch len(indices) { + case 0: + panic("empty indices") + case 1: + return &ast.IndexExpr{ + X: x, + Lbrack: lbrack, + Index: indices[0], + Rbrack: rbrack, + } + default: + return &IndexListExpr{ + X: x, + Lbrack: lbrack, + Indices: indices, + Rbrack: rbrack, + } + } +} + +// IsTypeParam reports whether t is a type parameter. +func IsTypeParam(t types.Type) bool { + _, ok := t.(*TypeParam) + return ok +} + +// OriginMethod returns the origin method associated with the method fn. +// For methods on a non-generic receiver base type, this is just +// fn. However, for methods with a generic receiver, OriginMethod returns the +// corresponding method in the method set of the origin type. +// +// As a special case, if fn is not a method (has no receiver), OriginMethod +// returns fn. +func OriginMethod(fn *types.Func) *types.Func { + recv := fn.Type().(*types.Signature).Recv() + if recv == nil { + + return fn + } + base := recv.Type() + p, isPtr := base.(*types.Pointer) + if isPtr { + base = p.Elem() + } + named, isNamed := base.(*types.Named) + if !isNamed { + // Receiver is a *types.Interface. + return fn + } + if ForNamed(named).Len() == 0 { + // Receiver base has no type parameters, so we can avoid the lookup below. + return fn + } + orig := NamedTypeOrigin(named) + gfn, _, _ := types.LookupFieldOrMethod(orig, true, fn.Pkg(), fn.Name()) + return gfn.(*types.Func) +} + +// GenericAssignableTo is a generalization of types.AssignableTo that +// implements the following rule for uninstantiated generic types: +// +// If V and T are generic named types, then V is considered assignable to T if, +// for every possible instantation of V[A_1, ..., A_N], the instantiation +// T[A_1, ..., A_N] is valid and V[A_1, ..., A_N] implements T[A_1, ..., A_N]. +// +// If T has structural constraints, they must be satisfied by V. +// +// For example, consider the following type declarations: +// +// type Interface[T any] interface { +// Accept(T) +// } +// +// type Container[T any] struct { +// Element T +// } +// +// func (c Container[T]) Accept(t T) { c.Element = t } +// +// In this case, GenericAssignableTo reports that instantiations of Container +// are assignable to the corresponding instantiation of Interface. +func GenericAssignableTo(ctxt *Context, V, T types.Type) bool { + // If V and T are not both named, or do not have matching non-empty type + // parameter lists, fall back on types.AssignableTo. + + VN, Vnamed := V.(*types.Named) + TN, Tnamed := T.(*types.Named) + if !Vnamed || !Tnamed { + return types.AssignableTo(V, T) + } + + vtparams := ForNamed(VN) + ttparams := ForNamed(TN) + if vtparams.Len() == 0 || vtparams.Len() != ttparams.Len() || NamedTypeArgs(VN).Len() != 0 || NamedTypeArgs(TN).Len() != 0 { + return types.AssignableTo(V, T) + } + + // V and T have the same (non-zero) number of type params. Instantiate both + // with the type parameters of V. This must always succeed for V, and will + // succeed for T if and only if the type set of each type parameter of V is a + // subset of the type set of the corresponding type parameter of T, meaning + // that every instantiation of V corresponds to a valid instantiation of T. + + // Minor optimization: ensure we share a context across the two + // instantiations below. + if ctxt == nil { + ctxt = NewContext() + } + + var targs []types.Type + for i := 0; i < vtparams.Len(); i++ { + targs = append(targs, vtparams.At(i)) + } + + vinst, err := Instantiate(ctxt, V, targs, true) + if err != nil { + panic("type parameters should satisfy their own constraints") + } + + tinst, err := Instantiate(ctxt, T, targs, true) + if err != nil { + return false + } + + return types.AssignableTo(vinst, tinst) +} diff --git a/vendor/golang.org/x/tools/internal/typeparams/coretype.go b/vendor/golang.org/x/tools/internal/typeparams/coretype.go new file mode 100644 index 0000000000..993135ec90 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/typeparams/coretype.go @@ -0,0 +1,122 @@ +// Copyright 2022 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. + +package typeparams + +import ( + "go/types" +) + +// CoreType returns the core type of T or nil if T does not have a core type. +// +// See https://go.dev/ref/spec#Core_types for the definition of a core type. +func CoreType(T types.Type) types.Type { + U := T.Underlying() + if _, ok := U.(*types.Interface); !ok { + return U // for non-interface types, + } + + terms, err := _NormalTerms(U) + if len(terms) == 0 || err != nil { + // len(terms) -> empty type set of interface. + // err != nil => U is invalid, exceeds complexity bounds, or has an empty type set. + return nil // no core type. + } + + U = terms[0].Type().Underlying() + var identical int // i in [0,identical) => Identical(U, terms[i].Type().Underlying()) + for identical = 1; identical < len(terms); identical++ { + if !types.Identical(U, terms[identical].Type().Underlying()) { + break + } + } + + if identical == len(terms) { + // https://go.dev/ref/spec#Core_types + // "There is a single type U which is the underlying type of all types in the type set of T" + return U + } + ch, ok := U.(*types.Chan) + if !ok { + return nil // no core type as identical < len(terms) and U is not a channel. + } + // https://go.dev/ref/spec#Core_types + // "the type chan E if T contains only bidirectional channels, or the type chan<- E or + // <-chan E depending on the direction of the directional channels present." + for chans := identical; chans < len(terms); chans++ { + curr, ok := terms[chans].Type().Underlying().(*types.Chan) + if !ok { + return nil + } + if !types.Identical(ch.Elem(), curr.Elem()) { + return nil // channel elements are not identical. + } + if ch.Dir() == types.SendRecv { + // ch is bidirectional. We can safely always use curr's direction. + ch = curr + } else if curr.Dir() != types.SendRecv && ch.Dir() != curr.Dir() { + // ch and curr are not bidirectional and not the same direction. + return nil + } + } + return ch +} + +// _NormalTerms returns a slice of terms representing the normalized structural +// type restrictions of a type, if any. +// +// For all types other than *types.TypeParam, *types.Interface, and +// *types.Union, this is just a single term with Tilde() == false and +// Type() == typ. For *types.TypeParam, *types.Interface, and *types.Union, see +// below. +// +// Structural type restrictions of a type parameter are created via +// non-interface types embedded in its constraint interface (directly, or via a +// chain of interface embeddings). For example, in the declaration type +// T[P interface{~int; m()}] int the structural restriction of the type +// parameter P is ~int. +// +// With interface embedding and unions, the specification of structural type +// restrictions may be arbitrarily complex. For example, consider the +// following: +// +// type A interface{ ~string|~[]byte } +// +// type B interface{ int|string } +// +// type C interface { ~string|~int } +// +// type T[P interface{ A|B; C }] int +// +// In this example, the structural type restriction of P is ~string|int: A|B +// expands to ~string|~[]byte|int|string, which reduces to ~string|~[]byte|int, +// which when intersected with C (~string|~int) yields ~string|int. +// +// _NormalTerms computes these expansions and reductions, producing a +// "normalized" form of the embeddings. A structural restriction is normalized +// if it is a single union containing no interface terms, and is minimal in the +// sense that removing any term changes the set of types satisfying the +// constraint. It is left as a proof for the reader that, modulo sorting, there +// is exactly one such normalized form. +// +// Because the minimal representation always takes this form, _NormalTerms +// returns a slice of tilde terms corresponding to the terms of the union in +// the normalized structural restriction. An error is returned if the type is +// invalid, exceeds complexity bounds, or has an empty type set. In the latter +// case, _NormalTerms returns ErrEmptyTypeSet. +// +// _NormalTerms makes no guarantees about the order of terms, except that it +// is deterministic. +func _NormalTerms(typ types.Type) ([]*Term, error) { + switch typ := typ.(type) { + case *TypeParam: + return StructuralTerms(typ) + case *Union: + return UnionTermSet(typ) + case *types.Interface: + return InterfaceTermSet(typ) + default: + return []*Term{NewTerm(false, typ)}, nil + } +} diff --git a/vendor/golang.org/x/tools/internal/typeparams/enabled_go117.go b/vendor/golang.org/x/tools/internal/typeparams/enabled_go117.go new file mode 100644 index 0000000000..18212390e1 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/typeparams/enabled_go117.go @@ -0,0 +1,12 @@ +// Copyright 2021 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. + +//go:build !go1.18 +// +build !go1.18 + +package typeparams + +// Enabled reports whether type parameters are enabled in the current build +// environment. +const Enabled = false diff --git a/vendor/golang.org/x/tools/internal/typeparams/enabled_go118.go b/vendor/golang.org/x/tools/internal/typeparams/enabled_go118.go new file mode 100644 index 0000000000..d67148823c --- /dev/null +++ b/vendor/golang.org/x/tools/internal/typeparams/enabled_go118.go @@ -0,0 +1,15 @@ +// Copyright 2021 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. + +//go:build go1.18 +// +build go1.18 + +package typeparams + +// Note: this constant is in a separate file as this is the only acceptable +// diff between the <1.18 API of this package and the 1.18 API. + +// Enabled reports whether type parameters are enabled in the current build +// environment. +const Enabled = true diff --git a/vendor/golang.org/x/tools/internal/typeparams/normalize.go b/vendor/golang.org/x/tools/internal/typeparams/normalize.go new file mode 100644 index 0000000000..9c631b6512 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/typeparams/normalize.go @@ -0,0 +1,218 @@ +// Copyright 2021 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. + +package typeparams + +import ( + "errors" + "fmt" + "go/types" + "os" + "strings" +) + +//go:generate go run copytermlist.go + +const debug = false + +var ErrEmptyTypeSet = errors.New("empty type set") + +// StructuralTerms returns a slice of terms representing the normalized +// structural type restrictions of a type parameter, if any. +// +// Structural type restrictions of a type parameter are created via +// non-interface types embedded in its constraint interface (directly, or via a +// chain of interface embeddings). For example, in the declaration +// +// type T[P interface{~int; m()}] int +// +// the structural restriction of the type parameter P is ~int. +// +// With interface embedding and unions, the specification of structural type +// restrictions may be arbitrarily complex. For example, consider the +// following: +// +// type A interface{ ~string|~[]byte } +// +// type B interface{ int|string } +// +// type C interface { ~string|~int } +// +// type T[P interface{ A|B; C }] int +// +// In this example, the structural type restriction of P is ~string|int: A|B +// expands to ~string|~[]byte|int|string, which reduces to ~string|~[]byte|int, +// which when intersected with C (~string|~int) yields ~string|int. +// +// StructuralTerms computes these expansions and reductions, producing a +// "normalized" form of the embeddings. A structural restriction is normalized +// if it is a single union containing no interface terms, and is minimal in the +// sense that removing any term changes the set of types satisfying the +// constraint. It is left as a proof for the reader that, modulo sorting, there +// is exactly one such normalized form. +// +// Because the minimal representation always takes this form, StructuralTerms +// returns a slice of tilde terms corresponding to the terms of the union in +// the normalized structural restriction. An error is returned if the +// constraint interface is invalid, exceeds complexity bounds, or has an empty +// type set. In the latter case, StructuralTerms returns ErrEmptyTypeSet. +// +// StructuralTerms makes no guarantees about the order of terms, except that it +// is deterministic. +func StructuralTerms(tparam *TypeParam) ([]*Term, error) { + constraint := tparam.Constraint() + if constraint == nil { + return nil, fmt.Errorf("%s has nil constraint", tparam) + } + iface, _ := constraint.Underlying().(*types.Interface) + if iface == nil { + return nil, fmt.Errorf("constraint is %T, not *types.Interface", constraint.Underlying()) + } + return InterfaceTermSet(iface) +} + +// InterfaceTermSet computes the normalized terms for a constraint interface, +// returning an error if the term set cannot be computed or is empty. In the +// latter case, the error will be ErrEmptyTypeSet. +// +// See the documentation of StructuralTerms for more information on +// normalization. +func InterfaceTermSet(iface *types.Interface) ([]*Term, error) { + return computeTermSet(iface) +} + +// UnionTermSet computes the normalized terms for a union, returning an error +// if the term set cannot be computed or is empty. In the latter case, the +// error will be ErrEmptyTypeSet. +// +// See the documentation of StructuralTerms for more information on +// normalization. +func UnionTermSet(union *Union) ([]*Term, error) { + return computeTermSet(union) +} + +func computeTermSet(typ types.Type) ([]*Term, error) { + tset, err := computeTermSetInternal(typ, make(map[types.Type]*termSet), 0) + if err != nil { + return nil, err + } + if tset.terms.isEmpty() { + return nil, ErrEmptyTypeSet + } + if tset.terms.isAll() { + return nil, nil + } + var terms []*Term + for _, term := range tset.terms { + terms = append(terms, NewTerm(term.tilde, term.typ)) + } + return terms, nil +} + +// A termSet holds the normalized set of terms for a given type. +// +// The name termSet is intentionally distinct from 'type set': a type set is +// all types that implement a type (and includes method restrictions), whereas +// a term set just represents the structural restrictions on a type. +type termSet struct { + complete bool + terms termlist +} + +func indentf(depth int, format string, args ...interface{}) { + fmt.Fprintf(os.Stderr, strings.Repeat(".", depth)+format+"\n", args...) +} + +func computeTermSetInternal(t types.Type, seen map[types.Type]*termSet, depth int) (res *termSet, err error) { + if t == nil { + panic("nil type") + } + + if debug { + indentf(depth, "%s", t.String()) + defer func() { + if err != nil { + indentf(depth, "=> %s", err) + } else { + indentf(depth, "=> %s", res.terms.String()) + } + }() + } + + const maxTermCount = 100 + if tset, ok := seen[t]; ok { + if !tset.complete { + return nil, fmt.Errorf("cycle detected in the declaration of %s", t) + } + return tset, nil + } + + // Mark the current type as seen to avoid infinite recursion. + tset := new(termSet) + defer func() { + tset.complete = true + }() + seen[t] = tset + + switch u := t.Underlying().(type) { + case *types.Interface: + // The term set of an interface is the intersection of the term sets of its + // embedded types. + tset.terms = allTermlist + for i := 0; i < u.NumEmbeddeds(); i++ { + embedded := u.EmbeddedType(i) + if _, ok := embedded.Underlying().(*TypeParam); ok { + return nil, fmt.Errorf("invalid embedded type %T", embedded) + } + tset2, err := computeTermSetInternal(embedded, seen, depth+1) + if err != nil { + return nil, err + } + tset.terms = tset.terms.intersect(tset2.terms) + } + case *Union: + // The term set of a union is the union of term sets of its terms. + tset.terms = nil + for i := 0; i < u.Len(); i++ { + t := u.Term(i) + var terms termlist + switch t.Type().Underlying().(type) { + case *types.Interface: + tset2, err := computeTermSetInternal(t.Type(), seen, depth+1) + if err != nil { + return nil, err + } + terms = tset2.terms + case *TypeParam, *Union: + // A stand-alone type parameter or union is not permitted as union + // term. + return nil, fmt.Errorf("invalid union term %T", t) + default: + if t.Type() == types.Typ[types.Invalid] { + continue + } + terms = termlist{{t.Tilde(), t.Type()}} + } + tset.terms = tset.terms.union(terms) + if len(tset.terms) > maxTermCount { + return nil, fmt.Errorf("exceeded max term count %d", maxTermCount) + } + } + case *TypeParam: + panic("unreachable") + default: + // For all other types, the term set is just a single non-tilde term + // holding the type itself. + if u != types.Typ[types.Invalid] { + tset.terms = termlist{{false, t}} + } + } + return tset, nil +} + +// under is a facade for the go/types internal function of the same name. It is +// used by typeterm.go. +func under(t types.Type) types.Type { + return t.Underlying() +} diff --git a/vendor/golang.org/x/tools/internal/typeparams/termlist.go b/vendor/golang.org/x/tools/internal/typeparams/termlist.go new file mode 100644 index 0000000000..933106a23d --- /dev/null +++ b/vendor/golang.org/x/tools/internal/typeparams/termlist.go @@ -0,0 +1,163 @@ +// Copyright 2021 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. + +// Code generated by copytermlist.go DO NOT EDIT. + +package typeparams + +import ( + "bytes" + "go/types" +) + +// A termlist represents the type set represented by the union +// t1 ∪ y2 ∪ ... tn of the type sets of the terms t1 to tn. +// A termlist is in normal form if all terms are disjoint. +// termlist operations don't require the operands to be in +// normal form. +type termlist []*term + +// allTermlist represents the set of all types. +// It is in normal form. +var allTermlist = termlist{new(term)} + +// String prints the termlist exactly (without normalization). +func (xl termlist) String() string { + if len(xl) == 0 { + return "∅" + } + var buf bytes.Buffer + for i, x := range xl { + if i > 0 { + buf.WriteString(" ∪ ") + } + buf.WriteString(x.String()) + } + return buf.String() +} + +// isEmpty reports whether the termlist xl represents the empty set of types. +func (xl termlist) isEmpty() bool { + // If there's a non-nil term, the entire list is not empty. + // If the termlist is in normal form, this requires at most + // one iteration. + for _, x := range xl { + if x != nil { + return false + } + } + return true +} + +// isAll reports whether the termlist xl represents the set of all types. +func (xl termlist) isAll() bool { + // If there's a 𝓤 term, the entire list is 𝓤. + // If the termlist is in normal form, this requires at most + // one iteration. + for _, x := range xl { + if x != nil && x.typ == nil { + return true + } + } + return false +} + +// norm returns the normal form of xl. +func (xl termlist) norm() termlist { + // Quadratic algorithm, but good enough for now. + // TODO(gri) fix asymptotic performance + used := make([]bool, len(xl)) + var rl termlist + for i, xi := range xl { + if xi == nil || used[i] { + continue + } + for j := i + 1; j < len(xl); j++ { + xj := xl[j] + if xj == nil || used[j] { + continue + } + if u1, u2 := xi.union(xj); u2 == nil { + // If we encounter a 𝓤 term, the entire list is 𝓤. + // Exit early. + // (Note that this is not just an optimization; + // if we continue, we may end up with a 𝓤 term + // and other terms and the result would not be + // in normal form.) + if u1.typ == nil { + return allTermlist + } + xi = u1 + used[j] = true // xj is now unioned into xi - ignore it in future iterations + } + } + rl = append(rl, xi) + } + return rl +} + +// union returns the union xl ∪ yl. +func (xl termlist) union(yl termlist) termlist { + return append(xl, yl...).norm() +} + +// intersect returns the intersection xl ∩ yl. +func (xl termlist) intersect(yl termlist) termlist { + if xl.isEmpty() || yl.isEmpty() { + return nil + } + + // Quadratic algorithm, but good enough for now. + // TODO(gri) fix asymptotic performance + var rl termlist + for _, x := range xl { + for _, y := range yl { + if r := x.intersect(y); r != nil { + rl = append(rl, r) + } + } + } + return rl.norm() +} + +// equal reports whether xl and yl represent the same type set. +func (xl termlist) equal(yl termlist) bool { + // TODO(gri) this should be more efficient + return xl.subsetOf(yl) && yl.subsetOf(xl) +} + +// includes reports whether t ∈ xl. +func (xl termlist) includes(t types.Type) bool { + for _, x := range xl { + if x.includes(t) { + return true + } + } + return false +} + +// supersetOf reports whether y ⊆ xl. +func (xl termlist) supersetOf(y *term) bool { + for _, x := range xl { + if y.subsetOf(x) { + return true + } + } + return false +} + +// subsetOf reports whether xl ⊆ yl. +func (xl termlist) subsetOf(yl termlist) bool { + if yl.isEmpty() { + return xl.isEmpty() + } + + // each term x of xl must be a subset of yl + for _, x := range xl { + if !yl.supersetOf(x) { + return false // x is not a subset yl + } + } + return true +} diff --git a/vendor/golang.org/x/tools/internal/typeparams/typeparams_go117.go b/vendor/golang.org/x/tools/internal/typeparams/typeparams_go117.go new file mode 100644 index 0000000000..b4788978ff --- /dev/null +++ b/vendor/golang.org/x/tools/internal/typeparams/typeparams_go117.go @@ -0,0 +1,197 @@ +// Copyright 2021 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. + +//go:build !go1.18 +// +build !go1.18 + +package typeparams + +import ( + "go/ast" + "go/token" + "go/types" +) + +func unsupported() { + panic("type parameters are unsupported at this go version") +} + +// IndexListExpr is a placeholder type, as type parameters are not supported at +// this Go version. Its methods panic on use. +type IndexListExpr struct { + ast.Expr + X ast.Expr // expression + Lbrack token.Pos // position of "[" + Indices []ast.Expr // index expressions + Rbrack token.Pos // position of "]" +} + +// ForTypeSpec returns an empty field list, as type parameters on not supported +// at this Go version. +func ForTypeSpec(*ast.TypeSpec) *ast.FieldList { + return nil +} + +// ForFuncType returns an empty field list, as type parameters are not +// supported at this Go version. +func ForFuncType(*ast.FuncType) *ast.FieldList { + return nil +} + +// TypeParam is a placeholder type, as type parameters are not supported at +// this Go version. Its methods panic on use. +type TypeParam struct{ types.Type } + +func (*TypeParam) Index() int { unsupported(); return 0 } +func (*TypeParam) Constraint() types.Type { unsupported(); return nil } +func (*TypeParam) Obj() *types.TypeName { unsupported(); return nil } + +// TypeParamList is a placeholder for an empty type parameter list. +type TypeParamList struct{} + +func (*TypeParamList) Len() int { return 0 } +func (*TypeParamList) At(int) *TypeParam { unsupported(); return nil } + +// TypeList is a placeholder for an empty type list. +type TypeList struct{} + +func (*TypeList) Len() int { return 0 } +func (*TypeList) At(int) types.Type { unsupported(); return nil } + +// NewTypeParam is unsupported at this Go version, and panics. +func NewTypeParam(name *types.TypeName, constraint types.Type) *TypeParam { + unsupported() + return nil +} + +// SetTypeParamConstraint is unsupported at this Go version, and panics. +func SetTypeParamConstraint(tparam *TypeParam, constraint types.Type) { + unsupported() +} + +// NewSignatureType calls types.NewSignature, panicking if recvTypeParams or +// typeParams is non-empty. +func NewSignatureType(recv *types.Var, recvTypeParams, typeParams []*TypeParam, params, results *types.Tuple, variadic bool) *types.Signature { + if len(recvTypeParams) != 0 || len(typeParams) != 0 { + panic("signatures cannot have type parameters at this Go version") + } + return types.NewSignature(recv, params, results, variadic) +} + +// ForSignature returns an empty slice. +func ForSignature(*types.Signature) *TypeParamList { + return nil +} + +// RecvTypeParams returns a nil slice. +func RecvTypeParams(sig *types.Signature) *TypeParamList { + return nil +} + +// IsComparable returns false, as no interfaces are type-restricted at this Go +// version. +func IsComparable(*types.Interface) bool { + return false +} + +// IsMethodSet returns true, as no interfaces are type-restricted at this Go +// version. +func IsMethodSet(*types.Interface) bool { + return true +} + +// IsImplicit returns false, as no interfaces are implicit at this Go version. +func IsImplicit(*types.Interface) bool { + return false +} + +// MarkImplicit does nothing, because this Go version does not have implicit +// interfaces. +func MarkImplicit(*types.Interface) {} + +// ForNamed returns an empty type parameter list, as type parameters are not +// supported at this Go version. +func ForNamed(*types.Named) *TypeParamList { + return nil +} + +// SetForNamed panics if tparams is non-empty. +func SetForNamed(_ *types.Named, tparams []*TypeParam) { + if len(tparams) > 0 { + unsupported() + } +} + +// NamedTypeArgs returns nil. +func NamedTypeArgs(*types.Named) *TypeList { + return nil +} + +// NamedTypeOrigin is the identity method at this Go version. +func NamedTypeOrigin(named *types.Named) types.Type { + return named +} + +// Term holds information about a structural type restriction. +type Term struct { + tilde bool + typ types.Type +} + +func (m *Term) Tilde() bool { return m.tilde } +func (m *Term) Type() types.Type { return m.typ } +func (m *Term) String() string { + pre := "" + if m.tilde { + pre = "~" + } + return pre + m.typ.String() +} + +// NewTerm is unsupported at this Go version, and panics. +func NewTerm(tilde bool, typ types.Type) *Term { + return &Term{tilde, typ} +} + +// Union is a placeholder type, as type parameters are not supported at this Go +// version. Its methods panic on use. +type Union struct{ types.Type } + +func (*Union) Len() int { return 0 } +func (*Union) Term(i int) *Term { unsupported(); return nil } + +// NewUnion is unsupported at this Go version, and panics. +func NewUnion(terms []*Term) *Union { + unsupported() + return nil +} + +// InitInstanceInfo is a noop at this Go version. +func InitInstanceInfo(*types.Info) {} + +// Instance is a placeholder type, as type parameters are not supported at this +// Go version. +type Instance struct { + TypeArgs *TypeList + Type types.Type +} + +// GetInstances returns a nil map, as type parameters are not supported at this +// Go version. +func GetInstances(info *types.Info) map[*ast.Ident]Instance { return nil } + +// Context is a placeholder type, as type parameters are not supported at +// this Go version. +type Context struct{} + +// NewContext returns a placeholder Context instance. +func NewContext() *Context { + return &Context{} +} + +// Instantiate is unsupported on this Go version, and panics. +func Instantiate(ctxt *Context, typ types.Type, targs []types.Type, validate bool) (types.Type, error) { + unsupported() + return nil, nil +} diff --git a/vendor/golang.org/x/tools/internal/typeparams/typeparams_go118.go b/vendor/golang.org/x/tools/internal/typeparams/typeparams_go118.go new file mode 100644 index 0000000000..114a36b866 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/typeparams/typeparams_go118.go @@ -0,0 +1,151 @@ +// Copyright 2021 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. + +//go:build go1.18 +// +build go1.18 + +package typeparams + +import ( + "go/ast" + "go/types" +) + +// IndexListExpr is an alias for ast.IndexListExpr. +type IndexListExpr = ast.IndexListExpr + +// ForTypeSpec returns n.TypeParams. +func ForTypeSpec(n *ast.TypeSpec) *ast.FieldList { + if n == nil { + return nil + } + return n.TypeParams +} + +// ForFuncType returns n.TypeParams. +func ForFuncType(n *ast.FuncType) *ast.FieldList { + if n == nil { + return nil + } + return n.TypeParams +} + +// TypeParam is an alias for types.TypeParam +type TypeParam = types.TypeParam + +// TypeParamList is an alias for types.TypeParamList +type TypeParamList = types.TypeParamList + +// TypeList is an alias for types.TypeList +type TypeList = types.TypeList + +// NewTypeParam calls types.NewTypeParam. +func NewTypeParam(name *types.TypeName, constraint types.Type) *TypeParam { + return types.NewTypeParam(name, constraint) +} + +// SetTypeParamConstraint calls tparam.SetConstraint(constraint). +func SetTypeParamConstraint(tparam *TypeParam, constraint types.Type) { + tparam.SetConstraint(constraint) +} + +// NewSignatureType calls types.NewSignatureType. +func NewSignatureType(recv *types.Var, recvTypeParams, typeParams []*TypeParam, params, results *types.Tuple, variadic bool) *types.Signature { + return types.NewSignatureType(recv, recvTypeParams, typeParams, params, results, variadic) +} + +// ForSignature returns sig.TypeParams() +func ForSignature(sig *types.Signature) *TypeParamList { + return sig.TypeParams() +} + +// RecvTypeParams returns sig.RecvTypeParams(). +func RecvTypeParams(sig *types.Signature) *TypeParamList { + return sig.RecvTypeParams() +} + +// IsComparable calls iface.IsComparable(). +func IsComparable(iface *types.Interface) bool { + return iface.IsComparable() +} + +// IsMethodSet calls iface.IsMethodSet(). +func IsMethodSet(iface *types.Interface) bool { + return iface.IsMethodSet() +} + +// IsImplicit calls iface.IsImplicit(). +func IsImplicit(iface *types.Interface) bool { + return iface.IsImplicit() +} + +// MarkImplicit calls iface.MarkImplicit(). +func MarkImplicit(iface *types.Interface) { + iface.MarkImplicit() +} + +// ForNamed extracts the (possibly empty) type parameter object list from +// named. +func ForNamed(named *types.Named) *TypeParamList { + return named.TypeParams() +} + +// SetForNamed sets the type params tparams on n. Each tparam must be of +// dynamic type *types.TypeParam. +func SetForNamed(n *types.Named, tparams []*TypeParam) { + n.SetTypeParams(tparams) +} + +// NamedTypeArgs returns named.TypeArgs(). +func NamedTypeArgs(named *types.Named) *TypeList { + return named.TypeArgs() +} + +// NamedTypeOrigin returns named.Orig(). +func NamedTypeOrigin(named *types.Named) types.Type { + return named.Origin() +} + +// Term is an alias for types.Term. +type Term = types.Term + +// NewTerm calls types.NewTerm. +func NewTerm(tilde bool, typ types.Type) *Term { + return types.NewTerm(tilde, typ) +} + +// Union is an alias for types.Union +type Union = types.Union + +// NewUnion calls types.NewUnion. +func NewUnion(terms []*Term) *Union { + return types.NewUnion(terms) +} + +// InitInstanceInfo initializes info to record information about type and +// function instances. +func InitInstanceInfo(info *types.Info) { + info.Instances = make(map[*ast.Ident]types.Instance) +} + +// Instance is an alias for types.Instance. +type Instance = types.Instance + +// GetInstances returns info.Instances. +func GetInstances(info *types.Info) map[*ast.Ident]Instance { + return info.Instances +} + +// Context is an alias for types.Context. +type Context = types.Context + +// NewContext calls types.NewContext. +func NewContext() *Context { + return types.NewContext() +} + +// Instantiate calls types.Instantiate. +func Instantiate(ctxt *Context, typ types.Type, targs []types.Type, validate bool) (types.Type, error) { + return types.Instantiate(ctxt, typ, targs, validate) +} diff --git a/vendor/golang.org/x/tools/internal/typeparams/typeterm.go b/vendor/golang.org/x/tools/internal/typeparams/typeterm.go new file mode 100644 index 0000000000..7ddee28d98 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/typeparams/typeterm.go @@ -0,0 +1,170 @@ +// Copyright 2021 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. + +// Code generated by copytermlist.go DO NOT EDIT. + +package typeparams + +import "go/types" + +// A term describes elementary type sets: +// +// ∅: (*term)(nil) == ∅ // set of no types (empty set) +// 𝓤: &term{} == 𝓤 // set of all types (𝓤niverse) +// T: &term{false, T} == {T} // set of type T +// ~t: &term{true, t} == {t' | under(t') == t} // set of types with underlying type t +// +type term struct { + tilde bool // valid if typ != nil + typ types.Type +} + +func (x *term) String() string { + switch { + case x == nil: + return "∅" + case x.typ == nil: + return "𝓤" + case x.tilde: + return "~" + x.typ.String() + default: + return x.typ.String() + } +} + +// equal reports whether x and y represent the same type set. +func (x *term) equal(y *term) bool { + // easy cases + switch { + case x == nil || y == nil: + return x == y + case x.typ == nil || y.typ == nil: + return x.typ == y.typ + } + // ∅ ⊂ x, y ⊂ 𝓤 + + return x.tilde == y.tilde && types.Identical(x.typ, y.typ) +} + +// union returns the union x ∪ y: zero, one, or two non-nil terms. +func (x *term) union(y *term) (_, _ *term) { + // easy cases + switch { + case x == nil && y == nil: + return nil, nil // ∅ ∪ ∅ == ∅ + case x == nil: + return y, nil // ∅ ∪ y == y + case y == nil: + return x, nil // x ∪ ∅ == x + case x.typ == nil: + return x, nil // 𝓤 ∪ y == 𝓤 + case y.typ == nil: + return y, nil // x ∪ 𝓤 == 𝓤 + } + // ∅ ⊂ x, y ⊂ 𝓤 + + if x.disjoint(y) { + return x, y // x ∪ y == (x, y) if x ∩ y == ∅ + } + // x.typ == y.typ + + // ~t ∪ ~t == ~t + // ~t ∪ T == ~t + // T ∪ ~t == ~t + // T ∪ T == T + if x.tilde || !y.tilde { + return x, nil + } + return y, nil +} + +// intersect returns the intersection x ∩ y. +func (x *term) intersect(y *term) *term { + // easy cases + switch { + case x == nil || y == nil: + return nil // ∅ ∩ y == ∅ and ∩ ∅ == ∅ + case x.typ == nil: + return y // 𝓤 ∩ y == y + case y.typ == nil: + return x // x ∩ 𝓤 == x + } + // ∅ ⊂ x, y ⊂ 𝓤 + + if x.disjoint(y) { + return nil // x ∩ y == ∅ if x ∩ y == ∅ + } + // x.typ == y.typ + + // ~t ∩ ~t == ~t + // ~t ∩ T == T + // T ∩ ~t == T + // T ∩ T == T + if !x.tilde || y.tilde { + return x + } + return y +} + +// includes reports whether t ∈ x. +func (x *term) includes(t types.Type) bool { + // easy cases + switch { + case x == nil: + return false // t ∈ ∅ == false + case x.typ == nil: + return true // t ∈ 𝓤 == true + } + // ∅ ⊂ x ⊂ 𝓤 + + u := t + if x.tilde { + u = under(u) + } + return types.Identical(x.typ, u) +} + +// subsetOf reports whether x ⊆ y. +func (x *term) subsetOf(y *term) bool { + // easy cases + switch { + case x == nil: + return true // ∅ ⊆ y == true + case y == nil: + return false // x ⊆ ∅ == false since x != ∅ + case y.typ == nil: + return true // x ⊆ 𝓤 == true + case x.typ == nil: + return false // 𝓤 ⊆ y == false since y != 𝓤 + } + // ∅ ⊂ x, y ⊂ 𝓤 + + if x.disjoint(y) { + return false // x ⊆ y == false if x ∩ y == ∅ + } + // x.typ == y.typ + + // ~t ⊆ ~t == true + // ~t ⊆ T == false + // T ⊆ ~t == true + // T ⊆ T == true + return !x.tilde || y.tilde +} + +// disjoint reports whether x ∩ y == ∅. +// x.typ and y.typ must not be nil. +func (x *term) disjoint(y *term) bool { + if debug && (x.typ == nil || y.typ == nil) { + panic("invalid argument(s)") + } + ux := x.typ + if y.tilde { + ux = under(ux) + } + uy := y.typ + if x.tilde { + uy = under(uy) + } + return !types.Identical(ux, uy) +} diff --git a/vendor/golang.zx2c4.com/wireguard/wgctrl/LICENSE.md b/vendor/golang.zx2c4.com/wireguard/wgctrl/LICENSE.md index 9807819f8e..4fa501057b 100644 --- a/vendor/golang.zx2c4.com/wireguard/wgctrl/LICENSE.md +++ b/vendor/golang.zx2c4.com/wireguard/wgctrl/LICENSE.md @@ -1,6 +1,6 @@ # MIT License -Copyright (C) 2018-2019 Matt Layher +Copyright (C) 2018-2022 Matt Layher Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/vendor/golang.zx2c4.com/wireguard/wgctrl/wgtypes/errors.go b/vendor/golang.zx2c4.com/wireguard/wgctrl/wgtypes/errors.go new file mode 100644 index 0000000000..2546410b15 --- /dev/null +++ b/vendor/golang.zx2c4.com/wireguard/wgctrl/wgtypes/errors.go @@ -0,0 +1,10 @@ +package wgtypes + +import ( + "errors" +) + +// ErrUpdateOnlyNotSupported is returned due to missing kernel support of +// the PeerConfig UpdateOnly flag. +var ErrUpdateOnlyNotSupported = errors.New("the UpdateOnly flag is not supported by this platform") + diff --git a/vendor/golang.zx2c4.com/wireguard/wgctrl/wgtypes/types.go b/vendor/golang.zx2c4.com/wireguard/wgctrl/wgtypes/types.go index 7d17b62e99..3b33b54df2 100644 --- a/vendor/golang.zx2c4.com/wireguard/wgctrl/wgtypes/types.go +++ b/vendor/golang.zx2c4.com/wireguard/wgctrl/wgtypes/types.go @@ -18,6 +18,8 @@ const ( Unknown DeviceType = iota LinuxKernel OpenBSDKernel + FreeBSDKernel + WindowsKernel Userspace ) @@ -28,6 +30,10 @@ func (dt DeviceType) String() string { return "Linux kernel" case OpenBSDKernel: return "OpenBSD kernel" + case FreeBSDKernel: + return "FreeBSD kernel" + case WindowsKernel: + return "Windows kernel" case Userspace: return "userspace" default: @@ -241,6 +247,10 @@ type PeerConfig struct { // from a device's peer list. Remove bool + // UpdateOnly specifies that an operation will only occur on this peer + // if the peer already exists as part of the interface. + UpdateOnly bool + // PresharedKey specifies a peer's preshared key configuration, if not nil. // // A non-nil, zero-value Key will clear the preshared key. diff --git a/vendor/gopkg.in/ini.v1/.travis.yml b/vendor/gopkg.in/ini.v1/.travis.yml deleted file mode 100644 index 17d3dc5a9f..0000000000 --- a/vendor/gopkg.in/ini.v1/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -sudo: false -language: go -go: - - 1.6.x - - 1.7.x - - 1.8.x - - 1.9.x - - 1.10.x - - 1.11.x - - 1.12.x - -script: - - go get golang.org/x/tools/cmd/cover - - go get github.com/smartystreets/goconvey - - mkdir -p $HOME/gopath/src/gopkg.in - - ln -s $HOME/gopath/src/github.com/go-ini/ini $HOME/gopath/src/gopkg.in/ini.v1 - - cd $HOME/gopath/src/gopkg.in/ini.v1 - - go test -v -cover -race diff --git a/vendor/gopkg.in/ini.v1/Makefile b/vendor/gopkg.in/ini.v1/Makefile index af27ff0768..f3b0dae2d2 100644 --- a/vendor/gopkg.in/ini.v1/Makefile +++ b/vendor/gopkg.in/ini.v1/Makefile @@ -6,7 +6,7 @@ test: go test -v -cover -race bench: - go test -v -cover -race -test.bench=. -test.benchmem + go test -v -cover -test.bench=. -test.benchmem vet: go vet diff --git a/vendor/gopkg.in/ini.v1/README.md b/vendor/gopkg.in/ini.v1/README.md index ae4dfc3a5a..5d65658b29 100644 --- a/vendor/gopkg.in/ini.v1/README.md +++ b/vendor/gopkg.in/ini.v1/README.md @@ -1,5 +1,9 @@ -INI [![Build Status](https://travis-ci.org/go-ini/ini.svg?branch=master)](https://travis-ci.org/go-ini/ini) [![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg)](https://sourcegraph.com/github.com/go-ini/ini) -=== +# INI + +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/go-ini/ini/Go?logo=github&style=for-the-badge)](https://github.com/go-ini/ini/actions?query=workflow%3AGo) +[![codecov](https://img.shields.io/codecov/c/github/go-ini/ini/master?logo=codecov&style=for-the-badge)](https://codecov.io/gh/go-ini/ini) +[![GoDoc](https://img.shields.io/badge/GoDoc-Reference-blue?style=for-the-badge&logo=go)](https://pkg.go.dev/github.com/go-ini/ini?tab=doc) +[![Sourcegraph](https://img.shields.io/badge/view%20on-Sourcegraph-brightgreen.svg?style=for-the-badge&logo=sourcegraph)](https://sourcegraph.com/github.com/go-ini/ini) ![](https://avatars0.githubusercontent.com/u/10216035?v=3&s=200) @@ -7,7 +11,7 @@ Package ini provides INI file read and write functionality in Go. ## Features -- Load from multiple data sources(`[]byte`, file and `io.ReadCloser`) with overwrites. +- Load from multiple data sources(file, `[]byte`, `io.Reader` and `io.ReadCloser`) with overwrites. - Read with recursion values. - Read with parent-child sections. - Read with auto-increment key names. @@ -22,24 +26,17 @@ Package ini provides INI file read and write functionality in Go. The minimum requirement of Go is **1.6**. -To use a tagged revision: - ```sh $ go get gopkg.in/ini.v1 ``` -To use with latest changes: - -```sh -$ go get github.com/go-ini/ini -``` - Please add `-u` flag to update in the future. ## Getting Help - [Getting Started](https://ini.unknwon.io/docs/intro/getting_started) - [API Documentation](https://gowalker.org/gopkg.in/ini.v1) +- 中国大陆镜像:https://ini.unknwon.cn ## License diff --git a/vendor/gopkg.in/ini.v1/codecov.yml b/vendor/gopkg.in/ini.v1/codecov.yml new file mode 100644 index 0000000000..fc947f2308 --- /dev/null +++ b/vendor/gopkg.in/ini.v1/codecov.yml @@ -0,0 +1,9 @@ +coverage: + range: "60...95" + status: + project: + default: + threshold: 1% + +comment: + layout: 'diff, files' diff --git a/vendor/gopkg.in/ini.v1/data_source.go b/vendor/gopkg.in/ini.v1/data_source.go new file mode 100644 index 0000000000..c3a541f1d1 --- /dev/null +++ b/vendor/gopkg.in/ini.v1/data_source.go @@ -0,0 +1,76 @@ +// Copyright 2019 Unknwon +// +// 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 ini + +import ( + "bytes" + "fmt" + "io" + "io/ioutil" + "os" +) + +var ( + _ dataSource = (*sourceFile)(nil) + _ dataSource = (*sourceData)(nil) + _ dataSource = (*sourceReadCloser)(nil) +) + +// dataSource is an interface that returns object which can be read and closed. +type dataSource interface { + ReadCloser() (io.ReadCloser, error) +} + +// sourceFile represents an object that contains content on the local file system. +type sourceFile struct { + name string +} + +func (s sourceFile) ReadCloser() (_ io.ReadCloser, err error) { + return os.Open(s.name) +} + +// sourceData represents an object that contains content in memory. +type sourceData struct { + data []byte +} + +func (s *sourceData) ReadCloser() (io.ReadCloser, error) { + return ioutil.NopCloser(bytes.NewReader(s.data)), nil +} + +// sourceReadCloser represents an input stream with Close method. +type sourceReadCloser struct { + reader io.ReadCloser +} + +func (s *sourceReadCloser) ReadCloser() (io.ReadCloser, error) { + return s.reader, nil +} + +func parseDataSource(source interface{}) (dataSource, error) { + switch s := source.(type) { + case string: + return sourceFile{s}, nil + case []byte: + return &sourceData{s}, nil + case io.ReadCloser: + return &sourceReadCloser{s}, nil + case io.Reader: + return &sourceReadCloser{ioutil.NopCloser(s)}, nil + default: + return nil, fmt.Errorf("error parsing data source: unknown type %q", s) + } +} diff --git a/vendor/gopkg.in/ini.v1/deprecated.go b/vendor/gopkg.in/ini.v1/deprecated.go new file mode 100644 index 0000000000..e8bda06e6f --- /dev/null +++ b/vendor/gopkg.in/ini.v1/deprecated.go @@ -0,0 +1,25 @@ +// Copyright 2019 Unknwon +// +// 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 ini + +const ( + // Deprecated: Use "DefaultSection" instead. + DEFAULT_SECTION = DefaultSection +) + +var ( + // Deprecated: AllCapsUnderscore converts to format ALL_CAPS_UNDERSCORE. + AllCapsUnderscore = SnackCase +) diff --git a/vendor/gopkg.in/ini.v1/file.go b/vendor/gopkg.in/ini.v1/file.go index b38aadd1f8..b96d172cf4 100644 --- a/vendor/gopkg.in/ini.v1/file.go +++ b/vendor/gopkg.in/ini.v1/file.go @@ -25,7 +25,7 @@ import ( "sync" ) -// File represents a combination of a or more INI file(s) in memory. +// File represents a combination of one or more INI files in memory. type File struct { options LoadOptions dataSources []dataSource @@ -36,8 +36,12 @@ type File struct { // To keep data in order. sectionList []string + // To keep track of the index of a section with same name. + // This meta list is only used with non-unique section names are allowed. + sectionIndexes []int + // Actual data is stored here. - sections map[string]*Section + sections map[string][]*Section NameMapper ValueMapper @@ -48,27 +52,40 @@ func newFile(dataSources []dataSource, opts LoadOptions) *File { if len(opts.KeyValueDelimiters) == 0 { opts.KeyValueDelimiters = "=:" } + if len(opts.KeyValueDelimiterOnWrite) == 0 { + opts.KeyValueDelimiterOnWrite = "=" + } + if len(opts.ChildSectionDelimiter) == 0 { + opts.ChildSectionDelimiter = "." + } + return &File{ BlockMode: true, dataSources: dataSources, - sections: make(map[string]*Section), - sectionList: make([]string, 0, 10), + sections: make(map[string][]*Section), options: opts, } } // Empty returns an empty file object. -func Empty() *File { - // Ignore error here, we sure our data is good. - f, _ := Load([]byte("")) +func Empty(opts ...LoadOptions) *File { + var opt LoadOptions + if len(opts) > 0 { + opt = opts[0] + } + + // Ignore error here, we are sure our data is good. + f, _ := LoadSources(opt, []byte("")) return f } // NewSection creates a new section. func (f *File) NewSection(name string) (*Section, error) { if len(name) == 0 { - return nil, errors.New("error creating new section: empty section name") - } else if f.options.Insensitive && name != DefaultSection { + return nil, errors.New("empty section name") + } + + if (f.options.Insensitive || f.options.InsensitiveSections) && name != DefaultSection { name = strings.ToLower(name) } @@ -77,13 +94,20 @@ func (f *File) NewSection(name string) (*Section, error) { defer f.lock.Unlock() } - if inSlice(name, f.sectionList) { - return f.sections[name], nil + if !f.options.AllowNonUniqueSections && inSlice(name, f.sectionList) { + return f.sections[name][0], nil } f.sectionList = append(f.sectionList, name) - f.sections[name] = newSection(f, name) - return f.sections[name], nil + + // NOTE: Append to indexes must happen before appending to sections, + // otherwise index will have off-by-one problem. + f.sectionIndexes = append(f.sectionIndexes, len(f.sections[name])) + + sec := newSection(f, name) + f.sections[name] = append(f.sections[name], sec) + + return sec, nil } // NewRawSection creates a new section with an unparseable body. @@ -110,10 +134,20 @@ func (f *File) NewSections(names ...string) (err error) { // GetSection returns section by given name. func (f *File) GetSection(name string) (*Section, error) { + secs, err := f.SectionsByName(name) + if err != nil { + return nil, err + } + + return secs[0], err +} + +// SectionsByName returns all sections with given name. +func (f *File) SectionsByName(name string) ([]*Section, error) { if len(name) == 0 { name = DefaultSection } - if f.options.Insensitive { + if f.options.Insensitive || f.options.InsensitiveSections { name = strings.ToLower(name) } @@ -122,11 +156,12 @@ func (f *File) GetSection(name string) (*Section, error) { defer f.lock.RUnlock() } - sec := f.sections[name] - if sec == nil { - return nil, fmt.Errorf("section '%s' does not exist", name) + secs := f.sections[name] + if len(secs) == 0 { + return nil, fmt.Errorf("section %q does not exist", name) } - return sec, nil + + return secs, nil } // Section assumes named section exists and returns a zero-value when not. @@ -141,6 +176,19 @@ func (f *File) Section(name string) *Section { return sec } +// SectionWithIndex assumes named section exists and returns a new section when not. +func (f *File) SectionWithIndex(name string, index int) *Section { + secs, err := f.SectionsByName(name) + if err != nil || len(secs) <= index { + // NOTE: It's OK here because the only possible error is empty section name, + // but if it's empty, this piece of code won't be executed. + newSec, _ := f.NewSection(name) + return newSec + } + + return secs[index] +} + // Sections returns a list of Section stored in the current instance. func (f *File) Sections() []*Section { if f.BlockMode { @@ -150,7 +198,7 @@ func (f *File) Sections() []*Section { sections := make([]*Section, len(f.sectionList)) for i, name := range f.sectionList { - sections[i] = f.sections[name] + sections[i] = f.sections[name][f.sectionIndexes[i]] } return sections } @@ -167,24 +215,70 @@ func (f *File) SectionStrings() []string { return list } -// DeleteSection deletes a section. +// DeleteSection deletes a section or all sections with given name. func (f *File) DeleteSection(name string) { - if f.BlockMode { - f.lock.Lock() - defer f.lock.Unlock() + secs, err := f.SectionsByName(name) + if err != nil { + return + } + + for i := 0; i < len(secs); i++ { + // For non-unique sections, it is always needed to remove the first one so + // in the next iteration, the subsequent section continue having index 0. + // Ignoring the error as index 0 never returns an error. + _ = f.DeleteSectionWithIndex(name, 0) + } +} + +// DeleteSectionWithIndex deletes a section with given name and index. +func (f *File) DeleteSectionWithIndex(name string, index int) error { + if !f.options.AllowNonUniqueSections && index != 0 { + return fmt.Errorf("delete section with non-zero index is only allowed when non-unique sections is enabled") } if len(name) == 0 { name = DefaultSection } - - for i, s := range f.sectionList { - if s == name { - f.sectionList = append(f.sectionList[:i], f.sectionList[i+1:]...) - delete(f.sections, name) - return - } + if f.options.Insensitive || f.options.InsensitiveSections { + name = strings.ToLower(name) } + + if f.BlockMode { + f.lock.Lock() + defer f.lock.Unlock() + } + + // Count occurrences of the sections + occurrences := 0 + + sectionListCopy := make([]string, len(f.sectionList)) + copy(sectionListCopy, f.sectionList) + + for i, s := range sectionListCopy { + if s != name { + continue + } + + if occurrences == index { + if len(f.sections[name]) <= 1 { + delete(f.sections, name) // The last one in the map + } else { + f.sections[name] = append(f.sections[name][:index], f.sections[name][index+1:]...) + } + + // Fix section lists + f.sectionList = append(f.sectionList[:i], f.sectionList[i+1:]...) + f.sectionIndexes = append(f.sectionIndexes[:i], f.sectionIndexes[i+1:]...) + + } else if occurrences > index { + // Fix the indices of all following sections with this name. + f.sectionIndexes[i-1]-- + } + + occurrences++ + } + + return nil } func (f *File) reload(s dataSource) error { @@ -203,11 +297,14 @@ func (f *File) Reload() (err error) { if err = f.reload(s); err != nil { // In loose mode, we create an empty default section for nonexistent files. if os.IsNotExist(err) && f.options.Loose { - f.parse(bytes.NewBuffer(nil)) + _ = f.parse(bytes.NewBuffer(nil)) continue } return err } + if f.options.ShortCircuit { + return nil + } } return nil } @@ -230,16 +327,16 @@ func (f *File) Append(source interface{}, others ...interface{}) error { } func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) { - equalSign := DefaultFormatLeft + "=" + DefaultFormatRight + equalSign := DefaultFormatLeft + f.options.KeyValueDelimiterOnWrite + DefaultFormatRight if PrettyFormat || PrettyEqual { - equalSign = " = " + equalSign = fmt.Sprintf(" %s ", f.options.KeyValueDelimiterOnWrite) } // Use buffer to make sure target is safe until finish encoding. buf := bytes.NewBuffer(nil) for i, sname := range f.sectionList { - sec := f.Section(sname) + sec := f.SectionWithIndex(sname, f.sectionIndexes[i]) if len(sec.Comment) > 0 { // Support multiline comments lines := strings.Split(sec.Comment, LineBreak) @@ -256,7 +353,7 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) { } } - if i > 0 || DefaultHeader { + if i > 0 || DefaultHeader || (i == 0 && strings.ToUpper(sec.name) != DefaultSection) { if _, err := buf.WriteString("[" + sname + "]" + LineBreak); err != nil { return nil, err } @@ -282,7 +379,7 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) { } // Count and generate alignment length and buffer spaces using the - // longest key. Keys may be modifed if they contain certain characters so + // longest key. Keys may be modified if they contain certain characters so // we need to take that into account in our calculation. alignLength := 0 if PrettyFormat { @@ -302,7 +399,7 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) { } alignSpaces := bytes.Repeat([]byte(" "), alignLength) - KEY_LIST: + KeyList: for _, kname := range sec.keyList { key := sec.Key(kname) if len(key.Comment) > 0 { @@ -347,7 +444,7 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) { if kname != sec.keyList[len(sec.keyList)-1] { buf.WriteString(LineBreak) } - continue KEY_LIST + continue KeyList } // Write out alignment spaces before "=" sign @@ -360,6 +457,8 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) { val = `"""` + val + `"""` } else if !f.options.IgnoreInlineComment && strings.ContainsAny(val, "#;") { val = "`" + val + "`" + } else if len(strings.TrimSpace(val)) != len(val) { + val = `"` + val + `"` } if _, err := buf.WriteString(equalSign + val + LineBreak); err != nil { return nil, err @@ -403,7 +502,7 @@ func (f *File) WriteTo(w io.Writer) (int64, error) { // SaveToIndent writes content to file system with given value indention. func (f *File) SaveToIndent(filename, indent string) error { // Note: Because we are truncating with os.Create, - // so it's safer to save to a temporary file location and rename afte done. + // so it's safer to save to a temporary file location and rename after done. buf, err := f.writeToBuffer(indent) if err != nil { return err diff --git a/vendor/gopkg.in/ini.v1/helper.go b/vendor/gopkg.in/ini.v1/helper.go new file mode 100644 index 0000000000..f9d80a682a --- /dev/null +++ b/vendor/gopkg.in/ini.v1/helper.go @@ -0,0 +1,24 @@ +// Copyright 2019 Unknwon +// +// 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 ini + +func inSlice(str string, s []string) bool { + for _, v := range s { + if str == v { + return true + } + } + return false +} diff --git a/vendor/gopkg.in/ini.v1/ini.go b/vendor/gopkg.in/ini.v1/ini.go index 03cd57ff96..23f07422ef 100644 --- a/vendor/gopkg.in/ini.v1/ini.go +++ b/vendor/gopkg.in/ini.v1/ini.go @@ -18,131 +18,71 @@ package ini import ( - "bytes" - "fmt" - "io" - "io/ioutil" "os" "regexp" "runtime" + "strings" ) const ( // DefaultSection is the name of default section. You can use this constant or the string literal. // In most of cases, an empty string is all you need to access the section. DefaultSection = "DEFAULT" - // Deprecated: Use "DefaultSection" instead. - DEFAULT_SECTION = DefaultSection // Maximum allowed depth when recursively substituing variable names. depthValues = 99 - version = "1.44.0" ) -// Version returns current package version literal. -func Version() string { - return version -} - var ( // LineBreak is the delimiter to determine or compose a new line. // This variable will be changed to "\r\n" automatically on Windows at package init time. LineBreak = "\n" - // DefaultFormatLeft places custom spaces on the left when PrettyFormat and PrettyEqual are both disabled. - DefaultFormatLeft = "" - // DefaultFormatRight places custom spaces on the right when PrettyFormat and PrettyEqual are both disabled. - DefaultFormatRight = "" - // Variable regexp pattern: %(variable)s - varPattern = regexp.MustCompile(`%\(([^\)]+)\)s`) - - // PrettyFormat indicates whether to align "=" sign with spaces to produce pretty output - // or reduce all possible spaces for compact format. - PrettyFormat = true - - // PrettyEqual places spaces around "=" sign even when PrettyFormat is false. - PrettyEqual = false + varPattern = regexp.MustCompile(`%\(([^)]+)\)s`) // DefaultHeader explicitly writes default section header. DefaultHeader = false // PrettySection indicates whether to put a line between sections. PrettySection = true + // PrettyFormat indicates whether to align "=" sign with spaces to produce pretty output + // or reduce all possible spaces for compact format. + PrettyFormat = true + // PrettyEqual places spaces around "=" sign even when PrettyFormat is false. + PrettyEqual = false + // DefaultFormatLeft places custom spaces on the left when PrettyFormat and PrettyEqual are both disabled. + DefaultFormatLeft = "" + // DefaultFormatRight places custom spaces on the right when PrettyFormat and PrettyEqual are both disabled. + DefaultFormatRight = "" ) +var inTest = len(os.Args) > 0 && strings.HasSuffix(strings.TrimSuffix(os.Args[0], ".exe"), ".test") + func init() { - if runtime.GOOS == "windows" { + if runtime.GOOS == "windows" && !inTest { LineBreak = "\r\n" } } -func inSlice(str string, s []string) bool { - for _, v := range s { - if str == v { - return true - } - } - return false -} - -// dataSource is an interface that returns object which can be read and closed. -type dataSource interface { - ReadCloser() (io.ReadCloser, error) -} - -// sourceFile represents an object that contains content on the local file system. -type sourceFile struct { - name string -} - -func (s sourceFile) ReadCloser() (_ io.ReadCloser, err error) { - return os.Open(s.name) -} - -// sourceData represents an object that contains content in memory. -type sourceData struct { - data []byte -} - -func (s *sourceData) ReadCloser() (io.ReadCloser, error) { - return ioutil.NopCloser(bytes.NewReader(s.data)), nil -} - -// sourceReadCloser represents an input stream with Close method. -type sourceReadCloser struct { - reader io.ReadCloser -} - -func (s *sourceReadCloser) ReadCloser() (io.ReadCloser, error) { - return s.reader, nil -} - -func parseDataSource(source interface{}) (dataSource, error) { - switch s := source.(type) { - case string: - return sourceFile{s}, nil - case []byte: - return &sourceData{s}, nil - case io.ReadCloser: - return &sourceReadCloser{s}, nil - default: - return nil, fmt.Errorf("error parsing data source: unknown type '%s'", s) - } -} - // LoadOptions contains all customized options used for load data source(s). type LoadOptions struct { // Loose indicates whether the parser should ignore nonexistent files or return error. Loose bool // Insensitive indicates whether the parser forces all section and key names to lowercase. Insensitive bool + // InsensitiveSections indicates whether the parser forces all section to lowercase. + InsensitiveSections bool + // InsensitiveKeys indicates whether the parser forces all key names to lowercase. + InsensitiveKeys bool // IgnoreContinuation indicates whether to ignore continuation lines while parsing. IgnoreContinuation bool // IgnoreInlineComment indicates whether to ignore comments at the end of value and treat it as part of value. IgnoreInlineComment bool // SkipUnrecognizableLines indicates whether to skip unrecognizable lines that do not conform to key/value pairs. SkipUnrecognizableLines bool + // ShortCircuit indicates whether to ignore other configuration sources after loaded the first available configuration source. + ShortCircuit bool // AllowBooleanKeys indicates whether to allow boolean type keys or treat as value is missing. // This type of keys are mostly used in my.cnf. AllowBooleanKeys bool @@ -173,10 +113,23 @@ type LoadOptions struct { UnparseableSections []string // KeyValueDelimiters is the sequence of delimiters that are used to separate key and value. By default, it is "=:". KeyValueDelimiters string + // KeyValueDelimiterOnWrite is the delimiter that are used to separate key and value output. By default, it is "=". + KeyValueDelimiterOnWrite string + // ChildSectionDelimiter is the delimiter that is used to separate child sections. By default, it is ".". + ChildSectionDelimiter string // PreserveSurroundedQuote indicates whether to preserve surrounded quote (single and double quotes). PreserveSurroundedQuote bool + // DebugFunc is called to collect debug information (currently only useful to debug parsing Python-style multiline values). + DebugFunc DebugFunc + // ReaderBufferSize is the buffer size of the reader in bytes. + ReaderBufferSize int + // AllowNonUniqueSections indicates whether to allow sections with the same name multiple times. + AllowNonUniqueSections bool } +// DebugFunc is the type of function called to log parse events. +type DebugFunc func(message string) + // LoadSources allows caller to apply customized options for loading from data source(s). func LoadSources(opts LoadOptions, source interface{}, others ...interface{}) (_ *File, err error) { sources := make([]dataSource, len(others)+1) diff --git a/vendor/gopkg.in/ini.v1/key.go b/vendor/gopkg.in/ini.v1/key.go index 38860ff4bd..8baafd9ea6 100644 --- a/vendor/gopkg.in/ini.v1/key.go +++ b/vendor/gopkg.in/ini.v1/key.go @@ -54,6 +54,16 @@ func (k *Key) addShadow(val string) error { return errors.New("cannot add shadow to auto-increment or boolean key") } + // Deduplicate shadows based on their values. + if k.value == val { + return nil + } + for i := range k.shadows { + if k.shadows[i].value == val { + return nil + } + } + shadow := newKey(k.s, k.name, val) shadow.isShadow = true k.shadows = append(k.shadows, shadow) @@ -137,10 +147,15 @@ func (k *Key) transformValue(val string) string { noption := vr[2 : len(vr)-2] // Search in the same section. + // If not found or found the key itself, then search again in default section. nk, err := k.s.GetKey(noption) if err != nil || k == nk { - // Search again in default section. nk, _ = k.s.f.Section("").GetKey(noption) + if nk == nil { + // Stop when no results found in the default section, + // and returns the value as-is. + break + } } // Substitute by new value and take off leading '%(' and trailing ')s'. @@ -554,6 +569,12 @@ func (k *Key) Uint64s(delim string) []uint64 { return vals } +// Bools returns list of bool divided by given delimiter. Any invalid input will be treated as zero value. +func (k *Key) Bools(delim string) []bool { + vals, _ := k.parseBools(k.Strings(delim), true, false) + return vals +} + // TimesFormat parses with given format and returns list of time.Time divided by given delimiter. // Any invalid input will be treated as zero value (0001-01-01 00:00:00 +0000 UTC). func (k *Key) TimesFormat(format, delim string) []time.Time { @@ -602,6 +623,13 @@ func (k *Key) ValidUint64s(delim string) []uint64 { return vals } +// ValidBools returns list of bool divided by given delimiter. If some value is not 64-bit unsigned +// integer, then it will not be included to result list. +func (k *Key) ValidBools(delim string) []bool { + vals, _ := k.parseBools(k.Strings(delim), false, false) + return vals +} + // ValidTimesFormat parses with given format and returns list of time.Time divided by given delimiter. func (k *Key) ValidTimesFormat(format, delim string) []time.Time { vals, _ := k.parseTimesFormat(format, k.Strings(delim), false, false) @@ -638,6 +666,11 @@ func (k *Key) StrictUint64s(delim string) ([]uint64, error) { return k.parseUint64s(k.Strings(delim), false, true) } +// StrictBools returns list of bool divided by given delimiter or error on first invalid input. +func (k *Key) StrictBools(delim string) ([]bool, error) { + return k.parseBools(k.Strings(delim), false, true) +} + // StrictTimesFormat parses with given format and returns list of time.Time divided by given delimiter // or error on first invalid input. func (k *Key) StrictTimesFormat(format, delim string) ([]time.Time, error) { @@ -650,87 +683,130 @@ func (k *Key) StrictTimes(delim string) ([]time.Time, error) { return k.StrictTimesFormat(time.RFC3339, delim) } +// parseBools transforms strings to bools. +func (k *Key) parseBools(strs []string, addInvalid, returnOnInvalid bool) ([]bool, error) { + vals := make([]bool, 0, len(strs)) + parser := func(str string) (interface{}, error) { + val, err := parseBool(str) + return val, err + } + rawVals, err := k.doParse(strs, addInvalid, returnOnInvalid, parser) + if err == nil { + for _, val := range rawVals { + vals = append(vals, val.(bool)) + } + } + return vals, err +} + // parseFloat64s transforms strings to float64s. func (k *Key) parseFloat64s(strs []string, addInvalid, returnOnInvalid bool) ([]float64, error) { vals := make([]float64, 0, len(strs)) - for _, str := range strs { + parser := func(str string) (interface{}, error) { val, err := strconv.ParseFloat(str, 64) - if err != nil && returnOnInvalid { - return nil, err - } - if err == nil || addInvalid { - vals = append(vals, val) + return val, err + } + rawVals, err := k.doParse(strs, addInvalid, returnOnInvalid, parser) + if err == nil { + for _, val := range rawVals { + vals = append(vals, val.(float64)) } } - return vals, nil + return vals, err } // parseInts transforms strings to ints. func (k *Key) parseInts(strs []string, addInvalid, returnOnInvalid bool) ([]int, error) { vals := make([]int, 0, len(strs)) - for _, str := range strs { - valInt64, err := strconv.ParseInt(str, 0, 64) - val := int(valInt64) - if err != nil && returnOnInvalid { - return nil, err - } - if err == nil || addInvalid { - vals = append(vals, val) + parser := func(str string) (interface{}, error) { + val, err := strconv.ParseInt(str, 0, 64) + return val, err + } + rawVals, err := k.doParse(strs, addInvalid, returnOnInvalid, parser) + if err == nil { + for _, val := range rawVals { + vals = append(vals, int(val.(int64))) } } - return vals, nil + return vals, err } // parseInt64s transforms strings to int64s. func (k *Key) parseInt64s(strs []string, addInvalid, returnOnInvalid bool) ([]int64, error) { vals := make([]int64, 0, len(strs)) - for _, str := range strs { + parser := func(str string) (interface{}, error) { val, err := strconv.ParseInt(str, 0, 64) - if err != nil && returnOnInvalid { - return nil, err - } - if err == nil || addInvalid { - vals = append(vals, val) + return val, err + } + + rawVals, err := k.doParse(strs, addInvalid, returnOnInvalid, parser) + if err == nil { + for _, val := range rawVals { + vals = append(vals, val.(int64)) } } - return vals, nil + return vals, err } // parseUints transforms strings to uints. func (k *Key) parseUints(strs []string, addInvalid, returnOnInvalid bool) ([]uint, error) { vals := make([]uint, 0, len(strs)) - for _, str := range strs { - val, err := strconv.ParseUint(str, 0, 0) - if err != nil && returnOnInvalid { - return nil, err - } - if err == nil || addInvalid { - vals = append(vals, uint(val)) + parser := func(str string) (interface{}, error) { + val, err := strconv.ParseUint(str, 0, 64) + return val, err + } + + rawVals, err := k.doParse(strs, addInvalid, returnOnInvalid, parser) + if err == nil { + for _, val := range rawVals { + vals = append(vals, uint(val.(uint64))) } } - return vals, nil + return vals, err } // parseUint64s transforms strings to uint64s. func (k *Key) parseUint64s(strs []string, addInvalid, returnOnInvalid bool) ([]uint64, error) { vals := make([]uint64, 0, len(strs)) - for _, str := range strs { + parser := func(str string) (interface{}, error) { val, err := strconv.ParseUint(str, 0, 64) - if err != nil && returnOnInvalid { - return nil, err - } - if err == nil || addInvalid { - vals = append(vals, val) + return val, err + } + rawVals, err := k.doParse(strs, addInvalid, returnOnInvalid, parser) + if err == nil { + for _, val := range rawVals { + vals = append(vals, val.(uint64)) } } - return vals, nil + return vals, err } + +type Parser func(str string) (interface{}, error) + + // parseTimesFormat transforms strings to times in given format. func (k *Key) parseTimesFormat(format string, strs []string, addInvalid, returnOnInvalid bool) ([]time.Time, error) { vals := make([]time.Time, 0, len(strs)) - for _, str := range strs { + parser := func(str string) (interface{}, error) { val, err := time.Parse(format, str) + return val, err + } + rawVals, err := k.doParse(strs, addInvalid, returnOnInvalid, parser) + if err == nil { + for _, val := range rawVals { + vals = append(vals, val.(time.Time)) + } + } + return vals, err +} + + +// doParse transforms strings to different types +func (k *Key) doParse(strs []string, addInvalid, returnOnInvalid bool, parser Parser) ([]interface{}, error) { + vals := make([]interface{}, 0, len(strs)) + for _, str := range strs { + val, err := parser(str) if err != nil && returnOnInvalid { return nil, err } diff --git a/vendor/gopkg.in/ini.v1/parser.go b/vendor/gopkg.in/ini.v1/parser.go index 7c22a25c1a..65147166f9 100644 --- a/vendor/gopkg.in/ini.v1/parser.go +++ b/vendor/gopkg.in/ini.v1/parser.go @@ -25,7 +25,9 @@ import ( "unicode" ) -var pythonMultiline = regexp.MustCompile("^(\\s+)([^\n]+)") +const minReaderBufferSize = 4096 + +var pythonMultiline = regexp.MustCompile(`^([\t\f ]+)(.*)`) type parserOptions struct { IgnoreContinuation bool @@ -35,6 +37,8 @@ type parserOptions struct { UnescapeValueDoubleQuotes bool UnescapeValueCommentSymbols bool PreserveSurroundedQuote bool + DebugFunc DebugFunc + ReaderBufferSize int } type parser struct { @@ -46,9 +50,20 @@ type parser struct { comment *bytes.Buffer } +func (p *parser) debug(format string, args ...interface{}) { + if p.options.DebugFunc != nil { + p.options.DebugFunc(fmt.Sprintf(format, args...)) + } +} + func newParser(r io.Reader, opts parserOptions) *parser { + size := opts.ReaderBufferSize + if size < minReaderBufferSize { + size = minReaderBufferSize + } + return &parser{ - buf: bufio.NewReader(r), + buf: bufio.NewReaderSize(r, size), options: opts, count: 1, comment: &bytes.Buffer{}, @@ -69,7 +84,10 @@ func (p *parser) BOM() error { case mask[0] == 254 && mask[1] == 255: fallthrough case mask[0] == 255 && mask[1] == 254: - p.buf.Read(mask) + _, err = p.buf.Read(mask) + if err != nil { + return err + } case mask[0] == 239 && mask[1] == 187: mask, err := p.buf.Peek(3) if err != nil && err != io.EOF { @@ -78,7 +96,10 @@ func (p *parser) BOM() error { return nil } if mask[2] == 191 { - p.buf.Read(mask) + _, err = p.buf.Read(mask) + if err != nil { + return err + } } } return nil @@ -120,7 +141,7 @@ func readKeyName(delimiters string, in []byte) (string, int, error) { } // Get out key name - endIdx := -1 + var endIdx int if len(keyQuote) > 0 { startIdx := len(keyQuote) // FIXME: fail case -> """"""name"""=value @@ -166,7 +187,7 @@ func (p *parser) readMultilines(line, val, valQuote string) (string, error) { } val += next if p.isEOF { - return "", fmt.Errorf("missing closing key quote from '%s' to '%s'", line, next) + return "", fmt.Errorf("missing closing key quote from %q to %q", line, next) } } return val, nil @@ -285,33 +306,55 @@ func (p *parser) readPythonMultilines(line string, bufferSize int) (string, erro parserBufferPeekResult, _ := p.buf.Peek(bufferSize) peekBuffer := bytes.NewBuffer(parserBufferPeekResult) + indentSize := 0 for { peekData, peekErr := peekBuffer.ReadBytes('\n') if peekErr != nil { if peekErr == io.EOF { + p.debug("readPythonMultilines: io.EOF, peekData: %q, line: %q", string(peekData), line) return line, nil } + + p.debug("readPythonMultilines: failed to peek with error: %v", peekErr) return "", peekErr } + p.debug("readPythonMultilines: parsing %q", string(peekData)) + peekMatches := pythonMultiline.FindStringSubmatch(string(peekData)) + p.debug("readPythonMultilines: matched %d parts", len(peekMatches)) + for n, v := range peekMatches { + p.debug(" %d: %q", n, v) + } + + // Return if not a Python multiline value. if len(peekMatches) != 3 { + p.debug("readPythonMultilines: end of value, got: %q", line) return line, nil } - // NOTE: Return if not a python-ini multi-line value. - currentIdentSize := len(peekMatches[1]) - if currentIdentSize <= 0 { + // Determine indent size and line prefix. + currentIndentSize := len(peekMatches[1]) + if indentSize < 1 { + indentSize = currentIndentSize + p.debug("readPythonMultilines: indent size is %d", indentSize) + } + + // Make sure each line is indented at least as far as first line. + if currentIndentSize < indentSize { + p.debug("readPythonMultilines: end of value, current indent: %d, expected indent: %d, line: %q", currentIndentSize, indentSize, line) return line, nil } - // NOTE: Just advance the parser reader (buffer) in-sync with the peek buffer. - _, err := p.readUntil('\n') + // Advance the parser reader (buffer) in-sync with the peek buffer. + _, err := p.buf.Discard(len(peekData)) if err != nil { + p.debug("readPythonMultilines: failed to skip to the end, returning error") return "", err } - line += fmt.Sprintf("\n%s", peekMatches[2]) + // Handle indented empty line. + line += "\n" + peekMatches[1][indentSize:] + peekMatches[2] } } @@ -325,6 +368,8 @@ func (f *File) parse(reader io.Reader) (err error) { UnescapeValueDoubleQuotes: f.options.UnescapeValueDoubleQuotes, UnescapeValueCommentSymbols: f.options.UnescapeValueCommentSymbols, PreserveSurroundedQuote: f.options.PreserveSurroundedQuote, + DebugFunc: f.options.DebugFunc, + ReaderBufferSize: f.options.ReaderBufferSize, }) if err = p.BOM(); err != nil { return fmt.Errorf("BOM: %v", err) @@ -332,7 +377,7 @@ func (f *File) parse(reader io.Reader) (err error) { // Ignore error because default section name is never empty string. name := DefaultSection - if f.options.Insensitive { + if f.options.Insensitive || f.options.InsensitiveSections { name = strings.ToLower(DefaultSection) } section, _ := f.NewSection(name) @@ -348,8 +393,8 @@ func (f *File) parse(reader io.Reader) (err error) { // the size of the parser buffer is found. // TODO(unknwon): When Golang 1.10 is the lowest version supported, replace with `parserBufferSize := p.buf.Size()`. parserBufferSize := 0 - // NOTE: Peek 1kb at a time. - currentPeekSize := 1024 + // NOTE: Peek 4kb at a time. + currentPeekSize := minReaderBufferSize if f.options.AllowPythonMultilineValues { for { @@ -374,7 +419,10 @@ func (f *File) parse(reader io.Reader) (err error) { if f.options.AllowNestedValues && isLastValueEmpty && len(line) > 0 { if line[0] == ' ' || line[0] == '\t' { - lastRegularKey.addNestedValue(string(bytes.TrimSpace(line))) + err = lastRegularKey.addNestedValue(string(bytes.TrimSpace(line))) + if err != nil { + return err + } continue } } @@ -414,14 +462,14 @@ func (f *File) parse(reader io.Reader) (err error) { section.Comment = strings.TrimSpace(p.comment.String()) - // Reset aotu-counter and comments + // Reset auto-counter and comments p.comment.Reset() p.count = 1 inUnparseableSection = false for i := range f.options.UnparseableSections { if f.options.UnparseableSections[i] == name || - (f.options.Insensitive && strings.ToLower(f.options.UnparseableSections[i]) == strings.ToLower(name)) { + ((f.options.Insensitive || f.options.InsensitiveSections) && strings.EqualFold(f.options.UnparseableSections[i], name)) { inUnparseableSection = true continue } diff --git a/vendor/gopkg.in/ini.v1/section.go b/vendor/gopkg.in/ini.v1/section.go index 0bd3e13015..afaa97c97e 100644 --- a/vendor/gopkg.in/ini.v1/section.go +++ b/vendor/gopkg.in/ini.v1/section.go @@ -66,7 +66,7 @@ func (s *Section) SetBody(body string) { func (s *Section) NewKey(name, val string) (*Key, error) { if len(name) == 0 { return nil, errors.New("error creating new key: empty key name") - } else if s.f.options.Insensitive { + } else if s.f.options.Insensitive || s.f.options.InsensitiveKeys { name = strings.ToLower(name) } @@ -109,7 +109,7 @@ func (s *Section) GetKey(name string) (*Key, error) { if s.f.BlockMode { s.f.lock.RLock() } - if s.f.options.Insensitive { + if s.f.options.Insensitive || s.f.options.InsensitiveKeys { name = strings.ToLower(name) } key := s.keys[name] @@ -121,7 +121,7 @@ func (s *Section) GetKey(name string) (*Key, error) { // Check if it is a child-section. sname := s.name for { - if i := strings.LastIndex(sname, "."); i > -1 { + if i := strings.LastIndex(sname, s.f.options.ChildSectionDelimiter); i > -1 { sname = sname[:i] sec, err := s.f.GetSection(sname) if err != nil { @@ -131,7 +131,7 @@ func (s *Section) GetKey(name string) (*Key, error) { } break } - return nil, fmt.Errorf("error when getting key of section '%s': key '%s' not exists", s.name, name) + return nil, fmt.Errorf("error when getting key of section %q: key %q not exists", s.name, name) } return key, nil } @@ -188,7 +188,7 @@ func (s *Section) ParentKeys() []*Key { var parentKeys []*Key sname := s.name for { - if i := strings.LastIndex(sname, "."); i > -1 { + if i := strings.LastIndex(sname, s.f.options.ChildSectionDelimiter); i > -1 { sname = sname[:i] sec, err := s.f.GetSection(sname) if err != nil { @@ -245,11 +245,11 @@ func (s *Section) DeleteKey(name string) { // For example, "[parent.child1]" and "[parent.child12]" are child sections // of section "[parent]". func (s *Section) ChildSections() []*Section { - prefix := s.name + "." + prefix := s.name + s.f.options.ChildSectionDelimiter children := make([]*Section, 0, 3) for _, name := range s.f.sectionList { if strings.HasPrefix(name, prefix) { - children = append(children, s.f.sections[name]) + children = append(children, s.f.sections[name]...) } } return children diff --git a/vendor/gopkg.in/ini.v1/struct.go b/vendor/gopkg.in/ini.v1/struct.go index 4cdcb6b41b..a486b2fe0f 100644 --- a/vendor/gopkg.in/ini.v1/struct.go +++ b/vendor/gopkg.in/ini.v1/struct.go @@ -29,8 +29,8 @@ type NameMapper func(string) string // Built-in name getters. var ( - // AllCapsUnderscore converts to format ALL_CAPS_UNDERSCORE. - AllCapsUnderscore NameMapper = func(raw string) string { + // SnackCase converts to format SNACK_CASE. + SnackCase NameMapper = func(raw string) string { newstr := make([]rune, 0, len(raw)) for i, chr := range raw { if isUpper := 'A' <= chr && chr <= 'Z'; isUpper { @@ -50,7 +50,7 @@ var ( if i > 0 { newstr = append(newstr, '_') } - chr -= ('A' - 'a') + chr -= 'A' - 'a' } newstr = append(newstr, chr) } @@ -108,6 +108,8 @@ func setSliceWithProperType(key *Key, field reflect.Value, delim string, allowSh vals, err = key.parseUint64s(strs, true, false) case reflect.Float64: vals, err = key.parseFloat64s(strs, true, false) + case reflect.Bool: + vals, err = key.parseBools(strs, true, false) case reflectTime: vals, err = key.parseTimesFormat(time.RFC3339, strs, true, false) default: @@ -132,6 +134,8 @@ func setSliceWithProperType(key *Key, field reflect.Value, delim string, allowSh slice.Index(i).Set(reflect.ValueOf(vals.([]uint64)[i])) case reflect.Float64: slice.Index(i).Set(reflect.ValueOf(vals.([]float64)[i])) + case reflect.Bool: + slice.Index(i).Set(reflect.ValueOf(vals.([]bool)[i])) case reflectTime: slice.Index(i).Set(reflect.ValueOf(vals.([]time.Time)[i])) } @@ -151,23 +155,45 @@ func wrapStrictError(err error, isStrict bool) error { // but it does not return error for failing parsing, // because we want to use default value that is already assigned to struct. func setWithProperType(t reflect.Type, key *Key, field reflect.Value, delim string, allowShadow, isStrict bool) error { - switch t.Kind() { + vt := t + isPtr := t.Kind() == reflect.Ptr + if isPtr { + vt = t.Elem() + } + switch vt.Kind() { case reflect.String: - if len(key.String()) == 0 { - return nil + stringVal := key.String() + if isPtr { + field.Set(reflect.ValueOf(&stringVal)) + } else if len(stringVal) > 0 { + field.SetString(key.String()) } - field.SetString(key.String()) case reflect.Bool: boolVal, err := key.Bool() if err != nil { return wrapStrictError(err, isStrict) } - field.SetBool(boolVal) + if isPtr { + field.Set(reflect.ValueOf(&boolVal)) + } else { + field.SetBool(boolVal) + } case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - durationVal, err := key.Duration() - // Skip zero value - if err == nil && int64(durationVal) > 0 { - field.Set(reflect.ValueOf(durationVal)) + // ParseDuration will not return err for `0`, so check the type name + if vt.Name() == "Duration" { + durationVal, err := key.Duration() + if err != nil { + if intVal, err := key.Int64(); err == nil { + field.SetInt(intVal) + return nil + } + return wrapStrictError(err, isStrict) + } + if isPtr { + field.Set(reflect.ValueOf(&durationVal)) + } else if int64(durationVal) > 0 { + field.Set(reflect.ValueOf(durationVal)) + } return nil } @@ -175,13 +201,23 @@ func setWithProperType(t reflect.Type, key *Key, field reflect.Value, delim stri if err != nil { return wrapStrictError(err, isStrict) } - field.SetInt(intVal) + if isPtr { + pv := reflect.New(t.Elem()) + pv.Elem().SetInt(intVal) + field.Set(pv) + } else { + field.SetInt(intVal) + } // byte is an alias for uint8, so supporting uint8 breaks support for byte case reflect.Uint, reflect.Uint16, reflect.Uint32, reflect.Uint64: durationVal, err := key.Duration() // Skip zero value if err == nil && uint64(durationVal) > 0 { - field.Set(reflect.ValueOf(durationVal)) + if isPtr { + field.Set(reflect.ValueOf(&durationVal)) + } else { + field.Set(reflect.ValueOf(durationVal)) + } return nil } @@ -189,41 +225,59 @@ func setWithProperType(t reflect.Type, key *Key, field reflect.Value, delim stri if err != nil { return wrapStrictError(err, isStrict) } - field.SetUint(uintVal) + if isPtr { + pv := reflect.New(t.Elem()) + pv.Elem().SetUint(uintVal) + field.Set(pv) + } else { + field.SetUint(uintVal) + } case reflect.Float32, reflect.Float64: floatVal, err := key.Float64() if err != nil { return wrapStrictError(err, isStrict) } - field.SetFloat(floatVal) + if isPtr { + pv := reflect.New(t.Elem()) + pv.Elem().SetFloat(floatVal) + field.Set(pv) + } else { + field.SetFloat(floatVal) + } case reflectTime: timeVal, err := key.Time() if err != nil { return wrapStrictError(err, isStrict) } - field.Set(reflect.ValueOf(timeVal)) + if isPtr { + field.Set(reflect.ValueOf(&timeVal)) + } else { + field.Set(reflect.ValueOf(timeVal)) + } case reflect.Slice: return setSliceWithProperType(key, field, delim, allowShadow, isStrict) default: - return fmt.Errorf("unsupported type '%s'", t) + return fmt.Errorf("unsupported type %q", t) } return nil } -func parseTagOptions(tag string) (rawName string, omitEmpty bool, allowShadow bool) { - opts := strings.SplitN(tag, ",", 3) +func parseTagOptions(tag string) (rawName string, omitEmpty bool, allowShadow bool, allowNonUnique bool, extends bool) { + opts := strings.SplitN(tag, ",", 5) rawName = opts[0] - if len(opts) > 1 { - omitEmpty = opts[1] == "omitempty" + for _, opt := range opts[1:] { + omitEmpty = omitEmpty || (opt == "omitempty") + allowShadow = allowShadow || (opt == "allowshadow") + allowNonUnique = allowNonUnique || (opt == "nonunique") + extends = extends || (opt == "extends") } - if len(opts) > 2 { - allowShadow = opts[2] == "allowshadow" - } - return rawName, omitEmpty, allowShadow + return rawName, omitEmpty, allowShadow, allowNonUnique, extends } -func (s *Section) mapTo(val reflect.Value, isStrict bool) error { +// mapToField maps the given value to the matching field of the given section. +// The sectionIndex is the index (if non unique sections are enabled) to which the value should be added. +func (s *Section) mapToField(val reflect.Value, isStrict bool, sectionIndex int, sectionName string) error { if val.Kind() == reflect.Ptr { val = val.Elem() } @@ -238,7 +292,7 @@ func (s *Section) mapTo(val reflect.Value, isStrict bool) error { continue } - rawName, _, allowShadow := parseTagOptions(tag) + rawName, _, allowShadow, allowNonUnique, extends := parseTagOptions(tag) fieldName := s.parseFieldName(tpField.Name, rawName) if len(fieldName) == 0 || !field.CanSet() { continue @@ -246,63 +300,116 @@ func (s *Section) mapTo(val reflect.Value, isStrict bool) error { isStruct := tpField.Type.Kind() == reflect.Struct isStructPtr := tpField.Type.Kind() == reflect.Ptr && tpField.Type.Elem().Kind() == reflect.Struct - isAnonymous := tpField.Type.Kind() == reflect.Ptr && tpField.Anonymous - if isAnonymous { + isAnonymousPtr := tpField.Type.Kind() == reflect.Ptr && tpField.Anonymous + if isAnonymousPtr { field.Set(reflect.New(tpField.Type.Elem())) } - if isAnonymous || isStruct || isStructPtr { - if sec, err := s.f.GetSection(fieldName); err == nil { - // Only set the field to non-nil struct value if we have - // a section for it. Otherwise, we end up with a non-nil - // struct ptr even though there is no data. + if extends && (isAnonymousPtr || (isStruct && tpField.Anonymous)) { + if isStructPtr && field.IsNil() { + field.Set(reflect.New(tpField.Type.Elem())) + } + fieldSection := s + if rawName != "" { + sectionName = s.name + s.f.options.ChildSectionDelimiter + rawName + if secs, err := s.f.SectionsByName(sectionName); err == nil && sectionIndex < len(secs) { + fieldSection = secs[sectionIndex] + } + } + if err := fieldSection.mapToField(field, isStrict, sectionIndex, sectionName); err != nil { + return fmt.Errorf("map to field %q: %v", fieldName, err) + } + } else if isAnonymousPtr || isStruct || isStructPtr { + if secs, err := s.f.SectionsByName(fieldName); err == nil { + if len(secs) <= sectionIndex { + return fmt.Errorf("there are not enough sections (%d <= %d) for the field %q", len(secs), sectionIndex, fieldName) + } + // Only set the field to non-nil struct value if we have a section for it. + // Otherwise, we end up with a non-nil struct ptr even though there is no data. if isStructPtr && field.IsNil() { field.Set(reflect.New(tpField.Type.Elem())) } - if err = sec.mapTo(field, isStrict); err != nil { - return fmt.Errorf("error mapping field(%s): %v", fieldName, err) + if err = secs[sectionIndex].mapToField(field, isStrict, sectionIndex, fieldName); err != nil { + return fmt.Errorf("map to field %q: %v", fieldName, err) } continue } } + // Map non-unique sections + if allowNonUnique && tpField.Type.Kind() == reflect.Slice { + newField, err := s.mapToSlice(fieldName, field, isStrict) + if err != nil { + return fmt.Errorf("map to slice %q: %v", fieldName, err) + } + + field.Set(newField) + continue + } + if key, err := s.GetKey(fieldName); err == nil { delim := parseDelim(tpField.Tag.Get("delim")) if err = setWithProperType(tpField.Type, key, field, delim, allowShadow, isStrict); err != nil { - return fmt.Errorf("error mapping field(%s): %v", fieldName, err) + return fmt.Errorf("set field %q: %v", fieldName, err) } } } return nil } -// MapTo maps section to given struct. -func (s *Section) MapTo(v interface{}) error { +// mapToSlice maps all sections with the same name and returns the new value. +// The type of the Value must be a slice. +func (s *Section) mapToSlice(secName string, val reflect.Value, isStrict bool) (reflect.Value, error) { + secs, err := s.f.SectionsByName(secName) + if err != nil { + return reflect.Value{}, err + } + + typ := val.Type().Elem() + for i, sec := range secs { + elem := reflect.New(typ) + if err = sec.mapToField(elem, isStrict, i, sec.name); err != nil { + return reflect.Value{}, fmt.Errorf("map to field from section %q: %v", secName, err) + } + + val = reflect.Append(val, elem.Elem()) + } + return val, nil +} + +// mapTo maps a section to object v. +func (s *Section) mapTo(v interface{}, isStrict bool) error { typ := reflect.TypeOf(v) val := reflect.ValueOf(v) if typ.Kind() == reflect.Ptr { typ = typ.Elem() val = val.Elem() } else { - return errors.New("cannot map to non-pointer struct") + return errors.New("not a pointer to a struct") } - return s.mapTo(val, false) + if typ.Kind() == reflect.Slice { + newField, err := s.mapToSlice(s.name, val, isStrict) + if err != nil { + return err + } + + val.Set(newField) + return nil + } + + return s.mapToField(val, isStrict, 0, s.name) +} + +// MapTo maps section to given struct. +func (s *Section) MapTo(v interface{}) error { + return s.mapTo(v, false) } // StrictMapTo maps section to given struct in strict mode, // which returns all possible error including value parsing error. func (s *Section) StrictMapTo(v interface{}) error { - typ := reflect.TypeOf(v) - val := reflect.ValueOf(v) - if typ.Kind() == reflect.Ptr { - typ = typ.Elem() - val = val.Elem() - } else { - return errors.New("cannot map to non-pointer struct") - } - - return s.mapTo(val, true) + return s.mapTo(v, true) } // MapTo maps file to given struct. @@ -369,6 +476,8 @@ func reflectSliceWithProperType(key *Key, field reflect.Value, delim string, all val = fmt.Sprint(slice.Index(i).Uint()) case reflect.Float64: val = fmt.Sprint(slice.Index(i).Float()) + case reflect.Bool: + val = fmt.Sprint(slice.Index(i).Bool()) case reflectTime: val = slice.Index(i).Interface().(time.Time).Format(time.RFC3339) default: @@ -378,10 +487,10 @@ func reflectSliceWithProperType(key *Key, field reflect.Value, delim string, all if i == 0 { keyWithShadows = newKey(key.s, key.name, val) } else { - keyWithShadows.AddShadow(val) + _ = keyWithShadows.AddShadow(val) } } - key = keyWithShadows + *key = *keyWithShadows return nil } @@ -396,6 +505,8 @@ func reflectSliceWithProperType(key *Key, field reflect.Value, delim string, all buf.WriteString(fmt.Sprint(slice.Index(i).Uint())) case reflect.Float64: buf.WriteString(fmt.Sprint(slice.Index(i).Float())) + case reflect.Bool: + buf.WriteString(fmt.Sprint(slice.Index(i).Bool())) case reflectTime: buf.WriteString(slice.Index(i).Interface().(time.Time).Format(time.RFC3339)) default: @@ -424,8 +535,12 @@ func reflectWithProperType(t reflect.Type, key *Key, field reflect.Value, delim key.SetValue(fmt.Sprint(field.Interface().(time.Time).Format(time.RFC3339))) case reflect.Slice: return reflectSliceWithProperType(key, field, delim, allowShadow) + case reflect.Ptr: + if !field.IsNil() { + return reflectWithProperType(t.Elem(), key, field.Elem(), delim, allowShadow) + } default: - return fmt.Errorf("unsupported type '%s'", t) + return fmt.Errorf("unsupported type %q", t) } return nil } @@ -453,6 +568,11 @@ func isEmptyValue(v reflect.Value) bool { return false } +// StructReflector is the interface implemented by struct types that can extract themselves into INI objects. +type StructReflector interface { + ReflectINIStruct(*File) error +} + func (s *Section) reflectFrom(val reflect.Value) error { if val.Kind() == reflect.Ptr { val = val.Elem() @@ -460,6 +580,10 @@ func (s *Section) reflectFrom(val reflect.Value) error { typ := val.Type() for i := 0; i < typ.NumField(); i++ { + if !val.Field(i).CanInterface() { + continue + } + field := val.Field(i) tpField := typ.Field(i) @@ -468,17 +592,28 @@ func (s *Section) reflectFrom(val reflect.Value) error { continue } - rawName, omitEmpty, allowShadow := parseTagOptions(tag) + rawName, omitEmpty, allowShadow, allowNonUnique, extends := parseTagOptions(tag) if omitEmpty && isEmptyValue(field) { continue } + if r, ok := field.Interface().(StructReflector); ok { + return r.ReflectINIStruct(s.f) + } + fieldName := s.parseFieldName(tpField.Name, rawName) if len(fieldName) == 0 || !field.CanSet() { continue } - if (tpField.Type.Kind() == reflect.Ptr && tpField.Anonymous) || + if extends && tpField.Anonymous && (tpField.Type.Kind() == reflect.Ptr || tpField.Type.Kind() == reflect.Struct) { + if err := s.reflectFrom(field); err != nil { + return fmt.Errorf("reflect from field %q: %v", fieldName, err) + } + continue + } + + if (tpField.Type.Kind() == reflect.Ptr && tpField.Type.Elem().Kind() == reflect.Struct) || (tpField.Type.Kind() == reflect.Struct && tpField.Type.Name() != "Time") { // Note: The only error here is section doesn't exist. sec, err := s.f.GetSection(fieldName) @@ -493,12 +628,41 @@ func (s *Section) reflectFrom(val reflect.Value) error { } if err = sec.reflectFrom(field); err != nil { - return fmt.Errorf("error reflecting field (%s): %v", fieldName, err) + return fmt.Errorf("reflect from field %q: %v", fieldName, err) } continue } - // Note: Same reason as secion. + if allowNonUnique && tpField.Type.Kind() == reflect.Slice { + slice := field.Slice(0, field.Len()) + if field.Len() == 0 { + return nil + } + sliceOf := field.Type().Elem().Kind() + + for i := 0; i < field.Len(); i++ { + if sliceOf != reflect.Struct && sliceOf != reflect.Ptr { + return fmt.Errorf("field %q is not a slice of pointer or struct", fieldName) + } + + sec, err := s.f.NewSection(fieldName) + if err != nil { + return err + } + + // Add comment from comment tag + if len(sec.Comment) == 0 { + sec.Comment = tpField.Tag.Get("comment") + } + + if err := sec.reflectFrom(slice.Index(i)); err != nil { + return fmt.Errorf("reflect from field %q: %v", fieldName, err) + } + } + continue + } + + // Note: Same reason as section. key, err := s.GetKey(fieldName) if err != nil { key, _ = s.NewKey(fieldName, "") @@ -509,23 +673,58 @@ func (s *Section) reflectFrom(val reflect.Value) error { key.Comment = tpField.Tag.Get("comment") } - if err = reflectWithProperType(tpField.Type, key, field, parseDelim(tpField.Tag.Get("delim")), allowShadow); err != nil { - return fmt.Errorf("error reflecting field (%s): %v", fieldName, err) + delim := parseDelim(tpField.Tag.Get("delim")) + if err = reflectWithProperType(tpField.Type, key, field, delim, allowShadow); err != nil { + return fmt.Errorf("reflect field %q: %v", fieldName, err) } } return nil } -// ReflectFrom reflects secion from given struct. +// ReflectFrom reflects section from given struct. It overwrites existing ones. func (s *Section) ReflectFrom(v interface{}) error { typ := reflect.TypeOf(v) val := reflect.ValueOf(v) + + if s.name != DefaultSection && s.f.options.AllowNonUniqueSections && + (typ.Kind() == reflect.Slice || typ.Kind() == reflect.Ptr) { + // Clear sections to make sure none exists before adding the new ones + s.f.DeleteSection(s.name) + + if typ.Kind() == reflect.Ptr { + sec, err := s.f.NewSection(s.name) + if err != nil { + return err + } + return sec.reflectFrom(val.Elem()) + } + + slice := val.Slice(0, val.Len()) + sliceOf := val.Type().Elem().Kind() + if sliceOf != reflect.Ptr { + return fmt.Errorf("not a slice of pointers") + } + + for i := 0; i < slice.Len(); i++ { + sec, err := s.f.NewSection(s.name) + if err != nil { + return err + } + + err = sec.reflectFrom(slice.Index(i)) + if err != nil { + return fmt.Errorf("reflect from %dth field: %v", i, err) + } + } + + return nil + } + if typ.Kind() == reflect.Ptr { - typ = typ.Elem() val = val.Elem() } else { - return errors.New("cannot reflect from non-pointer struct") + return errors.New("not a pointer to a struct") } return s.reflectFrom(val) diff --git a/vendor/modules.txt b/vendor/modules.txt index 979a56cfa8..3b5c33709c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -22,6 +22,8 @@ github.com/360EntSecGroup-Skylar/excelize ## explicit github.com/Azure/azure-sdk-for-go/storage github.com/Azure/azure-sdk-for-go/version +# github.com/Azure/go-autorest v14.2.0+incompatible +## explicit # github.com/Azure/go-autorest/autorest v0.9.6 ## explicit; go 1.12 github.com/Azure/go-autorest/autorest @@ -38,8 +40,6 @@ github.com/Azure/go-autorest/autorest/azure/cli # github.com/Azure/go-autorest/autorest/date v0.2.0 ## explicit; go 1.12 github.com/Azure/go-autorest/autorest/date -# github.com/Azure/go-autorest/autorest/to v0.4.0 -## explicit; go 1.12 # github.com/Azure/go-autorest/logger v0.1.0 ## explicit; go 1.12 github.com/Azure/go-autorest/logger @@ -240,8 +240,6 @@ github.com/aws/aws-sdk-go/service/sso/ssoiface github.com/aws/aws-sdk-go/service/sts github.com/aws/aws-sdk-go/service/sts/stsiface github.com/aws/aws-sdk-go/service/wafv2 -# github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f -## explicit # github.com/basgys/goxml2json v1.1.1-0.20181031222924-996d9fc8d313 ## explicit github.com/basgys/goxml2json @@ -360,8 +358,6 @@ github.com/dgrijalva/jwt-go # github.com/dimchansky/utfbom v1.1.0 ## explicit github.com/dimchansky/utfbom -# github.com/dnaeon/go-vcr v1.1.0 -## explicit; go 1.15 # github.com/dnstap/golang-dnstap v0.0.0-20170829151710-2cf77a2b5e11 ## explicit github.com/dnstap/golang-dnstap @@ -725,8 +721,8 @@ github.com/mohae/deepcopy # github.com/mozillazg/go-httpheader v0.2.1 ## explicit github.com/mozillazg/go-httpheader -# github.com/mozillazg/go-pinyin v0.15.0 -## explicit +# github.com/mozillazg/go-pinyin v0.19.0 +## explicit; go 1.11 github.com/mozillazg/go-pinyin # github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae ## explicit @@ -843,13 +839,14 @@ github.com/sirupsen/logrus github.com/skip2/go-qrcode github.com/skip2/go-qrcode/bitset github.com/skip2/go-qrcode/reedsolomon -# github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d -## explicit +# github.com/smartystreets/assertions v1.2.0 +## explicit; go 1.13 github.com/smartystreets/assertions +github.com/smartystreets/assertions/internal/go-diff/diffmatchpatch github.com/smartystreets/assertions/internal/go-render/render github.com/smartystreets/assertions/internal/oglematchers -# github.com/smartystreets/goconvey v1.6.4 -## explicit +# github.com/smartystreets/goconvey v1.7.2 +## explicit; go 1.16 github.com/smartystreets/goconvey/convey github.com/smartystreets/goconvey/convey/gotest github.com/smartystreets/goconvey/convey/reporting @@ -897,11 +894,11 @@ github.com/tklauser/go-sysconf # github.com/tklauser/numcpus v0.4.0 ## explicit; go 1.11 github.com/tklauser/numcpus -# github.com/tredoe/osutil v1.0.6 +# github.com/tredoe/osutil/v2 v2.0.0-rc.16 ## explicit; go 1.16 -github.com/tredoe/osutil/user/crypt -github.com/tredoe/osutil/user/crypt/common -github.com/tredoe/osutil/user/crypt/sha512_crypt +github.com/tredoe/osutil/v2/userutil/crypt +github.com/tredoe/osutil/v2/userutil/crypt/common +github.com/tredoe/osutil/v2/userutil/crypt/sha512_crypt # github.com/ugorji/go/codec v1.1.7 ## explicit github.com/ugorji/go/codec @@ -997,7 +994,7 @@ go.uber.org/zap/internal/color go.uber.org/zap/internal/exit go.uber.org/zap/zapcore go.uber.org/zap/zapgrpc -# golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 +# golang.org/x/crypto v0.1.0 ## explicit; go 1.17 golang.org/x/crypto/argon2 golang.org/x/crypto/bcrypt @@ -1007,8 +1004,8 @@ golang.org/x/crypto/chacha20 golang.org/x/crypto/curve25519 golang.org/x/crypto/curve25519/internal/field golang.org/x/crypto/ed25519 +golang.org/x/crypto/internal/alias golang.org/x/crypto/internal/poly1305 -golang.org/x/crypto/internal/subtle golang.org/x/crypto/pbkdf2 golang.org/x/crypto/pkcs12 golang.org/x/crypto/pkcs12/internal/rc2 @@ -1021,11 +1018,12 @@ golang.org/x/crypto/ssh/terminal ## explicit; go 1.11 golang.org/x/lint golang.org/x/lint/golint -# golang.org/x/mod v0.4.2 -## explicit; go 1.12 +# golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 +## explicit; go 1.17 +golang.org/x/mod/internal/lazyregexp golang.org/x/mod/module golang.org/x/mod/semver -# golang.org/x/net v0.0.0-20220418201149-a630d4f3e7a2 +# golang.org/x/net v0.1.0 ## explicit; go 1.17 golang.org/x/net/bpf golang.org/x/net/context @@ -1058,10 +1056,10 @@ golang.org/x/oauth2/google/internal/externalaccount golang.org/x/oauth2/internal golang.org/x/oauth2/jws golang.org/x/oauth2/jwt -# golang.org/x/sync v0.0.0-20210220032951-036812b2e83c +# golang.org/x/sync v0.1.0 ## explicit golang.org/x/sync/errgroup -# golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 +# golang.org/x/sys v0.1.0 ## explicit; go 1.17 golang.org/x/sys/cpu golang.org/x/sys/execabs @@ -1069,10 +1067,10 @@ golang.org/x/sys/internal/unsafeheader golang.org/x/sys/plan9 golang.org/x/sys/unix golang.org/x/sys/windows -# golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 +# golang.org/x/term v0.1.0 ## explicit; go 1.17 golang.org/x/term -# golang.org/x/text v0.3.7 +# golang.org/x/text v0.4.0 ## explicit; go 1.17 golang.org/x/text/encoding golang.org/x/text/encoding/charmap @@ -1105,12 +1103,13 @@ golang.org/x/text/unicode/norm # golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba ## explicit golang.org/x/time/rate -# golang.org/x/tools v0.1.2 -## explicit; go 1.17 +# golang.org/x/tools v0.1.12 +## explicit; go 1.18 golang.org/x/tools/cmd/goimports golang.org/x/tools/go/ast/astutil golang.org/x/tools/go/gcexportdata golang.org/x/tools/go/internal/gcimporter +golang.org/x/tools/go/internal/pkgbits golang.org/x/tools/internal/event golang.org/x/tools/internal/event/core golang.org/x/tools/internal/event/keys @@ -1119,12 +1118,13 @@ golang.org/x/tools/internal/fastwalk golang.org/x/tools/internal/gocommand golang.org/x/tools/internal/gopathwalk golang.org/x/tools/internal/imports +golang.org/x/tools/internal/typeparams # golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 ## explicit; go 1.11 golang.org/x/xerrors golang.org/x/xerrors/internal -# golang.zx2c4.com/wireguard/wgctrl v0.0.0-20191008142428-8d021180e987 -## explicit; go 1.13 +# golang.zx2c4.com/wireguard/wgctrl v0.0.0-20221104135756-97bc4ad4a1cb +## explicit; go 1.19 golang.zx2c4.com/wireguard/wgctrl/wgtypes # google.golang.org/api v0.30.0 ## explicit; go 1.11 @@ -1258,7 +1258,7 @@ gopkg.in/fatih/set.v0 # gopkg.in/inf.v0 v0.9.1 ## explicit gopkg.in/inf.v0 -# gopkg.in/ini.v1 v1.44.0 +# gopkg.in/ini.v1 v1.62.0 ## explicit gopkg.in/ini.v1 # gopkg.in/ldap.v3 v3.0.3 @@ -1439,7 +1439,7 @@ sigs.k8s.io/structured-merge-diff/v4/value # sigs.k8s.io/yaml v1.2.0 ## explicit; go 1.12 sigs.k8s.io/yaml -# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221221074003-215a6ca48a2a +# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20221226041034-c7119501d505 ## explicit; go 1.18 yunion.io/x/cloudmux/pkg/apis yunion.io/x/cloudmux/pkg/apis/billing @@ -1459,8 +1459,6 @@ yunion.io/x/cloudmux/pkg/multicloud/azure/progress yunion.io/x/cloudmux/pkg/multicloud/azure/provider yunion.io/x/cloudmux/pkg/multicloud/bingocloud yunion.io/x/cloudmux/pkg/multicloud/bingocloud/provider -yunion.io/x/cloudmux/pkg/multicloud/cloudpods -yunion.io/x/cloudmux/pkg/multicloud/cloudpods/provider yunion.io/x/cloudmux/pkg/multicloud/ctyun yunion.io/x/cloudmux/pkg/multicloud/ctyun/provider yunion.io/x/cloudmux/pkg/multicloud/ecloud @@ -1536,36 +1534,54 @@ yunion.io/x/log/hooks yunion.io/x/ovsdb/cli_util yunion.io/x/ovsdb/schema/ovn_nb yunion.io/x/ovsdb/types -# yunion.io/x/pkg v1.0.1-0.20221031045951-0b770b490c45 +# yunion.io/x/pkg v1.0.1-0.20221226030310-a8727011fc76 ## explicit; go 1.18 +yunion.io/x/pkg/appctx yunion.io/x/pkg/errors yunion.io/x/pkg/gotypes +yunion.io/x/pkg/object yunion.io/x/pkg/prettytable yunion.io/x/pkg/sortedmap yunion.io/x/pkg/trace yunion.io/x/pkg/tristate +yunion.io/x/pkg/util/billing yunion.io/x/pkg/util/cache yunion.io/x/pkg/util/clock +yunion.io/x/pkg/util/cloudinit yunion.io/x/pkg/util/compare yunion.io/x/pkg/util/delayedwork +yunion.io/x/pkg/util/encode yunion.io/x/pkg/util/errors yunion.io/x/pkg/util/fileutils yunion.io/x/pkg/util/filterclause yunion.io/x/pkg/util/goroutine_pool +yunion.io/x/pkg/util/httputils +yunion.io/x/pkg/util/imagetools +yunion.io/x/pkg/util/multipart yunion.io/x/pkg/util/netutils yunion.io/x/pkg/util/osprofile +yunion.io/x/pkg/util/pinyinutils +yunion.io/x/pkg/util/printutils yunion.io/x/pkg/util/prometheus +yunion.io/x/pkg/util/qemuimgfmt +yunion.io/x/pkg/util/rand +yunion.io/x/pkg/util/rbacscope yunion.io/x/pkg/util/reflectutils yunion.io/x/pkg/util/regutils yunion.io/x/pkg/util/runtime +yunion.io/x/pkg/util/s3auth +yunion.io/x/pkg/util/samlutils yunion.io/x/pkg/util/seclib yunion.io/x/pkg/util/secrules yunion.io/x/pkg/util/sets +yunion.io/x/pkg/util/shellutils yunion.io/x/pkg/util/signalutils +yunion.io/x/pkg/util/streamutils yunion.io/x/pkg/util/stringutils yunion.io/x/pkg/util/timeutils yunion.io/x/pkg/util/trace yunion.io/x/pkg/util/version +yunion.io/x/pkg/util/vmdkutils yunion.io/x/pkg/util/wait yunion.io/x/pkg/util/workqueue yunion.io/x/pkg/utils diff --git a/vendor/yunion.io/x/cloudmux/pkg/apis/const.go b/vendor/yunion.io/x/cloudmux/pkg/apis/const.go index 33788989d3..da02f1632e 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/apis/const.go +++ b/vendor/yunion.io/x/cloudmux/pkg/apis/const.go @@ -36,3 +36,7 @@ const ( OS_ARCH_AARCH32 = "aarch32" OS_ARCH_AARCH64 = "aarch64" ) + +const ( + PUBLIC_CLOUD_ANSIBLE_USER = "cloudroot" +) diff --git a/vendor/yunion.io/x/cloudmux/pkg/apis/metadata.go b/vendor/yunion.io/x/cloudmux/pkg/apis/metadata.go index ede9495ceb..4274ceec94 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/apis/metadata.go +++ b/vendor/yunion.io/x/cloudmux/pkg/apis/metadata.go @@ -17,4 +17,3 @@ package apis const ( IS_SYSTEM = "IsSystem" ) - diff --git a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/cloudprovider.go b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/cloudprovider.go index bf8c3defe5..686c8d8067 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/cloudprovider.go +++ b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/cloudprovider.go @@ -21,9 +21,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" - - "yunion.io/x/onecloud/pkg/util/httputils" ) type SCloudaccountCredential struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/dbinstance.go b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/dbinstance.go index 1677374063..2eb09c7676 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/dbinstance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/dbinstance.go @@ -14,7 +14,7 @@ package cloudprovider -import "yunion.io/x/onecloud/pkg/util/billing" +import "yunion.io/x/pkg/util/billing" type TBackupMethod string diff --git a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/elasticcache.go b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/elasticcache.go index 3696c0ba3b..612310a8e7 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/elasticcache.go +++ b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/elasticcache.go @@ -14,7 +14,7 @@ package cloudprovider -import "yunion.io/x/onecloud/pkg/util/billing" +import "yunion.io/x/pkg/util/billing" // https://support.huaweicloud.com/api-dcs/dcs-zh-api-180423019.html // https://help.aliyun.com/document_detail/60873.html?spm=a2c4g.11174283.6.715.7412dce0qSYemb diff --git a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/instance.go b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/instance.go index 4db5dc0132..3bd1342139 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/instance.go @@ -20,12 +20,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/cloudinit" "yunion.io/x/pkg/util/osprofile" + "yunion.io/x/pkg/util/seclib" - "yunion.io/x/onecloud/pkg/util/ansible" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/cloudinit" - "yunion.io/x/onecloud/pkg/util/seclib2" + "yunion.io/x/cloudmux/pkg/apis" ) type TOsType string @@ -209,7 +209,7 @@ func (vmConfig *SManagedVMCreateConfig) GetConfig(config *jsonutils.JSONDict) er resetPassword := jsonutils.QueryBoolean(config, "reset_password", false) vmConfig.Password, _ = config.GetString("password") if resetPassword && len(vmConfig.Password) == 0 { - vmConfig.Password = seclib2.RandomPassword2(12) + vmConfig.Password = seclib.RandomPassword2(12) } if vmConfig.IsNeedInjectPasswordByCloudInit { err = vmConfig.InjectPasswordByCloudInit() @@ -227,7 +227,7 @@ func generateUserData(adminPublicKey, projectPublicKey, oUserData string) string oCloudConfig, _ = cloudinit.ParseUserData(oUserData) } - ansibleUser := cloudinit.NewUser(ansible.PUBLIC_CLOUD_ANSIBLE_USER) + ansibleUser := cloudinit.NewUser(apis.PUBLIC_CLOUD_ANSIBLE_USER) ansibleUser.SshKey(adminPublicKey).SshKey(projectPublicKey).SudoPolicy(cloudinit.USER_SUDO_NOPASSWD) cloudConfig := cloudinit.SCloudConfig{ diff --git a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/loadbalancer.go b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/loadbalancer.go index d9d2856307..33b4515ced 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/loadbalancer.go +++ b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/loadbalancer.go @@ -14,7 +14,7 @@ package cloudprovider -import "yunion.io/x/onecloud/pkg/util/billing" +import "yunion.io/x/pkg/util/billing" type SLoadbalancerCreateOptions struct { Name string diff --git a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/nas.go b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/nas.go index f03e685690..469afff8d4 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/nas.go +++ b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/nas.go @@ -14,7 +14,7 @@ package cloudprovider -import "yunion.io/x/onecloud/pkg/util/billing" +import "yunion.io/x/pkg/util/billing" type FileSystemCraeteOptions struct { Name string diff --git a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/nat.go b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/nat.go index 660429edaf..a97e6237a3 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/nat.go +++ b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/nat.go @@ -14,7 +14,7 @@ package cloudprovider -import "yunion.io/x/onecloud/pkg/util/billing" +import "yunion.io/x/pkg/util/billing" // These two structures are designed for modifying snat table and dnat table. // There is a so strange point that they have both field of ExternalIP and ExternalIPID. diff --git a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/resources.go b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/resources.go index d775d7a286..686323d62b 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/resources.go +++ b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/resources.go @@ -21,10 +21,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" - - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rbacutils" - "yunion.io/x/onecloud/pkg/util/samlutils" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rbacscope" + "yunion.io/x/pkg/util/samlutils" ) type ICloudResource interface { @@ -231,7 +230,7 @@ type ICloudImage interface { GetMinRamSizeMb() int GetImageFormat() string - GetPublicScope() rbacutils.TRbacScope + GetPublicScope() rbacscope.TRbacScope GetSubImages() []SSubImage } @@ -641,7 +640,7 @@ type ICloudNetwork interface { // 仅私有云有用,公有云无效 // 1. scope = none 非共享, network仅会属于一个项目,并且私有 // 2. scope = system 系统共享 云账号共享会跟随云账号共享,云账号非共享,会共享到network所在域 - GetPublicScope() rbacutils.TRbacScope + GetPublicScope() rbacscope.TRbacScope Delete() error diff --git a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/saml.go b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/saml.go index eaa95c1532..ecd39c9bb4 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/saml.go +++ b/vendor/yunion.io/x/cloudmux/pkg/cloudprovider/saml.go @@ -14,7 +14,7 @@ package cloudprovider -import "yunion.io/x/onecloud/pkg/util/samlutils" +import "yunion.io/x/pkg/util/samlutils" const ( SAML_ENTITY_ID_ALIYUN_ROLE = "urn:alibaba:cloudcomputing" diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/aliyun.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/aliyun.go index 34dc2d87c7..0d0766092b 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/aliyun.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/aliyun.go @@ -32,11 +32,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" v "yunion.io/x/pkg/util/version" "yunion.io/x/pkg/utils" - "yunion.io/x/onecloud/pkg/util/httputils" - api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" ) diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/dbinstance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/dbinstance.go index ffb57a7c0d..8c7d71dcc4 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/dbinstance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/dbinstance.go @@ -23,13 +23,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rand" "yunion.io/x/pkg/utils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rand" ) type SReadOnlyDBInstanceIds struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/elasticcache_instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/elasticcache_instance.go index baa9d03ec1..b7cb38a7db 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/elasticcache_instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/elasticcache_instance.go @@ -25,11 +25,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) // https://help.aliyun.com/document_detail/60933.html?spm=a2c4g.11186623.6.726.38f82ca9U1Gtxw diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/host.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/host.go index 669969d2f6..a8b8a25fd6 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/host.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/host.go @@ -20,11 +20,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SHost struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/image.go index b24372d6d6..019e815704 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/image.go @@ -24,12 +24,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/imagetools" "yunion.io/x/cloudmux/pkg/apis" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type ImageStatusType string diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/instance.go index 4813fa2a6d..408324675d 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/instance.go @@ -24,6 +24,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/imagetools" "yunion.io/x/pkg/util/osprofile" "yunion.io/x/pkg/util/seclib" "yunion.io/x/pkg/utils" @@ -32,8 +34,6 @@ import ( api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/imagetools" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/saml_provider.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/saml_provider.go index 0220b458e1..36eb452073 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/saml_provider.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/saml_provider.go @@ -22,13 +22,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/samlutils" "yunion.io/x/cloudmux/pkg/apis/cloudid" api "yunion.io/x/cloudmux/pkg/apis/cloudid" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/samlutils" ) type SAMLProvider struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/storagecache.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/storagecache.go index a044956726..a0971c687d 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/storagecache.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/storagecache.go @@ -27,10 +27,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/qemuimg" ) type SStoragecache struct { @@ -118,7 +118,7 @@ func (self *SStoragecache) UploadImage(ctx context.Context, image *cloudprovider } func (self *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider.SImageCreateOption, callback func(float32)) (string, error) { - reader, sizeByte, err := image.GetReader(image.ImageId, string(qemuimg.QCOW2)) + reader, sizeByte, err := image.GetReader(image.ImageId, string(qemuimgfmt.QCOW2)) if err != nil { return "", errors.Wrapf(err, "GetReader") } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/vswitch.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/vswitch.go index 7797438672..1f1210bce2 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/vswitch.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aliyun/vswitch.go @@ -22,12 +22,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) // {"AvailableIpAddressCount":4091,"CidrBlock":"172.31.32.0/20","CreationTime":"2017-03-19T13:37:44Z","Description":"System created default virtual switch.","IsDefault":true,"Status":"Available","VSwitchId":"vsw-j6c3gig5ub4fmi2veyrus","VSwitchName":"","VpcId":"vpc-j6c86z3sh8ufhgsxwme0q","ZoneId":"cn-hongkong-b"} @@ -137,8 +137,8 @@ func (self *SVSwitch) GetIsPublic() bool { return true } -func (self *SVSwitch) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SVSwitch) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SRegion) createVSwitch(zoneId string, vpcId string, name string, cidr string, desc string) (string, error) { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/apsara.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/apsara.go index 4c1998c17d..5989cd38a6 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/apsara.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/apsara.go @@ -32,12 +32,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" v "yunion.io/x/pkg/util/version" "yunion.io/x/pkg/utils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/dbinstance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/dbinstance.go index d4a82de8a7..b6b4dbd0e7 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/dbinstance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/dbinstance.go @@ -23,13 +23,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/rand" "yunion.io/x/pkg/utils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/rand" ) type SReadOnlyDBInstanceIds struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/elasticcache_instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/elasticcache_instance.go index be7eb76f87..0c19818317 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/elasticcache_instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/elasticcache_instance.go @@ -25,12 +25,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/billing" billingapi "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) // https://help.apsara.com/document_detail/60933.html?spm=a2c4g.11186623.6.726.38f82ca9U1Gtxw diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/host.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/host.go index e01d59814b..5fc579fc7c 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/host.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/host.go @@ -19,11 +19,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SHost struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/image.go index d64ffb55ae..d94cf035f5 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/image.go @@ -22,11 +22,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/imagetools" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type ImageStatusType string diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/instance.go index 54e230415c..fa5320963a 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/instance.go @@ -24,6 +24,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/imagetools" "yunion.io/x/pkg/util/osprofile" "yunion.io/x/pkg/util/seclib" "yunion.io/x/pkg/utils" @@ -31,8 +33,6 @@ import ( api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/imagetools" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/storagecache.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/storagecache.go index 9b24097b4e..8caf772012 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/storagecache.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/storagecache.go @@ -25,10 +25,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/qemuimg" ) type SStoragecache struct { @@ -143,7 +143,7 @@ func (self *SStoragecache) UploadImage(ctx context.Context, image *cloudprovider } func (self *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider.SImageCreateOption, callback func(progress float32)) (string, error) { - reader, sizeByte, err := image.GetReader(image.ImageId, string(qemuimg.QCOW2)) + reader, sizeByte, err := image.GetReader(image.ImageId, string(qemuimgfmt.QCOW2)) if err != nil { return "", errors.Wrapf(err, "GetReader") } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/vswitch.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/vswitch.go index 2ca4b7026b..7767edcd0e 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/vswitch.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/apsara/vswitch.go @@ -22,12 +22,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) // {"AvailableIpAddressCount":4091,"CidrBlock":"172.31.32.0/20","CreationTime":"2017-03-19T13:37:44Z","Description":"System created default virtual switch.","IsDefault":true,"Status":"Available","VSwitchId":"vsw-j6c3gig5ub4fmi2veyrus","VSwitchName":"","VpcId":"vpc-j6c86z3sh8ufhgsxwme0q","ZoneId":"cn-hongkong-b"} @@ -137,8 +137,8 @@ func (self *SVSwitch) GetIsPublic() bool { return true } -func (self *SVSwitch) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SVSwitch) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SRegion) createVSwitch(zoneId string, vpcId string, name string, cidr string, desc string) (string, error) { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/bucket.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/bucket.go index 81117014c3..0b4f872e99 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/bucket.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/bucket.go @@ -30,11 +30,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/fileutils" "yunion.io/x/s3cli" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/fileutils2" ) type SBucket struct { @@ -225,7 +225,7 @@ func (b *SBucket) PutObject(ctx context.Context, key string, body io.Reader, siz input := &s3.PutObjectInput{} input.SetBucket(b.Name) input.SetKey(key) - seeker, err := fileutils2.NewReadSeeker(body, sizeBytes) + seeker, err := fileutils.NewReadSeeker(body, sizeBytes) if err != nil { return errors.Wrap(err, "newFakeSeeker") } @@ -330,7 +330,7 @@ func (b *SBucket) UploadPart(ctx context.Context, key string, uploadId string, p input.SetKey(key) input.SetUploadId(uploadId) input.SetPartNumber(int64(partIndex)) - seeker, err := fileutils2.NewReadSeeker(part, partSize) + seeker, err := fileutils.NewReadSeeker(part, partSize) if err != nil { return "", errors.Wrap(err, "newFakeSeeker") } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/elasticache_instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/elasticache_instance.go index 0d42aba87a..f3452f026a 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/elasticache_instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/elasticache_instance.go @@ -25,12 +25,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" billingapi "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) func (region *SRegion) DescribeElasticacheReplicationGroups(Id string) ([]*elasticache.ReplicationGroup, error) { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/image.go index 05187c2fd6..e6cb2d4cb9 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/image.go @@ -24,12 +24,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/imagetools" "yunion.io/x/pkg/util/timeutils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type ImageStatusType string diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/instance.go index e2799eec64..eef0f8e4e0 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/instance.go @@ -26,6 +26,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/cloudinit" "yunion.io/x/pkg/util/osprofile" "yunion.io/x/pkg/utils" @@ -34,8 +36,6 @@ import ( api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/cloudinit" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/network.go index 1abdc7ac7b..1d3f9026be 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/network.go @@ -26,11 +26,11 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SNetwork struct { @@ -148,8 +148,8 @@ func (self *SNetwork) GetIsPublic() bool { return true } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SNetwork) Delete() error { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/saml_provider.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/saml_provider.go index 9a856d0ac6..0966c0afda 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/saml_provider.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/saml_provider.go @@ -22,14 +22,14 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/samlutils" "yunion.io/x/cloudmux/pkg/apis/cloudid" api "yunion.io/x/cloudmux/pkg/apis/cloudid" compute_api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/samlutils" ) type SAMLProvider struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/storagecache.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/storagecache.go index c11b5932d9..65b65a56fc 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/storagecache.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/aws/storagecache.go @@ -27,10 +27,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/qemuimg" ) type SStoragecache struct { @@ -150,7 +150,7 @@ func (self *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider defer self.region.DeleteIBucket(bucketName) - reader, sizeBytes, err := image.GetReader(image.ImageId, string(qemuimg.VMDK)) + reader, sizeBytes, err := image.GetReader(image.ImageId, string(qemuimgfmt.VMDK)) if err != nil { return "", errors.Wrapf(err, "GetReader") } @@ -190,7 +190,7 @@ func (self *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider log.Debugf("uploadImage Match remote name %s", imageName) } - task, err := self.region.ImportImage(imageName, image.OsArch, image.OsType, image.OsDistribution, string(qemuimg.VMDK), bucketName, image.ImageId) + task, err := self.region.ImportImage(imageName, image.OsArch, image.OsType, image.OsDistribution, string(qemuimgfmt.VMDK), bucketName, image.ImageId) if err != nil { log.Errorf("ImportImage error %s %s %s", image.ImageId, bucketName, err) diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/azure.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/azure.go index 654c96cc3d..9f72d1de8e 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/azure.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/azure.go @@ -45,11 +45,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/classic_instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/classic_instance.go index d61021048e..9a83192619 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/classic_instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/classic_instance.go @@ -24,6 +24,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/osprofile" "yunion.io/x/cloudmux/pkg/apis" @@ -31,7 +32,6 @@ import ( api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type FormattedMessage struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/classic_network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/classic_network.go index 4d9a91eda1..285383d4ed 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/classic_network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/classic_network.go @@ -19,11 +19,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SClassicNetwork struct { @@ -107,8 +107,8 @@ func (self *SClassicNetwork) GetIsPublic() bool { return true } -func (self *SClassicNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SClassicNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SClassicNetwork) GetServerType() string { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/clouduser.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/clouduser.go index 692db2519c..7e0f3079e2 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/clouduser.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/clouduser.go @@ -22,10 +22,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SClouduserPasswordProfile struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/host.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/host.go index 9decb387cb..cb4979fb47 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/host.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/host.go @@ -23,12 +23,12 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/osprofile" + "yunion.io/x/pkg/util/seclib" "yunion.io/x/pkg/utils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/seclib2" ) type SHost struct { @@ -83,7 +83,7 @@ func (self *SRegion) _createVM(desc *cloudprovider.SManagedVMCreateConfig, nicId if len(desc.Password) == 0 { //Azure创建必须要设置密码 - desc.Password = seclib2.RandomPassword2(12) + desc.Password = seclib.RandomPassword2(12) } if image.Properties.ProvisioningState != ImageStatusAvailable { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/instance.go index 8887f774b5..37b269cac8 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/instance.go @@ -24,15 +24,15 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/osprofile" + "yunion.io/x/pkg/util/version" "yunion.io/x/cloudmux/pkg/apis" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/version" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/loganalytics.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/loganalytics.go index 83e79a5793..f3481a98c2 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/loganalytics.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/loganalytics.go @@ -19,7 +19,7 @@ import ( "net/url" "time" - "yunion.io/x/onecloud/pkg/util/httputils" + "yunion.io/x/pkg/util/httputils" ) type SLoganalyticsWorkspace struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/monitor.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/monitor.go index 9f5d9eec84..17d4691dea 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/monitor.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/monitor.go @@ -25,12 +25,12 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/pkg/utils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) type ResponseMetirc struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/network.go index 704b9d3172..8ceda63ce1 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/network.go @@ -19,11 +19,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SNetwork struct { @@ -100,8 +100,8 @@ func (self *SNetwork) GetIsPublic() bool { return true } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SNetwork) GetServerType() string { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/saml_provider.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/saml_provider.go index cc346b050b..a3d6c8800c 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/saml_provider.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/saml_provider.go @@ -20,14 +20,14 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/samlutils" "yunion.io/x/cloudmux/pkg/apis/cloudid" api "yunion.io/x/cloudmux/pkg/apis/cloudid" compute_api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/samlutils" ) type SAMLProvider struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/storagecache.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/storagecache.go index ddb43a4b83..2f9a63d5f1 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/storagecache.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/azure/storagecache.go @@ -26,11 +26,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/fileutils" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/fileutils2" - "yunion.io/x/onecloud/pkg/util/qemuimg" ) const ( @@ -139,7 +139,7 @@ func (self *SStoragecache) checkStorageAccount() (*SStorageAccount, error) { } func (self *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider.SImageCreateOption, tmpPath string, callback func(progress float32)) (string, error) { - reader, sizeBytes, err := image.GetReader(image.ImageId, string(qemuimg.VHD)) + reader, sizeBytes, err := image.GetReader(image.ImageId, string(qemuimgfmt.VHD)) if err != nil { return "", errors.Wrapf(err, "GetReader") } @@ -216,7 +216,7 @@ func (self *SStoragecache) downloadImage(imageId string, extId string, path stri defer tmpImageFile.Close() defer os.Remove(tmpImageFile.Name()) { - sf := fileutils2.NewSparseFileWriter(tmpImageFile) + sf := fileutils.NewSparseFileWriter(tmpImageFile) data := make([]byte, DefaultReadBlockSize) written := int64(0) for { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/billing_base.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/billing_base.go index 90c8a37032..b8dc0402d2 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/billing_base.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/billing_base.go @@ -18,9 +18,9 @@ import ( "time" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/billing" ) type SBillingBase struct{} diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/bingo.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/bingo.go index 956b7f3789..00b1463dec 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/bingo.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/bingo.go @@ -33,10 +33,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/image.go index a36278da03..05d831a183 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/image.go @@ -19,12 +19,12 @@ import ( "time" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/imagetools" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SImage struct { @@ -161,11 +161,11 @@ func (self *SImage) UEFI() bool { return self.Bootloader == "uefi" } -func (self *SImage) GetPublicScope() rbacutils.TRbacScope { +func (self *SImage) GetPublicScope() rbacscope.TRbacScope { if self.Shared == "true" { - return rbacutils.ScopeSystem + return rbacscope.ScopeSystem } - return rbacutils.ScopeDomain + return rbacscope.ScopeDomain } func (self *SImage) GetSubImages() []cloudprovider.SSubImage { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/network.go index e240545ce5..e305aa1201 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/bingocloud/network.go @@ -20,11 +20,11 @@ import ( "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SNetwork struct { @@ -132,8 +132,8 @@ func (self *SNetwork) GetProjectId() string { return "" } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SNetwork) GetServerType() string { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/doc.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/doc.go deleted file mode 100644 index 63215930c4..0000000000 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/cloudpods/doc.go +++ /dev/null @@ -1,15 +0,0 @@ -// 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 cloudpods // import "yunion.io/x/cloudmux/pkg/multicloud/cloudpods" diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/ctyun.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/ctyun.go index 4c583379ee..bd1e81269f 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/ctyun.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/ctyun.go @@ -30,10 +30,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/image.go index 7fd99a9ddd..1b20da2446 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/image.go @@ -21,11 +21,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/imagetools" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/instance.go index a3e81e1c24..33683873a2 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/instance.go @@ -24,13 +24,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/utils" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SInstance struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/network.go index d74c1aef2e..fcf5dcf767 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/network.go @@ -23,11 +23,11 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SNetwork struct { @@ -131,8 +131,8 @@ func (self *SNetwork) GetIsPublic() bool { return true } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SNetwork) Delete() error { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/dbinstance_base.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/dbinstance_base.go index 7a57d85a4a..2d4506cd1e 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/dbinstance_base.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/dbinstance_base.go @@ -18,9 +18,9 @@ import ( "context" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/billing" ) type SDBInstanceBase struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/client.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/client.go index 2e7a7fda2f..8be92bbb9d 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/client.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/client.go @@ -28,10 +28,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/image.go index 65aea2f47e..5140fa4d04 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/image.go @@ -20,11 +20,11 @@ import ( "time" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/imagetools" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type SImage struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/instance.go index 1dc5bd0246..a186ece42b 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/instance.go @@ -20,13 +20,13 @@ import ( "time" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/sets" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SNovaRequest struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/network.go index 0daf91cb1a..a88f9d17ec 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/network.go @@ -18,11 +18,11 @@ import ( "context" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SNetwork struct { @@ -135,8 +135,8 @@ func (self *SNetwork) GetIsPublic() bool { return true } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SNetwork) Delete() error { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/request.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/request.go index 5f513e8cd2..417a1fd1e0 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/request.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ecloud/request.go @@ -21,11 +21,11 @@ import ( "strings" "time" - "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/httputils" + "yunion.io/x/cloudmux/pkg/cloudprovider" ) type IRequest interface { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/image.go index 4445a67c47..afcce46812 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/image.go @@ -22,10 +22,11 @@ import ( "github.com/vmware/govmomi/object" + "yunion.io/x/pkg/util/imagetools" + api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type SImage struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/manager.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/manager.go index 50cb15dbeb..d174be4c7d 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/manager.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/manager.go @@ -42,13 +42,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/cloudmux/pkg/multicloud/esxi/vcenter" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/storage.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/storage.go index f2cfdd3fad..7322ce559c 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/storage.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/storage.go @@ -45,11 +45,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/vmdkutils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/vmdkutils" ) var DATASTORE_PROPS = []string{"name", "parent", "info", "summary", "host", "vm"} diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/vdisk.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/vdisk.go index 00de638ed5..86b5c09e3a 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/vdisk.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/vdisk.go @@ -25,15 +25,10 @@ import ( "github.com/vmware/govmomi/vim25/types" "yunion.io/x/log" - "yunion.io/x/pkg/errors" - "yunion.io/x/cloudmux/pkg/apis/compute" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - deployapi "yunion.io/x/onecloud/pkg/hostman/hostdeployer/apis" - "yunion.io/x/onecloud/pkg/hostman/hostdeployer/deployclient" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/cloudmux/pkg/multicloud/esxi/vcenter" ) var driverMap = map[string]string{ @@ -475,6 +470,7 @@ func (disk *SVirtualDisk) Resize(ctx context.Context, newSizeMb int64) error { return err } +/* func (disk *SVirtualDisk) ResizePartition(ctx context.Context, accessInfo vcenter.SVCenterAccessInfo) error { diskPath := disk.GetFilename() vmref := disk.vm.GetMoid() @@ -498,6 +494,7 @@ func (disk *SVirtualDisk) ResizePartition(ctx context.Context, accessInfo vcente } return nil } +*/ func (disk *SVirtualDisk) Reset(ctx context.Context, snapshotId string) (string, error) { return "", cloudprovider.ErrNotImplemented diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/virtualmachine.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/virtualmachine.go index 659b1afdc6..0226bc564d 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/virtualmachine.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/esxi/virtualmachine.go @@ -32,17 +32,14 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/imagetools" "yunion.io/x/pkg/util/netutils" "yunion.io/x/pkg/util/reflectutils" "yunion.io/x/pkg/util/regutils" + "yunion.io/x/pkg/util/version" "yunion.io/x/pkg/utils" - cloudtypes "yunion.io/x/onecloud/pkg/cloudcommon/types" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/imagetools" - "yunion.io/x/onecloud/pkg/util/netutils2" - "yunion.io/x/onecloud/pkg/util/version" - billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" @@ -1186,6 +1183,44 @@ func (self *SVirtualMachine) GetToolsVersion() string { return self.getVirtualMachine().Guest.ToolsVersion } +type SServerNic struct { + Name string `json:"name"` + Index int `json:"index"` + Bridge string `json:"bridge"` + Domain string `json:"domain"` + Ip string `json:"ip"` + Vlan int `json:"vlan"` + Driver string `json:"driver"` + Masklen int `json:"masklen"` + Virtual bool `json:"virtual"` + Manual bool `json:"manual"` + WireId string `json:"wire_id"` + NetId string `json:"net_id"` + Mac string `json:"mac"` + BandWidth int `json:"bw"` + Mtu int `json:"mtu,omitempty"` + Dns string `json:"dns"` + Ntp string `json:"ntp"` + Net string `json:"net"` + Interface string `json:"interface"` + Gateway string `json:"gateway"` + Ifname string `json:"ifname"` + NicType string `json:"nic_type,omitempty"` + LinkUp bool `json:"link_up,omitempty"` + TeamWith string `json:"team_with,omitempty"` + + TeamingMaster *SServerNic `json:"-"` + TeamingSlaves []*SServerNic `json:"-"` +} + +func (nicdesc SServerNic) getNicDns() []string { + dnslist := []string{} + if len(nicdesc.Dns) > 0 { + dnslist = append(dnslist, nicdesc.Dns) + } + return dnslist +} + func (self *SVirtualMachine) DoCustomize(ctx context.Context, params jsonutils.JSONObject) error { spec := new(types.CustomizationSpec) @@ -1197,24 +1232,22 @@ func (self *SVirtualMachine) DoCustomize(ctx context.Context, params jsonutils.J ipSettings.DnsSuffixList = []string{domain} // deal nics - nics, _ := params.GetArray("nics") - serverNics := make([]cloudtypes.SServerNic, len(nics)) - for i := range nics { - var nicType cloudtypes.SServerNic - nics[i].Unmarshal(&nicType) - serverNics[i] = nicType + serverNics := make([]SServerNic, 0) + err := params.Unmarshal(&serverNics, "nics") + if err != nil { + return errors.Wrap(err, "Unmarshal nics") } // find dnsServerList for i := range serverNics { - dnsList := netutils2.GetNicDns(&serverNics[i]) + dnsList := serverNics[i].getNicDns() if len(dnsList) != 0 { ipSettings.DnsServerList = dnsList } } spec.GlobalIPSettings = *ipSettings - maps := make([]types.CustomizationAdapterMapping, 0, len(nics)) + maps := make([]types.CustomizationAdapterMapping, 0, len(serverNics)) for _, nic := range serverNics { conf := types.CustomizationAdapterMapping{} conf.MacAddress = nic.Mac @@ -1233,13 +1266,13 @@ func (self *SVirtualMachine) DoCustomize(ctx context.Context, params jsonutils.J if maskLen == 0 { maskLen = 24 } - mask := netutils2.Netlen2Mask(maskLen) + mask := netutils.Netlen2Mask(maskLen) conf.Adapter.SubnetMask = mask if len(nic.Gateway) != 0 { conf.Adapter.Gateway = []string{nic.Gateway} } - dnsList := netutils2.GetNicDns(&nic) + dnsList := nic.getNicDns() if len(dnsList) != 0 { conf.Adapter.DnsServerList = dnsList dns := nic.Domain diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/dbinstance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/dbinstance.go index 259cd11b51..23b109256d 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/dbinstance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/dbinstance.go @@ -24,13 +24,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/utils" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) var ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/google.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/google.go index 4a14da9f12..fcd6e47036 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/google.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/google.go @@ -32,10 +32,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/image.go index c95f12045b..b8a78d4ec0 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/image.go @@ -22,11 +22,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/imagetools" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type GuestOsFeature struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/instance.go index ca0b7f81b7..4dcc722fe8 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/instance.go @@ -23,18 +23,18 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/cloudinit" + "yunion.io/x/pkg/util/encode" "yunion.io/x/pkg/util/fileutils" + "yunion.io/x/pkg/util/imagetools" + "yunion.io/x/pkg/util/pinyinutils" "yunion.io/x/pkg/utils" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/cloudinit" - "yunion.io/x/onecloud/pkg/util/encode" - "yunion.io/x/onecloud/pkg/util/imagetools" - "yunion.io/x/onecloud/pkg/util/pinyinutils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/network.go index cf8c03366f..d7efd2d9ee 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/network.go @@ -17,8 +17,8 @@ package google import ( "time" - "yunion.io/x/onecloud/pkg/util/rbacutils" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" @@ -104,6 +104,6 @@ func (network *SNetwork) GetIsPublic() bool { return true } -func (network *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (network *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/storagecache.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/storagecache.go index 3a73b19c6b..c8311a2733 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/storagecache.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/storagecache.go @@ -23,11 +23,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/pkg/utils" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/qemuimg" ) type SStoragecache struct { @@ -111,7 +111,7 @@ func (region *SRegion) checkAndCreateBucket(bucketName string) (*SBucket, error) } func (cache *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider.SImageCreateOption, callback func(progress float32)) (string, error) { - reader, sizeBytes, err := image.GetReader(image.ImageId, string(qemuimg.QCOW2)) + reader, sizeBytes, err := image.GetReader(image.ImageId, string(qemuimgfmt.QCOW2)) if err != nil { return "", errors.Wrapf(err, "GetReader") } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/tag_base.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/tag_base.go index 838c8b6c04..578774d623 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/tag_base.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/google/tag_base.go @@ -18,9 +18,9 @@ import ( "strings" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/encode" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/encode" ) type GoogleTags struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/dbinstance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/dbinstance.go index bc8f1a0603..7ae75b35fa 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/dbinstance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/dbinstance.go @@ -22,14 +22,14 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/httputils" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/cloudmux/pkg/multicloud/huawei" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SBackupStrategy struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/external_network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/external_network.go index e17807953d..7476c12802 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/external_network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/external_network.go @@ -19,11 +19,11 @@ import ( "net/url" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SBucketAllocationPools struct { @@ -120,8 +120,8 @@ func (self *SExternalNetwork) GetIsPublic() bool { return true } -func (self *SExternalNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SExternalNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SExternalNetwork) Delete() error { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/hcs.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/hcs.go index 587d5b4275..aa5b541c7d 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/hcs.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/hcs.go @@ -29,12 +29,12 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud/hcso/client/auth" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/host.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/host.go index 1f7b1a0299..9fb3bb2915 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/host.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/host.go @@ -21,12 +21,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/osprofile" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SHost struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/image.go index fe84226609..ae679ce13d 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/image.go @@ -24,13 +24,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/imagetools" "yunion.io/x/cloudmux/pkg/apis" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/cloudmux/pkg/multicloud/huawei" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type TImageOwnerType string diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/instance.go index a90490addb..b21839117f 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/instance.go @@ -26,10 +26,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/cloudinit" - "yunion.io/x/onecloud/pkg/util/imagetools" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/cloudinit" + "yunion.io/x/pkg/util/imagetools" "yunion.io/x/pkg/util/osprofile" "yunion.io/x/pkg/utils" diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/monitor.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/monitor.go index 9d2bfdfc78..e68019321a 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/monitor.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/monitor.go @@ -25,9 +25,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" - "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/cloudmux/pkg/cloudprovider" ) diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/network.go index f3178882ae..2f4a1e0d7b 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/network.go @@ -20,11 +20,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) /* @@ -129,8 +129,8 @@ func (self *SNetwork) GetIsPublic() bool { return true } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SNetwork) Delete() error { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/redis.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/redis.go index d1a341029e..d6ca6f7c04 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/redis.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/redis.go @@ -22,8 +22,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" - "yunion.io/x/onecloud/pkg/util/billing" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/storagecache.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/storagecache.go index cb6160aa7c..9b6e9b57fb 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/storagecache.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcs/storagecache.go @@ -24,8 +24,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" - - "yunion.io/x/onecloud/pkg/util/qemuimg" + "yunion.io/x/pkg/util/qemuimgfmt" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" @@ -133,7 +132,7 @@ func (self *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider } defer self.region.DeleteIBucket(bucketName) - reader, sizeByte, err := image.GetReader(image.ImageId, string(qemuimg.VMDK)) + reader, sizeByte, err := image.GetReader(image.ImageId, string(qemuimgfmt.VMDK)) if err != nil { return "", errors.Wrapf(err, "GetReader") } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/client/modules/manager_base.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/client/modules/manager_base.go index 2834a0758c..4da9815d8a 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/client/modules/manager_base.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/client/modules/manager_base.go @@ -27,13 +27,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud/hcso/client/auth" "yunion.io/x/cloudmux/pkg/multicloud/hcso/client/manager" "yunion.io/x/cloudmux/pkg/multicloud/hcso/client/requests" "yunion.io/x/cloudmux/pkg/multicloud/hcso/client/responses" - "yunion.io/x/onecloud/pkg/util/httputils" ) type IRequestHook interface { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/dbinstance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/dbinstance.go index 91ef5f860a..d969dc0a62 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/dbinstance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/dbinstance.go @@ -23,13 +23,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/billing" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/cloudmux/pkg/multicloud/huawei" - "yunion.io/x/onecloud/pkg/util/billing" ) type SBackupStrategy struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/elasticcache_instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/elasticcache_instance.go index 05cca6f004..d9346f475b 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/elasticcache_instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/elasticcache_instance.go @@ -23,13 +23,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/cloudmux/pkg/multicloud/huawei" - "yunion.io/x/onecloud/pkg/util/billing" ) // https://support.huaweicloud.com/api-dcs/dcs-zh-api-180423020.html diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/hcso.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/hcso.go index 95e1903630..a2f65f4ea2 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/hcso.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/hcso.go @@ -27,9 +27,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) type akClient struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/host.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/host.go index a43f96a592..2974c4b18a 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/host.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/host.go @@ -21,12 +21,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/osprofile" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SHost struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/image.go index 507ca4c194..b83ea82c68 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/image.go @@ -23,13 +23,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/imagetools" "yunion.io/x/cloudmux/pkg/apis" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/cloudmux/pkg/multicloud/huawei" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type TImageOwnerType string diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/instance.go index 381cc9d8f5..0832ac259d 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/instance.go @@ -26,6 +26,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/cloudinit" + "yunion.io/x/pkg/util/imagetools" "yunion.io/x/pkg/util/osprofile" "yunion.io/x/pkg/utils" @@ -36,9 +39,6 @@ import ( "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/cloudmux/pkg/multicloud/hcso/client/modules" "yunion.io/x/cloudmux/pkg/multicloud/huawei" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/cloudinit" - "yunion.io/x/onecloud/pkg/util/imagetools" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/modelarts.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/modelarts.go index ef47feac45..d86c35ad17 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/modelarts.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/modelarts.go @@ -20,12 +20,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SModelartsPool struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/network.go index 43870401ba..4ae4a16d28 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/network.go @@ -18,13 +18,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/cloudmux/pkg/multicloud/hcso/client/modules" "yunion.io/x/cloudmux/pkg/multicloud/huawei" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) /* @@ -135,8 +135,8 @@ func (self *SNetwork) GetIsPublic() bool { return true } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SNetwork) Delete() error { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/saml_provider.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/saml_provider.go index 0050d82376..35230c8556 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/saml_provider.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/saml_provider.go @@ -21,6 +21,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" "yunion.io/x/pkg/util/stringutils" api "yunion.io/x/cloudmux/pkg/apis/cloudid" @@ -28,7 +29,6 @@ import ( "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/cloudmux/pkg/multicloud/hcso/client/modules" "yunion.io/x/cloudmux/pkg/multicloud/huawei" - "yunion.io/x/onecloud/pkg/util/samlutils" ) type SAMLProviderLinks struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/storagecache.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/storagecache.go index f9adc164e8..8d8eaa7011 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/storagecache.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/storagecache.go @@ -24,12 +24,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/cloudmux/pkg/multicloud/huawei" - "yunion.io/x/onecloud/pkg/util/qemuimg" ) type SStoragecache struct { @@ -162,7 +162,7 @@ func (self *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider } defer self.region.DeleteIBucket(bucketName) - reader, sizeByte, err := image.GetReader(image.ImageId, string(qemuimg.VMDK)) + reader, sizeByte, err := image.GetReader(image.ImageId, string(qemuimgfmt.VMDK)) if err != nil { return "", errors.Wrapf(err, "GetReader") } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/utils.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/utils.go index 5174adcfe8..a167629fec 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/utils.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/hcso/utils.go @@ -22,10 +22,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud/hcso/client/manager" "yunion.io/x/cloudmux/pkg/multicloud/hcso/client/responses" diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/client/modules/manager_base.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/client/modules/manager_base.go index 75b043abf4..fadb967cac 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/client/modules/manager_base.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/client/modules/manager_base.go @@ -25,13 +25,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud/huawei/client/auth" "yunion.io/x/cloudmux/pkg/multicloud/huawei/client/manager" "yunion.io/x/cloudmux/pkg/multicloud/huawei/client/requests" "yunion.io/x/cloudmux/pkg/multicloud/huawei/client/responses" - "yunion.io/x/onecloud/pkg/util/httputils" ) type IRequestHook interface { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/dbinstance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/dbinstance.go index cfa00f7459..386db6b9e8 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/dbinstance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/dbinstance.go @@ -23,12 +23,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/billing" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SBackupStrategy struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/elasticcache_instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/elasticcache_instance.go index b049e02bbf..0e5dce6660 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/elasticcache_instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/elasticcache_instance.go @@ -23,12 +23,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) // https://support.huaweicloud.com/api-dcs/dcs-zh-api-180423020.html diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/host.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/host.go index 6060787799..b651b4fe10 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/host.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/host.go @@ -21,12 +21,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/osprofile" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SHost struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/huawei.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/huawei.go index 4253b10997..45aec98b23 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/huawei.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/huawei.go @@ -30,10 +30,9 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/timeutils" - "yunion.io/x/onecloud/pkg/util/httputils" - api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud/huawei/client" diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/image.go index ce523eaac7..8ff01d297e 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/image.go @@ -23,12 +23,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/imagetools" "yunion.io/x/cloudmux/pkg/apis" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type TImageOwnerType string diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/instance.go index 5f0df21006..677291190c 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/instance.go @@ -26,6 +26,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/cloudinit" "yunion.io/x/pkg/util/osprofile" "yunion.io/x/pkg/utils" @@ -35,8 +37,6 @@ import ( "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/cloudmux/pkg/multicloud/huawei/client/modules" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/cloudinit" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/modelarts_pool.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/modelarts_pool.go index e5d4b3b316..d412fcebaa 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/modelarts_pool.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/modelarts_pool.go @@ -20,12 +20,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SModelartsPool struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/network.go index fe79636429..61943753b2 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/network.go @@ -18,12 +18,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/cloudmux/pkg/multicloud/huawei/client/modules" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) /* @@ -134,8 +134,8 @@ func (self *SNetwork) GetIsPublic() bool { return true } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SNetwork) Delete() error { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/saml_provider.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/saml_provider.go index f42468533b..e94d73d1c5 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/saml_provider.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/saml_provider.go @@ -21,13 +21,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" "yunion.io/x/pkg/util/stringutils" api "yunion.io/x/cloudmux/pkg/apis/cloudid" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" "yunion.io/x/cloudmux/pkg/multicloud/huawei/client/modules" - "yunion.io/x/onecloud/pkg/util/samlutils" ) type SAMLProviderLinks struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/storagecache.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/storagecache.go index bfa67efb4e..199dbde9c2 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/storagecache.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/storagecache.go @@ -24,11 +24,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/qemuimg" ) type SStoragecache struct { @@ -139,7 +139,7 @@ func (self *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider } defer self.region.DeleteIBucket(bucketName) - reader, sizeByte, err := image.GetReader(image.ImageId, string(qemuimg.VMDK)) + reader, sizeByte, err := image.GetReader(image.ImageId, string(qemuimgfmt.VMDK)) if err != nil { return "", errors.Wrapf(err, "GetReader") } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/utils.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/utils.go index fe14e19afd..0475d3242e 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/utils.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/huawei/utils.go @@ -22,12 +22,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/utils" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud/huawei/client/manager" "yunion.io/x/cloudmux/pkg/multicloud/huawei/client/responses" - "yunion.io/x/onecloud/pkg/util/httputils" ) // 常用的方法 diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/image_base.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/image_base.go index 046781d765..5305904ac8 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/image_base.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/image_base.go @@ -15,16 +15,17 @@ package multicloud import ( + "yunion.io/x/pkg/util/rbacscope" + "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SImageBase struct { SVirtualResourceBase } -func (self *SImageBase) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (self *SImageBase) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (self *SImageBase) GetSubImages() []cloudprovider.SSubImage { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/image.go index dd075ca832..3c8e86cee4 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/image.go @@ -18,10 +18,11 @@ import ( "context" "fmt" + "yunion.io/x/pkg/util/imagetools" + api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type SImage struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/instance.go index 04b12cc8b0..e83f28e858 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/instance.go @@ -22,11 +22,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/imagetools" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type Cdrom struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/network.go index f56e3e7573..6545dd78b3 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/network.go @@ -21,11 +21,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SNetwork struct { @@ -159,8 +159,8 @@ func (self *SNetwork) GetProjectId() string { return "" } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SNetwork) GetServerType() string { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/sphere.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/sphere.go index a07e2227d1..bac6f0bf77 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/sphere.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/incloudsphere/sphere.go @@ -24,10 +24,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/jdcloud/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/jdcloud/image.go index 7fa9ff1dfe..720912c890 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/jdcloud/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/jdcloud/image.go @@ -26,11 +26,11 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/imagetools" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type SImage struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/jdcloud/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/jdcloud/instance.go index f866a6304b..1158b739d3 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/jdcloud/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/jdcloud/instance.go @@ -26,13 +26,13 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/sets" napis "yunion.io/x/cloudmux/pkg/apis" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SInstance struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/jdcloud/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/jdcloud/network.go index 4be97fd83c..c8e5346c24 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/jdcloud/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/jdcloud/network.go @@ -23,11 +23,11 @@ import ( "github.com/jdcloud-api/jdcloud-sdk-go/services/vpc/models" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SNetwork struct { @@ -100,8 +100,8 @@ func (n *SNetwork) GetIsPublic() bool { return true } -func (n *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (n *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (n *SNetwork) Delete() error { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/loader/loader.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/loader/loader.go index da4f28343b..9bb36d766f 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/loader/loader.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/loader/loader.go @@ -22,7 +22,7 @@ import ( _ "yunion.io/x/cloudmux/pkg/multicloud/aws/provider" _ "yunion.io/x/cloudmux/pkg/multicloud/azure/provider" _ "yunion.io/x/cloudmux/pkg/multicloud/bingocloud/provider" // private clouds - _ "yunion.io/x/cloudmux/pkg/multicloud/cloudpods/provider" // private clouds + // _ "yunion.io/x/cloudmux/pkg/multicloud/cloudpods/provider" // private clouds _ "yunion.io/x/cloudmux/pkg/multicloud/ctyun/provider" _ "yunion.io/x/cloudmux/pkg/multicloud/ecloud/provider" // public clouds _ "yunion.io/x/cloudmux/pkg/multicloud/esxi/provider" // private clouds diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/image.go index e63420686f..6b70787ca1 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/image.go @@ -25,11 +25,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/imagetools" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type SImage struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/network.go index 2ecdc52656..cf43252671 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/network.go @@ -21,11 +21,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SNetwork struct { @@ -133,8 +133,8 @@ func (self *SNetwork) GetProjectId() string { return "" } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SNetwork) GetServerType() string { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/nutanix.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/nutanix.go index c6a99a0a59..3657be6640 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/nutanix.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/nutanix.go @@ -25,10 +25,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/storagecache.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/storagecache.go index 2ad8058408..6746365d00 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/storagecache.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/nutanix/storagecache.go @@ -19,10 +19,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/qemuimg" ) type SStoragecache struct { @@ -91,7 +91,7 @@ func (self *SStoragecache) DownloadImage(imageId string, extId string, path stri } func (self *SStoragecache) UploadImage(ctx context.Context, opts *cloudprovider.SImageCreateOption, callback func(float32)) (string, error) { - reader, size, err := opts.GetReader(opts.ImageId, string(qemuimg.QCOW2)) + reader, size, err := opts.GetReader(opts.ImageId, string(qemuimgfmt.QCOW2)) if err != nil { return "", errors.Wrapf(err, "GetReader") } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/ceph/adminapi.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/ceph/adminapi.go index e343c44f3c..ff06a9fe94 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/ceph/adminapi.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/ceph/adminapi.go @@ -21,14 +21,14 @@ import ( "net/http" "strings" - "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/s3auth" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/s3auth" + "yunion.io/x/cloudmux/pkg/cloudprovider" ) type SCephAdminApi struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/ceph/ceph.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/ceph/ceph.go index 9f86da433f..3cc9f096a0 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/ceph/ceph.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/ceph/ceph.go @@ -20,12 +20,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/s3cli" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud/objectstore" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SCephRadosClient struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/objectstore.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/objectstore.go index 1abc05ca04..08f54c15f7 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/objectstore.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/objectstore.go @@ -22,14 +22,14 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/object" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/secrules" "yunion.io/x/s3cli" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/cloudcommon/object" - "yunion.io/x/onecloud/pkg/util/httputils" ) type ObjectStoreClientConfig struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/shell.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/shell.go index df6e11111d..ece4c482b6 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/shell.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/shell.go @@ -26,12 +26,12 @@ import ( "time" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/fileutils" + "yunion.io/x/pkg/util/printutils" + "yunion.io/x/pkg/util/shellutils" + "yunion.io/x/pkg/util/streamutils" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/fileutils2" - "yunion.io/x/onecloud/pkg/util/printutils" - "yunion.io/x/onecloud/pkg/util/shellutils" - "yunion.io/x/onecloud/pkg/util/streamutils" ) type ObjectHeaderOptions struct { @@ -313,12 +313,12 @@ func S3Shell() { return nil } - if fileutils2.IsFile(args.Path) { + if fileutils.IsFile(args.Path) { err := uploadFile(args.KEY, args.Path) if err != nil { return errors.Wrap(err, "uploadFile") } - } else if fileutils2.IsDir(args.Path) { + } else if fileutils.IsDir(args.Path) { return filepath.Walk(args.Path, func(path string, info os.FileInfo, err error) error { if err != nil { return err diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/xsky/adminapi.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/xsky/adminapi.go index f7c0aeeffc..5c95a3f797 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/xsky/adminapi.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/xsky/adminapi.go @@ -26,8 +26,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" - - "yunion.io/x/onecloud/pkg/util/httputils" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/cloudmux/pkg/cloudprovider" ) diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/xsky/xsky.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/xsky/xsky.go index 23dbf9f9b9..a4d8fb8946 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/xsky/xsky.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/objectstore/xsky/xsky.go @@ -21,12 +21,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/s3cli" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud/objectstore" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SXskyClient struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/disk.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/disk.go index 3a8d424b6d..6e0129e6dc 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/disk.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/disk.go @@ -24,12 +24,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/version" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/version" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/image.go index 1af3cb80b3..c2e9561c0b 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/image.go @@ -25,13 +25,13 @@ import ( "github.com/pkg/errors" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/imagetools" + "yunion.io/x/pkg/util/qemuimgfmt" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" - "yunion.io/x/onecloud/pkg/util/qemuimg" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) const ( @@ -194,12 +194,12 @@ func (image *SImage) GetImageType() cloudprovider.TImageType { return cloudprovider.ImageTypeSystem } -func (image *SImage) GetPublicScope() rbacutils.TRbacScope { +func (image *SImage) GetPublicScope() rbacscope.TRbacScope { switch image.Visibility { case "private": - return rbacutils.ScopeNone + return rbacscope.ScopeNone default: - return rbacutils.ScopeSystem + return rbacscope.ScopeSystem } } @@ -308,7 +308,7 @@ func (region *SRegion) GetImageByName(name string) (*SImage, error) { func (region *SRegion) CreateImage(imageName string, osType string, osDist string, minDiskGb int, minRam int, size int64, body io.Reader, callback func(progress float32)) (*SImage, error) { params := map[string]interface{}{ "container_format": "bare", - "disk_format": string(qemuimg.QCOW2), + "disk_format": string(qemuimgfmt.QCOW2), "name": imageName, "min_disk": minDiskGb, "min_ram": minRam, diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/instance.go index 4c88090608..abc2ec4ae3 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/instance.go @@ -25,12 +25,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/keypaire.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/keypaire.go index e6669e6a4a..dbe5f45378 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/keypaire.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/keypaire.go @@ -19,9 +19,9 @@ import ( "net/url" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rand" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/rand" ) type SKeypair struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/network.go index de215a3aeb..2cbd04c5f8 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/network.go @@ -25,11 +25,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type AllocationPool struct { @@ -228,11 +228,11 @@ func (network *SNetwork) GetIsPublic() bool { return network.wire.vpc.Shared } -func (network *SNetwork) GetPublicScope() rbacutils.TRbacScope { +func (network *SNetwork) GetPublicScope() rbacscope.TRbacScope { if network.wire.vpc.Shared { - return rbacutils.ScopeSystem + return rbacscope.ScopeSystem } - return rbacutils.ScopeNone + return rbacscope.ScopeNone } func (network *SNetwork) GetServerType() string { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/openstack.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/openstack.go index 99ebeadd47..65523e8c28 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/openstack.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/openstack.go @@ -25,11 +25,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/version" "yunion.io/x/pkg/utils" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/version" - api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" @@ -204,13 +203,16 @@ type sApiVersions struct { func (v *sApiVersions) GetMaxVersion() string { if v.Version.Status == "CURRENT" && len(v.Version.Id) > 0 { - return v.Version.Id + return strings.TrimPrefix(v.Version.Id, "v") } maxVersion := v.Version.Version for _, _version := range v.Versions { if version.GT(_version.Version, maxVersion) { maxVersion = _version.Version } + if v.Version.Status == "CURRENT" && len(v.Version.Id) > 0 { + return strings.TrimPrefix(v.Version.Id, "v") + } } return maxVersion } @@ -426,7 +428,7 @@ func (cli *SOpenStackClient) getDefaultSession(regionName string) *oscli.ClientS } func (cli *SOpenStackClient) getDefaultClient() *oscli.Client { - client := oscli.NewClient(cli.authURL, 5, cli.debug, false, "", "") + client := oscli.NewClient(cli.authURL, 5, cli.debug, false) client.SetHttpTransportProxyFunc(cli.cpcfg.ProxyFunc) _client := client.GetClient() ts, _ := _client.Transport.(*http.Transport) diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/const.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/const.go new file mode 100644 index 0000000000..00b66ded05 --- /dev/null +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/const.go @@ -0,0 +1,19 @@ +package oscli + +const ( + DEFAULT_DOMAIN_ID = "default" + DEFAULT_DOMAIN_NAME = "Default" + + AUTH_METHOD_PASSWORD = "password" + AUTH_METHOD_TOKEN = "token" + + AUTH_TOKEN_HEADER = "X-Auth-Token" + AUTH_SUBJECT_TOKEN_HEADER = "X-Subject-Token" +) + +type SIdentityObject struct { + // UUID + Id string `json:"id"` + // 名称 + Name string `json:"name"` +} diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/oscli.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/oscli.go index fb89e22a5a..1e2f91ecc8 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/oscli.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/oscli.go @@ -26,10 +26,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/gotypes" - - api "yunion.io/x/onecloud/pkg/apis/identity" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/seclib2" + "yunion.io/x/pkg/util/httputils" ) type Client struct { @@ -41,16 +38,17 @@ type Client struct { _serviceCatalog IServiceCatalog } -func NewClient(authUrl string, timeout int, debug bool, insecure bool, certFile, keyFile string) *Client { +func NewClient(authUrl string, timeout int, debug bool, insecure bool) *Client { var tlsConf *tls.Config - if len(certFile) > 0 && len(keyFile) > 0 { + // do not support customized cert key file QIUJIAN + /*if len(certFile) > 0 && len(keyFile) > 0 { var err error tlsConf, err = seclib2.InitTLSConfig(certFile, keyFile) if err != nil { log.Errorf("load TLS failed %s", err) } - } + }*/ if tlsConf == nil || gotypes.IsNil(tlsConf) { tlsConf = &tls.Config{} @@ -150,17 +148,17 @@ func (this *Client) jsonRequest(ctx context.Context, endpoint string, token stri func (this *Client) _authV3(domainName, uname, passwd, projectId, projectName, projectDomain, token string) (TokenCredential, error) { input := SAuthenticationInputV3{} if len(uname) > 0 && len(passwd) > 0 { // Password authentication - input.Auth.Identity.Methods = []string{api.AUTH_METHOD_PASSWORD} + input.Auth.Identity.Methods = []string{AUTH_METHOD_PASSWORD} input.Auth.Identity.Password.User.Name = uname input.Auth.Identity.Password.User.Password = passwd if len(domainName) > 0 { input.Auth.Identity.Password.User.Domain.Name = domainName } // else { - // input.Auth.Identity.Password.User.Domain.Name = api.DEFAULT_DOMAIN_ID + // input.Auth.Identity.Password.User.Domain.Name = DEFAULT_DOMAIN_ID //} } else if len(token) > 0 { - input.Auth.Identity.Methods = []string{api.AUTH_METHOD_TOKEN} + input.Auth.Identity.Methods = []string{AUTH_METHOD_TOKEN} input.Auth.Identity.Token.Id = token } if len(projectId) > 0 { @@ -172,7 +170,7 @@ func (this *Client) _authV3(domainName, uname, passwd, projectId, projectName, p input.Auth.Scope.Project.Domain.Name = projectDomain } // else { - // input.Auth.Scope.Project.Domain.Id = api.DEFAULT_DOMAIN_ID + // input.Auth.Scope.Project.Domain.Id = DEFAULT_DOMAIN_ID // } } return this._authV3Input(input) @@ -256,8 +254,8 @@ func (this *Client) unmarshalV2Token(rbody jsonutils.JSONObject) (cred TokenCred func (this *Client) verifyV3(adminToken, token string) (TokenCredential, error) { header := http.Header{} - header.Add(api.AUTH_TOKEN_HEADER, adminToken) - header.Add(api.AUTH_SUBJECT_TOKEN_HEADER, token) + header.Add(AUTH_TOKEN_HEADER, adminToken) + header.Add(AUTH_SUBJECT_TOKEN_HEADER, token) _, rbody, err := this.jsonRequest(context.Background(), this.authUrl, "", "GET", "/auth/tokens", header, nil) if err != nil { return nil, err @@ -267,7 +265,7 @@ func (this *Client) verifyV3(adminToken, token string) (TokenCredential, error) func (this *Client) verifyV2(adminToken, token string) (TokenCredential, error) { header := http.Header{} - header.Add(api.AUTH_TOKEN_HEADER, adminToken) + header.Add(AUTH_TOKEN_HEADER, adminToken) verifyUrl := fmt.Sprintf("/tokens/%s", token) _, rbody, err := this.jsonRequest(context.Background(), this.authUrl, "", "GET", verifyUrl, header, nil) if err != nil { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/session.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/session.go index 743495b3be..ec170682ed 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/session.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/session.go @@ -24,13 +24,11 @@ import ( "strings" "golang.org/x/text/language" + "yunion.io/x/jsonutils" - "yunion.io/x/log" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" - - api "yunion.io/x/onecloud/pkg/apis/identity" - "yunion.io/x/onecloud/pkg/util/httputils" + "yunion.io/x/pkg/util/httputils" ) const ( @@ -143,19 +141,6 @@ func (this *ClientSession) getServiceVersionURLs(service, region, zone, endpoint return []string{this.client.authUrl}, nil } urls, err := catalog.GetServiceURLs(service, region, zone, endpointType) - // HACK! in case of fail to get kestone url or schema of keystone changed, always trust authUrl - if service == api.SERVICE_TYPE && (err != nil || len(urls) == 0 || (len(this.client.authUrl) != 0 && this.client.authUrl[:5] != urls[0][:5])) { - var msg string - if err != nil { - msg = fmt.Sprintf("fail to retrieve keystone urls: %s", err) - } else if len(urls) == 0 { - msg = fmt.Sprintf("empty keystone url") - } else { - msg = fmt.Sprintf("Schema of keystone authUrl and endpoint mismatch: %s!=%s", this.client.authUrl, urls) - } - log.Warningln(msg) - return []string{this.client.authUrl}, nil - } if err != nil { return nil, errors.Wrap(err, "catalog.GetServiceURLs") } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/token.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/token.go index e4a535cde5..b25cee6432 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/token.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/token.go @@ -19,8 +19,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/gotypes" - - "yunion.io/x/onecloud/pkg/util/rbacutils" + "yunion.io/x/pkg/util/rbacscope" ) type ExternalService struct { @@ -39,13 +38,13 @@ type Endpoint struct { Interface string } -func OwnerIdString(owner IIdentityProvider, scope rbacutils.TRbacScope) string { +func OwnerIdString(owner IIdentityProvider, scope rbacscope.TRbacScope) string { switch scope { - case rbacutils.ScopeDomain: + case rbacscope.ScopeDomain: return owner.GetProjectDomainId() - case rbacutils.ScopeProject: + case rbacscope.ScopeProject: return owner.GetProjectId() - case rbacutils.ScopeUser: + case rbacscope.ScopeUser: return owner.GetUserId() default: return "" @@ -83,8 +82,6 @@ type TokenCredential interface { // IsAdmin() bool HasSystemAdminPrivilege() bool - IsAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult - GetRegions() []string GetServiceCatalog() IServiceCatalog diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/token2.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/token2.go index 2d588c490f..f99e6654df 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/token2.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/token2.go @@ -21,9 +21,7 @@ import ( "time" "yunion.io/x/jsonutils" - - api "yunion.io/x/onecloud/pkg/apis/identity" - "yunion.io/x/onecloud/pkg/util/rbacutils" + "yunion.io/x/pkg/util/rbacscope" ) type KeystoneEndpointV2 struct { @@ -121,11 +119,11 @@ func (token *TokenCredentialV2) GetTokenString() string { } func (token *TokenCredentialV2) GetDomainId() string { - return api.DEFAULT_DOMAIN_ID + return DEFAULT_DOMAIN_ID } func (token *TokenCredentialV2) GetDomainName() string { - return api.DEFAULT_DOMAIN_NAME + return DEFAULT_DOMAIN_NAME } func (token *TokenCredentialV2) GetTenantId() string { @@ -145,11 +143,11 @@ func (token *TokenCredentialV2) GetProjectName() string { } func (token *TokenCredentialV2) GetProjectDomainId() string { - return api.DEFAULT_DOMAIN_ID + return DEFAULT_DOMAIN_ID } func (token *TokenCredentialV2) GetProjectDomain() string { - return api.DEFAULT_DOMAIN_NAME + return DEFAULT_DOMAIN_NAME } func (token *TokenCredentialV2) GetUserName() string { @@ -205,16 +203,8 @@ func (this *TokenCredentialV2) HasSystemAdminPrivilege() bool { return this.IsAdmin() && this.GetTenantName() == "system" } -func (this *TokenCredentialV2) IsAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { - if this.isAllow(scope, service, resource, action, extra...) { - return rbacutils.PolicyAllow - } else { - return rbacutils.PolicyDeny - } -} - -func (this *TokenCredentialV2) isAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) bool { - if scope == rbacutils.ScopeSystem || scope == rbacutils.ScopeDomain { +func (this *TokenCredentialV2) isAllow(scope rbacscope.TRbacScope, service string, resource string, action string, extra ...string) bool { + if scope == rbacscope.ScopeSystem || scope == rbacscope.ScopeDomain { return this.HasSystemAdminPrivilege() } else { return true diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/token3.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/token3.go index 4db09f9740..7a9357bcdb 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/token3.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/token3.go @@ -22,10 +22,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/rbacscope" "yunion.io/x/pkg/utils" - - api "yunion.io/x/onecloud/pkg/apis/identity" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) const REGION_ZONE_SEP = '-' @@ -65,9 +63,9 @@ type KeystoneServiceV3 struct { Endpoints []KeystoneEndpointV3 `json:"endpoints,omitempty"` } -type KeystoneDomainV3 api.SIdentityObject +type KeystoneDomainV3 SIdentityObject -type KeystoneRoleV3 api.SIdentityObject +type KeystoneRoleV3 SIdentityObject type KeystoneProjectV3 struct { // 项目ID @@ -224,16 +222,8 @@ func (this *TokenCredentialV3) HasSystemAdminPrivilege() bool { return this.IsAdmin() && this.GetTenantName() == "system" } -func (this *TokenCredentialV3) IsAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { - if this.isAllow(scope, service, resource, action, extra...) { - return rbacutils.PolicyAllow - } else { - return rbacutils.PolicyDeny - } -} - -func (this *TokenCredentialV3) isAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) bool { - if scope == rbacutils.ScopeSystem || scope == rbacutils.ScopeDomain { +func (this *TokenCredentialV3) isAllow(scope rbacscope.TRbacScope, service string, resource string, action string, extra ...string) bool { + if scope == rbacscope.ScopeSystem || scope == rbacscope.ScopeDomain { return this.HasSystemAdminPrivilege() } else { return true diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/tokensimple.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/tokensimple.go index 7419bdde04..1e166759ac 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/tokensimple.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/oscli/tokensimple.go @@ -22,9 +22,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/gotypes" - - api "yunion.io/x/onecloud/pkg/apis/identity" - "yunion.io/x/onecloud/pkg/util/rbacutils" + "yunion.io/x/pkg/util/rbacscope" ) type SSimpleToken struct { @@ -74,14 +72,14 @@ func (self *SSimpleToken) GetProjectName() string { func (self *SSimpleToken) GetProjectDomainId() string { if len(self.ProjectDomainId) == 0 { - return api.DEFAULT_DOMAIN_ID + return DEFAULT_DOMAIN_ID } return self.ProjectDomainId } func (self *SSimpleToken) GetProjectDomain() string { if len(self.ProjectDomain) == 0 { - return api.DEFAULT_DOMAIN_NAME + return DEFAULT_DOMAIN_NAME } return self.ProjectDomain } @@ -128,16 +126,8 @@ func (self *SSimpleToken) HasSystemAdminPrivilege() bool { return self.IsAdmin() && self.Project == "system" } -func (this *SSimpleToken) IsAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) rbacutils.SPolicyResult { - if this.isAllow(scope, service, resource, action, extra...) { - return rbacutils.PolicyAllow - } else { - return rbacutils.PolicyDeny - } -} - -func (this *SSimpleToken) isAllow(scope rbacutils.TRbacScope, service string, resource string, action string, extra ...string) bool { - if scope == rbacutils.ScopeSystem || scope == rbacutils.ScopeDomain { +func (this *SSimpleToken) isAllow(scope rbacscope.TRbacScope, service string, resource string, action string, extra ...string) bool { + if scope == rbacscope.ScopeSystem || scope == rbacscope.ScopeDomain { return this.HasSystemAdminPrivilege() } else { return true diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/project.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/project.go index c50ff3f81b..033f5d6242 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/project.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/project.go @@ -20,8 +20,7 @@ import ( "yunion.io/x/log" "yunion.io/x/pkg/errors" - - "yunion.io/x/onecloud/pkg/util/httputils" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/multicloud" diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/region.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/region.go index 8631316b08..27fb76cae1 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/region.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/region.go @@ -22,11 +22,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SRegion struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/roles.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/roles.go index fc84f65bee..5877e007aa 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/roles.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/roles.go @@ -19,9 +19,9 @@ import ( "net/url" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SRole struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/securitygroup.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/securitygroup.go index 292114c025..6f5e8b5dee 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/securitygroup.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/securitygroup.go @@ -22,12 +22,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/secrules" "yunion.io/x/pkg/utils" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/storagecache.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/storagecache.go index b684099452..57f60bbe9b 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/storagecache.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/openstack/storagecache.go @@ -21,11 +21,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/qemuimg" ) type SStoragecache struct { @@ -93,7 +93,7 @@ func (cache *SStoragecache) UploadImage(ctx context.Context, image *cloudprovide } func (cache *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider.SImageCreateOption, callback func(progress float32)) (string, error) { - reader, size, err := image.GetReader(image.ImageId, string(qemuimg.QCOW2)) + reader, size, err := image.GetReader(image.ImageId, string(qemuimgfmt.QCOW2)) if err != nil { return "", errors.Wrapf(err, "GetReader") } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/proxmox/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/proxmox/image.go index 74cd68c40b..c7f95f97ad 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/proxmox/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/proxmox/image.go @@ -23,11 +23,11 @@ import ( "strings" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/imagetools" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type SImage struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/proxmox/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/proxmox/network.go index 5640be6e51..aaa20b7231 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/proxmox/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/proxmox/network.go @@ -22,11 +22,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SNetwork struct { @@ -127,8 +127,8 @@ func (self *SNetwork) GetProjectId() string { return "" } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SNetwork) GetServerType() string { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/proxmox/proxmox.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/proxmox/proxmox.go index 07c6514d4b..553523513e 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/proxmox/proxmox.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/proxmox/proxmox.go @@ -25,10 +25,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/elasticcache_instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/elasticcache_instance.go index cc0e067ef5..fe56bc8318 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/elasticcache_instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/elasticcache_instance.go @@ -24,12 +24,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/billing" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SElasticcache struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/host.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/host.go index 221dfe8cb3..0a410dbd81 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/host.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/host.go @@ -21,11 +21,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SHost struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/image.go index 7a68da9205..6bcf567106 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/image.go @@ -23,13 +23,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/imagetools" "yunion.io/x/pkg/utils" "yunion.io/x/cloudmux/pkg/apis" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type ImageStatusType string diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/instance.go index 5c5ec7897e..db2b328f58 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/instance.go @@ -26,14 +26,14 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/imagetools" "yunion.io/x/pkg/utils" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/imagetools" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/loadbalancer.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/loadbalancer.go index 7027641ae4..00cfc98b39 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/loadbalancer.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/loadbalancer.go @@ -22,6 +22,7 @@ import ( "time" sdkerrors "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors" + "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/memcached.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/memcached.go index d9f486bdea..985ea00845 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/memcached.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/memcached.go @@ -21,12 +21,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SMemcached struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/network.go index 66f43fa05c..f97f9144a6 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/network.go @@ -22,11 +22,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SNetwork struct { @@ -148,8 +148,8 @@ func (self *SNetwork) GetIsPublic() bool { return true } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SNetwork) GetServerType() string { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/qcloud.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/qcloud.go index da943bd0b3..77d57284fb 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/qcloud.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/qcloud.go @@ -35,12 +35,12 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/pkg/utils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/rds_mysql.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/rds_mysql.go index bdae0a6e4d..5aa80651d8 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/rds_mysql.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/rds_mysql.go @@ -25,6 +25,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/pkg/utils" @@ -32,7 +33,6 @@ import ( api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SlaveInstanceInfo struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/saml_provider.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/saml_provider.go index 481795b6b2..c53034af2e 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/saml_provider.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/saml_provider.go @@ -21,11 +21,11 @@ import ( "unicode" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/samlutils" api "yunion.io/x/cloudmux/pkg/apis/cloudid" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/samlutils" ) type SAMLProvider struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/storagecache.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/storagecache.go index 4016727181..ca872d19ae 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/storagecache.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/qcloud/storagecache.go @@ -23,11 +23,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/qemuimg" ) type SStoragecache struct { @@ -132,7 +132,7 @@ func (self *SRegion) getCosUrl(bucket, object string) string { } func (self *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider.SImageCreateOption, callback func(progress float32)) (string, error) { - reader, sizeBytes, err := image.GetReader(image.ImageId, string(qemuimg.QCOW2)) + reader, sizeBytes, err := image.GetReader(image.ImageId, string(qemuimgfmt.QCOW2)) if err != nil { return "", errors.Wrapf(err, "GetReader") } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/doc.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/doc.go index f5b36586be..8ae8d8f7b8 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/doc.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/doc.go @@ -1 +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 remotefile // import "yunion.io/x/cloudmux/pkg/multicloud/remotefile" diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/eip.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/eip.go index 21a30188a3..6a45d8aa2f 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/eip.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/eip.go @@ -15,9 +15,10 @@ package remotefile import ( + "yunion.io/x/pkg/utils" + api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/pkg/utils" ) type SEip struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/instance.go index ca8a62a67f..9cf69d576e 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/instance.go @@ -17,9 +17,10 @@ package remotefile import ( "context" + "yunion.io/x/pkg/util/imagetools" + api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type SInstance struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/network.go index 2806c49355..61164c5aea 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/network.go @@ -15,9 +15,10 @@ package remotefile import ( + "yunion.io/x/pkg/util/rbacscope" + api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SNetwork struct { @@ -55,8 +56,8 @@ func (self *SNetwork) GetServerType() string { return api.NETWORK_TYPE_GUEST } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SNetwork) Delete() error { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/remotefile.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/remotefile.go index c5bd786a46..c730f5b39d 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/remotefile.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/remotefile/remotefile.go @@ -21,10 +21,10 @@ import ( "sync" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/client.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/client.go index b9be47c58d..0c2aaf1a58 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/client.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/client.go @@ -24,9 +24,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) const UCLOUD_API_HOST = "https://api.ucloud.cn" diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/host.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/host.go index 7ffb1c0c94..93813df92d 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/host.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/host.go @@ -22,11 +22,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" ) type SHost struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/image.go index e53010751b..c42ba4025f 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/image.go @@ -20,11 +20,11 @@ import ( "time" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/util/imagetools" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type SImage struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/instance.go index 0e11609323..63b68652ca 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/instance.go @@ -24,14 +24,14 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/imagetools" "yunion.io/x/pkg/utils" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/imagetools" ) type SInstance struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/network.go index 76f0a5b973..5871c160cb 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/network.go @@ -20,11 +20,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) // https://docs.ucloud.cn/api/vpc2.0-api/describe_subnet @@ -124,8 +124,8 @@ func (self *SNetwork) GetIsPublic() bool { return true } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeDomain +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeDomain } func (self *SNetwork) Delete() error { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/storagecache.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/storagecache.go index 107ef9bdaf..2ba14af145 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/storagecache.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/storagecache.go @@ -24,11 +24,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/qemuimgfmt" "yunion.io/x/pkg/utils" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/qemuimg" ) type SStoragecache struct { @@ -130,7 +130,7 @@ func (self *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider } }() - reader, size, err := image.GetReader(image.ImageId, string(qemuimg.VMDK)) + reader, size, err := image.GetReader(image.ImageId, string(qemuimgfmt.VMDK)) if err != nil { return "", errors.Wrapf(err, "GetReader") } @@ -143,7 +143,7 @@ func (self *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider minDiskGB = 1024 } md5 := image.Checksum - diskFormat := string(qemuimg.QCOW2) + diskFormat := string(qemuimgfmt.QCOW2) // upload to ucloud bucket, err := self.region.GetIBucketById(bucketName) if err != nil { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/ufile.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/ufile.go index 9dead430d4..f103863d07 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/ufile.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/ufile.go @@ -29,10 +29,10 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/httputils" ) type SBucket struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/image.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/image.go index 1f385d3421..a45b5923fb 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/image.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/image.go @@ -26,13 +26,13 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" + "yunion.io/x/pkg/util/imagetools" + "yunion.io/x/pkg/util/multipart" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/httputils" - "yunion.io/x/onecloud/pkg/util/imagetools" - "yunion.io/x/onecloud/pkg/util/multipart" ) type SBackupStorageRef struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/instance.go index 38e6d1b2cb..82deb23ca3 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/instance.go @@ -24,14 +24,14 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/billing" + "yunion.io/x/pkg/util/imagetools" + "yunion.io/x/pkg/util/version" "yunion.io/x/pkg/utils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/billing" - "yunion.io/x/onecloud/pkg/util/imagetools" - "yunion.io/x/onecloud/pkg/util/version" ) type SInstanceCdrome struct { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/network.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/network.go index f6cb71292a..c29e1140d5 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/network.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/network.go @@ -20,11 +20,11 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/util/netutils" + "yunion.io/x/pkg/util/rbacscope" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/rbacutils" ) type SNetwork struct { @@ -201,8 +201,8 @@ func (network *SNetwork) GetIsPublic() bool { return true } -func (self *SNetwork) GetPublicScope() rbacutils.TRbacScope { - return rbacutils.ScopeSystem +func (self *SNetwork) GetPublicScope() rbacscope.TRbacScope { + return rbacscope.ScopeSystem } func (network *SNetwork) GetServerType() string { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/storagecache.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/storagecache.go index 4953ba79c6..3c281e3eb8 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/storagecache.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/storagecache.go @@ -20,13 +20,14 @@ import ( "time" "github.com/pkg/errors" + "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/qemuimgfmt" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" "yunion.io/x/cloudmux/pkg/multicloud" - "yunion.io/x/onecloud/pkg/util/qemuimg" ) type SStoragecache struct { @@ -101,13 +102,13 @@ func (scache *SStoragecache) UploadImage(ctx context.Context, image *cloudprovid } func (self *SStoragecache) uploadImage(ctx context.Context, image *cloudprovider.SImageCreateOption, callback func(progress float32)) (string, error) { - reader, size, err := image.GetReader(image.ImageId, string(qemuimg.QCOW2)) + reader, size, err := image.GetReader(image.ImageId, string(qemuimgfmt.QCOW2)) if err != nil { return "", errors.Wrapf(err, "GetReader") } // size, _ := meta.Int("size") - img, err := self.region.CreateImage(self.ZoneId, image.ImageName, string(qemuimg.QCOW2), image.OsType, "", reader, size, callback) + img, err := self.region.CreateImage(self.ZoneId, image.ImageName, string(qemuimgfmt.QCOW2), image.OsType, "", reader, size, callback) if err != nil { return "", err } diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/zstack.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/zstack.go index 05d0436303..05d71faef8 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/zstack.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/zstack/zstack.go @@ -27,14 +27,13 @@ import ( "strings" "time" - "github.com/pkg/errors" - "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/httputils" api "yunion.io/x/cloudmux/pkg/apis/compute" "yunion.io/x/cloudmux/pkg/cloudprovider" - "yunion.io/x/onecloud/pkg/util/httputils" ) const ( diff --git a/pkg/appctx/appctx.go b/vendor/yunion.io/x/pkg/appctx/appctx.go similarity index 100% rename from pkg/appctx/appctx.go rename to vendor/yunion.io/x/pkg/appctx/appctx.go diff --git a/pkg/appctx/context.go b/vendor/yunion.io/x/pkg/appctx/context.go similarity index 100% rename from pkg/appctx/context.go rename to vendor/yunion.io/x/pkg/appctx/context.go diff --git a/pkg/appctx/doc.go b/vendor/yunion.io/x/pkg/appctx/doc.go similarity index 90% rename from pkg/appctx/doc.go rename to vendor/yunion.io/x/pkg/appctx/doc.go index 57b6bd2086..4ff7bc8618 100644 --- a/pkg/appctx/doc.go +++ b/vendor/yunion.io/x/pkg/appctx/doc.go @@ -12,4 +12,4 @@ // See the License for the specific language governing permissions and // limitations under the License. -package appctx // import "yunion.io/x/onecloud/pkg/appctx" +package appctx // import "yunion.io/x/pkg/appctx" diff --git a/pkg/appctx/i18n.go b/vendor/yunion.io/x/pkg/appctx/i18n.go similarity index 100% rename from pkg/appctx/i18n.go rename to vendor/yunion.io/x/pkg/appctx/i18n.go diff --git a/vendor/yunion.io/x/pkg/errors/consts.go b/vendor/yunion.io/x/pkg/errors/consts.go index 9ce2305204..89c0bec7cb 100644 --- a/vendor/yunion.io/x/pkg/errors/consts.go +++ b/vendor/yunion.io/x/pkg/errors/consts.go @@ -21,4 +21,8 @@ const ( ErrAccountReadOnly = Error("AccountReadOnlyError") ErrAggregate = Error("AggregateError") + + ErrInvalidFormat = Error("InvalidFormatError") + + ErrUnsupportedProtocol = Error("UnsupportedProtocol") ) diff --git a/pkg/util/rand/doc.go b/vendor/yunion.io/x/pkg/object/doc.go similarity index 90% rename from pkg/util/rand/doc.go rename to vendor/yunion.io/x/pkg/object/doc.go index 83b590273d..cf8d7cbf98 100644 --- a/pkg/util/rand/doc.go +++ b/vendor/yunion.io/x/pkg/object/doc.go @@ -12,4 +12,4 @@ // See the License for the specific language governing permissions and // limitations under the License. -package rand // import "yunion.io/x/onecloud/pkg/util/rand" +package object // import "yunion.io/x/pkg/object" diff --git a/pkg/cloudcommon/object/object.go b/vendor/yunion.io/x/pkg/object/object.go similarity index 100% rename from pkg/cloudcommon/object/object.go rename to vendor/yunion.io/x/pkg/object/object.go diff --git a/pkg/util/billing/billingcycle.go b/vendor/yunion.io/x/pkg/util/billing/billingcycle.go similarity index 100% rename from pkg/util/billing/billingcycle.go rename to vendor/yunion.io/x/pkg/util/billing/billingcycle.go diff --git a/pkg/util/encode/doc.go b/vendor/yunion.io/x/pkg/util/billing/doc.go similarity index 90% rename from pkg/util/encode/doc.go rename to vendor/yunion.io/x/pkg/util/billing/doc.go index 5b2cd19656..2f4ac98cff 100644 --- a/pkg/util/encode/doc.go +++ b/vendor/yunion.io/x/pkg/util/billing/doc.go @@ -12,4 +12,4 @@ // See the License for the specific language governing permissions and // limitations under the License. -package encode // import "yunion.io/x/onecloud/pkg/util/encode" +package billing // import "yunion.io/x/pkg/util/billing" diff --git a/pkg/util/cloudinit/cloudconfig.go b/vendor/yunion.io/x/pkg/util/cloudinit/cloudconfig.go similarity index 99% rename from pkg/util/cloudinit/cloudconfig.go rename to vendor/yunion.io/x/pkg/util/cloudinit/cloudconfig.go index 8a7e7c6e76..f4639fb688 100644 --- a/pkg/util/cloudinit/cloudconfig.go +++ b/vendor/yunion.io/x/pkg/util/cloudinit/cloudconfig.go @@ -22,9 +22,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/log" + "yunion.io/x/pkg/util/seclib" "yunion.io/x/pkg/utils" - - "yunion.io/x/onecloud/pkg/util/seclib2" ) /* @@ -163,7 +162,7 @@ func (u *SUser) SshKey(key string) *SUser { func (u *SUser) Password(passwd string) *SUser { if len(passwd) > 0 { - hash, err := seclib2.GeneratePassword(passwd) + hash, err := seclib.GeneratePassword(passwd) if err != nil { log.Errorf("GeneratePassword error %s", err) } else { diff --git a/pkg/util/s3auth/doc.go b/vendor/yunion.io/x/pkg/util/cloudinit/doc.go similarity index 90% rename from pkg/util/s3auth/doc.go rename to vendor/yunion.io/x/pkg/util/cloudinit/doc.go index c9766fc2d3..357cc2e6f9 100644 --- a/pkg/util/s3auth/doc.go +++ b/vendor/yunion.io/x/pkg/util/cloudinit/doc.go @@ -12,4 +12,4 @@ // See the License for the specific language governing permissions and // limitations under the License. -package s3auth // import "yunion.io/x/onecloud/pkg/util/s3auth" +package cloudinit // import "yunion.io/x/pkg/util/cloudinit" diff --git a/vendor/yunion.io/x/pkg/util/encode/doc.go b/vendor/yunion.io/x/pkg/util/encode/doc.go new file mode 100644 index 0000000000..61ec80ad9a --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/encode/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 encode // import "yunion.io/x/pkg/util/encode" diff --git a/pkg/util/encode/encode.go b/vendor/yunion.io/x/pkg/util/encode/encode.go similarity index 100% rename from pkg/util/encode/encode.go rename to vendor/yunion.io/x/pkg/util/encode/encode.go diff --git a/vendor/yunion.io/x/pkg/util/fileutils/fileutils.go b/vendor/yunion.io/x/pkg/util/fileutils/fileutils.go new file mode 100644 index 0000000000..35ea4c57fe --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/fileutils/fileutils.go @@ -0,0 +1,35 @@ +// 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 fileutils + +import "os" + +func IsFile(filepath string) bool { + fi, err := os.Lstat(filepath) + if err != nil { + return false + } + mode := fi.Mode() + return mode.IsRegular() +} + +func IsDir(filepath string) bool { + fi, err := os.Lstat(filepath) + if err != nil { + return false + } + mode := fi.Mode() + return mode.IsDir() +} diff --git a/pkg/util/fileutils2/seeker.go b/vendor/yunion.io/x/pkg/util/fileutils/seeker.go similarity index 99% rename from pkg/util/fileutils2/seeker.go rename to vendor/yunion.io/x/pkg/util/fileutils/seeker.go index 1b086b6aca..9763ab75f4 100644 --- a/pkg/util/fileutils2/seeker.go +++ b/vendor/yunion.io/x/pkg/util/fileutils/seeker.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package fileutils2 +package fileutils import ( "io" diff --git a/pkg/util/fileutils2/sparse.go b/vendor/yunion.io/x/pkg/util/fileutils/sparse.go similarity index 98% rename from pkg/util/fileutils2/sparse.go rename to vendor/yunion.io/x/pkg/util/fileutils/sparse.go index 8290541bdd..fb43c21992 100644 --- a/pkg/util/fileutils2/sparse.go +++ b/vendor/yunion.io/x/pkg/util/fileutils/sparse.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package fileutils2 +package fileutils import ( "os" diff --git a/pkg/util/httputils/delegate.go b/vendor/yunion.io/x/pkg/util/httputils/delegate.go similarity index 100% rename from pkg/util/httputils/delegate.go rename to vendor/yunion.io/x/pkg/util/httputils/delegate.go diff --git a/vendor/yunion.io/x/pkg/util/httputils/doc.go b/vendor/yunion.io/x/pkg/util/httputils/doc.go new file mode 100644 index 0000000000..1a23854e15 --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/httputils/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 httputils // import "yunion.io/x/pkg/util/httputils" diff --git a/pkg/util/httputils/error.go b/vendor/yunion.io/x/pkg/util/httputils/error.go similarity index 100% rename from pkg/util/httputils/error.go rename to vendor/yunion.io/x/pkg/util/httputils/error.go diff --git a/pkg/util/httputils/fs.go b/vendor/yunion.io/x/pkg/util/httputils/fs.go similarity index 100% rename from pkg/util/httputils/fs.go rename to vendor/yunion.io/x/pkg/util/httputils/fs.go diff --git a/pkg/util/httputils/httputils.go b/vendor/yunion.io/x/pkg/util/httputils/httputils.go similarity index 99% rename from pkg/util/httputils/httputils.go rename to vendor/yunion.io/x/pkg/util/httputils/httputils.go index 5cdb9ded80..592fc291c2 100644 --- a/pkg/util/httputils/httputils.go +++ b/vendor/yunion.io/x/pkg/util/httputils/httputils.go @@ -37,12 +37,11 @@ import ( "moul.io/http2curl/v2" "yunion.io/x/jsonutils" + "yunion.io/x/pkg/appctx" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/gotypes" "yunion.io/x/pkg/trace" "yunion.io/x/pkg/utils" - - "yunion.io/x/onecloud/pkg/appctx" ) type THttpMethod string diff --git a/vendor/yunion.io/x/pkg/util/imagetools/doc.go b/vendor/yunion.io/x/pkg/util/imagetools/doc.go new file mode 100644 index 0000000000..2ceed5da9d --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/imagetools/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 imagetools // import "yunion.io/x/pkg/util/imagetools" diff --git a/pkg/util/imagetools/imagetools.go b/vendor/yunion.io/x/pkg/util/imagetools/imagetools.go similarity index 93% rename from pkg/util/imagetools/imagetools.go rename to vendor/yunion.io/x/pkg/util/imagetools/imagetools.go index ffad6f9962..8d88786b03 100644 --- a/pkg/util/imagetools/imagetools.go +++ b/vendor/yunion.io/x/pkg/util/imagetools/imagetools.go @@ -20,19 +20,17 @@ import ( "strings" "yunion.io/x/pkg/util/osprofile" - - "yunion.io/x/onecloud/pkg/apis" ) func normalizeOsArch(osArch string, imageName string) string { if len(osArch) > 0 { switch strings.ToLower(osArch) { case "x86_64", "amd64", "64", "64bit", "64位": - return apis.OS_ARCH_X86_64 + return osprofile.OS_ARCH_X86_64 case "x86", "x86_32", "32", "32bit", "32位": - return apis.OS_ARCH_X86 + return osprofile.OS_ARCH_X86 case "arm", "arm64", "aarch", "aarch64": - return apis.OS_ARCH_AARCH64 + return osprofile.OS_ARCH_AARCH64 default: return osArch } @@ -46,17 +44,17 @@ func normalizeOsArch(osArch string, imageName string) string { if strings.Contains(strings.ToLower(imageName), arch) { switch arch { case "64bit", "64位", "amd64", "x86_64": - return apis.OS_ARCH_X86_64 + return osprofile.OS_ARCH_X86_64 case "32bit", "32位", "i386", "x86": - return apis.OS_ARCH_X86_32 + return osprofile.OS_ARCH_X86_32 case "armv8", "arm64", "aarch64": - return apis.OS_ARCH_AARCH64 + return osprofile.OS_ARCH_AARCH64 case "armv6", "armv7", "armv7s", "arm", "aarch32": - return apis.OS_ARCH_AARCH32 + return osprofile.OS_ARCH_AARCH32 } } } - return apis.OS_ARCH_X86_64 + return osprofile.OS_ARCH_X86_64 } } @@ -210,12 +208,12 @@ func normalizeOsLang2(imageName string, sep string) string { func normalizeOsBios(imageName string, osArch string) string { if osArch != "" { switch osArch { - case apis.OS_ARCH_ARM, apis.OS_ARCH_AARCH32, apis.OS_ARCH_AARCH64: - return "UEFI" + case osprofile.OS_ARCH_ARM, osprofile.OS_ARCH_AARCH32, osprofile.OS_ARCH_AARCH64: + return osprofile.OS_BOOT_UEFI } } for _, sep := range []string{" ", "-", "_"} { - lang := normalizeOsLang2(imageName, sep) + lang := normalizeOsBios2(imageName, sep) if len(lang) > 0 { return lang } @@ -228,10 +226,10 @@ func normalizeOsBios2(imageName string, sep string) string { for _, o := range parts { switch strings.ToLower(o) { case "uefi": - return "UEFI" + return osprofile.OS_BOOT_UEFI } } - return "BIOS" + return osprofile.OS_BOOT_BIOS } type ImageInfo struct { diff --git a/vendor/yunion.io/x/pkg/util/multipart/doc.go b/vendor/yunion.io/x/pkg/util/multipart/doc.go new file mode 100644 index 0000000000..4da1ec4348 --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/multipart/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 multipart // import "yunion.io/x/pkg/util/multipart" diff --git a/pkg/util/multipart/reader.go b/vendor/yunion.io/x/pkg/util/multipart/reader.go similarity index 100% rename from pkg/util/multipart/reader.go rename to vendor/yunion.io/x/pkg/util/multipart/reader.go diff --git a/vendor/yunion.io/x/pkg/util/netutils/netutils.go b/vendor/yunion.io/x/pkg/util/netutils/netutils.go index 99a5c0cdfa..bab82e5209 100644 --- a/vendor/yunion.io/x/pkg/util/netutils/netutils.go +++ b/vendor/yunion.io/x/pkg/util/netutils/netutils.go @@ -493,3 +493,45 @@ func MacUnpackHex(mac string) string { } return "" } + +func GetFreePort() (int, error) { + addr, err := net.ResolveTCPAddr("tcp", "localhost:0") + if err != nil { + return 0, err + } + l, err := net.ListenTCP("tcp", addr) + if err != nil { + return 0, err + } + defer l.Close() + return l.Addr().(*net.TCPAddr).Port, nil +} + +var MASKS = []string{"0", "128", "192", "224", "240", "248", "252", "254", "255"} + +func Netlen2Mask(netmasklen int) string { + var mask = "" + var segCnt = 0 + for netmasklen > 0 { + var m string + if netmasklen > 8 { + m = MASKS[8] + netmasklen -= 8 + } else { + m = MASKS[netmasklen] + netmasklen = 0 + } + if mask != "" { + mask += "." + } + mask += m + segCnt += 1 + } + for i := 0; i < (4 - segCnt); i++ { + if mask != "" { + mask += "." + } + mask += "0" + } + return mask +} diff --git a/vendor/yunion.io/x/pkg/util/osprofile/arch.go b/vendor/yunion.io/x/pkg/util/osprofile/arch.go new file mode 100644 index 0000000000..036ac74372 --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/osprofile/arch.go @@ -0,0 +1,51 @@ +// 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 osprofile + +import ( + "yunion.io/x/pkg/utils" +) + +const ( + OS_ARCH_X86 = "x86" + OS_ARCH_ARM = "arm" + + OS_ARCH_I386 = "i386" + OS_ARCH_X86_32 = "x86_32" + OS_ARCH_X86_64 = "x86_64" + OS_ARCH_AARCH32 = "aarch32" + OS_ARCH_AARCH64 = "aarch64" + + OS_BOOT_BIOS = "BIOS" + OS_BOOT_UEFI = "UEFI" +) + +var ( + ARCH_X86 = []string{ + OS_ARCH_X86, + OS_ARCH_I386, + OS_ARCH_X86_32, + OS_ARCH_X86_64, + } + ARCH_ARM = []string{ + OS_ARCH_ARM, + OS_ARCH_AARCH32, + OS_ARCH_AARCH64, + } +) + +func IsARM(osArch string) bool { + return utils.IsInStringArray(osArch, ARCH_ARM) +} diff --git a/vendor/yunion.io/x/pkg/util/pinyinutils/doc.go b/vendor/yunion.io/x/pkg/util/pinyinutils/doc.go new file mode 100644 index 0000000000..3310a4b766 --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/pinyinutils/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 pinyinutils // import "yunion.io/x/pkg/util/pinyinutils" diff --git a/pkg/util/pinyinutils/pinyin.go b/vendor/yunion.io/x/pkg/util/pinyinutils/pinyin.go similarity index 100% rename from pkg/util/pinyinutils/pinyin.go rename to vendor/yunion.io/x/pkg/util/pinyinutils/pinyin.go diff --git a/vendor/yunion.io/x/pkg/util/printutils/doc.go b/vendor/yunion.io/x/pkg/util/printutils/doc.go new file mode 100644 index 0000000000..a799fa44a8 --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/printutils/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 printutils // import "yunion.io/x/pkg/util/printutils" diff --git a/pkg/util/printutils/printgetter.go b/vendor/yunion.io/x/pkg/util/printutils/printgetter.go similarity index 96% rename from pkg/util/printutils/printgetter.go rename to vendor/yunion.io/x/pkg/util/printutils/printgetter.go index da19ff499b..42b0729a7a 100644 --- a/pkg/util/printutils/printgetter.go +++ b/vendor/yunion.io/x/pkg/util/printutils/printgetter.go @@ -22,8 +22,6 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/gotypes" "yunion.io/x/pkg/utils" - - "yunion.io/x/onecloud/pkg/mcclient/modulebase" ) func getter2json(obj interface{}) jsonutils.JSONObject { @@ -69,7 +67,7 @@ func PrintGetterList(data interface{}, columns []string) { for i := 0; i < dataValue.Len(); i += 1 { jsonList[i] = getter2json(dataValue.Index(i).Interface()) } - list := &modulebase.ListResult{ + list := &ListResult{ Data: jsonList, Total: dataValue.Len(), Limit: 0, diff --git a/pkg/util/printutils/printjson.go b/vendor/yunion.io/x/pkg/util/printutils/printjson.go similarity index 94% rename from pkg/util/printutils/printjson.go rename to vendor/yunion.io/x/pkg/util/printutils/printjson.go index e9da1dadb0..c373a7e238 100644 --- a/pkg/util/printutils/printjson.go +++ b/vendor/yunion.io/x/pkg/util/printutils/printjson.go @@ -24,11 +24,9 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/prettytable" "yunion.io/x/pkg/util/sets" - - "yunion.io/x/onecloud/pkg/mcclient/modulebase" ) -func PrintJSONList(list *modulebase.ListResult, columns []string) { +func PrintJSONList(list *ListResult, columns []string) { colsWithData := make([]string, 0) if columns == nil || len(columns) == 0 { colsWithDataMap := make(map[string]bool) @@ -199,7 +197,7 @@ func printJSONArray(array *jsonutils.JSONArray) { } } - list := &modulebase.ListResult{ + list := &ListResult{ Data: objs, Total: array.Length(), Limit: 0, @@ -258,7 +256,7 @@ func PrintJSONObjectRecursiveEx(obj jsonutils.JSONObject, cb PrintJSONObjectRecu printJSONObjectRecursive_(obj, cb) } -func PrintJSONBatchResults(results []modulebase.SubmitResult, columns []string) { +func PrintJSONBatchResults(results []SubmitResult, columns []string) { objs := make([]jsonutils.JSONObject, 0) errs := make([]jsonutils.JSONObject, 0) for _, r := range results { @@ -273,9 +271,9 @@ func PrintJSONBatchResults(results []modulebase.SubmitResult, columns []string) } } if len(objs) > 0 { - PrintJSONList(&modulebase.ListResult{Data: objs}, columns) + PrintJSONList(&ListResult{Data: objs}, columns) } if len(errs) > 0 { - PrintJSONList(&modulebase.ListResult{Data: errs}, []string{"status", "id", "error"}) + PrintJSONList(&ListResult{Data: errs}, []string{"status", "id", "error"}) } } diff --git a/pkg/util/printutils/printobj.go b/vendor/yunion.io/x/pkg/util/printutils/printobj.go similarity index 93% rename from pkg/util/printutils/printobj.go rename to vendor/yunion.io/x/pkg/util/printutils/printobj.go index 38320405ef..c6dd5e3d28 100644 --- a/pkg/util/printutils/printobj.go +++ b/vendor/yunion.io/x/pkg/util/printutils/printobj.go @@ -19,8 +19,6 @@ import ( "reflect" "yunion.io/x/jsonutils" - - "yunion.io/x/onecloud/pkg/mcclient/modulebase" ) func PrintInterfaceList(data interface{}, total, offset, limit int, columns []string) { @@ -36,7 +34,7 @@ func PrintInterfaceList(data interface{}, total, offset, limit int, columns []st if total == 0 { total = dataValue.Len() } - list := &modulebase.ListResult{ + list := &ListResult{ Data: jsonList, Total: total, Limit: limit, diff --git a/pkg/util/multipart/reader_test.go b/vendor/yunion.io/x/pkg/util/printutils/struct.go similarity index 65% rename from pkg/util/multipart/reader_test.go rename to vendor/yunion.io/x/pkg/util/printutils/struct.go index d3a8b67458..9c9ab0c71c 100644 --- a/pkg/util/multipart/reader_test.go +++ b/vendor/yunion.io/x/pkg/util/printutils/struct.go @@ -12,20 +12,25 @@ // See the License for the specific language governing permissions and // limitations under the License. -package multipart +package printutils import ( - "bytes" - "io" - "strings" - "testing" + "yunion.io/x/jsonutils" ) -func TestReader(t *testing.T) { - body := "this is the file body message!!!" - r := NewReader(strings.NewReader(body), "", "test.txt") - var buf bytes.Buffer - io.Copy(&buf, r) - t.Logf("%s", r.FormDataContentType()) - t.Logf("%s", buf.String()) +type ListResult struct { + Data []jsonutils.JSONObject `json:"data,allowempty"` + Total int + Limit int + Offset int + + NextMarker string + MarkerField string + MarkerOrder string +} + +type SubmitResult struct { + Status int + Id interface{} + Data jsonutils.JSONObject } diff --git a/pkg/util/printutils/termwidth_unix.go b/vendor/yunion.io/x/pkg/util/printutils/termwidth_unix.go similarity index 100% rename from pkg/util/printutils/termwidth_unix.go rename to vendor/yunion.io/x/pkg/util/printutils/termwidth_unix.go diff --git a/pkg/util/printutils/termwidth_windows.go b/vendor/yunion.io/x/pkg/util/printutils/termwidth_windows.go similarity index 97% rename from pkg/util/printutils/termwidth_windows.go rename to vendor/yunion.io/x/pkg/util/printutils/termwidth_windows.go index a2366c3432..4e41e9f985 100644 --- a/pkg/util/printutils/termwidth_windows.go +++ b/vendor/yunion.io/x/pkg/util/printutils/termwidth_windows.go @@ -1,6 +1,5 @@ // Copyright 2019 Yunion -// 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 diff --git a/vendor/yunion.io/x/pkg/util/qemuimgfmt/doc.go b/vendor/yunion.io/x/pkg/util/qemuimgfmt/doc.go new file mode 100644 index 0000000000..dacc0fc086 --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/qemuimgfmt/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 qemuimgfmt // import "yunion.io/x/pkg/util/qemuimgfmt" diff --git a/vendor/yunion.io/x/pkg/util/qemuimgfmt/fmt.go b/vendor/yunion.io/x/pkg/util/qemuimgfmt/fmt.go new file mode 100644 index 0000000000..6425ffbb19 --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/qemuimgfmt/fmt.go @@ -0,0 +1,68 @@ +// 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 qemuimgfmt + +import ( + "strings" +) + +type TImageFormat string + +const ( + QCOW2 = TImageFormat("qcow2") + VMDK = TImageFormat("vmdk") + VHD = TImageFormat("vhd") + ISO = TImageFormat("iso") + RAW = TImageFormat("raw") +) + +var supportedImageFormats = []TImageFormat{ + QCOW2, VMDK, VHD, ISO, RAW, +} + +func IsSupportedImageFormat(fmtStr string) bool { + for i := 0; i < len(supportedImageFormats); i += 1 { + if fmtStr == string(supportedImageFormats[i]) { + return true + } + } + return false +} + +func (fmt TImageFormat) String() string { + switch string(fmt) { + case "vhd": + return "vpc" + default: + return string(fmt) + } +} + +func String2ImageFormat(fmt string) TImageFormat { + switch strings.ToLower(fmt) { + case "vhd", "vpc": + return VHD + case "qcow2": + return QCOW2 + case "vmdk": + return VMDK + case "iso": + return ISO + case "raw": + return RAW + } + // log.Fatalf("unknown image format!!! %s", fmt) + return TImageFormat(fmt) +} diff --git a/vendor/yunion.io/x/pkg/util/rand/doc.go b/vendor/yunion.io/x/pkg/util/rand/doc.go new file mode 100644 index 0000000000..131fbfd99e --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/rand/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 rand // import "yunion.io/x/pkg/util/rand" diff --git a/pkg/util/rand/rand.go b/vendor/yunion.io/x/pkg/util/rand/rand.go similarity index 100% rename from pkg/util/rand/rand.go rename to vendor/yunion.io/x/pkg/util/rand/rand.go diff --git a/vendor/yunion.io/x/pkg/util/rbacscope/doc.go b/vendor/yunion.io/x/pkg/util/rbacscope/doc.go new file mode 100644 index 0000000000..d4a7321be9 --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/rbacscope/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 rbacscope // import "yunion.io/x/pkg/util/rbacscope" diff --git a/vendor/yunion.io/x/pkg/util/rbacscope/scope.go b/vendor/yunion.io/x/pkg/util/rbacscope/scope.go new file mode 100644 index 0000000000..7419baffa6 --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/rbacscope/scope.go @@ -0,0 +1,69 @@ +// 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 rbacscope + +import ( + "strings" +) + +type TRbacScope string + +const ( + ScopeSystem = TRbacScope("system") + ScopeDomain = TRbacScope("domain") + ScopeProject = TRbacScope("project") + // ScopeObject = "object" + ScopeUser = TRbacScope("user") + ScopeNone = TRbacScope("none") +) + +var ( + scopeScore = map[TRbacScope]int{ + ScopeNone: 0, + ScopeUser: 1, + ScopeProject: 2, + ScopeDomain: 3, + ScopeSystem: 4, + } +) + +func (s1 TRbacScope) HigherEqual(s2 TRbacScope) bool { + return scopeScore[s1] >= scopeScore[s2] +} + +func (s1 TRbacScope) HigherThan(s2 TRbacScope) bool { + return scopeScore[s1] > scopeScore[s2] +} + +func String2Scope(str string) TRbacScope { + return String2ScopeDefault(str, ScopeProject) +} + +func String2ScopeDefault(str string, defScope TRbacScope) TRbacScope { + switch strings.ToLower(str) { + case string(ScopeSystem): + return ScopeSystem + case string(ScopeDomain): + return ScopeDomain + case string(ScopeProject): + return ScopeProject + case string(ScopeUser): + return ScopeUser + case "true": + return ScopeSystem + default: + return defScope + } +} diff --git a/vendor/yunion.io/x/pkg/util/s3auth/doc.go b/vendor/yunion.io/x/pkg/util/s3auth/doc.go new file mode 100644 index 0000000000..e87beb8949 --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/s3auth/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 s3auth // import "yunion.io/x/pkg/util/s3auth" diff --git a/pkg/util/s3auth/interface.go b/vendor/yunion.io/x/pkg/util/s3auth/interface.go similarity index 100% rename from pkg/util/s3auth/interface.go rename to vendor/yunion.io/x/pkg/util/s3auth/interface.go diff --git a/pkg/util/s3auth/utils.go b/vendor/yunion.io/x/pkg/util/s3auth/utils.go similarity index 100% rename from pkg/util/s3auth/utils.go rename to vendor/yunion.io/x/pkg/util/s3auth/utils.go diff --git a/pkg/util/s3auth/v2.go b/vendor/yunion.io/x/pkg/util/s3auth/v2.go similarity index 100% rename from pkg/util/s3auth/v2.go rename to vendor/yunion.io/x/pkg/util/s3auth/v2.go diff --git a/pkg/util/s3auth/v4.go b/vendor/yunion.io/x/pkg/util/s3auth/v4.go similarity index 99% rename from pkg/util/s3auth/v4.go rename to vendor/yunion.io/x/pkg/util/s3auth/v4.go index 5b0bd8662e..2b39519639 100644 --- a/pkg/util/s3auth/v4.go +++ b/vendor/yunion.io/x/pkg/util/s3auth/v4.go @@ -27,9 +27,8 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" + "yunion.io/x/pkg/util/streamutils" "yunion.io/x/pkg/util/timeutils" - - "yunion.io/x/onecloud/pkg/util/streamutils" ) // Signature and API related constants. diff --git a/pkg/util/samlutils/consts.go b/vendor/yunion.io/x/pkg/util/samlutils/consts.go similarity index 100% rename from pkg/util/samlutils/consts.go rename to vendor/yunion.io/x/pkg/util/samlutils/consts.go diff --git a/vendor/yunion.io/x/pkg/util/samlutils/doc.go b/vendor/yunion.io/x/pkg/util/samlutils/doc.go new file mode 100644 index 0000000000..291c9204d3 --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/samlutils/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 samlutils // import "yunion.io/x/pkg/util/samlutils" diff --git a/pkg/util/samlutils/encrypt.go b/vendor/yunion.io/x/pkg/util/samlutils/encrypt.go similarity index 85% rename from pkg/util/samlutils/encrypt.go rename to vendor/yunion.io/x/pkg/util/samlutils/encrypt.go index acc3fb970f..7a6e1d7a53 100644 --- a/pkg/util/samlutils/encrypt.go +++ b/vendor/yunion.io/x/pkg/util/samlutils/encrypt.go @@ -28,8 +28,7 @@ import ( "yunion.io/x/pkg/errors" - "yunion.io/x/onecloud/pkg/httperrors" - "yunion.io/x/onecloud/pkg/util/seclib2" + "yunion.io/x/pkg/util/seclib" ) func (saml *SSAMLInstance) parseKeys() error { @@ -37,7 +36,7 @@ func (saml *SSAMLInstance) parseKeys() error { if err != nil { return errors.Wrapf(err, "ioutil.ReadFile %s", saml.privateKeyFile) } - saml.privateKey, err = seclib2.DecodePrivateKey(privData) + saml.privateKey, err = seclib.DecodePrivateKey(privData) if err != nil { return errors.Wrap(err, "decodePrivateKey") } @@ -57,7 +56,7 @@ func (saml *SSAMLInstance) parseKeys() error { } if first { first = false - saml.certString = seclib2.CleanCertificate(string(pem.EncodeToMemory(block))) + saml.certString = seclib.CleanCertificate(string(pem.EncodeToMemory(block))) } cert, err := x509.ParseCertificate(block.Bytes) if err != nil { @@ -83,7 +82,7 @@ func (key EncryptedKey) decryptKey(privateKey *rsa.PrivateKey) ([]byte, error) { case "http://www.w3.org/2000/09/xmldsig#sha1": shaAlg = sha1.New() default: - return nil, errors.Wrapf(httperrors.ErrUnsupportedProtocol, "unsupported digest algorithm %s", hashAlg) + return nil, errors.Wrapf(errors.ErrUnsupportedProtocol, "unsupported digest algorithm %s", hashAlg) } plaintext, err := rsa.DecryptOAEP(shaAlg, rand.Reader, privateKey, cipher, nil) if err != nil { @@ -91,7 +90,7 @@ func (key EncryptedKey) decryptKey(privateKey *rsa.PrivateKey) ([]byte, error) { } return plaintext, nil default: - return nil, errors.Wrapf(httperrors.ErrUnsupportedProtocol, "unsupported encryption algorithm %s", encAlg) + return nil, errors.Wrapf(errors.ErrUnsupportedProtocol, "unsupported encryption algorithm %s", encAlg) } } @@ -109,7 +108,7 @@ func (data EncryptedData) decryptData(privateKey *rsa.PrivateKey) ([]byte, error case "http://www.w3.org/2001/04/xmlenc#aes128-cbc", "http://www.w3.org/2001/04/xmlenc#aes192-cbc", "http://www.w3.org/2001/04/xmlenc#aes256-cbc": return decryptAesCbc(key, cipher) default: - return nil, errors.Wrapf(httperrors.ErrUnsupportedProtocol, "unsupported encryption algorithm %s", encAlg) + return nil, errors.Wrapf(errors.ErrUnsupportedProtocol, "unsupported encryption algorithm %s", encAlg) } } diff --git a/pkg/util/samlutils/instance.go b/vendor/yunion.io/x/pkg/util/samlutils/instance.go similarity index 100% rename from pkg/util/samlutils/instance.go rename to vendor/yunion.io/x/pkg/util/samlutils/instance.go diff --git a/pkg/util/samlutils/metadata.go b/vendor/yunion.io/x/pkg/util/samlutils/metadata.go similarity index 100% rename from pkg/util/samlutils/metadata.go rename to vendor/yunion.io/x/pkg/util/samlutils/metadata.go diff --git a/pkg/util/samlutils/request.go b/vendor/yunion.io/x/pkg/util/samlutils/request.go similarity index 100% rename from pkg/util/samlutils/request.go rename to vendor/yunion.io/x/pkg/util/samlutils/request.go diff --git a/pkg/util/samlutils/response.go b/vendor/yunion.io/x/pkg/util/samlutils/response.go similarity index 100% rename from pkg/util/samlutils/response.go rename to vendor/yunion.io/x/pkg/util/samlutils/response.go diff --git a/pkg/util/samlutils/types.go b/vendor/yunion.io/x/pkg/util/samlutils/types.go similarity index 100% rename from pkg/util/samlutils/types.go rename to vendor/yunion.io/x/pkg/util/samlutils/types.go diff --git a/pkg/util/samlutils/util.go b/vendor/yunion.io/x/pkg/util/samlutils/util.go similarity index 100% rename from pkg/util/samlutils/util.go rename to vendor/yunion.io/x/pkg/util/samlutils/util.go diff --git a/vendor/yunion.io/x/pkg/util/seclib/certs.go b/vendor/yunion.io/x/pkg/util/seclib/certs.go new file mode 100644 index 0000000000..49a2af9acd --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/seclib/certs.go @@ -0,0 +1,46 @@ +// 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 seclib + +import ( + "crypto/rsa" + "crypto/x509" + "encoding/pem" + "regexp" + "strings" + + "yunion.io/x/pkg/errors" +) + +func CleanCertificate(cert string) string { + re := regexp.MustCompile("---(.*)CERTIFICATE(.*)---") + cert = re.ReplaceAllString(cert, "") + cert = strings.Trim(cert, " \n") + // cert = strings.Replace(cert, "\n", "", -1) + return cert +} + +func DecodePrivateKey(keyString []byte) (*rsa.PrivateKey, error) { + block, _ := pem.Decode(keyString) + privKey, err := x509.ParsePKCS8PrivateKey(block.Bytes) + if err == nil { + return privKey.(*rsa.PrivateKey), nil + } + priv, err := x509.ParsePKCS1PrivateKey(block.Bytes) + if err == nil { + return priv, nil + } + return nil, errors.Wrap(errors.ErrInvalidFormat, "not a valid private key") +} diff --git a/vendor/yunion.io/x/pkg/util/seclib/seclib.go b/vendor/yunion.io/x/pkg/util/seclib/seclib.go index c2659526ad..37cf1afc4f 100644 --- a/vendor/yunion.io/x/pkg/util/seclib/seclib.go +++ b/vendor/yunion.io/x/pkg/util/seclib/seclib.go @@ -19,15 +19,25 @@ import ( "fmt" "math/rand" "strings" + + "github.com/tredoe/osutil/v2/userutil/crypt/sha512_crypt" + + "yunion.io/x/pkg/utils" ) const ( DIGITS = "23456789" LETTERS = "abcdefghjkmnpqrstuvwxyz" - PUNC = "" + UPPERS = "ABCDEFGHJKMNPRSTUVWXYZ" + PUNC = "@^-+=" + + ALL_DIGITS = "0123456789" + ALL_LETTERS = "abcdefghijklmnopqrstuvwxyz" + ALL_UPPERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + ALL_PUNC = "~`!@#$%^&*()-_=+[]{}|:';\",./<>?" ) -var CHARS = fmt.Sprintf("%s%s%s%s", DIGITS, LETTERS, strings.ToUpper(LETTERS), PUNC) +var CHARS = fmt.Sprintf("%s%s%s", DIGITS, LETTERS, UPPERS) func RandomPassword(width int) string { if width < 6 { @@ -56,3 +66,105 @@ func RandomPassword(width int) string { } return "" } + +func GeneratePassword(passwd string) (string, error) { + salt := RandomPassword(8) + sha512Crypt := sha512_crypt.New() + return sha512Crypt.Generate([]byte(passwd), []byte(fmt.Sprintf("$6$%s", salt))) +} + +var WEAK_PASSWORDS []string = []string{ + "Huawei@", "huawei@", "Admin@", "admin@", "Root@", "root@", "ABC@", "abc@", "ABCD@", "abcd@", "Huawei123@", "huawei123@", "Admin123@", "admin123@", "Root123@", "root123@", "Huawei#", "huawei#", "Admin#", "admin#", "Root#", "root#", "ABC#", "abc#", "ABCD#", "abcd#", "Huawei123#", "huawei123#", "Admin123#", "admin123#", "Root123#", "root123#,Huawei!", "huawei!", "Admin!", "admin!", "Root!", "root!", "ABC!", "abc!", "ABCD!", "abcd!", "Huawei123!", "huawei123!", "Admin123!", "admin123!", "Root123!", "root123!", "ABC123!", "abc123!", "Huawei@123", "huawei@123", "Admin@123", "admin@123", "Root@123", "root@123", "ABC@123", "abc@123", "123@Huawei", "123@Root", "123@abc", "Huawei123", "huawei123", "Admin123", "admin123", "Root123", "root123", "abc123", "Huawei_123", "huawei_123", "Admin_123", "admin_123", "Root_123", "root_123", "ABC_123", "abc_123", "123abc", "123abcd", "1234abc", "1234abcd", "abcd123", "abc1234", "abcd1234", "abcd@1234", "abcd1234!", "abcd_1234", "a123456", "123.com", "123@com", "123_com", "Huawei!@#", "huawei!@#", "Admin!@#", "admin!@#", "Root!@#", "root!@#", "Huawei!@", "huawei!@", "Admin!@", "admin!@", "Root!@", "root!@", "Huaweiroot", "HuaweiRoot", "huaweiroot", "huaweiRoot", "Huaweiadmin", "HuaweiAdmin", "huaweiadmin", "huaweiAdmin", "Adminroot", "AdminRoot", "adminRoot", "adminroot", "Rootadmin", "RootAdmin", "rootAdmin", "rootadmin", "Rootroot", "RootRoot", "rootroot", "Administrator", "Password", "Password123", "Password@123", "Password_123", "Password123!", "DDM@123", "ddM@123", "dDm@123", +} + +var CHARS2 = fmt.Sprintf("%s%s%s%s", DIGITS, LETTERS, UPPERS, PUNC) + +func RandomPassword2(width int) string { + for { + password := randomPassword2(width) + if !utils.IsInStringArray(password, WEAK_PASSWORDS) { + return password + } + } +} + +type PasswordStrength struct { + Digits int + Lowercases int + Uppercases int + Punctuats int + Invalid []byte +} + +func randomPassword2(width int) string { + if width < 6 { + width = 6 + } + for { + ps := PasswordStrength{} + var buf bytes.Buffer + for i := 0; i < width; i += 1 { + var ch byte + for { + index := rand.Intn(len(CHARS2)) + ch = CHARS2[index] + if i == 0 && ch == '/' { + continue + } + break + } + if strings.IndexByte(DIGITS, ch) >= 0 { + ps.Digits += 1 + } else if strings.IndexByte(LETTERS, ch) >= 0 { + ps.Lowercases += 1 + } else if strings.IndexByte(UPPERS, ch) >= 0 { + ps.Uppercases += 1 + } else if strings.IndexByte(PUNC, ch) >= 0 { + ps.Punctuats += 1 + } + buf.WriteByte(ch) + } + if ps.Digits > 1 && ps.Lowercases > 1 && ps.Uppercases > 1 && ps.Punctuats >= 1 && ps.Punctuats <= 2 { + return buf.String() + } + } +} + +func AnalyzePasswordStrenth(passwd string) PasswordStrength { + ps := PasswordStrength{Invalid: []byte{}} + + for i := 0; i < len(passwd); i += 1 { + if strings.IndexByte(ALL_DIGITS, passwd[i]) >= 0 { + ps.Digits += 1 + } else if strings.IndexByte(ALL_LETTERS, passwd[i]) >= 0 { + ps.Lowercases += 1 + } else if strings.IndexByte(ALL_UPPERS, passwd[i]) >= 0 { + ps.Uppercases += 1 + } else if strings.IndexByte(ALL_PUNC, passwd[i]) >= 0 { + ps.Punctuats += 1 + } else { + ps.Invalid = append(ps.Invalid, passwd[i]) + } + } + return ps +} + +func (ps PasswordStrength) Len() int { + return ps.Punctuats + ps.Uppercases + ps.Lowercases + ps.Digits +} + +func (ps PasswordStrength) MeetComplexity() bool { + if ps.Punctuats > 0 && ps.Digits > 0 && ps.Lowercases > 0 && ps.Uppercases > 0 && ps.Len() >= 12 { + return true + } else { + return false + } +} + +func MeetComplxity(passwd string) bool { + if utils.IsInStringArray(passwd, WEAK_PASSWORDS) { + return false + } + ps := AnalyzePasswordStrenth(passwd) + return ps.MeetComplexity() +} diff --git a/vendor/yunion.io/x/pkg/util/shellutils/doc.go b/vendor/yunion.io/x/pkg/util/shellutils/doc.go new file mode 100644 index 0000000000..5a8a6d9386 --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/shellutils/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 shellutils // import "yunion.io/x/pkg/util/shellutils" diff --git a/pkg/util/shellutils/edit.go b/vendor/yunion.io/x/pkg/util/shellutils/edit.go similarity index 100% rename from pkg/util/shellutils/edit.go rename to vendor/yunion.io/x/pkg/util/shellutils/edit.go diff --git a/pkg/util/shellutils/shell.go b/vendor/yunion.io/x/pkg/util/shellutils/shell.go similarity index 100% rename from pkg/util/shellutils/shell.go rename to vendor/yunion.io/x/pkg/util/shellutils/shell.go diff --git a/vendor/yunion.io/x/pkg/util/streamutils/doc.go b/vendor/yunion.io/x/pkg/util/streamutils/doc.go new file mode 100644 index 0000000000..8eaec5856c --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/streamutils/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 streamutils // import "yunion.io/x/pkg/util/streamutils" diff --git a/pkg/util/streamutils/streamutils.go b/vendor/yunion.io/x/pkg/util/streamutils/streamutils.go similarity index 100% rename from pkg/util/streamutils/streamutils.go rename to vendor/yunion.io/x/pkg/util/streamutils/streamutils.go diff --git a/pkg/util/version/version.go b/vendor/yunion.io/x/pkg/util/version/compare.go similarity index 100% rename from pkg/util/version/version.go rename to vendor/yunion.io/x/pkg/util/version/compare.go diff --git a/vendor/yunion.io/x/pkg/util/vmdkutils/doc.go b/vendor/yunion.io/x/pkg/util/vmdkutils/doc.go new file mode 100644 index 0000000000..3d29dc7575 --- /dev/null +++ b/vendor/yunion.io/x/pkg/util/vmdkutils/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 vmdkutils // import "yunion.io/x/pkg/util/vmdkutils" diff --git a/pkg/util/vmdkutils/vmdkutils.go b/vendor/yunion.io/x/pkg/util/vmdkutils/vmdkutils.go similarity index 100% rename from pkg/util/vmdkutils/vmdkutils.go rename to vendor/yunion.io/x/pkg/util/vmdkutils/vmdkutils.go