Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Move ResourceID from root to resource package #2201

Merged
merged 1 commit into from
Jun 27, 2019
Merged

Move ResourceID from root to resource package #2201

merged 1 commit into from
Jun 27, 2019

Conversation

stefanprodan
Copy link
Member

@stefanprodan stefanprodan commented Jun 27, 2019

  • move ResourceID from root to resource package
  • move Update type from policy pkg to resource pkg to avoid circular dependency
  • rename resource.Update to resource.PolicyUpdate
  • rename ResourceID and related functions to ID
  • run go fmt on all files

@squaremo
Copy link
Member

ResourceID should really be resource.ID. This PR tidies a file away, but since it just introduces another package, it's a big diff for a modest tidy.

@stefanprodan stefanprodan changed the title Move ResourceID from root to its own package Move ResourceID from root to resource package Jun 27, 2019
Copy link
Member

@squaremo squaremo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • the resource import seems to have got jammed among stdlib imports, wherever it's mentioned. It should be among the weaveworks/flux imports.

  • resource.Update shouldn't really be in that package (see comment in resource/policy.go)

Elsewise, a few accidental replacements, for which I've put in suggestions.

api/v11/api.go Outdated Show resolved Hide resolved
"github.com/weaveworks/flux/api/v10"
"github.com/weaveworks/flux/api/v6"
)

type ListServicesOptions struct {
Namespace string
Services []flux.ResourceID
Services []resource.ID
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is SO much nicer, it is like a breath of fresh air!

@@ -145,7 +145,7 @@ func (c *Cluster) ImagesToFetch() registry.ImageCreds {

imageCreds := make(registry.ImageCreds)
for _, workload := range workloads {
logger := log.With(c.logger, "resource", flux.MakeResourceID(ns.Name, kind, workload.GetName()))
logger := log.With(c.logger, "resource", resource.MakeID(ns.Name, kind, workload.GetName()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YAAASSS

"github.com/weaveworks/flux/cluster"
"github.com/weaveworks/flux/cluster/kubernetes/resource"
kresource "github.com/weaveworks/flux/cluster/kubernetes/resource"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to have consistency here, nice

cluster/kubernetes/resourcekinds.go Outdated Show resolved Hide resolved
cluster/kubernetes/sync.go Outdated Show resolved Hide resolved
integrations/apis/flux.weave.works/v1beta1/types.go Outdated Show resolved Hide resolved
integrations/helm/release/release.go Outdated Show resolved Hide resolved

type Updates map[ID]Update

type Update struct {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a weird place to put this type. At the least, I'd expect it to be called PolicyUpdate. But it probably belongs in another package, rather than here. As update.Policy, if that doesn't create more problems, for example.

@stefanprodan
Copy link
Member Author

@squaremo I've went with renaming resource.Update to resource.PolicyUpdate and I've fixed the import order.

@squaremo
Copy link
Member

I've went with renaming resource.Update to resource.PolicyUpdate

Was it impossible to do the preferred change, moving it into update?

@stefanprodan
Copy link
Member Author

@squaremo

import cycle not allowed
package github.com/weaveworks/flux/cmd/fluxctl
	imports github.com/weaveworks/flux/api
	imports github.com/weaveworks/flux/api/v11
	imports github.com/weaveworks/flux/api/v10
	imports github.com/weaveworks/flux/api/v6
	imports github.com/weaveworks/flux/cluster
	imports github.com/weaveworks/flux/resource
	imports github.com/weaveworks/flux/update
	imports github.com/weaveworks/flux/cluster

@squaremo
Copy link
Member

import cycle not allowed

Ugh, nightmare. OK.

@squaremo
Copy link
Member

👍

Rebass and squash the suggestion commit, and the Update re-rename.
In the future, consider keeping code changes, and reformatting, in separate commits.

- rename ResourceID and related functions to ID
- move Update type from policy pkg to resource pkg to avoid circular dependency
- rename resource.Update to resource.PolicyUpdate
- run go fmt on all files
@stefanprodan stefanprodan merged commit 20e67fb into master Jun 27, 2019
@stefanprodan stefanprodan deleted the refac branch June 27, 2019 16:40
@squaremo squaremo modified the milestones: 1.14.0, 1.13.2 Jul 10, 2019
squaremo pushed a commit that referenced this pull request Jul 10, 2019
Move ResourceID from root to resource package
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants