Skip to content

Commit

Permalink
feat: add secure flag (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
byashimov authored Aug 14, 2024
1 parent ddf0a3d commit 5e360b6
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 30 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"
"strings"

"github.com/aiven/aiven-go-client"
"github.com/aiven/aiven-go-client/v2"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/aiven/go-api-schemas
go 1.22

require (
github.com/aiven/aiven-go-client v1.36.0
github.com/aiven/aiven-go-client/v2 v2.26.0
github.com/google/go-cmp v0.6.0
github.com/mitchellh/copystructure v1.2.0
github.com/spf13/cobra v1.8.1
Expand Down
14 changes: 6 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/aiven/aiven-go-client v1.36.0 h1:AUuldvYdk2b9wu4v7L9qx01d6ZB5VckiMgRW37yxZVE=
github.com/aiven/aiven-go-client v1.36.0/go.mod h1:3Hh1PDNcqNNCYrkU/jSAHMV/b/ynoy73fwhBPKnMe6I=
github.com/aiven/aiven-go-client/v2 v2.26.0 h1:1dBlF0BULbPsRXEEmcKs71AE3VZ+AYt5zv05LO/b8O4=
github.com/aiven/aiven-go-client/v2 v2.26.0/go.mod h1:KdHfLIlIRZIfCSEBd39j1Q81jlSb6Nd+oCQKqERfnuA=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -29,17 +29,17 @@ github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw=
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk=
github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 h1:LoYXNGAShUG3m/ehNk4iFctuhGX/+R1ZpfJ4/ia80JM=
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
Expand All @@ -55,7 +55,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
12 changes: 10 additions & 2 deletions internal/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package convert

import (
"errors"
"fmt"

"github.com/aiven/aiven-go-client"
"github.com/aiven/aiven-go-client/v2"
"github.com/mitchellh/copystructure"
"golang.org/x/exp/slices"

Expand Down Expand Up @@ -113,6 +114,12 @@ func UserConfigSchema(v aiven.UserConfigSchema) (*types.UserConfigSchema, error)
}
}

// Removes empty examples
var example any
if v.Example != nil && fmt.Sprintf("%v", v.Example) != "" {
example = v.Example
}

return &types.UserConfigSchema{
Title: v.Title,
Description: v.Description,
Expand All @@ -130,8 +137,9 @@ func UserConfigSchema(v aiven.UserConfigSchema) (*types.UserConfigSchema, error)
MaxItems: v.MaxItems,
CreateOnly: v.CreateOnly,
Pattern: v.Pattern,
Example: v.Example,
Example: example,
UserError: v.UserError,
Secure: v.Secure,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/convert/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package convert
import (
"testing"

"github.com/aiven/aiven-go-client"
"github.com/aiven/aiven-go-client/v2"
"github.com/google/go-cmp/cmp"

"github.com/aiven/go-api-schemas/internal/pkg/types"
Expand Down
2 changes: 2 additions & 0 deletions internal/diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ func diff(
nv.Example = gen[k].Example

nv.UserError = gen[k].UserError

nv.Secure = gen[k].Secure
}

resultSchema[k] = nv
Expand Down
24 changes: 12 additions & 12 deletions internal/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package gen

import (
"github.com/aiven/aiven-go-client"
"github.com/aiven/aiven-go-client/v2"
"golang.org/x/net/context"
"golang.org/x/sync/errgroup"

Expand All @@ -29,12 +29,12 @@ var client *aiven.Client
var result types.GenerationResult

// serviceTypes generates the service types.
func serviceTypes() error {
func serviceTypes(ctx context.Context) error {
defer util.MeasureExecutionTime(logger)()

logger.Info.Printf(generating, "service types")

r, err := client.Projects.ServiceTypes(env[util.EnvAivenProjectName])
r, err := client.Projects.ServiceTypes(ctx, env[util.EnvAivenProjectName])
if err != nil {
return err
}
Expand All @@ -56,12 +56,12 @@ func serviceTypes() error {
}

// integrationTypes generates the integration types.
func integrationTypes() error {
func integrationTypes(ctx context.Context) error {
defer util.MeasureExecutionTime(logger)()

logger.Info.Printf(generating, "integration types")

r, err := client.Projects.IntegrationTypes(env[util.EnvAivenProjectName])
r, err := client.Projects.IntegrationTypes(ctx, env[util.EnvAivenProjectName])
if err != nil {
return err
}
Expand All @@ -83,12 +83,12 @@ func integrationTypes() error {
}

// integrationEndpointTypes generates the integration endpoint types.
func integrationEndpointTypes() error {
func integrationEndpointTypes(ctx context.Context) error {
defer util.MeasureExecutionTime(logger)()

logger.Info.Printf(generating, "integration endpoint types")

r, err := client.Projects.IntegrationEndpointTypes(env[util.EnvAivenProjectName])
r, err := client.Projects.IntegrationEndpointTypes(ctx, env[util.EnvAivenProjectName])
if err != nil {
return err
}
Expand Down Expand Up @@ -127,11 +127,11 @@ func Run(
) (types.GenerationResult, error) {
setup(logger, env, client)

errs, _ := errgroup.WithContext(ctx)
g, ctx := errgroup.WithContext(ctx)

errs.Go(serviceTypes)
errs.Go(integrationTypes)
errs.Go(integrationEndpointTypes)
g.Go(func() error { return serviceTypes(ctx) })
g.Go(func() error { return integrationTypes(ctx) })
g.Go(func() error { return integrationEndpointTypes(ctx) })

return result, errs.Wait()
return result, g.Wait()
}
1 change: 1 addition & 0 deletions internal/pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type UserConfigSchema struct {
Pattern string `yaml:"pattern,omitempty"`
Example interface{} `yaml:"example,omitempty"`
UserError string `yaml:"user_error,omitempty"`
Secure bool `yaml:"_secure,omitempty"`
}

// GenerationResult represents the result of a generation.
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"runtime"
"time"

"github.com/aiven/aiven-go-client"
"github.com/aiven/aiven-go-client/v2"
)

const (
Expand Down
2 changes: 2 additions & 0 deletions pkg/dist/integration_endpoint_types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ external_postgresql:
type: string
max_length: 256
example: jjKk45Nnd
_secure: true
port:
title: Port number of the server
type: integer
Expand All @@ -428,6 +429,7 @@ external_postgresql:
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----
_secure: true
ssl_mode:
title: SSL Mode
description: SSL mode to use for the connection. Please note that Aiven requires TLS for all connections to external PostgreSQL services.
Expand Down
9 changes: 5 additions & 4 deletions pkg/dist/service_types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2478,6 +2478,7 @@ kafka:
title: Secret key used to authenticate with aws
type: string
max_length: 128
_secure: true
name:
title: Name of the secret provider. Used to reference secrets in connector config.
type: string
Expand Down Expand Up @@ -2511,6 +2512,7 @@ kafka:
title: Token used to authenticate with vault and auth method `token`.
type: string
max_length: 256
_secure: true
kafka_rest:
title: Enable Kafka-REST service
type: boolean
Expand Down Expand Up @@ -3017,6 +3019,7 @@ kafka_connect:
title: Secret key used to authenticate with aws
type: string
max_length: 128
_secure: true
name:
title: Name of the secret provider. Used to reference secrets in connector config.
type: string
Expand Down Expand Up @@ -3050,6 +3053,7 @@ kafka_connect:
title: Token used to authenticate with vault and auth method `token`.
type: string
max_length: 256
_secure: true
service_log:
title: Service logging
description: Store logs for the service so that they are available in the HTTP API and console.
Expand Down Expand Up @@ -4237,15 +4241,14 @@ opensearch:
min_length: 1
max_length: 1024
pattern: ^[^\r\n]*$
example: ""
client_secret:
title: The client secret of the OpenID Connect
description: The client secret of the OpenID Connect client configured in your IdP. Required.
type: string
min_length: 1
max_length: 1024
pattern: ^[^\r\n]*$
example: ""
_secure: true
connect_url:
title: OpenID Connect metadata/configuration URL
description: The URL of your IdP where the Security plugin can find the OpenID Connect metadata/configuration settings.
Expand All @@ -4265,7 +4268,6 @@ opensearch:
min_length: 1
max_length: 1024
pattern: ^[^\r\n]*$
example: ""
jwt_header:
title: The HTTP header that stores the token
description: 'The HTTP header that stores the token. Typically the Authorization header with the Bearer schema: Authorization: Bearer <token>. Optional. Default is Authorization.'
Expand Down Expand Up @@ -4321,7 +4323,6 @@ opensearch:
min_length: 1
max_length: 1024
pattern: ^[^\r\n]*$
example: ""
subject_key:
title: The key in the JSON payload that stores the user’s name
description: The key in the JSON payload that stores the user’s name. If not defined, the subject registered claim is used. Most IdP providers use the preferred_username claim. Optional.
Expand Down

0 comments on commit 5e360b6

Please sign in to comment.