// addRequiredPackages is defined on the AdvancedPackagingConfig interface.
196427
func (cfg *ubuntuCloudConfig) addRequiredPackages() {
	packages := []string{
		"curl",
		"cpu-checker",
		// TODO(axw) 2014-07-02 #1277359
		// Don't install bridge-utils in cloud-init;
		// leave it to the networker worker.
		"bridge-utils",
		"cloud-utils",
		"tmux",
		// TODO(wpk) 2017-07-23 maybe we should do it in fanconfigurer?
		"ubuntu-fan",
	}

	// The required packages need to come from the correct repo.
	// For precise, that might require an explicit --target-release parameter.
	// We cannot just pass packages below, because
	// this will generate install commands which older
	// versions of cloud-init (e.g. 0.6.3 in precise) will
	// interpret incorrectly (see bug http://pad.lv/1424777).
	for _, pack := range packages {
		if config.SeriesRequiresCloudArchiveTools(cfg.series) && cfg.pacconfer.IsCloudArchivePackage(pack) {
			// On precise, we need to pass a --target-release entry in
			// pieces (as "packages") for it to work:
			// --target-release, precise-updates/cloud-tools,
			// package-name. All these 3 entries are needed so
			// cloud-init 0.6.3 can generate the correct apt-get
			// install command line for "package-name".
			args := cfg.pacconfer.ApplyCloudArchiveTarget(pack)
			for _, arg := range args {
				cfg.AddPackage(arg)
			}
		} else {
			cfg.AddPackage(pack)
		}
	}
}
1352890
func (impl *repoImpl) setPackageHidden(c context.Context, r *api.PackageRequest, hidden bool) (resp *empty.Empty, err error) {
	defer func() { err = grpcutil.GRPCifyAndLogErr(c, err) }()

	if err := common.ValidatePackageName(r.Package); err != nil {
		return nil, status.Errorf(codes.InvalidArgument, "bad 'package' - %s", err)
	}
	if _, err := impl.checkRole(c, r.Package, api.Role_OWNER); err != nil {
		return nil, err
	}

	switch err := model.SetPackageHidden(c, r.Package, hidden); {
	case err == datastore.ErrNoSuchEntity:
		return nil, status.Errorf(codes.NotFound, "no such package")
	case err != nil:
		return nil, errors.Annotate(err, "failed to update the package").Err()
	}
	return &empty.Empty{}, nil
}
1000969
func (c *CloudAPI) ListPackages(filters map[string]string) ([]cloudapi.Package, error) {
	if err := c.ProcessFunctionHook(c, filters); err != nil {
		return nil, err
	}

	availablePackages := c.packages

	if filters != nil {
		for k, f := range filters {
			// check if valid filter
			if contains(packagesFilters, k) {
				pkgs := []cloudapi.Package{}
				// filter from availablePackages and add to pkgs
				for _, p := range availablePackages {
					if k == "name" && p.Name == f {
						pkgs = append(pkgs, p)
					} else if k == "memory" {
						i, err := strconv.Atoi(f)
						if err == nil && p.Memory == i {
							pkgs = append(pkgs, p)
						}
					} else if k == "disk" {
						i, err := strconv.Atoi(f)
						if err == nil && p.Disk == i {
							pkgs = append(pkgs, p)
						}
					} else if k == "swap" {
						i, err := strconv.Atoi(f)
						if err == nil && p.Swap == i {
							pkgs = append(pkgs, p)
						}
					} else if k == "version" && p.Version == f {
						pkgs = append(pkgs, p)
					} else if k == "vcpus" {
						i, err := strconv.Atoi(f)
						if err == nil && p.VCPUs == i {
							pkgs = append(pkgs, p)
						}
					} else if k == "group" && p.Group == f {
						pkgs = append(pkgs, p)
					}
				}
				availablePackages = pkgs
			}
		}
	}

	return availablePackages, nil
}
168632
func (s *SchemaAttributeType) SetRequired(v bool) *SchemaAttributeType {
	s.Required = &v
	return s
}
1337921
func (b *bridge) ListPackages(id ProjectIdentifier, v Version) (pkgtree.PackageTree, error) {
	if b.s.rd.isRoot(id.ProjectRoot) {
		return b.s.rd.rpt, nil
	}

	b.s.mtr.push("b-list-pkgs")
	pt, err := b.sm.ListPackages(id, v)
	b.s.mtr.pop()
	return pt, err
}
1223541
func MustParsePackage(input string) *Package {
	parsed, err := ParsePackage(input)
	if err != nil {
		panic(err)
	}
	return parsed
}
1255952
func (s *RegisterTaskDefinitionInput) SetRequiresCompatibilities(v []*string) *RegisterTaskDefinitionInput {
	s.RequiresCompatibilities = v
	return s
}
660318
func (c *Conn) hideSetRequiredAcks(n int) error {
	switch n {
	case -1, 1:
		atomic.StoreInt32(&c.requiredAcks, int32(n))
		return nil
	default:
		return InvalidRequiredAcks
	}
}
1280948
func (cfg *windowsCloudConfig) AddPackageCommands(
	aptProxySettings proxy.Settings,
	aptMirror string,
	addUpdateScripts bool,
	addUpgradeScripts bool,
) {
	return
}
315000
func (cfg *ubuntuCloudConfig) AddPackageSource(src packaging.PackageSource) {
	cfg.attrs["apt_sources"] = append(cfg.PackageSources(), src)
}
1002754
func (v *ValidationDefinition) AddRequired(required []string) {
	for _, r := range required {
		found := false
		for _, rr := range v.Required {
			if r == rr {
				found = true
				break
			}
		}
		if !found {
			v.Required = append(v.Required, r)
		}
	}
}
1147467
func (client *Client) GetPackages(query ...Query) ([]Package, Warnings, error) {
	request, err := client.newHTTPRequest(requestOptions{
		RequestName: internal.GetPackagesRequest,
		Query:       query,
	})
	if err != nil {
		return nil, nil, err
	}

	var fullPackagesList []Package
	warnings, err := client.paginate(request, Package{}, func(item interface{}) error {
		if pkg, ok := item.(Package); ok {
			fullPackagesList = append(fullPackagesList, pkg)
		} else {
			return ccerror.UnknownObjectInListError{
				Expected:   Package{},
				Unexpected: item,
			}
		}
		return nil
	})

	return fullPackagesList, warnings, err
}
338813
func addPackageCommandsCommon(
	cfg CloudConfig,
	packageProxySettings proxy.Settings,
	packageMirror string,
	addUpdateScripts bool,
	addUpgradeScripts bool,
	series string,
) {
	// Set the package mirror.
	cfg.SetPackageMirror(packageMirror)

	// For LTS series which need support for the cloud-tools archive,
	// we need to enable package-list update regardless of the environ
	// setting, otherwise bootstrap or provisioning will fail.
	if config.SeriesRequiresCloudArchiveTools(series) && !addUpdateScripts {
		addUpdateScripts = true
	}

	// Bring packages up-to-date.
	cfg.SetSystemUpdate(addUpdateScripts)
	cfg.SetSystemUpgrade(addUpgradeScripts)

	// Always run this step - this is where we install packages that juju
	// requires.
	cfg.addRequiredPackages()

	// TODO(bogdanteleaga): Deal with proxy settings on CentOS
	cfg.updateProxySettings(packageProxySettings)
}
1306332
func addPackage(pkgName, typeStr string) string {
	if typeStr == "" {
		return ""
	}

	// we can't use raml package to get basic type and decide whether it is array
	// or not because in this phase the type is already Go type, not RAML type
	switch {
	case strings.HasPrefix(typeStr, "[][]"): // bidimensi array
		return "[][]" + addPackage(pkgName, strings.TrimPrefix(typeStr, "[][]"))
	case strings.HasPrefix(typeStr, "[]"): // array array
		return "[]" + addPackage(pkgName, strings.TrimPrefix(typeStr, "[]"))
	default:
		return aliasPackage(fmt.Sprintf("%v.%v", pkgName, typeStr))
	}
}
1360983
func (s *Layer) SetPackages(v []*string) *Layer {
	s.Packages = v
	return s
}
774947
func (impl *repoImpl) HidePackage(c context.Context, r *api.PackageRequest) (*empty.Empty, error) {
	return impl.setPackageHidden(c, r, model.Hidden)
}
300285
func (c *Config) AddLoaders(loaders ...Loader) *Config {
	c.lock.Lock()
	defer c.lock.Unlock()

	c.loaders = append(c.loaders, loaders...)
	return c
}