|
| 1 | +/* |
| 2 | +Copyright 2021. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package rukpakapi |
| 18 | + |
| 19 | +import ( |
| 20 | + corev1 "k8s.io/api/core/v1" |
| 21 | +) |
| 22 | + |
| 23 | +type SourceType string |
| 24 | + |
| 25 | +const ( |
| 26 | + SourceTypeImage SourceType = "image" |
| 27 | + SourceTypeGit SourceType = "git" |
| 28 | + SourceTypeConfigMaps SourceType = "configMaps" |
| 29 | + SourceTypeHTTP SourceType = "http" |
| 30 | + |
| 31 | + TypeUnpacked = "Unpacked" |
| 32 | + |
| 33 | + ReasonUnpackPending = "UnpackPending" |
| 34 | + ReasonUnpacking = "Unpacking" |
| 35 | + ReasonUnpackSuccessful = "UnpackSuccessful" |
| 36 | + ReasonUnpackFailed = "UnpackFailed" |
| 37 | + ReasonProcessingFinalizerFailed = "ProcessingFinalizerFailed" |
| 38 | + |
| 39 | + PhasePending = "Pending" |
| 40 | + PhaseUnpacking = "Unpacking" |
| 41 | + PhaseFailing = "Failing" |
| 42 | + PhaseUnpacked = "Unpacked" |
| 43 | +) |
| 44 | + |
| 45 | +type BundleSource struct { |
| 46 | + // Type defines the kind of Bundle content being sourced. |
| 47 | + Type SourceType `json:"type"` |
| 48 | + // Image is the bundle image that backs the content of this bundle. |
| 49 | + Image *ImageSource `json:"image,omitempty"` |
| 50 | + // Git is the git repository that backs the content of this Bundle. |
| 51 | + Git *GitSource `json:"git,omitempty"` |
| 52 | + // ConfigMaps is a list of config map references and their relative |
| 53 | + // directory paths that represent a bundle filesystem. |
| 54 | + ConfigMaps []ConfigMapSource `json:"configMaps,omitempty"` |
| 55 | + // HTTP is the remote location that backs the content of this Bundle. |
| 56 | + HTTP *HTTPSource `json:"http,omitempty"` |
| 57 | +} |
| 58 | + |
| 59 | +type ImageSource struct { |
| 60 | + // Ref contains the reference to a container image containing Bundle contents. |
| 61 | + Ref string `json:"ref"` |
| 62 | + // ImagePullSecretName contains the name of the image pull secret in the namespace that the provisioner is deployed. |
| 63 | + ImagePullSecretName string `json:"pullSecret,omitempty"` |
| 64 | +} |
| 65 | + |
| 66 | +type GitSource struct { |
| 67 | + // Repository is a URL link to the git repository containing the bundle. |
| 68 | + // Repository is required and the URL should be parsable by a standard git tool. |
| 69 | + Repository string `json:"repository"` |
| 70 | + // Directory refers to the location of the bundle within the git repository. |
| 71 | + // Directory is optional and if not set defaults to ./manifests. |
| 72 | + Directory string `json:"directory,omitempty"` |
| 73 | + // Ref configures the git source to clone a specific branch, tag, or commit |
| 74 | + // from the specified repo. Ref is required, and exactly one field within Ref |
| 75 | + // is required. Setting more than one field or zero fields will result in an |
| 76 | + // error. |
| 77 | + Ref GitRef `json:"ref"` |
| 78 | + // Auth configures the authorization method if necessary. |
| 79 | + Auth Authorization `json:"auth,omitempty"` |
| 80 | +} |
| 81 | + |
| 82 | +type ConfigMapSource struct { |
| 83 | + // ConfigMap is a reference to a configmap in the rukpak system namespace |
| 84 | + ConfigMap corev1.LocalObjectReference `json:"configMap"` |
| 85 | + // Path is the relative directory path within the bundle where the files |
| 86 | + // from the configmap will be present when the bundle is unpacked. |
| 87 | + Path string `json:"path,omitempty"` |
| 88 | +} |
| 89 | + |
| 90 | +type HTTPSource struct { |
| 91 | + // URL is where the bundle contents is. |
| 92 | + URL string `json:"url"` |
| 93 | + // Auth configures the authorization method if necessary. |
| 94 | + Auth Authorization `json:"auth,omitempty"` |
| 95 | +} |
| 96 | + |
| 97 | +type GitRef struct { |
| 98 | + // Branch refers to the branch to checkout from the repository. |
| 99 | + // The Branch should contain the bundle manifests in the specified directory. |
| 100 | + Branch string `json:"branch,omitempty"` |
| 101 | + // Tag refers to the tag to checkout from the repository. |
| 102 | + // The Tag should contain the bundle manifests in the specified directory. |
| 103 | + Tag string `json:"tag,omitempty"` |
| 104 | + // Commit refers to the commit to checkout from the repository. |
| 105 | + // The Commit should contain the bundle manifests in the specified directory. |
| 106 | + Commit string `json:"commit,omitempty"` |
| 107 | +} |
| 108 | + |
| 109 | +type Authorization struct { |
| 110 | + // Secret contains reference to the secret that has authorization information and is in the namespace that the provisioner is deployed. |
| 111 | + // The secret is expected to contain `data.username` and `data.password` for the username and password, respectively for http(s) scheme. |
| 112 | + // Refer to https://kubernetes.io/docs/concepts/configuration/secret/#basic-authentication-secret |
| 113 | + // For the ssh authorization of the GitSource, the secret is expected to contain `data.ssh-privatekey` and `data.ssh-knownhosts` for the ssh privatekey and the host entry in the known_hosts file respectively. |
| 114 | + // Refer to https://kubernetes.io/docs/concepts/configuration/secret/#ssh-authentication-secrets |
| 115 | + Secret corev1.LocalObjectReference `json:"secret,omitempty"` |
| 116 | + // InsecureSkipVerify controls whether a client verifies the server's certificate chain and host name. If InsecureSkipVerify |
| 117 | + // is true, the clone operation will accept any certificate presented by the server and any host name in that |
| 118 | + // certificate. In this mode, TLS is susceptible to machine-in-the-middle attacks unless custom verification is |
| 119 | + // used. This should be used only for testing. |
| 120 | + InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"` |
| 121 | +} |
| 122 | + |
| 123 | +type ProvisionerID string |
0 commit comments