Skip to content

Commit

Permalink
feat: Add an app CRD
Browse files Browse the repository at this point in the history
* support for exposing services (using expose controller)
  by adding element to CRD
* refactor exposecontroller logic out of commands
* An example of an app that uses the exposing services
  feature is https://github.com/jenkins-x-apps/jx-app-grafana
  - specifically see https://github.com/jenkins-x-apps/jx-app-grafana/blob/master/charts/jx-app-grafana/values.yaml#L1-L2 and
  https://github.com/jenkins-x-apps/jx-app-grafana/blob/master/charts/jx-app-grafana/templates/app.yaml
  • Loading branch information
pmuir committed Nov 27, 2018
1 parent 30787ab commit 81ea04b
Show file tree
Hide file tree
Showing 26 changed files with 973 additions and 251 deletions.
2 changes: 2 additions & 0 deletions pkg/apis/jenkins.io/v1/register.go
Expand Up @@ -42,6 +42,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&BuildPack{},
&BuildPackList{},
&App{},
&AppList{},
&CommitStatus{},
&CommitStatusList{},
&Environment{},
Expand Down
32 changes: 32 additions & 0 deletions pkg/apis/jenkins.io/v1/types_extensions.go
Expand Up @@ -411,3 +411,35 @@ type CommitStatusItem struct {
Description string `json:"description,omitempty" protobuf:"bytes,2,opt,name=description"`
Pass bool `json:"pass" protobuf:"bytes,3,opt,name=pass"`
}

// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:openapi-gen=true

// App is the metadata for an App
type App struct {
metav1.TypeMeta `json:",inline"`
// Standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

Spec AppSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
}

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

// AppList is a structure used by k8s to store lists of apps
type AppList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []App `json:"items"`
}

// AppSpec provides details of the metadata for an App
type AppSpec struct {
// A list of services that this App exposes
ExposedServices []string `json:"exposedServices,omitempty" protobuf:"bytes,1,opt,name=exposedServices"`
}
81 changes: 81 additions & 0 deletions pkg/apis/jenkins.io/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions pkg/certmanager/certmanager.go
@@ -0,0 +1,20 @@
package certmanager

import (
"fmt"

"github.com/jenkins-x/jx/pkg/kube"
"k8s.io/client-go/kubernetes"
)

// CopyCertmanagerResources copies certmanager resources to the targetNamespace
func CopyCertmanagerResources(targetNamespace string, ic kube.IngressConfig, kubeClient kubernetes.Interface) error {
if ic.TLS {
err := kube.CleanCertmanagerResources(kubeClient, targetNamespace, ic)
if err != nil {
return fmt.Errorf("failed to create certmanager resources in target namespace %s: %v", targetNamespace, err)
}
}

return nil
}
141 changes: 141 additions & 0 deletions pkg/client/clientset/versioned/typed/jenkins.io/v1/app.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 81ea04b

Please sign in to comment.