Skip to content

Commit 0f93028

Browse files
committed
Add MIT Licence copyright notice
Signed-off-by: Soule BA <[email protected]>
1 parent 366f5cf commit 0f93028

File tree

4 files changed

+56
-43
lines changed

4 files changed

+56
-43
lines changed

api/v1beta2/condition_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ const (
9797
// ArtifactUpToDateReason signals that an existing Artifact is up-to-date
9898
// with the Source.
9999
ArtifactUpToDateReason string = "ArtifactUpToDate"
100+
100101
// CacheOperationFailedReason signals a failure in cache operation.
101102
CacheOperationFailedReason string = "CacheOperationFailed"
102103
)

internal/cache/LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2012-2019 Patrick Mylund Nielsen and the go-cache contributors
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

internal/cache/cache.go

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
/*
2-
Copyright 2022 The Flux authors
3-
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
7-
8-
http://www.apache.org/licenses/LICENSE-2.0
9-
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
15-
*/
1+
// Copyright (c) 2012-2019 Patrick Mylund Nielsen and the go-cache contributors
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
// Copyright 2022 The FluxCD contributors. All rights reserved.
6+
// This package provides an in-memory cache
7+
// derived from the https://github.com/patrickmn/go-cache
8+
// package
9+
// It has been modified in order to keep a small set of functions
10+
// and to add a maxItems parameter in order to limit the number of,
11+
// and thus the size of, items in the cache.
1612

1713
package cache
1814

@@ -23,9 +19,6 @@ import (
2319
"time"
2420
)
2521

26-
// NOTE: this is heavily based on patrickmn/go-cache:
27-
// https://github.com/patrickmn/go-cache
28-
2922
// Cache is a thread-safe in-memory key/value store.
3023
type Cache struct {
3124
*cache

main.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,24 @@ func init() {
7272

7373
func main() {
7474
var (
75-
metricsAddr string
76-
eventsAddr string
77-
healthAddr string
78-
storagePath string
79-
storageAddr string
80-
storageAdvAddr string
81-
concurrent int
82-
requeueDependency time.Duration
83-
watchAllNamespaces bool
84-
helmIndexLimit int64
85-
helmChartLimit int64
86-
helmChartFileLimit int64
87-
clientOptions client.Options
88-
logOptions logger.Options
89-
leaderElectionOptions leaderelection.Options
90-
cacheMaxSize int
91-
cacheTTL string
92-
cachePurgeInterval string
75+
metricsAddr string
76+
eventsAddr string
77+
healthAddr string
78+
storagePath string
79+
storageAddr string
80+
storageAdvAddr string
81+
concurrent int
82+
requeueDependency time.Duration
83+
watchAllNamespaces bool
84+
helmIndexLimit int64
85+
helmChartLimit int64
86+
helmChartFileLimit int64
87+
clientOptions client.Options
88+
logOptions logger.Options
89+
leaderElectionOptions leaderelection.Options
90+
helmCacheMaxSize int
91+
helmCacheTTL string
92+
helmCachePurgeInterval string
9393
)
9494

9595
flag.StringVar(&metricsAddr, "metrics-addr", envOrDefault("METRICS_ADDR", ":8080"),
@@ -114,11 +114,11 @@ func main() {
114114
"The max allowed size in bytes of a file in a Helm chart.")
115115
flag.DurationVar(&requeueDependency, "requeue-dependency", 30*time.Second,
116116
"The interval at which failing dependencies are reevaluated.")
117-
flag.IntVar(&cacheMaxSize, "cache-max-size", 0,
117+
flag.IntVar(&helmCacheMaxSize, "helm-cache-max-size", 0,
118118
"The maximum size of the cache in number of items.")
119-
flag.StringVar(&cacheTTL, "cache-ttl", "15m",
119+
flag.StringVar(&helmCacheTTL, "helm-cache-ttl", "15m",
120120
"The TTL of an item in the cache. Valid time units are ns, us (or µs), ms, s, m, h.")
121-
flag.StringVar(&cachePurgeInterval, "cache-purge-interval", "1m",
121+
flag.StringVar(&helmCachePurgeInterval, "helm-cache-purge-interval", "1m",
122122
"The interval at which the cache is purged. Valid time units are ns, us (or µs), ms, s, m, h.")
123123

124124
clientOptions.BindFlags(flag.CommandLine)
@@ -204,20 +204,20 @@ func main() {
204204

205205
var c *cache.Cache
206206
var ttl time.Duration
207-
if cacheMaxSize > 0 {
208-
interval, err := time.ParseDuration(cachePurgeInterval)
207+
if helmCacheMaxSize > 0 {
208+
interval, err := time.ParseDuration(helmCachePurgeInterval)
209209
if err != nil {
210210
setupLog.Error(err, "unable to parse cache purge interval")
211211
os.Exit(1)
212212
}
213213

214-
ttl, err = time.ParseDuration(cacheTTL)
214+
ttl, err = time.ParseDuration(helmCacheTTL)
215215
if err != nil {
216216
setupLog.Error(err, "unable to parse cache TTL")
217217
os.Exit(1)
218218
}
219219

220-
c = cache.New(cacheMaxSize, interval)
220+
c = cache.New(helmCacheMaxSize, interval)
221221
}
222222
if err = (&controllers.HelmChartReconciler{
223223
Client: mgr.GetClient(),

0 commit comments

Comments
 (0)