Skip to content

Commit f906aa8

Browse files
authored
Merge pull request #11 from coryschwartz/experiment/relay
circuitrelay
2 parents 04d49bb + 0bc6216 commit f906aa8

File tree

3,790 files changed

+1085
-1299669
lines changed

Some content is hidden

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

3,790 files changed

+1085
-1299669
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ testbin/*
2323
*.swp
2424
*.swo
2525
*~
26+
27+
# kubeconfig generated during test-e2e
28+
test-e2e/kubeconfig
29+
30+
# don't include vendor/
31+
vendor/*

PROJECT

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@ resources:
1616
kind: Ipfs
1717
path: github.com/redhat-et/ipfs-operator/api/v1alpha1
1818
version: v1alpha1
19+
- api:
20+
crdVersion: v1
21+
namespaced: true
22+
controller: true
23+
domain: ipfs.io
24+
group: cluster
25+
kind: CircuitRelay
26+
path: github.com/redhat-et/ipfs-operator/api/v1alpha1
27+
version: v1alpha1
1928
version: "3"

api/v1alpha1/circuitrelay_types.go

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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+
"github.com/libp2p/go-libp2p-core/peer"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
23+
ma "github.com/multiformats/go-multiaddr"
24+
)
25+
26+
// This is intended to mimic peer.AddrInfo
27+
type AddrInfoBasicType struct {
28+
ID string `json:"id"`
29+
Addrs []string `json:"addrs"`
30+
addrInfo peer.AddrInfo `json:"-"`
31+
}
32+
33+
func (a *AddrInfoBasicType) Parse() error {
34+
id, err := peer.IDB58Decode(a.ID)
35+
if err != nil {
36+
return err
37+
}
38+
addrs := make([]ma.Multiaddr, len(a.Addrs))
39+
for i, addr := range a.Addrs {
40+
maddr, err := ma.NewMultiaddr(addr)
41+
if err != nil {
42+
return err
43+
}
44+
addrs[i] = maddr
45+
}
46+
ai := peer.AddrInfo{
47+
ID: id,
48+
Addrs: addrs,
49+
}
50+
a.addrInfo = ai
51+
return nil
52+
}
53+
54+
func (a *AddrInfoBasicType) AddrInfo() *peer.AddrInfo {
55+
return &a.addrInfo
56+
}
57+
58+
func (a *AddrInfoBasicType) DeepCopyInto(out *AddrInfoBasicType) {
59+
out = new(AddrInfoBasicType)
60+
addrs := make([]string, len(a.Addrs))
61+
for i, addr := range a.Addrs {
62+
addrs[i] = addr
63+
}
64+
out.ID = a.ID
65+
out.Addrs = addrs
66+
}
67+
68+
func (a *AddrInfoBasicType) DeepCopy() *AddrInfoBasicType {
69+
var out *AddrInfoBasicType
70+
a.DeepCopyInto(out)
71+
return out
72+
}
73+
74+
type CircuitRelaySpec struct {
75+
}
76+
77+
type CircuitRelayStatus struct {
78+
AddrInfo AddrInfoBasicType `json:"addrInfo"`
79+
}
80+
81+
//+kubebuilder:object:root=true
82+
//+kubebuilder:subresource:status
83+
84+
// CircuitRelay is the Schema for the circuitrelays API
85+
type CircuitRelay struct {
86+
metav1.TypeMeta `json:",inline"`
87+
metav1.ObjectMeta `json:"metadata,omitempty"`
88+
89+
Spec CircuitRelaySpec `json:"spec,omitempty"`
90+
Status CircuitRelayStatus `json:"status,omitempty"`
91+
}
92+
93+
//+kubebuilder:object:root=true
94+
95+
// CircuitRelayList contains a list of CircuitRelay
96+
type CircuitRelayList struct {
97+
metav1.TypeMeta `json:",inline"`
98+
metav1.ListMeta `json:"metadata,omitempty"`
99+
Items []CircuitRelay `json:"items"`
100+
}
101+
102+
func init() {
103+
SchemeBuilder.Register(&CircuitRelay{}, &CircuitRelayList{})
104+
}

api/v1alpha1/ipfs_types.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,22 @@ const (
3131
ReconciledReasonError string = "ReconcileError"
3232
)
3333

34+
type networkConfig struct {
35+
CircuitRelays int32 `json:"circuitRelays"`
36+
}
37+
3438
type IpfsSpec struct {
35-
URL string `json:"url"`
36-
Public bool `json:"public"`
37-
IpfsStorage string `json:"ipfsStorage"`
38-
ClusterStorage string `json:"clusterStorage"`
39-
Replicas int32 `json:"replicas"`
39+
URL string `json:"url"`
40+
Public bool `json:"public"`
41+
IpfsStorage string `json:"ipfsStorage"`
42+
ClusterStorage string `json:"clusterStorage"`
43+
Replicas int32 `json:"replicas"`
44+
Networking networkConfig `json:"networking"`
4045
}
4146

4247
type IpfsStatus struct {
43-
Conditions []metav1.Condition `json:"conditions,omitempty"`
44-
Addresses []string `json:"addresses,omitempty"`
48+
Conditions []metav1.Condition `json:"conditions,omitempty"`
49+
CircuitRelays []string `json:"circuitRelays,omitempty"`
4550
}
4651

4752
//+kubebuilder:object:root=true

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 93 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
annotations:
5+
controller-gen.kubebuilder.io/version: v0.8.0
6+
creationTimestamp: null
7+
name: circuitrelays.cluster.ipfs.io
8+
spec:
9+
group: cluster.ipfs.io
10+
names:
11+
kind: CircuitRelay
12+
listKind: CircuitRelayList
13+
plural: circuitrelays
14+
singular: circuitrelay
15+
scope: Namespaced
16+
versions:
17+
- name: v1alpha1
18+
schema:
19+
openAPIV3Schema:
20+
description: CircuitRelay is the Schema for the circuitrelays API
21+
properties:
22+
apiVersion:
23+
description: 'APIVersion defines the versioned schema of this representation
24+
of an object. Servers should convert recognized schemas to the latest
25+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
26+
type: string
27+
kind:
28+
description: 'Kind is a string value representing the REST resource this
29+
object represents. Servers may infer this from the endpoint the client
30+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
31+
type: string
32+
metadata:
33+
type: object
34+
spec:
35+
type: object
36+
status:
37+
properties:
38+
addrInfo:
39+
description: This is intended to mimic peer.AddrInfo
40+
properties:
41+
addrs:
42+
items:
43+
type: string
44+
type: array
45+
id:
46+
type: string
47+
required:
48+
- addrs
49+
- id
50+
type: object
51+
required:
52+
- addrInfo
53+
type: object
54+
type: object
55+
served: true
56+
storage: true
57+
subresources:
58+
status: {}
59+
status:
60+
acceptedNames:
61+
kind: ""
62+
plural: ""
63+
conditions: []
64+
storedVersions: []

bundle/manifests/cluster.ipfs.io_ipfs.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ spec:
3737
type: string
3838
ipfsStorage:
3939
type: string
40+
networking:
41+
properties:
42+
circuitRelays:
43+
format: int32
44+
type: integer
45+
required:
46+
- circuitRelays
47+
type: object
4048
public:
4149
type: boolean
4250
replicas:
@@ -47,13 +55,14 @@ spec:
4755
required:
4856
- clusterStorage
4957
- ipfsStorage
58+
- networking
5059
- public
5160
- replicas
5261
- url
5362
type: object
5463
status:
5564
properties:
56-
addresses:
65+
circuitRelays:
5766
items:
5867
type: string
5968
type: array

0 commit comments

Comments
 (0)