Skip to content

Commit 494cf1a

Browse files
committed
adding configuration to Plan
1 parent ef63576 commit 494cf1a

File tree

10 files changed

+214
-70
lines changed

10 files changed

+214
-70
lines changed

artifacts/plans/s3-plan.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: hykube.io/v1alpha1
2+
kind: Plan
3+
metadata:
4+
name: aws-test
5+
spec:
6+
provider:
7+
name: aws
8+
config:
9+
test: "true"

docs/local-development.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ kubectl create -f artifacts/deployment/apiservice.yaml
7676

7777
## Test that your setup has worked
7878

79+
### Testing provider
80+
7981
You should now be able to create the resource type `Provider` which is the resource type registered by the API server.
8082

8183
```shell
@@ -103,8 +105,16 @@ kubectl get provider aws -o custom-columns=Name:.metadata.name,status:.status,Cr
103105
Once the provider is ready, you can add a test AWS S3 bucket:
104106

105107
```shell
106-
kubectl create -f artifacts/aws-test/s3-bucket.yaml
107-
kubectl delete -f artifacts/aws-test/s3-bucket.yaml
108+
kubectl create -f artifacts/aws-test/s3-bucket.yaml
109+
# aws-s3-bucket.aws.hykube.io/test-bucket created
110+
```
111+
112+
## Testing plan
113+
114+
One a provider is installed and test resource is added, we invoke a plan to perform synchronization:
115+
116+
```shell
117+
kubectl create -f artifacts/plans/s3-plan.yaml
108118
# aws-s3-bucket.aws.hykube.io/test-bucket created
109119
```
110120

hack/hykube_apiserver_violation_exceptions.list

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
API rule violation: names_match,github.com/infrapot/hykube/pkg/apis/hykube/v1alpha1,PlanSpec,Provider
2+
API rule violation: names_match,github.com/infrapot/hykube/pkg/apis/hykube/v1alpha1,ProviderPlanDetails,Config
3+
API rule violation: names_match,github.com/infrapot/hykube/pkg/apis/hykube/v1alpha1,ProviderPlanDetails,Name
14
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,APIResourceList,APIResources
25
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,Duration,Duration
36
API rule violation: names_match,k8s.io/apimachinery/pkg/apis/meta/v1,InternalEvent,Object

pkg/apis/hykube/types.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
1010

1111
package hykube
1212

13-
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13+
import (
14+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
15+
)
1416

1517
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
1618

@@ -51,9 +53,23 @@ type PlanList struct {
5153
Items []Plan
5254
}
5355

54-
// PlanSpec is the specification of a Provider.
56+
type ProviderPlanDetails struct {
57+
Name string
58+
Config interface{}
59+
}
60+
61+
func (p *ProviderPlanDetails) DeepCopy() *ProviderPlanDetails {
62+
ret := ProviderPlanDetails{}
63+
64+
ret.Name = p.Name
65+
ret.Config = p.Config // TODO: we assume configuration is always immutable; maybe marshal and unmarshal is better
66+
67+
return &ret
68+
}
69+
70+
// PlanSpec is the specification of a Plan.
5571
type PlanSpec struct {
56-
// TODO provider specific configuration
72+
Provider ProviderPlanDetails
5773
}
5874

5975
// +genclient

pkg/apis/hykube/v1alpha1/types.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ For details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
1010

1111
package v1alpha1
1212

13-
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13+
import (
14+
"github.com/infrapot/hykube/pkg/apis/hykube"
15+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16+
)
1417

1518
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
1619
// +k8s:prerelease-lifecycle-gen:introduced=1.0
@@ -59,7 +62,22 @@ type PlanList struct {
5962
Items []Plan `json:"items" protobuf:"bytes,2,rep,name=items"`
6063
}
6164

65+
type ProviderPlanDetails struct {
66+
Name string
67+
Config interface{}
68+
}
69+
70+
func (p *ProviderPlanDetails) DeepCopy() *ProviderPlanDetails {
71+
ret := ProviderPlanDetails{}
72+
73+
ret.Name = p.Name
74+
ret.Config = p.Config // TODO: we assume configuration is always immutable; maybe marshal and unmarshal is better
75+
76+
return &ret
77+
}
78+
6279
type PlanSpec struct {
80+
Provider hykube.ProviderPlanDetails
6381
}
6482

6583
type PlanStatus struct {

pkg/apis/hykube/v1alpha1/zz_generated.conversion.go

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/hykube/v1alpha1/zz_generated.deepcopy.go

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/hykube/zz_generated.deepcopy.go

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)