diff --git a/cmd/root.go b/cmd/root.go index 588e21a..59e3f11 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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" diff --git a/go.mod b/go.mod index 1e09fda..d1b7693 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 42aa6b4..cf16ffd 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -29,8 +29,8 @@ 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= @@ -38,8 +38,8 @@ 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= @@ -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= diff --git a/internal/convert/convert.go b/internal/convert/convert.go index c3d0843..768f997 100644 --- a/internal/convert/convert.go +++ b/internal/convert/convert.go @@ -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" @@ -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, @@ -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 } diff --git a/internal/convert/convert_test.go b/internal/convert/convert_test.go index ce39621..345a546 100644 --- a/internal/convert/convert_test.go +++ b/internal/convert/convert_test.go @@ -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" diff --git a/internal/diff/diff.go b/internal/diff/diff.go index 86aefc8..3da9f95 100644 --- a/internal/diff/diff.go +++ b/internal/diff/diff.go @@ -220,6 +220,8 @@ func diff( nv.Example = gen[k].Example nv.UserError = gen[k].UserError + + nv.Secure = gen[k].Secure } resultSchema[k] = nv diff --git a/internal/gen/gen.go b/internal/gen/gen.go index c88f0ea..45b4133 100644 --- a/internal/gen/gen.go +++ b/internal/gen/gen.go @@ -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" @@ -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 } @@ -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 } @@ -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 } @@ -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() } diff --git a/internal/pkg/types/types.go b/internal/pkg/types/types.go index ec26466..faefafa 100644 --- a/internal/pkg/types/types.go +++ b/internal/pkg/types/types.go @@ -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. diff --git a/internal/pkg/util/util.go b/internal/pkg/util/util.go index f366e51..19a12dc 100644 --- a/internal/pkg/util/util.go +++ b/internal/pkg/util/util.go @@ -8,7 +8,7 @@ import ( "runtime" "time" - "github.com/aiven/aiven-go-client" + "github.com/aiven/aiven-go-client/v2" ) const ( diff --git a/pkg/dist/integration_endpoint_types.yml b/pkg/dist/integration_endpoint_types.yml index f7b16b5..d105d33 100644 --- a/pkg/dist/integration_endpoint_types.yml +++ b/pkg/dist/integration_endpoint_types.yml @@ -404,6 +404,7 @@ external_postgresql: type: string max_length: 256 example: jjKk45Nnd + _secure: true port: title: Port number of the server type: integer @@ -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. diff --git a/pkg/dist/service_types.yml b/pkg/dist/service_types.yml index 82a42a8..d1db7a0 100644 --- a/pkg/dist/service_types.yml +++ b/pkg/dist/service_types.yml @@ -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 @@ -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 @@ -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 @@ -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. @@ -4237,7 +4241,6 @@ 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. @@ -4245,7 +4248,7 @@ opensearch: 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. @@ -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 . Optional. Default is Authorization.' @@ -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.