Skip to content

Commit

Permalink
Add Gateway CRD
Browse files Browse the repository at this point in the history
This will be used to store and report the cluster-local engine
status.

Signed-off-by: Stephen Kitt <[email protected]>
  • Loading branch information
skitt authored and mangelajo committed Apr 14, 2020
1 parent 01ed175 commit fbff8b2
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions pkg/subctl/operator/submarinerop/crds/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,21 @@ func Ensure(restConfig *rest.Config) (bool, error) {
return false, err
}

crd, err := getSubmarinerCRD()
submarinerCrd, err := getSubmarinerCRD()
if err != nil {
return false, err
}

// Attempt to update or create the CRD definition
// TODO(majopela): In the future we may want to report when we have updated the existing
// CRD definition with new versions
return updateOrCreateCRD(clientSet, crd)
submarinerResult, err := updateOrCreateCRD(clientSet, submarinerCrd)
if err != nil {
return submarinerResult, err
}

gatewaysResult, err := updateOrCreateCRD(clientSet, getGatewaysCRD())
return (submarinerResult || gatewaysResult), err
}

func updateOrCreateCRD(clientSet clientset.Interface, crd *apiextensionsv1beta1.CustomResourceDefinition) (bool, error) {
Expand Down Expand Up @@ -77,3 +82,25 @@ func getSubmarinerCRD() (*apiextensionsv1beta1.CustomResourceDefinition, error)

return crd, nil
}

// TODO Move this to the operator
func getGatewaysCRD() *apiextensionsv1beta1.CustomResourceDefinition {
crd := &apiextensionsv1beta1.CustomResourceDefinition{
ObjectMeta: v1.ObjectMeta{
Name: "gateways.submariner.io",
},
Spec: apiextensionsv1beta1.CustomResourceDefinitionSpec{
Group: "submariner.io",
Scope: apiextensionsv1beta1.NamespaceScoped,
Names: apiextensionsv1beta1.CustomResourceDefinitionNames{
Plural: "gateways",
Singular: "gateway",
ListKind: "GatewayList",
Kind: "Gateway",
},
Version: "v1",
},
}

return crd
}

0 comments on commit fbff8b2

Please sign in to comment.