Skip to content

Commit

Permalink
feat: ocm integration
Browse files Browse the repository at this point in the history
  • Loading branch information
lburgazzoli committed Nov 7, 2022
1 parent 288ff50 commit 841d938
Show file tree
Hide file tree
Showing 42 changed files with 1,639 additions and 135 deletions.
49 changes: 16 additions & 33 deletions rhoc/cmd/rhoc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,36 @@ package main

import (
"fmt"
"github.com/bf2fc6cc711aee1a0c2a/cos-tools/rhoc/pkg/util/cmdutil"
"os"

"github.com/bf2fc6cc711aee1a0c2a/cos-tools/rhoc/pkg/cmd/root"
"github.com/redhat-developer/app-services-cli/pkg/core/config"
"github.com/redhat-developer/app-services-cli/pkg/core/localize/goi18n"
"github.com/redhat-developer/app-services-cli/pkg/shared/factory"
"github.com/redhat-developer/app-services-cli/pkg/shared/factory/defaultfactory"
)

func main() {
localizer, err := goi18n.New(&goi18n.Config{})
f, err := cmdutil.NewFactory()
if err != nil {
fmt.Fprintln(os.Stderr, err)
_, _ = fmt.Fprintln(os.Stdout, err)
os.Exit(1)
}

cmdFactory := defaultfactory.New(localizer)

if err != nil {
fmt.Println(cmdFactory.IOStreams.ErrOut, err)
os.Exit(1)
cfgFile, err := f.Config.Load()
if cfgFile == nil {
if !os.IsNotExist(err) {
_, _ = fmt.Fprintln(f.IOStreams.ErrOut, err)
os.Exit(1)
}

cfgFile = &config.Config{}
if err := f.Config.Save(cfgFile); err != nil {
_, _ = fmt.Fprintln(f.IOStreams.ErrOut, err)
os.Exit(1)
}
}

initConfig(cmdFactory)

rootCmd := root.NewRootCommand(cmdFactory)

err = rootCmd.Execute()
err = root.NewRootCommand(f).Execute()
if err == nil {
return
}
}

func initConfig(f *factory.Factory) {
cfgFile, err := f.Config.Load()

if cfgFile != nil {
return
}
if !os.IsNotExist(err) {
fmt.Fprintln(f.IOStreams.ErrOut, err)
os.Exit(1)
}

cfgFile = &config.Config{}
if err := f.Config.Save(cfgFile); err != nil {
fmt.Fprintln(f.IOStreams.ErrOut, err)
os.Exit(1)
}
}
52 changes: 50 additions & 2 deletions rhoc/etc/openapi/connector_mgmt-private-admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ paths:
content:
application/json:
schema:
$ref: "connector_mgmt.yaml#/components/schemas/ConnectorClusterList"
$ref: "#/components/schemas/ConnectorClusterAdminList"
description: A list of connector clusters
"401":
content:
Expand Down Expand Up @@ -77,7 +77,7 @@ paths:
content:
application/json:
schema:
$ref: "connector_mgmt.yaml#/components/schemas/ConnectorCluster"
$ref: "#/components/schemas/ConnectorClusterAdminView"
description: The connector cluster matching the request
"401":
content:
Expand Down Expand Up @@ -1211,6 +1211,54 @@ components:
shard_metadata:
type: object

ConnectorClusterAdminList:
allOf:
- $ref: "connector_mgmt.yaml#/components/schemas/List"
- type: object
properties:
items:
type: array
items:
$ref: "#/components/schemas/ConnectorClusterAdminView"

ConnectorClusterAdminStatus:
type: object
properties:
state:
$ref: 'connector_mgmt.yaml#/components/schemas/ConnectorClusterState'
version:
type: string
conditions:
type: array
items:
$ref: 'connector_mgmt-private.yaml#/components/schemas/MetaV1Condition'
platform:
$ref: 'connector_mgmt-private.yaml#/components/schemas/ConnectorClusterPlatform'
operators:
description: the list of installed operators
type: array
items:
type: object
properties:
operator:
$ref: 'connector_mgmt-private.yaml#/components/schemas/ConnectorOperator'
namespace:
description: the namespace to which the operator has been installed
type: string
status:
description: the status of the operator
type: string

ConnectorClusterAdminView:
allOf:
- $ref: "connector_mgmt.yaml#/components/schemas/ObjectReference"
- $ref: "connector_mgmt.yaml#/components/schemas/ConnectorClusterMeta"
- type: object
properties:
status:
$ref: "#/components/schemas/ConnectorClusterAdminStatus"


securitySchemes:
Bearer:
scheme: bearer
Expand Down
16 changes: 16 additions & 0 deletions rhoc/etc/openapi/connector_mgmt-private.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,20 @@ components:
description: the version of the operator
type: string

ConnectorClusterPlatform:
description: information about the kubernetes platform
type: object
properties:
type:
description: the kubernetes cluster type
type: string
id:
description: uniquely identifies the kubernetes cluster
type: string
version:
description: optional version of the kubernetes cluster
type: string

ConnectorClusterStatus:
description: "Schema for the request to update a data plane cluster's status"
type: object
Expand All @@ -561,6 +575,8 @@ components:
type: array
items:
$ref: '#/components/schemas/MetaV1Condition'
platform:
$ref: '#/components/schemas/ConnectorClusterPlatform'
operators:
description: the list of installed operators
type: array
Expand Down
67 changes: 66 additions & 1 deletion rhoc/etc/openapi/connector_mgmt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,44 @@ paths:
$ref: "#/components/examples/500Example"
description: Unexpected error occurred

"/api/connector_mgmt/v1/kafka_connector_types/labels":
get:
tags:
- Connector Types
security:
- Bearer: [ ]
operationId: getConnectorTypeLabels
summary: Returns a list of connector type labels
description: Returns a list of connector type labels
parameters:
- $ref: "#/components/parameters/orderBy"
- $ref: "#/components/parameters/search"
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/ConnectorTypeLabelCountList"
description: A list of connector type labels
"401":
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
401Example:
$ref: "#/components/examples/401Example"
description: Auth token is invalid
"500":
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
examples:
500Example:
$ref: "#/components/examples/500Example"
description: Unexpected error occurred

#
# Connector
#
Expand Down Expand Up @@ -1315,6 +1353,10 @@ components:
type: array
items:
type: string
featured_rank:
description: Ranking for featured connectors
type: integer
format: int32
capabilities:
description: The capabilities supported by the conenctor
type: array
Expand All @@ -1336,6 +1378,29 @@ components:
items:
$ref: "#/components/schemas/ConnectorType"

ConnectorTypeLabelCount:
description: Represents a connector type label and the number of types with that label
required:
- label
- count
type: object
properties:
label:
description: Name of the connector type label.
type: string
count:
description: Number of connector types with this label.
type: integer
format: int32

ConnectorTypeLabelCountList:
type: object
properties:
items:
type: array
items:
$ref: "#/components/schemas/ConnectorTypeLabelCount"

#
# Connector Namespaces
#
Expand Down Expand Up @@ -1560,7 +1625,7 @@ components:
* Cluster: id, created_at, updated_at, owner, organisation_id, name, state, client_id
* Namespace: id, created_at, updated_at, name, cluster_id, owner, expiration, tenant_user_id, tenant_organisation_id, state
* Connector Types: id, created_at, updated_at, version, name, description, label, channel
* Connector Types: id, created_at, updated_at, version, name, description, label, channel, featured_rank
* Connectors: id, created_at, updated_at, name, owner, organisation_id, connector_type_id, desired_state, state, channel, namespace_id, kafka_id, kafka_bootstrap_server, service_account_client_id, schema_registry_id, schema_registry_url
Allowed operators are `<>`, `=`, `LIKE`, or `ILIKE`.
Expand Down
36 changes: 30 additions & 6 deletions rhoc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ require (
github.com/gobeam/stringy v0.0.5
github.com/hashicorp/go-multierror v1.1.1
github.com/olekukonko/tablewriter v0.0.5
github.com/redhat-developer/app-services-cli v0.51.2
github.com/openshift-online/ocm-cli v0.1.60
github.com/openshift-online/ocm-sdk-go v0.1.287
github.com/pkg/errors v0.9.1
github.com/redhat-developer/app-services-cli v0.51.3
github.com/spf13/cobra v1.5.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.8.1
Expand All @@ -21,13 +24,27 @@ require (
k8s.io/client-go v0.24.4
)

require (
github.com/golang/glog v1.0.0
github.com/jeremywohl/flatten/v2 v2.0.0-20211013061545-07e4a09fb8e4
)

require (
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/openconfig/goyang v1.0.0 // indirect
)

require (
github.com/BurntSushi/toml v1.2.0 // indirect
github.com/Nerzal/gocloak/v7 v7.11.0 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/briandowns/spinner v1.18.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coreos/go-oidc/v3 v3.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1 // indirect
Expand All @@ -43,7 +60,7 @@ require (
github.com/go-openapi/swag v0.19.14 // indirect
github.com/go-resty/resty/v2 v2.3.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect; indirectdef4e6c14b // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
Expand All @@ -52,7 +69,8 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand All @@ -70,7 +88,10 @@ require (
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/microcosm-cc/bluemonday v1.0.18 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand All @@ -80,8 +101,11 @@ require (
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/redhat-developer/app-services-sdk-go v0.11.0 // indirect
github.com/redhat-developer/app-services-sdk-go/accountmgmt v0.2.0 // indirect
github.com/redhat-developer/app-services-sdk-go/connectormgmt v0.8.0 // indirect
Expand All @@ -102,7 +126,7 @@ require (
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 // indirect
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f // indirect
golang.org/x/net v0.0.0-20220909164309-bea034e7d591 // indirect
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
Expand All @@ -112,7 +136,7 @@ require (
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
Expand Down
Loading

0 comments on commit 841d938

Please sign in to comment.