Skip to content

Commit 92832c5

Browse files
author
Cory Schwartz
committed
Merge branch 'main' into feat/configure-resources-for-volume-size
2 parents ff1b48e + 1d7d2f6 commit 92832c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+909
-382
lines changed

Makefile

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ vet: ## Run go vet against code.
130130

131131
.PHONY: test
132132
GINKGO_ARGS ?= --progress --fail-on-pending --keep-going --cover --coverprofile=cover.profile --race --trace --json-report=report.json --timeout=3m
133+
GINKGO_TARGETS ?= ./...
133134
test: lint manifests generate fmt vet lint envtest ginkgo ## Run tests.
134-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" $(GINKGO) run $(GINKGO_ARGS) ./...
135+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" $(GINKGO) run $(GINKGO_ARGS) $(GINKGO_TARGETS)
135136

136137
.PHONY: test-e2e
137138
test-e2e: kuttl ## Run e2e tests. Requires cluster w/ Scribe already installed
@@ -211,11 +212,38 @@ TMP_DIR=$$(mktemp -d) ;\
211212
cd $$TMP_DIR ;\
212213
go mod init tmp ;\
213214
echo "Downloading $(2)" ;\
214-
GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
215+
GOBIN=$(LOCALBIN) go get $(2) ;\
215216
rm -rf $$TMP_DIR ;\
216217
}
217218
endef
218219

220+
# go-install-tool will 'go install' any package $2 and install it to $1.
221+
define go-install-tool
222+
@[ -f $(1) ] || { \
223+
set -e ;\
224+
TMP_DIR=$$(mktemp -d) ;\
225+
cd $$TMP_DIR ;\
226+
go mod init tmp ;\
227+
echo "Downloading $(2)" ;\
228+
GOBIN=$(LOCALBIN) go install $(2) ;\
229+
rm -rf $$TMP_DIR ;\
230+
}
231+
endef
232+
233+
# go-install-mod-tool will 'go install' any package $2 and install it to $1.
234+
define go-install-mod-tool
235+
@[ -f $(1) ] || { \
236+
set -e ;\
237+
TMP_DIR=$$(mktemp -d) ;\
238+
cd $$TMP_DIR ;\
239+
go mod init tmp ;\
240+
echo "Downloading $(2)" ;\
241+
GOBIN=$(LOCALBIN) go install -mod=mod $(2) ;\
242+
rm -rf $$TMP_DIR ;\
243+
}
244+
endef
245+
246+
219247
.PHONY: bundle
220248
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
221249
operator-sdk generate kustomize manifests -q
@@ -273,7 +301,7 @@ catalog-push: ## Push a catalog image.
273301
$(MAKE) docker-push IMG=$(CATALOG_IMG)
274302

275303

276-
##@ Download Utilities
304+
##@ Download tools
277305

278306
# download-tool will curl any file $2 and install it to $1.
279307
define download-tool
@@ -282,32 +310,9 @@ set -e ;\
282310
echo "📥 Downloading $(2)" ;\
283311
curl -sSLo "$(1)" "$(2)" ;\
284312
chmod a+x "$(1)" ;\
285-
echo "✅ Done" ;\
286-
}
287-
endef
288-
289-
# install-go-tool will download any $2 URL and install to $1
290-
define install-go-tool
291-
@[ -f $(1) ] || { \
292-
set -e ;\
293-
echo "📥 Downloading $(2)" ;\
294-
GOBIN=$(1) go install $(2) ;\
295-
echo "✅ Done" ;\
296313
}
297314
endef
298315

299-
# install-go-tool will download any $2 URL and install to $1
300-
define install-go-tool-mod
301-
@[ -f $(1) ] || { \
302-
set -e ;\
303-
echo "📥 Downloading $(2)" ;\
304-
GOBIN=$(1) go install -mod=mod $(2) ;\
305-
echo "✅ Done" ;\
306-
}
307-
endef
308-
309-
310-
311316
.PHONY: kuttl
312317
KUTTL := $(LOCALBIN)/kuttl
313318
KUTTL_URL := https://github.com/kudobuilder/kuttl/releases/download/v$(KUTTL_VERSION)/kubectl-kuttl_$(KUTTL_VERSION)_linux_x86_64
@@ -319,15 +324,15 @@ GINKGO := $(LOCALBIN)/ginkgo
319324
GINKGO_URL := github.com/onsi/ginkgo/v2/ginkgo
320325
ginkgo: $(GINKGO) ## Install ginkgo
321326
$(GINKGO): $(LOCALBIN)
322-
$(call install-go-tool-mod,$(LOCALBIN),$(GINKGO_URL))
327+
$(call go-install-mod-tool,$(LOCALBIN),$(GINKGO_URL))
323328

324329

325330
.PHONY: kustomize
326331
KUSTOMIZE = $(LOCALBIN)/kustomize
327332
KUSTOMIZE_URL := sigs.k8s.io/kustomize/kustomize/$(KUSTOMIZE_MAJOR)@$(KUSTOMIZE_VERSION)
328333
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
329334
$(KUSTOMIZE): $(LOCALBIN)
330-
$(call install-go-tool,$(LOCALBIN),$(KUSTOMIZE_URL))
335+
$(call go-install-tool,$(LOCALBIN),$(KUSTOMIZE_URL))
331336

