Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
fix formatting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JameelB committed Nov 2, 2018
1 parent 22ee6db commit 1d51c30
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 90 deletions.
2 changes: 1 addition & 1 deletion cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
k8sutil "github.com/operator-framework/operator-sdk/pkg/util/k8sutil"
sdkVersion "github.com/operator-framework/operator-sdk/version"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"math/rand"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
"time"
"math/rand"
)

func printVersion() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/integreatly/v1alpha1/gitea_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
type GiteaSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
Hostname string `json:"hostname"`
DeployProxy bool `json:"deployProxy"`
Hostname string `json:"hostname"`
DeployProxy bool `json:"deployProxy"`
}

// GiteaStatus defines the observed state of Gitea
Expand Down
10 changes: 5 additions & 5 deletions pkg/controller/gitea/gitea_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import (
integreatlyv1alpha1 "github.com/integr8ly/gitea-operator/pkg/apis/integreatly/v1alpha1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Add creates a new Gitea Controller and adds it to the Manager. The Manager will set fields on the Controller
Expand Down Expand Up @@ -129,7 +129,7 @@ func (r *ReconcileGitea) CreateResource(cr *integreatlyv1alpha1.Gitea, resourceN
// Try to find the resource, it may already exist
selector := types.NamespacedName{
Namespace: cr.Namespace,
Name: resourceName,
Name: resourceName,
}
err = r.client.Get(context.TODO(), selector, resource)

Expand All @@ -151,7 +151,7 @@ func (r *ReconcileGitea) CreateResource(cr *integreatlyv1alpha1.Gitea, resourceN
controllerutil.SetControllerReference(cr, resource.(v1.Object), r.scheme)

err = r.client.Create(context.TODO(), resource)
if err != nil {
if err != nil {
log.Printf("Error creating resource: %s", err)
}
}
10 changes: 5 additions & 5 deletions pkg/controller/gitea/resourceHelper.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package gitea

import (
integreatlyv1alpha1 "github.com/integr8ly/gitea-operator/pkg/apis/integreatly/v1alpha1"
yaml "github.com/ghodss/yaml"
"k8s.io/apimachinery/pkg/runtime"
integreatlyv1alpha1 "github.com/integr8ly/gitea-operator/pkg/apis/integreatly/v1alpha1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
)

type ResourceHelper struct {
templateHelper *GiteaTemplateHelper
cr *integreatlyv1alpha1.Gitea
cr *integreatlyv1alpha1.Gitea
}

func newResourceHelper(cr *integreatlyv1alpha1.Gitea) *ResourceHelper {
return &ResourceHelper{
templateHelper: newTemplateHelper(cr),
cr: cr,
cr: cr,
}
}

Expand All @@ -28,7 +28,7 @@ func (r *ResourceHelper) createResource(template string) (runtime.Object, error)
resource := unstructured.Unstructured{}
err = yaml.Unmarshal(tpl, &resource)

if err != nil {
if err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/gitea/resourceHelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ func TestCreateResource(t *testing.T) {
t.Errorf("Invalid resource for template %s", template)
}
}
}
}
147 changes: 74 additions & 73 deletions pkg/controller/gitea/templateHelper.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
package gitea

import (
"math/rand"
integreatlyv1alpha1 "github.com/integr8ly/gitea-operator/pkg/apis/integreatly/v1alpha1"
"io/ioutil"
"bytes"
"fmt"
"text/template"
integreatlyv1alpha1 "github.com/integr8ly/gitea-operator/pkg/apis/integreatly/v1alpha1"
"io/ioutil"
"math/rand"
"os"
"text/template"
)

var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")

const (
GiteaImage = "docker.io/wkulhanek/gitea"
GiteaVersion = "1.6"
GiteaConfigMapName = "gitea-config"
GiteaDeploymentName = "gitea"
GiteaIngressName = "gitea-ingress"
GiteaPgDeploymentName = "postgres"
GiteaPgPvcName = "gitea-postgres-pvc"
GiteaPgServiceName = "gitea-postgres-service"
GiteaReposPvcName = "gitea-repos-pvc"
GiteaImage = "docker.io/wkulhanek/gitea"
GiteaVersion = "1.6"
GiteaConfigMapName = "gitea-config"
GiteaDeploymentName = "gitea"
GiteaIngressName = "gitea-ingress"
GiteaPgDeploymentName = "postgres"
GiteaPgPvcName = "gitea-postgres-pvc"
GiteaPgServiceName = "gitea-postgres-service"
GiteaReposPvcName = "gitea-repos-pvc"
GiteaServiceAccountName = "gitea-service-account"
GiteaServiceName = "gitea-service"
ProxyDeploymentName = "oauth-proxy"
ProxyRouteName = "oauth-proxy-route"
ProxyServiceName = "oauth-proxy-service"
GiteaServiceName = "gitea-service"
ProxyDeploymentName = "oauth-proxy"
ProxyRouteName = "oauth-proxy-route"
ProxyServiceName = "oauth-proxy-service"
ProxyServiceAccountName = "oauth-proxy-service-account"
)

Expand All @@ -42,43 +43,43 @@ var DatabaseAdminPassword = generateToken(10)

type GiteaParameters struct {
// Resource names
GiteaConfigMapName string
GiteaDeploymentName string
GiteaIngressName string
GiteaPgDeploymentName string
GiteaPgPvcName string
GiteaPgServiceName string
GiteaReposPvcName string
GiteaConfigMapName string
GiteaDeploymentName string
GiteaIngressName string
GiteaPgDeploymentName string
GiteaPgPvcName string
GiteaPgServiceName string
GiteaReposPvcName string
GiteaServiceAccountName string
GiteaServiceName string
GiteaServiceName string

// OAuth Proxy names
ProxyDeploymentName string
ProxyRouteName string
ProxyServiceName string
ProxyDeploymentName string
ProxyRouteName string
ProxyServiceName string
ProxyServiceAccountName string

// Resource properties
ApplicationNamespace string
ApplicationName string
Hostname string
DatabaseUser string
DatabasePassword string
DatabaseAdminPassword string
DatabaseName string
ApplicationNamespace string
ApplicationName string
Hostname string
DatabaseUser string
DatabasePassword string
DatabaseAdminPassword string
DatabaseName string
DatabaseMaxConnections string
DatabaseSharedBuffers string
InstallLock bool
GiteaInternalToken string
GiteaSecretKey string
GiteaImage string
GiteaVersion string
GiteaVolumeCapacity string
DbVolumeCapacity string
DatabaseSharedBuffers string
InstallLock bool
GiteaInternalToken string
GiteaSecretKey string
GiteaImage string
GiteaVersion string
GiteaVolumeCapacity string
DbVolumeCapacity string
}

type GiteaTemplateHelper struct {
Parameters GiteaParameters
Parameters GiteaParameters
TemplatePath string
}

Expand All @@ -87,35 +88,35 @@ type GiteaTemplateHelper struct {
// by the user in the custom resource
func newTemplateHelper(cr *integreatlyv1alpha1.Gitea) *GiteaTemplateHelper {
param := GiteaParameters{
GiteaConfigMapName: GiteaConfigMapName,
GiteaDeploymentName: GiteaDeploymentName,
GiteaIngressName: GiteaIngressName,
GiteaPgDeploymentName: GiteaPgDeploymentName,
GiteaPgPvcName: GiteaPgPvcName,
GiteaPgServiceName: GiteaPgServiceName,
GiteaReposPvcName: GiteaReposPvcName,
GiteaConfigMapName: GiteaConfigMapName,
GiteaDeploymentName: GiteaDeploymentName,
GiteaIngressName: GiteaIngressName,
GiteaPgDeploymentName: GiteaPgDeploymentName,
GiteaPgPvcName: GiteaPgPvcName,
GiteaPgServiceName: GiteaPgServiceName,
GiteaReposPvcName: GiteaReposPvcName,
GiteaServiceAccountName: GiteaServiceAccountName,
GiteaServiceName: GiteaServiceName,
ProxyDeploymentName: ProxyDeploymentName,
ProxyRouteName: ProxyRouteName,
ProxyServiceName: ProxyServiceName,
GiteaServiceName: GiteaServiceName,
ProxyDeploymentName: ProxyDeploymentName,
ProxyRouteName: ProxyRouteName,
ProxyServiceName: ProxyServiceName,
ProxyServiceAccountName: ProxyServiceAccountName,
ApplicationNamespace: cr.Namespace,
ApplicationName: "gitea",
Hostname: cr.Spec.Hostname,
DatabaseUser: "gitea",
DatabasePassword: DatabasePassword,
DatabaseAdminPassword: DatabaseAdminPassword,
DatabaseName: "gitea",
DatabaseMaxConnections: "100",
DatabaseSharedBuffers: "12MB",
InstallLock: true,
GiteaInternalToken: generateToken(105),
GiteaSecretKey: generateToken(10),
GiteaImage: GiteaImage,
GiteaVersion: GiteaVersion,
GiteaVolumeCapacity: "1Gi",
DbVolumeCapacity: "1Gi",
ApplicationNamespace: cr.Namespace,
ApplicationName: "gitea",
Hostname: cr.Spec.Hostname,
DatabaseUser: "gitea",
DatabasePassword: DatabasePassword,
DatabaseAdminPassword: DatabaseAdminPassword,
DatabaseName: "gitea",
DatabaseMaxConnections: "100",
DatabaseSharedBuffers: "12MB",
InstallLock: true,
GiteaInternalToken: generateToken(105),
GiteaSecretKey: generateToken(10),
GiteaImage: GiteaImage,
GiteaVersion: GiteaVersion,
GiteaVolumeCapacity: "1Gi",
DbVolumeCapacity: "1Gi",
}

templatePath := os.Getenv("TEMPLATE_PATH")
Expand All @@ -124,7 +125,7 @@ func newTemplateHelper(cr *integreatlyv1alpha1.Gitea) *GiteaTemplateHelper {
}

return &GiteaTemplateHelper{
Parameters: param,
Parameters: param,
TemplatePath: templatePath,
}
}
Expand All @@ -150,4 +151,4 @@ func (h *GiteaTemplateHelper) loadTemplate(name string) ([]byte, error) {
}

return buffer.Bytes(), nil
}
}
4 changes: 2 additions & 2 deletions pkg/controller/gitea/templateHelper_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package gitea

import (
"testing"
"strings"
"testing"
)

// Verifies that all templates are present and can be parsed
Expand All @@ -24,4 +24,4 @@ func TestLoadTemplate(t *testing.T) {
t.Errorf("Namespace missing in template %s", template)
}
}
}
}
2 changes: 1 addition & 1 deletion pkg/controller/gitea/testing_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var MockCR = integreatlyv1alpha1.Gitea{
},
Spec: integreatlyv1alpha1.GiteaSpec{
DeployProxy: true,
Hostname: "gitea.example.com",
Hostname: "gitea.example.com",
},
}

Expand Down

0 comments on commit 1d51c30

Please sign in to comment.