Browse Source

Revert

This reverts commit 6027b42fb6.

Revert "nitpicks"

This reverts commit 327d51dc99.

Revert "moar nitpicks"

This reverts commit b61b1bfa13.

Revert "moar"

This reverts commit b4b2964723.

Revert "docs"

This reverts commit e0f7fccf02.
Dimitri Mitropoulos 5 months ago
parent
commit
267e0115d1

+ 0
- 1
.gitignore View File

@@ -40,4 +40,3 @@ docker/fluxy-dumbconf.priv
40 40
 test/profiles
41 41
 test/bin/kubectl
42 42
 test/bin/helm
43
-test/deploy

+ 5
- 19
api/v6/api.go View File

@@ -22,26 +22,12 @@ type ImageStatus struct {
22 22
 // send.
23 23
 type ReadOnlyReason string
24 24
 
25
-// ReadOnlyOK signifies that the repo can be written to
26
-const ReadOnlyOK ReadOnlyReason = ""
27
-
28
-// ReadOnlyMissing it's in a cluster but not in the git repo
29
-const ReadOnlyMissing ReadOnlyReason = "NotInRepo"
30
-
31
-// ReadOnlySystem indicates that the repo is in control of kubernetes not by the repo
32
-const ReadOnlySystem ReadOnlyReason = "System"
33
-
34
-// ReadOnlyNoRepo indicates that the user has elected to not supply a git repo
35
-const ReadOnlyNoRepo ReadOnlyReason = "NoRepo"
36
-
37
-// ReadOnlyNotReady indicates that Flux hasn't booted up yet
38
-const ReadOnlyNotReady ReadOnlyReason = "NotReady"
39
-
40 25
 const (
41
-	// TestGoDoc is a test for Go Doc
42
-	TestGoDoc = "asdf"
43
-
44
-	SecondGoDocTest = "qwerty" // SecondGoDocTest tests an inline comment
26
+	ReadOnlyOK       ReadOnlyReason = ""
27
+	ReadOnlyMissing  ReadOnlyReason = "NotInRepo"
28
+	ReadOnlySystem   ReadOnlyReason = "System"
29
+	ReadOnlyNoRepo   ReadOnlyReason = "NoRepo"
30
+	ReadOnlyNotReady ReadOnlyReason = "NotReady"
45 31
 )
46 32
 
47 33
 type ControllerStatus struct {

+ 1
- 1
cluster/kubernetes/policies.go View File

@@ -42,7 +42,7 @@ func (m *Manifests) UpdatePolicies(def []byte, id flux.ResourceID, update policy
42 42
 		}
43 43
 		args = append(args, fmt.Sprintf("%s%s=%s", kresource.PolicyPrefix, pol, val))
44 44
 	}
45
-	for pol := range del {
45
+	for pol, _ := range del {
46 46
 		args = append(args, fmt.Sprintf("%s%s=", kresource.PolicyPrefix, pol))
47 47
 	}
48 48
 

+ 1
- 1
cluster/kubernetes/resourcekinds.go View File

@@ -365,7 +365,7 @@ func (dk *cronJobKind) getWorkloads(c *Cluster, namespace string) ([]workload, e
365 365
 	}
366 366
 
367 367
 	var workloads []workload
368
-	for i := range cronJobs.Items {
368
+	for i, _ := range cronJobs.Items {
369 369
 		workloads = append(workloads, makeCronJobWorkload(&cronJobs.Items[i]))
370 370
 	}
371 371
 

+ 3
- 3
cmd/fluxd/main.go View File

@@ -126,9 +126,9 @@ func main() {
126 126
 		registryAWSBlockAccountIDs = fs.StringSlice("registry-ecr-exclude-id", []string{registry.EKS_SYSTEM_ACCOUNT}, "do not scan ECR for images in these AWS account IDs; the default is to exclude the EKS system account")
127 127
 
128 128
 		// k8s-secret backed ssh keyring configuration
129
-		k8sSecretName            = fs.String("k8s-secret-name", "flux-git-deploy", "name of the k8s Secret used to store the private SSH key")
130
-		k8sSecretVolumeMountPath = fs.String("k8s-secret-volume-mount-path", "/etc/fluxd/ssh", "mount location of the k8s Secret storing the private SSH key")
131
-		k8sSecretDataKey         = fs.String("k8s-secret-data-key", "identity", "data key holding the private SSH key within the k8s Secret")
129
+		k8sSecretName            = fs.String("k8s-secret-name", "flux-git-deploy", "name of the k8s secret used to store the private SSH key")
130
+		k8sSecretVolumeMountPath = fs.String("k8s-secret-volume-mount-path", "/etc/fluxd/ssh", "mount location of the k8s secret storing the private SSH key")
131
+		k8sSecretDataKey         = fs.String("k8s-secret-data-key", "identity", "data key holding the private SSH key within the k8s secret")
132 132
 		k8sNamespaceWhitelist    = fs.StringSlice("k8s-namespace-whitelist", []string{}, "experimental, optional: restrict the view of the cluster to the namespaces listed. All namespaces are included if this is not set.")
133 133
 		// SSH key generation
134 134
 		sshKeyBits   = optionalVar(fs, &ssh.KeyBitsValue{}, "ssh-keygen-bits", "-b argument to ssh-keygen (default unspecified)")

+ 2
- 2
daemon/daemon.go View File

@@ -707,7 +707,7 @@ func policyEvents(us policy.Updates, now time.Time) map[string]event.Event {
707 707
 // policyEventTypes is a deduped list of all event types this update contains
708 708
 func policyEventTypes(u policy.Update) []string {
709 709
 	types := map[string]struct{}{}
710
-	for p := range u.Add {
710
+	for p, _ := range u.Add {
711 711
 		switch {
712 712
 		case p == policy.Automated:
713 713
 			types[event.EventAutomate] = struct{}{}
@@ -718,7 +718,7 @@ func policyEventTypes(u policy.Update) []string {
718 718
 		}
719 719
 	}
720 720
 
721
-	for p := range u.Remove {
721
+	for p, _ := range u.Remove {
722 722
 		switch {
723 723
 		case p == policy.Automated:
724 724
 			types[event.EventDeautomate] = struct{}{}

+ 1
- 1
daemon/images.go View File

@@ -89,7 +89,7 @@ func (d *Daemon) pollForNewImages(logger log.Logger) {
89 89
 type resources map[flux.ResourceID]resource.Resource
90 90
 
91 91
 func (r resources) IDs() (ids []flux.ResourceID) {
92
-	for k := range r {
92
+	for k, _ := range r {
93 93
 		ids = append(ids, k)
94 94
 	}
95 95
 	return ids

+ 3
- 3
daemon/loop_test.go View File

@@ -91,7 +91,7 @@ func TestPullAndSync_InitialSync(t *testing.T) {
91 91
 	syncCalled := 0
92 92
 	var syncDef *cluster.SyncSet
93 93
 	expectedResourceIDs := flux.ResourceIDs{}
94
-	for id := range testfiles.ResourceMap {
94
+	for id, _ := range testfiles.ResourceMap {
95 95
 		expectedResourceIDs = append(expectedResourceIDs, id)
96 96
 	}
97 97
 	expectedResourceIDs.Sort()
@@ -166,7 +166,7 @@ func TestDoSync_NoNewCommits(t *testing.T) {
166 166
 	syncCalled := 0
167 167
 	var syncDef *cluster.SyncSet
168 168
 	expectedResourceIDs := flux.ResourceIDs{}
169
-	for id := range testfiles.ResourceMap {
169
+	for id, _ := range testfiles.ResourceMap {
170 170
 		expectedResourceIDs = append(expectedResourceIDs, id)
171 171
 	}
172 172
 	expectedResourceIDs.Sort()
@@ -266,7 +266,7 @@ func TestDoSync_WithNewCommit(t *testing.T) {
266 266
 	syncCalled := 0
267 267
 	var syncDef *cluster.SyncSet
268 268
 	expectedResourceIDs := flux.ResourceIDs{}
269
-	for id := range testfiles.ResourceMap {
269
+	for id, _ := range testfiles.ResourceMap {
270 270
 		expectedResourceIDs = append(expectedResourceIDs, id)
271 271
 	}
272 272
 	expectedResourceIDs.Sort()

+ 8
- 8
git/gittest/repo.go View File

@@ -44,7 +44,7 @@ func Repo(t *testing.T) (*git.Repo, func()) {
44 44
 		cleanup()
45 45
 		t.Fatal(err)
46 46
 	}
47
-	if err = execCommand("git", "-C", filesDir, "commit", "--message", "'Initial revision'"); err != nil {
47
+	if err = execCommand("git", "-C", filesDir, "commit", "-m", "'Initial revision'"); err != nil {
48 48
 		cleanup()
49 49
 		t.Fatal(err)
50 50
 	}
@@ -66,7 +66,7 @@ func Repo(t *testing.T) (*git.Repo, func()) {
66 66
 // not all resources, just the workloads) represented in the test
67 67
 // files.
68 68
 func Workloads() (res []flux.ResourceID) {
69
-	for k := range testfiles.WorkloadMap("") {
69
+	for k, _ := range testfiles.WorkloadMap("") {
70 70
 		res = append(res, k)
71 71
 	}
72 72
 	return res
@@ -74,18 +74,18 @@ func Workloads() (res []flux.ResourceID) {
74 74
 
75 75
 // CheckoutWithConfig makes a standard repo, clones it, and returns
76 76
 // the clone, the original repo, and a cleanup function.
77
-func CheckoutWithConfig(t *testing.T, gitConfig git.Config) (*git.Checkout, *git.Repo, func()) {
77
+func CheckoutWithConfig(t *testing.T, config git.Config) (*git.Checkout, *git.Repo, func()) {
78 78
 	// Add files to the repo with the same name as the git branch and the sync tag.
79 79
 	// This is to make sure that git commands don't have ambiguity problems between revisions and files.
80
-	testfiles.Files[gitConfig.Branch] = "Filename doctored to create a conflict with the git branch name"
81
-	testfiles.Files[gitConfig.SyncTag] = "Filename doctored to create a conflict with the git sync tag"
80
+	testfiles.Files[config.Branch] = "Filename doctored to create a conflict with the git branch name"
81
+	testfiles.Files[config.SyncTag] = "Filename doctored to create a conflict with the git sync tag"
82 82
 	repo, cleanup := Repo(t)
83 83
 	if err := repo.Ready(context.Background()); err != nil {
84 84
 		cleanup()
85 85
 		t.Fatal(err)
86 86
 	}
87 87
 
88
-	co, err := repo.Clone(context.Background(), gitConfig)
88
+	co, err := repo.Clone(context.Background(), config)
89 89
 	if err != nil {
90 90
 		cleanup()
91 91
 		t.Fatal(err)
@@ -93,8 +93,8 @@ func CheckoutWithConfig(t *testing.T, gitConfig git.Config) (*git.Checkout, *git
93 93
 	return co, repo, func() {
94 94
 		co.Clean()
95 95
 		cleanup()
96
-		delete(testfiles.Files, gitConfig.Branch)
97
-		delete(testfiles.Files, gitConfig.SyncTag)
96
+		delete(testfiles.Files, config.Branch)
97
+		delete(testfiles.Files, config.SyncTag)
98 98
 	}
99 99
 }
100 100
 

+ 6
- 6
git/gittest/repo_test.go View File

@@ -26,7 +26,7 @@ func TestCommit(t *testing.T) {
26 26
 	checkout, repo, cleanup := CheckoutWithConfig(t, config)
27 27
 	defer cleanup()
28 28
 
29
-	for file := range testfiles.Files {
29
+	for file, _ := range testfiles.Files {
30 30
 		dirs := checkout.ManifestDirs()
31 31
 		path := filepath.Join(dirs[0], file)
32 32
 		if err := ioutil.WriteFile(path, []byte("FIRST CHANGE"), 0666); err != nil {
@@ -81,7 +81,7 @@ func TestSignedCommit(t *testing.T) {
81 81
 	checkout, repo, cleanup := CheckoutWithConfig(t, config)
82 82
 	defer cleanup()
83 83
 
84
-	for file := range testfiles.Files {
84
+	for file, _ := range testfiles.Files {
85 85
 		dirs := checkout.ManifestDirs()
86 86
 		path := filepath.Join(dirs[0], file)
87 87
 		if err := ioutil.WriteFile(path, []byte("FIRST CHANGE"), 0666); err != nil {
@@ -162,14 +162,14 @@ func TestCheckout(t *testing.T) {
162 162
 
163 163
 	ctx := context.Background()
164 164
 
165
-	gitConfig := git.Config{
165
+	params := git.Config{
166 166
 		Branch:    "master",
167 167
 		UserName:  "example",
168 168
 		UserEmail: "example@example.com",
169 169
 		SyncTag:   "flux-test",
170 170
 		NotesRef:  "fluxtest",
171 171
 	}
172
-	checkout, err := repo.Clone(ctx, gitConfig)
172
+	checkout, err := repo.Clone(ctx, params)
173 173
 	if err != nil {
174 174
 		t.Fatal(err)
175 175
 	}
@@ -193,7 +193,7 @@ func TestCheckout(t *testing.T) {
193 193
 
194 194
 	changedFile := ""
195 195
 	dirs := checkout.ManifestDirs()
196
-	for file := range testfiles.Files {
196
+	for file, _ := range testfiles.Files {
197 197
 		path := filepath.Join(dirs[0], file)
198 198
 		if err := ioutil.WriteFile(path, []byte("FIRST CHANGE"), 0666); err != nil {
199 199
 			t.Fatal(err)
@@ -251,7 +251,7 @@ func TestCheckout(t *testing.T) {
251 251
 		t.Error(err)
252 252
 	}
253 253
 
254
-	another, err := repo.Clone(ctx, gitConfig)
254
+	another, err := repo.Clone(ctx, params)
255 255
 	if err != nil {
256 256
 		t.Fatal(err)
257 257
 	}

+ 4
- 3
git/operations.go View File

@@ -87,7 +87,7 @@ func checkPush(ctx context.Context, workingDir, upstream string) error {
87 87
 }
88 88
 
89 89
 func commit(ctx context.Context, workingDir string, commitAction CommitAction) error {
90
-	args := []string{"commit", "--no-verify", "--all", "--message", commitAction.Message}
90
+	args := []string{"commit", "--no-verify", "-a", "-m", commitAction.Message}
91 91
 	var env []string
92 92
 	if commitAction.Author != "" {
93 93
 		args = append(args, "--author", commitAction.Author)
@@ -147,7 +147,7 @@ func addNote(ctx context.Context, workingDir, rev, notesRef string, note interfa
147 147
 	if err != nil {
148 148
 		return err
149 149
 	}
150
-	args := []string{"notes", "--ref", notesRef, "add", "--message", string(b), rev}
150
+	args := []string{"notes", "--ref", notesRef, "add", "-m", string(b), rev}
151 151
 	return execGitCmd(ctx, args, gitCmdConfig{dir: workingDir})
152 152
 }
153 153
 
@@ -251,8 +251,9 @@ func moveTagAndPush(ctx context.Context, workingDir, tag, upstream string, tagAc
251 251
 }
252 252
 
253 253
 func verifyTag(ctx context.Context, workingDir, tag string) error {
254
+	var env []string
254 255
 	args := []string{"verify-tag", tag}
255
-	if err := execGitCmd(ctx, args, gitCmdConfig{dir: workingDir}); err != nil {
256
+	if err := execGitCmd(ctx, args, gitCmdConfig{dir: workingDir, env: env}); err != nil {
256 257
 		return errors.Wrap(err, "verifying tag "+tag)
257 258
 	}
258 259
 	return nil

+ 6
- 6
git/operations_test.go View File

@@ -17,7 +17,7 @@ const (
17 17
 )
18 18
 
19 19
 var (
20
-	noteIDCounter = 1
20
+	noteIdCounter = 1
21 21
 )
22 22
 
23 23
 type Note struct {
@@ -86,8 +86,8 @@ func TestListNotes_0Notes(t *testing.T) {
86 86
 }
87 87
 
88 88
 func testNote(dir, rev string) (string, error) {
89
-	id := fmt.Sprintf("%v", noteIDCounter)
90
-	noteIDCounter += 1
89
+	id := fmt.Sprintf("%v", noteIdCounter)
90
+	noteIdCounter += 1
91 91
 	err := addNote(context.Background(), dir, rev, testNoteRef, &Note{ID: id})
92 92
 	return id, err
93 93
 }
@@ -245,11 +245,11 @@ func createRepo(dir string, subdirs []string) error {
245 245
 		if err = execCommand("git", "-C", dir, "add", "--all"); err != nil {
246 246
 			return err
247 247
 		}
248
-		if err = execCommand("git", "-C", dir, "commit", "--message", "'Initial revision'"); err != nil {
248
+		if err = execCommand("git", "-C", dir, "commit", "-m", "'Initial revision'"); err != nil {
249 249
 			return err
250 250
 		}
251 251
 	}
252
-	if err = execCommand("git", "-C", dir, "commit", "--allow-empty", "--message", "'Second revision'"); err != nil {
252
+	if err = execCommand("git", "-C", dir, "commit", "--allow-empty", "-m", "'Second revision'"); err != nil {
253 253
 		return err
254 254
 	}
255 255
 
@@ -282,7 +282,7 @@ func updateDirAndCommit(dir, subdir string, filesUpdated map[string]string) erro
282 282
 	if err := execCommand("git", "-C", path, "add", "--all"); err != nil {
283 283
 		return err
284 284
 	}
285
-	if err := execCommand("git", "-C", path, "commit", "--message", "'Update 1'"); err != nil {
285
+	if err := execCommand("git", "-C", path, "commit", "-m", "'Update 1'"); err != nil {
286 286
 		return err
287 287
 	}
288 288
 	return nil

+ 3
- 3
git/repo.go View File

@@ -88,7 +88,7 @@ var ReadOnly optionFunc = func(r *Repo) {
88 88
 }
89 89
 
90 90
 // NewRepo constructs a repo mirror which will sync itself.
91
-func NewRepo(origin Remote, options ...Option) *Repo {
91
+func NewRepo(origin Remote, opts ...Option) *Repo {
92 92
 	status := RepoNew
93 93
 	if origin.URL == "" {
94 94
 		status = RepoNoConfig
@@ -102,8 +102,8 @@ func NewRepo(origin Remote, options ...Option) *Repo {
102 102
 		notify:   make(chan struct{}, 1), // `1` so that Notify doesn't block
103 103
 		C:        make(chan struct{}, 1), // `1` so we don't block on completing a refresh
104 104
 	}
105
-	for _, option := range options {
106
-		option.apply(r)
105
+	for _, opt := range opts {
106
+		opt.apply(r)
107 107
 	}
108 108
 	return r
109 109
 }

+ 1
- 3
git/url_test.go View File

@@ -12,9 +12,7 @@ func TestSafeURL(t *testing.T) {
12 12
 		"https://user@example.com:5050/repo.git",
13 13
 		"https://user:" + password + "@example.com:5050/repo.git",
14 14
 	} {
15
-		u := Remote{
16
-			URL: url,
17
-		}
15
+		u := Remote{url}
18 16
 		if strings.Contains(u.SafeURL(), password) {
19 17
 			t.Errorf("Safe URL for %s contains password %q", url, password)
20 18
 		}

+ 1
- 1
git/working.go View File

@@ -141,7 +141,7 @@ func (c *Checkout) CommitAndPush(ctx context.Context, commitAction CommitAction,
141 141
 	}
142 142
 
143 143
 	if note != nil {
144
-		rev, err := c.HeadRevision(ctx)
144
+		rev, err := refRevision(ctx, c.dir, "HEAD")
145 145
 		if err != nil {
146 146
 			return err
147 147
 		}

+ 2
- 2
integrations/client/informers/externalversions/factory.go View File

@@ -97,8 +97,8 @@ func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResy
97 97
 	}
98 98
 
99 99
 	// Apply all options
100
-	for _, option := range options {
101
-		factory = option(factory)
100
+	for _, opt := range options {
101
+		factory = opt(factory)
102 102
 	}
103 103
 
104 104
 	return factory

+ 1
- 1
remote/rpc/compat.go View File

@@ -41,7 +41,7 @@ func requireServiceIDKinds(id flux.ResourceID, kinds []string) error {
41 41
 func requireSpecKinds(s update.Spec, kinds []string) error {
42 42
 	switch s := s.Spec.(type) {
43 43
 	case policy.Updates:
44
-		for id := range s {
44
+		for id, _ := range s {
45 45
 			_, kind, _ := id.Components()
46 46
 			if !contains(kinds, kind) {
47 47
 				return fmt.Errorf("Unsupported resource kind: %s", kind)

+ 1
- 1
site/daemon.md View File

@@ -57,7 +57,7 @@ fluxd requires setup and offers customization though a multitude of flags.
57 57
 | --git-user                                       | `Weave Flux`             | username to use as git committer
58 58
 | --git-email                                      | `support@weave.works`    | email to use as git committer
59 59
 | --git-set-author                                 | false                    | if set, the author of git commits will reflect the user who initiated the commit and will differ from the git committer
60
-| --git-gpg-key-import                             |                          | if set, fluxd will attempt to import the GPG key(s) found on the given path
60
+| --git-gpg-key-import                             |                          | if set, fluxd will attempt to import the gpg key(s) found on the given path
61 61
 | --git-signing-key                                |                          | if set, commits made by fluxd to the user git repo will be signed with the provided GPG key. See [Git commit signing](git-commit-signing.md) to learn how to use this feature
62 62
 | --git-label                                      |                          | label to keep track of sync progress; overrides both --git-sync-tag and --git-notes-ref
63 63
 | --git-sync-tag                                   | `flux-sync`              | tag to use to mark sync progress for this cluster (old config, still used if --git-label is not supplied)

+ 4
- 10
site/get-started-developing.md View File

@@ -31,19 +31,13 @@ We're going to make some changes soon enough, but just to get a good baseline pl
31 31
 
32 32
 Now that we know everything is working with `flux-getting-started`, we're going to try and do nearly the same thing as `flux-getting-started`, except instead of using official releases of flux, we're going to build and run what we have locally.
33 33
 
34
-## Prepare your Mind
35
-
36
-Even if you've been using git for a long time in your day-to-day, there are features of git that Flux utilizes (e.g. `notes`, `refs`) that you may have never been forced to think very deeply about during daily usage.  The document on [Git Internals -Git References](https://git-scm.com/book/en/v2/Git-Internals-Git-References) is a good jumping-off point.
37
-
38
-The Helm Operator is likely something you'll encounter when developing Flux.  While it isn't required for the most minimal changes, over time you're going to want to familiarize yourself.  The [Kubernetes Operators](https://coreos.com/operators/) document by CoreOS serves as a table of contents for getting started.
39
-
40 34
 ## Prepare your Environment
41 35
 
42 36
 1. Install the prerequisites.  This guide is written from running Linux, but the same instructions will generally apply to OSX.  Although everything you need has been known to work independently in Windows from time to time, results may vary.
43
-  - [Minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/)
44
-  - [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
45
-  - [Docker](https://docs.docker.com/install/)
46
-  - [Go](https://golang.org/doc/install)
37
+    - [Minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/)
38
+    - [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
39
+    - [Docker](https://docs.docker.com/install/)
40
+    - [Go](https://golang.org/doc/install)
47 41
 
48 42
 1. Configure your enviroment so you can run tests.  Run:
49 43
     ```sh

+ 1
- 1
update/automated.go View File

@@ -148,7 +148,7 @@ func (a *Automated) workloadMap() map[flux.ResourceID][]Change {
148 148
 
149 149
 func (a *Automated) workloadIDs() []flux.ResourceID {
150 150
 	slice := []flux.ResourceID{}
151
-	for workload := range a.workloadMap() {
151
+	for workload, _ := range a.workloadMap() {
152 152
 		slice = append(slice, flux.MustParseResourceID(workload.String()))
153 153
 	}
154 154
 	return slice

Loading…
Cancel
Save