Skip to content

Commit

Permalink
Merge pull request #22 from jack-w-shaw/JUJU-4948_remove_unused_serie…
Browse files Browse the repository at this point in the history
…s_function

Remove unused functions + drop series before focal
  • Loading branch information
jack-w-shaw committed Apr 16, 2024
2 parents 6786bbb + 3e84d38 commit 0573320
Show file tree
Hide file tree
Showing 38 changed files with 52 additions and 505 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PROJECT := github.com/juju/packaging/v2
PROJECT := github.com/juju/packaging/v3

.PHONY: check-licence check-go check

Expand Down
2 changes: 1 addition & 1 deletion commands/apt.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

package commands

import "github.com/juju/packaging/v2/config"
import "github.com/juju/packaging/v3/config"

const (
// AptConfFilePath is the full file path for the proxy settings that are
Expand Down
2 changes: 1 addition & 1 deletion commands/apt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/juju/proxy"
gc "gopkg.in/check.v1"

"github.com/juju/packaging/v2/commands"
"github.com/juju/packaging/v3/commands"
)

var _ = gc.Suite(&AptSuite{})
Expand Down
2 changes: 1 addition & 1 deletion commands/snap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/juju/proxy"
gc "gopkg.in/check.v1"

"github.com/juju/packaging/v2/commands"
"github.com/juju/packaging/v3/commands"
)

var _ = gc.Suite(&SnapSuite{})
Expand Down
2 changes: 1 addition & 1 deletion commands/yum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/juju/proxy"
gc "gopkg.in/check.v1"

"github.com/juju/packaging/v2/commands"
"github.com/juju/packaging/v3/commands"
)

var _ = gc.Suite(&YumSuite{})
Expand Down
2 changes: 1 addition & 1 deletion commands/zypper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/juju/proxy"
gc "gopkg.in/check.v1"

"github.com/juju/packaging/v2/commands"
"github.com/juju/packaging/v3/commands"
)

var _ = gc.Suite(&ZypperSuite{})
Expand Down
24 changes: 2 additions & 22 deletions config/apt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
package config_test

import (
"fmt"

jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"

"github.com/juju/packaging/v2/config"
"github.com/juju/packaging/v3/config"
)

var _ = gc.Suite(&AptSuite{})
Expand All @@ -20,29 +18,13 @@ type AptSuite struct {
}

func (s *AptSuite) SetUpSuite(c *gc.C) {
s.pacconfer = config.NewAptPackagingConfigurer(testedSeriesUbuntu)
s.pacconfer = config.NewAptPackagingConfigurer()
}

func (s *AptSuite) TestDefaultPackages(c *gc.C) {
c.Assert(s.pacconfer.DefaultPackages(), gc.DeepEquals, config.UbuntuDefaultPackages)
}

func (s *AptSuite) TestGetPackageNameForSeriesSameSeries(c *gc.C) {
for _, pack := range testedPackages {
res, err := s.pacconfer.GetPackageNameForSeries(pack, testedSeriesUbuntu)
c.Assert(err, jc.ErrorIsNil)
c.Assert(res, gc.Equals, pack)
}
}

func (s *AptSuite) TestGetPackageNameForSeriesErrors(c *gc.C) {
for _, pack := range testedPackages {
res, err := s.pacconfer.GetPackageNameForSeries(pack, "some-other-series")
c.Assert(res, gc.Equals, "")
c.Assert(err, gc.ErrorMatches, fmt.Sprintf("no equivalent package found for series %s: %s", "some-other-series", pack))
}
}

