├── .dockerignore ├── .gitignore ├── Dockerfile.dapper ├── LICENSE ├── Makefile ├── README.md ├── agent ├── agent.go ├── handle.go └── metadata.go ├── bridge └── server.go ├── cmd ├── agent.go └── server.go ├── docs ├── applications.md ├── secrets_bridge_arch.svg ├── setup.md └── vault.md ├── main.go ├── package ├── Dockerfile └── ca-certificates.crt ├── pkg └── archive │ └── tar.go ├── scripts ├── build ├── ci ├── entry ├── package ├── release ├── test ├── validate └── version ├── trash.yml ├── types └── types.go ├── vault ├── cubbyhole.go └── vault.go ├── vendor ├── github.com │ ├── Sirupsen │ │ └── logrus │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── CHANGELOG.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── doc.go │ │ │ ├── entry.go │ │ │ ├── exported.go │ │ │ ├── formatter.go │ │ │ ├── hooks.go │ │ │ ├── json_formatter.go │ │ │ ├── logger.go │ │ │ ├── logrus.go │ │ │ ├── terminal_bsd.go │ │ │ ├── terminal_linux.go │ │ │ ├── terminal_notwindows.go │ │ │ ├── terminal_solaris.go │ │ │ ├── terminal_windows.go │ │ │ ├── text_formatter.go │ │ │ └── writer.go │ ├── docker │ │ ├── distribution │ │ │ ├── .gitignore │ │ │ ├── .mailmap │ │ │ ├── AUTHORS │ │ │ ├── CONTRIBUTING.md │ │ │ ├── Dockerfile │ │ │ ├── LICENSE │ │ │ ├── MAINTAINERS │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── ROADMAP.md │ │ │ ├── circle.yml │ │ │ ├── coverpkg.sh │ │ │ ├── digest │ │ │ │ ├── digest.go │ │ │ │ ├── digester.go │ │ │ │ ├── doc.go │ │ │ │ ├── set.go │ │ │ │ └── verifiers.go │ │ │ └── reference │ │ │ │ ├── reference.go │ │ │ │ └── regexp.go │ │ ├── engine-api │ │ │ ├── .travis.yml │ │ │ ├── CHANGELOG.md │ │ │ ├── CONTRIBUTING.md │ │ │ ├── LICENSE │ │ │ ├── MAINTAINERS │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── appveyor.yml │ │ │ ├── client │ │ │ │ ├── client.go │ │ │ │ ├── client_darwin.go │ │ │ │ ├── client_unix.go │ │ │ │ ├── client_windows.go │ │ │ │ ├── container_attach.go │ │ │ │ ├── container_commit.go │ │ │ │ ├── container_copy.go │ │ │ │ ├── container_create.go │ │ │ │ ├── container_diff.go │ │ │ │ ├── container_exec.go │ │ │ │ ├── container_export.go │ │ │ │ ├── container_inspect.go │ │ │ │ ├── container_kill.go │ │ │ │ ├── container_list.go │ │ │ │ ├── container_logs.go │ │ │ │ ├── container_pause.go │ │ │ │ ├── container_remove.go │ │ │ │ ├── container_rename.go │ │ │ │ ├── container_resize.go │ │ │ │ ├── container_restart.go │ │ │ │ ├── container_start.go │ │ │ │ ├── container_stats.go │ │ │ │ ├── container_stop.go │ │ │ │ ├── container_top.go │ │ │ │ ├── container_unpause.go │ │ │ │ ├── container_update.go │ │ │ │ ├── container_wait.go │ │ │ │ ├── errors.go │ │ │ │ ├── events.go │ │ │ │ ├── hijack.go │ │ │ │ ├── image_build.go │ │ │ │ ├── image_create.go │ │ │ │ ├── image_history.go │ │ │ │ ├── image_import.go │ │ │ │ ├── image_inspect.go │ │ │ │ ├── image_list.go │ │ │ │ ├── image_load.go │ │ │ │ ├── image_pull.go │ │ │ │ ├── image_push.go │ │ │ │ ├── image_remove.go │ │ │ │ ├── image_save.go │ │ │ │ ├── image_search.go │ │ │ │ ├── image_tag.go │ │ │ │ ├── info.go │ │ │ │ ├── interface.go │ │ │ │ ├── login.go │ │ │ │ ├── network_connect.go │ │ │ │ ├── network_create.go │ │ │ │ ├── network_disconnect.go │ │ │ │ ├── network_inspect.go │ │ │ │ ├── network_list.go │ │ │ │ ├── network_remove.go │ │ │ │ ├── request.go │ │ │ │ ├── transport │ │ │ │ │ ├── cancellable │ │ │ │ │ │ ├── LICENSE │ │ │ │ │ │ ├── canceler.go │ │ │ │ │ │ ├── canceler_go14.go │ │ │ │ │ │ └── cancellable.go │ │ │ │ │ ├── client.go │ │ │ │ │ └── transport.go │ │ │ │ ├── version.go │ │ │ │ ├── volume_create.go │ │ │ │ ├── volume_inspect.go │ │ │ │ ├── volume_list.go │ │ │ │ └── volume_remove.go │ │ │ └── types │ │ │ │ ├── auth.go │ │ │ │ ├── blkiodev │ │ │ │ └── blkio.go │ │ │ │ ├── client.go │ │ │ │ ├── configs.go │ │ │ │ ├── container │ │ │ │ ├── config.go │ │ │ │ ├── host_config.go │ │ │ │ ├── hostconfig_unix.go │ │ │ │ └── hostconfig_windows.go │ │ │ │ ├── events │ │ │ │ └── events.go │ │ │ │ ├── filters │ │ │ │ └── parse.go │ │ │ │ ├── network │ │ │ │ └── network.go │ │ │ │ ├── reference │ │ │ │ └── image_reference.go │ │ │ │ ├── registry │ │ │ │ └── registry.go │ │ │ │ ├── seccomp.go │ │ │ │ ├── stats.go │ │ │ │ ├── strslice │ │ │ │ └── strslice.go │ │ │ │ ├── time │ │ │ │ └── timestamp.go │ │ │ │ ├── types.go │ │ │ │ └── versions │ │ │ │ ├── README.md │ │ │ │ └── compare.go │ │ ├── go-connections │ │ │ ├── CONTRIBUTING.md │ │ │ ├── LICENSE │ │ │ ├── MAINTAINERS │ │ │ ├── README.md │ │ │ ├── circle.yml │ │ │ ├── nat │ │ │ │ ├── nat.go │ │ │ │ ├── parse.go │ │ │ │ └── sort.go │ │ │ ├── sockets │ │ │ │ ├── README.md │ │ │ │ ├── inmem_socket.go │ │ │ │ ├── proxy.go │ │ │ │ ├── sockets.go │ │ │ │ ├── sockets_unix.go │ │ │ │ ├── sockets_windows.go │ │ │ │ ├── tcp_socket.go │ │ │ │ └── unix_socket.go │ │ │ └── tlsconfig │ │ │ │ ├── config.go │ │ │ │ ├── config_client_ciphers.go │ │ │ │ └── config_legacy_client_ciphers.go │ │ └── go-units │ │ │ ├── CONTRIBUTING.md │ │ │ ├── LICENSE.code │ │ │ ├── LICENSE.docs │ │ │ ├── MAINTAINERS │ │ │ ├── README.md │ │ │ ├── circle.yml │ │ │ ├── duration.go │ │ │ ├── size.go │ │ │ └── ulimit.go │ ├── fatih │ │ └── structs │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── field.go │ │ │ ├── structs.go │ │ │ └── tags.go │ ├── gorilla │ │ ├── context │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── context.go │ │ │ └── doc.go │ │ ├── mux │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── doc.go │ │ │ ├── mux.go │ │ │ ├── regexp.go │ │ │ └── route.go │ │ └── websocket │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── AUTHORS │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── client.go │ │ │ ├── conn.go │ │ │ ├── doc.go │ │ │ ├── json.go │ │ │ ├── server.go │ │ │ └── util.go │ ├── hashicorp │ │ ├── errwrap │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ └── errwrap.go │ │ ├── go-cleanhttp │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── cleanhttp.go │ │ │ └── doc.go │ │ ├── go-multierror │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── append.go │ │ │ ├── flatten.go │ │ │ ├── format.go │ │ │ ├── multierror.go │ │ │ └── prefix.go │ │ ├── go-rootcerts │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── doc.go │ │ │ ├── rootcerts.go │ │ │ ├── rootcerts_base.go │ │ │ └── rootcerts_darwin.go │ │ ├── hcl │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── appveyor.yml │ │ │ ├── decoder.go │ │ │ ├── hcl.go │ │ │ ├── hcl │ │ │ │ ├── ast │ │ │ │ │ ├── ast.go │ │ │ │ │ └── walk.go │ │ │ │ ├── parser │ │ │ │ │ ├── error.go │ │ │ │ │ └── parser.go │ │ │ │ ├── scanner │ │ │ │ │ └── scanner.go │ │ │ │ ├── strconv │ │ │ │ │ └── quote.go │ │ │ │ └── token │ │ │ │ │ ├── position.go │ │ │ │ │ └── token.go │ │ │ ├── json │ │ │ │ ├── parser │ │ │ │ │ ├── flatten.go │ │ │ │ │ └── parser.go │ │ │ │ ├── scanner │ │ │ │ │ └── scanner.go │ │ │ │ └── token │ │ │ │ │ ├── position.go │ │ │ │ │ └── token.go │ │ │ ├── lex.go │ │ │ └── parse.go │ │ └── vault │ │ │ ├── .gitattributes │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── CHANGELOG.md │ │ │ ├── CONTRIBUTING.md │ │ │ ├── LICENSE │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── api │ │ │ ├── SPEC.md │ │ │ ├── auth.go │ │ │ ├── auth_token.go │ │ │ ├── client.go │ │ │ ├── help.go │ │ │ ├── logical.go │ │ │ ├── request.go │ │ │ ├── response.go │ │ │ ├── secret.go │ │ │ ├── ssh.go │ │ │ ├── ssh_agent.go │ │ │ ├── sys.go │ │ │ ├── sys_audit.go │ │ │ ├── sys_auth.go │ │ │ ├── sys_capabilities.go │ │ │ ├── sys_generate_root.go │ │ │ ├── sys_init.go │ │ │ ├── sys_leader.go │ │ │ ├── sys_lease.go │ │ │ ├── sys_mounts.go │ │ │ ├── sys_policy.go │ │ │ ├── sys_rekey.go │ │ │ ├── sys_rotate.go │ │ │ ├── sys_seal.go │ │ │ └── sys_stepdown.go │ │ │ ├── helper │ │ │ └── jsonutil │ │ │ │ └── json.go │ │ │ └── make.bat │ ├── mitchellh │ │ └── mapstructure │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── decode_hooks.go │ │ │ ├── error.go │ │ │ └── mapstructure.go │ ├── opencontainers │ │ └── runc │ │ │ ├── .gitignore │ │ │ ├── CONTRIBUTING.md │ │ │ ├── Dockerfile │ │ │ ├── LICENSE │ │ │ ├── MAINTAINERS │ │ │ ├── MAINTAINERS_GUIDE.md │ │ │ ├── Makefile │ │ │ ├── NOTICE │ │ │ ├── PRINCIPLES.md │ │ │ ├── README.md │ │ │ └── libcontainer │ │ │ ├── README.md │ │ │ ├── SPEC.md │ │ │ └── user │ │ │ ├── MAINTAINERS │ │ │ ├── lookup.go │ │ │ ├── lookup_unix.go │ │ │ ├── lookup_unsupported.go │ │ │ └── user.go │ ├── rancher │ │ ├── go-rancher-metadata │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ └── metadata │ │ │ │ ├── change.go │ │ │ │ ├── metadata.go │ │ │ │ ├── types.go │ │ │ │ └── utils.go │ │ └── go-rancher │ │ │ ├── .drone.yml │ │ │ ├── .gitignore │ │ │ ├── .package │ │ │ ├── .wrap-docker-args │ │ │ ├── Dockerfile │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── client │ │ │ ├── client.go │ │ │ ├── common.go │ │ │ ├── generated_account.go │ │ │ ├── generated_active_setting.go │ │ │ ├── generated_add_label_input.go │ │ │ ├── generated_add_load_balancer_input.go │ │ │ ├── generated_add_outputs_input.go │ │ │ ├── generated_add_remove_cluster_host_input.go │ │ │ ├── generated_add_remove_load_balancer_host_input.go │ │ │ ├── generated_add_remove_load_balancer_listener_input.go │ │ │ ├── generated_add_remove_load_balancer_service_link_input.go │ │ │ ├── generated_add_remove_load_balancer_target_input.go │ │ │ ├── generated_add_remove_service_link_input.go │ │ │ ├── generated_agent.go │ │ │ ├── generated_amazonec2config.go │ │ │ ├── generated_api_key.go │ │ │ ├── generated_audit_log.go │ │ │ ├── generated_azure_config.go │ │ │ ├── generated_azureadconfig.go │ │ │ ├── generated_backup.go │ │ │ ├── generated_backup_target.go │ │ │ ├── generated_base_machine_config.go │ │ │ ├── generated_blkio_device_option.go │ │ │ ├── generated_certificate.go │ │ │ ├── generated_change_secret_input.go │ │ │ ├── generated_client.go │ │ │ ├── generated_cluster.go │ │ │ ├── generated_compose_config.go │ │ │ ├── generated_compose_config_input.go │ │ │ ├── generated_compose_project.go │ │ │ ├── generated_compose_service.go │ │ │ ├── generated_config_item.go │ │ │ ├── generated_config_item_status.go │ │ │ ├── generated_container.go │ │ │ ├── generated_container_event.go │ │ │ ├── generated_container_exec.go │ │ │ ├── generated_container_logs.go │ │ │ ├── generated_container_proxy.go │ │ │ ├── generated_credential.go │ │ │ ├── generated_databasechangelog.go │ │ │ ├── generated_databasechangeloglock.go │ │ │ ├── generated_digitalocean_config.go │ │ │ ├── generated_dns_service.go │ │ │ ├── generated_docker_build.go │ │ │ ├── generated_dynamic_schema.go │ │ │ ├── generated_environment.go │ │ │ ├── generated_environment_upgrade.go │ │ │ ├── generated_exoscale_config.go │ │ │ ├── generated_extension_implementation.go │ │ │ ├── generated_extension_point.go │ │ │ ├── generated_external_dns_event.go │ │ │ ├── generated_external_event.go │ │ │ ├── generated_external_handler.go │ │ │ ├── generated_external_handler_external_handler_process_map.go │ │ │ ├── generated_external_handler_process.go │ │ │ ├── generated_external_handler_process_config.go │ │ │ ├── generated_external_host_event.go │ │ │ ├── generated_external_service.go │ │ │ ├── generated_external_service_event.go │ │ │ ├── generated_external_storage_pool_event.go │ │ │ ├── generated_external_volume_event.go │ │ │ ├── generated_field_documentation.go │ │ │ ├── generated_githubconfig.go │ │ │ ├── generated_global_load_balancer.go │ │ │ ├── generated_global_load_balancer_health_check.go │ │ │ ├── generated_global_load_balancer_policy.go │ │ │ ├── generated_ha_config.go │ │ │ ├── generated_ha_config_input.go │ │ │ ├── generated_haproxy_config.go │ │ │ ├── generated_healthcheck_instance_host_map.go │ │ │ ├── generated_host.go │ │ │ ├── generated_host_access.go │ │ │ ├── generated_host_api_proxy_token.go │ │ │ ├── generated_identity.go │ │ │ ├── generated_image.go │ │ │ ├── generated_in_service_upgrade_strategy.go │ │ │ ├── generated_instance.go │ │ │ ├── generated_instance_console.go │ │ │ ├── generated_instance_console_input.go │ │ │ ├── generated_instance_health_check.go │ │ │ ├── generated_instance_link.go │ │ │ ├── generated_instance_stop.go │ │ │ ├── generated_ip_address.go │ │ │ ├── generated_ip_address_associate_input.go │ │ │ ├── generated_kubernetes_service.go │ │ │ ├── generated_label.go │ │ │ ├── generated_launch_config.go │ │ │ ├── generated_ldapconfig.go │ │ │ ├── generated_load_balancer.go │ │ │ ├── generated_load_balancer_app_cookie_stickiness_policy.go │ │ │ ├── generated_load_balancer_config.go │ │ │ ├── generated_load_balancer_config_listener_map.go │ │ │ ├── generated_load_balancer_cookie_stickiness_policy.go │ │ │ ├── generated_load_balancer_health_check.go │ │ │ ├── generated_load_balancer_host_map.go │ │ │ ├── generated_load_balancer_listener.go │ │ │ ├── generated_load_balancer_service.go │ │ │ ├── generated_load_balancer_service_link.go │ │ │ ├── generated_load_balancer_target.go │ │ │ ├── generated_local_auth_config.go │ │ │ ├── generated_log_config.go │ │ │ ├── generated_machine.go │ │ │ ├── generated_machine_driver.go │ │ │ ├── generated_machine_driver_error_input.go │ │ │ ├── generated_machine_driver_update_input.go │ │ │ ├── generated_mount.go │ │ │ ├── generated_network.go │ │ │ ├── generated_nfs_config.go │ │ │ ├── generated_openldapconfig.go │ │ │ ├── generated_openstack_config.go │ │ │ ├── generated_packet_config.go │ │ │ ├── generated_password.go │ │ │ ├── generated_physical_host.go │ │ │ ├── generated_port.go │ │ │ ├── generated_process_definition.go │ │ │ ├── generated_process_execution.go │ │ │ ├── generated_process_instance.go │ │ │ ├── generated_project.go │ │ │ ├── generated_project_member.go │ │ │ ├── generated_public_endpoint.go │ │ │ ├── generated_publish.go │ │ │ ├── generated_pull_task.go │ │ │ ├── generated_rackspace_config.go │ │ │ ├── generated_recreate_on_quorum_strategy_config.go │ │ │ ├── generated_register.go │ │ │ ├── generated_registration_token.go │ │ │ ├── generated_registry.go │ │ │ ├── generated_registry_credential.go │ │ │ ├── generated_remove_label_input.go │ │ │ ├── generated_remove_load_balancer_input.go │ │ │ ├── generated_resource_definition.go │ │ │ ├── generated_restart_policy.go │ │ │ ├── generated_restore_from_backup_input.go │ │ │ ├── generated_revert_to_snapshot_input.go │ │ │ ├── generated_rolling_restart_strategy.go │ │ │ ├── generated_scale_policy.go │ │ │ ├── generated_secondary_launch_config.go │ │ │ ├── generated_service.go │ │ │ ├── generated_service_consume_map.go │ │ │ ├── generated_service_event.go │ │ │ ├── generated_service_expose_map.go │ │ │ ├── generated_service_link.go │ │ │ ├── generated_service_proxy.go │ │ │ ├── generated_service_restart.go │ │ │ ├── generated_service_upgrade.go │ │ │ ├── generated_service_upgrade_strategy.go │ │ │ ├── generated_services_port_range.go │ │ │ ├── generated_set_labels_input.go │ │ │ ├── generated_set_load_balancer_hosts_input.go │ │ │ ├── generated_set_load_balancer_listeners_input.go │ │ │ ├── generated_set_load_balancer_service_links_input.go │ │ │ ├── generated_set_load_balancer_targets_input.go │ │ │ ├── generated_set_project_members_input.go │ │ │ ├── generated_set_service_links_input.go │ │ │ ├── generated_setting.go │ │ │ ├── generated_snapshot.go │ │ │ ├── generated_snapshot_backup_input.go │ │ │ ├── generated_softlayer_config.go │ │ │ ├── generated_state_transition.go │ │ │ ├── generated_stats_access.go │ │ │ ├── generated_storage_pool.go │ │ │ ├── generated_subscribe.go │ │ │ ├── generated_task.go │ │ │ ├── generated_task_instance.go │ │ │ ├── generated_to_service_upgrade_strategy.go │ │ │ ├── generated_type_documentation.go │ │ │ ├── generated_ubiquity_config.go │ │ │ ├── generated_user_preference.go │ │ │ ├── generated_virtual_machine.go │ │ │ ├── generated_virtual_machine_disk.go │ │ │ ├── generated_virtualbox_config.go │ │ │ ├── generated_vmwarevcloudair_config.go │ │ │ ├── generated_vmwarevsphere_config.go │ │ │ ├── generated_volume.go │ │ │ ├── generated_volume_snapshot_input.go │ │ │ ├── schemas.go │ │ │ └── types.go │ │ │ └── schemas.json │ ├── sethgrid │ │ └── pester │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ └── main.go │ └── urfave │ │ └── cli │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── app.go │ │ ├── appveyor.yml │ │ ├── category.go │ │ ├── cli.go │ │ ├── command.go │ │ ├── context.go │ │ ├── errors.go │ │ ├── flag.go │ │ ├── funcs.go │ │ ├── help.go │ │ └── runtests └── golang.org │ └── x │ └── net │ ├── .gitattributes │ ├── .gitignore │ ├── AUTHORS │ ├── CONTRIBUTING.md │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ ├── README │ ├── codereview.cfg │ ├── context │ ├── context.go │ ├── go17.go │ └── pre_go17.go │ └── proxy │ ├── direct.go │ ├── per_host.go │ ├── proxy.go │ └── socks5.go ├── verifier ├── client.go ├── k8sResponse.go ├── rancherResponse.go ├── types.go └── utils.go └── writer └── container_fs.go /.dockerignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancher/secrets-bridge/cbda250c0f17e2107c8a0eee348a4a405b139c6d/.dockerignore -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.dapper 2 | /bin 3 | *.swp 4 | /.trash-cache 5 | /src 6 | /pkg 7 | -------------------------------------------------------------------------------- /Dockerfile.dapper: -------------------------------------------------------------------------------- 1 | FROM golang:1.6 2 | RUN go get github.com/rancher/trash 3 | RUN go get github.com/golang/lint/golint 4 | RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/docker && \ 5 | chmod +x /usr/bin/docker 6 | ENV PATH /go/bin:$PATH 7 | ENV DAPPER_SOURCE /go/src/github.com/rancher/secrets-bridge 8 | ENV DAPPER_OUTPUT bin 9 | ENV DAPPER_DOCKER_SOCKET true 10 | ENV DAPPER_ENV TAG REPO 11 | ENV GO15VENDOREXPERIMENT 1 12 | ENV TRASH_CACHE ${DAPPER_SOURCE}/.trash-cache 13 | WORKDIR ${DAPPER_SOURCE} 14 | ENTRYPOINT ["./scripts/entry"] 15 | CMD ["ci"] 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancher/secrets-bridge/cbda250c0f17e2107c8a0eee348a4a405b139c6d/LICENSE -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TARGETS := $(shell ls scripts) 2 | 3 | .dapper: 4 | @echo Downloading dapper 5 | @curl -sL https://releases.rancher.com/dapper/latest/dapper-`uname -s`-`uname -m` > .dapper.tmp 6 | @@chmod +x .dapper.tmp 7 | @./.dapper.tmp -v 8 | @mv .dapper.tmp .dapper 9 | 10 | $(TARGETS): .dapper 11 | ./.dapper $@ 12 | 13 | trash: .dapper 14 | ./.dapper -m bind trash 15 | 16 | trash-keep: .dapper 17 | ./.dapper -m bind trash -k 18 | 19 | deps: trash 20 | 21 | .DEFAULT_GOAL := ci 22 | 23 | .PHONY: $(TARGETS) 24 | -------------------------------------------------------------------------------- /agent/agent.go: -------------------------------------------------------------------------------- 1 | package agent 2 | 3 | import ( 4 | "encoding/json" 5 | "os" 6 | "strings" 7 | 8 | "github.com/Sirupsen/logrus" 9 | "github.com/docker/engine-api/client" 10 | "github.com/docker/engine-api/types" 11 | "github.com/docker/engine-api/types/events" 12 | "github.com/docker/engine-api/types/filters" 13 | "github.com/urfave/cli" 14 | "golang.org/x/net/context" 15 | ) 16 | 17 | func StartAgent(c *cli.Context) { 18 | cli, err := getDockerClient() 19 | if err != nil { 20 | logrus.Fatalf("Could not get Docker client: %s", err) 21 | } 22 | 23 | filterArgs := filters.NewArgs() 24 | filterArgs.Add("event", "start") 25 | 26 | eventOptions := types.EventsOptions{ 27 | Filters: filterArgs, 28 | } 29 | 30 | eventsResp, err := cli.Events(context.Background(), eventOptions) 31 | if err != nil { 32 | logrus.Fatal(err) 33 | } 34 | defer eventsResp.Close() 35 | 36 | bridgeUrl := strings.TrimSuffix(c.String("bridge-url"), "/") 37 | logrus.Debugf("Sending events to: %s", bridgeUrl) 38 | 39 | handler, err := NewMessageHandler(map[string]interface{}{ 40 | "metadata-url": c.String("metadata-url"), 41 | "bridge-url": bridgeUrl + "/v1/message", 42 | }) 43 | if err != nil { 44 | logrus.Fatalf("Error: %s", err) 45 | } 46 | 47 | logrus.Info("Entering event listening Loop") 48 | d := json.NewDecoder(eventsResp) 49 | for { 50 | msg := &events.Message{} 51 | d.Decode(msg) 52 | 53 | // For now... will need to add some throttling at some point. 54 | go wrapHandler(handler.Handle, msg) 55 | } 56 | 57 | os.Exit(0) 58 | } 59 | 60 | func wrapHandler(handlerFunc func(*events.Message) error, msg *events.Message) { 61 | if err := handlerFunc(msg); err != nil { 62 | logrus.Debugf("Warning: %s", err) 63 | } 64 | } 65 | 66 | func getDockerClient() (*client.Client, error) { 67 | defaultHeaders := map[string]string{"User-Agent": "engine-api-cli-1.0"} 68 | return client.NewClient("unix:///var/run/docker.sock", "v1.22", nil, defaultHeaders) 69 | } 70 | -------------------------------------------------------------------------------- /agent/metadata.go: -------------------------------------------------------------------------------- 1 | package agent 2 | 3 | import ( 4 | "strings" 5 | "time" 6 | 7 | "github.com/Sirupsen/logrus" 8 | "github.com/docker/engine-api/types/events" 9 | "github.com/rancher/go-rancher-metadata/metadata" 10 | ) 11 | 12 | type ContainerEventMessage struct { 13 | Event *events.Message 14 | UUID string `json:"UUID"` 15 | Action string `json:"Action"` 16 | Host string `json:"Host"` 17 | ContainerType string `json:"container_type"` 18 | } 19 | 20 | func (cem *ContainerEventMessage) SetUUIDFromMetadata(mdCli *metadata.Client) error { 21 | nameKey := "name" 22 | verifyKey := "io.rancher.container.uuid" 23 | 24 | if cem.ContainerType == "kubernetes" { 25 | verifyKey = "io.kubernetes.pod.namespace" 26 | nameKey = "io.kubernetes.pod.name" 27 | } 28 | 29 | name := cem.Event.Actor.Attributes[nameKey] 30 | 31 | logrus.Debugf("Received: %s as a container name", name) 32 | 33 | if strings.HasPrefix(name, "r-") { 34 | name = strings.Replace(name, "r-", "", 1) 35 | nameSplit := strings.Split(name, "-") 36 | 37 | name = strings.Join(nameSplit[:len(nameSplit)-1], "-") 38 | } 39 | 40 | logrus.Debugf("Using: %s as a container name", name) 41 | 42 | container := metadata.Container{} 43 | for len(container.Labels) == 0 { 44 | containers, err := mdCli.GetContainers() 45 | if err != nil { 46 | return err 47 | } 48 | container = loopContainers(name, verifyKey, cem.Event.Actor.Attributes[verifyKey], containers) 49 | time.Sleep(100 * time.Millisecond) 50 | } 51 | 52 | logrus.Debugf("UUID: %s found", container.UUID) 53 | cem.UUID = container.UUID 54 | 55 | return nil 56 | } 57 | 58 | func loopContainers(name, vKey, expectedVKeyValue string, containers []metadata.Container) metadata.Container { 59 | for _, container := range containers { 60 | if container.Name == name { 61 | if value, ok := container.Labels[vKey]; ok { 62 | if value == expectedVKeyValue { 63 | return container 64 | } 65 | } 66 | } 67 | } 68 | 69 | return metadata.Container{} 70 | 71 | } 72 | -------------------------------------------------------------------------------- /cmd/agent.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "github.com/rancher/secrets-bridge/agent" 5 | "github.com/urfave/cli" 6 | ) 7 | 8 | func AgentCommand() cli.Command { 9 | return cli.Command{ 10 | Name: "agent", 11 | Usage: "Start listening agent on docker host", 12 | Action: agent.StartAgent, 13 | Flags: []cli.Flag{ 14 | cli.StringFlag{ 15 | Name: "metadata-url", 16 | Value: "http://rancher-metadata/2015-12-19", 17 | Usage: "Sets the metadata variable", 18 | }, 19 | cli.StringFlag{ 20 | Name: "bridge-url", 21 | Usage: "Secrets Bridge endpoint", 22 | }, 23 | }, 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cmd/server.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "github.com/rancher/secrets-bridge/bridge" 5 | "github.com/urfave/cli" 6 | ) 7 | 8 | func ServerCommand() cli.Command { 9 | return cli.Command{ 10 | Name: "server", 11 | Usage: "Provides a Secrets endpoint for verification and credential creation", 12 | Action: bridge.StartServer, 13 | Flags: []cli.Flag{ 14 | cli.StringFlag{ 15 | Name: "vault-url", 16 | Usage: "URL to Vault server. http://127.0.0.1:8200", 17 | }, 18 | cli.StringFlag{ 19 | Name: "vault-token", 20 | Usage: "CubbyHole Vault Token to use to communicate with Vault", 21 | EnvVar: "VAULT_TOKEN", 22 | }, 23 | cli.StringFlag{ 24 | Name: "vault-cacert", 25 | Usage: "CA Pem to use to communicate with Vault", 26 | EnvVar: "VAULT_CA_CERT", 27 | }, 28 | cli.StringFlag{ 29 | Name: "vault-cubbypath", 30 | Usage: "CubbyHole path to get Vault Token", 31 | EnvVar: "VAULT_CUBBYPATH", 32 | }, 33 | cli.StringFlag{ 34 | Name: "rancher-url", 35 | Usage: "Rancher API endpoint to verify", 36 | EnvVar: "CATTLE_URL", 37 | }, 38 | cli.StringFlag{ 39 | Name: "rancher-secret", 40 | Usage: "Rancher API secret key", 41 | EnvVar: "CATTLE_SECRET_KEY", 42 | }, 43 | cli.StringFlag{ 44 | Name: "rancher-access", 45 | Usage: "Rancher API access key", 46 | EnvVar: "CATTLE_ACCESS_KEY", 47 | }, 48 | }, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /docs/vault.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancher/secrets-bridge/cbda250c0f17e2107c8a0eee348a4a405b139c6d/docs/vault.md -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/Sirupsen/logrus" 7 | "github.com/rancher/secrets-bridge/cmd" 8 | "github.com/urfave/cli" 9 | ) 10 | 11 | func beforeApp(c *cli.Context) error { 12 | if c.GlobalBool("debug") { 13 | logrus.SetLevel(logrus.DebugLevel) 14 | } 15 | return nil 16 | } 17 | 18 | func main() { 19 | app := cli.NewApp() 20 | app.Name = "secrets-bridge" 21 | app.Usage = "Bridge containers with a secret" 22 | app.Before = beforeApp 23 | app.Flags = []cli.Flag{ 24 | cli.BoolFlag{ 25 | Name: "debug,d", 26 | }, 27 | } 28 | 29 | app.Commands = []cli.Command{ 30 | cmd.ServerCommand(), 31 | cmd.AgentCommand(), 32 | } 33 | 34 | app.Run(os.Args) 35 | } 36 | -------------------------------------------------------------------------------- /package/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM busybox 2 | 3 | ADD ./secrets-bridge /secrets-bridge 4 | ADD ./ca-certificates.crt /etc/ssl/certs/ca-certificates.crt 5 | 6 | ENTRYPOINT ["/secrets-bridge"] 7 | CMD ["-h"] 8 | -------------------------------------------------------------------------------- /pkg/archive/tar.go: -------------------------------------------------------------------------------- 1 | package archive 2 | 3 | import ( 4 | "archive/tar" 5 | "bytes" 6 | ) 7 | 8 | type ArchiveFile struct { 9 | Name string 10 | Content string 11 | } 12 | 13 | func CreateTarArchive(files []ArchiveFile) (*bytes.Buffer, error) { 14 | buffer := new(bytes.Buffer) 15 | tw := tar.NewWriter(buffer) 16 | 17 | for _, file := range files { 18 | hdr := &tar.Header{ 19 | Name: file.Name, 20 | Mode: 0600, 21 | Size: int64(len(file.Content)), 22 | } 23 | 24 | if err := tw.WriteHeader(hdr); err != nil { 25 | return buffer, err 26 | } 27 | if _, err := tw.Write([]byte(file.Content)); err != nil { 28 | return buffer, err 29 | } 30 | } 31 | 32 | if err := tw.Close(); err != nil { 33 | return buffer, err 34 | } 35 | return buffer, nil 36 | } 37 | -------------------------------------------------------------------------------- /scripts/build: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | source $(dirname $0)/version 4 | 5 | cd $(dirname $0)/.. 6 | 7 | mkdir -p bin 8 | go build -ldflags="-X main.VERSION=$VERSION -linkmode external -extldflags -static" -o bin/secrets-bridge 9 | -------------------------------------------------------------------------------- /scripts/ci: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | cd $(dirname $0)/.. 6 | 7 | export PATH=$GOPATH/bin:$PATH 8 | 9 | ./scripts/build 10 | ./scripts/package 11 | -------------------------------------------------------------------------------- /scripts/entry: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | trap "chown -R $DAPPER_UID:$DAPPER_GID ." exit 5 | 6 | mkdir -p bin 7 | if [ -e ./scripts/$1 ]; then 8 | ./scripts/"$@" 9 | else 10 | "$@" 11 | fi 12 | 13 | -------------------------------------------------------------------------------- /scripts/package: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | source $(dirname $0)/version 5 | 6 | cd $(dirname $0)/../package 7 | 8 | TAG=${TAG:-${VERSION}} 9 | REPO=${REPO:-rancher} 10 | 11 | cp ../bin/secrets-bridge . 12 | docker build -t ${REPO}/secrets-bridge:${TAG} . 13 | 14 | echo Built ${REPO}/secrets-bridge:${TAG} 15 | -------------------------------------------------------------------------------- /scripts/release: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | exec $(dirname $0)/ci 4 | -------------------------------------------------------------------------------- /scripts/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | cd $(dirname $0)/.. 5 | 6 | echo Running tests 7 | 8 | PACKAGES=". $(find -name '*.go' | xargs -I{} dirname {} | cut -f2 -d/ | sort -u | grep -Ev '(^\.$|.git|.trash-cache|vendor|bin)' | sed -e 's!^!./!' -e 's!$!/...!')" 9 | 10 | go test -race -cover -tags=test ${PACKAGES} 11 | -------------------------------------------------------------------------------- /scripts/validate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancher/secrets-bridge/cbda250c0f17e2107c8a0eee348a4a405b139c6d/scripts/validate -------------------------------------------------------------------------------- /scripts/version: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -n "$(git status --porcelain --untracked-files=no)" ]; then 4 | DIRTY="-dirty" 5 | fi 6 | 7 | COMMIT=$(git rev-parse --short HEAD) 8 | GIT_TAG=$(git tag -l --contains HEAD | head -n 1) 9 | 10 | if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then 11 | VERSION=$GIT_TAG 12 | else 13 | VERSION="${COMMIT}${DIRTY}" 14 | fi 15 | -------------------------------------------------------------------------------- /types/types.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import "github.com/docker/engine-api/types/events" 4 | 5 | type Message struct { 6 | Event *events.Message 7 | UUID string `json:"UUID"` 8 | Action string `json:"Action"` 9 | Host string `json:"Host"` 10 | ContainerType string `json:"container_type"` 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/.gitignore: -------------------------------------------------------------------------------- 1 | logrus 2 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.3 4 | - 1.4 5 | - 1.5 6 | - tip 7 | install: 8 | - go get -t ./... 9 | script: GOMAXPROCS=4 GORACE="halt_on_error=1" go test -race -v ./... 10 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.10.0 2 | 3 | * feature: Add a test hook (#180) 4 | * feature: `ParseLevel` is now case-insensitive (#326) 5 | * feature: `FieldLogger` interface that generalizes `Logger` and `Entry` (#308) 6 | * performance: avoid re-allocations on `WithFields` (#335) 7 | 8 | # 0.9.0 9 | 10 | * logrus/text_formatter: don't emit empty msg 11 | * logrus/hooks/airbrake: move out of main repository 12 | * logrus/hooks/sentry: move out of main repository 13 | * logrus/hooks/papertrail: move out of main repository 14 | * logrus/hooks/bugsnag: move out of main repository 15 | * logrus/core: run tests with `-race` 16 | * logrus/core: detect TTY based on `stderr` 17 | * logrus/core: support `WithError` on logger 18 | * logrus/core: Solaris support 19 | 20 | # 0.8.7 21 | 22 | * logrus/core: fix possible race (#216) 23 | * logrus/doc: small typo fixes and doc improvements 24 | 25 | 26 | # 0.8.6 27 | 28 | * hooks/raven: allow passing an initialized client 29 | 30 | # 0.8.5 31 | 32 | * logrus/core: revert #208 33 | 34 | # 0.8.4 35 | 36 | * formatter/text: fix data race (#218) 37 | 38 | # 0.8.3 39 | 40 | * logrus/core: fix entry log level (#208) 41 | * logrus/core: improve performance of text formatter by 40% 42 | * logrus/core: expose `LevelHooks` type 43 | * logrus/core: add support for DragonflyBSD and NetBSD 44 | * formatter/text: print structs more verbosely 45 | 46 | # 0.8.2 47 | 48 | * logrus: fix more Fatal family functions 49 | 50 | # 0.8.1 51 | 52 | * logrus: fix not exiting on `Fatalf` and `Fatalln` 53 | 54 | # 0.8.0 55 | 56 | * logrus: defaults to stderr instead of stdout 57 | * hooks/sentry: add special field for `*http.Request` 58 | * formatter/text: ignore Windows for colors 59 | 60 | # 0.7.3 61 | 62 | * formatter/\*: allow configuration of timestamp layout 63 | 64 | # 0.7.2 65 | 66 | * formatter/text: Add configuration option for time format (#158) 67 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simon Eskildsen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package logrus is a structured logger for Go, completely API compatible with the standard library logger. 3 | 4 | 5 | The simplest way to use Logrus is simply the package-level exported logger: 6 | 7 | package main 8 | 9 | import ( 10 | log "github.com/Sirupsen/logrus" 11 | ) 12 | 13 | func main() { 14 | log.WithFields(log.Fields{ 15 | "animal": "walrus", 16 | "number": 1, 17 | "size": 10, 18 | }).Info("A walrus appears") 19 | } 20 | 21 | Output: 22 | time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 23 | 24 | For a full guide visit https://github.com/Sirupsen/logrus 25 | */ 26 | package logrus 27 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import "time" 4 | 5 | const DefaultTimestampFormat = time.RFC3339 6 | 7 | // The Formatter interface is used to implement a custom Formatter. It takes an 8 | // `Entry`. It exposes all the fields, including the default ones: 9 | // 10 | // * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. 11 | // * `entry.Data["time"]`. The timestamp. 12 | // * `entry.Data["level"]. The level the entry was logged at. 13 | // 14 | // Any additional fields added with `WithField` or `WithFields` are also in 15 | // `entry.Data`. Format is expected to return an array of bytes which are then 16 | // logged to `logger.Out`. 17 | type Formatter interface { 18 | Format(*Entry) ([]byte, error) 19 | } 20 | 21 | // This is to not silently overwrite `time`, `msg` and `level` fields when 22 | // dumping it. If this code wasn't there doing: 23 | // 24 | // logrus.WithField("level", 1).Info("hello") 25 | // 26 | // Would just silently drop the user provided level. Instead with this code 27 | // it'll logged as: 28 | // 29 | // {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."} 30 | // 31 | // It's not exported because it's still using Data in an opinionated way. It's to 32 | // avoid code duplication between the two default formatters. 33 | func prefixFieldClashes(data Fields) { 34 | _, ok := data["time"] 35 | if ok { 36 | data["fields.time"] = data["time"] 37 | } 38 | 39 | _, ok = data["msg"] 40 | if ok { 41 | data["fields.msg"] = data["msg"] 42 | } 43 | 44 | _, ok = data["level"] 45 | if ok { 46 | data["fields.level"] = data["level"] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // A hook to be fired when logging on the logging levels returned from 4 | // `Levels()` on your implementation of the interface. Note that this is not 5 | // fired in a goroutine or a channel with workers, you should handle such 6 | // functionality yourself if your call is non-blocking and you don't wish for 7 | // the logging calls for levels returned from `Levels()` to block. 8 | type Hook interface { 9 | Levels() []Level 10 | Fire(*Entry) error 11 | } 12 | 13 | // Internal type for storing the hooks on a logger instance. 14 | type LevelHooks map[Level][]Hook 15 | 16 | // Add a hook to an instance of logger. This is called with 17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. 18 | func (hooks LevelHooks) Add(hook Hook) { 19 | for _, level := range hook.Levels() { 20 | hooks[level] = append(hooks[level], hook) 21 | } 22 | } 23 | 24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire 25 | // appropriate hooks for a log entry. 26 | func (hooks LevelHooks) Fire(level Level, entry *Entry) error { 27 | for _, hook := range hooks[level] { 28 | if err := hook.Fire(entry); err != nil { 29 | return err 30 | } 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/json_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type JSONFormatter struct { 9 | // TimestampFormat sets the format used for marshaling timestamps. 10 | TimestampFormat string 11 | } 12 | 13 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { 14 | data := make(Fields, len(entry.Data)+3) 15 | for k, v := range entry.Data { 16 | switch v := v.(type) { 17 | case error: 18 | // Otherwise errors are ignored by `encoding/json` 19 | // https://github.com/Sirupsen/logrus/issues/137 20 | data[k] = v.Error() 21 | default: 22 | data[k] = v 23 | } 24 | } 25 | prefixFieldClashes(data) 26 | 27 | timestampFormat := f.TimestampFormat 28 | if timestampFormat == "" { 29 | timestampFormat = DefaultTimestampFormat 30 | } 31 | 32 | data["time"] = entry.Time.Format(timestampFormat) 33 | data["msg"] = entry.Message 34 | data["level"] = entry.Level.String() 35 | 36 | serialized, err := json.Marshal(data) 37 | if err != nil { 38 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 39 | } 40 | return append(serialized, '\n'), nil 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | 3 | package logrus 4 | 5 | import "syscall" 6 | 7 | const ioctlReadTermios = syscall.TIOCGETA 8 | 9 | type Termios syscall.Termios 10 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_linux.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package logrus 7 | 8 | import "syscall" 9 | 10 | const ioctlReadTermios = syscall.TCGETS 11 | 12 | type Termios syscall.Termios 13 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_notwindows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build linux darwin freebsd openbsd netbsd dragonfly 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | // IsTerminal returns true if stderr's file descriptor is a terminal. 16 | func IsTerminal() bool { 17 | fd := syscall.Stderr 18 | var termios Termios 19 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 20 | return err == 0 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | 3 | package logrus 4 | 5 | import ( 6 | "os" 7 | 8 | "golang.org/x/sys/unix" 9 | ) 10 | 11 | // IsTerminal returns true if the given file descriptor is a terminal. 12 | func IsTerminal() bool { 13 | _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA) 14 | return err == nil 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build windows 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | var ( 18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 | ) 20 | 21 | // IsTerminal returns true if stderr's file descriptor is a terminal. 22 | func IsTerminal() bool { 23 | fd := syscall.Stderr 24 | var st uint32 25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 26 | return r != 0 && e == 0 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/writer.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "runtime" 7 | ) 8 | 9 | func (logger *Logger) Writer() *io.PipeWriter { 10 | reader, writer := io.Pipe() 11 | 12 | go logger.writerScanner(reader) 13 | runtime.SetFinalizer(writer, writerFinalizer) 14 | 15 | return writer 16 | } 17 | 18 | func (logger *Logger) writerScanner(reader *io.PipeReader) { 19 | scanner := bufio.NewScanner(reader) 20 | for scanner.Scan() { 21 | logger.Print(scanner.Text()) 22 | } 23 | if err := scanner.Err(); err != nil { 24 | logger.Errorf("Error while reading from Writer: %s", err) 25 | } 26 | reader.Close() 27 | } 28 | 29 | func writerFinalizer(writer *io.PipeWriter) { 30 | writer.Close() 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/docker/distribution/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | 26 | # never checkin from the bin file (for now) 27 | bin/* 28 | 29 | # Test key files 30 | *.pem 31 | 32 | # Cover profiles 33 | *.out 34 | 35 | # Editor/IDE specific files. 36 | *.sublime-project 37 | *.sublime-workspace 38 | -------------------------------------------------------------------------------- /vendor/github.com/docker/distribution/.mailmap: -------------------------------------------------------------------------------- 1 | Stephen J Day Stephen Day 2 | Stephen J Day Stephen Day 3 | Olivier Gambier Olivier Gambier 4 | Brian Bland Brian Bland 5 | Brian Bland Brian Bland 6 | Josh Hawn Josh Hawn 7 | Richard Scothern Richard 8 | Richard Scothern Richard Scothern 9 | Andrew Meredith Andrew Meredith 10 | harche harche 11 | Jessie Frazelle 12 | Sharif Nassar Sharif Nassar 13 | Sven Dowideit Sven Dowideit 14 | Vincent Giersch Vincent Giersch 15 | davidli davidli 16 | Omer Cohen Omer Cohen -------------------------------------------------------------------------------- /vendor/github.com/docker/distribution/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.6 2 | 3 | RUN apt-get update && \ 4 | apt-get install -y apache2-utils && \ 5 | rm -rf /var/lib/apt/lists/* 6 | 7 | ENV DISTRIBUTION_DIR /go/src/github.com/docker/distribution 8 | ENV DOCKER_BUILDTAGS include_oss include_gcs 9 | 10 | WORKDIR $DISTRIBUTION_DIR 11 | COPY . $DISTRIBUTION_DIR 12 | COPY cmd/registry/config-dev.yml /etc/docker/registry/config.yml 13 | RUN make PREFIX=/go clean binaries 14 | 15 | VOLUME ["/var/lib/registry"] 16 | EXPOSE 5000 17 | ENTRYPOINT ["registry"] 18 | CMD ["serve", "/etc/docker/registry/config.yml"] 19 | -------------------------------------------------------------------------------- /vendor/github.com/docker/distribution/MAINTAINERS: -------------------------------------------------------------------------------- 1 | # Distribution maintainers file 2 | # 3 | # This file describes who runs the docker/distribution project and how. 4 | # This is a living document - if you see something out of date or missing, speak up! 5 | # 6 | # It is structured to be consumable by both humans and programs. 7 | # To extract its contents programmatically, use any TOML-compliant parser. 8 | # 9 | # This file is compiled into the MAINTAINERS file in docker/opensource. 10 | # 11 | [Org] 12 | [Org."Core maintainers"] 13 | people = [ 14 | "aaronlehmann", 15 | "dmcgowan", 16 | "dmp42", 17 | "richardscothern", 18 | "shykes", 19 | "stevvooe", 20 | ] 21 | 22 | [people] 23 | 24 | # A reference list of all people associated with the project. 25 | # All other sections should refer to people by their canonical key 26 | # in the people section. 27 | 28 | # ADD YOURSELF HERE IN ALPHABETICAL ORDER 29 | 30 | [people.aaronlehmann] 31 | Name = "Aaron Lehmann" 32 | Email = "aaron.lehmann@docker.com" 33 | GitHub = "aaronlehmann" 34 | 35 | [people.brianbland] 36 | Name = "Brian Bland" 37 | Email = "brian.bland@docker.com" 38 | GitHub = "BrianBland" 39 | 40 | [people.dmcgowan] 41 | Name = "Derek McGowan" 42 | Email = "derek@mcgstyle.net" 43 | GitHub = "dmcgowan" 44 | 45 | [people.dmp42] 46 | Name = "Olivier Gambier" 47 | Email = "olivier@docker.com" 48 | GitHub = "dmp42" 49 | 50 | [people.richardscothern] 51 | Name = "Richard Scothern" 52 | Email = "richard.scothern@gmail.com" 53 | GitHub = "richardscothern" 54 | 55 | [people.shykes] 56 | Name = "Solomon Hykes" 57 | Email = "solomon@docker.com" 58 | GitHub = "shykes" 59 | 60 | [people.stevvooe] 61 | Name = "Stephen Day" 62 | Email = "stephen.day@docker.com" 63 | GitHub = "stevvooe" 64 | -------------------------------------------------------------------------------- /vendor/github.com/docker/distribution/coverpkg.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Given a subpackage and the containing package, figures out which packages 3 | # need to be passed to `go test -coverpkg`: this includes all of the 4 | # subpackage's dependencies within the containing package, as well as the 5 | # subpackage itself. 6 | DEPENDENCIES="$(go list -f $'{{range $f := .Deps}}{{$f}}\n{{end}}' ${1} | grep ${2} | grep -v github.com/docker/distribution/vendor)" 7 | echo "${1} ${DEPENDENCIES}" | xargs echo -n | tr ' ' ',' 8 | -------------------------------------------------------------------------------- /vendor/github.com/docker/distribution/digest/doc.go: -------------------------------------------------------------------------------- 1 | // Package digest provides a generalized type to opaquely represent message 2 | // digests and their operations within the registry. The Digest type is 3 | // designed to serve as a flexible identifier in a content-addressable system. 4 | // More importantly, it provides tools and wrappers to work with 5 | // hash.Hash-based digests with little effort. 6 | // 7 | // Basics 8 | // 9 | // The format of a digest is simply a string with two parts, dubbed the 10 | // "algorithm" and the "digest", separated by a colon: 11 | // 12 | // : 13 | // 14 | // An example of a sha256 digest representation follows: 15 | // 16 | // sha256:7173b809ca12ec5dee4506cd86be934c4596dd234ee82c0662eac04a8c2c71dc 17 | // 18 | // In this case, the string "sha256" is the algorithm and the hex bytes are 19 | // the "digest". 20 | // 21 | // Because the Digest type is simply a string, once a valid Digest is 22 | // obtained, comparisons are cheap, quick and simple to express with the 23 | // standard equality operator. 24 | // 25 | // Verification 26 | // 27 | // The main benefit of using the Digest type is simple verification against a 28 | // given digest. The Verifier interface, modeled after the stdlib hash.Hash 29 | // interface, provides a common write sink for digest verification. After 30 | // writing is complete, calling the Verifier.Verified method will indicate 31 | // whether or not the stream of bytes matches the target digest. 32 | // 33 | // Missing Features 34 | // 35 | // In addition to the above, we intend to add the following features to this 36 | // package: 37 | // 38 | // 1. A Digester type that supports write sink digest calculation. 39 | // 40 | // 2. Suspend and resume of ongoing digest calculations to support efficient digest verification in the registry. 41 | // 42 | package digest 43 | -------------------------------------------------------------------------------- /vendor/github.com/docker/distribution/digest/verifiers.go: -------------------------------------------------------------------------------- 1 | package digest 2 | 3 | import ( 4 | "hash" 5 | "io" 6 | ) 7 | 8 | // Verifier presents a general verification interface to be used with message 9 | // digests and other byte stream verifications. Users instantiate a Verifier 10 | // from one of the various methods, write the data under test to it then check 11 | // the result with the Verified method. 12 | type Verifier interface { 13 | io.Writer 14 | 15 | // Verified will return true if the content written to Verifier matches 16 | // the digest. 17 | Verified() bool 18 | } 19 | 20 | // NewDigestVerifier returns a verifier that compares the written bytes 21 | // against a passed in digest. 22 | func NewDigestVerifier(d Digest) (Verifier, error) { 23 | if err := d.Validate(); err != nil { 24 | return nil, err 25 | } 26 | 27 | return hashVerifier{ 28 | hash: d.Algorithm().Hash(), 29 | digest: d, 30 | }, nil 31 | } 32 | 33 | type hashVerifier struct { 34 | digest Digest 35 | hash hash.Hash 36 | } 37 | 38 | func (hv hashVerifier) Write(p []byte) (n int, err error) { 39 | return hv.hash.Write(p) 40 | } 41 | 42 | func (hv hashVerifier) Verified() bool { 43 | return hv.digest == NewDigest(hv.digest.Algorithm(), hv.hash) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: go 3 | sudo: false 4 | notifications: 5 | email: false 6 | go: 7 | - 1.6 8 | install: make deps 9 | script: make validate && make test 10 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all deps test validate lint 2 | 3 | all: deps test validate 4 | 5 | deps: 6 | go get -t ./... 7 | go get github.com/golang/lint/golint 8 | 9 | test: 10 | go test -race -cover ./... 11 | 12 | validate: lint 13 | go vet ./... 14 | test -z "$(gofmt -s -l . | tee /dev/stderr)" 15 | 16 | lint: 17 | out="$$(golint ./...)"; \ 18 | if [ -n "$$(golint ./...)" ]; then \ 19 | echo "$$out"; \ 20 | exit 1; \ 21 | fi 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | 3 | # Source Config 4 | clone_folder: c:\gopath\src\github.com\docker\engine-api 5 | 6 | # Build host 7 | 8 | environment: 9 | GOPATH: c:\gopath 10 | GOVERSION: 1.6 11 | 12 | init: 13 | - git config --global core.autocrlf input 14 | 15 | # Build 16 | 17 | install: 18 | # Install Go 1.6. 19 | - rmdir c:\go /s /q 20 | - appveyor DownloadFile https://storage.googleapis.com/golang/go%GOVERSION%.windows-amd64.msi 21 | - msiexec /i go%GOVERSION%.windows-amd64.msi /q 22 | - set Path=c:\go\bin;c:\gopath\bin;%Path% 23 | - go version 24 | - go env 25 | 26 | build: false 27 | deploy: false 28 | 29 | before_test: 30 | - go get -t ./... 31 | - go get github.com/golang/lint/golint 32 | 33 | test_script: 34 | - go vet ./... 35 | - golint ./... 36 | - gofmt -s -l . 37 | - go test -race -cover -v -tags=test ./... 38 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/client_darwin.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | // DefaultDockerHost defines os specific default if DOCKER_HOST is unset 4 | const DefaultDockerHost = "tcp://127.0.0.1:2375" 5 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/client_unix.go: -------------------------------------------------------------------------------- 1 | // +build linux freebsd solaris openbsd 2 | 3 | package client 4 | 5 | // DefaultDockerHost defines os specific default if DOCKER_HOST is unset 6 | const DefaultDockerHost = "unix:///var/run/docker.sock" 7 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/client_windows.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | // DefaultDockerHost defines os specific default if DOCKER_HOST is unset 4 | const DefaultDockerHost = "npipe:////./pipe/docker_engine" 5 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_attach.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "github.com/docker/engine-api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ContainerAttach attaches a connection to a container in the server. 11 | // It returns a types.HijackedConnection with the hijacked connection 12 | // and the a reader to get output. It's up to the called to close 13 | // the hijacked connection by calling types.HijackedResponse.Close. 14 | func (cli *Client) ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) { 15 | query := url.Values{} 16 | if options.Stream { 17 | query.Set("stream", "1") 18 | } 19 | if options.Stdin { 20 | query.Set("stdin", "1") 21 | } 22 | if options.Stdout { 23 | query.Set("stdout", "1") 24 | } 25 | if options.Stderr { 26 | query.Set("stderr", "1") 27 | } 28 | if options.DetachKeys != "" { 29 | query.Set("detachKeys", options.DetachKeys) 30 | } 31 | 32 | headers := map[string][]string{"Content-Type": {"text/plain"}} 33 | return cli.postHijacked(ctx, "/containers/"+container+"/attach", query, nil, headers) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_commit.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "errors" 6 | "net/url" 7 | 8 | distreference "github.com/docker/distribution/reference" 9 | "github.com/docker/engine-api/types" 10 | "github.com/docker/engine-api/types/reference" 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | // ContainerCommit applies changes into a container and creates a new tagged image. 15 | func (cli *Client) ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.ContainerCommitResponse, error) { 16 | var repository, tag string 17 | if options.Reference != "" { 18 | distributionRef, err := distreference.ParseNamed(options.Reference) 19 | if err != nil { 20 | return types.ContainerCommitResponse{}, err 21 | } 22 | 23 | if _, isCanonical := distributionRef.(distreference.Canonical); isCanonical { 24 | return types.ContainerCommitResponse{}, errors.New("refusing to create a tag with a digest reference") 25 | } 26 | 27 | tag = reference.GetTagFromNamedRef(distributionRef) 28 | repository = distributionRef.Name() 29 | } 30 | 31 | query := url.Values{} 32 | query.Set("container", container) 33 | query.Set("repo", repository) 34 | query.Set("tag", tag) 35 | query.Set("comment", options.Comment) 36 | query.Set("author", options.Author) 37 | for _, change := range options.Changes { 38 | query.Add("changes", change) 39 | } 40 | if options.Pause != true { 41 | query.Set("pause", "0") 42 | } 43 | 44 | var response types.ContainerCommitResponse 45 | resp, err := cli.post(ctx, "/commit", query, options.Config, nil) 46 | if err != nil { 47 | return response, err 48 | } 49 | 50 | err = json.NewDecoder(resp.body).Decode(&response) 51 | ensureReaderClosed(resp) 52 | return response, err 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_create.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | "strings" 7 | 8 | "github.com/docker/engine-api/types" 9 | "github.com/docker/engine-api/types/container" 10 | "github.com/docker/engine-api/types/network" 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | type configWrapper struct { 15 | *container.Config 16 | HostConfig *container.HostConfig 17 | NetworkingConfig *network.NetworkingConfig 18 | } 19 | 20 | // ContainerCreate creates a new container based in the given configuration. 21 | // It can be associated with a name, but it's not mandatory. 22 | func (cli *Client) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (types.ContainerCreateResponse, error) { 23 | var response types.ContainerCreateResponse 24 | query := url.Values{} 25 | if containerName != "" { 26 | query.Set("name", containerName) 27 | } 28 | 29 | body := configWrapper{ 30 | Config: config, 31 | HostConfig: hostConfig, 32 | NetworkingConfig: networkingConfig, 33 | } 34 | 35 | serverResp, err := cli.post(ctx, "/containers/create", query, body, nil) 36 | if err != nil { 37 | if serverResp != nil && serverResp.statusCode == 404 && strings.Contains(err.Error(), "No such image") { 38 | return response, imageNotFoundError{config.Image} 39 | } 40 | return response, err 41 | } 42 | 43 | err = json.NewDecoder(serverResp.body).Decode(&response) 44 | ensureReaderClosed(serverResp) 45 | return response, err 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_diff.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/engine-api/types" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // ContainerDiff shows differences in a container filesystem since it was started. 12 | func (cli *Client) ContainerDiff(ctx context.Context, containerID string) ([]types.ContainerChange, error) { 13 | var changes []types.ContainerChange 14 | 15 | serverResp, err := cli.get(ctx, "/containers/"+containerID+"/changes", url.Values{}, nil) 16 | if err != nil { 17 | return changes, err 18 | } 19 | 20 | err = json.NewDecoder(serverResp.body).Decode(&changes) 21 | ensureReaderClosed(serverResp) 22 | return changes, err 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_export.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ContainerExport retrieves the raw contents of a container 11 | // and returns them as an io.ReadCloser. It's up to the caller 12 | // to close the stream. 13 | func (cli *Client) ContainerExport(ctx context.Context, containerID string) (io.ReadCloser, error) { 14 | serverResp, err := cli.get(ctx, "/containers/"+containerID+"/export", url.Values{}, nil) 15 | if err != nil { 16 | return nil, err 17 | } 18 | 19 | return serverResp.body, nil 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_kill.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "golang.org/x/net/context" 7 | ) 8 | 9 | // ContainerKill terminates the container process but does not remove the container from the docker host. 10 | func (cli *Client) ContainerKill(ctx context.Context, containerID, signal string) error { 11 | query := url.Values{} 12 | query.Set("signal", signal) 13 | 14 | resp, err := cli.post(ctx, "/containers/"+containerID+"/kill", query, nil, nil) 15 | ensureReaderClosed(resp) 16 | return err 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_list.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | "strconv" 7 | 8 | "github.com/docker/engine-api/types" 9 | "github.com/docker/engine-api/types/filters" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // ContainerList returns the list of containers in the docker host. 14 | func (cli *Client) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) { 15 | query := url.Values{} 16 | 17 | if options.All { 18 | query.Set("all", "1") 19 | } 20 | 21 | if options.Limit != -1 { 22 | query.Set("limit", strconv.Itoa(options.Limit)) 23 | } 24 | 25 | if options.Since != "" { 26 | query.Set("since", options.Since) 27 | } 28 | 29 | if options.Before != "" { 30 | query.Set("before", options.Before) 31 | } 32 | 33 | if options.Size { 34 | query.Set("size", "1") 35 | } 36 | 37 | if options.Filter.Len() > 0 { 38 | filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filter) 39 | 40 | if err != nil { 41 | return nil, err 42 | } 43 | 44 | query.Set("filters", filterJSON) 45 | } 46 | 47 | resp, err := cli.get(ctx, "/containers/json", query, nil) 48 | if err != nil { 49 | return nil, err 50 | } 51 | 52 | var containers []types.Container 53 | err = json.NewDecoder(resp.body).Decode(&containers) 54 | ensureReaderClosed(resp) 55 | return containers, err 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_logs.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | "time" 7 | 8 | "golang.org/x/net/context" 9 | 10 | "github.com/docker/engine-api/types" 11 | timetypes "github.com/docker/engine-api/types/time" 12 | ) 13 | 14 | // ContainerLogs returns the logs generated by a container in an io.ReadCloser. 15 | // It's up to the caller to close the stream. 16 | func (cli *Client) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error) { 17 | query := url.Values{} 18 | if options.ShowStdout { 19 | query.Set("stdout", "1") 20 | } 21 | 22 | if options.ShowStderr { 23 | query.Set("stderr", "1") 24 | } 25 | 26 | if options.Since != "" { 27 | ts, err := timetypes.GetTimestamp(options.Since, time.Now()) 28 | if err != nil { 29 | return nil, err 30 | } 31 | query.Set("since", ts) 32 | } 33 | 34 | if options.Timestamps { 35 | query.Set("timestamps", "1") 36 | } 37 | 38 | if options.Follow { 39 | query.Set("follow", "1") 40 | } 41 | query.Set("tail", options.Tail) 42 | 43 | resp, err := cli.get(ctx, "/containers/"+container+"/logs", query, nil) 44 | if err != nil { 45 | return nil, err 46 | } 47 | return resp.body, nil 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_pause.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import "golang.org/x/net/context" 4 | 5 | // ContainerPause pauses the main process of a given container without terminating it. 6 | func (cli *Client) ContainerPause(ctx context.Context, containerID string) error { 7 | resp, err := cli.post(ctx, "/containers/"+containerID+"/pause", nil, nil, nil) 8 | ensureReaderClosed(resp) 9 | return err 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_remove.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "github.com/docker/engine-api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ContainerRemove kills and removes a container from the docker host. 11 | func (cli *Client) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error { 12 | query := url.Values{} 13 | if options.RemoveVolumes { 14 | query.Set("v", "1") 15 | } 16 | if options.RemoveLinks { 17 | query.Set("link", "1") 18 | } 19 | 20 | if options.Force { 21 | query.Set("force", "1") 22 | } 23 | 24 | resp, err := cli.delete(ctx, "/containers/"+containerID, query, nil) 25 | ensureReaderClosed(resp) 26 | return err 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_rename.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | 6 | "golang.org/x/net/context" 7 | ) 8 | 9 | // ContainerRename changes the name of a given container. 10 | func (cli *Client) ContainerRename(ctx context.Context, containerID, newContainerName string) error { 11 | query := url.Values{} 12 | query.Set("name", newContainerName) 13 | resp, err := cli.post(ctx, "/containers/"+containerID+"/rename", query, nil, nil) 14 | ensureReaderClosed(resp) 15 | return err 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_resize.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | "strconv" 6 | 7 | "github.com/docker/engine-api/types" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // ContainerResize changes the size of the tty for a container. 12 | func (cli *Client) ContainerResize(ctx context.Context, containerID string, options types.ResizeOptions) error { 13 | return cli.resize(ctx, "/containers/"+containerID, options.Height, options.Width) 14 | } 15 | 16 | // ContainerExecResize changes the size of the tty for an exec process running inside a container. 17 | func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error { 18 | return cli.resize(ctx, "/exec/"+execID, options.Height, options.Width) 19 | } 20 | 21 | func (cli *Client) resize(ctx context.Context, basePath string, height, width int) error { 22 | query := url.Values{} 23 | query.Set("h", strconv.Itoa(height)) 24 | query.Set("w", strconv.Itoa(width)) 25 | 26 | resp, err := cli.post(ctx, basePath+"/resize", query, nil, nil) 27 | ensureReaderClosed(resp) 28 | return err 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_restart.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | "strconv" 6 | 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ContainerRestart stops and starts a container again. 11 | // It makes the daemon to wait for the container to be up again for 12 | // a specific amount of time, given the timeout. 13 | func (cli *Client) ContainerRestart(ctx context.Context, containerID string, timeout int) error { 14 | query := url.Values{} 15 | query.Set("t", strconv.Itoa(timeout)) 16 | resp, err := cli.post(ctx, "/containers/"+containerID+"/restart", query, nil, nil) 17 | ensureReaderClosed(resp) 18 | return err 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_start.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import "golang.org/x/net/context" 4 | 5 | // ContainerStart sends a request to the docker daemon to start a container. 6 | func (cli *Client) ContainerStart(ctx context.Context, containerID string) error { 7 | resp, err := cli.post(ctx, "/containers/"+containerID+"/start", nil, nil, nil) 8 | ensureReaderClosed(resp) 9 | return err 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_stats.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ContainerStats returns near realtime stats for a given container. 11 | // It's up to the caller to close the io.ReadCloser returned. 12 | func (cli *Client) ContainerStats(ctx context.Context, containerID string, stream bool) (io.ReadCloser, error) { 13 | query := url.Values{} 14 | query.Set("stream", "0") 15 | if stream { 16 | query.Set("stream", "1") 17 | } 18 | 19 | resp, err := cli.get(ctx, "/containers/"+containerID+"/stats", query, nil) 20 | if err != nil { 21 | return nil, err 22 | } 23 | return resp.body, err 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_stop.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "net/url" 5 | "strconv" 6 | 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ContainerStop stops a container without terminating the process. 11 | // The process is blocked until the container stops or the timeout expires. 12 | func (cli *Client) ContainerStop(ctx context.Context, containerID string, timeout int) error { 13 | query := url.Values{} 14 | query.Set("t", strconv.Itoa(timeout)) 15 | resp, err := cli.post(ctx, "/containers/"+containerID+"/stop", query, nil, nil) 16 | ensureReaderClosed(resp) 17 | return err 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_top.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | "strings" 7 | 8 | "github.com/docker/engine-api/types" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // ContainerTop shows process information from within a container. 13 | func (cli *Client) ContainerTop(ctx context.Context, containerID string, arguments []string) (types.ContainerProcessList, error) { 14 | var response types.ContainerProcessList 15 | query := url.Values{} 16 | if len(arguments) > 0 { 17 | query.Set("ps_args", strings.Join(arguments, " ")) 18 | } 19 | 20 | resp, err := cli.get(ctx, "/containers/"+containerID+"/top", query, nil) 21 | if err != nil { 22 | return response, err 23 | } 24 | 25 | err = json.NewDecoder(resp.body).Decode(&response) 26 | ensureReaderClosed(resp) 27 | return response, err 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_unpause.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import "golang.org/x/net/context" 4 | 5 | // ContainerUnpause resumes the process execution within a container 6 | func (cli *Client) ContainerUnpause(ctx context.Context, containerID string) error { 7 | resp, err := cli.post(ctx, "/containers/"+containerID+"/unpause", nil, nil, nil) 8 | ensureReaderClosed(resp) 9 | return err 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_update.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/docker/engine-api/types/container" 5 | "golang.org/x/net/context" 6 | ) 7 | 8 | // ContainerUpdate updates resources of a container 9 | func (cli *Client) ContainerUpdate(ctx context.Context, containerID string, updateConfig container.UpdateConfig) error { 10 | resp, err := cli.post(ctx, "/containers/"+containerID+"/update", nil, updateConfig, nil) 11 | ensureReaderClosed(resp) 12 | return err 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/container_wait.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "golang.org/x/net/context" 7 | 8 | "github.com/docker/engine-api/types" 9 | ) 10 | 11 | // ContainerWait pauses execution until a container exits. 12 | // It returns the API status code as response of its readiness. 13 | func (cli *Client) ContainerWait(ctx context.Context, containerID string) (int, error) { 14 | resp, err := cli.post(ctx, "/containers/"+containerID+"/wait", nil, nil, nil) 15 | if err != nil { 16 | return -1, err 17 | } 18 | defer ensureReaderClosed(resp) 19 | 20 | var res types.ContainerWaitResponse 21 | if err := json.NewDecoder(resp.body).Decode(&res); err != nil { 22 | return -1, err 23 | } 24 | 25 | return res.StatusCode, nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/events.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | "time" 7 | 8 | "golang.org/x/net/context" 9 | 10 | "github.com/docker/engine-api/types" 11 | "github.com/docker/engine-api/types/filters" 12 | timetypes "github.com/docker/engine-api/types/time" 13 | ) 14 | 15 | // Events returns a stream of events in the daemon in a ReadCloser. 16 | // It's up to the caller to close the stream. 17 | func (cli *Client) Events(ctx context.Context, options types.EventsOptions) (io.ReadCloser, error) { 18 | query := url.Values{} 19 | ref := time.Now() 20 | 21 | if options.Since != "" { 22 | ts, err := timetypes.GetTimestamp(options.Since, ref) 23 | if err != nil { 24 | return nil, err 25 | } 26 | query.Set("since", ts) 27 | } 28 | if options.Until != "" { 29 | ts, err := timetypes.GetTimestamp(options.Until, ref) 30 | if err != nil { 31 | return nil, err 32 | } 33 | query.Set("until", ts) 34 | } 35 | if options.Filters.Len() > 0 { 36 | filterJSON, err := filters.ToParam(options.Filters) 37 | if err != nil { 38 | return nil, err 39 | } 40 | query.Set("filters", filterJSON) 41 | } 42 | 43 | serverResponse, err := cli.get(ctx, "/events", query, nil) 44 | if err != nil { 45 | return nil, err 46 | } 47 | return serverResponse.body, nil 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/image_create.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | 7 | "golang.org/x/net/context" 8 | 9 | "github.com/docker/engine-api/types" 10 | "github.com/docker/engine-api/types/reference" 11 | ) 12 | 13 | // ImageCreate creates a new image based in the parent options. 14 | // It returns the JSON content in the response body. 15 | func (cli *Client) ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) { 16 | repository, tag, err := reference.Parse(parentReference) 17 | if err != nil { 18 | return nil, err 19 | } 20 | 21 | query := url.Values{} 22 | query.Set("fromImage", repository) 23 | query.Set("tag", tag) 24 | resp, err := cli.tryImageCreate(ctx, query, options.RegistryAuth) 25 | if err != nil { 26 | return nil, err 27 | } 28 | return resp.body, nil 29 | } 30 | 31 | func (cli *Client) tryImageCreate(ctx context.Context, query url.Values, registryAuth string) (*serverResponse, error) { 32 | headers := map[string][]string{"X-Registry-Auth": {registryAuth}} 33 | return cli.post(ctx, "/images/create", query, nil, headers) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/image_history.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/engine-api/types" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // ImageHistory returns the changes in an image in history format. 12 | func (cli *Client) ImageHistory(ctx context.Context, imageID string) ([]types.ImageHistory, error) { 13 | var history []types.ImageHistory 14 | serverResp, err := cli.get(ctx, "/images/"+imageID+"/history", url.Values{}, nil) 15 | if err != nil { 16 | return history, err 17 | } 18 | 19 | err = json.NewDecoder(serverResp.body).Decode(&history) 20 | ensureReaderClosed(serverResp) 21 | return history, err 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/image_import.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | 7 | "golang.org/x/net/context" 8 | 9 | "github.com/docker/distribution/reference" 10 | "github.com/docker/engine-api/types" 11 | ) 12 | 13 | // ImageImport creates a new image based in the source options. 14 | // It returns the JSON content in the response body. 15 | func (cli *Client) ImageImport(ctx context.Context, source types.ImageImportSource, ref string, options types.ImageImportOptions) (io.ReadCloser, error) { 16 | if ref != "" { 17 | //Check if the given image name can be resolved 18 | if _, err := reference.ParseNamed(ref); err != nil { 19 | return nil, err 20 | } 21 | } 22 | 23 | query := url.Values{} 24 | query.Set("fromSrc", source.SourceName) 25 | query.Set("repo", ref) 26 | query.Set("tag", options.Tag) 27 | query.Set("message", options.Message) 28 | for _, change := range options.Changes { 29 | query.Add("changes", change) 30 | } 31 | 32 | resp, err := cli.postRaw(ctx, "/images/create", query, source.Source, nil) 33 | if err != nil { 34 | return nil, err 35 | } 36 | return resp.body, nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/image_inspect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io/ioutil" 7 | "net/http" 8 | "net/url" 9 | 10 | "github.com/docker/engine-api/types" 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | // ImageInspectWithRaw returns the image information and its raw representation. 15 | func (cli *Client) ImageInspectWithRaw(ctx context.Context, imageID string, getSize bool) (types.ImageInspect, []byte, error) { 16 | query := url.Values{} 17 | if getSize { 18 | query.Set("size", "1") 19 | } 20 | serverResp, err := cli.get(ctx, "/images/"+imageID+"/json", query, nil) 21 | if err != nil { 22 | if serverResp.statusCode == http.StatusNotFound { 23 | return types.ImageInspect{}, nil, imageNotFoundError{imageID} 24 | } 25 | return types.ImageInspect{}, nil, err 26 | } 27 | defer ensureReaderClosed(serverResp) 28 | 29 | body, err := ioutil.ReadAll(serverResp.body) 30 | if err != nil { 31 | return types.ImageInspect{}, nil, err 32 | } 33 | 34 | var response types.ImageInspect 35 | rdr := bytes.NewReader(body) 36 | err = json.NewDecoder(rdr).Decode(&response) 37 | return response, body, err 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/image_list.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/engine-api/types" 8 | "github.com/docker/engine-api/types/filters" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // ImageList returns a list of images in the docker host. 13 | func (cli *Client) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.Image, error) { 14 | var images []types.Image 15 | query := url.Values{} 16 | 17 | if options.Filters.Len() > 0 { 18 | filterJSON, err := filters.ToParam(options.Filters) 19 | if err != nil { 20 | return images, err 21 | } 22 | query.Set("filters", filterJSON) 23 | } 24 | if options.MatchName != "" { 25 | // FIXME rename this parameter, to not be confused with the filters flag 26 | query.Set("filter", options.MatchName) 27 | } 28 | if options.All { 29 | query.Set("all", "1") 30 | } 31 | 32 | serverResp, err := cli.get(ctx, "/images/json", query, nil) 33 | if err != nil { 34 | return images, err 35 | } 36 | 37 | err = json.NewDecoder(serverResp.body).Decode(&images) 38 | ensureReaderClosed(serverResp) 39 | return images, err 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/image_load.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | 7 | "golang.org/x/net/context" 8 | 9 | "github.com/docker/engine-api/types" 10 | ) 11 | 12 | // ImageLoad loads an image in the docker host from the client host. 13 | // It's up to the caller to close the io.ReadCloser returned by 14 | // this function. 15 | func (cli *Client) ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error) { 16 | v := url.Values{} 17 | v.Set("quiet", "0") 18 | if quiet { 19 | v.Set("quiet", "1") 20 | } 21 | headers := map[string][]string{"Content-Type": {"application/x-tar"}} 22 | resp, err := cli.postRaw(ctx, "/images/load", v, input, headers) 23 | if err != nil { 24 | return types.ImageLoadResponse{}, err 25 | } 26 | return types.ImageLoadResponse{ 27 | Body: resp.body, 28 | JSON: resp.header.Get("Content-Type") == "application/json", 29 | }, nil 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/image_pull.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/http" 6 | "net/url" 7 | 8 | "golang.org/x/net/context" 9 | 10 | "github.com/docker/engine-api/types" 11 | "github.com/docker/engine-api/types/reference" 12 | ) 13 | 14 | // ImagePull requests the docker host to pull an image from a remote registry. 15 | // It executes the privileged function if the operation is unauthorized 16 | // and it tries one more time. 17 | // It's up to the caller to handle the io.ReadCloser and close it properly. 18 | // 19 | // FIXME(vdemeester): there is currently used in a few way in docker/docker 20 | // - if not in trusted content, ref is used to pass the whole reference, and tag is empty 21 | // - if in trusted content, ref is used to pass the reference name, and tag for the digest 22 | func (cli *Client) ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error) { 23 | repository, tag, err := reference.Parse(ref) 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | query := url.Values{} 29 | query.Set("fromImage", repository) 30 | if tag != "" { 31 | query.Set("tag", tag) 32 | } 33 | 34 | resp, err := cli.tryImageCreate(ctx, query, options.RegistryAuth) 35 | if resp.statusCode == http.StatusUnauthorized { 36 | newAuthHeader, privilegeErr := options.PrivilegeFunc() 37 | if privilegeErr != nil { 38 | return nil, privilegeErr 39 | } 40 | resp, err = cli.tryImageCreate(ctx, query, newAuthHeader) 41 | } 42 | if err != nil { 43 | return nil, err 44 | } 45 | return resp.body, nil 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/image_push.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "errors" 5 | "io" 6 | "net/http" 7 | "net/url" 8 | 9 | "golang.org/x/net/context" 10 | 11 | distreference "github.com/docker/distribution/reference" 12 | "github.com/docker/engine-api/types" 13 | "github.com/docker/engine-api/types/reference" 14 | ) 15 | 16 | // ImagePush requests the docker host to push an image to a remote registry. 17 | // It executes the privileged function if the operation is unauthorized 18 | // and it tries one more time. 19 | // It's up to the caller to handle the io.ReadCloser and close it properly. 20 | func (cli *Client) ImagePush(ctx context.Context, ref string, options types.ImagePushOptions) (io.ReadCloser, error) { 21 | distributionRef, err := distreference.ParseNamed(ref) 22 | if err != nil { 23 | return nil, err 24 | } 25 | 26 | if _, isCanonical := distributionRef.(distreference.Canonical); isCanonical { 27 | return nil, errors.New("cannot push a digest reference") 28 | } 29 | 30 | tag := reference.GetTagFromNamedRef(distributionRef) 31 | 32 | query := url.Values{} 33 | query.Set("tag", tag) 34 | 35 | resp, err := cli.tryImagePush(ctx, distributionRef.Name(), query, options.RegistryAuth) 36 | if resp.statusCode == http.StatusUnauthorized { 37 | newAuthHeader, privilegeErr := options.PrivilegeFunc() 38 | if privilegeErr != nil { 39 | return nil, privilegeErr 40 | } 41 | resp, err = cli.tryImagePush(ctx, distributionRef.Name(), query, newAuthHeader) 42 | } 43 | if err != nil { 44 | return nil, err 45 | } 46 | return resp.body, nil 47 | } 48 | 49 | func (cli *Client) tryImagePush(ctx context.Context, imageID string, query url.Values, registryAuth string) (*serverResponse, error) { 50 | headers := map[string][]string{"X-Registry-Auth": {registryAuth}} 51 | return cli.post(ctx, "/images/"+imageID+"/push", query, nil, headers) 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/image_remove.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/engine-api/types" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // ImageRemove removes an image from the docker host. 12 | func (cli *Client) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDelete, error) { 13 | query := url.Values{} 14 | 15 | if options.Force { 16 | query.Set("force", "1") 17 | } 18 | if !options.PruneChildren { 19 | query.Set("noprune", "1") 20 | } 21 | 22 | resp, err := cli.delete(ctx, "/images/"+imageID, query, nil) 23 | if err != nil { 24 | return nil, err 25 | } 26 | 27 | var dels []types.ImageDelete 28 | err = json.NewDecoder(resp.body).Decode(&dels) 29 | ensureReaderClosed(resp) 30 | return dels, err 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/image_save.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "io" 5 | "net/url" 6 | 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ImageSave retrieves one or more images from the docker host as an io.ReadCloser. 11 | // It's up to the caller to store the images and close the stream. 12 | func (cli *Client) ImageSave(ctx context.Context, imageIDs []string) (io.ReadCloser, error) { 13 | query := url.Values{ 14 | "names": imageIDs, 15 | } 16 | 17 | resp, err := cli.get(ctx, "/images/get", query, nil) 18 | if err != nil { 19 | return nil, err 20 | } 21 | return resp.body, nil 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/image_search.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/http" 6 | "net/url" 7 | 8 | "github.com/docker/engine-api/types" 9 | "github.com/docker/engine-api/types/registry" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // ImageSearch makes the docker host to search by a term in a remote registry. 14 | // The list of results is not sorted in any fashion. 15 | func (cli *Client) ImageSearch(ctx context.Context, term string, options types.ImageSearchOptions) ([]registry.SearchResult, error) { 16 | var results []registry.SearchResult 17 | query := url.Values{} 18 | query.Set("term", term) 19 | 20 | resp, err := cli.tryImageSearch(ctx, query, options.RegistryAuth) 21 | if resp.statusCode == http.StatusUnauthorized { 22 | newAuthHeader, privilegeErr := options.PrivilegeFunc() 23 | if privilegeErr != nil { 24 | return results, privilegeErr 25 | } 26 | resp, err = cli.tryImageSearch(ctx, query, newAuthHeader) 27 | } 28 | if err != nil { 29 | return results, err 30 | } 31 | 32 | err = json.NewDecoder(resp.body).Decode(&results) 33 | ensureReaderClosed(resp) 34 | return results, err 35 | } 36 | 37 | func (cli *Client) tryImageSearch(ctx context.Context, query url.Values, registryAuth string) (*serverResponse, error) { 38 | headers := map[string][]string{"X-Registry-Auth": {registryAuth}} 39 | return cli.get(ctx, "/images/search", query, headers) 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/image_tag.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "net/url" 7 | 8 | "golang.org/x/net/context" 9 | 10 | distreference "github.com/docker/distribution/reference" 11 | "github.com/docker/engine-api/types" 12 | "github.com/docker/engine-api/types/reference" 13 | ) 14 | 15 | // ImageTag tags an image in the docker host 16 | func (cli *Client) ImageTag(ctx context.Context, imageID, ref string, options types.ImageTagOptions) error { 17 | distributionRef, err := distreference.ParseNamed(ref) 18 | if err != nil { 19 | return fmt.Errorf("Error parsing reference: %q is not a valid repository/tag", ref) 20 | } 21 | 22 | if _, isCanonical := distributionRef.(distreference.Canonical); isCanonical { 23 | return errors.New("refusing to create a tag with a digest reference") 24 | } 25 | 26 | tag := reference.GetTagFromNamedRef(distributionRef) 27 | 28 | query := url.Values{} 29 | query.Set("repo", distributionRef.Name()) 30 | query.Set("tag", tag) 31 | if options.Force { 32 | query.Set("force", "1") 33 | } 34 | 35 | resp, err := cli.post(ctx, "/images/"+imageID+"/tag", query, nil, nil) 36 | ensureReaderClosed(resp) 37 | return err 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/info.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | 8 | "github.com/docker/engine-api/types" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // Info returns information about the docker server. 13 | func (cli *Client) Info(ctx context.Context) (types.Info, error) { 14 | var info types.Info 15 | serverResp, err := cli.get(ctx, "/info", url.Values{}, nil) 16 | if err != nil { 17 | return info, err 18 | } 19 | defer ensureReaderClosed(serverResp) 20 | 21 | if err := json.NewDecoder(serverResp.body).Decode(&info); err != nil { 22 | return info, fmt.Errorf("Error reading remote info: %v", err) 23 | } 24 | 25 | return info, nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/login.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/http" 6 | "net/url" 7 | 8 | "github.com/docker/engine-api/types" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // RegistryLogin authenticates the docker server with a given docker registry. 13 | // It returns UnauthorizerError when the authentication fails. 14 | func (cli *Client) RegistryLogin(ctx context.Context, auth types.AuthConfig) (types.AuthResponse, error) { 15 | resp, err := cli.post(ctx, "/auth", url.Values{}, auth, nil) 16 | 17 | if resp != nil && resp.statusCode == http.StatusUnauthorized { 18 | return types.AuthResponse{}, unauthorizedError{err} 19 | } 20 | if err != nil { 21 | return types.AuthResponse{}, err 22 | } 23 | 24 | var response types.AuthResponse 25 | err = json.NewDecoder(resp.body).Decode(&response) 26 | ensureReaderClosed(resp) 27 | return response, err 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/network_connect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/docker/engine-api/types" 5 | "github.com/docker/engine-api/types/network" 6 | "golang.org/x/net/context" 7 | ) 8 | 9 | // NetworkConnect connects a container to an existent network in the docker host. 10 | func (cli *Client) NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error { 11 | nc := types.NetworkConnect{ 12 | Container: containerID, 13 | EndpointConfig: config, 14 | } 15 | resp, err := cli.post(ctx, "/networks/"+networkID+"/connect", nil, nc, nil) 16 | ensureReaderClosed(resp) 17 | return err 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/network_create.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/docker/engine-api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // NetworkCreate creates a new network in the docker host. 11 | func (cli *Client) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) { 12 | networkCreateRequest := types.NetworkCreateRequest{ 13 | NetworkCreate: options, 14 | Name: name, 15 | } 16 | var response types.NetworkCreateResponse 17 | serverResp, err := cli.post(ctx, "/networks/create", nil, networkCreateRequest, nil) 18 | if err != nil { 19 | return response, err 20 | } 21 | 22 | json.NewDecoder(serverResp.body).Decode(&response) 23 | ensureReaderClosed(serverResp) 24 | return response, err 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/network_disconnect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "github.com/docker/engine-api/types" 5 | "golang.org/x/net/context" 6 | ) 7 | 8 | // NetworkDisconnect disconnects a container from an existent network in the docker host. 9 | func (cli *Client) NetworkDisconnect(ctx context.Context, networkID, containerID string, force bool) error { 10 | nd := types.NetworkDisconnect{Container: containerID, Force: force} 11 | resp, err := cli.post(ctx, "/networks/"+networkID+"/disconnect", nil, nd, nil) 12 | ensureReaderClosed(resp) 13 | return err 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/network_inspect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/http" 6 | 7 | "github.com/docker/engine-api/types" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // NetworkInspect returns the information for a specific network configured in the docker host. 12 | func (cli *Client) NetworkInspect(ctx context.Context, networkID string) (types.NetworkResource, error) { 13 | var networkResource types.NetworkResource 14 | resp, err := cli.get(ctx, "/networks/"+networkID, nil, nil) 15 | if err != nil { 16 | if resp.statusCode == http.StatusNotFound { 17 | return networkResource, networkNotFoundError{networkID} 18 | } 19 | return networkResource, err 20 | } 21 | err = json.NewDecoder(resp.body).Decode(&networkResource) 22 | ensureReaderClosed(resp) 23 | return networkResource, err 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/network_list.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/engine-api/types" 8 | "github.com/docker/engine-api/types/filters" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // NetworkList returns the list of networks configured in the docker host. 13 | func (cli *Client) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) { 14 | query := url.Values{} 15 | if options.Filters.Len() > 0 { 16 | filterJSON, err := filters.ToParam(options.Filters) 17 | if err != nil { 18 | return nil, err 19 | } 20 | 21 | query.Set("filters", filterJSON) 22 | } 23 | var networkResources []types.NetworkResource 24 | resp, err := cli.get(ctx, "/networks", query, nil) 25 | if err != nil { 26 | return networkResources, err 27 | } 28 | err = json.NewDecoder(resp.body).Decode(&networkResources) 29 | ensureReaderClosed(resp) 30 | return networkResources, err 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/network_remove.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import "golang.org/x/net/context" 4 | 5 | // NetworkRemove removes an existent network from the docker host. 6 | func (cli *Client) NetworkRemove(ctx context.Context, networkID string) error { 7 | resp, err := cli.delete(ctx, "/networks/"+networkID, nil, nil) 8 | ensureReaderClosed(resp) 9 | return err 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/transport/cancellable/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/transport/cancellable/canceler.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.5 6 | 7 | package cancellable 8 | 9 | import ( 10 | "net/http" 11 | 12 | "github.com/docker/engine-api/client/transport" 13 | ) 14 | 15 | func canceler(client transport.Sender, req *http.Request) func() { 16 | // TODO(djd): Respect any existing value of req.Cancel. 17 | ch := make(chan struct{}) 18 | req.Cancel = ch 19 | 20 | return func() { 21 | close(ch) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/transport/cancellable/canceler_go14.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.5 6 | 7 | package cancellable 8 | 9 | import ( 10 | "net/http" 11 | 12 | "github.com/docker/engine-api/client/transport" 13 | ) 14 | 15 | type requestCanceler interface { 16 | CancelRequest(*http.Request) 17 | } 18 | 19 | func canceler(client transport.Sender, req *http.Request) func() { 20 | rc, ok := client.(requestCanceler) 21 | if !ok { 22 | return func() {} 23 | } 24 | return func() { 25 | rc.CancelRequest(req) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/transport/client.go: -------------------------------------------------------------------------------- 1 | package transport 2 | 3 | import ( 4 | "crypto/tls" 5 | "net/http" 6 | ) 7 | 8 | // Sender is an interface that clients must implement 9 | // to be able to send requests to a remote connection. 10 | type Sender interface { 11 | // Do sends request to a remote endpoint. 12 | Do(*http.Request) (*http.Response, error) 13 | } 14 | 15 | // Client is an interface that abstracts all remote connections. 16 | type Client interface { 17 | Sender 18 | // Secure tells whether the connection is secure or not. 19 | Secure() bool 20 | // Scheme returns the connection protocol the client uses. 21 | Scheme() string 22 | // TLSConfig returns any TLS configuration the client uses. 23 | TLSConfig() *tls.Config 24 | } 25 | 26 | // tlsInfo returns information about the TLS configuration. 27 | type tlsInfo struct { 28 | tlsConfig *tls.Config 29 | } 30 | 31 | // TLSConfig returns the TLS configuration. 32 | func (t *tlsInfo) TLSConfig() *tls.Config { 33 | return t.tlsConfig 34 | } 35 | 36 | // Scheme returns protocol scheme to use. 37 | func (t *tlsInfo) Scheme() string { 38 | if t.tlsConfig != nil { 39 | return "https" 40 | } 41 | return "http" 42 | } 43 | 44 | // Secure returns true if there is a TLS configuration. 45 | func (t *tlsInfo) Secure() bool { 46 | return t.tlsConfig != nil 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/transport/transport.go: -------------------------------------------------------------------------------- 1 | // Package transport provides function to send request to remote endpoints. 2 | package transport 3 | 4 | import ( 5 | "fmt" 6 | "net/http" 7 | 8 | "github.com/docker/go-connections/sockets" 9 | ) 10 | 11 | // apiTransport holds information about the http transport to connect with the API. 12 | type apiTransport struct { 13 | *http.Client 14 | *tlsInfo 15 | transport *http.Transport 16 | } 17 | 18 | // NewTransportWithHTTP creates a new transport based on the provided proto, address and http client. 19 | // It uses Docker's default http transport configuration if the client is nil. 20 | // It does not modify the client's transport if it's not nil. 21 | func NewTransportWithHTTP(proto, addr string, client *http.Client) (Client, error) { 22 | var transport *http.Transport 23 | 24 | if client != nil { 25 | tr, ok := client.Transport.(*http.Transport) 26 | if !ok { 27 | return nil, fmt.Errorf("unable to verify TLS configuration, invalid transport %v", client.Transport) 28 | } 29 | transport = tr 30 | } else { 31 | transport = defaultTransport(proto, addr) 32 | client = &http.Client{ 33 | Transport: transport, 34 | } 35 | } 36 | 37 | return &apiTransport{ 38 | Client: client, 39 | tlsInfo: &tlsInfo{transport.TLSClientConfig}, 40 | transport: transport, 41 | }, nil 42 | } 43 | 44 | // CancelRequest stops a request execution. 45 | func (a *apiTransport) CancelRequest(req *http.Request) { 46 | a.transport.CancelRequest(req) 47 | } 48 | 49 | // defaultTransport creates a new http.Transport with Docker's 50 | // default transport configuration. 51 | func defaultTransport(proto, addr string) *http.Transport { 52 | tr := new(http.Transport) 53 | sockets.ConfigureTransport(tr, proto, addr) 54 | return tr 55 | } 56 | 57 | var _ Client = &apiTransport{} 58 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/version.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/docker/engine-api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // ServerVersion returns information of the docker client and server host. 11 | func (cli *Client) ServerVersion(ctx context.Context) (types.Version, error) { 12 | resp, err := cli.get(ctx, "/version", nil, nil) 13 | if err != nil { 14 | return types.Version{}, err 15 | } 16 | 17 | var server types.Version 18 | err = json.NewDecoder(resp.body).Decode(&server) 19 | ensureReaderClosed(resp) 20 | return server, err 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/volume_create.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/docker/engine-api/types" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // VolumeCreate creates a volume in the docker host. 11 | func (cli *Client) VolumeCreate(ctx context.Context, options types.VolumeCreateRequest) (types.Volume, error) { 12 | var volume types.Volume 13 | resp, err := cli.post(ctx, "/volumes/create", nil, options, nil) 14 | if err != nil { 15 | return volume, err 16 | } 17 | err = json.NewDecoder(resp.body).Decode(&volume) 18 | ensureReaderClosed(resp) 19 | return volume, err 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/volume_inspect.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/http" 6 | 7 | "github.com/docker/engine-api/types" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | // VolumeInspect returns the information about a specific volume in the docker host. 12 | func (cli *Client) VolumeInspect(ctx context.Context, volumeID string) (types.Volume, error) { 13 | var volume types.Volume 14 | resp, err := cli.get(ctx, "/volumes/"+volumeID, nil, nil) 15 | if err != nil { 16 | if resp.statusCode == http.StatusNotFound { 17 | return volume, volumeNotFoundError{volumeID} 18 | } 19 | return volume, err 20 | } 21 | err = json.NewDecoder(resp.body).Decode(&volume) 22 | ensureReaderClosed(resp) 23 | return volume, err 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/volume_list.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "encoding/json" 5 | "net/url" 6 | 7 | "github.com/docker/engine-api/types" 8 | "github.com/docker/engine-api/types/filters" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | // VolumeList returns the volumes configured in the docker host. 13 | func (cli *Client) VolumeList(ctx context.Context, filter filters.Args) (types.VolumesListResponse, error) { 14 | var volumes types.VolumesListResponse 15 | query := url.Values{} 16 | 17 | if filter.Len() > 0 { 18 | filterJSON, err := filters.ToParam(filter) 19 | if err != nil { 20 | return volumes, err 21 | } 22 | query.Set("filters", filterJSON) 23 | } 24 | resp, err := cli.get(ctx, "/volumes", query, nil) 25 | if err != nil { 26 | return volumes, err 27 | } 28 | 29 | err = json.NewDecoder(resp.body).Decode(&volumes) 30 | ensureReaderClosed(resp) 31 | return volumes, err 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/client/volume_remove.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import "golang.org/x/net/context" 4 | 5 | // VolumeRemove removes a volume from the docker host. 6 | func (cli *Client) VolumeRemove(ctx context.Context, volumeID string) error { 7 | resp, err := cli.delete(ctx, "/volumes/"+volumeID, nil, nil) 8 | ensureReaderClosed(resp) 9 | return err 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/types/auth.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // AuthConfig contains authorization information for connecting to a Registry 4 | type AuthConfig struct { 5 | Username string `json:"username,omitempty"` 6 | Password string `json:"password,omitempty"` 7 | Auth string `json:"auth,omitempty"` 8 | 9 | // Email is an optional value associated with the username. 10 | // This field is deprecated and will be removed in a later 11 | // version of docker. 12 | Email string `json:"email,omitempty"` 13 | 14 | ServerAddress string `json:"serveraddress,omitempty"` 15 | 16 | // IdentityToken is used to authenticate the user and get 17 | // an access token for the registry. 18 | IdentityToken string `json:"identitytoken,omitempty"` 19 | 20 | // RegistryToken is a bearer token to be sent to a registry 21 | RegistryToken string `json:"registrytoken,omitempty"` 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/types/blkiodev/blkio.go: -------------------------------------------------------------------------------- 1 | package blkiodev 2 | 3 | import "fmt" 4 | 5 | // WeightDevice is a structure that holds device:weight pair 6 | type WeightDevice struct { 7 | Path string 8 | Weight uint16 9 | } 10 | 11 | func (w *WeightDevice) String() string { 12 | return fmt.Sprintf("%s:%d", w.Path, w.Weight) 13 | } 14 | 15 | // ThrottleDevice is a structure that holds device:rate_per_second pair 16 | type ThrottleDevice struct { 17 | Path string 18 | Rate uint64 19 | } 20 | 21 | func (t *ThrottleDevice) String() string { 22 | return fmt.Sprintf("%s:%d", t.Path, t.Rate) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/types/configs.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/docker/engine-api/types/container" 5 | "github.com/docker/engine-api/types/network" 6 | ) 7 | 8 | // configs holds structs used for internal communication between the 9 | // frontend (such as an http server) and the backend (such as the 10 | // docker daemon). 11 | 12 | // ContainerCreateConfig is the parameter set to ContainerCreate() 13 | type ContainerCreateConfig struct { 14 | Name string 15 | Config *container.Config 16 | HostConfig *container.HostConfig 17 | NetworkingConfig *network.NetworkingConfig 18 | AdjustCPUShares bool 19 | } 20 | 21 | // ContainerRmConfig holds arguments for the container remove 22 | // operation. This struct is used to tell the backend what operations 23 | // to perform. 24 | type ContainerRmConfig struct { 25 | ForceRemove, RemoveVolume, RemoveLink bool 26 | } 27 | 28 | // ContainerCommitConfig contains build configs for commit operation, 29 | // and is used when making a commit with the current state of the container. 30 | type ContainerCommitConfig struct { 31 | Pause bool 32 | Repo string 33 | Tag string 34 | Author string 35 | Comment string 36 | // merge container config into commit config before commit 37 | MergeConfigs bool 38 | Config *container.Config 39 | } 40 | 41 | // ExecConfig is a small subset of the Config struct that holds the configuration 42 | // for the exec feature of docker. 43 | type ExecConfig struct { 44 | User string // User that will run the command 45 | Privileged bool // Is the container in privileged mode 46 | Tty bool // Attach standard streams to a tty. 47 | AttachStdin bool // Attach the standard input, makes possible user interaction 48 | AttachStderr bool // Attach the standard output 49 | AttachStdout bool // Attach the standard error 50 | Detach bool // Execute in detach mode 51 | DetachKeys string // Escape keys for detach 52 | Cmd []string // Execution commands and args 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/types/events/events.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | const ( 4 | // ContainerEventType is the event type that containers generate 5 | ContainerEventType = "container" 6 | // ImageEventType is the event type that images generate 7 | ImageEventType = "image" 8 | // VolumeEventType is the event type that volumes generate 9 | VolumeEventType = "volume" 10 | // NetworkEventType is the event type that networks generate 11 | NetworkEventType = "network" 12 | ) 13 | 14 | // Actor describes something that generates events, 15 | // like a container, or a network, or a volume. 16 | // It has a defined name and a set or attributes. 17 | // The container attributes are its labels, other actors 18 | // can generate these attributes from other properties. 19 | type Actor struct { 20 | ID string 21 | Attributes map[string]string 22 | } 23 | 24 | // Message represents the information an event contains 25 | type Message struct { 26 | // Deprecated information from JSONMessage. 27 | // With data only in container events. 28 | Status string `json:"status,omitempty"` 29 | ID string `json:"id,omitempty"` 30 | From string `json:"from,omitempty"` 31 | 32 | Type string 33 | Action string 34 | Actor Actor 35 | 36 | Time int64 `json:"time,omitempty"` 37 | TimeNano int64 `json:"timeNano,omitempty"` 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/types/network/network.go: -------------------------------------------------------------------------------- 1 | package network 2 | 3 | // Address represents an IP address 4 | type Address struct { 5 | Addr string 6 | PrefixLen int 7 | } 8 | 9 | // IPAM represents IP Address Management 10 | type IPAM struct { 11 | Driver string 12 | Options map[string]string //Per network IPAM driver options 13 | Config []IPAMConfig 14 | } 15 | 16 | // IPAMConfig represents IPAM configurations 17 | type IPAMConfig struct { 18 | Subnet string `json:",omitempty"` 19 | IPRange string `json:",omitempty"` 20 | Gateway string `json:",omitempty"` 21 | AuxAddress map[string]string `json:"AuxiliaryAddresses,omitempty"` 22 | } 23 | 24 | // EndpointIPAMConfig represents IPAM configurations for the endpoint 25 | type EndpointIPAMConfig struct { 26 | IPv4Address string `json:",omitempty"` 27 | IPv6Address string `json:",omitempty"` 28 | } 29 | 30 | // EndpointSettings stores the network endpoint details 31 | type EndpointSettings struct { 32 | // Configurations 33 | IPAMConfig *EndpointIPAMConfig 34 | Links []string 35 | Aliases []string 36 | // Operational data 37 | NetworkID string 38 | EndpointID string 39 | Gateway string 40 | IPAddress string 41 | IPPrefixLen int 42 | IPv6Gateway string 43 | GlobalIPv6Address string 44 | GlobalIPv6PrefixLen int 45 | MacAddress string 46 | } 47 | 48 | // NetworkingConfig represents the container's networking configuration for each of its interfaces 49 | // Carries the networking configs specified in the `docker run` and `docker network connect` commands 50 | type NetworkingConfig struct { 51 | EndpointsConfig map[string]*EndpointSettings // Endpoint configs for each connecting network 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/types/reference/image_reference.go: -------------------------------------------------------------------------------- 1 | package reference 2 | 3 | import ( 4 | distreference "github.com/docker/distribution/reference" 5 | ) 6 | 7 | // Parse parses the given references and returns the repository and 8 | // tag (if present) from it. If there is an error during parsing, it will 9 | // return an error. 10 | func Parse(ref string) (string, string, error) { 11 | distributionRef, err := distreference.ParseNamed(ref) 12 | if err != nil { 13 | return "", "", err 14 | } 15 | 16 | tag := GetTagFromNamedRef(distributionRef) 17 | return distributionRef.Name(), tag, nil 18 | } 19 | 20 | // GetTagFromNamedRef returns a tag from the specified reference. 21 | // This function is necessary as long as the docker "server" api makes the distinction between repository 22 | // and tags. 23 | func GetTagFromNamedRef(ref distreference.Named) string { 24 | var tag string 25 | switch x := ref.(type) { 26 | case distreference.Digested: 27 | tag = x.Digest().String() 28 | case distreference.NamedTagged: 29 | tag = x.Tag() 30 | } 31 | return tag 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/types/strslice/strslice.go: -------------------------------------------------------------------------------- 1 | package strslice 2 | 3 | import "encoding/json" 4 | 5 | // StrSlice represents a string or an array of strings. 6 | // We need to override the json decoder to accept both options. 7 | type StrSlice []string 8 | 9 | // UnmarshalJSON decodes the byte slice whether it's a string or an array of 10 | // strings. This method is needed to implement json.Unmarshaler. 11 | func (e *StrSlice) UnmarshalJSON(b []byte) error { 12 | if len(b) == 0 { 13 | // With no input, we preserve the existing value by returning nil and 14 | // leaving the target alone. This allows defining default values for 15 | // the type. 16 | return nil 17 | } 18 | 19 | p := make([]string, 0, 1) 20 | if err := json.Unmarshal(b, &p); err != nil { 21 | var s string 22 | if err := json.Unmarshal(b, &s); err != nil { 23 | return err 24 | } 25 | p = append(p, s) 26 | } 27 | 28 | *e = p 29 | return nil 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/types/versions/README.md: -------------------------------------------------------------------------------- 1 | ## Legacy API type versions 2 | 3 | This package includes types for legacy API versions. The stable version of the API types live in `api/types/*.go`. 4 | 5 | Consider moving a type here when you need to keep backwards compatibility in the API. This legacy types are organized by the latest API version they appear in. For instance, types in the `v1p19` package are valid for API versions below or equal `1.19`. Types in the `v1p20` package are valid for the API version `1.20`, since the versions below that will use the legacy types in `v1p19`. 6 | 7 | ### Package name conventions 8 | 9 | The package name convention is to use `v` as a prefix for the version number and `p`(patch) as a separator. We use this nomenclature due to a few restrictions in the Go package name convention: 10 | 11 | 1. We cannot use `.` because it's interpreted by the language, think of `v1.20.CallFunction`. 12 | 2. We cannot use `_` because golint complains abount it. The code is actually valid, but it looks probably more weird: `v1_20.CallFunction`. 13 | 14 | For instance, if you want to modify a type that was available in the version `1.21` of the API but it will have different fields in the version `1.22`, you want to create a new package under `api/types/versions/v1p21`. 15 | -------------------------------------------------------------------------------- /vendor/github.com/docker/engine-api/types/versions/compare.go: -------------------------------------------------------------------------------- 1 | package versions 2 | 3 | import ( 4 | "strconv" 5 | "strings" 6 | ) 7 | 8 | // compare compares two version strings 9 | // returns -1 if v1 < v2, 1 if v1 > v2, 0 otherwise. 10 | func compare(v1, v2 string) int { 11 | var ( 12 | currTab = strings.Split(v1, ".") 13 | otherTab = strings.Split(v2, ".") 14 | ) 15 | 16 | max := len(currTab) 17 | if len(otherTab) > max { 18 | max = len(otherTab) 19 | } 20 | for i := 0; i < max; i++ { 21 | var currInt, otherInt int 22 | 23 | if len(currTab) > i { 24 | currInt, _ = strconv.Atoi(currTab[i]) 25 | } 26 | if len(otherTab) > i { 27 | otherInt, _ = strconv.Atoi(otherTab[i]) 28 | } 29 | if currInt > otherInt { 30 | return 1 31 | } 32 | if otherInt > currInt { 33 | return -1 34 | } 35 | } 36 | return 0 37 | } 38 | 39 | // LessThan checks if a version is less than another 40 | func LessThan(v, other string) bool { 41 | return compare(v, other) == -1 42 | } 43 | 44 | // LessThanOrEqualTo checks if a version is less than or equal to another 45 | func LessThanOrEqualTo(v, other string) bool { 46 | return compare(v, other) <= 0 47 | } 48 | 49 | // GreaterThan checks if a version is greater than another 50 | func GreaterThan(v, other string) bool { 51 | return compare(v, other) == 1 52 | } 53 | 54 | // GreaterThanOrEqualTo checks if a version is greater than or equal to another 55 | func GreaterThanOrEqualTo(v, other string) bool { 56 | return compare(v, other) >= 0 57 | } 58 | 59 | // Equal checks if a version is equal to another 60 | func Equal(v, other string) bool { 61 | return compare(v, other) == 0 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/MAINTAINERS: -------------------------------------------------------------------------------- 1 | # go-connections maintainers file 2 | # 3 | # This file describes who runs the docker/go-connections project and how. 4 | # This is a living document - if you see something out of date or missing, speak up! 5 | # 6 | # It is structured to be consumable by both humans and programs. 7 | # To extract its contents programmatically, use any TOML-compliant parser. 8 | # 9 | # This file is compiled into the MAINTAINERS file in docker/opensource. 10 | # 11 | [Org] 12 | [Org."Core maintainers"] 13 | people = [ 14 | "calavera", 15 | ] 16 | 17 | [people] 18 | 19 | # A reference list of all people associated with the project. 20 | # All other sections should refer to people by their canonical key 21 | # in the people section. 22 | 23 | # ADD YOURSELF HERE IN ALPHABETICAL ORDER 24 | [people.calavera] 25 | Name = "David Calavera" 26 | Email = "david.calavera@gmail.com" 27 | GitHub = "calavera" 28 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/docker/go-connections?status.svg)](https://godoc.org/github.com/docker/go-connections) 2 | 3 | # Introduction 4 | 5 | go-connections provides common package to work with network connections. 6 | 7 | ## Usage 8 | 9 | See the [docs in godoc](https://godoc.org/github.com/docker/go-connections) for examples and documentation. 10 | 11 | ## License 12 | 13 | go-connections is licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for the full license text. 14 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/circle.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | pre: 3 | # setup ipv6 4 | - sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0 net.ipv6.conf.default.disable_ipv6=0 net.ipv6.conf.all.disable_ipv6=0 5 | post: 6 | # install golint 7 | - go get github.com/golang/lint/golint 8 | 9 | test: 10 | pre: 11 | # run analysis before tests 12 | - go vet ./... 13 | - test -z "$(golint ./... | tee /dev/stderr)" 14 | - test -z "$(gofmt -s -l . | tee /dev/stderr)" 15 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/nat/parse.go: -------------------------------------------------------------------------------- 1 | package nat 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "strings" 7 | ) 8 | 9 | // PartParser parses and validates the specified string (data) using the specified template 10 | // e.g. ip:public:private -> 192.168.0.1:80:8000 11 | func PartParser(template, data string) (map[string]string, error) { 12 | // ip:public:private 13 | var ( 14 | templateParts = strings.Split(template, ":") 15 | parts = strings.Split(data, ":") 16 | out = make(map[string]string, len(templateParts)) 17 | ) 18 | if len(parts) != len(templateParts) { 19 | return nil, fmt.Errorf("Invalid format to parse. %s should match template %s", data, template) 20 | } 21 | 22 | for i, t := range templateParts { 23 | value := "" 24 | if len(parts) > i { 25 | value = parts[i] 26 | } 27 | out[t] = value 28 | } 29 | return out, nil 30 | } 31 | 32 | // ParsePortRange parses and validates the specified string as a port-range (8000-9000) 33 | func ParsePortRange(ports string) (uint64, uint64, error) { 34 | if ports == "" { 35 | return 0, 0, fmt.Errorf("Empty string specified for ports.") 36 | } 37 | if !strings.Contains(ports, "-") { 38 | start, err := strconv.ParseUint(ports, 10, 16) 39 | end := start 40 | return start, end, err 41 | } 42 | 43 | parts := strings.Split(ports, "-") 44 | start, err := strconv.ParseUint(parts[0], 10, 16) 45 | if err != nil { 46 | return 0, 0, err 47 | } 48 | end, err := strconv.ParseUint(parts[1], 10, 16) 49 | if err != nil { 50 | return 0, 0, err 51 | } 52 | if end < start { 53 | return 0, 0, fmt.Errorf("Invalid range specified for the Port: %s", ports) 54 | } 55 | return start, end, nil 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/sockets/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rancher/secrets-bridge/cbda250c0f17e2107c8a0eee348a4a405b139c6d/vendor/github.com/docker/go-connections/sockets/README.md -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/sockets/proxy.go: -------------------------------------------------------------------------------- 1 | package sockets 2 | 3 | import ( 4 | "net" 5 | "net/url" 6 | "os" 7 | "strings" 8 | 9 | "golang.org/x/net/proxy" 10 | ) 11 | 12 | // GetProxyEnv allows access to the uppercase and the lowercase forms of 13 | // proxy-related variables. See the Go specification for details on these 14 | // variables. https://golang.org/pkg/net/http/ 15 | func GetProxyEnv(key string) string { 16 | proxyValue := os.Getenv(strings.ToUpper(key)) 17 | if proxyValue == "" { 18 | return os.Getenv(strings.ToLower(key)) 19 | } 20 | return proxyValue 21 | } 22 | 23 | // DialerFromEnvironment takes in a "direct" *net.Dialer and returns a 24 | // proxy.Dialer which will route the connections through the proxy using the 25 | // given dialer. 26 | func DialerFromEnvironment(direct *net.Dialer) (proxy.Dialer, error) { 27 | allProxy := GetProxyEnv("all_proxy") 28 | if len(allProxy) == 0 { 29 | return direct, nil 30 | } 31 | 32 | proxyURL, err := url.Parse(allProxy) 33 | if err != nil { 34 | return direct, err 35 | } 36 | 37 | proxyFromURL, err := proxy.FromURL(proxyURL, direct) 38 | if err != nil { 39 | return direct, err 40 | } 41 | 42 | noProxy := GetProxyEnv("no_proxy") 43 | if len(noProxy) == 0 { 44 | return proxyFromURL, nil 45 | } 46 | 47 | perHost := proxy.NewPerHost(proxyFromURL, direct) 48 | perHost.AddFromString(noProxy) 49 | 50 | return perHost, nil 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/sockets/sockets.go: -------------------------------------------------------------------------------- 1 | // Package sockets provides helper functions to create and configure Unix or TCP sockets. 2 | package sockets 3 | 4 | import ( 5 | "net" 6 | "net/http" 7 | "time" 8 | ) 9 | 10 | // Why 32? See https://github.com/docker/docker/pull/8035. 11 | const defaultTimeout = 32 * time.Second 12 | 13 | // ConfigureTransport configures the specified Transport according to the 14 | // specified proto and addr. 15 | // If the proto is unix (using a unix socket to communicate) or npipe the 16 | // compression is disabled. 17 | func ConfigureTransport(tr *http.Transport, proto, addr string) error { 18 | switch proto { 19 | case "unix": 20 | // No need for compression in local communications. 21 | tr.DisableCompression = true 22 | tr.Dial = func(_, _ string) (net.Conn, error) { 23 | return net.DialTimeout(proto, addr, defaultTimeout) 24 | } 25 | case "npipe": 26 | // No need for compression in local communications. 27 | tr.DisableCompression = true 28 | tr.Dial = func(_, _ string) (net.Conn, error) { 29 | return DialPipe(addr, defaultTimeout) 30 | } 31 | default: 32 | tr.Proxy = http.ProxyFromEnvironment 33 | dialer, err := DialerFromEnvironment(&net.Dialer{ 34 | Timeout: defaultTimeout, 35 | }) 36 | if err != nil { 37 | return err 38 | } 39 | tr.Dial = dialer.Dial 40 | } 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/sockets/sockets_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package sockets 4 | 5 | import ( 6 | "net" 7 | "syscall" 8 | "time" 9 | ) 10 | 11 | // DialPipe connects to a Windows named pipe. 12 | // This is not supported on other OSes. 13 | func DialPipe(_ string, _ time.Duration) (net.Conn, error) { 14 | return nil, syscall.EAFNOSUPPORT 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/sockets/sockets_windows.go: -------------------------------------------------------------------------------- 1 | package sockets 2 | 3 | import ( 4 | "net" 5 | "time" 6 | 7 | "github.com/Microsoft/go-winio" 8 | ) 9 | 10 | // DialPipe connects to a Windows named pipe. 11 | func DialPipe(addr string, timeout time.Duration) (net.Conn, error) { 12 | return winio.DialPipe(addr, &timeout) 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/sockets/tcp_socket.go: -------------------------------------------------------------------------------- 1 | // Package sockets provides helper functions to create and configure Unix or TCP sockets. 2 | package sockets 3 | 4 | import ( 5 | "crypto/tls" 6 | "net" 7 | ) 8 | 9 | // NewTCPSocket creates a TCP socket listener with the specified address and 10 | // and the specified tls configuration. If TLSConfig is set, will encapsulate the 11 | // TCP listener inside a TLS one. 12 | func NewTCPSocket(addr string, tlsConfig *tls.Config) (net.Listener, error) { 13 | l, err := net.Listen("tcp", addr) 14 | if err != nil { 15 | return nil, err 16 | } 17 | if tlsConfig != nil { 18 | tlsConfig.NextProtos = []string{"http/1.1"} 19 | l = tls.NewListener(l, tlsConfig) 20 | } 21 | return l, nil 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/tlsconfig/config_client_ciphers.go: -------------------------------------------------------------------------------- 1 | // +build go1.5 2 | 3 | // Package tlsconfig provides primitives to retrieve secure-enough TLS configurations for both clients and servers. 4 | // 5 | package tlsconfig 6 | 7 | import ( 8 | "crypto/tls" 9 | ) 10 | 11 | // Client TLS cipher suites (dropping CBC ciphers for client preferred suite set) 12 | var clientCipherSuites = []uint16{ 13 | tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, 14 | tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, 15 | tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 16 | tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-connections/tlsconfig/config_legacy_client_ciphers.go: -------------------------------------------------------------------------------- 1 | // +build !go1.5 2 | 3 | // Package tlsconfig provides primitives to retrieve secure-enough TLS configurations for both clients and servers. 4 | // 5 | package tlsconfig 6 | 7 | import ( 8 | "crypto/tls" 9 | ) 10 | 11 | // Client TLS cipher suites (dropping CBC ciphers for client preferred suite set) 12 | var clientCipherSuites = []uint16{ 13 | tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 14 | tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-units/MAINTAINERS: -------------------------------------------------------------------------------- 1 | # go-connections maintainers file 2 | # 3 | # This file describes who runs the docker/go-connections project and how. 4 | # This is a living document - if you see something out of date or missing, speak up! 5 | # 6 | # It is structured to be consumable by both humans and programs. 7 | # To extract its contents programmatically, use any TOML-compliant parser. 8 | # 9 | # This file is compiled into the MAINTAINERS file in docker/opensource. 10 | # 11 | [Org] 12 | [Org."Core maintainers"] 13 | people = [ 14 | "calavera", 15 | ] 16 | 17 | [people] 18 | 19 | # A reference list of all people associated with the project. 20 | # All other sections should refer to people by their canonical key 21 | # in the people section. 22 | 23 | # ADD YOURSELF HERE IN ALPHABETICAL ORDER 24 | [people.calavera] 25 | Name = "David Calavera" 26 | Email = "david.calavera@gmail.com" 27 | GitHub = "calavera" 28 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-units/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/docker/go-units?status.svg)](https://godoc.org/github.com/docker/go-units) 2 | 3 | # Introduction 4 | 5 | go-units is a library to transform human friendly measurements into machine friendly values. 6 | 7 | ## Usage 8 | 9 | See the [docs in godoc](https://godoc.org/github.com/docker/go-units) for examples and documentation. 10 | 11 | ## Copyright and license 12 | 13 | Copyright © 2015 Docker, Inc. All rights reserved, except as follows. Code 14 | is released under the Apache 2.0 license. The README.md file, and files in the 15 | "docs" folder are licensed under the Creative Commons Attribution 4.0 16 | International License under the terms and conditions set forth in the file 17 | "LICENSE.docs". You may obtain a duplicate copy of the same license, titled 18 | CC-BY-SA-4.0, at http://creativecommons.org/licenses/by/4.0/. 19 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-units/circle.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | post: 3 | # install golint 4 | - go get github.com/golang/lint/golint 5 | 6 | test: 7 | pre: 8 | # run analysis before tests 9 | - go vet ./... 10 | - test -z "$(golint ./... | tee /dev/stderr)" 11 | - test -z "$(gofmt -s -l . | tee /dev/stderr)" 12 | -------------------------------------------------------------------------------- /vendor/github.com/docker/go-units/duration.go: -------------------------------------------------------------------------------- 1 | // Package units provides helper function to parse and print size and time units 2 | // in human-readable format. 3 | package units 4 | 5 | import ( 6 | "fmt" 7 | "time" 8 | ) 9 | 10 | // HumanDuration returns a human-readable approximation of a duration 11 | // (eg. "About a minute", "4 hours ago", etc.). 12 | func HumanDuration(d time.Duration) string { 13 | if seconds := int(d.Seconds()); seconds < 1 { 14 | return "Less than a second" 15 | } else if seconds < 60 { 16 | return fmt.Sprintf("%d seconds", seconds) 17 | } else if minutes := int(d.Minutes()); minutes == 1 { 18 | return "About a minute" 19 | } else if minutes < 60 { 20 | return fmt.Sprintf("%d minutes", minutes) 21 | } else if hours := int(d.Hours()); hours == 1 { 22 | return "About an hour" 23 | } else if hours < 48 { 24 | return fmt.Sprintf("%d hours", hours) 25 | } else if hours < 24*7*2 { 26 | return fmt.Sprintf("%d days", hours/24) 27 | } else if hours < 24*30*3 { 28 | return fmt.Sprintf("%d weeks", hours/24/7) 29 | } else if hours < 24*365*2 { 30 | return fmt.Sprintf("%d months", hours/24/30) 31 | } 32 | return fmt.Sprintf("%d years", int(d.Hours())/24/365) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/structs/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/structs/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.6 4 | - tip 5 | sudo: false 6 | before_install: 7 | - go get github.com/axw/gocov/gocov 8 | - go get github.com/mattn/goveralls 9 | - if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi 10 | script: 11 | - $HOME/gopath/bin/goveralls -service=travis-ci 12 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/structs/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Fatih Arslan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /vendor/github.com/fatih/structs/tags.go: -------------------------------------------------------------------------------- 1 | package structs 2 | 3 | import "strings" 4 | 5 | // tagOptions contains a slice of tag options 6 | type tagOptions []string 7 | 8 | // Has returns true if the given optiton is available in tagOptions 9 | func (t tagOptions) Has(opt string) bool { 10 | for _, tagOpt := range t { 11 | if tagOpt == opt { 12 | return true 13 | } 14 | } 15 | 16 | return false 17 | } 18 | 19 | // parseTag splits a struct field's tag into its name and a list of options 20 | // which comes after a name. A tag is in the form of: "name,option1,option2". 21 | // The name can be neglectected. 22 | func parseTag(tag string) (string, tagOptions) { 23 | // tag is one of followings: 24 | // "" 25 | // "name" 26 | // "name,opt" 27 | // "name,opt,opt2" 28 | // ",opt" 29 | 30 | res := strings.Split(tag, ",") 31 | return res[0], res[1:] 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | matrix: 5 | include: 6 | - go: 1.3 7 | - go: 1.4 8 | - go: 1.5 9 | - go: 1.6 10 | - go: tip 11 | allow_failures: 12 | - go: tip 13 | 14 | script: 15 | - go get -t -v ./... 16 | - diff -u <(echo -n) <(gofmt -d .) 17 | - go vet $(go list ./... | grep -v /vendor/) 18 | - go test -v -race ./... 19 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/README.md: -------------------------------------------------------------------------------- 1 | context 2 | ======= 3 | [![Build Status](https://travis-ci.org/gorilla/context.png?branch=master)](https://travis-ci.org/gorilla/context) 4 | 5 | gorilla/context is a general purpose registry for global request variables. 6 | 7 | Read the full documentation here: http://www.gorillatoolkit.org/pkg/context 8 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | matrix: 5 | include: 6 | - go: 1.2 7 | - go: 1.3 8 | - go: 1.4 9 | - go: 1.5 10 | - go: 1.6 11 | - go: tip 12 | 13 | script: 14 | - go get -t -v ./... 15 | - diff -u <(echo -n) <(gofmt -d .) 16 | - go tool vet . 17 | - go test -v -race ./... 18 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | matrix: 5 | include: 6 | - go: 1.2 7 | - go: 1.3 8 | - go: 1.4 9 | - go: 1.5 10 | - go: 1.6 11 | - go: tip 12 | 13 | install: 14 | - go get golang.org/x/tools/cmd/vet 15 | 16 | script: 17 | - go get -t -v ./... 18 | - diff -u <(echo -n) <(gofmt -d .) 19 | - go vet . 20 | - go test -v -race ./... 21 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of Gorilla WebSocket authors for copyright 2 | # purposes. 3 | # 4 | # Please keep the list sorted. 5 | 6 | Gary Burd 7 | Joachim Bauch 8 | 9 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 17 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 21 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/json.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package websocket 6 | 7 | import ( 8 | "encoding/json" 9 | "io" 10 | ) 11 | 12 | // WriteJSON is deprecated, use c.WriteJSON instead. 13 | func WriteJSON(c *Conn, v interface{}) error { 14 | return c.WriteJSON(v) 15 | } 16 | 17 | // WriteJSON writes the JSON encoding of v to the connection. 18 | // 19 | // See the documentation for encoding/json Marshal for details about the 20 | // conversion of Go values to JSON. 21 | func (c *Conn) WriteJSON(v interface{}) error { 22 | w, err := c.NextWriter(TextMessage) 23 | if err != nil { 24 | return err 25 | } 26 | err1 := json.NewEncoder(w).Encode(v) 27 | err2 := w.Close() 28 | if err1 != nil { 29 | return err1 30 | } 31 | return err2 32 | } 33 | 34 | // ReadJSON is deprecated, use c.ReadJSON instead. 35 | func ReadJSON(c *Conn, v interface{}) error { 36 | return c.ReadJSON(v) 37 | } 38 | 39 | // ReadJSON reads the next JSON-encoded message from the connection and stores 40 | // it in the value pointed to by v. 41 | // 42 | // See the documentation for the encoding/json Unmarshal function for details 43 | // about the conversion of JSON to a Go value. 44 | func (c *Conn) ReadJSON(v interface{}) error { 45 | _, r, err := c.NextReader() 46 | if err != nil { 47 | return err 48 | } 49 | err = json.NewDecoder(r).Decode(v) 50 | if err == io.EOF { 51 | // One value is expected in the message. 52 | err = io.ErrUnexpectedEOF 53 | } 54 | return err 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/websocket/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package websocket 6 | 7 | import ( 8 | "crypto/rand" 9 | "crypto/sha1" 10 | "encoding/base64" 11 | "io" 12 | "net/http" 13 | "strings" 14 | ) 15 | 16 | // tokenListContainsValue returns true if the 1#token header with the given 17 | // name contains token. 18 | func tokenListContainsValue(header http.Header, name string, value string) bool { 19 | for _, v := range header[name] { 20 | for _, s := range strings.Split(v, ",") { 21 | if strings.EqualFold(value, strings.TrimSpace(s)) { 22 | return true 23 | } 24 | } 25 | } 26 | return false 27 | } 28 | 29 | var keyGUID = []byte("258EAFA5-E914-47DA-95CA-C5AB0DC85B11") 30 | 31 | func computeAcceptKey(challengeKey string) string { 32 | h := sha1.New() 33 | h.Write([]byte(challengeKey)) 34 | h.Write(keyGUID) 35 | return base64.StdEncoding.EncodeToString(h.Sum(nil)) 36 | } 37 | 38 | func generateChallengeKey() (string, error) { 39 | p := make([]byte, 16) 40 | if _, err := io.ReadFull(rand.Reader, p); err != nil { 41 | return "", err 42 | } 43 | return base64.StdEncoding.EncodeToString(p), nil 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-cleanhttp/README.md: -------------------------------------------------------------------------------- 1 | # cleanhttp 2 | 3 | Functions for accessing "clean" Go http.Client values 4 | 5 | ------------- 6 | 7 | The Go standard library contains a default `http.Client` called 8 | `http.DefaultClient`. It is a common idiom in Go code to start with 9 | `http.DefaultClient` and tweak it as necessary, and in fact, this is 10 | encouraged; from the `http` package documentation: 11 | 12 | > The Client's Transport typically has internal state (cached TCP connections), 13 | so Clients should be reused instead of created as needed. Clients are safe for 14 | concurrent use by multiple goroutines. 15 | 16 | Unfortunately, this is a shared value, and it is not uncommon for libraries to 17 | assume that they are free to modify it at will. With enough dependencies, it 18 | can be very easy to encounter strange problems and race conditions due to 19 | manipulation of this shared value across libraries and goroutines (clients are 20 | safe for concurrent use, but writing values to the client struct itself is not 21 | protected). 22 | 23 | Making things worse is the fact that a bare `http.Client` will use a default 24 | `http.Transport` called `http.DefaultTransport`, which is another global value 25 | that behaves the same way. So it is not simply enough to replace 26 | `http.DefaultClient` with `&http.Client{}`. 27 | 28 | This repository provides some simple functions to get a "clean" `http.Client` 29 | -- one that uses the same default values as the Go standard library, but 30 | returns a client that does not share any state with other clients. 31 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go: -------------------------------------------------------------------------------- 1 | package cleanhttp 2 | 3 | import ( 4 | "net" 5 | "net/http" 6 | "time" 7 | ) 8 | 9 | // DefaultTransport returns a new http.Transport with the same default values 10 | // as http.DefaultTransport, but with idle connections and keepalives disabled. 11 | func DefaultTransport() *http.Transport { 12 | transport := DefaultPooledTransport() 13 | transport.DisableKeepAlives = true 14 | transport.MaxIdleConnsPerHost = -1 15 | return transport 16 | } 17 | 18 | // DefaultPooledTransport returns a new http.Transport with similar default 19 | // values to http.DefaultTransport. Do not use this for transient transports as 20 | // it can leak file descriptors over time. Only use this for transports that 21 | // will be re-used for the same host(s). 22 | func DefaultPooledTransport() *http.Transport { 23 | transport := &http.Transport{ 24 | Proxy: http.ProxyFromEnvironment, 25 | Dial: (&net.Dialer{ 26 | Timeout: 30 * time.Second, 27 | KeepAlive: 30 * time.Second, 28 | }).Dial, 29 | TLSHandshakeTimeout: 10 * time.Second, 30 | DisableKeepAlives: false, 31 | MaxIdleConnsPerHost: 1, 32 | } 33 | return transport 34 | } 35 | 36 | // DefaultClient returns a new http.Client with similar default values to 37 | // http.Client, but with a non-shared Transport, idle connections disabled, and 38 | // keepalives disabled. 39 | func DefaultClient() *http.Client { 40 | return &http.Client{ 41 | Transport: DefaultTransport(), 42 | } 43 | } 44 | 45 | // DefaultPooledClient returns a new http.Client with the same default values 46 | // as http.Client, but with a shared Transport. Do not use this function 47 | // for transient clients as it can leak file descriptors over time. Only use 48 | // this for clients that will be re-used for the same host(s). 49 | func DefaultPooledClient() *http.Client { 50 | return &http.Client{ 51 | Transport: DefaultPooledTransport(), 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-cleanhttp/doc.go: -------------------------------------------------------------------------------- 1 | // Package cleanhttp offers convenience utilities for acquiring "clean" 2 | // http.Transport and http.Client structs. 3 | // 4 | // Values set on http.DefaultClient and http.DefaultTransport affect all 5 | // callers. This can have detrimental effects, esepcially in TLS contexts, 6 | // where client or root certificates set to talk to multiple endpoints can end 7 | // up displacing each other, leading to hard-to-debug issues. This package 8 | // provides non-shared http.Client and http.Transport structs to ensure that 9 | // the configuration will not be overwritten by other parts of the application 10 | // or dependencies. 11 | // 12 | // The DefaultClient and DefaultTransport functions disable idle connections 13 | // and keepalives. Without ensuring that idle connections are closed before 14 | // garbage collection, short-term clients/transports can leak file descriptors, 15 | // eventually leading to "too many open files" errors. If you will be 16 | // connecting to the same hosts repeatedly from the same client, you can use 17 | // DefaultPooledClient to receive a client that has connection pooling 18 | // semantics similar to http.DefaultClient. 19 | // 20 | package cleanhttp 21 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-multierror/append.go: -------------------------------------------------------------------------------- 1 | package multierror 2 | 3 | // Append is a helper function that will append more errors 4 | // onto an Error in order to create a larger multi-error. 5 | // 6 | // If err is not a multierror.Error, then it will be turned into 7 | // one. If any of the errs are multierr.Error, they will be flattened 8 | // one level into err. 9 | func Append(err error, errs ...error) *Error { 10 | switch err := err.(type) { 11 | case *Error: 12 | // Typed nils can reach here, so initialize if we are nil 13 | if err == nil { 14 | err = new(Error) 15 | } 16 | 17 | // Go through each error and flatten 18 | for _, e := range errs { 19 | switch e := e.(type) { 20 | case *Error: 21 | err.Errors = append(err.Errors, e.Errors...) 22 | default: 23 | err.Errors = append(err.Errors, e) 24 | } 25 | } 26 | 27 | return err 28 | default: 29 | newErrs := make([]error, 0, len(errs)+1) 30 | if err != nil { 31 | newErrs = append(newErrs, err) 32 | } 33 | newErrs = append(newErrs, errs...) 34 | 35 | return Append(&Error{}, newErrs...) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-multierror/flatten.go: -------------------------------------------------------------------------------- 1 | package multierror 2 | 3 | // Flatten flattens the given error, merging any *Errors together into 4 | // a single *Error. 5 | func Flatten(err error) error { 6 | // If it isn't an *Error, just return the error as-is 7 | if _, ok := err.(*Error); !ok { 8 | return err 9 | } 10 | 11 | // Otherwise, make the result and flatten away! 12 | flatErr := new(Error) 13 | flatten(err, flatErr) 14 | return flatErr 15 | } 16 | 17 | func flatten(err error, flatErr *Error) { 18 | switch err := err.(type) { 19 | case *Error: 20 | for _, e := range err.Errors { 21 | flatten(e, flatErr) 22 | } 23 | default: 24 | flatErr.Errors = append(flatErr.Errors, err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-multierror/format.go: -------------------------------------------------------------------------------- 1 | package multierror 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // ErrorFormatFunc is a function callback that is called by Error to 9 | // turn the list of errors into a string. 10 | type ErrorFormatFunc func([]error) string 11 | 12 | // ListFormatFunc is a basic formatter that outputs the number of errors 13 | // that occurred along with a bullet point list of the errors. 14 | func ListFormatFunc(es []error) string { 15 | points := make([]string, len(es)) 16 | for i, err := range es { 17 | points[i] = fmt.Sprintf("* %s", err) 18 | } 19 | 20 | return fmt.Sprintf( 21 | "%d error(s) occurred:\n\n%s", 22 | len(es), strings.Join(points, "\n")) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-multierror/multierror.go: -------------------------------------------------------------------------------- 1 | package multierror 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | // Error is an error type to track multiple errors. This is used to 8 | // accumulate errors in cases and return them as a single "error". 9 | type Error struct { 10 | Errors []error 11 | ErrorFormat ErrorFormatFunc 12 | } 13 | 14 | func (e *Error) Error() string { 15 | fn := e.ErrorFormat 16 | if fn == nil { 17 | fn = ListFormatFunc 18 | } 19 | 20 | return fn(e.Errors) 21 | } 22 | 23 | // ErrorOrNil returns an error interface if this Error represents 24 | // a list of errors, or returns nil if the list of errors is empty. This 25 | // function is useful at the end of accumulation to make sure that the value 26 | // returned represents the existence of errors. 27 | func (e *Error) ErrorOrNil() error { 28 | if e == nil { 29 | return nil 30 | } 31 | if len(e.Errors) == 0 { 32 | return nil 33 | } 34 | 35 | return e 36 | } 37 | 38 | func (e *Error) GoString() string { 39 | return fmt.Sprintf("*%#v", *e) 40 | } 41 | 42 | // WrappedErrors returns the list of errors that this Error is wrapping. 43 | // It is an implementatin of the errwrap.Wrapper interface so that 44 | // multierror.Error can be used with that library. 45 | // 46 | // This method is not safe to be called concurrently and is no different 47 | // than accessing the Errors field directly. It is implementd only to 48 | // satisfy the errwrap.Wrapper interface. 49 | func (e *Error) WrappedErrors() []error { 50 | return e.Errors 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-multierror/prefix.go: -------------------------------------------------------------------------------- 1 | package multierror 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/hashicorp/errwrap" 7 | ) 8 | 9 | // Prefix is a helper function that will prefix some text 10 | // to the given error. If the error is a multierror.Error, then 11 | // it will be prefixed to each wrapped error. 12 | // 13 | // This is useful to use when appending multiple multierrors 14 | // together in order to give better scoping. 15 | func Prefix(err error, prefix string) error { 16 | if err == nil { 17 | return nil 18 | } 19 | 20 | format := fmt.Sprintf("%s {{err}}", prefix) 21 | switch err := err.(type) { 22 | case *Error: 23 | // Typed nils can reach here, so initialize if we are nil 24 | if err == nil { 25 | err = new(Error) 26 | } 27 | 28 | // Wrap each of the errors 29 | for i, e := range err.Errors { 30 | err.Errors[i] = errwrap.Wrapf(format, e) 31 | } 32 | 33 | return err 34 | default: 35 | return errwrap.Wrapf(format, err) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-rootcerts/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | 3 | language: go 4 | 5 | go: 6 | - 1.6 7 | 8 | branches: 9 | only: 10 | - master 11 | 12 | script: make test 13 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-rootcerts/Makefile: -------------------------------------------------------------------------------- 1 | TEST?=./... 2 | 3 | test: 4 | go test $(TEST) $(TESTARGS) -timeout=3s -parallel=4 5 | go vet $(TEST) 6 | go test $(TEST) -race 7 | 8 | .PHONY: test 9 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-rootcerts/README.md: -------------------------------------------------------------------------------- 1 | # rootcerts 2 | 3 | Functions for loading root certificates for TLS connections. 4 | 5 | ----- 6 | 7 | Go's standard library `crypto/tls` provides a common mechanism for configuring 8 | TLS connections in `tls.Config`. The `RootCAs` field on this struct is a pool 9 | of certificates for the client to use as a trust store when verifying server 10 | certificates. 11 | 12 | This library contains utility functions for loading certificates destined for 13 | that field, as well as one other important thing: 14 | 15 | When the `RootCAs` field is `nil`, the standard library attempts to load the 16 | host's root CA set. This behavior is OS-specific, and the Darwin 17 | implementation contains [a bug that prevents trusted certificates from the 18 | System and Login keychains from being loaded][1]. This library contains 19 | Darwin-specific behavior that works around that bug. 20 | 21 | [1]: https://github.com/golang/go/issues/14514 22 | 23 | ## Example Usage 24 | 25 | Here's a snippet demonstrating how this library is meant to be used: 26 | 27 | ```go 28 | func httpClient() (*http.Client, error) 29 | tlsConfig := &tls.Config{} 30 | err := rootcerts.ConfigureTLS(tlsConfig, &rootcerts.Config{ 31 | CAFile: os.Getenv("MYAPP_CAFILE"), 32 | CAPath: os.Getenv("MYAPP_CAPATH"), 33 | }) 34 | if err != nil { 35 | return nil, err 36 | } 37 | c := cleanhttp.DefaultClient() 38 | t := cleanhttp.DefaultTransport() 39 | t.TLSClientConfig = tlsConfig 40 | c.Transport = t 41 | return c, nil 42 | } 43 | ``` 44 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-rootcerts/doc.go: -------------------------------------------------------------------------------- 1 | // Package rootcerts contains functions to aid in loading CA certificates for 2 | // TLS connections. 3 | // 4 | // In addition, its default behavior on Darwin works around an open issue [1] 5 | // in Go's crypto/x509 that prevents certicates from being loaded from the 6 | // System or Login keychains. 7 | // 8 | // [1] https://github.com/golang/go/issues/14514 9 | package rootcerts 10 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-rootcerts/rootcerts_base.go: -------------------------------------------------------------------------------- 1 | // +build !darwin 2 | 3 | package rootcerts 4 | 5 | import "crypto/x509" 6 | 7 | // LoadSystemCAs does nothing on non-Darwin systems. We return nil so that 8 | // default behavior of standard TLS config libraries is triggered, which is to 9 | // load system certs. 10 | func LoadSystemCAs() (*x509.CertPool, error) { 11 | return nil, nil 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-rootcerts/rootcerts_darwin.go: -------------------------------------------------------------------------------- 1 | package rootcerts 2 | 3 | import ( 4 | "crypto/x509" 5 | "os/exec" 6 | "path" 7 | 8 | "github.com/mitchellh/go-homedir" 9 | ) 10 | 11 | // LoadSystemCAs has special behavior on Darwin systems to work around 12 | func LoadSystemCAs() (*x509.CertPool, error) { 13 | pool := x509.NewCertPool() 14 | 15 | for _, keychain := range certKeychains() { 16 | err := addCertsFromKeychain(pool, keychain) 17 | if err != nil { 18 | return nil, err 19 | } 20 | } 21 | 22 | return pool, nil 23 | } 24 | 25 | func addCertsFromKeychain(pool *x509.CertPool, keychain string) error { 26 | cmd := exec.Command("/usr/bin/security", "find-certificate", "-a", "-p", keychain) 27 | data, err := cmd.Output() 28 | if err != nil { 29 | return err 30 | } 31 | 32 | pool.AppendCertsFromPEM(data) 33 | 34 | return nil 35 | } 36 | 37 | func certKeychains() []string { 38 | keychains := []string{ 39 | "/System/Library/Keychains/SystemRootCertificates.keychain", 40 | "/Library/Keychains/System.keychain", 41 | } 42 | home, err := homedir.Dir() 43 | if err == nil { 44 | loginKeychain := path.Join(home, "Library", "Keychains", "login.keychain") 45 | keychains = append(keychains, loginKeychain) 46 | } 47 | return keychains 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/.gitignore: -------------------------------------------------------------------------------- 1 | y.output 2 | 3 | # ignore intellij files 4 | .idea 5 | *.iml 6 | *.ipr 7 | *.iws 8 | 9 | *.test 10 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 1.5 4 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/Makefile: -------------------------------------------------------------------------------- 1 | TEST?=./... 2 | 3 | default: test 4 | 5 | fmt: generate 6 | go fmt ./... 7 | 8 | test: generate 9 | go test $(TEST) $(TESTARGS) 10 | 11 | generate: 12 | go generate ./... 13 | 14 | updatedeps: 15 | go get -u golang.org/x/tools/cmd/stringer 16 | 17 | .PHONY: default generate test updatedeps 18 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "build-{branch}-{build}" 2 | image: Visual Studio 2015 3 | clone_folder: c:\gopath\src\github.com\hashicorp\hcl 4 | environment: 5 | GOPATH: c:\gopath 6 | init: 7 | - git config --global core.autocrlf true 8 | install: 9 | - cmd: >- 10 | echo %Path% 11 | 12 | go version 13 | 14 | go env 15 | build_script: 16 | - cmd: go test -v ./... 17 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/hcl.go: -------------------------------------------------------------------------------- 1 | // Package hcl decodes HCL into usable Go structures. 2 | // 3 | // hcl input can come in either pure HCL format or JSON format. 4 | // It can be parsed into an AST, and then decoded into a structure, 5 | // or it can be decoded directly from a string into a structure. 6 | // 7 | // If you choose to parse HCL into a raw AST, the benefit is that you 8 | // can write custom visitor implementations to implement custom 9 | // semantic checks. By default, HCL does not perform any semantic 10 | // checks. 11 | package hcl 12 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/hcl/ast/walk.go: -------------------------------------------------------------------------------- 1 | package ast 2 | 3 | import "fmt" 4 | 5 | // WalkFunc describes a function to be called for each node during a Walk. The 6 | // returned node can be used to rewrite the AST. Walking stops the returned 7 | // bool is false. 8 | type WalkFunc func(Node) (Node, bool) 9 | 10 | // Walk traverses an AST in depth-first order: It starts by calling fn(node); 11 | // node must not be nil. If fn returns true, Walk invokes fn recursively for 12 | // each of the non-nil children of node, followed by a call of fn(nil). The 13 | // returned node of fn can be used to rewrite the passed node to fn. 14 | func Walk(node Node, fn WalkFunc) Node { 15 | rewritten, ok := fn(node) 16 | if !ok { 17 | return rewritten 18 | } 19 | 20 | switch n := node.(type) { 21 | case *File: 22 | n.Node = Walk(n.Node, fn) 23 | case *ObjectList: 24 | for i, item := range n.Items { 25 | n.Items[i] = Walk(item, fn).(*ObjectItem) 26 | } 27 | case *ObjectKey: 28 | // nothing to do 29 | case *ObjectItem: 30 | for i, k := range n.Keys { 31 | n.Keys[i] = Walk(k, fn).(*ObjectKey) 32 | } 33 | 34 | if n.Val != nil { 35 | n.Val = Walk(n.Val, fn) 36 | } 37 | case *LiteralType: 38 | // nothing to do 39 | case *ListType: 40 | for i, l := range n.List { 41 | n.List[i] = Walk(l, fn) 42 | } 43 | case *ObjectType: 44 | n.List = Walk(n.List, fn).(*ObjectList) 45 | default: 46 | // should we panic here? 47 | fmt.Printf("unknown type: %T\n", n) 48 | } 49 | 50 | fn(nil) 51 | return rewritten 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/hcl/parser/error.go: -------------------------------------------------------------------------------- 1 | package parser 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/hashicorp/hcl/hcl/token" 7 | ) 8 | 9 | // PosError is a parse error that contains a position. 10 | type PosError struct { 11 | Pos token.Pos 12 | Err error 13 | } 14 | 15 | func (e *PosError) Error() string { 16 | return fmt.Sprintf("At %s: %s", e.Pos, e.Err) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/hcl/token/position.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import "fmt" 4 | 5 | // Pos describes an arbitrary source position 6 | // including the file, line, and column location. 7 | // A Position is valid if the line number is > 0. 8 | type Pos struct { 9 | Filename string // filename, if any 10 | Offset int // offset, starting at 0 11 | Line int // line number, starting at 1 12 | Column int // column number, starting at 1 (character count) 13 | } 14 | 15 | // IsValid returns true if the position is valid. 16 | func (p *Pos) IsValid() bool { return p.Line > 0 } 17 | 18 | // String returns a string in one of several forms: 19 | // 20 | // file:line:column valid position with file name 21 | // line:column valid position without file name 22 | // file invalid position with file name 23 | // - invalid position without file name 24 | func (p Pos) String() string { 25 | s := p.Filename 26 | if p.IsValid() { 27 | if s != "" { 28 | s += ":" 29 | } 30 | s += fmt.Sprintf("%d:%d", p.Line, p.Column) 31 | } 32 | if s == "" { 33 | s = "-" 34 | } 35 | return s 36 | } 37 | 38 | // Before reports whether the position p is before u. 39 | func (p Pos) Before(u Pos) bool { 40 | return u.Offset > p.Offset || u.Line > p.Line 41 | } 42 | 43 | // After reports whether the position p is after u. 44 | func (p Pos) After(u Pos) bool { 45 | return u.Offset < p.Offset || u.Line < p.Line 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/json/token/position.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import "fmt" 4 | 5 | // Pos describes an arbitrary source position 6 | // including the file, line, and column location. 7 | // A Position is valid if the line number is > 0. 8 | type Pos struct { 9 | Filename string // filename, if any 10 | Offset int // offset, starting at 0 11 | Line int // line number, starting at 1 12 | Column int // column number, starting at 1 (character count) 13 | } 14 | 15 | // IsValid returns true if the position is valid. 16 | func (p *Pos) IsValid() bool { return p.Line > 0 } 17 | 18 | // String returns a string in one of several forms: 19 | // 20 | // file:line:column valid position with file name 21 | // line:column valid position without file name 22 | // file invalid position with file name 23 | // - invalid position without file name 24 | func (p Pos) String() string { 25 | s := p.Filename 26 | if p.IsValid() { 27 | if s != "" { 28 | s += ":" 29 | } 30 | s += fmt.Sprintf("%d:%d", p.Line, p.Column) 31 | } 32 | if s == "" { 33 | s = "-" 34 | } 35 | return s 36 | } 37 | 38 | // Before reports whether the position p is before u. 39 | func (p Pos) Before(u Pos) bool { 40 | return u.Offset > p.Offset || u.Line > p.Line 41 | } 42 | 43 | // After reports whether the position p is after u. 44 | func (p Pos) After(u Pos) bool { 45 | return u.Offset < p.Offset || u.Line < p.Line 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/lex.go: -------------------------------------------------------------------------------- 1 | package hcl 2 | 3 | import ( 4 | "unicode" 5 | "unicode/utf8" 6 | ) 7 | 8 | type lexModeValue byte 9 | 10 | const ( 11 | lexModeUnknown lexModeValue = iota 12 | lexModeHcl 13 | lexModeJson 14 | ) 15 | 16 | // lexMode returns whether we're going to be parsing in JSON 17 | // mode or HCL mode. 18 | func lexMode(v []byte) lexModeValue { 19 | var ( 20 | r rune 21 | w int 22 | offset int 23 | ) 24 | 25 | for { 26 | r, w = utf8.DecodeRune(v[offset:]) 27 | offset += w 28 | if unicode.IsSpace(r) { 29 | continue 30 | } 31 | if r == '{' { 32 | return lexModeJson 33 | } 34 | break 35 | } 36 | 37 | return lexModeHcl 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/hcl/parse.go: -------------------------------------------------------------------------------- 1 | package hcl 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/hashicorp/hcl/hcl/ast" 7 | hclParser "github.com/hashicorp/hcl/hcl/parser" 8 | jsonParser "github.com/hashicorp/hcl/json/parser" 9 | ) 10 | 11 | // ParseBytes accepts as input byte slice and returns ast tree. 12 | // 13 | // Input can be either JSON or HCL 14 | func ParseBytes(in []byte) (*ast.File, error) { 15 | return parse(in) 16 | } 17 | 18 | // ParseString accepts input as a string and returns ast tree. 19 | func ParseString(input string) (*ast.File, error) { 20 | return parse([]byte(input)) 21 | } 22 | 23 | func parse(in []byte) (*ast.File, error) { 24 | switch lexMode(in) { 25 | case lexModeHcl: 26 | return hclParser.Parse(in) 27 | case lexModeJson: 28 | return jsonParser.Parse(in) 29 | } 30 | 31 | return nil, fmt.Errorf("unknown config format") 32 | } 33 | 34 | // Parse parses the given input and returns the root object. 35 | // 36 | // The input format can be either HCL or JSON. 37 | func Parse(input string) (*ast.File, error) { 38 | return parse([]byte(input)) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/.gitattributes: -------------------------------------------------------------------------------- 1 | vendor/* linguist-vendored 2 | website/* linguist-documentation 3 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | .cover 10 | 11 | # Architecture specific extensions/prefixes 12 | *.[568vq] 13 | [568vq].out 14 | 15 | *.cgo1.go 16 | *.cgo2.c 17 | _cgo_defun.c 18 | _cgo_gotypes.go 19 | _cgo_export.* 20 | 21 | _testmain.go 22 | 23 | *.exe 24 | *.test 25 | *.prof 26 | 27 | # Other dirs 28 | /bin/ 29 | /pkg/ 30 | 31 | # Vault-specific 32 | example.hcl 33 | example.vault.d 34 | 35 | # Ruby 36 | website/vendor 37 | website/.bundle 38 | website/build 39 | 40 | # Vagrant 41 | .vagrant/ 42 | Vagrantfile 43 | 44 | # Configs 45 | *.hcl 46 | 47 | .DS_Store 48 | .idea 49 | 50 | dist/* 51 | 52 | tags 53 | 54 | # Editor backups 55 | *~ 56 | *.sw[a-z] 57 | 58 | # IntelliJ IDEA project files 59 | .idea 60 | *.ipr 61 | *.iml 62 | 63 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | 3 | language: go 4 | 5 | services: 6 | - docker 7 | 8 | go: 9 | - 1.6.2 10 | # tip is currently using go1.4.1, which we're not compatible with, so always 11 | # fails 12 | # - tip 13 | 14 | matrix: 15 | allow_failures: 16 | - go: tip 17 | 18 | branches: 19 | only: 20 | - master 21 | - travis-testing 22 | 23 | # Having an install function stops Travis from trying to do automagic things 24 | # with godep 25 | install: 26 | - true 27 | 28 | script: 29 | - make test testrace 30 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/auth.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | // Auth is used to perform credential backend related operations. 4 | type Auth struct { 5 | c *Client 6 | } 7 | 8 | // Auth is used to return the client for credential-backend API calls. 9 | func (c *Client) Auth() *Auth { 10 | return &Auth{c: c} 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/help.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | // Help reads the help information for the given path. 8 | func (c *Client) Help(path string) (*Help, error) { 9 | r := c.NewRequest("GET", fmt.Sprintf("/v1/%s", path)) 10 | r.Params.Add("help", "1") 11 | resp, err := c.RawRequest(r) 12 | if err != nil { 13 | return nil, err 14 | } 15 | defer resp.Body.Close() 16 | 17 | var result Help 18 | err = resp.DecodeJSON(&result) 19 | return &result, err 20 | } 21 | 22 | type Help struct { 23 | Help string `json:"help"` 24 | SeeAlso []string `json:"see_also"` 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/request.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "io" 7 | "net/http" 8 | "net/url" 9 | ) 10 | 11 | // Request is a raw request configuration structure used to initiate 12 | // API requests to the Vault server. 13 | type Request struct { 14 | Method string 15 | URL *url.URL 16 | Params url.Values 17 | ClientToken string 18 | WrapTTL string 19 | Obj interface{} 20 | Body io.Reader 21 | BodySize int64 22 | } 23 | 24 | // SetJSONBody is used to set a request body that is a JSON-encoded value. 25 | func (r *Request) SetJSONBody(val interface{}) error { 26 | buf := bytes.NewBuffer(nil) 27 | enc := json.NewEncoder(buf) 28 | if err := enc.Encode(val); err != nil { 29 | return err 30 | } 31 | 32 | r.Obj = val 33 | r.Body = buf 34 | r.BodySize = int64(buf.Len()) 35 | return nil 36 | } 37 | 38 | // ResetJSONBody is used to reset the body for a redirect 39 | func (r *Request) ResetJSONBody() error { 40 | if r.Body == nil { 41 | return nil 42 | } 43 | return r.SetJSONBody(r.Obj) 44 | } 45 | 46 | // ToHTTP turns this request into a valid *http.Request for use with the 47 | // net/http package. 48 | func (r *Request) ToHTTP() (*http.Request, error) { 49 | // Encode the query parameters 50 | r.URL.RawQuery = r.Params.Encode() 51 | 52 | // Create the HTTP request 53 | req, err := http.NewRequest(r.Method, r.URL.RequestURI(), r.Body) 54 | if err != nil { 55 | return nil, err 56 | } 57 | 58 | req.URL.Scheme = r.URL.Scheme 59 | req.URL.Host = r.URL.Host 60 | req.Host = r.URL.Host 61 | 62 | if len(r.ClientToken) != 0 { 63 | req.Header.Set("X-Vault-Token", r.ClientToken) 64 | } 65 | 66 | if len(r.WrapTTL) != 0 { 67 | req.Header.Set("X-Vault-Wrap-TTL", r.WrapTTL) 68 | } 69 | 70 | return req, nil 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/ssh.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import "fmt" 4 | 5 | // SSH is used to return a client to invoke operations on SSH backend. 6 | type SSH struct { 7 | c *Client 8 | MountPoint string 9 | } 10 | 11 | // SSH returns the client for logical-backend API calls. 12 | func (c *Client) SSH() *SSH { 13 | return c.SSHWithMountPoint(SSHHelperDefaultMountPoint) 14 | } 15 | 16 | // SSHWithMountPoint returns the client with specific SSH mount point. 17 | func (c *Client) SSHWithMountPoint(mountPoint string) *SSH { 18 | return &SSH{ 19 | c: c, 20 | MountPoint: mountPoint, 21 | } 22 | } 23 | 24 | // Credential invokes the SSH backend API to create a credential to establish an SSH session. 25 | func (c *SSH) Credential(role string, data map[string]interface{}) (*Secret, error) { 26 | r := c.c.NewRequest("PUT", fmt.Sprintf("/v1/%s/creds/%s", c.MountPoint, role)) 27 | if err := r.SetJSONBody(data); err != nil { 28 | return nil, err 29 | } 30 | 31 | resp, err := c.c.RawRequest(r) 32 | if err != nil { 33 | return nil, err 34 | } 35 | defer resp.Body.Close() 36 | 37 | return ParseSecret(resp.Body) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/sys.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | // Sys is used to perform system-related operations on Vault. 4 | type Sys struct { 5 | c *Client 6 | } 7 | 8 | // Sys is used to return the client for sys-related API calls. 9 | func (c *Client) Sys() *Sys { 10 | return &Sys{c: c} 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/sys_auth.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func (c *Sys) ListAuth() (map[string]*AuthMount, error) { 8 | r := c.c.NewRequest("GET", "/v1/sys/auth") 9 | resp, err := c.c.RawRequest(r) 10 | if err != nil { 11 | return nil, err 12 | } 13 | defer resp.Body.Close() 14 | 15 | var result map[string]*AuthMount 16 | err = resp.DecodeJSON(&result) 17 | return result, err 18 | } 19 | 20 | func (c *Sys) EnableAuth(path, authType, desc string) error { 21 | body := map[string]string{ 22 | "type": authType, 23 | "description": desc, 24 | } 25 | 26 | r := c.c.NewRequest("POST", fmt.Sprintf("/v1/sys/auth/%s", path)) 27 | if err := r.SetJSONBody(body); err != nil { 28 | return err 29 | } 30 | 31 | resp, err := c.c.RawRequest(r) 32 | if err != nil { 33 | return err 34 | } 35 | defer resp.Body.Close() 36 | 37 | return nil 38 | } 39 | 40 | func (c *Sys) DisableAuth(path string) error { 41 | r := c.c.NewRequest("DELETE", fmt.Sprintf("/v1/sys/auth/%s", path)) 42 | resp, err := c.c.RawRequest(r) 43 | if err == nil { 44 | defer resp.Body.Close() 45 | } 46 | return err 47 | } 48 | 49 | // Structures for the requests/resposne are all down here. They aren't 50 | // individually documentd because the map almost directly to the raw HTTP API 51 | // documentation. Please refer to that documentation for more details. 52 | 53 | type AuthMount struct { 54 | Type string `json:"type" structs:"type" mapstructure:"type"` 55 | Description string `json:"description" structs:"description" mapstructure:"description"` 56 | Config AuthConfigOutput `json:"config" structs:"config" mapstructure:"config"` 57 | } 58 | 59 | type AuthConfigOutput struct { 60 | DefaultLeaseTTL int `json:"default_lease_ttl" structs:"default_lease_ttl" mapstructure:"default_lease_ttl"` 61 | MaxLeaseTTL int `json:"max_lease_ttl" structs:"max_lease_ttl" mapstructure:"max_lease_ttl"` 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/sys_capabilities.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | func (c *Sys) CapabilitiesSelf(path string) ([]string, error) { 4 | body := map[string]string{ 5 | "path": path, 6 | } 7 | 8 | r := c.c.NewRequest("POST", "/v1/sys/capabilities-self") 9 | if err := r.SetJSONBody(body); err != nil { 10 | return nil, err 11 | } 12 | 13 | resp, err := c.c.RawRequest(r) 14 | if err != nil { 15 | return nil, err 16 | } 17 | defer resp.Body.Close() 18 | 19 | var result map[string]interface{} 20 | err = resp.DecodeJSON(&result) 21 | if err != nil { 22 | return nil, err 23 | } 24 | var capabilities []string 25 | capabilitiesRaw := result["capabilities"].([]interface{}) 26 | for _, capability := range capabilitiesRaw { 27 | capabilities = append(capabilities, capability.(string)) 28 | } 29 | return capabilities, nil 30 | } 31 | 32 | func (c *Sys) Capabilities(token, path string) ([]string, error) { 33 | body := map[string]string{ 34 | "token": token, 35 | "path": path, 36 | } 37 | 38 | r := c.c.NewRequest("POST", "/v1/sys/capabilities") 39 | if err := r.SetJSONBody(body); err != nil { 40 | return nil, err 41 | } 42 | 43 | resp, err := c.c.RawRequest(r) 44 | if err != nil { 45 | return nil, err 46 | } 47 | defer resp.Body.Close() 48 | 49 | var result map[string]interface{} 50 | err = resp.DecodeJSON(&result) 51 | if err != nil { 52 | return nil, err 53 | } 54 | var capabilities []string 55 | capabilitiesRaw := result["capabilities"].([]interface{}) 56 | for _, capability := range capabilitiesRaw { 57 | capabilities = append(capabilities, capability.(string)) 58 | } 59 | return capabilities, nil 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/sys_generate_root.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | func (c *Sys) GenerateRootStatus() (*GenerateRootStatusResponse, error) { 4 | r := c.c.NewRequest("GET", "/v1/sys/generate-root/attempt") 5 | resp, err := c.c.RawRequest(r) 6 | if err != nil { 7 | return nil, err 8 | } 9 | defer resp.Body.Close() 10 | 11 | var result GenerateRootStatusResponse 12 | err = resp.DecodeJSON(&result) 13 | return &result, err 14 | } 15 | 16 | func (c *Sys) GenerateRootInit(otp, pgpKey string) (*GenerateRootStatusResponse, error) { 17 | body := map[string]interface{}{ 18 | "otp": otp, 19 | "pgp_key": pgpKey, 20 | } 21 | 22 | r := c.c.NewRequest("PUT", "/v1/sys/generate-root/attempt") 23 | if err := r.SetJSONBody(body); err != nil { 24 | return nil, err 25 | } 26 | 27 | resp, err := c.c.RawRequest(r) 28 | if err != nil { 29 | return nil, err 30 | } 31 | defer resp.Body.Close() 32 | 33 | var result GenerateRootStatusResponse 34 | err = resp.DecodeJSON(&result) 35 | return &result, err 36 | } 37 | 38 | func (c *Sys) GenerateRootCancel() error { 39 | r := c.c.NewRequest("DELETE", "/v1/sys/generate-root/attempt") 40 | resp, err := c.c.RawRequest(r) 41 | if err == nil { 42 | defer resp.Body.Close() 43 | } 44 | return err 45 | } 46 | 47 | func (c *Sys) GenerateRootUpdate(shard, nonce string) (*GenerateRootStatusResponse, error) { 48 | body := map[string]interface{}{ 49 | "key": shard, 50 | "nonce": nonce, 51 | } 52 | 53 | r := c.c.NewRequest("PUT", "/v1/sys/generate-root/update") 54 | if err := r.SetJSONBody(body); err != nil { 55 | return nil, err 56 | } 57 | 58 | resp, err := c.c.RawRequest(r) 59 | if err != nil { 60 | return nil, err 61 | } 62 | defer resp.Body.Close() 63 | 64 | var result GenerateRootStatusResponse 65 | err = resp.DecodeJSON(&result) 66 | return &result, err 67 | } 68 | 69 | type GenerateRootStatusResponse struct { 70 | Nonce string 71 | Started bool 72 | Progress int 73 | Required int 74 | Complete bool 75 | EncodedRootToken string `json:"encoded_root_token"` 76 | PGPFingerprint string `json:"pgp_fingerprint"` 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/sys_init.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | func (c *Sys) InitStatus() (bool, error) { 4 | r := c.c.NewRequest("GET", "/v1/sys/init") 5 | resp, err := c.c.RawRequest(r) 6 | if err != nil { 7 | return false, err 8 | } 9 | defer resp.Body.Close() 10 | 11 | var result InitStatusResponse 12 | err = resp.DecodeJSON(&result) 13 | return result.Initialized, err 14 | } 15 | 16 | func (c *Sys) Init(opts *InitRequest) (*InitResponse, error) { 17 | r := c.c.NewRequest("PUT", "/v1/sys/init") 18 | if err := r.SetJSONBody(opts); err != nil { 19 | return nil, err 20 | } 21 | 22 | resp, err := c.c.RawRequest(r) 23 | if err != nil { 24 | return nil, err 25 | } 26 | defer resp.Body.Close() 27 | 28 | var result InitResponse 29 | err = resp.DecodeJSON(&result) 30 | return &result, err 31 | } 32 | 33 | type InitRequest struct { 34 | SecretShares int `json:"secret_shares"` 35 | SecretThreshold int `json:"secret_threshold"` 36 | StoredShares int `json:"stored_shares"` 37 | PGPKeys []string `json:"pgp_keys"` 38 | RecoveryShares int `json:"recovery_shares"` 39 | RecoveryThreshold int `json:"recovery_threshold"` 40 | RecoveryPGPKeys []string `json:"recovery_pgp_keys"` 41 | } 42 | 43 | type InitStatusResponse struct { 44 | Initialized bool 45 | } 46 | 47 | type InitResponse struct { 48 | Keys []string 49 | RecoveryKeys []string `json:"recovery_keys"` 50 | RootToken string `json:"root_token"` 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/sys_leader.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | func (c *Sys) Leader() (*LeaderResponse, error) { 4 | r := c.c.NewRequest("GET", "/v1/sys/leader") 5 | resp, err := c.c.RawRequest(r) 6 | if err != nil { 7 | return nil, err 8 | } 9 | defer resp.Body.Close() 10 | 11 | var result LeaderResponse 12 | err = resp.DecodeJSON(&result) 13 | return &result, err 14 | } 15 | 16 | type LeaderResponse struct { 17 | HAEnabled bool `json:"ha_enabled"` 18 | IsSelf bool `json:"is_self"` 19 | LeaderAddress string `json:"leader_address"` 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/sys_lease.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | func (c *Sys) Renew(id string, increment int) (*Secret, error) { 4 | r := c.c.NewRequest("PUT", "/v1/sys/renew/"+id) 5 | 6 | body := map[string]interface{}{"increment": increment} 7 | if err := r.SetJSONBody(body); err != nil { 8 | return nil, err 9 | } 10 | 11 | resp, err := c.c.RawRequest(r) 12 | if err != nil { 13 | return nil, err 14 | } 15 | defer resp.Body.Close() 16 | 17 | return ParseSecret(resp.Body) 18 | } 19 | 20 | func (c *Sys) Revoke(id string) error { 21 | r := c.c.NewRequest("PUT", "/v1/sys/revoke/"+id) 22 | resp, err := c.c.RawRequest(r) 23 | if err == nil { 24 | defer resp.Body.Close() 25 | } 26 | return err 27 | } 28 | 29 | func (c *Sys) RevokePrefix(id string) error { 30 | r := c.c.NewRequest("PUT", "/v1/sys/revoke-prefix/"+id) 31 | resp, err := c.c.RawRequest(r) 32 | if err == nil { 33 | defer resp.Body.Close() 34 | } 35 | return err 36 | } 37 | 38 | func (c *Sys) RevokeForce(id string) error { 39 | r := c.c.NewRequest("PUT", "/v1/sys/revoke-force/"+id) 40 | resp, err := c.c.RawRequest(r) 41 | if err == nil { 42 | defer resp.Body.Close() 43 | } 44 | return err 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/sys_policy.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func (c *Sys) ListPolicies() ([]string, error) { 8 | r := c.c.NewRequest("GET", "/v1/sys/policy") 9 | resp, err := c.c.RawRequest(r) 10 | if err != nil { 11 | return nil, err 12 | } 13 | defer resp.Body.Close() 14 | 15 | var result listPoliciesResp 16 | err = resp.DecodeJSON(&result) 17 | return result.Policies, err 18 | } 19 | 20 | func (c *Sys) GetPolicy(name string) (string, error) { 21 | r := c.c.NewRequest("GET", fmt.Sprintf("/v1/sys/policy/%s", name)) 22 | resp, err := c.c.RawRequest(r) 23 | if resp != nil { 24 | defer resp.Body.Close() 25 | if resp.StatusCode == 404 { 26 | return "", nil 27 | } 28 | } 29 | if err != nil { 30 | return "", err 31 | } 32 | 33 | var result getPoliciesResp 34 | err = resp.DecodeJSON(&result) 35 | return result.Rules, err 36 | } 37 | 38 | func (c *Sys) PutPolicy(name, rules string) error { 39 | body := map[string]string{ 40 | "rules": rules, 41 | } 42 | 43 | r := c.c.NewRequest("PUT", fmt.Sprintf("/v1/sys/policy/%s", name)) 44 | if err := r.SetJSONBody(body); err != nil { 45 | return err 46 | } 47 | 48 | resp, err := c.c.RawRequest(r) 49 | if err != nil { 50 | return err 51 | } 52 | defer resp.Body.Close() 53 | 54 | return nil 55 | } 56 | 57 | func (c *Sys) DeletePolicy(name string) error { 58 | r := c.c.NewRequest("DELETE", fmt.Sprintf("/v1/sys/policy/%s", name)) 59 | resp, err := c.c.RawRequest(r) 60 | if err == nil { 61 | defer resp.Body.Close() 62 | } 63 | return err 64 | } 65 | 66 | type getPoliciesResp struct { 67 | Rules string `json:"rules"` 68 | } 69 | 70 | type listPoliciesResp struct { 71 | Policies []string `json:"policies"` 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/sys_rotate.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import "time" 4 | 5 | func (c *Sys) Rotate() error { 6 | r := c.c.NewRequest("POST", "/v1/sys/rotate") 7 | resp, err := c.c.RawRequest(r) 8 | if err == nil { 9 | defer resp.Body.Close() 10 | } 11 | return err 12 | } 13 | 14 | func (c *Sys) KeyStatus() (*KeyStatus, error) { 15 | r := c.c.NewRequest("GET", "/v1/sys/key-status") 16 | resp, err := c.c.RawRequest(r) 17 | if err != nil { 18 | return nil, err 19 | } 20 | defer resp.Body.Close() 21 | 22 | result := new(KeyStatus) 23 | err = resp.DecodeJSON(result) 24 | return result, err 25 | } 26 | 27 | type KeyStatus struct { 28 | Term int 29 | InstallTime time.Time `json:"install_time"` 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/sys_seal.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | func (c *Sys) SealStatus() (*SealStatusResponse, error) { 4 | r := c.c.NewRequest("GET", "/v1/sys/seal-status") 5 | return sealStatusRequest(c, r) 6 | } 7 | 8 | func (c *Sys) Seal() error { 9 | r := c.c.NewRequest("PUT", "/v1/sys/seal") 10 | resp, err := c.c.RawRequest(r) 11 | if err == nil { 12 | defer resp.Body.Close() 13 | } 14 | return err 15 | } 16 | 17 | func (c *Sys) ResetUnsealProcess() (*SealStatusResponse, error) { 18 | body := map[string]interface{}{"reset": true} 19 | 20 | r := c.c.NewRequest("PUT", "/v1/sys/unseal") 21 | if err := r.SetJSONBody(body); err != nil { 22 | return nil, err 23 | } 24 | 25 | return sealStatusRequest(c, r) 26 | } 27 | 28 | func (c *Sys) Unseal(shard string) (*SealStatusResponse, error) { 29 | body := map[string]interface{}{"key": shard} 30 | 31 | r := c.c.NewRequest("PUT", "/v1/sys/unseal") 32 | if err := r.SetJSONBody(body); err != nil { 33 | return nil, err 34 | } 35 | 36 | return sealStatusRequest(c, r) 37 | } 38 | 39 | func sealStatusRequest(c *Sys, r *Request) (*SealStatusResponse, error) { 40 | resp, err := c.c.RawRequest(r) 41 | if err != nil { 42 | return nil, err 43 | } 44 | defer resp.Body.Close() 45 | 46 | var result SealStatusResponse 47 | err = resp.DecodeJSON(&result) 48 | return &result, err 49 | } 50 | 51 | type SealStatusResponse struct { 52 | Sealed bool 53 | T int 54 | N int 55 | Progress int 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/api/sys_stepdown.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | func (c *Sys) StepDown() error { 4 | r := c.c.NewRequest("PUT", "/v1/sys/step-down") 5 | resp, err := c.c.RawRequest(r) 6 | if err == nil { 7 | defer resp.Body.Close() 8 | } 9 | return err 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/vault/helper/jsonutil/json.go: -------------------------------------------------------------------------------- 1 | package jsonutil 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "fmt" 7 | "io" 8 | ) 9 | 10 | // Encodes/Marshals the given object into JSON 11 | func EncodeJSON(in interface{}) ([]byte, error) { 12 | var buf bytes.Buffer 13 | enc := json.NewEncoder(&buf) 14 | if err := enc.Encode(in); err != nil { 15 | return nil, err 16 | } 17 | return buf.Bytes(), nil 18 | } 19 | 20 | // Decodes/Unmarshals the given JSON into a desired object 21 | func DecodeJSON(data []byte, out interface{}) error { 22 | if data == nil { 23 | return fmt.Errorf("'data' being decoded is nil") 24 | } 25 | if out == nil { 26 | return fmt.Errorf("output parameter 'out' is nil") 27 | } 28 | 29 | return DecodeJSONFromReader(bytes.NewReader(data), out) 30 | } 31 | 32 | // Decodes/Unmarshals the given io.Reader pointing to a JSON, into a desired object 33 | func DecodeJSONFromReader(r io.Reader, out interface{}) error { 34 | if r == nil { 35 | return fmt.Errorf("'io.Reader' being decoded is nil") 36 | } 37 | if out == nil { 38 | return fmt.Errorf("output parameter 'out' is nil") 39 | } 40 | 41 | dec := json.NewDecoder(r) 42 | 43 | // While decoding JSON values, intepret the integer values as `json.Number`s instead of `float64`. 44 | dec.UseNumber() 45 | 46 | // Since 'out' is an interface representing a pointer, pass it to the decoder without an '&' 47 | return dec.Decode(out) 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/mapstructure/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.4 5 | 6 | script: 7 | - go test 8 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/mapstructure/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Mitchell Hashimoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/mapstructure/README.md: -------------------------------------------------------------------------------- 1 | # mapstructure 2 | 3 | mapstructure is a Go library for decoding generic map values to structures 4 | and vice versa, while providing helpful error handling. 5 | 6 | This library is most useful when decoding values from some data stream (JSON, 7 | Gob, etc.) where you don't _quite_ know the structure of the underlying data 8 | until you read a part of it. You can therefore read a `map[string]interface{}` 9 | and use this library to decode it into the proper underlying native Go 10 | structure. 11 | 12 | ## Installation 13 | 14 | Standard `go get`: 15 | 16 | ``` 17 | $ go get github.com/mitchellh/mapstructure 18 | ``` 19 | 20 | ## Usage & Example 21 | 22 | For usage and examples see the [Godoc](http://godoc.org/github.com/mitchellh/mapstructure). 23 | 24 | The `Decode` function has examples associated with it there. 25 | 26 | ## But Why?! 27 | 28 | Go offers fantastic standard libraries for decoding formats such as JSON. 29 | The standard method is to have a struct pre-created, and populate that struct 30 | from the bytes of the encoded format. This is great, but the problem is if 31 | you have configuration or an encoding that changes slightly depending on 32 | specific fields. For example, consider this JSON: 33 | 34 | ```json 35 | { 36 | "type": "person", 37 | "name": "Mitchell" 38 | } 39 | ``` 40 | 41 | Perhaps we can't populate a specific structure without first reading 42 | the "type" field from the JSON. We could always do two passes over the 43 | decoding of the JSON (reading the "type" first, and the rest later). 44 | However, it is much simpler to just decode this into a `map[string]interface{}` 45 | structure, read the "type" key, then use something like this library 46 | to decode it into the proper structure. 47 | -------------------------------------------------------------------------------- /vendor/github.com/mitchellh/mapstructure/error.go: -------------------------------------------------------------------------------- 1 | package mapstructure 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "sort" 7 | "strings" 8 | ) 9 | 10 | // Error implements the error interface and can represents multiple 11 | // errors that occur in the course of a single decode. 12 | type Error struct { 13 | Errors []string 14 | } 15 | 16 | func (e *Error) Error() string { 17 | points := make([]string, len(e.Errors)) 18 | for i, err := range e.Errors { 19 | points[i] = fmt.Sprintf("* %s", err) 20 | } 21 | 22 | sort.Strings(points) 23 | return fmt.Sprintf( 24 | "%d error(s) decoding:\n\n%s", 25 | len(e.Errors), strings.Join(points, "\n")) 26 | } 27 | 28 | // WrappedErrors implements the errwrap.Wrapper interface to make this 29 | // return value more useful with the errwrap and go-multierror libraries. 30 | func (e *Error) WrappedErrors() []error { 31 | if e == nil { 32 | return nil 33 | } 34 | 35 | result := make([]error, len(e.Errors)) 36 | for i, e := range e.Errors { 37 | result[i] = errors.New(e) 38 | } 39 | 40 | return result 41 | } 42 | 43 | func appendErrors(errors []string, err error) []string { 44 | switch e := err.(type) { 45 | case *Error: 46 | return append(errors, e.Errors...) 47 | default: 48 | return append(errors, e.Error()) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/opencontainers/runc/.gitignore: -------------------------------------------------------------------------------- 1 | vendor/pkg 2 | /runc 3 | Godeps/_workspace/src/github.com/opencontainers/runc 4 | man/man8 5 | -------------------------------------------------------------------------------- /vendor/github.com/opencontainers/runc/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM runc_test 2 | ADD . /go/src/github.com/opencontainers/runc 3 | RUN make 4 | -------------------------------------------------------------------------------- /vendor/github.com/opencontainers/runc/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Michael Crosby (@crosbymichael) 2 | Rohit Jnagal (@rjnagal) 3 | Victor Marmol (@vmarmol) 4 | Mrunal Patel (@mrunalp) 5 | Alexander Morozov (@LK4D4) 6 | Daniel, Dao Quang Minh (@dqminh) 7 | Andrey Vagin (@avagin) 8 | Qiang Huang (@hqhq) 9 | Aleksa Sarai (@cyphar) 10 | -------------------------------------------------------------------------------- /vendor/github.com/opencontainers/runc/NOTICE: -------------------------------------------------------------------------------- 1 | runc 2 | 3 | Copyright 2012-2015 Docker, Inc. 4 | 5 | This product includes software developed at Docker, Inc. (http://www.docker.com). 6 | 7 | The following is courtesy of our legal counsel: 8 | 9 | 10 | Use and transfer of Docker may be subject to certain restrictions by the 11 | United States and other governments. 12 | It is your responsibility to ensure that your use and/or transfer does not 13 | violate applicable laws. 14 | 15 | For more information, please see http://www.bis.doc.gov 16 | 17 | See also http://www.apache.org/dev/crypto.html and/or seek legal counsel. 18 | -------------------------------------------------------------------------------- /vendor/github.com/opencontainers/runc/PRINCIPLES.md: -------------------------------------------------------------------------------- 1 | # runc principles 2 | 3 | In the design and development of runc and libcontainer we try to follow these principles: 4 | 5 | (Work in progress) 6 | 7 | * Don't try to replace every tool. Instead, be an ingredient to improve them. 8 | * Less code is better. 9 | * Fewer components are better. Do you really need to add one more class? 10 | * 50 lines of straightforward, readable code is better than 10 lines of magic that nobody can understand. 11 | * Don't do later what you can do now. "//TODO: refactor" is not acceptable in new code. 12 | * When hesitating between two options, choose the one that is easier to reverse. 13 | * "No" is temporary; "Yes" is forever. If you're not sure about a new feature, say no. You can change your mind later. 14 | * Containers must be portable to the greatest possible number of machines. Be suspicious of any change which makes machines less interchangeable. 15 | * The fewer moving parts in a container, the better. 16 | * Don't merge it unless you document it. 17 | * Don't document it unless you can keep it up-to-date. 18 | * Don't merge it unless you test it! 19 | * Everyone's problem is slightly different. Focus on the part that is the same for everyone, and solve that. 20 | -------------------------------------------------------------------------------- /vendor/github.com/opencontainers/runc/libcontainer/user/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Tianon Gravi (@tianon) 2 | Aleksa Sarai (@cyphar) 3 | -------------------------------------------------------------------------------- /vendor/github.com/opencontainers/runc/libcontainer/user/lookup_unix.go: -------------------------------------------------------------------------------- 1 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 2 | 3 | package user 4 | 5 | import ( 6 | "io" 7 | "os" 8 | ) 9 | 10 | // Unix-specific path to the passwd and group formatted files. 11 | const ( 12 | unixPasswdPath = "/etc/passwd" 13 | unixGroupPath = "/etc/group" 14 | ) 15 | 16 | func GetPasswdPath() (string, error) { 17 | return unixPasswdPath, nil 18 | } 19 | 20 | func GetPasswd() (io.ReadCloser, error) { 21 | return os.Open(unixPasswdPath) 22 | } 23 | 24 | func GetGroupPath() (string, error) { 25 | return unixGroupPath, nil 26 | } 27 | 28 | func GetGroup() (io.ReadCloser, error) { 29 | return os.Open(unixGroupPath) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/opencontainers/runc/libcontainer/user/lookup_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris 2 | 3 | package user 4 | 5 | import "io" 6 | 7 | func GetPasswdPath() (string, error) { 8 | return "", ErrUnsupported 9 | } 10 | 11 | func GetPasswd() (io.ReadCloser, error) { 12 | return nil, ErrUnsupported 13 | } 14 | 15 | func GetGroupPath() (string, error) { 16 | return "", ErrUnsupported 17 | } 18 | 19 | func GetGroup() (io.ReadCloser, error) { 20 | return nil, ErrUnsupported 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher-metadata/.gitignore: -------------------------------------------------------------------------------- 1 | go-rancher-metadata 2 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher-metadata/README.md: -------------------------------------------------------------------------------- 1 | # Go bindings for Rancher-metadata 2 | 3 | This library is incomplete, but implements a variety of calls against [rancher-metadata](https://github.com/rancher/rancher-metadata) service 4 | 5 | #Example usage 6 | 7 | ```go 8 | package main 9 | 10 | import ( 11 | "time" 12 | 13 | "github.com/Sirupsen/logrus" 14 | "github.com/rancher/go-rancher-metadata/metadata" 15 | ) 16 | 17 | const ( 18 | metadataUrl = "http://rancher-metadata/2015-12-19" 19 | ) 20 | 21 | func main() { 22 | 23 | m := metadata.NewClient(metadataUrl) 24 | 25 | version := "init" 26 | 27 | for { 28 | newVersion, err := m.GetVersion() 29 | if err != nil { 30 | logrus.Errorf("Error reading metadata version: %v", err) 31 | } else if version == newVersion { 32 | logrus.Debug("No changes in metadata version") 33 | } else { 34 | logrus.Debugf("Metadata Version has been changed. Old version: %s. New version: %s.", version, newVersion) 35 | version = newVersion 36 | } 37 | time.Sleep(5 * time.Second) 38 | } 39 | } 40 | ``` 41 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher-metadata/metadata/change.go: -------------------------------------------------------------------------------- 1 | package metadata 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/Sirupsen/logrus" 7 | ) 8 | 9 | func (m *Client) OnChange(intervalSeconds int, do func(string)) { 10 | interval := time.Duration(intervalSeconds) 11 | version := "init" 12 | 13 | for { 14 | newVersion, err := m.GetVersion() 15 | if err != nil { 16 | logrus.Errorf("Error reading metadata version: %v", err) 17 | time.Sleep(interval * time.Second) 18 | } else if version == newVersion { 19 | logrus.Debug("No changes in metadata version") 20 | time.Sleep(interval * time.Second) 21 | } else { 22 | logrus.Debugf("Metadata Version has been changed. Old version: %s. New version: %s.", version, newVersion) 23 | version = newVersion 24 | do(newVersion) 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher-metadata/metadata/utils.go: -------------------------------------------------------------------------------- 1 | package metadata 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | func testConnection(mdClient *Client) error { 8 | var err error 9 | maxTime := 20 * time.Second 10 | 11 | for i := 1 * time.Second; i < maxTime; i *= time.Duration(2) { 12 | if _, err = mdClient.GetVersion(); err != nil { 13 | time.Sleep(i) 14 | } else { 15 | return nil 16 | } 17 | } 18 | return err 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher/.drone.yml: -------------------------------------------------------------------------------- 1 | image: rancher/dind:v0.3.0 2 | script: 3 | - ./scripts/ci 4 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher/.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | 3 | /build 4 | /bin 5 | /gopath 6 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher/.package: -------------------------------------------------------------------------------- 1 | github.com/rancher/go-rancher 2 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher/.wrap-docker-args: -------------------------------------------------------------------------------- 1 | --privileged 2 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rancher/dind:v0.3.0 2 | COPY ./scripts/bootstrap /scripts/bootstrap 3 | RUN /scripts/bootstrap 4 | WORKDIR /source 5 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher/README.md: -------------------------------------------------------------------------------- 1 | # Go Bindings for Rancher API 2 | 3 | # Building 4 | 5 | ```sh 6 | godep go build ./client 7 | ``` 8 | 9 | # Tests 10 | 11 | ```sh 12 | godep go test ./client 13 | ``` 14 | # Contact 15 | For bugs, questions, comments, corrections, suggestions, etc., open an issue in 16 | [rancher/rancher](//github.com/rancher/rancher/issues) with a title starting with `[go-rancher] `. 17 | 18 | Or just [click here](//github.com/rancher/rancher/issues/new?title=%5Bgo-rancher%5D%20) to create a new issue. 19 | 20 | 21 | # License 22 | Copyright (c) 2014-2015 [Rancher Labs, Inc.](http://rancher.com) 23 | 24 | Licensed under the Apache License, Version 2.0 (the "License"); 25 | you may not use this file except in compliance with the License. 26 | You may obtain a copy of the License at 27 | 28 | [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) 29 | 30 | Unless required by applicable law or agreed to in writing, software 31 | distributed under the License is distributed on an "AS IS" BASIS, 32 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 33 | See the License for the specific language governing permissions and 34 | limitations under the License. 35 | 36 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher/client/client.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | type RancherBaseClient struct { 4 | Opts *ClientOpts 5 | Schemas *Schemas 6 | Types map[string]Schema 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher/client/generated_add_label_input.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | const ( 4 | ADD_LABEL_INPUT_TYPE = "addLabelInput" 5 | ) 6 | 7 | type AddLabelInput struct { 8 | Resource 9 | 10 | Key string `json:"key,omitempty"` 11 | 12 | Value string `json:"value,omitempty"` 13 | } 14 | 15 | type AddLabelInputCollection struct { 16 | Collection 17 | Data []AddLabelInput `json:"data,omitempty"` 18 | } 19 | 20 | type AddLabelInputClient struct { 21 | rancherClient *RancherClient 22 | } 23 | 24 | type AddLabelInputOperations interface { 25 | List(opts *ListOpts) (*AddLabelInputCollection, error) 26 | Create(opts *AddLabelInput) (*AddLabelInput, error) 27 | Update(existing *AddLabelInput, updates interface{}) (*AddLabelInput, error) 28 | ById(id string) (*AddLabelInput, error) 29 | Delete(container *AddLabelInput) error 30 | } 31 | 32 | func newAddLabelInputClient(rancherClient *RancherClient) *AddLabelInputClient { 33 | return &AddLabelInputClient{ 34 | rancherClient: rancherClient, 35 | } 36 | } 37 | 38 | func (c *AddLabelInputClient) Create(container *AddLabelInput) (*AddLabelInput, error) { 39 | resp := &AddLabelInput{} 40 | err := c.rancherClient.doCreate(ADD_LABEL_INPUT_TYPE, container, resp) 41 | return resp, err 42 | } 43 | 44 | func (c *AddLabelInputClient) Update(existing *AddLabelInput, updates interface{}) (*AddLabelInput, error) { 45 | resp := &AddLabelInput{} 46 | err := c.rancherClient.doUpdate(ADD_LABEL_INPUT_TYPE, &existing.Resource, updates, resp) 47 | return resp, err 48 | } 49 | 50 | func (c *AddLabelInputClient) List(opts *ListOpts) (*AddLabelInputCollection, error) { 51 | resp := &AddLabelInputCollection{} 52 | err := c.rancherClient.doList(ADD_LABEL_INPUT_TYPE, opts, resp) 53 | return resp, err 54 | } 55 | 56 | func (c *AddLabelInputClient) ById(id string) (*AddLabelInput, error) { 57 | resp := &AddLabelInput{} 58 | err := c.rancherClient.doById(ADD_LABEL_INPUT_TYPE, id, resp) 59 | return resp, err 60 | } 61 | 62 | func (c *AddLabelInputClient) Delete(container *AddLabelInput) error { 63 | return c.rancherClient.doResourceDelete(ADD_LABEL_INPUT_TYPE, &container.Resource) 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher/client/generated_log_config.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | const ( 4 | LOG_CONFIG_TYPE = "logConfig" 5 | ) 6 | 7 | type LogConfig struct { 8 | Resource 9 | 10 | Config map[string]interface{} `json:"config,omitempty" yaml:"config,omitempty"` 11 | 12 | Driver string `json:"driver,omitempty" yaml:"driver,omitempty"` 13 | } 14 | 15 | type LogConfigCollection struct { 16 | Collection 17 | Data []LogConfig `json:"data,omitempty"` 18 | } 19 | 20 | type LogConfigClient struct { 21 | rancherClient *RancherClient 22 | } 23 | 24 | type LogConfigOperations interface { 25 | List(opts *ListOpts) (*LogConfigCollection, error) 26 | Create(opts *LogConfig) (*LogConfig, error) 27 | Update(existing *LogConfig, updates interface{}) (*LogConfig, error) 28 | ById(id string) (*LogConfig, error) 29 | Delete(container *LogConfig) error 30 | } 31 | 32 | func newLogConfigClient(rancherClient *RancherClient) *LogConfigClient { 33 | return &LogConfigClient{ 34 | rancherClient: rancherClient, 35 | } 36 | } 37 | 38 | func (c *LogConfigClient) Create(container *LogConfig) (*LogConfig, error) { 39 | resp := &LogConfig{} 40 | err := c.rancherClient.doCreate(LOG_CONFIG_TYPE, container, resp) 41 | return resp, err 42 | } 43 | 44 | func (c *LogConfigClient) Update(existing *LogConfig, updates interface{}) (*LogConfig, error) { 45 | resp := &LogConfig{} 46 | err := c.rancherClient.doUpdate(LOG_CONFIG_TYPE, &existing.Resource, updates, resp) 47 | return resp, err 48 | } 49 | 50 | func (c *LogConfigClient) List(opts *ListOpts) (*LogConfigCollection, error) { 51 | resp := &LogConfigCollection{} 52 | err := c.rancherClient.doList(LOG_CONFIG_TYPE, opts, resp) 53 | return resp, err 54 | } 55 | 56 | func (c *LogConfigClient) ById(id string) (*LogConfig, error) { 57 | resp := &LogConfig{} 58 | err := c.rancherClient.doById(LOG_CONFIG_TYPE, id, resp) 59 | if apiError, ok := err.(*ApiError); ok { 60 | if apiError.StatusCode == 404 { 61 | return nil, nil 62 | } 63 | } 64 | return resp, err 65 | } 66 | 67 | func (c *LogConfigClient) Delete(container *LogConfig) error { 68 | return c.rancherClient.doResourceDelete(LOG_CONFIG_TYPE, &container.Resource) 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher/client/generated_subscribe.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | const ( 4 | SUBSCRIBE_TYPE = "subscribe" 5 | ) 6 | 7 | type Subscribe struct { 8 | Resource 9 | 10 | AgentId string `json:"agentId,omitempty" yaml:"agent_id,omitempty"` 11 | 12 | EventNames []string `json:"eventNames,omitempty" yaml:"event_names,omitempty"` 13 | } 14 | 15 | type SubscribeCollection struct { 16 | Collection 17 | Data []Subscribe `json:"data,omitempty"` 18 | } 19 | 20 | type SubscribeClient struct { 21 | rancherClient *RancherClient 22 | } 23 | 24 | type SubscribeOperations interface { 25 | List(opts *ListOpts) (*SubscribeCollection, error) 26 | Create(opts *Subscribe) (*Subscribe, error) 27 | Update(existing *Subscribe, updates interface{}) (*Subscribe, error) 28 | ById(id string) (*Subscribe, error) 29 | Delete(container *Subscribe) error 30 | } 31 | 32 | func newSubscribeClient(rancherClient *RancherClient) *SubscribeClient { 33 | return &SubscribeClient{ 34 | rancherClient: rancherClient, 35 | } 36 | } 37 | 38 | func (c *SubscribeClient) Create(container *Subscribe) (*Subscribe, error) { 39 | resp := &Subscribe{} 40 | err := c.rancherClient.doCreate(SUBSCRIBE_TYPE, container, resp) 41 | return resp, err 42 | } 43 | 44 | func (c *SubscribeClient) Update(existing *Subscribe, updates interface{}) (*Subscribe, error) { 45 | resp := &Subscribe{} 46 | err := c.rancherClient.doUpdate(SUBSCRIBE_TYPE, &existing.Resource, updates, resp) 47 | return resp, err 48 | } 49 | 50 | func (c *SubscribeClient) List(opts *ListOpts) (*SubscribeCollection, error) { 51 | resp := &SubscribeCollection{} 52 | err := c.rancherClient.doList(SUBSCRIBE_TYPE, opts, resp) 53 | return resp, err 54 | } 55 | 56 | func (c *SubscribeClient) ById(id string) (*Subscribe, error) { 57 | resp := &Subscribe{} 58 | err := c.rancherClient.doById(SUBSCRIBE_TYPE, id, resp) 59 | if apiError, ok := err.(*ApiError); ok { 60 | if apiError.StatusCode == 404 { 61 | return nil, nil 62 | } 63 | } 64 | return resp, err 65 | } 66 | 67 | func (c *SubscribeClient) Delete(container *Subscribe) error { 68 | return c.rancherClient.doResourceDelete(SUBSCRIBE_TYPE, &container.Resource) 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/rancher/go-rancher/client/generated_task.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | const ( 4 | TASK_TYPE = "task" 5 | ) 6 | 7 | type Task struct { 8 | Resource 9 | 10 | Name string `json:"name,omitempty" yaml:"name,omitempty"` 11 | } 12 | 13 | type TaskCollection struct { 14 | Collection 15 | Data []Task `json:"data,omitempty"` 16 | } 17 | 18 | type TaskClient struct { 19 | rancherClient *RancherClient 20 | } 21 | 22 | type TaskOperations interface { 23 | List(opts *ListOpts) (*TaskCollection, error) 24 | Create(opts *Task) (*Task, error) 25 | Update(existing *Task, updates interface{}) (*Task, error) 26 | ById(id string) (*Task, error) 27 | Delete(container *Task) error 28 | 29 | ActionExecute(*Task) (*Task, error) 30 | } 31 | 32 | func newTaskClient(rancherClient *RancherClient) *TaskClient { 33 | return &TaskClient{ 34 | rancherClient: rancherClient, 35 | } 36 | } 37 | 38 | func (c *TaskClient) Create(container *Task) (*Task, error) { 39 | resp := &Task{} 40 | err := c.rancherClient.doCreate(TASK_TYPE, container, resp) 41 | return resp, err 42 | } 43 | 44 | func (c *TaskClient) Update(existing *Task, updates interface{}) (*Task, error) { 45 | resp := &Task{} 46 | err := c.rancherClient.doUpdate(TASK_TYPE, &existing.Resource, updates, resp) 47 | return resp, err 48 | } 49 | 50 | func (c *TaskClient) List(opts *ListOpts) (*TaskCollection, error) { 51 | resp := &TaskCollection{} 52 | err := c.rancherClient.doList(TASK_TYPE, opts, resp) 53 | return resp, err 54 | } 55 | 56 | func (c *TaskClient) ById(id string) (*Task, error) { 57 | resp := &Task{} 58 | err := c.rancherClient.doById(TASK_TYPE, id, resp) 59 | if apiError, ok := err.(*ApiError); ok { 60 | if apiError.StatusCode == 404 { 61 | return nil, nil 62 | } 63 | } 64 | return resp, err 65 | } 66 | 67 | func (c *TaskClient) Delete(container *Task) error { 68 | return c.rancherClient.doResourceDelete(TASK_TYPE, &container.Resource) 69 | } 70 | 71 | func (c *TaskClient) ActionExecute(resource *Task) (*Task, error) { 72 | 73 | resp := &Task{} 74 | 75 | err := c.rancherClient.doAction(TASK_TYPE, "execute", &resource.Resource, nil, resp) 76 | 77 | return resp, err 78 | } 79 | -------------------------------------------------------------------------------- /vendor/github.com/sethgrid/pester/LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2016] [Seth Ammons] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/.gitignore: -------------------------------------------------------------------------------- 1 | *.coverprofile 2 | node_modules/ 3 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | sudo: false 4 | 5 | cache: 6 | directories: 7 | - node_modules 8 | 9 | go: 10 | - 1.2.2 11 | - 1.3.3 12 | - 1.4 13 | - 1.5.4 14 | - 1.6.2 15 | - master 16 | 17 | matrix: 18 | allow_failures: 19 | - go: master 20 | include: 21 | - go: 1.6.2 22 | os: osx 23 | - go: 1.1.2 24 | install: go get -v . 25 | before_script: echo skipping gfmxr on $TRAVIS_GO_VERSION 26 | script: 27 | - ./runtests vet 28 | - ./runtests test 29 | 30 | before_script: 31 | - go get github.com/urfave/gfmxr/... 32 | - if [ ! -f node_modules/.bin/markdown-toc ] ; then 33 | npm install markdown-toc ; 34 | fi 35 | 36 | script: 37 | - ./runtests vet 38 | - ./runtests test 39 | - ./runtests gfmxr 40 | - ./runtests toc 41 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Jeremy Saenz & Contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | 3 | os: Windows Server 2012 R2 4 | 5 | clone_folder: c:\gopath\src\github.com\urfave\cli 6 | 7 | environment: 8 | GOPATH: C:\gopath 9 | GOVERSION: 1.6 10 | PYTHON: C:\Python27-x64 11 | PYTHON_VERSION: 2.7.x 12 | PYTHON_ARCH: 64 13 | GFMXR_DEBUG: 1 14 | 15 | install: 16 | - set PATH=%GOPATH%\bin;C:\go\bin;%PATH% 17 | - go version 18 | - go env 19 | - go get github.com/urfave/gfmxr/... 20 | - go get -v -t ./... 21 | 22 | build_script: 23 | - python runtests vet 24 | - python runtests test 25 | - python runtests gfmxr 26 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/category.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // CommandCategories is a slice of *CommandCategory. 4 | type CommandCategories []*CommandCategory 5 | 6 | // CommandCategory is a category containing commands. 7 | type CommandCategory struct { 8 | Name string 9 | Commands Commands 10 | } 11 | 12 | func (c CommandCategories) Less(i, j int) bool { 13 | return c[i].Name < c[j].Name 14 | } 15 | 16 | func (c CommandCategories) Len() int { 17 | return len(c) 18 | } 19 | 20 | func (c CommandCategories) Swap(i, j int) { 21 | c[i], c[j] = c[j], c[i] 22 | } 23 | 24 | // AddCommand adds a command to a category. 25 | func (c CommandCategories) AddCommand(category string, command Command) CommandCategories { 26 | for _, commandCategory := range c { 27 | if commandCategory.Name == category { 28 | commandCategory.Commands = append(commandCategory.Commands, command) 29 | return c 30 | } 31 | } 32 | return append(c, &CommandCategory{Name: category, Commands: []Command{command}}) 33 | } 34 | 35 | // VisibleCommands returns a slice of the Commands with Hidden=false 36 | func (c *CommandCategory) VisibleCommands() []Command { 37 | ret := []Command{} 38 | for _, command := range c.Commands { 39 | if !command.Hidden { 40 | ret = append(ret, command) 41 | } 42 | } 43 | return ret 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/cli.go: -------------------------------------------------------------------------------- 1 | // Package cli provides a minimal framework for creating and organizing command line 2 | // Go applications. cli is designed to be easy to understand and write, the most simple 3 | // cli application can be written as follows: 4 | // func main() { 5 | // cli.NewApp().Run(os.Args) 6 | // } 7 | // 8 | // Of course this application does not do much, so let's make this an actual application: 9 | // func main() { 10 | // app := cli.NewApp() 11 | // app.Name = "greet" 12 | // app.Usage = "say a greeting" 13 | // app.Action = func(c *cli.Context) error { 14 | // println("Greetings") 15 | // } 16 | // 17 | // app.Run(os.Args) 18 | // } 19 | package cli 20 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/funcs.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // BashCompleteFunc is an action to execute when the bash-completion flag is set 4 | type BashCompleteFunc func(*Context) 5 | 6 | // BeforeFunc is an action to execute before any subcommands are run, but after 7 | // the context is ready if a non-nil error is returned, no subcommands are run 8 | type BeforeFunc func(*Context) error 9 | 10 | // AfterFunc is an action to execute after any subcommands are run, but after the 11 | // subcommand has finished it is run even if Action() panics 12 | type AfterFunc func(*Context) error 13 | 14 | // ActionFunc is the action to execute when no subcommands are specified 15 | type ActionFunc func(*Context) error 16 | 17 | // CommandNotFoundFunc is executed if the proper command cannot be found 18 | type CommandNotFoundFunc func(*Context, string) 19 | 20 | // OnUsageErrorFunc is executed if an usage error occurs. This is useful for displaying 21 | // customized usage error messages. This function is able to replace the 22 | // original error messages. If this function is not set, the "Incorrect usage" 23 | // is displayed and the execution is interrupted. 24 | type OnUsageErrorFunc func(context *Context, err error, isSubcommand bool) error 25 | 26 | // FlagStringFunc is used by the help generation to display a flag, which is 27 | // expected to be a single line. 28 | type FlagStringFunc func(Flag) string 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/.gitattributes: -------------------------------------------------------------------------------- 1 | # Treat all files in this repo as binary, with no git magic updating 2 | # line endings. Windows users contributing to Go will need to use a 3 | # modern version of git and editors capable of LF line endings. 4 | # 5 | # We'll prevent accidental CRLF line endings from entering the repo 6 | # via the git-review gofmt checks. 7 | # 8 | # See golang.org/issue/9281 9 | 10 | * -text 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/.gitignore: -------------------------------------------------------------------------------- 1 | # Add no patterns to .hgignore except for files generated by the build. 2 | last-change 3 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Go 2 | 3 | Go is an open source project. 4 | 5 | It is the work of hundreds of contributors. We appreciate your help! 6 | 7 | 8 | ## Filing issues 9 | 10 | When [filing an issue](https://golang.org/issue/new), make sure to answer these five questions: 11 | 12 | 1. What version of Go are you using (`go version`)? 13 | 2. What operating system and processor architecture are you using? 14 | 3. What did you do? 15 | 4. What did you expect to see? 16 | 5. What did you see instead? 17 | 18 | General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker. 19 | The gophers there will answer or ask you to file an issue if you've tripped over a bug. 20 | 21 | ## Contributing code 22 | 23 | Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) 24 | before sending patches. 25 | 26 | **We do not accept GitHub pull requests** 27 | (we use [Gerrit](https://code.google.com/p/gerrit/) instead for code review). 28 | 29 | Unless otherwise noted, the Go source files are distributed under 30 | the BSD-style license found in the LICENSE file. 31 | 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/README: -------------------------------------------------------------------------------- 1 | This repository holds supplementary Go networking libraries. 2 | 3 | To submit changes to this repository, see http://golang.org/doc/contribute.html. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/codereview.cfg: -------------------------------------------------------------------------------- 1 | issuerepo: golang/go 2 | -------------------------------------------------------------------------------- /vendor/golang.org/x/net/proxy/direct.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package proxy 6 | 7 | import ( 8 | "net" 9 | ) 10 | 11 | type direct struct{} 12 | 13 | // Direct is a direct proxy: one that makes network connections directly. 14 | var Direct = direct{} 15 | 16 | func (direct) Dial(network, addr string) (net.Conn, error) { 17 | return net.Dial(network, addr) 18 | } 19 | -------------------------------------------------------------------------------- /verifier/k8sResponse.go: -------------------------------------------------------------------------------- 1 | package verifier 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | 7 | "github.com/rancher/go-rancher/client" 8 | ) 9 | 10 | func (rvr *RancherK8sVerifiedResponse) PrepareResponse(verified bool, container *client.Container, c *client.RancherClient) error { 11 | 12 | rvr.verified = verified 13 | 14 | if _, ok := container.Labels["io.kubernetes.pod.namespace"].(string); !ok { 15 | return errors.New("No pod namespace found") 16 | } 17 | 18 | if _, ok := container.Labels["io.kubernetes.pod.namespace"].(string); !ok { 19 | return errors.New("Namespace could not be determined") 20 | } 21 | rvr.namespace = container.Labels["io.kubernetes.pod.namespace"].(string) 22 | 23 | project, err := getProjectFromAPIKey(c) 24 | if err != nil { 25 | return err 26 | } 27 | 28 | rvr.environmentName = project.Name 29 | 30 | if labelPath, ok := container.Labels["secrets.bridge.k8s.path"].(string); ok { 31 | rvr.labelPath = labelPath 32 | } 33 | 34 | // This shouldn't happen if the New Verifier Factory was used. 35 | if rvr.id == "" { 36 | rvr.id = container.ExternalId 37 | } 38 | 39 | return nil 40 | } 41 | 42 | func (rvr *RancherK8sVerifiedResponse) Path() string { 43 | if rvr.labelPath == "" { 44 | return fmt.Sprintf("%s/%s/%s", rvr.environmentName, rvr.namespace, rvr.id) 45 | } 46 | 47 | return fmt.Sprintf("%s/%s/%s/%s", rvr.environmentName, rvr.namespace, rvr.labelPath, rvr.id) 48 | } 49 | 50 | func (rvr *RancherK8sVerifiedResponse) Verified() bool { 51 | return rvr.verified 52 | } 53 | 54 | func (rvr *RancherK8sVerifiedResponse) ID() string { 55 | return rvr.id 56 | } 57 | -------------------------------------------------------------------------------- /verifier/rancherResponse.go: -------------------------------------------------------------------------------- 1 | package verifier 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/rancher/go-rancher/client" 7 | ) 8 | 9 | func (rvr *RancherVerifiedResponse) PrepareResponse(verified bool, container *client.Container, c *client.RancherClient) error { 10 | svc, err := getServiceFromContainer(c, container) 11 | if err != nil { 12 | return err 13 | } 14 | 15 | stk, err := getStackFromService(c, svc) 16 | if err != nil { 17 | return err 18 | } 19 | 20 | env, err := getEnvFromStack(c, stk) 21 | if err != nil { 22 | return err 23 | } 24 | 25 | rvr.verified = verified 26 | rvr.serviceName = svc.Name 27 | rvr.stackName = stk.Name 28 | rvr.environmentName = env.Name 29 | rvr.containerName = container.Name 30 | rvr.id = container.ExternalId 31 | 32 | return nil 33 | } 34 | 35 | func (rvr *RancherVerifiedResponse) Path() string { 36 | return fmt.Sprintf("%s/%s/%s/%s", rvr.environmentName, rvr.stackName, rvr.serviceName, rvr.containerName) 37 | } 38 | 39 | func (rvr *RancherVerifiedResponse) Verified() bool { 40 | return rvr.verified 41 | } 42 | 43 | func (rvr *RancherVerifiedResponse) ID() string { 44 | return rvr.id 45 | } 46 | -------------------------------------------------------------------------------- /verifier/types.go: -------------------------------------------------------------------------------- 1 | package verifier 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/rancher/go-rancher/client" 7 | "github.com/rancher/secrets-bridge/types" 8 | ) 9 | 10 | type VerifiedResponse interface { 11 | Path() string 12 | Verified() bool 13 | ID() string 14 | PrepareResponse(bool, *client.Container, *client.RancherClient) error 15 | } 16 | 17 | func NewVerifiedResponse(msg *types.Message) (VerifiedResponse, error) { 18 | switch msg.ContainerType { 19 | case "kubernetes": 20 | return &RancherK8sVerifiedResponse{id: msg.Event.ID}, nil 21 | case "cattle": 22 | return &RancherVerifiedResponse{}, nil 23 | default: 24 | return nil, errors.New("Invalid Type") 25 | } 26 | } 27 | 28 | type RancherVerifiedResponse struct { 29 | verified bool 30 | serviceName string 31 | stackName string 32 | containerName string 33 | environmentName string 34 | id string 35 | } 36 | 37 | type RancherK8sVerifiedResponse struct { 38 | verified bool 39 | namespace string 40 | environmentName string 41 | labelPath string 42 | id string 43 | } 44 | -------------------------------------------------------------------------------- /verifier/utils.go: -------------------------------------------------------------------------------- 1 | package verifier 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/rancher/go-rancher/client" 7 | ) 8 | 9 | func getProjectFromAPIKey(c *client.RancherClient) (*client.Project, error) { 10 | projects, err := c.Project.List(&client.ListOpts{}) 11 | if err != nil { 12 | return nil, err 13 | } 14 | 15 | if len(projects.Data) == 0 { 16 | return nil, errors.New("No project found for key") 17 | } 18 | 19 | return &projects.Data[0], nil 20 | } 21 | 22 | func getServiceFromContainer(c *client.RancherClient, container *client.Container) (*client.Service, error) { 23 | var svc *client.ServiceCollection 24 | err := c.GetLink(container.Resource, "services", &svc) 25 | if err != nil { 26 | return nil, err 27 | } 28 | if len(svc.Data) == 0 { 29 | return nil, errors.New("Error: This container is not running inside a Rancher service") 30 | } 31 | 32 | return &svc.Data[0], nil 33 | } 34 | 35 | func getStackFromService(c *client.RancherClient, service *client.Service) (*client.Environment, error) { 36 | var stack *client.Environment 37 | err := c.GetLink(service.Resource, "environment", &stack) 38 | if err != nil || stack.Name == "" { 39 | return nil, err 40 | } 41 | return stack, nil 42 | } 43 | 44 | func getEnvFromStack(c *client.RancherClient, stk *client.Environment) (*client.Project, error) { 45 | var environment *client.Project 46 | err := c.GetLink(stk.Resource, "account", &environment) 47 | if err != nil || environment.Name == "" { 48 | return nil, err 49 | } 50 | return environment, nil 51 | } 52 | -------------------------------------------------------------------------------- /writer/container_fs.go: -------------------------------------------------------------------------------- 1 | package writer 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | "github.com/docker/engine-api/client" 6 | "github.com/docker/engine-api/types" 7 | "github.com/rancher/secrets-bridge/pkg/archive" 8 | "golang.org/x/net/context" 9 | ) 10 | 11 | type DockerContainerFSWriter struct { 12 | message string 13 | path string 14 | dockerClient *client.Client 15 | containerId string 16 | } 17 | 18 | type SecretWriter interface { 19 | Write() error 20 | } 21 | 22 | func NewSecretWriter(config map[string]interface{}) (SecretWriter, error) { 23 | return NewDockerContainerFSWriter(config) 24 | } 25 | 26 | func NewDockerContainerFSWriter(opts map[string]interface{}) (*DockerContainerFSWriter, error) { 27 | return &DockerContainerFSWriter{ 28 | message: opts["message"].(string), 29 | path: opts["path"].(string), 30 | dockerClient: opts["dockerClient"].(*client.Client), 31 | containerId: opts["containerId"].(string), 32 | }, nil 33 | } 34 | 35 | func (d *DockerContainerFSWriter) Write() error { 36 | // this will log the temp token.. but with short TTLs 37 | // the debug value outweighs the risk. 38 | logrus.Debugf("Writing message: %#v", d.message) 39 | files := []archive.ArchiveFile{ 40 | {"secrets.txt", d.message}, 41 | } 42 | tarball, err := archive.CreateTarArchive(files) 43 | if err != nil { 44 | logrus.Error("Failed to create Tar file") 45 | return err 46 | } 47 | 48 | // verify the path 49 | _, err = d.dockerClient.ContainerStatPath(context.Background(), d.containerId, d.path) 50 | if err != nil { 51 | return err 52 | } 53 | 54 | opts := types.CopyToContainerOptions{} 55 | 56 | if err = d.dockerClient.CopyToContainer(context.Background(), d.containerId, d.path, tarball, opts); err != nil { 57 | return err 58 | } 59 | 60 | return nil 61 | } 62 | --------------------------------------------------------------------------------