예제 #1
0
파일: commands.go 프로젝트: rdgreis/machine
		}

		if err := utils.GenerateCert([]string{""}, clientCertPath, clientKeyPath, caCertPath, caKeyPath, org, bits); err != nil {
			log.Fatalf("Error generating client certificate: %s", err)
		}
	}

	return nil
}

var sharedCreateFlags = []cli.Flag{
	cli.StringFlag{
		Name: "driver, d",
		Usage: fmt.Sprintf(
			"Driver to create machine with. Available drivers: %s",
			strings.Join(drivers.GetDriverNames(), ", "),
		),
		Value: "none",
	},
	cli.StringFlag{
		Name:   "engine-install-url",
		Usage:  "Custom URL to use for engine installation",
		Value:  "https://get.docker.com",
		EnvVar: "MACHINE_DOCKER_INSTALL_URL",
	},
	cli.StringSliceFlag{
		Name:  "engine-opt",
		Usage: "Specify arbitrary flags to include with the created engine in the form flag=value",
		Value: &cli.StringSlice{},
	},
	cli.StringSliceFlag{
예제 #2
0
func fetchData() (*helpers.ResourceData, error) {
	blacklist := loadBlacklist()
	resourceMap := make(map[string]helpers.ResourceFields)
	documentationMap := make(map[string][]helpers.DocumentationFields)
	for _, driver := range drivers.GetDriverNames() {
		resourceFieldStruct := make(helpers.ResourceFields)
		resourceFieldMap := make(helpers.ResourceFieldConfigs)
		resourceFieldStruct["resourceFields"] = resourceFieldMap
		resourceMap[driver] = resourceFieldStruct
		documentationFieldStruct := new(helpers.DocumentationFields)
		documentationFieldMap := make(helpers.DocumentationFieldConfigs)
		documentationFieldStruct.ResourceFields = documentationFieldMap
		documentationFieldStruct.Id = driver + "Config"
		documentationMap[driver] = []helpers.DocumentationFields{*documentationFieldStruct}
		createFlags, err := drivers.GetCreateFlagsForDriver(driver)
		if err != nil {
			return nil, fmt.Errorf("error getting create flags for driver=%s, err=%v", driver, err)
		}
		for _, flagStruct := range createFlags {
			var flagName, flagType, description string
			var err error
			switch flagStruct.(type) {
			case cli.StringFlag:
				flag := flagStruct.(cli.StringFlag)
				flagName, err = getRancherName(flag.Name)
				if err != nil {
					return nil, fmt.Errorf("error getting the rancher name of flagStruct=%v for driver=%s, err=%v", flagStruct, driver, err)
				}
				flagType = "string"
				description = flag.Usage
			case cli.IntFlag:
				flag := flagStruct.(cli.IntFlag)
				flagName, err = getRancherName(flag.Name)
				if err != nil {
					return nil, fmt.Errorf("error getting the rancher name of flagStruct=%v for driver=%s, err=%v", flagStruct, driver, err)
				}
				flagType = "string"
				description = flag.Usage
			case cli.BoolFlag:
				flag := flagStruct.(cli.BoolFlag)
				flagName, err = getRancherName(flag.Name)
				if err != nil {
					return nil, fmt.Errorf("error getting the rancher name of flagStruct=%v for driver=%s, err=%v", flagStruct, driver, err)
				}
				flagType = "boolean"
				description = flag.Usage
			case cli.BoolTFlag:
				flag := flagStruct.(cli.BoolTFlag)
				flagName, err = getRancherName(flag.Name)
				if err != nil {
					return nil, fmt.Errorf("error getting the rancher name of flagStruct=%v for driver=%s, err=%v", flagStruct, driver, err)
				}
				flagType = "boolean"
				description = flag.Usage
			case cli.StringSliceFlag:
				flag := flagStruct.(cli.StringSliceFlag)
				flagName, err = getRancherName(flag.Name)
				if err != nil {
					return nil, fmt.Errorf("error getting the rancher name of flagStruct=%v for driver=%s, err=%v", flagStruct, driver, err)
				}
				flagType = "array[string]"
				description = flag.Usage
			default:
				return nil, fmt.Errorf("unknown type of flag %v, for driver=%s", flagStruct, driver)
			}
			documentationFieldMap[flagName] = helpers.DocumentationFieldConfig{Description: description}
			resourceFieldMap[flagName] = helpers.ResourceFieldConfig{Type: flagType, Nullable: true, Required: false}
		}
	}
	return &helpers.ResourceData{Blacklist: blacklist, Drivers: drivers.GetDriverNames(), ResourceMap: resourceMap, DocumentationMap: documentationMap}, nil
}