Skip to content

Commit

Permalink
AssetBuilder does not use Phase; removing
Browse files Browse the repository at this point in the history
  • Loading branch information
justinsb committed Dec 18, 2017
1 parent dd49d69 commit 481d8f8
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 28 deletions.
2 changes: 1 addition & 1 deletion cmd/kops/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ func RunCreateCluster(f *util.Factory, out io.Writer, c *CreateClusterOptions) e
return err
}

assetBuilder := assets.NewAssetBuilder(cluster.Spec.Assets, "")
assetBuilder := assets.NewAssetBuilder(cluster.Spec.Assets)
fullCluster, err := cloudup.PopulateClusterSpec(clientset, cluster, assetBuilder)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/kops/edit_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func RunEditCluster(f *util.Factory, cmd *cobra.Command, args []string, out io.W
return preservedFile(fmt.Errorf("error populating configuration: %v", err), file, out)
}

assetBuilder := assets.NewAssetBuilder(newCluster.Spec.Assets, "")
assetBuilder := assets.NewAssetBuilder(newCluster.Spec.Assets)
fullCluster, err := cloudup.PopulateClusterSpec(clientset, newCluster, assetBuilder)
if err != nil {
results = editResults{
Expand Down
2 changes: 1 addition & 1 deletion cmd/kops/edit_instancegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func RunEditInstanceGroup(f *util.Factory, cmd *cobra.Command, args []string, ou
return fmt.Errorf("error populating configuration: %v", err)
}

assetBuilder := assets.NewAssetBuilder(cluster.Spec.Assets, "")
assetBuilder := assets.NewAssetBuilder(cluster.Spec.Assets)
fullCluster, err := cloudup.PopulateClusterSpec(clientset, cluster, assetBuilder)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/kops/upgrade_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func (c *UpgradeClusterCmd) Run(args []string) error {
return fmt.Errorf("error populating configuration: %v", err)
}

assetBuilder := assets.NewAssetBuilder(cluster.Spec.Assets, "")
assetBuilder := assets.NewAssetBuilder(cluster.Spec.Assets)
fullCluster, err := cloudup.PopulateClusterSpec(clientset, cluster, assetBuilder)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion nodeup/pkg/model/protokube.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (t *ProtokubeBuilder) ProtokubeFlags(k8sVersion semver.Version) (*Protokube

// TODO this is dupicate code with etcd model
image := fmt.Sprintf("gcr.io/google_containers/etcd:%s", imageVersion)
assets := assets.NewAssetBuilder(t.Cluster.Spec.Assets, "")
assets := assets.NewAssetBuilder(t.Cluster.Spec.Assets)
remapped, err := assets.RemapImage(image)
if err != nil {
return nil, fmt.Errorf("unable to remap container %q: %v", image, err)
Expand Down
5 changes: 1 addition & 4 deletions pkg/assets/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ type AssetBuilder struct {
ContainerAssets []*ContainerAsset
FileAssets []*FileAsset
AssetsLocation *kops.Assets
// TODO we'd like to use cloudup.Phase here, but that introduces a go cyclic dependency
Phase string
}

// ContainerAsset models a container's location.
Expand All @@ -69,10 +67,9 @@ type FileAsset struct {
}

// NewAssetBuilder creates a new AssetBuilder.
func NewAssetBuilder(assets *kops.Assets, phase string) *AssetBuilder {
func NewAssetBuilder(assets *kops.Assets) *AssetBuilder {
return &AssetBuilder{
AssetsLocation: assets,
Phase: phase,
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/model/components/kubecontrollermanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func buildCluster() *api.Cluster {

func Test_Build_KCM_Builder_Lower_Version(t *testing.T) {
versions := []string{"v1.4.0", "v1.4.7", "v1.5.0"}
b := assets.NewAssetBuilder(nil, "")
b := assets.NewAssetBuilder(nil)

for _, v := range versions {

Expand Down Expand Up @@ -73,7 +73,7 @@ func Test_Build_KCM_Builder_Lower_Version(t *testing.T) {

func Test_Build_KCM_Builder_High_Enough_Version(t *testing.T) {
versions := []string{"v1.4.8", "v1.5.2", "v1.9.0", "v2.4.0"}
b := assets.NewAssetBuilder(nil, "")
b := assets.NewAssetBuilder(nil)
for _, v := range versions {

c := buildCluster()
Expand Down Expand Up @@ -104,7 +104,7 @@ func Test_Build_KCM_Builder_Change_Duration(t *testing.T) {
c := buildCluster()
c.Spec.KubernetesVersion = "v1.5.2"

b := assets.NewAssetBuilder(nil, "")
b := assets.NewAssetBuilder(nil)
kcm := &KubeControllerManagerOptionsBuilder{
Context: &OptionsContext{
AssetBuilder: b,
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/components/kubelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func buildSpec() *kops.ClusterSpec {
}

func buildOptions(spec *kops.ClusterSpec) error {
ab := assets.NewAssetBuilder(nil, "")
ab := assets.NewAssetBuilder(nil)

ver, err := KubernetesVersion(spec)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/model/components/kubescheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func buildSchedulerConfigMapCluster() *api.Cluster {

func Test_Build_Scheduler_Without_PolicyConfigMap(t *testing.T) {
versions := []string{"v1.6.0", "v1.6.4", "v1.7.0", "v1.7.4"}
b := assets.NewAssetBuilder(nil, "")
b := assets.NewAssetBuilder(nil)

for _, v := range versions {

Expand Down Expand Up @@ -72,7 +72,7 @@ func Test_Build_Scheduler_Without_PolicyConfigMap(t *testing.T) {
}
func Test_Build_Scheduler_PolicyConfigMap_Unsupported_Version(t *testing.T) {
versions := []string{"v1.6.0", "v1.6.4"}
b := assets.NewAssetBuilder(nil, "")
b := assets.NewAssetBuilder(nil)

for _, v := range versions {

Expand Down Expand Up @@ -105,7 +105,7 @@ func Test_Build_Scheduler_PolicyConfigMap_Unsupported_Version(t *testing.T) {

func Test_Build_Scheduler_PolicyConfigMap_Supported_Version(t *testing.T) {
versions := []string{"v1.7.0", "v1.7.4", "v1.8.0"}
b := assets.NewAssetBuilder(nil, "")
b := assets.NewAssetBuilder(nil)

for _, v := range versions {

Expand Down
5 changes: 1 addition & 4 deletions upup/pkg/fi/cloudup/apply_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,7 @@ func (c *ApplyClusterCmd) Run() error {
return fmt.Errorf("unknown phase %q", c.Phase)
}

// This is kinda a hack. Need to move phases out of fi. If we use Phase here we introduce a circular
// go dependency.
phase := string(c.Phase)
assetBuilder := assets.NewAssetBuilder(c.Cluster.Spec.Assets, phase)
assetBuilder := assets.NewAssetBuilder(c.Cluster.Spec.Assets)
err = c.upgradeSpecs(assetBuilder)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion upup/pkg/fi/cloudup/awstasks/elastic_ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestElasticIPCreate(t *testing.T) {
}

func checkNoChanges(t *testing.T, cloud fi.Cloud, allTasks map[string]fi.Task) {
assetBuilder := assets.NewAssetBuilder(nil, "")
assetBuilder := assets.NewAssetBuilder(nil)
target := fi.NewDryRunTarget(assetBuilder, os.Stderr)
context, err := fi.NewContext(target, nil, cloud, nil, nil, nil, true, allTasks)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion upup/pkg/fi/cloudup/bootstrapchannelbuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func runChannelBuilderTest(t *testing.T, key string) {
bcb := BootstrapChannelBuilder{
cluster: cluster,
templates: templates,
assetBuilder: assets.NewAssetBuilder(nil, ""),
assetBuilder: assets.NewAssetBuilder(nil),
}

context := &fi.ModelBuilderContext{
Expand Down
6 changes: 3 additions & 3 deletions upup/pkg/fi/cloudup/networking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func Test_FindCNIAssetFromEnvironmentVariable(t *testing.T) {
}()

cluster := &api.Cluster{}
assetBuilder := assets.NewAssetBuilder(nil, "")
assetBuilder := assets.NewAssetBuilder(nil)
cniAsset, cniAssetHashString, err := findCNIAssets(cluster, assetBuilder)

if err != nil {
Expand All @@ -53,7 +53,7 @@ func Test_FindCNIAssetDefaultValue1_6(t *testing.T) {

cluster := &api.Cluster{Spec: api.ClusterSpec{}}
cluster.Spec.KubernetesVersion = "v1.7.0"
assetBuilder := assets.NewAssetBuilder(nil, "")
assetBuilder := assets.NewAssetBuilder(nil)
cniAsset, cniAssetHashString, err := findCNIAssets(cluster, assetBuilder)

if err != nil {
Expand All @@ -74,7 +74,7 @@ func Test_FindCNIAssetDefaultValue1_5(t *testing.T) {

cluster := &api.Cluster{Spec: api.ClusterSpec{}}
cluster.Spec.KubernetesVersion = "v1.5.12"
assetBuilder := assets.NewAssetBuilder(nil, "")
assetBuilder := assets.NewAssetBuilder(nil)
cniAsset, cniAssetHashString, err := findCNIAssets(cluster, assetBuilder)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion upup/pkg/fi/cloudup/populatecluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestPopulateCluster_Default_NoError(t *testing.T) {
func mockedPopulateClusterSpec(c *api.Cluster) (*api.Cluster, error) {
vfs.Context.ResetMemfsContext(true)

assetBuilder := assets.NewAssetBuilder(nil, "")
assetBuilder := assets.NewAssetBuilder(nil)
basePath, err := vfs.Context.BuildVfsPath("memfs://tests")
if err != nil {
return nil, fmt.Errorf("error building vfspath: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion upup/pkg/fi/nodeup/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (c *NodeUpCommand) Run(out io.Writer) error {
Tags: nodeTags,
}
case "dryrun":
assetBuilder := assets.NewAssetBuilder(c.cluster.Spec.Assets, "")
assetBuilder := assets.NewAssetBuilder(c.cluster.Spec.Assets)
target = fi.NewDryRunTarget(assetBuilder, out)
case "cloudinit":
checkExisting = false
Expand Down
2 changes: 1 addition & 1 deletion upup/pkg/kutil/convert_kubeup_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (x *ConvertKubeupCluster) Upgrade() error {
delete(cluster.ObjectMeta.Annotations, api.AnnotationNameManagement)
}

assetBuilder := assets.NewAssetBuilder(cluster.Spec.Assets, "")
assetBuilder := assets.NewAssetBuilder(cluster.Spec.Assets)
fullCluster, err := cloudup.PopulateClusterSpec(x.Clientset, cluster, assetBuilder)
if err != nil {
return err
Expand Down

0 comments on commit 481d8f8

Please sign in to comment.