/*
Copyright AppsCode Inc. and Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/


// This file was autogenerated by go-to-protobuf. Do not edit it manually!

syntax = "proto2";

package kmodules.xyz.custom_resources.apis.appcatalog.v1alpha1;

import "k8s.io/api/core/v1/generated.proto";
import "k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto";
import "k8s.io/apimachinery/pkg/runtime/generated.proto";
import "k8s.io/apimachinery/pkg/runtime/schema/generated.proto";

// Package-wide variables from generator "generated".
option go_package = "kmodules.xyz/custom-resources/apis/appcatalog/v1alpha1";

// AddKeyTransform specifies that Service Catalog should add an
// additional entry to the Secret associated with the ServiceBinding.
// For example, given the following AddKeyTransform:
//
// 	{"key": "CONNECTION_POOL_SIZE", "stringValue": "10"}
//
// the following entry will appear in the Secret:
//
// 	"CONNECTION_POOL_SIZE": "10"
//
// Note that this transform should only be used to add non-sensitive
// (non-secret) values. To add sensitive information, the
// AddKeysFromTransform should be used instead.
message AddKeyTransform {
  // The name of the key to add
  optional string key = 1;

  // The binary value (possibly non-string) to add to the Secret under the specified key. If both
  // value and stringValue are specified, then value is ignored and stringValue is stored.
  // +optional
  optional bytes value = 2;

  // The string (non-binary) value to add to the Secret under the specified key.
  // +optional
  optional string stringValue = 3;
}

// AddKeysFromTransform specifies that Service Catalog should merge
// an existing secret into the Secret associated with the ServiceBinding.
// For example, given the following AddKeysFromTransform:
//
// 	{"secretRef": {"namespace": "foo", "name": "bar"}}
//
// the entries of the Secret "bar" from Namespace "foo" will be merged into
// the credentials Secret.
message AddKeysFromTransform {
  // The reference to the Secret that should be merged into the credentials Secret.
  optional k8s.io.api.core.v1.LocalObjectReference secretRef = 1;
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=appbindings,singular=appbinding,categories={catalog,appscode,all}
// +kubebuilder:printcolumn:name="Type",type="string",JSONPath=".spec.type"
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
message AppBinding {
  optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;

  optional AppBindingSpec spec = 2;
}

// AppBindingList is a list of Apps
message AppBindingList {
  optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;

  // Items is a list of AppBinding CRD objects
  repeated AppBinding items = 2;
}

// AppBindingSpec is the spec for app
message AppBindingSpec {
  // Type used to facilitate programmatic handling of application.
  // +optional
  optional string type = 1;

  // Reference to underlying application
  // +optional
  optional TypedObjectReference appRef = 2;

  // Version used to facilitate programmatic handling of application.
  // +optional
  optional string version = 3;

  // ClientConfig defines how to communicate with the app.
  // Required
  optional ClientConfig clientConfig = 4;

  // Secret is the name of the secret to create in the AppBinding's
  // namespace that will hold the credentials associated with the AppBinding.
  optional k8s.io.api.core.v1.LocalObjectReference secret = 5;

  // List of transformations that should be applied to the credentials
  // associated with the ServiceBinding before they are inserted into the Secret.
  repeated SecretTransform secretTransforms = 6;

  // Parameters is a set of the parameters to be used to connect to the
  // app. The inline YAML/JSON payload to be translated into equivalent
  // JSON object.
  //
  // The Parameters field is NOT secret or secured in any way and should
  // NEVER be used to hold sensitive information. To set parameters that
  // contain secret information, you should ALWAYS store that information
  // in a Secret.
  //
  // +optional
  // +kubebuilder:validation:EmbeddedResource
  // +kubebuilder:pruning:PreserveUnknownFields
  optional k8s.io.apimachinery.pkg.runtime.RawExtension parameters = 7;

  // TLSSecret is the name of the secret that will hold
  // the client certificate and private key associated with the AppBinding.
  optional k8s.io.api.core.v1.LocalObjectReference tlsSecret = 8;
}

message AppReference {
  // `namespace` is the namespace of the app.
  // Required
  optional string namespace = 1;

  // `name` is the name of the app.
  // Required
  optional string name = 2;

  // Parameters is a set of the parameters to be used to override default
  // parameters. The inline YAML/JSON payload to be translated into equivalent
  // JSON object.
  //
  // The Parameters field is NOT secret or secured in any way and should
  // NEVER be used to hold sensitive information.
  //
  // +optional
  // +kubebuilder:validation:EmbeddedResource
  // +kubebuilder:pruning:PreserveUnknownFields
  optional k8s.io.apimachinery.pkg.runtime.RawExtension parameters = 3;
}

// ClientConfig contains the information to make a connection with an app
message ClientConfig {
  // `url` gives the location of the app, in standard URL form
  // (`[scheme://]host:port/path`). Exactly one of `url` or `service`
  // must be specified.
  //
  // The `host` should not refer to a service running in the cluster; use
  // the `service` field instead. The host might be resolved via external
  // DNS in some apiservers (e.g., `kube-apiserver` cannot resolve
  // in-cluster DNS as that would be a layering violation). `host` may
  // also be an IP address.
  //
  // A path is optional, and if present may be any string permissible in
  // a URL. You may use the path to pass an arbitrary string to the
  // app, for example, a cluster identifier.
  //
  // Attempting to use a user or basic auth e.g. "user:password@" is not
  // allowed. Fragments ("#...") and query parameters ("?...") are not
  // allowed, either.
  //
  // +optional
  optional string url = 1;

  // `service` is a reference to the service for this app. Either
  // `service` or `url` must be specified.
  //
  // If the webhook is running within the cluster, then you should use `service`.
  //
  // +optional
  optional ServiceReference service = 2;

  // InsecureSkipTLSVerify disables TLS certificate verification when communicating with this app.
  // This is strongly discouraged.  You should use the CABundle instead.
  optional bool insecureSkipTLSVerify = 3;

  // CABundle is a PEM encoded CA bundle which will be used to validate the serving certificate of this app.
  // +optional
  optional bytes caBundle = 4;

  // ServerName is used to verify the hostname on the returned
  // certificates unless InsecureSkipVerify is given. It is also included
  // in the client's handshake to support virtual hosting unless it is
  // an IP address.
  optional string serverName = 5;
}

// ObjectReference contains enough information to let you locate the
// referenced object.
message ObjectReference {
  // Namespace of the referent.
  optional string namespace = 1;

  // Name of the referent.
  optional string name = 2;
}

// Param declares a value to use for the Param called Name.
message Param {
  optional string name = 1;

  optional string value = 2;
}

// RemoveKeyTransform specifies that one of the credentials keys returned
// from the broker should not be included in the credentials Secret.
message RemoveKeyTransform {
  // The key to remove from the Secret
  optional string key = 1;
}

// RenameKeyTransform specifies that one of the credentials keys returned
// from the broker should be renamed and stored under a different key
// in the Secret.
// For example, given the following credentials entry:
//
// 	"USERNAME": "johndoe"
//
// and the following RenameKeyTransform:
//
// 	{"from": "USERNAME", "to": "DB_USER"}
//
// the following entry will appear in the Secret:
//
// 	"DB_USER": "johndoe"
message RenameKeyTransform {
  // The name of the key to rename
  optional string from = 1;

  // The new name for the key
  optional string to = 2;
}

// SecretTransform is a single transformation that is applied to the
// credentials returned from the broker before they are inserted into
// the Secret associated with the ServiceBinding.
// Because different brokers providing the same type of service may
// each return a different credentials structure, users can specify
// the transformations that should be applied to the Secret to adapt
// its entries to whatever the service consumer expects.
// For example, the credentials returned by the broker may include the
// key "USERNAME", but the consumer requires the username to be
// exposed under the key "DB_USER" instead. To have the Service
// Catalog transform the Secret, the following SecretTransform must
// be specified in ServiceBinding.spec.secretTransform:
// - {"renameKey": {"from": "USERNAME", "to": "DB_USER"}}
// Only one of the SecretTransform's members may be specified.
message SecretTransform {
  // RenameKey represents a transform that renames a credentials Secret entry's key
  optional RenameKeyTransform renameKey = 1;

  // AddKey represents a transform that adds an additional key to the credentials Secret
  optional AddKeyTransform addKey = 2;

  // AddKeysFrom represents a transform that merges all the entries of an existing Secret
  // into the credentials Secret
  optional AddKeysFromTransform addKeysFrom = 3;

  // RemoveKey represents a transform that removes a credentials Secret entry
  optional RemoveKeyTransform removeKey = 4;
}

// ServiceReference holds a reference to Service.legacy.k8s.io
message ServiceReference {
  // Specifies which scheme to use, for example: http, https
  // If specified, then it will applied as prefix in this format: scheme://
  // If not specified, then nothing will be prefixed
  optional string scheme = 1;

  // `namespace` is the namespace of the service.
  // +optional
  optional string namespace = 2;

  // `name` is the name of the service.
  // Required
  optional string name = 3;

  // The port that will be exposed by this app.
  optional int32 port = 4;

  // `path` is an optional URL path which will be sent in any request to
  // this service.
  // +optional
  optional string path = 5;

  // `query` is optional encoded query string, without '?' which will be
  // sent in any request to this service.
  // +optional
  optional string query = 6;
}

message StashAddon {
  optional StashAddonSpec stash = 1;
}

// StashAddonSpec is the spec for app
message StashAddonSpec {
  optional StashTaskSpec addon = 1;
}

// StashTaskSpec is the spec for app
message StashTaskSpec {
  // Backup task definition
  optional TaskRef backupTask = 1;

  // Restore task definition
  optional TaskRef restoreTask = 2;
}

message TaskRef {
  optional string name = 1;

  // Params specifies a list of parameter to pass to the Task. Stash will use this parameters to resolve the task.
  // +optional
  repeated Param params = 2;
}

message TypedObjectReference {
  optional string apiGroup = 1;

  optional string kind = 2;

  // Namespace of the referent.
  // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
  // +optional
  optional string namespace = 3;

  // Name of the referent.
  // More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
  optional string name = 4;
}

