Example #1
0
func parseInputVersions() (paths []string, groups []types.GroupVersions, gvToPath map[types.GroupVersion]string, err error) {
	var seenGroups = make(map[types.Group]*types.GroupVersions)
	gvToPath = make(map[types.GroupVersion]string)
	for _, input := range *inputVersions {
		gvPath, gvString := parsePathGroupVersion(input)
		gv, err := types.ToGroupVersion(gvString)
		if err != nil {
			return nil, nil, nil, err
		}
		if group, ok := seenGroups[gv.Group]; ok {
			(*seenGroups[gv.Group]).Versions = append(group.Versions, gv.Version)
		} else {
			seenGroups[gv.Group] = &types.GroupVersions{
				Group:    gv.Group,
				Versions: []types.Version{gv.Version},
			}
		}

		path := versionToPath(gvPath, gv.Group.String(), gv.Version.String())
		paths = append(paths, path)
		gvToPath[gv] = path
	}
	var groupNames []string
	for groupName := range seenGroups {
		groupNames = append(groupNames, groupName.String())
	}
	sort.Strings(groupNames)
	for _, groupName := range groupNames {
		groups = append(groups, *seenGroups[types.Group(groupName)])
	}

	return paths, groups, gvToPath, nil
}
Example #2
0
func parseIncludedTypesOverrides() (map[types.GroupVersion][]string, error) {
	overrides := make(map[types.GroupVersion][]string)
	for _, input := range *includedTypesOverrides {
		gvString, typeStr, err := parseGroupVersionType(input)
		if err != nil {
			return nil, err
		}
		gv, err := types.ToGroupVersion(gvString)
		if err != nil {
			return nil, err
		}
		types, ok := overrides[gv]
		if !ok {
			types = []string{}
		}
		types = append(types, typeStr)
		overrides[gv] = types
	}
	return overrides, nil
}