Skip to content

Commit

Permalink
Add pods queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Gorgol committed Jan 14, 2019
1 parent c5e7c82 commit 4000107
Show file tree
Hide file tree
Showing 77 changed files with 2,889 additions and 173 deletions.
333 changes: 276 additions & 57 deletions components/ui-api-layer/Gopkg.lock

Large diffs are not rendered by default.

Expand Up @@ -7,7 +7,7 @@ import (
"github.com/kyma-project/kyma/components/ui-api-layer/internal/gqlschema"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestApiConverter_ToGQL(t *testing.T) {
Expand Down
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/kyma-project/kyma/components/ui-api-layer/internal/gqlschema"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestApiResolver_APIsQuery(t *testing.T) {
Expand Down
Expand Up @@ -10,7 +10,7 @@ import (
testingUtils "github.com/kyma-project/kyma/components/ui-api-layer/internal/testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/cache"
)
Expand Down
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestApplicationStatusSuccess(t *testing.T) {
Expand Down
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
k8sTesting "k8s.io/client-go/testing"
Expand Down
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/kyma-project/kyma/components/ui-api-layer/internal/domain/content/storage"
"github.com/kyma-project/kyma/components/ui-api-layer/internal/gqlschema"
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestEventActivationConverter_ToGQL(t *testing.T) {
Expand Down
Expand Up @@ -11,7 +11,7 @@ import (
testingUtils "github.com/kyma-project/kyma/components/ui-api-layer/internal/testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/cache"
)
Expand Down
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/golang/glog"
"github.com/pkg/errors"
apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/watch"
Expand Down
Expand Up @@ -7,7 +7,7 @@ import (
idppresetv1alpha1 "github.com/kyma-project/kyma/components/idppreset/pkg/client/clientset/versioned/typed/authentication/v1alpha1"
"github.com/kyma-project/kyma/components/ui-api-layer/internal/pager"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
)

Expand Down
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
apiErrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
testingErrors "k8s.io/client-go/testing"
"k8s.io/client-go/tools/cache"
Expand Down
2 changes: 1 addition & 1 deletion components/ui-api-layer/internal/domain/content/content.go
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/kyma-project/kyma/components/ui-api-layer/internal/domain/content/storage"
"github.com/kyma-project/kyma/components/ui-api-layer/internal/gqlschema"
"github.com/kyma-project/kyma/components/ui-api-layer/internal/module"
"github.com/minio/minio-go"
minio "github.com/minio/minio-go"
)

type contentRetriever struct {
Expand Down
Expand Up @@ -3,7 +3,7 @@ package storage
import (
"io"

"github.com/minio/minio-go"
minio "github.com/minio/minio-go"
)

//go:generate mockery -name=Cache -output=automock -outpkg=automock -case=underscore
Expand Down
Expand Up @@ -6,7 +6,7 @@ import (
"path/filepath"

"github.com/golang/glog"
"github.com/minio/minio-go"
minio "github.com/minio/minio-go"
"github.com/pkg/errors"
)

Expand Down
Expand Up @@ -31,3 +31,11 @@ func NewLimitRangeLister() *limitRangeLister {
func NewResourceQuotaStatusChecker() *resourceQuotaStatusChecker {
return new(resourceQuotaStatusChecker)
}

func NewPodLister() *podLister {
return new(podLister)
}

func NewGqlPodConverter() *gqlPodConverter {
return new(gqlPodConverter)
}

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

58 changes: 58 additions & 0 deletions components/ui-api-layer/internal/domain/k8s/automock/pod_lister.go

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

2 changes: 1 addition & 1 deletion components/ui-api-layer/internal/domain/k8s/dep.go
Expand Up @@ -2,7 +2,7 @@ package k8s

import (
api "k8s.io/api/apps/v1beta2"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
)

//go:generate mockery -name=deploymentGetter -output=automock -outpkg=automock -case=underscore
Expand Down
Expand Up @@ -56,8 +56,8 @@ func (c *deploymentConverter) toGQLCondition(in api.DeploymentCondition) gqlsche
Message: in.Message,
LastUpdateTimestamp: in.LastUpdateTime.Time,
LastTransitionTimestamp: in.LastTransitionTime.Time,
Type: string(in.Type),
Status: string(in.Status),
Type: string(in.Type),
Status: string(in.Status),
}
}

Expand Down
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
appsApi "k8s.io/api/apps/v1beta2"
coreApi "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func TestDeploymentConverter_ToGQL(t *testing.T) {
Expand Down
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"k8s.io/api/apps/v1beta2"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes/fake"
Expand Down
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/kyma-project/kyma/components/ui-api-layer/internal/gqlschema"
"github.com/kyma-project/kyma/components/ui-api-layer/internal/module"
"github.com/pkg/errors"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
Expand Up @@ -3,7 +3,7 @@ package k8s
import (
"github.com/kyma-project/kyma/components/ui-api-layer/internal/domain/application/pretty"
"github.com/pkg/errors"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
)
Expand Down
14 changes: 14 additions & 0 deletions components/ui-api-layer/internal/domain/k8s/export_test.go
Expand Up @@ -25,3 +25,17 @@ func NewSecretResolver(secretGetter v1.SecretsGetter) *secretResolver {
func NewResourceQuotaService(rqInformer cache.SharedIndexInformer, rsInformer cache.SharedIndexInformer, ssInformer cache.SharedIndexInformer, podClient v1.CoreV1Interface) *resourceQuotaService {
return newResourceQuotaService(rqInformer, rsInformer, ssInformer, podClient)
}

// Pod

func NewPodResolver(podLister podLister) *podResolver {
return newPodResolver(podLister)
}

func (r *podResolver) SetInstanceConverter(converter gqlPodConverter) {
r.podConverter = converter
}

func NewPodService(informer cache.SharedIndexInformer) *podService {
return newPodService(informer)
}
5 changes: 4 additions & 1 deletion components/ui-api-layer/internal/domain/k8s/k8s.go
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/pkg/errors"
"k8s.io/client-go/informers"
k8sClientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/typed/core/v1"
v1 "k8s.io/client-go/kubernetes/typed/core/v1"
"k8s.io/client-go/rest"
)

Expand All @@ -25,6 +25,7 @@ type Resolver struct {
*resourceQuotaResolver
*resourceQuotaStatusResolver
*limitRangeResolver
*podResolver

informerFactory informers.SharedInformerFactory
}
Expand All @@ -45,6 +46,7 @@ func New(restConfig *rest.Config, informerResyncPeriod time.Duration, applicatio
environmentService := newEnvironmentService(client.Namespaces())
deploymentService := newDeploymentService(informerFactory.Apps().V1beta2().Deployments().Informer())
limitRangeService := newLimitRangeService(informerFactory.Core().V1().LimitRanges().Informer())
podService := newPodService(informerFactory.Core().V1().Pods().Informer())

resourceQuotaService := newResourceQuotaService(informerFactory.Core().V1().ResourceQuotas().Informer(),
informerFactory.Apps().V1().ReplicaSets().Informer(), informerFactory.Apps().V1().StatefulSets().Informer(), client)
Expand All @@ -54,6 +56,7 @@ func New(restConfig *rest.Config, informerResyncPeriod time.Duration, applicatio
environmentResolver: newEnvironmentResolver(environmentService, applicationRetriever),
secretResolver: newSecretResolver(client),
deploymentResolver: newDeploymentResolver(deploymentService, scRetriever, scaRetriever),
podResolver: newPodResolver(podService),
limitRangeResolver: newLimitRangeResolver(limitRangeService),
resourceQuotaResolver: newResourceQuotaResolver(resourceQuotaService),
resourceQuotaStatusResolver: newResourceQuotaStatusResolver(resourceQuotaStatusService),
Expand Down
Expand Up @@ -2,7 +2,7 @@ package k8s

import (
"github.com/kyma-project/kyma/components/ui-api-layer/internal/gqlschema"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
)

type limitRangeConverter struct{}
Expand Down
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/kyma-project/kyma/components/ui-api-layer/internal/gqlschema"
"github.com/stretchr/testify/assert"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down
Expand Up @@ -2,7 +2,7 @@ package k8s

import (
"github.com/pkg/errors"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/client-go/tools/cache"
)

Expand Down

0 comments on commit 4000107

Please sign in to comment.