func (s *AptSuite) TestIsCloudArchivePackage(c *gc.C) {
testedPacks := []string{
"random",
Expand Down Expand Up @@ -85,8 +67,6 @@ func (s *AptSuite) TestRenderPreferences(c *gc.C) {
func (s *AptSuite) TestApplyCloudArchiveTarget(c *gc.C) {
res := s.pacconfer.ApplyCloudArchiveTarget("some-package")
c.Assert(res, gc.DeepEquals, []string{
"--target-release",
"precise-updates/cloud-tools",
"some-package",
})
}
18 changes: 0 additions & 18 deletions config/centos_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@

package config

import (
"github.com/juju/packaging/v2"
)

const (
// CentOSCloudArchiveUrl is the url of the (future) cloud archive for CentOS.
// TODO (people of the distant future): add this when it is available.
Expand Down Expand Up @@ -39,17 +35,3 @@ var cloudArchivePackagesCentOS = map[string]struct{}{
// CentOS 7+ especially for Juju is to ever occur, please add the relevant
// package listings here.
}

// centOSToUbuntuPackageNameMap is a map for converting package names from
// their names as found in CentOS repositories to their equivalent in Ubuntu.
// It is implemented as the flipped package mapper for Ubuntu.
var centOSToUbuntuPackageNameMap = flipMap(ubuntuToCentOSPackageNameMap)

// configureCloudArchiveSourceCentOS is a helper function which returns the
// cloud archive PackageSource and PackagePreferences for the given series for
// CentOS machines.
func configureCloudArchiveSourceCentOS(series string) (packaging.PackageSource, packaging.PackagePreferences) {
// TODO (aznashwan, all): implement this when the
// archive for CentOS goes up.
return packaging.PackageSource{}, packaging.PackagePreferences{}
}
29 changes: 0 additions & 29 deletions config/configurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@

package config

import (
"github.com/juju/errors"
)

// baseConfigurer is the base type of a Configurer object.
type baseConfigurer struct {
series string
defaultPackages []string
cloudArchivePackages map[string]struct{}
}
Expand All @@ -20,30 +15,6 @@ func (c *baseConfigurer) DefaultPackages() []string {
return c.defaultPackages
}

// GetPackageNameForSeries is defined on the PackagingConfigurer interface.
func (c *baseConfigurer) GetPackageNameForSeries(pack, series string) (string, error) {
if c.series == series {
return pack, nil
}

// TODO(aznashwan): find a more deterministic way of filtering series that
// does not imply importing version from core.
switch series {
case "centos7":
res, ok := centOSToUbuntuPackageNameMap[pack]
if !ok {
return "", errors.Errorf("no equivalent package found for series %s: %s", series, pack)
}
return res, nil
default:
res, ok := ubuntuToCentOSPackageNameMap[pack]
if !ok {
return "", errors.Errorf("no equivalent package found for series %s: %s", series, pack)
}
return res, nil
}
}

// IsCloudArchivePackage is defined on the PackagingConfigurer interface.
func (c *baseConfigurer) IsCloudArchivePackage(pack string) bool {
_, ok := c.cloudArchivePackages[pack]
Expand Down
4 changes: 2 additions & 2 deletions config/configurer_apt.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package config

import (
"github.com/juju/packaging/v2"
"github.com/juju/packaging/v3"
)

// aptConfigurer is the PackagingConfigurer implementation for apt-based systems.
Expand All @@ -25,5 +25,5 @@ func (c *aptConfigurer) RenderPreferences(prefs packaging.PackagePreferences) (s

// ApplyCloudArchiveTarget is defined on the PackagingConfigurer interface.
func (c *aptConfigurer) ApplyCloudArchiveTarget(pack string) []string {
return []string{"--target-release", getTargetReleaseSpecifierUbuntu(c.series), pack}
return []string{pack}
}
2 changes: 1 addition & 1 deletion config/configurer_yum.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package config

import (
"github.com/juju/packaging/v2"
"github.com/juju/packaging/v3"
)

// yumConfigurer is the PackagingConfigurer implementation for apt-based systems.
Expand Down
2 changes: 1 addition & 1 deletion config/configurer_zypper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package config

import (
"github.com/juju/packaging/v2"
"github.com/juju/packaging/v3"
)

// yumConfigurer is the PackagingConfigurer implementation for apt-based systems.
Expand Down
19 changes: 1 addition & 18 deletions config/constants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,9 @@

package config_test

import "github.com/juju/packaging/v2"
import "github.com/juju/packaging/v3"

var (
// testedSeriesUbuntu is simply the series to use in Ubuntu tests.
testedSeriesUbuntu = "precise"

// testedSeriesCentOS is simply the series we use in CentOS tests.
testedSeriesCentOS = "centos7"

// testedSeriesOpenSUSE is simply the series we use in OpenSUSE tests.
testedSeriesOpenSUSE = "opensuseleap"

// testedPackages is a slice of random package tests to run tests on.
testedPackages = []string{
"awesome-wm",
"archey3",
"arch-chroot",
"ranger",
}

testedSource = packaging.PackageSource{
Name: "Some Totally Official Source.",
URL: "some-source.com/packages",
Expand Down
1 change: 0 additions & 1 deletion config/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ var (
CloudArchivePackagesUbuntu = cloudArchivePackagesUbuntu
CloudArchivePackagesCentOS = cloudArchivePackagesCentOS
CloudArchivePackagesOpenSUSE = cloudArchivePackagesOpenSUSE
SeriesRequiringCloudTools = seriesRequiringCloudTools
)
44 changes: 0 additions & 44 deletions config/functions.go

This file was deleted.

81 changes: 0 additions & 81 deletions config/functions_test.go

This file was deleted.

10 changes: 0 additions & 10 deletions config/global_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,11 @@ function package_manager_loop {
)

var (
seriesRequiringCloudTools = map[string]bool{
// TODO (aznashwan, all): add any other OS's
// which require cloud tools' series here.
"precise": true,
}

// DefaultPackages is a list of the default packages Juju'd like to see
// installed on all it's machines.
DefaultPackages = []string{
// TODO (everyone): populate this list with all required packages.
// for example:
"curl",
}

backportsBySeries = map[string][]string{
"trusty": {"lxd"},
}
)
Loading

0 comments on commit 0573320

Please sign in to comment.