332337
.PHONY: helm
333338
HELM := $(LOCALBIN)/helm
@@ -344,4 +349,4 @@ golangci-lint: $(GOLANGCILINT) ## Download golangci-lint
344349
$(GOLANGCILINT): $(LOCALBIN)
345350
@ echo "📥 Downloading helm"
346351
curl -sSfL $(GOLANGCI_URL) | sh -s -- -b $(LOCALBIN) $(GOLANGCI_VERSION)
347-
@ echo "✅ Done"
352+
@ echo "✅ Done"

PROJECT

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ resources:
1313
controller: true
1414
domain: ipfs.io
1515
group: cluster
16-
kind: Ipfs
16+
kind: CircuitRelay
1717
path: github.com/redhat-et/ipfs-operator/api/v1alpha1
1818
version: v1alpha1
1919
- api:
@@ -22,7 +22,7 @@ resources:
2222
controller: true
2323
domain: ipfs.io
2424
group: cluster
25-
kind: CircuitRelay
25+
kind: IpfsCluster
2626
path: github.com/redhat-et/ipfs-operator/api/v1alpha1
2727
version: v1alpha1
2828
version: "3"

api/v1alpha1/groupversion_info.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ limitations under the License.
1515
*/
1616

1717
// Package v1alpha1 contains API Schema definitions for the cluster v1alpha1 API group
18-
//+kubebuilder:object:generate=true
19-
//+groupName=cluster.ipfs.io
18+
// +kubebuilder:object:generate=true
19+
// +groupName=cluster.ipfs.io
2020
package v1alpha1
2121

2222
import (

api/v1alpha1/ipfs_types.go

Lines changed: 0 additions & 82 deletions
This file was deleted.

api/v1alpha1/ipfscluster_types.go

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
Copyright 2022.
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+
*/
16+
17+
package v1alpha1
18+
19+
import (
20+
"k8s.io/apimachinery/pkg/api/resource"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
const (
25+
// ConditionReconciled is a status condition type that indicates whether the
26+
// CR has been successfully reconciled.
27+
ConditionReconciled string = "Reconciled"
28+
// ReconciledReasonComplete indicates the CR was successfully reconciled.
29+
ReconciledReasonComplete string = "ReconcileComplete"
30+
// ReconciledReasonError indicates an error was encountered while
31+
// reconciling the CR.
32+
ReconciledReasonError string = "ReconcileError"
33+
)
34+
35+
type ReproviderStrategy string
36+
37+
const (
38+
// ReproviderStrategyAll Announces the CID of every stored block.
39+
ReproviderStrategyAll ReproviderStrategy = "all"
40+
// ReproviderStrategyPinned Only announces the pinned CIDs recursively.
41+
ReproviderStrategyPinned ReproviderStrategy = "pinned"
42+
// ReproviderStrategyRoots Only announces the root block of explicitly pinned CIDs.
43+
ReproviderStrategyRoots ReproviderStrategy = "roots"
44+
)
45+
46+
type ReprovideSettings struct {
47+
// Strategy specifies the reprovider strategy, defaults to 'all'.
48+
// +kubebuilder:validation:Enum={all,pinned,roots}
49+
// +optional
50+
Strategy ReproviderStrategy `json:"strategy,omitempty"`
51+
// Interval sets the time between rounds of reproviding
52+
// local content to the routing system. Defaults to '12h'.
53+
// +optional
54+
Interval string `json:"interval,omitempty"`
55+
}
56+
57+
type followParams struct {
58+
Name string `json:"name"`
59+
Template string `json:"template"`
60+
}
61+
62+
type networkConfig struct {
63+
CircuitRelays int32 `json:"circuitRelays"`
64+
}
65+
66+
type IpfsClusterSpec struct {
67+
// +kubebuilder:validation:Optional
68+
URL string `json:"url"`
69+
Public bool `json:"public"`
70+
IpfsStorage resource.Quantity `json:"ipfsStorage"`
71+
ClusterStorage string `json:"clusterStorage"`
72+
Replicas int32 `json:"replicas"`
73+
Networking networkConfig `json:"networking"`
74+
Follows []followParams `json:"follows"`
75+
// Reprovider Describes the settings that each IPFS node
76+
// should use when reproviding content.
77+
// +optional
78+
Reprovider ReprovideSettings `json:"reprovider,omitempty"`
79+
}
80+
81+
type IpfsClusterStatus struct {
82+
Conditions []metav1.Condition `json:"conditions,omitempty"`
83+
CircuitRelays []string `json:"circuitRelays,omitempty"`
84+
}
85+
86+
//+kubebuilder:object:root=true
87+
//+kubebuilder:subresource:status
88+
89+
// IpfsCluster is the Schema for the ipfs API.
90+
type IpfsCluster struct {
91+
metav1.TypeMeta `json:",inline"`
92+
metav1.ObjectMeta `json:"metadata,omitempty"`
93+
94+
Spec IpfsClusterSpec `json:"spec,omitempty"`
95+
Status IpfsClusterStatus `json:"status,omitempty"`
96+
}
97+
98+
//+kubebuilder:object:root=true
99+
100+
// IpfsList contains a list of Ipfs.
101+
type IpfsClusterList struct {
102+
metav1.TypeMeta `json:",inline"`
103+
metav1.ListMeta `json:"metadata,omitempty"`
104+
Items []IpfsCluster `json:"items"`
105+
}
106+
107+
func init() {
108+
SchemeBuilder.Register(&IpfsCluster{}, &IpfsClusterList{})
109+
}

0 commit comments

Comments
 (0)