Compare commits

..

92 Commits

Author SHA1 Message Date
Javier Adriel
9ed8f11b22 Change register tabs (#2250)
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-08-17 18:32:10 -05:00
Prakash Senthil Vel
860d8c6b78 UI to delete configured notification targets (#2213) 2022-08-17 15:40:37 -05:00
Alex
99965805a6 Reimplemented DirectPV API in operator console (#2207)
- Updated API to use latest directpv library

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-17 13:05:07 -05:00
Alex
7036d1328e Added Color customization to embedded object browser (#2246)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-17 11:06:10 -05:00
Lenin Alevski
697910c7b2 fix: buckets browse button was not clickable (#2249)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-08-16 18:23:48 -05:00
Kaan Kabalak
64dc605843 Fix inconsistencies in Health Diagnostics UI (#2239) 2022-08-12 22:45:08 -05:00
jinapurapu
75fa88e6e2 Added delay to Audit Log tests to reduce failure (#2245) 2022-08-12 22:44:27 -05:00
Alex
2857b8c586 Release v0.19.5 (#2243) 2022-08-10 20:43:36 -07:00
Alex
b1788c29db Disabled Object Locking button when permissions are not set (#2226)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-10 22:15:18 -05:00
jinapurapu
2e1401f013 Increased delay to reduce failure of Operator UI test (#2240) 2022-08-10 16:12:55 -05:00
Alex
1e1c11b13c Added FSGroupChangePolicy support to create tenant screen (#2233)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-10 13:28:15 -05:00
Javier Adriel
25c1c854b1 Add new section to register tenants with API key in operator (#2222) 2022-08-09 13:23:15 -05:00
Javier Adriel
5be2cc1965 Implement register handlers (#2219) 2022-08-09 13:22:53 -05:00
Alex
4aa3f40792 Removed permanent scrollbar in embedded object browser (#2237)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-09 12:02:09 -05:00
jinapurapu
3f41a82fd3 Image field fix (#2231) 2022-08-09 11:04:43 -05:00
Harshavardhana
1b641b4222 return bad request instead of 403's (#2229)
S3 API requests '403' as valid error
in some situations when client is probing
the server for valid S3 endpoint.

return '400 Bad Request' instead.
2022-08-08 15:37:01 -05:00
jinapurapu
85aabebbb4 Added text to AddBuckets Helpbox advising to enable versioning to enable retention (#2235)
Added hepbox guidance text to enable versioning in order to set retention on bucket creation
2022-08-08 14:08:08 -05:00
Pedro Juarez
919232261d switch to node version specified in .nvmrc file (#2225) 2022-08-05 17:54:47 -07:00
Harshavardhana
ddd25a20eb update CREDITS and enable builds for go1.19 (#2227) 2022-08-05 10:07:38 -05:00
Harshavardhana
84b8f9d6fa support P-384, P-512 constant time implementations (#2224)
fixes #2223
2022-08-04 15:36:38 -07:00
jinapurapu
46af0ff74c Protocol Logos for Add Tenant - Identity Provider (#2210) 2022-08-04 09:14:38 -07:00
Javier Adriel
b3651ed0a3 Auto register API key once it is retrieved from subnet (#2217) 2022-08-03 09:43:22 -07:00
Alex
78c4fa393a Changed x axis notation to display date indicator in zoom mode (#2221)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-02 22:23:27 -07:00
Kaan Kabalak
84c4159062 Fix anchors and update links for License page features (#2220) 2022-08-02 20:30:16 -05:00
Javier Adriel
ac2888fc4e Implement login and api key handlers (#2204) 2022-08-02 10:41:12 -05:00
Alex
c311847dcf Changed wrong button structure un buckets list page (#2218)
Also fixed issue with tests part 3 workflow

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-01 22:04:51 -05:00
Harshavardhana
cb6cda7265 fix: crash in operator console for missing fsGroup (#2211)
Bonus: Add support for "fsGroupChangePolicy"
Bonus: keep only github actions in workflow folder
2022-08-01 19:04:00 -07:00
Cesar Celis Hernandez
16fd5470db Correcting response on invalid login attempt (#2216)
Verifying detailed message error from bad login in SSO Test
2022-08-01 18:12:39 -05:00
jiuker
ea0cac2a92 fix:Incorrect template (#2196)
The formatting template is incorrectly formatted.
2022-08-01 17:44:35 -05:00
Alex
33b041ef34 Fixed incompatibility with some base64 strings & React Router v6 (#2208)
* Fixed incompatibility with some base64 strings & React Router v6

This affected Object Browser & certain Cyrillic / Chinese names

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-01 15:15:03 -05:00
Garen Chan
b692ea693f Fix error: setMultiBucketReplication healthCheckPeriod not work (#2212) 2022-08-01 13:12:54 -07:00
Cesar Celis Hernandez
fd39e50c08 Updating SSO Error Message on bad login (#2215)
Updating error message on bad sso login
2022-08-01 14:09:07 -05:00
Alex
ad4b9c050a Added DirectPV mode to Operator console (#2203)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-01 12:57:31 -05:00
Alex
1deb6371ed Release v0.19.4 (#2209)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-07-29 13:12:41 -07:00
Aditya Manthramurthy
3b11556f4b Fix build after swagger codegen (#2201) 2022-07-28 13:20:16 -07:00
Lenin Alevski
25f719b0e2 TLS Certificates help box and small bug fixes (#2206)
- Added TLSHelpBox component
- fix: Use the right `add` icon component in the security tab to be consistent
- fix: Add/Remove additional certificates button for custom certificates
- fix: Add/Remove additional users button for built-in IDP

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-07-28 14:18:28 -05:00
Alex
231b63f1b0 Added duration param to speedtest (#2205) 2022-07-27 21:00:54 -05:00
Javier Adriel
e73370cc8c Add dummy subnet handlers (#2198) 2022-07-27 16:34:19 -07:00
Javier Adriel
5d25dd4c06 Improve marketplace test coverage (#2202)
* Improve marketplace test coverage

* gofumpt
2022-07-27 16:33:56 -07:00
Kaan Kabalak
51a8bacc18 Implement WebSockets for Profile download (#2190) 2022-07-26 18:40:24 -07:00
Harshavardhana
db07f546a4 Release v0.19.3
Signed-off-by: Harshavardhana <harsha@minio.io>
2022-07-24 09:51:03 -07:00
Harshavardhana
255cf0bc85 fix: hard regression in console login from v0.19.2 release
fixes #2197
2022-07-24 09:41:55 -07:00
Harshavardhana
733e0b18e2 make sure build works for now 2022-07-22 22:47:08 -07:00
Daniel Valdivia
8d90e03992 Release v0.19.2 (#2194)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-07-22 22:15:03 -07:00
Cesar Celis Hernandez
1a1fae9ce3 Use intended console code in compiled MinIO (#2193) 2022-07-22 22:14:46 -07:00
Alex
f26786c904 Fixed Tiers load when information from tierStats is not available (#2191)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-07-22 12:40:38 -07:00
Javier Adriel
e0b6bf5aa6 Register api key section (#2180)
Split register section in tabs
Add register API key section
2022-07-22 11:27:53 -07:00
Daniel Valdivia
9655fc4490 Fix operator login not showing error (#2185)
* Fix operator login not showing error

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* Fix Test

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-07-22 12:21:25 -05:00
dependabot[bot]
417ea4d481 Bump terser from 5.14.0 to 5.14.2 in /portal-ui (#2187)
Bumps [terser](https://github.com/terser/terser) from 5.14.0 to 5.14.2.
- [Release notes](https://github.com/terser/terser/releases)
- [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/terser/terser/commits)

---
updated-dependencies:
- dependency-name: terser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-22 11:57:54 -05:00
Daniel Valdivia
5a59f8e3f4 iFrame Header when embedding (#2189)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-07-22 00:03:52 -07:00
jinapurapu
48340d0010 Fixed jumpy switch for Proxy configuration on Register screen (#2186) 2022-07-21 19:12:01 -05:00
Lenin Alevski
251de9fe8a Add support for adding LDAP admins based on user/group DNs (#2178)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-07-20 18:27:11 -07:00
Javier Adriel
c501df927b Split register section in tabs (#2176) 2022-07-20 18:26:43 -07:00
Daniel Valdivia
cdb1659506 Fix redirect to login base url. (#2182)
No longer needed due to baseUrl in the react router
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-07-20 16:23:24 -07:00
Lenin Alevski
558afe36ad Various fixes for Tenant details page (#2181)
- fixed refresh tenant details page after changing Domains and updating
  image
- Relax tenant domains to allow including port number

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-07-20 11:55:19 -05:00
Alex
712d3870eb Fixed storage class selectors for add & edit pool wizards (#2183)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-07-20 10:11:56 -05:00
NaccOll
c71f084531 feat: subpath support using reverse proxy (#2174) 2022-07-19 19:32:20 -07:00
jinapurapu
1c58a543b6 Monitoring and Audit Log config screen UI tests (#2179) 2022-07-19 19:10:21 -05:00
Alex
8e857dc563 Updated security issue with glob-parent dependency (#2177)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-07-18 19:00:48 -05:00
Javier Adriel
78d4d4c89e Add endpoint to get api key from subnet (#2175) 2022-07-18 17:51:07 -05:00
Alex
aea749d82f Added Loader in rewind enable function (#2172)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-07-18 15:39:14 -05:00
jinapurapu
ce3293b4e2 Added Testcafe test for Audit Logging text fields (#2173)
Added Testcafe test for Audit Logging text fields, fixed bug in setting serviceAccount
2022-07-15 17:06:33 -05:00
jinapurapu
0c12fbdd23 Tenant Monitoring Screen TestCafe UI tests (#2161) 2022-07-15 14:06:48 -05:00
Aditya Manthramurthy
118cf97e1d Allow multiple IDPs config to be passed via struct (#2167)
* Allow multiple IDPs config to be passed via struct

* This removes support for ENV based IDP configuration for console

* Ensure default scopes are used if none are given

* Add display name field for provider config
2022-07-14 07:27:45 -07:00
jinapurapu
abb668633b Added bucket naming rules to Add Bucket help text (#2171) 2022-07-13 14:05:37 -07:00
jinapurapu
dd2fffd3dc Tenant security context component (#2139)
Added edit Security Context component to Tenant Security screen, and updated API and backend to enable editing
2022-07-13 14:05:07 -07:00
Harshavardhana
64b13e9dc9 Remove pkg.MPSECRET unused value 2022-07-12 13:59:36 -07:00
Alex
58d7f1e8ae Release v0.19.1 (#2169)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-07-12 13:51:11 -07:00
dependabot[bot]
45e4a94416 Bump moment from 2.29.3 to 2.29.4 in /portal-ui (#2164)
Bumps [moment](https://github.com/moment/moment) from 2.29.3 to 2.29.4.
- [Release notes](https://github.com/moment/moment/releases)
- [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/moment/moment/compare/2.29.3...2.29.4)

---
updated-dependencies:
- dependency-name: moment
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-07 14:53:04 -05:00
jinapurapu
cce054bbe8 Create security context component and add to edit Prometheus Monitoring (#2115) 2022-07-07 14:52:30 -05:00
Alex
cf0e326b82 Object Browser only mode (#2157)
- Added flag CONSOLE_OBJECT_BROWSER_ONLY=on to trigger between console mode & Object Browser only
- Hidden not necessary buttons for object browse
- STS Login

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-07-07 12:28:25 -07:00
Javier Adriel
e48958f5a0 Connect marketplace API to microservice (#2130) 2022-07-06 23:11:23 -05:00
Klaus Post
63e2793272 Update trace response and dependencies (#2141) 2022-07-05 13:36:12 -07:00
Prakash Senthil Vel
532e64b802 UI AGPL license consent (#2154) 2022-07-05 09:17:51 -07:00
Alex
64b3e965c6 Change Support menu positon (#2160)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-07-05 11:08:18 -05:00
Alex
9371c027f3 Added Prettier test to workflow (#2159)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-06-30 23:40:23 -05:00
jinapurapu
a8bc58a420 Add Audit Log and Log DB security context selector and split screen into tabs (#2156)
* Added security context selector for logging and log DB to Audit Log screen, split Audit Log screen into tabs
* Cleaned up tab titles, disabled Save button while loading
2022-06-30 14:28:08 -07:00
Javier Adriel
10c56a91da Check if user is in EU (#2143) 2022-06-30 14:27:36 -07:00
Javier Adriel
403972de39 Select not working without dispatch (#2152) 2022-06-29 19:02:38 -05:00
Paweł Kuffel
1c0632473a Add object-level error message display in Downloads/Uploads panel (#2150) 2022-06-29 08:26:22 -07:00
Harshavardhana
ff93109b57 simplify and optimize deleting multiple versions of object (#2153) 2022-06-28 20:25:50 -07:00
Cesar Celis Hernandez
b518810106 Avoid the crash in the test (#2147) 2022-06-24 18:51:52 -05:00
Prakash Senthil Vel
b4d2d65c5c UX Top bar height (#2146) 2022-06-24 10:25:30 -07:00
Alex
beeb188d7e Fixed issues in Replication rules screens (#2145) 2022-06-23 21:35:50 -07:00
jinapurapu
2830022ede Tenant log config screen (#2142)
* Created file for auditLogsScreen, connected to link in TenantDetails Audit Log tab
* Fixed input title formatting, confirmation modal logic
2022-06-23 16:43:23 -07:00
Javier Adriel
ba4103e03f Prompt email after login (#2108)
* Add new route to marketplace modal
* Add redux logic for showing and displaying marketplace modal
* Redirect to marketplace view if console is in operator and marketplace mode
* Add marketplace component
* Use navigate instead of redirect
2022-06-23 12:22:38 -07:00
Alex
f3d6638384 Added improvements to Rename modal in windows (#2140)
- Disabled button when filename is less than 200 characters long
- Selector to override & accept long name
- Added this behavior when one file is checked in objects list

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-06-23 10:17:52 -05:00
Alex
2ad42d660b Added Rename modal for filenames longer than 200 characters in Windows (#2137)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-06-22 12:43:57 -05:00
Cesar Celis Hernandez
618a00d775 Improving our Operator Test in console (#2138) 2022-06-22 11:07:40 -05:00
jinapurapu
d0b65ce297 Single screen to display and edit Prometheus monitoring configuration (#2134)
* Created new screen to display and edit Prometheus monitoring configuration
* Updated image name validation to include slash and colon
* Removed unused files
2022-06-21 09:39:32 -07:00
Cesar Celis Hernandez
41f640077b Delete Tenant Test (#2098) 2022-06-20 15:24:44 -07:00
Cesar Celis Hernandez
bfa05616b1 Wait until resource exist to wait on it (#2136) 2022-06-20 14:48:54 -07:00
751 changed files with 22246 additions and 7531 deletions

View File

@@ -29,7 +29,7 @@ jobs:
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -98,7 +98,7 @@ jobs:
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -135,6 +135,7 @@ jobs:
run: |
echo "The idea is to build minio image from downloaded repository";
cd $GITHUB_WORKSPACE/minio_repository;
echo "replace github.com/minio/console => ../" >> go.mod
echo "Get git version to build MinIO Image";
VERSION=`git rev-parse HEAD`;
echo $VERSION;
@@ -167,7 +168,7 @@ jobs:
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
steps:
@@ -192,7 +193,7 @@ jobs:
curl -sLO "https://dl.k8s.io/release/v1.23.1/bin/linux/amd64/kubectl" -o kubectl
chmod +x kubectl
mv kubectl /usr/local/bin
"${GITHUB_WORKSPACE}/.github/workflows/deploy-tenant.sh"
"${GITHUB_WORKSPACE}/tests/deploy-tenant.sh"
echo "start ---> make test-operator-integration";
make test-operator-integration;
@@ -209,7 +210,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -233,7 +234,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -276,11 +277,11 @@ jobs:
semgrep --config semgrep.yaml $(pwd)/portal-ui --error
no-warnings-and-make-assets:
name: "React Code Has No Warnings and then Make Assets"
name: "React Code Has No Warnings & is Prettified, then Make Assets"
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -288,12 +289,18 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
id: go
- uses: actions/setup-node@v2
with:
node-version: '17'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Read .nvmrc
id: node_version
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NVMRC }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -329,13 +336,18 @@ jobs:
continue-on-error: false
run: |
./check-warnings.sh
- name: Check if Files are Prettified
working-directory: ./portal-ui
continue-on-error: false
run: |
./check-prettier.sh
reuse-golang-dependencies:
name: reuse golang dependencies
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -373,7 +385,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -381,12 +393,18 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
id: go
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Read .nvmrc
id: node_version
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NVMRC }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -452,7 +470,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -460,12 +478,18 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
id: go
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Read .nvmrc
id: node_version
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NVMRC }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -531,7 +555,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -539,12 +563,18 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
id: go
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Read .nvmrc
id: node_version
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NVMRC }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -612,7 +642,7 @@ jobs:
timeout-minutes: 5
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -620,11 +650,14 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
id: go
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Read .nvmrc
id: node_version
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NVMRC }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -681,7 +714,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -689,11 +722,14 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
id: go
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Read .nvmrc
id: node_version
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NVMRC }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -750,7 +786,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -758,11 +794,14 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
id: go
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Read .nvmrc
id: node_version
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NVMRC }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -819,7 +858,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -827,11 +866,14 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
id: go
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Read .nvmrc
id: node_version
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NVMRC }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -888,7 +930,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -896,11 +938,14 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
id: go
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Read .nvmrc
id: node_version
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NVMRC }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
@@ -946,6 +991,91 @@ jobs:
with:
args: '"chrome:headless" portal-ui/tests/permissions-8/ --skip-js-errors'
all-permissions-9:
name: Permissions Tests Part 9
needs:
- lint-job
- no-warnings-and-make-assets
- reuse-golang-dependencies
- vulnerable-dependencies-checks
- semgrep-static-code-analysis
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Read .nvmrc
id: node_version
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NVMRC }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
name: Yarn Cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
./portal-ui/node_modules/
./portal-ui/build/
key: ${{ runner.os }}-yarn-${{ hashFiles('./portal-ui/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/cache@v2
id: assets-cache
name: Assets Cache
with:
path: |
./portal-ui/build/
key: ${{ runner.os }}-assets-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-assets-
- uses: actions/cache@v2
name: Go Mod Cache
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ github.run_id }}
- name: Build Console on ${{ matrix.os }}
env:
GO111MODULE: on
GOOS: linux
run: |
make console
- name: Start Console, front-end app and initialize users/policies
run: |
(./console server) & (make initialize-permissions)
- name: Run TestCafe Tests
uses: DevExpress/testcafe-action@latest
with:
args: '"chrome:headless" portal-ui/tests/permissions-9/ --skip-js-errors -c 3'
- name: Clean up users & policies
run: |
make cleanup-permissions
all-operator-tests:
name: Operator UI Tests
needs:
@@ -957,7 +1087,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -965,11 +1095,18 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
id: go
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Read .nvmrc
id: node_version
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
- uses: actions/setup-node@v2
with:
node-version: ${{ env.NVMRC }}
- uses: actions/cache@v2
name: Go Mod Cache
with:
@@ -1031,7 +1168,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -1069,7 +1206,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -1107,7 +1244,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -1145,7 +1282,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -1183,7 +1320,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -1221,7 +1358,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -1259,7 +1396,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -1297,7 +1434,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -1343,7 +1480,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -1390,7 +1527,7 @@ jobs:
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
@@ -1502,7 +1639,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [ 1.17.x ]
go-version: [ 1.18.x, 1.19.x ]
os: [ ubuntu-latest ]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}

View File

@@ -5,6 +5,12 @@ linters-settings:
misspell:
locale: US
goheader:
values:
regexp:
copyright-holder: Copyright \(c\) (20\d\d\-20\d\d)|2021|({{year}})
template-path: .license.tmpl
linters:
disable-all: true
enable:
@@ -28,27 +34,21 @@ linters:
- tenv
- durationcheck
linters-settings:
goheader:
values:
regexp:
copyright-holder: Copyright \(c\) (20\d\d\-20\d\d)|2021|({{year}})
template-path: .license.tmpl
service:
golangci-lint-version: 1.43.0 # use the fixed version to not introduce new linters unexpectedly
issues:
exclude-use-default: false
exclude:
- should have a package comment
# TODO(y4m4): Remove once all exported ident. have comments!
- comment on exported function
- comment on exported type
- should have comment
- use leading k in Go names
- comment on exported const
- should have a package comment
# TODO(y4m4): Remove once all exported ident. have comments!
- comment on exported function
- comment on exported type
- should have comment
- use leading k in Go names
- comment on exported const
run:
skip-dirs:
- pkg/clientgen
- pkg/apis/networking.gke.io
- restapi/operations

1
.nvmrc Normal file
View File

@@ -0,0 +1 @@
17

2768
CREDITS

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,5 @@
FROM node:17 as uilayer
ARG NODE_VERSION
FROM node:$NODE_VERSION as uilayer
WORKDIR /app
@@ -12,7 +13,7 @@ RUN make build-static
USER node
FROM golang:1.17 as golayer
FROM golang:1.18 as golayer
RUN apt-get update -y && apt-get install -y ca-certificates
@@ -31,7 +32,7 @@ ENV CGO_ENABLED=0
COPY --from=uilayer /app/build /go/src/github.com/minio/console/portal-ui/build
RUN go build --tags=kqueue,operator -ldflags "-w -s" -a -o console ./cmd/console
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.5
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.6
MAINTAINER MinIO Development "dev@min.io"
EXPOSE 9090

View File

@@ -1,4 +1,5 @@
FROM node:17 as uilayer
ARG NODE_VERSION
FROM node:$NODE_VERSION as uilayer
WORKDIR /app

View File

@@ -6,6 +6,7 @@ BUILD_TIME:=$(shell date 2>/dev/null)
TAG ?= "minio/console:$(BUILD_VERSION)-dev"
MINIO_VERSION ?= "quay.io/minio/minio:latest"
TARGET_BUCKET ?= "target"
NODE_VERSION := $(shell cat .nvmrc)
default: console
@@ -15,13 +16,13 @@ console:
@(GO111MODULE=on CGO_ENABLED=0 go build -trimpath --tags=kqueue,operator --ldflags "-s -w" -o console ./cmd/console)
k8sdev:
@docker build -t $(TAG) --build-arg build_version=$(BUILD_VERSION) --build-arg build_time='$(BUILD_TIME)' .
@docker build -t $(TAG) --build-arg build_version=$(BUILD_VERSION) --build-arg build_time='$(BUILD_TIME)' --build-arg NODE_VERSION='$(NODE_VERSION)' .
@kind load docker-image $(TAG)
@echo "Done, now restart your console deployment"
getdeps:
@mkdir -p ${GOPATH}/bin
@which golangci-lint 1>/dev/null || (echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.43.0)
@echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin
verifiers: getdeps fmt lint
@@ -63,7 +64,8 @@ swagger-operator:
@swagger generate server -A operator --main-package=operator --server-package=operatorapi --exclude-main -P models.Principal -f ./swagger-operator.yml -r NOTICE
assets:
@(cd portal-ui; yarn install --prefer-offline; make build-static; yarn prettier --write . --loglevel warn; cd ..)
@(if [ -f "${NVM_DIR}/nvm.sh" ]; then \. "${NVM_DIR}/nvm.sh" && nvm install && nvm use && npm install -g yarn ; fi &&\
cd portal-ui; yarn install --prefer-offline; make build-static; yarn prettier --write . --loglevel warn; cd ..)
test-integration:
@(docker stop pgsqlcontainer || true)
@@ -261,7 +263,7 @@ clean:
@rm -vf console
docker:
@docker buildx build --output=type=docker --platform linux/amd64 -t $(TAG) --build-arg build_version=$(BUILD_VERSION) --build-arg build_time='$(BUILD_TIME)' .
@docker buildx build --output=type=docker --platform linux/amd64 -t $(TAG) --build-arg build_version=$(BUILD_VERSION) --build-arg build_time='$(BUILD_TIME)' --build-arg NODE_VERSION='$(NODE_VERSION)' .
release: swagger-gen
@echo "Generating Release: $(RELEASE)"

View File

@@ -17,6 +17,7 @@
package cluster
import (
directpvclient "github.com/minio/directpv/pkg/client"
operator "github.com/minio/operator/pkg/client/clientset/versioned"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
@@ -63,3 +64,13 @@ func OperatorClient(token string) (*operator.Clientset, error) {
func K8sClient(token string) (*kubernetes.Clientset, error) {
return kubernetes.NewForConfig(GetK8sConfig(token))
}
// DirectPV interfaces required to fetch information
func DirectPVDriveInterface(token string) (*directpvclient.DirectCSIDriveInterface, error) {
return directpvclient.DirectCSIDriveInterfaceForConfig(GetK8sConfig(token))
}
func DirectPVVolumeInterface(token string) (*directpvclient.DirectCSIVolumeInterface, error) {
return directpvclient.DirectCSIVolumeInterfaceForConfig(GetK8sConfig(token))
}

53
go.mod
View File

@@ -20,11 +20,12 @@ require (
github.com/jessevdk/go-flags v1.5.0
github.com/klauspost/compress v1.15.1
github.com/minio/cli v1.22.0
github.com/minio/directpv v1.4.4-0.20220805090942-948ca4731651
github.com/minio/highwayhash v1.0.2
github.com/minio/kes v0.19.2
github.com/minio/madmin-go v1.3.14
github.com/minio/mc v0.0.0-20220512134321-aa60a8db1e4d
github.com/minio/minio-go/v7 v7.0.26
github.com/minio/madmin-go v1.4.3
github.com/minio/mc v0.0.0-20220705180830-01b87ecc02ff
github.com/minio/minio-go/v7 v7.0.30
github.com/minio/operator v0.0.0-20220414212219-ba4c097324b2
github.com/minio/pkg v1.1.23
github.com/minio/selfupdate v0.4.0
@@ -34,21 +35,27 @@ require (
github.com/stretchr/testify v1.7.1
github.com/tidwall/gjson v1.14.0
github.com/unrolled/secure v1.10.0
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
golang.org/x/net v0.0.0-20220421235706-1d1ef9303861
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.23.5
k8s.io/apimachinery v0.23.5
k8s.io/client-go v0.23.5
k8s.io/api v0.24.3
k8s.io/apimachinery v0.24.3
k8s.io/client-go v0.24.3
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
)
require (
cloud.google.com/go v0.81.0 // indirect
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.18 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.13 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/briandowns/spinner v1.18.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/charmbracelet/bubbles v0.10.3 // indirect
github.com/charmbracelet/bubbletea v0.20.0 // indirect
@@ -60,8 +67,11 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/gdamore/encoding v1.0.0 // indirect
github.com/gdamore/tcell/v2 v2.4.1-0.20210905002822-f057f0a857a1 // indirect
github.com/go-logr/logr v1.2.2 // indirect
@@ -73,13 +83,16 @@ require (
github.com/goccy/go-json v0.9.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.7 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
@@ -92,12 +105,14 @@ require (
github.com/lestrrat-go/option v1.0.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-ieproxy v0.0.1 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mb0/glob v0.0.0-20160210091149-1eb79d2de6c4 // indirect
github.com/minio/colorjson v1.0.2 // indirect
github.com/minio/filepath v1.0.0 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
@@ -109,16 +124,18 @@ require (
github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.11.1-0.20220212125758-44cd13922739 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/navidys/tvxwidgets v0.1.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/philhofer/fwd v1.1.2-0.20210722190033-5c56ac6d0bb9 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/xattr v0.4.5 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/power-devops/perfstat v0.0.0-20220216144756-c35f1ee13d7c // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.33.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
@@ -128,6 +145,12 @@ require (
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/shirou/gopsutil/v3 v3.22.2 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.8.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/tinylib/msgp v1.1.7-0.20211026165309-e818a1881b0e // indirect
@@ -137,7 +160,7 @@ require (
go.etcd.io/etcd/api/v3 v3.5.2 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.2 // indirect
go.etcd.io/etcd/client/v3 v3.5.2 // indirect
go.mongodb.org/mongo-driver v1.8.4 // indirect
go.mongodb.org/mongo-driver v1.9.1 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
@@ -153,10 +176,10 @@ require (
gopkg.in/h2non/filetype.v1 v1.0.5 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/klog/v2 v2.40.1 // indirect
k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf // indirect
maze.io/x/duration v0.0.0-20160924141736-faac084b6075 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.24.3 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20220627174259-011e075b9cb8 // indirect
sigs.k8s.io/controller-runtime v0.11.1 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect

993
go.sum

File diff suppressed because it is too large Load Diff

View File

@@ -157,7 +157,7 @@ func TestBadLogin(t *testing.T) {
response, err := client.Do(request)
assert.Equal(response.StatusCode, 500, "Login request not rejected")
assert.Equal(401, response.StatusCode, "Login request not rejected")
assert.NotNil(response, "Login response is nil")
assert.Nil(err, "Login errored out")
}

View File

@@ -20,18 +20,16 @@ import (
"archive/zip"
"bytes"
"fmt"
"io"
"log"
"net/http"
"strings"
"testing"
"time"
"github.com/gorilla/websocket"
"github.com/stretchr/testify/assert"
)
func TestStartProfiling(t *testing.T) {
testAsser := assert.New(t)
testAssert := assert.New(t)
tests := []struct {
name string
@@ -58,53 +56,28 @@ func TestStartProfiling(t *testing.T) {
"profile-127.0.0.1:9000-mutex-before.pprof": false,
}
client := &http.Client{
Timeout: 3 * time.Second,
}
wsDestination := "/ws/profile?types=cpu,mem,block,mutex,trace,threads,goroutines"
wsFinalURL := fmt.Sprintf("ws://localhost:9090%s", wsDestination)
destination := "/api/v1/profiling/start"
finalURL := fmt.Sprintf("http://localhost:9090%s", destination)
request, err := http.NewRequest("POST", finalURL, strings.NewReader("{\"type\":\"cpu,mem,block,mutex,trace,threads,goroutines\"}"))
ws, _, err := websocket.DefaultDialer.Dial(wsFinalURL, nil)
if err != nil {
log.Println(err)
return
}
defer ws.Close()
_, zipFileBytes, err := ws.ReadMessage()
if err != nil {
log.Println(err)
return
}
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
request.Header.Add("Content-Type", "application/json")
response, err := client.Do(request)
testAsser.Nil(err, fmt.Sprintf("%s returned an error: %v", tt.name, err))
testAsser.Equal(201, response.StatusCode)
time.Sleep(5 * time.Second)
destination = "/api/v1/profiling/stop"
finalURL = fmt.Sprintf("http://localhost:9090%s", destination)
request, err = http.NewRequest("POST", finalURL, nil)
if err != nil {
log.Println(err)
return
}
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
request.Header.Add("Content-Type", "application/json")
response, err = client.Do(request)
testAsser.Nil(err, fmt.Sprintf("%s returned an error: %v", tt.name, err))
testAsser.Equal(200, response.StatusCode)
zipFileBytes, err := io.ReadAll(response.Body)
if err != nil {
testAsser.Nil(err, fmt.Sprintf("%s returned an error: %v", tt.name, err))
}
filetype := http.DetectContentType(zipFileBytes)
testAsser.Equal("application/zip", filetype)
testAssert.Equal("application/zip", filetype)
zipReader, err := zip.NewReader(bytes.NewReader(zipFileBytes), int64(len(zipFileBytes)))
if err != nil {
testAsser.Nil(err, fmt.Sprintf("%s returned an error: %v", tt.name, err))
testAssert.Nil(err, fmt.Sprintf("%s returned an error: %v", tt.name, err))
}
// Read all the files from zip archive
@@ -113,7 +86,7 @@ func TestStartProfiling(t *testing.T) {
}
for k, v := range files {
testAsser.Equal(true, v, fmt.Sprintf("%s : compressed file expected to have %v file inside", tt.name, k))
testAssert.Equal(true, v, fmt.Sprintf("%s : compressed file expected to have %v file inside", tt.name, k))
}
})
}

View File

@@ -2787,10 +2787,7 @@ func TestReplication(t *testing.T) {
}
finalResponse := inspectHTTPResponse(response)
if response != nil {
// https://github.com/minio/minio/pull/14972
// Disallow deletion of arn when active replication config
// no longer 204 is expected due to above change
assert.Equal(500, response.StatusCode, finalResponse)
assert.Equal(204, response.StatusCode, finalResponse)
}
// 6. Delete 2nd rule only with dedicated end point for single rules:
@@ -2825,10 +2822,7 @@ func TestReplication(t *testing.T) {
}
finalResponse = inspectHTTPResponse(response)
if response != nil {
// https://github.com/minio/minio/pull/14972
// Disallow deletion of arn when active replication config
// 204 is no longer expected but 500
assert.Equal(500, response.StatusCode, finalResponse)
assert.Equal(204, response.StatusCode, finalResponse)
}
// 8. Get replication, at this point zero rules are expected
@@ -2850,7 +2844,7 @@ func TestReplication(t *testing.T) {
log.Println(err)
assert.Nil(err)
}
expected := 3 // none got deleted due to https://github.com/minio/minio/pull/14972
expected := 0
actual := len(structBucketRepl.Rules)
assert.Equal(expected, actual, "Delete failed")
}

View File

@@ -15,7 +15,7 @@ spec:
serviceAccountName: console-sa
containers:
- name: console
image: 'minio/console:v0.19.0'
image: 'minio/console:v0.19.5'
imagePullPolicy: "IfNotPresent"
env:
- name: CONSOLE_OPERATOR_MODE

View File

@@ -32,7 +32,7 @@ spec:
spec:
containers:
- name: console
image: 'minio/console:v0.19.0'
image: 'minio/console:v0.19.5'
imagePullPolicy: "IfNotPresent"
env:
- name: CONSOLE_MINIO_SERVER

67
models/api_key.go Normal file
View File

@@ -0,0 +1,67 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// APIKey api key
//
// swagger:model apiKey
type APIKey struct {
// api key
APIKey string `json:"apiKey,omitempty"`
}
// Validate validates this api key
func (m *APIKey) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this api key based on context it is used
func (m *APIKey) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *APIKey) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *APIKey) UnmarshalBinary(b []byte) error {
var res APIKey
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,85 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// DirectPVDriveInfo direct p v drive info
//
// swagger:model directPVDriveInfo
type DirectPVDriveInfo struct {
// allocated
Allocated int64 `json:"allocated,omitempty"`
// capacity
Capacity int64 `json:"capacity,omitempty"`
// drive
Drive string `json:"drive,omitempty"`
// message
Message string `json:"message,omitempty"`
// node
Node string `json:"node,omitempty"`
// status
Status string `json:"status,omitempty"`
// volumes
Volumes int64 `json:"volumes,omitempty"`
}
// Validate validates this direct p v drive info
func (m *DirectPVDriveInfo) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this direct p v drive info based on context it is used
func (m *DirectPVDriveInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *DirectPVDriveInfo) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *DirectPVDriveInfo) UnmarshalBinary(b []byte) error {
var res DirectPVDriveInfo
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,76 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// DirectPVVolumeInfo direct p v volume info
//
// swagger:model directPVVolumeInfo
type DirectPVVolumeInfo struct {
// capacity
Capacity int64 `json:"capacity,omitempty"`
// drive
Drive string `json:"drive,omitempty"`
// node
Node string `json:"node,omitempty"`
// volume
Volume string `json:"volume,omitempty"`
}
// Validate validates this direct p v volume info
func (m *DirectPVVolumeInfo) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this direct p v volume info based on context it is used
func (m *DirectPVVolumeInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *DirectPVVolumeInfo) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *DirectPVVolumeInfo) UnmarshalBinary(b []byte) error {
var res DirectPVVolumeInfo
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,133 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// FormatDirectPVDrivesResponse format direct p v drives response
//
// swagger:model formatDirectPVDrivesResponse
type FormatDirectPVDrivesResponse struct {
// format issues list
FormatIssuesList []*PvFormatErrorResponse `json:"formatIssuesList"`
}
// Validate validates this format direct p v drives response
func (m *FormatDirectPVDrivesResponse) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateFormatIssuesList(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *FormatDirectPVDrivesResponse) validateFormatIssuesList(formats strfmt.Registry) error {
if swag.IsZero(m.FormatIssuesList) { // not required
return nil
}
for i := 0; i < len(m.FormatIssuesList); i++ {
if swag.IsZero(m.FormatIssuesList[i]) { // not required
continue
}
if m.FormatIssuesList[i] != nil {
if err := m.FormatIssuesList[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("formatIssuesList" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("formatIssuesList" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// ContextValidate validate this format direct p v drives response based on the context it is used
func (m *FormatDirectPVDrivesResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateFormatIssuesList(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *FormatDirectPVDrivesResponse) contextValidateFormatIssuesList(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.FormatIssuesList); i++ {
if m.FormatIssuesList[i] != nil {
if err := m.FormatIssuesList[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("formatIssuesList" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("formatIssuesList" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// MarshalBinary interface implementation
func (m *FormatDirectPVDrivesResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *FormatDirectPVDrivesResponse) UnmarshalBinary(b []byte) error {
var res FormatDirectPVDrivesResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,133 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// GetDirectPVDriveListResponse get direct p v drive list response
//
// swagger:model getDirectPVDriveListResponse
type GetDirectPVDriveListResponse struct {
// drives
Drives []*DirectPVDriveInfo `json:"drives"`
}
// Validate validates this get direct p v drive list response
func (m *GetDirectPVDriveListResponse) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateDrives(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *GetDirectPVDriveListResponse) validateDrives(formats strfmt.Registry) error {
if swag.IsZero(m.Drives) { // not required
return nil
}
for i := 0; i < len(m.Drives); i++ {
if swag.IsZero(m.Drives[i]) { // not required
continue
}
if m.Drives[i] != nil {
if err := m.Drives[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("drives" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("drives" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// ContextValidate validate this get direct p v drive list response based on the context it is used
func (m *GetDirectPVDriveListResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateDrives(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *GetDirectPVDriveListResponse) contextValidateDrives(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Drives); i++ {
if m.Drives[i] != nil {
if err := m.Drives[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("drives" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("drives" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// MarshalBinary interface implementation
func (m *GetDirectPVDriveListResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *GetDirectPVDriveListResponse) UnmarshalBinary(b []byte) error {
var res GetDirectPVDriveListResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,133 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"strconv"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// GetDirectPVVolumeListResponse get direct p v volume list response
//
// swagger:model getDirectPVVolumeListResponse
type GetDirectPVVolumeListResponse struct {
// volumes
Volumes []*DirectPVVolumeInfo `json:"volumes"`
}
// Validate validates this get direct p v volume list response
func (m *GetDirectPVVolumeListResponse) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateVolumes(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *GetDirectPVVolumeListResponse) validateVolumes(formats strfmt.Registry) error {
if swag.IsZero(m.Volumes) { // not required
return nil
}
for i := 0; i < len(m.Volumes); i++ {
if swag.IsZero(m.Volumes[i]) { // not required
continue
}
if m.Volumes[i] != nil {
if err := m.Volumes[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("volumes" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("volumes" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// ContextValidate validate this get direct p v volume list response based on the context it is used
func (m *GetDirectPVVolumeListResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateVolumes(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *GetDirectPVVolumeListResponse) contextValidateVolumes(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Volumes); i++ {
if m.Volumes[i] != nil {
if err := m.Volumes[i].ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("volumes" + "." + strconv.Itoa(i))
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("volumes" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// MarshalBinary interface implementation
func (m *GetDirectPVVolumeListResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *GetDirectPVVolumeListResponse) UnmarshalBinary(b []byte) error {
var res GetDirectPVVolumeListResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -37,6 +37,9 @@ import (
// swagger:model loginDetails
type LoginDetails struct {
// is direct p v
IsDirectPV bool `json:"isDirectPV,omitempty"`
// login strategy
// Enum: [form redirect service-account redirect-service-account]
LoginStrategy string `json:"loginStrategy,omitempty"`

View File

@@ -28,7 +28,6 @@ import (
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// LoginRequest login request
@@ -37,48 +36,32 @@ import (
type LoginRequest struct {
// access key
// Required: true
AccessKey *string `json:"accessKey"`
AccessKey string `json:"accessKey,omitempty"`
// features
Features *LoginRequestFeatures `json:"features,omitempty"`
// secret key
// Required: true
SecretKey *string `json:"secretKey"`
SecretKey string `json:"secretKey,omitempty"`
// sts
Sts string `json:"sts,omitempty"`
}
// Validate validates this login request
func (m *LoginRequest) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateAccessKey(formats); err != nil {
res = append(res, err)
}
if err := m.validateFeatures(formats); err != nil {
res = append(res, err)
}
if err := m.validateSecretKey(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *LoginRequest) validateAccessKey(formats strfmt.Registry) error {
if err := validate.Required("accessKey", "body", m.AccessKey); err != nil {
return err
}
return nil
}
func (m *LoginRequest) validateFeatures(formats strfmt.Registry) error {
if swag.IsZero(m.Features) { // not required
return nil
@@ -98,15 +81,6 @@ func (m *LoginRequest) validateFeatures(formats strfmt.Registry) error {
return nil
}
func (m *LoginRequest) validateSecretKey(formats strfmt.Registry) error {
if err := validate.Required("secretKey", "body", m.SecretKey); err != nil {
return err
}
return nil
}
// ContextValidate validate this login request based on the context it is used
func (m *LoginRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error

View File

@@ -36,6 +36,9 @@ type MpIntegration struct {
// email
Email string `json:"email,omitempty"`
// is in e u
IsInEU bool `json:"isInEU,omitempty"`
}
// Validate validates this mp integration

View File

@@ -37,6 +37,9 @@ import (
// swagger:model operatorSessionResponse
type OperatorSessionResponse struct {
// direct p v
DirectPV bool `json:"directPV,omitempty"`
// features
Features []string `json:"features"`

View File

@@ -0,0 +1,67 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// OperatorSubnetAPIKey operator subnet API key
//
// swagger:model operatorSubnetAPIKey
type OperatorSubnetAPIKey struct {
// api key
APIKey string `json:"apiKey,omitempty"`
}
// Validate validates this operator subnet API key
func (m *OperatorSubnetAPIKey) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this operator subnet API key based on context it is used
func (m *OperatorSubnetAPIKey) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *OperatorSubnetAPIKey) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *OperatorSubnetAPIKey) UnmarshalBinary(b []byte) error {
var res OperatorSubnetAPIKey
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,122 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// OperatorSubnetLoginMFARequest operator subnet login m f a request
//
// swagger:model operatorSubnetLoginMFARequest
type OperatorSubnetLoginMFARequest struct {
// mfa token
// Required: true
MfaToken *string `json:"mfa_token"`
// otp
// Required: true
Otp *string `json:"otp"`
// username
// Required: true
Username *string `json:"username"`
}
// Validate validates this operator subnet login m f a request
func (m *OperatorSubnetLoginMFARequest) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateMfaToken(formats); err != nil {
res = append(res, err)
}
if err := m.validateOtp(formats); err != nil {
res = append(res, err)
}
if err := m.validateUsername(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *OperatorSubnetLoginMFARequest) validateMfaToken(formats strfmt.Registry) error {
if err := validate.Required("mfa_token", "body", m.MfaToken); err != nil {
return err
}
return nil
}
func (m *OperatorSubnetLoginMFARequest) validateOtp(formats strfmt.Registry) error {
if err := validate.Required("otp", "body", m.Otp); err != nil {
return err
}
return nil
}
func (m *OperatorSubnetLoginMFARequest) validateUsername(formats strfmt.Registry) error {
if err := validate.Required("username", "body", m.Username); err != nil {
return err
}
return nil
}
// ContextValidate validates this operator subnet login m f a request based on context it is used
func (m *OperatorSubnetLoginMFARequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *OperatorSubnetLoginMFARequest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *OperatorSubnetLoginMFARequest) UnmarshalBinary(b []byte) error {
var res OperatorSubnetLoginMFARequest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,70 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// OperatorSubnetLoginRequest operator subnet login request
//
// swagger:model operatorSubnetLoginRequest
type OperatorSubnetLoginRequest struct {
// password
Password string `json:"password,omitempty"`
// username
Username string `json:"username,omitempty"`
}
// Validate validates this operator subnet login request
func (m *OperatorSubnetLoginRequest) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this operator subnet login request based on context it is used
func (m *OperatorSubnetLoginRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *OperatorSubnetLoginRequest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *OperatorSubnetLoginRequest) UnmarshalBinary(b []byte) error {
var res OperatorSubnetLoginRequest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,70 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// OperatorSubnetLoginResponse operator subnet login response
//
// swagger:model operatorSubnetLoginResponse
type OperatorSubnetLoginResponse struct {
// access token
AccessToken string `json:"access_token,omitempty"`
// mfa token
MfaToken string `json:"mfa_token,omitempty"`
}
// Validate validates this operator subnet login response
func (m *OperatorSubnetLoginResponse) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this operator subnet login response based on context it is used
func (m *OperatorSubnetLoginResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *OperatorSubnetLoginResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *OperatorSubnetLoginResponse) UnmarshalBinary(b []byte) error {
var res OperatorSubnetLoginResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,67 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// OperatorSubnetRegisterAPIKey operator subnet register API key
//
// swagger:model operatorSubnetRegisterAPIKey
type OperatorSubnetRegisterAPIKey struct {
// registered
Registered bool `json:"registered,omitempty"`
}
// Validate validates this operator subnet register API key
func (m *OperatorSubnetRegisterAPIKey) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this operator subnet register API key based on context it is used
func (m *OperatorSubnetRegisterAPIKey) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *OperatorSubnetRegisterAPIKey) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *OperatorSubnetRegisterAPIKey) UnmarshalBinary(b []byte) error {
var res OperatorSubnetRegisterAPIKey
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -0,0 +1,67 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// OperatorSubnetRegisterAPIKeyResponse operator subnet register API key response
//
// swagger:model operatorSubnetRegisterAPIKeyResponse
type OperatorSubnetRegisterAPIKeyResponse struct {
// registered
Registered bool `json:"registered,omitempty"`
}
// Validate validates this operator subnet register API key response
func (m *OperatorSubnetRegisterAPIKeyResponse) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this operator subnet register API key response based on context it is used
func (m *OperatorSubnetRegisterAPIKeyResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *OperatorSubnetRegisterAPIKeyResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *OperatorSubnetRegisterAPIKeyResponse) UnmarshalBinary(b []byte) error {
var res OperatorSubnetRegisterAPIKeyResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -46,8 +46,14 @@ type Principal struct {
// account access key
AccountAccessKey string `json:"accountAccessKey,omitempty"`
// custom style ob
CustomStyleOb string `json:"customStyleOb,omitempty"`
// hm
Hm bool `json:"hm,omitempty"`
// ob
Ob bool `json:"ob,omitempty"`
}
// Validate validates this principal

View File

@@ -0,0 +1,73 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// PvFormatErrorResponse pv format error response
//
// swagger:model pvFormatErrorResponse
type PvFormatErrorResponse struct {
// drive
Drive string `json:"drive,omitempty"`
// error
Error string `json:"error,omitempty"`
// node
Node string `json:"node,omitempty"`
}
// Validate validates this pv format error response
func (m *PvFormatErrorResponse) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this pv format error response based on context it is used
func (m *PvFormatErrorResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *PvFormatErrorResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *PvFormatErrorResponse) UnmarshalBinary(b []byte) error {
var res PvFormatErrorResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -37,8 +37,10 @@ import (
type SecurityContext struct {
// fs group
// Required: true
FsGroup *string `json:"fsGroup"`
FsGroup string `json:"fsGroup,omitempty"`
// fs group change policy
FsGroupChangePolicy string `json:"fsGroupChangePolicy,omitempty"`
// run as group
// Required: true
@@ -57,10 +59,6 @@ type SecurityContext struct {
func (m *SecurityContext) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateFsGroup(formats); err != nil {
res = append(res, err)
}
if err := m.validateRunAsGroup(formats); err != nil {
res = append(res, err)
}
@@ -79,15 +77,6 @@ func (m *SecurityContext) Validate(formats strfmt.Registry) error {
return nil
}
func (m *SecurityContext) validateFsGroup(formats strfmt.Registry) error {
if err := validate.Required("fsGroup", "body", m.FsGroup); err != nil {
return err
}
return nil
}
func (m *SecurityContext) validateRunAsGroup(formats strfmt.Registry) error {
if err := validate.Required("runAsGroup", "body", m.RunAsGroup); err != nil {

View File

@@ -41,6 +41,9 @@ type SessionResponse struct {
// allow resources
AllowResources []*PermissionResource `json:"allowResources"`
// custom styles
CustomStyles string `json:"customStyles,omitempty"`
// distributed mode
DistributedMode bool `json:"distributedMode,omitempty"`

View File

@@ -0,0 +1,70 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// SetAdministratorsRequest set administrators request
//
// swagger:model setAdministratorsRequest
type SetAdministratorsRequest struct {
// group dns
GroupDNS []string `json:"group_dns"`
// user dns
UserDNS []string `json:"user_dns"`
}
// Validate validates this set administrators request
func (m *SetAdministratorsRequest) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this set administrators request based on context it is used
func (m *SetAdministratorsRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *SetAdministratorsRequest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *SetAdministratorsRequest) UnmarshalBinary(b []byte) error {
var res SetAdministratorsRequest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -54,6 +54,9 @@ type TenantLogs struct {
// db node selector
DbNodeSelector []*NodeSelector `json:"dbNodeSelector"`
// db security context
DbSecurityContext *SecurityContext `json:"dbSecurityContext,omitempty"`
// db service account name
DbServiceAccountName string `json:"dbServiceAccountName,omitempty"`
@@ -84,6 +87,9 @@ type TenantLogs struct {
// node selector
NodeSelector []*NodeSelector `json:"nodeSelector"`
// security context
SecurityContext *SecurityContext `json:"securityContext,omitempty"`
// service account name
ServiceAccountName string `json:"serviceAccountName,omitempty"`
}
@@ -108,6 +114,10 @@ func (m *TenantLogs) Validate(formats strfmt.Registry) error {
res = append(res, err)
}
if err := m.validateDbSecurityContext(formats); err != nil {
res = append(res, err)
}
if err := m.validateLabels(formats); err != nil {
res = append(res, err)
}
@@ -116,6 +126,10 @@ func (m *TenantLogs) Validate(formats strfmt.Registry) error {
res = append(res, err)
}
if err := m.validateSecurityContext(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
@@ -226,6 +240,25 @@ func (m *TenantLogs) validateDbNodeSelector(formats strfmt.Registry) error {
return nil
}
func (m *TenantLogs) validateDbSecurityContext(formats strfmt.Registry) error {
if swag.IsZero(m.DbSecurityContext) { // not required
return nil
}
if m.DbSecurityContext != nil {
if err := m.DbSecurityContext.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("dbSecurityContext")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("dbSecurityContext")
}
return err
}
}
return nil
}
func (m *TenantLogs) validateLabels(formats strfmt.Registry) error {
if swag.IsZero(m.Labels) { // not required
return nil
@@ -278,6 +311,25 @@ func (m *TenantLogs) validateNodeSelector(formats strfmt.Registry) error {
return nil
}
func (m *TenantLogs) validateSecurityContext(formats strfmt.Registry) error {
if swag.IsZero(m.SecurityContext) { // not required
return nil
}
if m.SecurityContext != nil {
if err := m.SecurityContext.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("securityContext")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("securityContext")
}
return err
}
}
return nil
}
// ContextValidate validate this tenant logs based on the context it is used
func (m *TenantLogs) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
@@ -298,6 +350,10 @@ func (m *TenantLogs) ContextValidate(ctx context.Context, formats strfmt.Registr
res = append(res, err)
}
if err := m.contextValidateDbSecurityContext(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateLabels(ctx, formats); err != nil {
res = append(res, err)
}
@@ -306,6 +362,10 @@ func (m *TenantLogs) ContextValidate(ctx context.Context, formats strfmt.Registr
res = append(res, err)
}
if err := m.contextValidateSecurityContext(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
@@ -392,6 +452,22 @@ func (m *TenantLogs) contextValidateDbNodeSelector(ctx context.Context, formats
return nil
}
func (m *TenantLogs) contextValidateDbSecurityContext(ctx context.Context, formats strfmt.Registry) error {
if m.DbSecurityContext != nil {
if err := m.DbSecurityContext.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("dbSecurityContext")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("dbSecurityContext")
}
return err
}
}
return nil
}
func (m *TenantLogs) contextValidateLabels(ctx context.Context, formats strfmt.Registry) error {
for i := 0; i < len(m.Labels); i++ {
@@ -432,6 +508,22 @@ func (m *TenantLogs) contextValidateNodeSelector(ctx context.Context, formats st
return nil
}
func (m *TenantLogs) contextValidateSecurityContext(ctx context.Context, formats strfmt.Registry) error {
if m.SecurityContext != nil {
if err := m.SecurityContext.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("securityContext")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("securityContext")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *TenantLogs) MarshalBinary() ([]byte, error) {
if m == nil {

View File

@@ -63,6 +63,9 @@ type TenantMonitoringInfo struct {
// prometheus enabled
PrometheusEnabled bool `json:"prometheusEnabled,omitempty"`
// security context
SecurityContext *SecurityContext `json:"securityContext,omitempty"`
// service account name
ServiceAccountName string `json:"serviceAccountName,omitempty"`
@@ -92,6 +95,10 @@ func (m *TenantMonitoringInfo) Validate(formats strfmt.Registry) error {
res = append(res, err)
}
if err := m.validateSecurityContext(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
@@ -176,6 +183,25 @@ func (m *TenantMonitoringInfo) validateNodeSelector(formats strfmt.Registry) err
return nil
}
func (m *TenantMonitoringInfo) validateSecurityContext(formats strfmt.Registry) error {
if swag.IsZero(m.SecurityContext) { // not required
return nil
}
if m.SecurityContext != nil {
if err := m.SecurityContext.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("securityContext")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("securityContext")
}
return err
}
}
return nil
}
// ContextValidate validate this tenant monitoring info based on the context it is used
func (m *TenantMonitoringInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
@@ -192,6 +218,10 @@ func (m *TenantMonitoringInfo) ContextValidate(ctx context.Context, formats strf
res = append(res, err)
}
if err := m.contextValidateSecurityContext(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
@@ -258,6 +288,22 @@ func (m *TenantMonitoringInfo) contextValidateNodeSelector(ctx context.Context,
return nil
}
func (m *TenantMonitoringInfo) contextValidateSecurityContext(ctx context.Context, formats strfmt.Registry) error {
if m.SecurityContext != nil {
if err := m.SecurityContext.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("securityContext")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("securityContext")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *TenantMonitoringInfo) MarshalBinary() ([]byte, error) {
if m == nil {

View File

@@ -41,6 +41,9 @@ type TenantSecurityResponse struct {
// custom certificates
CustomCertificates *TenantSecurityResponseCustomCertificates `json:"customCertificates,omitempty"`
// security context
SecurityContext *SecurityContext `json:"securityContext,omitempty"`
}
// Validate validates this tenant security response
@@ -51,6 +54,10 @@ func (m *TenantSecurityResponse) Validate(formats strfmt.Registry) error {
res = append(res, err)
}
if err := m.validateSecurityContext(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
@@ -76,6 +83,25 @@ func (m *TenantSecurityResponse) validateCustomCertificates(formats strfmt.Regis
return nil
}
func (m *TenantSecurityResponse) validateSecurityContext(formats strfmt.Registry) error {
if swag.IsZero(m.SecurityContext) { // not required
return nil
}
if m.SecurityContext != nil {
if err := m.SecurityContext.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("securityContext")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("securityContext")
}
return err
}
}
return nil
}
// ContextValidate validate this tenant security response based on the context it is used
func (m *TenantSecurityResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
@@ -84,6 +110,10 @@ func (m *TenantSecurityResponse) ContextValidate(ctx context.Context, formats st
res = append(res, err)
}
if err := m.contextValidateSecurityContext(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
@@ -106,6 +136,22 @@ func (m *TenantSecurityResponse) contextValidateCustomCertificates(ctx context.C
return nil
}
func (m *TenantSecurityResponse) contextValidateSecurityContext(ctx context.Context, formats strfmt.Registry) error {
if m.SecurityContext != nil {
if err := m.SecurityContext.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("securityContext")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("securityContext")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *TenantSecurityResponse) MarshalBinary() ([]byte, error) {
if m == nil {

View File

@@ -41,6 +41,9 @@ type UpdateTenantSecurityRequest struct {
// custom certificates
CustomCertificates *UpdateTenantSecurityRequestCustomCertificates `json:"customCertificates,omitempty"`
// security context
SecurityContext *SecurityContext `json:"securityContext,omitempty"`
}
// Validate validates this update tenant security request
@@ -51,6 +54,10 @@ func (m *UpdateTenantSecurityRequest) Validate(formats strfmt.Registry) error {
res = append(res, err)
}
if err := m.validateSecurityContext(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
@@ -76,6 +83,25 @@ func (m *UpdateTenantSecurityRequest) validateCustomCertificates(formats strfmt.
return nil
}
func (m *UpdateTenantSecurityRequest) validateSecurityContext(formats strfmt.Registry) error {
if swag.IsZero(m.SecurityContext) { // not required
return nil
}
if m.SecurityContext != nil {
if err := m.SecurityContext.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("securityContext")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("securityContext")
}
return err
}
}
return nil
}
// ContextValidate validate this update tenant security request based on the context it is used
func (m *UpdateTenantSecurityRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
@@ -84,6 +110,10 @@ func (m *UpdateTenantSecurityRequest) ContextValidate(ctx context.Context, forma
res = append(res, err)
}
if err := m.contextValidateSecurityContext(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
@@ -106,6 +136,22 @@ func (m *UpdateTenantSecurityRequest) contextValidateCustomCertificates(ctx cont
return nil
}
func (m *UpdateTenantSecurityRequest) contextValidateSecurityContext(ctx context.Context, formats strfmt.Registry) error {
if m.SecurityContext != nil {
if err := m.SecurityContext.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("securityContext")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("securityContext")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *UpdateTenantSecurityRequest) MarshalBinary() ([]byte, error) {
if m == nil {

73
models/user_s_as.go Normal file
View File

@@ -0,0 +1,73 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// UserSAs user s as
//
// swagger:model userSAs
type UserSAs struct {
// path
Path string `json:"path,omitempty"`
// recursive
Recursive bool `json:"recursive,omitempty"`
// version ID
VersionID string `json:"versionID,omitempty"`
}
// Validate validates this user s as
func (m *UserSAs) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this user s as based on context it is used
func (m *UserSAs) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *UserSAs) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *UserSAs) UnmarshalBinary(b []byte) error {
var res UserSAs
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@@ -293,6 +293,29 @@ func CreateTenant(tenantName string, namespace string, accessKey string, secretK
return response, err
}
func DeleteTenant(nameSpace, tenant string) (*http.Response, error) {
/*
URL: /namespaces/{namespace}/tenants/{tenant}:
HTTP Verb: DELETE
Summary: Delete tenant and underlying pvcs
*/
request, err := http.NewRequest(
"DELETE",
"http://localhost:9090/api/v1/namespaces/"+nameSpace+"/tenants/"+tenant,
nil,
)
if err != nil {
log.Println(err)
}
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
request.Header.Add("Content-Type", "application/json")
client := &http.Client{
Timeout: 2 * time.Second,
}
response, err := client.Do(request)
return response, err
}
func TestCreateTenant(t *testing.T) {
printStartFunc("TestCreateTenant")
@@ -419,6 +442,159 @@ func TestCreateTenant(t *testing.T) {
printEndFunc("TestCreateTenant")
}
func TestDeleteTenant(t *testing.T) {
printStartFunc("TestCreateTenant")
// Variables
assert := assert.New(t)
erasureCodingParity := 2
tenantName := "new-tenant-3"
namespace := "new-namespace-3"
// 0. Create the namespace
resp, err := CreateNamespace(namespace)
assert.Nil(err)
if err != nil {
log.Println(err)
return
}
if resp != nil {
assert.Equal(
201, resp.StatusCode, inspectHTTPResponse(resp))
}
accessKey := ""
secretKey := ""
var accessKeys []string
var secretKeys []string
var minio []string
var caCertificates []string
var consoleCAcertificates []string
enableTLS := true
enableConsole := true
enablePrometheus := true
serviceName := ""
image := ""
exposeMinIO := true
exposeConsole := true
values := make([]string, 1)
values[0] = "new-tenant"
values2 := make([]string, 1)
values2[0] = "pool-0"
keys := make([]map[string]interface{}, 1)
keys[0] = map[string]interface{}{
"access_key": "IGLksSXdiU3fjcRI",
"secret_key": "EqeCPZ1xBYdnygizxxRWnkH09N2350nO",
}
pools := make([]map[string]interface{}, 1)
matchExpressions := make([]map[string]interface{}, 2)
matchExpressions[0] = map[string]interface{}{
"key": "v1.min.io/tenant",
"operator": "In",
"values": values,
}
matchExpressions[1] = map[string]interface{}{
"key": "v1.min.io/pool",
"operator": "In",
"values": values2,
}
requiredDuringSchedulingIgnoredDuringExecution := make([]map[string]interface{}, 1)
requiredDuringSchedulingIgnoredDuringExecution[0] = map[string]interface{}{
"labelSelector": map[string]interface{}{
"matchExpressions": matchExpressions,
},
"topologyKey": "kubernetes.io/hostname",
}
pools0 := map[string]interface{}{
"name": "pool-0",
"servers": 4,
"volumes_per_server": 1,
"volume_configuration": map[string]interface{}{
"size": 26843545600,
"storage_class_name": "standard",
},
"securityContext": nil,
"affinity": map[string]interface{}{
"podAntiAffinity": map[string]interface{}{
"requiredDuringSchedulingIgnoredDuringExecution": requiredDuringSchedulingIgnoredDuringExecution,
},
},
"resources": map[string]interface{}{
"requests": map[string]interface{}{
"cpu": 2,
"memory": 2,
},
},
}
logSearchConfiguration := map[string]interface{}{
"image": "",
"postgres_image": "",
"postgres_init_image": "",
}
prometheusConfiguration := map[string]interface{}{
"image": "",
"sidecar_image": "",
"init_image": "",
}
tls := map[string]interface{}{
"minio": minio,
"ca_certificates": caCertificates,
"console_ca_certificates": consoleCAcertificates,
}
idp := map[string]interface{}{
"keys": keys,
}
pools[0] = pools0
// 1. Create Tenant
resp, err = CreateTenant(
tenantName,
namespace,
accessKey,
secretKey,
accessKeys,
idp,
tls,
prometheusConfiguration,
logSearchConfiguration,
erasureCodingParity,
pools,
exposeConsole,
exposeMinIO,
image,
serviceName,
enablePrometheus,
enableConsole,
enableTLS,
secretKeys,
)
assert.Nil(err)
if err != nil {
log.Println(err)
return
}
if resp != nil {
assert.Equal(
200, resp.StatusCode, "Status Code is incorrect")
}
// 2. Delete tenant
resp, err = DeleteTenant(namespace, tenantName)
if err != nil {
log.Println(err)
return
}
if resp != nil {
assert.Equal(
204,
resp.StatusCode,
inspectHTTPResponse(resp),
)
}
printEndFunc("TestCreateTenant")
}
func ListTenantsByNameSpace(namespace string) (*http.Response, error) {
/*
Helper function to list buckets
@@ -459,7 +635,10 @@ func TestListTenantsByNameSpace(t *testing.T) {
log.Println(err)
assert.Nil(err)
}
TenantName := &result.Tenants[0].Name // The array has to be empty, no index accessible
if len(result.Tenants) == 0 {
assert.Fail("FAIL: There are no tenants in the array")
}
TenantName := &result.Tenants[0].Name
fmt.Println(*TenantName)
assert.Equal("new-tenant", *TenantName, *TenantName)
}

View File

@@ -69,3 +69,10 @@ func getK8sSAToken() string {
func getMarketplace() string {
return env.Get(ConsoleMarketplace, "")
}
// Get DirectPVMode
func getDirectPVEnabled() bool {
currentMode := env.Get(DirectPVMode, "off")
return currentMode == "on"
}

View File

@@ -89,7 +89,12 @@ func configureAPI(api *operations.OperatorAPI) http.Handler {
registerVolumesHandlers(api)
// Namespaces handlers
registerNamespaceHandlers(api)
// Marketplace handlers
registerMarketplaceHandlers(api)
// Subnet handlers
registerOperatorSubnetHandlers(api)
// Direct PV handlers
registerDirectPVHandlers(api)
api.PreServerShutdown = func() {}

View File

@@ -25,6 +25,9 @@ const (
prometheusPath = "prometheus.io/path"
prometheusPort = "prometheus.io/port"
prometheusScrape = "prometheus.io/scrape"
// Constants for DirectPV
DirectPVMode = "DIRECTPV_MODE"
)
// Image versions

328
operatorapi/directpv.go Normal file
View File

@@ -0,0 +1,328 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package operatorapi
import (
"context"
"errors"
"sort"
"strings"
"github.com/minio/directpv/pkg/utils"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/cluster"
"github.com/minio/console/models"
"github.com/minio/console/operatorapi/operations"
"github.com/minio/console/operatorapi/operations/operator_api"
xerrors "github.com/minio/console/restapi"
directcsi "github.com/minio/directpv/pkg/apis/direct.csi.min.io/v1beta4"
"github.com/minio/directpv/pkg/sys"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const XFS = "xfs"
func registerDirectPVHandlers(api *operations.OperatorAPI) {
api.OperatorAPIGetDirectPVDriveListHandler = operator_api.GetDirectPVDriveListHandlerFunc(func(params operator_api.GetDirectPVDriveListParams, session *models.Principal) middleware.Responder {
resp, err := getDirectPVDrivesListResponse(session)
if err != nil {
return operator_api.NewGetDirectPVDriveListDefault(int(err.Code)).WithPayload(err)
}
return operator_api.NewGetDirectPVDriveListOK().WithPayload(resp)
})
api.OperatorAPIGetDirectPVVolumeListHandler = operator_api.GetDirectPVVolumeListHandlerFunc(func(params operator_api.GetDirectPVVolumeListParams, session *models.Principal) middleware.Responder {
resp, err := getDirectPVVolumesListResponse(session)
if err != nil {
return operator_api.NewGetDirectPVVolumeListDefault(int(err.Code)).WithPayload(err)
}
return operator_api.NewGetDirectPVVolumeListOK().WithPayload(resp)
})
api.OperatorAPIDirectPVFormatDriveHandler = operator_api.DirectPVFormatDriveHandlerFunc(func(params operator_api.DirectPVFormatDriveParams, session *models.Principal) middleware.Responder {
resp, err := formatVolumesResponse(session, params)
if err != nil {
return operator_api.NewDirectPVFormatDriveDefault(int(err.Code)).WithPayload(err)
}
return operator_api.NewDirectPVFormatDriveOK().WithPayload(resp)
})
}
// getDirectPVVolumesList returns directPV drives
func getDirectPVDriveList(ctx context.Context, driveInterface DirectPVDrivesClientI) (*models.GetDirectPVDriveListResponse, error) {
drivesList, err := driveInterface.List(ctx, metav1.ListOptions{})
if err != nil {
return nil, err
}
res := &models.GetDirectPVDriveListResponse{}
// implementation same as directPV `drives ls` command
driveName := func(val string) string {
dr := strings.ReplaceAll(val, sys.DirectCSIDevRoot+"/", "")
dr = strings.ReplaceAll(dr, sys.HostDevRoot+"/", "")
return strings.ReplaceAll(dr, sys.DirectCSIPartitionInfix, "")
}
drivesSorted := drivesList.Items
// sort by nodename, path and status
sort.Slice(drivesSorted, func(i, j int) bool {
d1 := drivesSorted[i]
d2 := drivesSorted[j]
if v := strings.Compare(d1.Status.NodeName, d2.Status.NodeName); v != 0 {
return v < 0
}
if v := strings.Compare(d1.Status.Path, d2.Status.Path); v != 0 {
return v < 0
}
return strings.Compare(string(d1.Status.DriveStatus), string(d2.Status.DriveStatus)) < 0
})
for _, d := range drivesSorted {
volumes := 0
if len(d.Finalizers) > 1 {
volumes = len(d.Finalizers) - 1
}
dr := driveName(d.Status.Path)
dr = strings.ReplaceAll("/dev/"+dr, sys.DirectCSIPartitionInfix, "")
status := d.Status.DriveStatus
msg := ""
for _, c := range d.Status.Conditions {
switch c.Type {
case string(directcsi.DirectCSIDriveConditionInitialized), string(directcsi.DirectCSIDriveConditionOwned), string(directcsi.DirectCSIDriveConditionReady):
if c.Status != metav1.ConditionTrue {
msg = c.Message
if msg != "" {
status = d.Status.DriveStatus + "*"
msg = strings.ReplaceAll(msg, d.Name, "")
msg = strings.ReplaceAll(msg, sys.DirectCSIDevRoot, "/dev")
msg = strings.ReplaceAll(msg, sys.DirectCSIPartitionInfix, "")
msg = strings.Split(msg, "\n")[0]
}
}
}
}
var allocatedCapacity int64
if status == directcsi.DriveStatusInUse {
allocatedCapacity = d.Status.AllocatedCapacity
}
drStatus := d.Status.DriveStatus
driveInfo := &models.DirectPVDriveInfo{
Drive: dr,
Capacity: d.Status.TotalCapacity,
Allocated: allocatedCapacity,
Node: d.Status.NodeName,
Status: string(drStatus),
Message: msg,
Volumes: int64(volumes),
}
res.Drives = append(res.Drives, driveInfo)
}
return res, nil
}
func getDirectPVDrivesListResponse(session *models.Principal) (*models.GetDirectPVDriveListResponse, *models.Error) {
ctx := context.Background()
driveInterface, err := cluster.DirectPVDriveInterface(session.STSSessionToken)
if err != nil {
return nil, xerrors.ErrorWithContext(ctx, err)
}
directPVDrvClient := &directPVDrivesClient{
client: driveInterface,
}
drives, err := getDirectPVDriveList(ctx, directPVDrvClient)
if err != nil {
return nil, xerrors.ErrorWithContext(ctx, err)
}
return drives, nil
}
// getDirectPVVolumesList returns directPV volumes
func getDirectPVVolumesList(ctx context.Context, volumeInterface DirectPVVolumesClientI) (*models.GetDirectPVVolumeListResponse, error) {
volList, err := volumeInterface.List(ctx, metav1.ListOptions{})
if err != nil {
return nil, err
}
driveName := func(val string) string {
dr := strings.ReplaceAll(val, sys.DirectCSIDevRoot+"/", "")
return strings.ReplaceAll(dr, sys.HostDevRoot+"/", "")
}
getLabelValue := func(obj metav1.Object, key string) string {
if labels := obj.GetLabels(); labels != nil {
return labels[key]
}
return ""
}
var volumes []*models.DirectPVVolumeInfo
for _, v := range volList.Items {
vol := &models.DirectPVVolumeInfo{
Volume: v.Name,
Capacity: v.Status.TotalCapacity,
Drive: driveName(getLabelValue(&v, string(utils.DrivePathLabelKey))),
Node: v.Status.NodeName,
}
volumes = append(volumes, vol)
}
res := &models.GetDirectPVVolumeListResponse{
Volumes: volumes,
}
return res, nil
}
func getDirectPVVolumesListResponse(session *models.Principal) (*models.GetDirectPVVolumeListResponse, *models.Error) {
ctx := context.Background()
volumeInterface, err := cluster.DirectPVVolumeInterface(session.STSSessionToken)
if err != nil {
return nil, xerrors.ErrorWithContext(ctx, err)
}
directPVVolClient := &directPVVolumesClient{
client: volumeInterface,
}
volumes, err := getDirectPVVolumesList(ctx, directPVVolClient)
if err != nil {
return nil, xerrors.ErrorWithContext(ctx, err)
}
return volumes, nil
}
func formatDrives(ctx context.Context, driveInterface DirectPVDrivesClientI, drives []string, force bool) (*models.FormatDirectPVDrivesResponse, error) {
if len(drives) == 0 {
return nil, errors.New("at least one drive needs to be set")
}
driveList, err := driveInterface.List(ctx, metav1.ListOptions{})
if err != nil {
return nil, err
}
driveName := func(val string) string {
dr := strings.ReplaceAll(val, sys.DirectCSIDevRoot+"/", "")
dr = strings.ReplaceAll(dr, sys.HostDevRoot+"/", "")
return strings.ReplaceAll(dr, sys.DirectCSIPartitionInfix, "")
}
drivesArray := map[string]string{}
for _, driveFromAPI := range drives {
drivesArray[driveFromAPI] = driveFromAPI
}
if len(driveList.Items) == 0 {
return nil, errors.New("no resources found globally")
}
var errorResponses []*models.PvFormatErrorResponse
for _, driveItem := range driveList.Items {
drName := "/dev/" + driveName(driveItem.Status.Path)
driveName := driveItem.Status.NodeName + ":" + drName
base := &models.PvFormatErrorResponse{
Node: driveItem.Status.NodeName,
Drive: drName,
Error: "",
}
// Element is requested to be formatted
if _, ok := drivesArray[driveName]; ok {
if driveItem.Status.DriveStatus == directcsi.DriveStatusUnavailable {
base.Error = "Status is unavailable"
errorResponses = append(errorResponses, base)
continue
}
if driveItem.Status.DriveStatus == directcsi.DriveStatusInUse {
base.Error = "Drive in use. Cannot be formatted"
errorResponses = append(errorResponses, base)
continue
}
if driveItem.Status.DriveStatus == directcsi.DriveStatusReady {
base.Error = "Drive already owned and managed."
errorResponses = append(errorResponses, base)
continue
}
if driveItem.Status.Filesystem != "" && !force {
base.Error = "Drive already has a fs. Use force to overwrite"
errorResponses = append(errorResponses, base)
continue
}
if driveItem.Status.DriveStatus == directcsi.DriveStatusReleased {
base.Error = "Drive is in 'released state'. Please wait until it becomes available"
errorResponses = append(errorResponses, base)
continue
}
// Validation passes, we request format
driveItem.Spec.DirectCSIOwned = true
driveItem.Spec.RequestedFormat = &directcsi.RequestedFormat{
Filesystem: XFS,
Force: force,
}
_, err := driveInterface.Update(ctx, &driveItem, metav1.UpdateOptions{})
if err != nil {
base.Error = err.Error()
errorResponses = append(errorResponses, base)
}
}
}
returnErrors := &models.FormatDirectPVDrivesResponse{
FormatIssuesList: errorResponses,
}
return returnErrors, nil
}
func formatVolumesResponse(session *models.Principal, params operator_api.DirectPVFormatDriveParams) (*models.FormatDirectPVDrivesResponse, *models.Error) {
ctx := context.Background()
driveInterface, err := cluster.DirectPVDriveInterface(session.STSSessionToken)
if err != nil {
return nil, xerrors.ErrorWithContext(ctx, err)
}
directPVDrvClient := &directPVDrivesClient{
client: driveInterface,
}
formatResult, errFormat := formatDrives(ctx, directPVDrvClient, params.Body.Drives, *params.Body.Force)
if errFormat != nil {
return nil, xerrors.ErrorWithContext(ctx, errFormat)
}
return formatResult, nil
}

View File

@@ -0,0 +1,73 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package operatorapi
import (
"context"
"github.com/minio/directpv/pkg/apis/direct.csi.min.io/v1beta4"
directPVClient "github.com/minio/directpv/pkg/client"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// DirectPVDrivesClientI interface with all functions to be implemented
// by mock when testing, it should include all DirectPVDrivesClientI respective api calls
// that are used within this project.
type DirectPVDrivesClientI interface {
List(ctx context.Context, opts metav1.ListOptions) (*v1beta4.DirectCSIDriveList, error)
Update(ctx context.Context, driveItem *v1beta4.DirectCSIDrive, opts metav1.UpdateOptions) (*v1beta4.DirectCSIDriveList, error)
}
// Interface implementation
//
// Define the structure of directpv drive client and define the functions that are actually used
// from the minio operator / directpv interface.
type directPVDrivesClient struct {
client *directPVClient.DirectCSIDriveInterface
}
// List implements the listing for DirectPV Drives List functionality
func (dpd *directPVDrivesClient) List(ctx context.Context, opts metav1.ListOptions) (*v1beta4.DirectCSIDriveList, error) {
return dpd.List(ctx, opts)
}
// Update implements the listing for DirectPV Drives Update functionality
func (dpd *directPVDrivesClient) Update(ctx context.Context, driveItem *v1beta4.DirectCSIDrive, opts metav1.UpdateOptions) (*v1beta4.DirectCSIDriveList, error) {
return dpd.Update(ctx, driveItem, opts)
}
// DirectPVVolumesClientI interface with all functions to be implemented
// by mock when testing, it should include all DirectPVVolumesClientI respective api calls
// that are used within this project.
type DirectPVVolumesClientI interface {
List(ctx context.Context, opts metav1.ListOptions) (*v1beta4.DirectCSIVolumeList, error)
}
// Interface implementation
//
// Define the structure of directpv volumes client and define the functions that are actually used
// from the minio operator / directpv interface.
type directPVVolumesClient struct {
client *directPVClient.DirectCSIVolumeInterface
}
// List implements the listing for DirectPV Volumes List functionality
func (dpv *directPVVolumesClient) List(ctx context.Context, opts metav1.ListOptions) (*v1beta4.DirectCSIVolumeList, error) {
return dpv.List(ctx, opts)
}

View File

@@ -0,0 +1,410 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package operatorapi
import (
"context"
"errors"
"testing"
"github.com/minio/directpv/pkg/apis/direct.csi.min.io/v1beta4"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
var (
dpdClientListMock func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error)
dpdClientUpdateMock func(ctx context.Context, driveItem *v1beta4.DirectCSIDrive, opts v1.UpdateOptions) (*v1beta4.DirectCSIDriveList, error)
)
// mock function for drives List()
func (dpdm directPVDriveMock) List(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error) {
return dpdClientListMock(ctx, opts)
}
func (dpdm directPVDriveMock) Update(ctx context.Context, driveItem *v1beta4.DirectCSIDrive, opts v1.UpdateOptions) (*v1beta4.DirectCSIDriveList, error) {
return dpdClientUpdateMock(ctx, driveItem, opts)
}
var dpvClientListMock func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIVolumeList, error)
// mock function for volumes List()
func (dpvm directPVVolumeMock) List(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIVolumeList, error) {
return dpvClientListMock(ctx, opts)
}
// DirectPVDrivesList
func Test_GetDirectPVDrives(t *testing.T) {
directPVDrvMock := directPVDriveMock{}
type args struct {
ctx context.Context
opts v1.ListOptions
}
tests := []struct {
name string
args args
client DirectPVDrivesClientI
mockListDrives func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error)
wantErr bool
}{
{
name: "Can List Drives correctly",
args: args{
ctx: context.Background(),
opts: v1.ListOptions{},
},
client: directPVDrvMock,
mockListDrives: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error) {
items := []v1beta4.DirectCSIDrive{}
returnList := v1beta4.DirectCSIDriveList{
Items: items,
}
return &returnList, nil
},
wantErr: false,
},
{
name: "Drives request from DirectPV failed",
args: args{
ctx: context.Background(),
},
client: directPVDrvMock,
mockListDrives: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error) {
return nil, errors.New("some error occurred")
},
wantErr: true,
},
{
name: "Drives request from DirectPV has information and doesn't return errors",
args: args{
ctx: context.Background(),
},
client: directPVDrvMock,
mockListDrives: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error) {
items := []v1beta4.DirectCSIDrive{
{
Status: v1beta4.DirectCSIDriveStatus{
Path: "/var/lib/direct-csi/devices/test-part-dev0-directcsi",
AllocatedCapacity: 0,
FreeCapacity: 4772382377372,
RootPartition: "/",
PartitionNum: 0,
Filesystem: "nfs",
Mountpoint: "",
NodeName: "test-dev0-directcsi",
DriveStatus: v1beta4.DriveStatusReady,
ModelNumber: "testModel",
SerialNumber: "testSN",
TotalCapacity: 4772382377372,
PhysicalBlockSize: 1024,
LogicalBlockSize: 1024,
AccessTier: "",
FilesystemUUID: "",
PartitionUUID: "",
MajorNumber: 0,
MinorNumber: 0,
UeventSerial: "",
UeventFSUUID: "",
WWID: "",
Vendor: "",
DMName: "",
DMUUID: "",
MDUUID: "",
PartTableUUID: "",
PartTableType: "",
Virtual: false,
ReadOnly: false,
Partitioned: false,
SwapOn: false,
Master: "",
OtherMountsInfo: nil,
PCIPath: "",
SerialNumberLong: "",
Conditions: []v1.Condition{{
Type: "",
Status: "",
ObservedGeneration: 0,
LastTransitionTime: v1.Time{},
Reason: "",
Message: "",
}},
},
},
{
Status: v1beta4.DirectCSIDriveStatus{
Path: "/var/lib/direct-csi/devices/test-part-dev1-directcsi",
AllocatedCapacity: 0,
FreeCapacity: 4772382377372,
RootPartition: "/",
PartitionNum: 0,
Filesystem: "nfs",
Mountpoint: "",
NodeName: "test-dev1-directcsi",
DriveStatus: v1beta4.DriveStatus(v1beta4.DirectCSIDriveConditionOwned),
ModelNumber: "testModel",
SerialNumber: "testSN2",
TotalCapacity: 4772382377372,
PhysicalBlockSize: 1024,
LogicalBlockSize: 1024,
AccessTier: "",
FilesystemUUID: "",
PartitionUUID: "",
MajorNumber: 0,
MinorNumber: 0,
UeventSerial: "",
UeventFSUUID: "",
WWID: "",
Vendor: "",
DMName: "",
DMUUID: "",
MDUUID: "",
PartTableUUID: "",
PartTableType: "",
Virtual: false,
ReadOnly: false,
Partitioned: false,
SwapOn: false,
Master: "",
OtherMountsInfo: nil,
PCIPath: "",
SerialNumberLong: "",
Conditions: nil,
},
},
}
returnList := v1beta4.DirectCSIDriveList{
Items: items,
}
return &returnList, nil
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
dpdClientListMock = tt.mockListDrives
_, err := getDirectPVDriveList(tt.args.ctx, tt.client)
if (err != nil) != tt.wantErr {
t.Errorf("getNamespaceCreated() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
// DirectPVVolumesList
func Test_GetDirectPVVolumes(t *testing.T) {
directPVVolMock := directPVVolumeMock{}
type args struct {
ctx context.Context
opts v1.ListOptions
}
tests := []struct {
name string
args args
volumesClient DirectPVVolumesClientI
mockListVolumes func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIVolumeList, error)
wantErr bool
}{
{
name: "Can List Volumes correctly",
args: args{
ctx: context.Background(),
opts: v1.ListOptions{},
},
volumesClient: directPVVolMock,
mockListVolumes: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIVolumeList, error) {
items := []v1beta4.DirectCSIVolume{}
returnList := v1beta4.DirectCSIVolumeList{
Items: items,
}
return &returnList, nil
},
wantErr: false,
},
{
name: "Drives request from DirectPV is ok but volumes request failed",
args: args{
ctx: context.Background(),
},
volumesClient: directPVVolMock,
mockListVolumes: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIVolumeList, error) {
return nil, errors.New("some error occurred")
},
wantErr: true,
},
{
name: "Can List Volumes & Drives correctly without any issue",
args: args{
ctx: context.Background(),
opts: v1.ListOptions{},
},
volumesClient: directPVVolMock,
mockListVolumes: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIVolumeList, error) {
items := []v1beta4.DirectCSIVolume{{
Status: v1beta4.DirectCSIVolumeStatus{
Drive: "/var/lib/direct-csi/devices/test-part-dev1-directcsi",
NodeName: "testNodeName",
HostPath: "",
StagingPath: "",
ContainerPath: "",
TotalCapacity: 4772382377372,
AvailableCapacity: 4772382377372,
UsedCapacity: 0,
Conditions: nil,
},
}}
returnList := v1beta4.DirectCSIVolumeList{
Items: items,
}
return &returnList, nil
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
dpvClientListMock = tt.mockListVolumes
_, err := getDirectPVVolumesList(tt.args.ctx, tt.volumesClient)
if (err != nil) != tt.wantErr {
t.Errorf("getNamespaceCreated() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
// FormatDrives
func Test_GetDirectPVFormatDrives(t *testing.T) {
directPVDrvMock := directPVDriveMock{}
type args struct {
ctx context.Context
opts v1.ListOptions
}
tests := []struct {
name string
args args
drivesClient DirectPVDrivesClientI
mockListDrives func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error)
drives []string
force bool
wantErr bool
}{
{
name: "Format doesn't crash on empty list & returns error",
args: args{
ctx: context.Background(),
opts: v1.ListOptions{},
},
drivesClient: directPVDrvMock,
mockListDrives: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error) {
items := []v1beta4.DirectCSIDrive{}
returnList := v1beta4.DirectCSIDriveList{
Items: items,
}
return &returnList, nil
},
drives: []string{},
force: false,
wantErr: true,
},
{
name: "Can Format Selected drives",
args: args{
ctx: context.Background(),
opts: v1.ListOptions{},
},
drivesClient: directPVDrvMock,
mockListDrives: func(ctx context.Context, opts v1.ListOptions) (*v1beta4.DirectCSIDriveList, error) {
items := []v1beta4.DirectCSIDrive{
{
Status: v1beta4.DirectCSIDriveStatus{
Path: "/var/lib/direct-csi/devices/test-part-dev1-directcsi",
AllocatedCapacity: 0,
FreeCapacity: 4772382377372,
RootPartition: "/",
PartitionNum: 0,
Filesystem: "nfs",
Mountpoint: "",
NodeName: "test-dev1-directcsi",
DriveStatus: v1beta4.DriveStatusAvailable,
ModelNumber: "testModel",
SerialNumber: "testSN2",
TotalCapacity: 4772382377372,
PhysicalBlockSize: 1024,
LogicalBlockSize: 1024,
AccessTier: "",
FilesystemUUID: "",
PartitionUUID: "",
MajorNumber: 0,
MinorNumber: 0,
UeventSerial: "",
UeventFSUUID: "",
WWID: "",
Vendor: "",
DMName: "",
DMUUID: "",
MDUUID: "",
PartTableUUID: "",
PartTableType: "",
Virtual: false,
ReadOnly: false,
Partitioned: false,
SwapOn: false,
Master: "",
OtherMountsInfo: nil,
PCIPath: "",
SerialNumberLong: "",
Conditions: nil,
},
},
}
returnList := v1beta4.DirectCSIDriveList{
Items: items,
}
return &returnList, nil
},
drives: []string{"test-dev1-directcsi:/dev/testdev1-directcsi"},
force: false,
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
dpdClientListMock = tt.mockListDrives
_, err := formatDrives(tt.args.ctx, tt.drivesClient, tt.drives, tt.force)
if (err != nil) != tt.wantErr {
t.Errorf("getNamespaceCreated() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -118,6 +118,7 @@ func getLoginDetailsResponse(params authApi.LoginDetailParams) (*models.LoginDet
loginDetails := &models.LoginDetails{
LoginStrategy: loginStrategy,
Redirect: redirectURL,
IsDirectPV: getDirectPVEnabled(),
}
return loginDetails, nil
}

View File

@@ -1,5 +1,5 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
@@ -19,14 +19,21 @@ package operatorapi
import (
"context"
"fmt"
"io"
"net/http"
"os"
"strings"
"time"
"github.com/go-openapi/runtime/middleware"
"github.com/golang-jwt/jwt/v4"
"github.com/minio/console/cluster"
"github.com/minio/console/models"
"github.com/minio/console/operatorapi/operations"
"github.com/minio/console/operatorapi/operations/operator_api"
"github.com/minio/console/pkg"
errors "github.com/minio/console/restapi"
"github.com/minio/pkg/env"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@@ -34,7 +41,11 @@ import (
var (
mpConfigMapDefault = "mp-config"
mpConfigMapKey = "MP_CONFIG_KEY"
mpEmail = "email"
mpHostEnvVar = "MP_HOST"
defaultMPHost = "https://marketplace.apps.min.dev"
mpEUHostEnvVar = "MP_EU_HOST"
defaultEUMPHost = "https://marketplace-eu.apps.min.dev"
isMPEmailSet = "isEmailSet"
emailNotSetMsg = "Email was not sent in request"
)
@@ -56,62 +67,112 @@ func registerMarketplaceHandlers(api *operations.OperatorAPI) {
})
}
func getMPIntegrationResponse(session *models.Principal, params operator_api.GetMPIntegrationParams) (*models.MpIntegration, *models.Error) {
if true { // This block will be removed once service to register emails is deployed
return nil, &models.Error{Code: 501}
}
func getMPIntegrationResponse(session *models.Principal, params operator_api.GetMPIntegrationParams) (*operator_api.GetMPIntegrationOKBody, *models.Error) {
clientSet, err := cluster.K8sClient(session.STSSessionToken)
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
if err != nil {
return nil, errors.ErrorWithContext(ctx, err)
}
mpEmail, err := getMPEmail(ctx, &k8sClient{client: clientSet})
isMPEmailSet, err := getMPEmail(ctx, &k8sClient{client: clientSet})
if err != nil {
return nil, errors.ErrorWithContext(ctx, errors.ErrNotFound)
}
return &models.MpIntegration{
Email: mpEmail,
return &operator_api.GetMPIntegrationOKBody{
IsEmailSet: isMPEmailSet,
}, nil
}
func getMPEmail(ctx context.Context, clientSet K8sClientI) (string, error) {
func getMPEmail(ctx context.Context, clientSet K8sClientI) (bool, error) {
cm, err := clientSet.getConfigMap(ctx, "default", getMPConfigMapKey(mpConfigMapKey), metav1.GetOptions{})
if err != nil {
return "", err
return false, err
}
return cm.Data[mpEmail], nil
return cm.Data[isMPEmailSet] == "true", nil
}
func postMPIntegrationResponse(session *models.Principal, params operator_api.PostMPIntegrationParams) *models.Error {
if true { // This block will be removed once service to register emails is deployed
return &models.Error{Code: 501}
}
clientSet, err := cluster.K8sClient(session.STSSessionToken)
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
if err != nil {
return errors.ErrorWithContext(ctx, err)
}
return setMPIntegration(ctx, params.Body.Email, &k8sClient{client: clientSet})
return setMPIntegration(ctx, params.Body.Email, params.Body.IsInEU, &k8sClient{client: clientSet})
}
func setMPIntegration(ctx context.Context, email string, clientSet K8sClientI) *models.Error {
func setMPIntegration(ctx context.Context, email string, isInEU bool, clientSet K8sClientI) *models.Error {
if email == "" {
return errors.ErrorWithContext(ctx, errors.ErrBadRequest, fmt.Errorf(emailNotSetMsg))
}
if _, err := setMPEmail(ctx, email, clientSet); err != nil {
if _, err := setMPEmail(ctx, email, isInEU, clientSet); err != nil {
return errors.ErrorWithContext(ctx, err)
}
return nil
}
func setMPEmail(ctx context.Context, email string, clientSet K8sClientI) (*corev1.ConfigMap, error) {
cm := createCM(email)
func setMPEmail(ctx context.Context, email string, isInEU bool, clientSet K8sClientI) (*corev1.ConfigMap, error) {
if err := postEmailToMP(email, isInEU); err != nil {
return nil, err
}
cm := createCM()
return clientSet.createConfigMap(ctx, "default", cm, metav1.CreateOptions{})
}
func createCM(email string) *corev1.ConfigMap {
func postEmailToMP(email string, isInEU bool) error {
mpURL, err := getMPURL(isInEU)
if err != nil {
return err
}
return makePostRequestToMP(mpURL, email)
}
func getMPURL(isInEU bool) (string, error) {
mpHost := getMPHost(isInEU)
if mpHost == "" {
return "", fmt.Errorf("mp host not set")
}
return fmt.Sprintf("%s/mp-email", mpHost), nil
}
func getMPHost(isInEU bool) string {
if isInEU {
return env.Get(mpEUHostEnvVar, defaultEUMPHost)
}
return env.Get(mpHostEnvVar, defaultMPHost)
}
func makePostRequestToMP(url, email string) error {
request, err := createMPRequest(url, email)
if err != nil {
return err
}
client := &http.Client{Timeout: 3 * time.Second}
if res, err := client.Do(request); err != nil {
return err
} else if res.StatusCode >= http.StatusBadRequest {
b, _ := io.ReadAll(res.Body)
return fmt.Errorf("request to %s failed with status code %d and error %s", url, res.StatusCode, string(b))
}
return nil
}
func createMPRequest(url, email string) (*http.Request, error) {
request, err := http.NewRequest("POST", url, strings.NewReader(fmt.Sprintf("{\"email\":\"%s\"}", email)))
if err != nil {
return nil, err
}
jwtToken := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{})
jwtTokenString, err := jwtToken.SignedString([]byte(pkg.MPSecret))
if err != nil {
return nil, err
}
request.Header.Add("Cookie", fmt.Sprintf("jwtToken=%s", jwtTokenString))
request.Header.Add("Content-Type", "application/json")
return request, nil
}
func createCM() *corev1.ConfigMap {
return &corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
Kind: "ConfigMap",
@@ -121,7 +182,7 @@ func createCM(email string) *corev1.ConfigMap {
Name: getMPConfigMapKey(mpConfigMapKey),
Namespace: "default",
},
Data: map[string]string{mpEmail: email},
Data: map[string]string{isMPEmailSet: "true"},
}
}

View File

@@ -19,7 +19,9 @@ package operatorapi
import (
"context"
"errors"
"fmt"
"net/http"
"net/http/httptest"
"os"
"testing"
@@ -34,6 +36,7 @@ import (
var (
testWithError = false
testServerWithError = false
errMock = errors.New("mock error")
k8sClientGetConfigMapMock func(ctx context.Context, namespace, configMap string, opts metav1.GetOptions) (*corev1.ConfigMap, error)
k8sClientCreateConfigMapMock func(ctx context.Context, namespace string, cm *corev1.ConfigMap, opts metav1.CreateOptions) (*corev1.ConfigMap, error)
@@ -43,9 +46,10 @@ var (
type MarketplaceTestSuite struct {
suite.Suite
assert *assert.Assertions
kClient k8sClientMock
namespace string
assert *assert.Assertions
kClient k8sClientMock
namespace string
postServer *httptest.Server
}
func (c k8sClientMock) getConfigMap(ctx context.Context, namespace, configMap string, opts metav1.GetOptions) (*corev1.ConfigMap, error) {
@@ -72,6 +76,17 @@ func (suite *MarketplaceTestSuite) SetupSuite() {
k8sClientUpdateConfigMapMock = suite.updateConfigMapMock
k8sClientDeleteConfigMapMock = suite.deleteConfigMapMock
os.Setenv(mpConfigMapKey, "mp-mock-config")
suite.postServer = httptest.NewServer(http.HandlerFunc(suite.postHandler))
}
func (suite *MarketplaceTestSuite) postHandler(
w http.ResponseWriter, r *http.Request,
) {
if testServerWithError {
w.WriteHeader(400)
} else {
fmt.Fprintf(w, `{"post": "Post response"}`)
}
}
func (suite *MarketplaceTestSuite) TearDownSuite() {
@@ -82,7 +97,7 @@ func (suite *MarketplaceTestSuite) getConfigMapMock(ctx context.Context, namespa
if testWithError {
return nil, errMock
}
return &corev1.ConfigMap{Data: map[string]string{mpEmail: "mock@mock.com"}}, nil
return &corev1.ConfigMap{Data: map[string]string{isMPEmailSet: "true"}}, nil
}
func (suite *MarketplaceTestSuite) createConfigMapMock(ctx context.Context, namespace string, cm *corev1.ConfigMap, opts metav1.CreateOptions) (*corev1.ConfigMap, error) {
@@ -115,11 +130,6 @@ func (suite *MarketplaceTestSuite) TestRegisterMarketplaceHandlers() {
suite.assert.NotNil(api.OperatorAPIPostMPIntegrationHandler)
}
// TODO
// WIP - Complete successful tests to RUD handlers
// WIP - Add tests to POST handler
// WIP - Check how to mock k8s objects for tests with no error
func (suite *MarketplaceTestSuite) TestGetMPIntegrationHandlerWithError() {
api := &operations.OperatorAPI{}
registerMarketplaceHandlers(api)
@@ -130,6 +140,19 @@ func (suite *MarketplaceTestSuite) TestGetMPIntegrationHandlerWithError() {
suite.assert.True(ok)
}
func (suite *MarketplaceTestSuite) TestPostMPIntegrationHandlerWithError() {
api := &operations.OperatorAPI{}
registerMarketplaceHandlers(api)
params := operator_api.NewPostMPIntegrationParams()
params.Body = &models.MpIntegration{Email: ""}
params.HTTPRequest = &http.Request{}
params.HTTPRequest.Header = map[string][]string{}
params.HTTPRequest.AddCookie(&http.Cookie{Value: "token", Name: "token"})
response := api.OperatorAPIPostMPIntegrationHandler.Handle(params, &models.Principal{})
_, ok := response.(*operator_api.PostMPIntegrationDefault)
suite.assert.True(ok)
}
func (suite *MarketplaceTestSuite) TestGetMPEmailWithError() {
testWithError = true
ctx, cancel := context.WithCancel(context.Background())
@@ -143,15 +166,15 @@ func (suite *MarketplaceTestSuite) TestGetMPEmailNoError() {
testWithError = false
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
email, err := getMPEmail(ctx, &suite.kClient)
isSet, err := getMPEmail(ctx, &suite.kClient)
suite.assert.Nil(err)
suite.assert.NotEmpty(email)
suite.assert.True(isSet)
}
func (suite *MarketplaceTestSuite) TestSetMPIntegrationNoEmail() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := setMPIntegration(ctx, "", &suite.kClient)
err := setMPIntegration(ctx, "", false, &suite.kClient)
suite.assert.NotNil(err)
}
@@ -159,16 +182,31 @@ func (suite *MarketplaceTestSuite) TestSetMPIntegrationWithError() {
testWithError = true
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := setMPIntegration(ctx, "mock@mock.com", &suite.kClient)
os.Setenv(mpHostEnvVar, " ")
err := setMPIntegration(ctx, "mock@mock.com", false, &suite.kClient)
suite.assert.NotNil(err)
os.Unsetenv(mpHostEnvVar)
}
func (suite *MarketplaceTestSuite) TestSetMPIntegrationNoError() {
testWithError = false
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err := setMPIntegration(ctx, "mock@mock.com", &suite.kClient)
os.Setenv(mpHostEnvVar, suite.postServer.URL)
err := setMPIntegration(ctx, "mock@mock.com", false, &suite.kClient)
suite.assert.Nil(err)
os.Unsetenv(mpHostEnvVar)
}
func (suite *MarketplaceTestSuite) TestSetMPIntegrationWithRequestError() {
testWithError = false
testServerWithError = true
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
os.Setenv(mpHostEnvVar, suite.postServer.URL)
err := setMPIntegration(ctx, "mock@mock.com", false, &suite.kClient)
suite.assert.NotNil(err)
os.Unsetenv(mpHostEnvVar)
}
func TestMarketplace(t *testing.T) {

View File

@@ -22,8 +22,10 @@ import (
)
type (
opClientMock struct{}
httpClientMock struct{}
opClientMock struct{}
httpClientMock struct{}
directPVDriveMock struct{}
directPVVolumeMock struct{}
)
func createMockPVC(pvcMockName, pvcMockNamespace string) *v1.PersistentVolumeClaim {

View File

@@ -85,6 +85,9 @@ func NewOperatorAPI(spec *loads.Document) *OperatorAPI {
OperatorAPIDescribePodHandler: operator_api.DescribePodHandlerFunc(func(params operator_api.DescribePodParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.DescribePod has not yet been implemented")
}),
OperatorAPIDirectPVFormatDriveHandler: operator_api.DirectPVFormatDriveHandlerFunc(func(params operator_api.DirectPVFormatDriveParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.DirectPVFormatDrive has not yet been implemented")
}),
OperatorAPIDisableTenantLoggingHandler: operator_api.DisableTenantLoggingHandlerFunc(func(params operator_api.DisableTenantLoggingParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.DisableTenantLogging has not yet been implemented")
}),
@@ -94,6 +97,12 @@ func NewOperatorAPI(spec *loads.Document) *OperatorAPI {
OperatorAPIGetAllocatableResourcesHandler: operator_api.GetAllocatableResourcesHandlerFunc(func(params operator_api.GetAllocatableResourcesParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.GetAllocatableResources has not yet been implemented")
}),
OperatorAPIGetDirectPVDriveListHandler: operator_api.GetDirectPVDriveListHandlerFunc(func(params operator_api.GetDirectPVDriveListParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.GetDirectPVDriveList has not yet been implemented")
}),
OperatorAPIGetDirectPVVolumeListHandler: operator_api.GetDirectPVVolumeListHandlerFunc(func(params operator_api.GetDirectPVVolumeListParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.GetDirectPVVolumeList has not yet been implemented")
}),
OperatorAPIGetMPIntegrationHandler: operator_api.GetMPIntegrationHandlerFunc(func(params operator_api.GetMPIntegrationParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.GetMPIntegration has not yet been implemented")
}),
@@ -166,6 +175,21 @@ func NewOperatorAPI(spec *loads.Document) *OperatorAPI {
AuthLogoutHandler: auth.LogoutHandlerFunc(func(params auth.LogoutParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation auth.Logout has not yet been implemented")
}),
OperatorAPIOperatorSubnetAPIKeyInfoHandler: operator_api.OperatorSubnetAPIKeyInfoHandlerFunc(func(params operator_api.OperatorSubnetAPIKeyInfoParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.OperatorSubnetAPIKeyInfo has not yet been implemented")
}),
OperatorAPIOperatorSubnetAPIKeyHandler: operator_api.OperatorSubnetAPIKeyHandlerFunc(func(params operator_api.OperatorSubnetAPIKeyParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.OperatorSubnetAPIKey has not yet been implemented")
}),
OperatorAPIOperatorSubnetLoginHandler: operator_api.OperatorSubnetLoginHandlerFunc(func(params operator_api.OperatorSubnetLoginParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.OperatorSubnetLogin has not yet been implemented")
}),
OperatorAPIOperatorSubnetLoginMFAHandler: operator_api.OperatorSubnetLoginMFAHandlerFunc(func(params operator_api.OperatorSubnetLoginMFAParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.OperatorSubnetLoginMFA has not yet been implemented")
}),
OperatorAPIOperatorSubnetRegisterAPIKeyHandler: operator_api.OperatorSubnetRegisterAPIKeyHandlerFunc(func(params operator_api.OperatorSubnetRegisterAPIKeyParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.OperatorSubnetRegisterAPIKey has not yet been implemented")
}),
OperatorAPIPostMPIntegrationHandler: operator_api.PostMPIntegrationHandlerFunc(func(params operator_api.PostMPIntegrationParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.PostMPIntegration has not yet been implemented")
}),
@@ -175,6 +199,9 @@ func NewOperatorAPI(spec *loads.Document) *OperatorAPI {
AuthSessionCheckHandler: auth.SessionCheckHandlerFunc(func(params auth.SessionCheckParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation auth.SessionCheck has not yet been implemented")
}),
OperatorAPISetTenantAdministratorsHandler: operator_api.SetTenantAdministratorsHandlerFunc(func(params operator_api.SetTenantAdministratorsParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.SetTenantAdministrators has not yet been implemented")
}),
OperatorAPISetTenantLogsHandler: operator_api.SetTenantLogsHandlerFunc(func(params operator_api.SetTenantLogsParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation operator_api.SetTenantLogs has not yet been implemented")
}),
@@ -295,12 +322,18 @@ type OperatorAPI struct {
OperatorAPIDeleteTenantHandler operator_api.DeleteTenantHandler
// OperatorAPIDescribePodHandler sets the operation handler for the describe pod operation
OperatorAPIDescribePodHandler operator_api.DescribePodHandler
// OperatorAPIDirectPVFormatDriveHandler sets the operation handler for the direct p v format drive operation
OperatorAPIDirectPVFormatDriveHandler operator_api.DirectPVFormatDriveHandler
// OperatorAPIDisableTenantLoggingHandler sets the operation handler for the disable tenant logging operation
OperatorAPIDisableTenantLoggingHandler operator_api.DisableTenantLoggingHandler
// OperatorAPIEnableTenantLoggingHandler sets the operation handler for the enable tenant logging operation
OperatorAPIEnableTenantLoggingHandler operator_api.EnableTenantLoggingHandler
// OperatorAPIGetAllocatableResourcesHandler sets the operation handler for the get allocatable resources operation
OperatorAPIGetAllocatableResourcesHandler operator_api.GetAllocatableResourcesHandler
// OperatorAPIGetDirectPVDriveListHandler sets the operation handler for the get direct p v drive list operation
OperatorAPIGetDirectPVDriveListHandler operator_api.GetDirectPVDriveListHandler
// OperatorAPIGetDirectPVVolumeListHandler sets the operation handler for the get direct p v volume list operation
OperatorAPIGetDirectPVVolumeListHandler operator_api.GetDirectPVVolumeListHandler
// OperatorAPIGetMPIntegrationHandler sets the operation handler for the get m p integration operation
OperatorAPIGetMPIntegrationHandler operator_api.GetMPIntegrationHandler
// OperatorAPIGetMaxAllocatableMemHandler sets the operation handler for the get max allocatable mem operation
@@ -349,12 +382,24 @@ type OperatorAPI struct {
AuthLoginOperatorHandler auth.LoginOperatorHandler
// AuthLogoutHandler sets the operation handler for the logout operation
AuthLogoutHandler auth.LogoutHandler
// OperatorAPIOperatorSubnetAPIKeyInfoHandler sets the operation handler for the operator subnet API key info operation
OperatorAPIOperatorSubnetAPIKeyInfoHandler operator_api.OperatorSubnetAPIKeyInfoHandler
// OperatorAPIOperatorSubnetAPIKeyHandler sets the operation handler for the operator subnet Api key operation
OperatorAPIOperatorSubnetAPIKeyHandler operator_api.OperatorSubnetAPIKeyHandler
// OperatorAPIOperatorSubnetLoginHandler sets the operation handler for the operator subnet login operation
OperatorAPIOperatorSubnetLoginHandler operator_api.OperatorSubnetLoginHandler
// OperatorAPIOperatorSubnetLoginMFAHandler sets the operation handler for the operator subnet login m f a operation
OperatorAPIOperatorSubnetLoginMFAHandler operator_api.OperatorSubnetLoginMFAHandler
// OperatorAPIOperatorSubnetRegisterAPIKeyHandler sets the operation handler for the operator subnet register API key operation
OperatorAPIOperatorSubnetRegisterAPIKeyHandler operator_api.OperatorSubnetRegisterAPIKeyHandler
// OperatorAPIPostMPIntegrationHandler sets the operation handler for the post m p integration operation
OperatorAPIPostMPIntegrationHandler operator_api.PostMPIntegrationHandler
// OperatorAPIPutTenantYAMLHandler sets the operation handler for the put tenant y a m l operation
OperatorAPIPutTenantYAMLHandler operator_api.PutTenantYAMLHandler
// AuthSessionCheckHandler sets the operation handler for the session check operation
AuthSessionCheckHandler auth.SessionCheckHandler
// OperatorAPISetTenantAdministratorsHandler sets the operation handler for the set tenant administrators operation
OperatorAPISetTenantAdministratorsHandler operator_api.SetTenantAdministratorsHandler
// OperatorAPISetTenantLogsHandler sets the operation handler for the set tenant logs operation
OperatorAPISetTenantLogsHandler operator_api.SetTenantLogsHandler
// OperatorAPISetTenantMonitoringHandler sets the operation handler for the set tenant monitoring operation
@@ -495,6 +540,9 @@ func (o *OperatorAPI) Validate() error {
if o.OperatorAPIDescribePodHandler == nil {
unregistered = append(unregistered, "operator_api.DescribePodHandler")
}
if o.OperatorAPIDirectPVFormatDriveHandler == nil {
unregistered = append(unregistered, "operator_api.DirectPVFormatDriveHandler")
}
if o.OperatorAPIDisableTenantLoggingHandler == nil {
unregistered = append(unregistered, "operator_api.DisableTenantLoggingHandler")
}
@@ -504,6 +552,12 @@ func (o *OperatorAPI) Validate() error {
if o.OperatorAPIGetAllocatableResourcesHandler == nil {
unregistered = append(unregistered, "operator_api.GetAllocatableResourcesHandler")
}
if o.OperatorAPIGetDirectPVDriveListHandler == nil {
unregistered = append(unregistered, "operator_api.GetDirectPVDriveListHandler")
}
if o.OperatorAPIGetDirectPVVolumeListHandler == nil {
unregistered = append(unregistered, "operator_api.GetDirectPVVolumeListHandler")
}
if o.OperatorAPIGetMPIntegrationHandler == nil {
unregistered = append(unregistered, "operator_api.GetMPIntegrationHandler")
}
@@ -576,6 +630,21 @@ func (o *OperatorAPI) Validate() error {
if o.AuthLogoutHandler == nil {
unregistered = append(unregistered, "auth.LogoutHandler")
}
if o.OperatorAPIOperatorSubnetAPIKeyInfoHandler == nil {
unregistered = append(unregistered, "operator_api.OperatorSubnetAPIKeyInfoHandler")
}
if o.OperatorAPIOperatorSubnetAPIKeyHandler == nil {
unregistered = append(unregistered, "operator_api.OperatorSubnetAPIKeyHandler")
}
if o.OperatorAPIOperatorSubnetLoginHandler == nil {
unregistered = append(unregistered, "operator_api.OperatorSubnetLoginHandler")
}
if o.OperatorAPIOperatorSubnetLoginMFAHandler == nil {
unregistered = append(unregistered, "operator_api.OperatorSubnetLoginMFAHandler")
}
if o.OperatorAPIOperatorSubnetRegisterAPIKeyHandler == nil {
unregistered = append(unregistered, "operator_api.OperatorSubnetRegisterAPIKeyHandler")
}
if o.OperatorAPIPostMPIntegrationHandler == nil {
unregistered = append(unregistered, "operator_api.PostMPIntegrationHandler")
}
@@ -585,6 +654,9 @@ func (o *OperatorAPI) Validate() error {
if o.AuthSessionCheckHandler == nil {
unregistered = append(unregistered, "auth.SessionCheckHandler")
}
if o.OperatorAPISetTenantAdministratorsHandler == nil {
unregistered = append(unregistered, "operator_api.SetTenantAdministratorsHandler")
}
if o.OperatorAPISetTenantLogsHandler == nil {
unregistered = append(unregistered, "operator_api.SetTenantLogsHandler")
}
@@ -771,6 +843,10 @@ func (o *OperatorAPI) initHandlerCache() {
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/directpv/drives/format"] = operator_api.NewDirectPVFormatDrive(o.context, o.OperatorAPIDirectPVFormatDriveHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/namespaces/{namespace}/tenants/{tenant}/disable-logging"] = operator_api.NewDisableTenantLogging(o.context, o.OperatorAPIDisableTenantLoggingHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
@@ -783,6 +859,14 @@ func (o *OperatorAPI) initHandlerCache() {
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/directpv/drives"] = operator_api.NewGetDirectPVDriveList(o.context, o.OperatorAPIGetDirectPVDriveListHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/directpv/volumes"] = operator_api.NewGetDirectPVVolumeList(o.context, o.OperatorAPIGetDirectPVVolumeListHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/mp-integration"] = operator_api.NewGetMPIntegration(o.context, o.OperatorAPIGetMPIntegrationHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
@@ -876,6 +960,26 @@ func (o *OperatorAPI) initHandlerCache() {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/logout"] = auth.NewLogout(o.context, o.AuthLogoutHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/subnet/apikey/info"] = operator_api.NewOperatorSubnetAPIKeyInfo(o.context, o.OperatorAPIOperatorSubnetAPIKeyInfoHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/subnet/apikey"] = operator_api.NewOperatorSubnetAPIKey(o.context, o.OperatorAPIOperatorSubnetAPIKeyHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/subnet/login"] = operator_api.NewOperatorSubnetLogin(o.context, o.OperatorAPIOperatorSubnetLoginHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/subnet/login/mfa"] = operator_api.NewOperatorSubnetLoginMFA(o.context, o.OperatorAPIOperatorSubnetLoginMFAHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/subnet/apikey/register"] = operator_api.NewOperatorSubnetRegisterAPIKey(o.context, o.OperatorAPIOperatorSubnetRegisterAPIKeyHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
@@ -888,6 +992,10 @@ func (o *OperatorAPI) initHandlerCache() {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/session"] = auth.NewSessionCheck(o.context, o.AuthSessionCheckHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/namespaces/{namespace}/tenants/{tenant}/set-administrators"] = operator_api.NewSetTenantAdministrators(o.context, o.OperatorAPISetTenantAdministratorsHandler)
if o.handlers["PUT"] == nil {
o.handlers["PUT"] = make(map[string]http.Handler)
}

View File

@@ -0,0 +1,88 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/models"
)
// DirectPVFormatDriveHandlerFunc turns a function with the right signature into a direct p v format drive handler
type DirectPVFormatDriveHandlerFunc func(DirectPVFormatDriveParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn DirectPVFormatDriveHandlerFunc) Handle(params DirectPVFormatDriveParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// DirectPVFormatDriveHandler interface for that can handle valid direct p v format drive params
type DirectPVFormatDriveHandler interface {
Handle(DirectPVFormatDriveParams, *models.Principal) middleware.Responder
}
// NewDirectPVFormatDrive creates a new http.Handler for the direct p v format drive operation
func NewDirectPVFormatDrive(ctx *middleware.Context, handler DirectPVFormatDriveHandler) *DirectPVFormatDrive {
return &DirectPVFormatDrive{Context: ctx, Handler: handler}
}
/* DirectPVFormatDrive swagger:route POST /directpv/drives/format OperatorAPI directPVFormatDrive
Format directpv drives from a list
*/
type DirectPVFormatDrive struct {
Context *middleware.Context
Handler DirectPVFormatDriveHandler
}
func (o *DirectPVFormatDrive) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewDirectPVFormatDriveParams()
uprinc, aCtx, err := o.Context.Authorize(r, route)
if err != nil {
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
if aCtx != nil {
*r = *aCtx
}
var principal *models.Principal
if uprinc != nil {
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
}
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params, principal) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@@ -0,0 +1,102 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/validate"
"github.com/minio/console/models"
)
// NewDirectPVFormatDriveParams creates a new DirectPVFormatDriveParams object
//
// There are no default values defined in the spec.
func NewDirectPVFormatDriveParams() DirectPVFormatDriveParams {
return DirectPVFormatDriveParams{}
}
// DirectPVFormatDriveParams contains all the bound params for the direct p v format drive operation
// typically these are obtained from a http.Request
//
// swagger:parameters DirectPVFormatDrive
type DirectPVFormatDriveParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
Required: true
In: body
*/
Body *models.FormatConfiguration
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls.
//
// To ensure default values, the struct must have been initialized with NewDirectPVFormatDriveParams() beforehand.
func (o *DirectPVFormatDriveParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if runtime.HasBody(r) {
defer r.Body.Close()
var body models.FormatConfiguration
if err := route.Consumer.Consume(r.Body, &body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("body", "body", ""))
} else {
res = append(res, errors.NewParseError("body", "body", "", err))
}
} else {
// validate body object
if err := body.Validate(route.Formats); err != nil {
res = append(res, err)
}
ctx := validate.WithOperationRequest(context.Background())
if err := body.ContextValidate(ctx, route.Formats); err != nil {
res = append(res, err)
}
if len(res) == 0 {
o.Body = &body
}
}
} else {
res = append(res, errors.Required("body", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@@ -0,0 +1,133 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/runtime"
"github.com/minio/console/models"
)
// DirectPVFormatDriveOKCode is the HTTP code returned for type DirectPVFormatDriveOK
const DirectPVFormatDriveOKCode int = 200
/*DirectPVFormatDriveOK A successful response.
swagger:response directPVFormatDriveOK
*/
type DirectPVFormatDriveOK struct {
/*
In: Body
*/
Payload *models.FormatDirectPVDrivesResponse `json:"body,omitempty"`
}
// NewDirectPVFormatDriveOK creates DirectPVFormatDriveOK with default headers values
func NewDirectPVFormatDriveOK() *DirectPVFormatDriveOK {
return &DirectPVFormatDriveOK{}
}
// WithPayload adds the payload to the direct p v format drive o k response
func (o *DirectPVFormatDriveOK) WithPayload(payload *models.FormatDirectPVDrivesResponse) *DirectPVFormatDriveOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the direct p v format drive o k response
func (o *DirectPVFormatDriveOK) SetPayload(payload *models.FormatDirectPVDrivesResponse) {
o.Payload = payload
}
// WriteResponse to the client
func (o *DirectPVFormatDriveOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(200)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}
/*DirectPVFormatDriveDefault Generic error response.
swagger:response directPVFormatDriveDefault
*/
type DirectPVFormatDriveDefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
}
// NewDirectPVFormatDriveDefault creates DirectPVFormatDriveDefault with default headers values
func NewDirectPVFormatDriveDefault(code int) *DirectPVFormatDriveDefault {
if code <= 0 {
code = 500
}
return &DirectPVFormatDriveDefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the direct p v format drive default response
func (o *DirectPVFormatDriveDefault) WithStatusCode(code int) *DirectPVFormatDriveDefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the direct p v format drive default response
func (o *DirectPVFormatDriveDefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the direct p v format drive default response
func (o *DirectPVFormatDriveDefault) WithPayload(payload *models.Error) *DirectPVFormatDriveDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the direct p v format drive default response
func (o *DirectPVFormatDriveDefault) SetPayload(payload *models.Error) {
o.Payload = payload
}
// WriteResponse to the client
func (o *DirectPVFormatDriveDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(o._statusCode)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}

View File

@@ -0,0 +1,104 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
)
// DirectPVFormatDriveURL generates an URL for the direct p v format drive operation
type DirectPVFormatDriveURL struct {
_basePath string
}
// WithBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *DirectPVFormatDriveURL) WithBasePath(bp string) *DirectPVFormatDriveURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *DirectPVFormatDriveURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *DirectPVFormatDriveURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/directpv/drives/format"
_basePath := o._basePath
if _basePath == "" {
_basePath = "/api/v1"
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *DirectPVFormatDriveURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *DirectPVFormatDriveURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *DirectPVFormatDriveURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on DirectPVFormatDriveURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on DirectPVFormatDriveURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *DirectPVFormatDriveURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -0,0 +1,88 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/models"
)
// GetDirectPVDriveListHandlerFunc turns a function with the right signature into a get direct p v drive list handler
type GetDirectPVDriveListHandlerFunc func(GetDirectPVDriveListParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn GetDirectPVDriveListHandlerFunc) Handle(params GetDirectPVDriveListParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// GetDirectPVDriveListHandler interface for that can handle valid get direct p v drive list params
type GetDirectPVDriveListHandler interface {
Handle(GetDirectPVDriveListParams, *models.Principal) middleware.Responder
}
// NewGetDirectPVDriveList creates a new http.Handler for the get direct p v drive list operation
func NewGetDirectPVDriveList(ctx *middleware.Context, handler GetDirectPVDriveListHandler) *GetDirectPVDriveList {
return &GetDirectPVDriveList{Context: ctx, Handler: handler}
}
/* GetDirectPVDriveList swagger:route GET /directpv/drives OperatorAPI getDirectPVDriveList
Get directpv drives list
*/
type GetDirectPVDriveList struct {
Context *middleware.Context
Handler GetDirectPVDriveListHandler
}
func (o *GetDirectPVDriveList) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewGetDirectPVDriveListParams()
uprinc, aCtx, err := o.Context.Authorize(r, route)
if err != nil {
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
if aCtx != nil {
*r = *aCtx
}
var principal *models.Principal
if uprinc != nil {
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
}
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params, principal) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@@ -0,0 +1,121 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
)
// NewGetDirectPVDriveListParams creates a new GetDirectPVDriveListParams object
//
// There are no default values defined in the spec.
func NewGetDirectPVDriveListParams() GetDirectPVDriveListParams {
return GetDirectPVDriveListParams{}
}
// GetDirectPVDriveListParams contains all the bound params for the get direct p v drive list operation
// typically these are obtained from a http.Request
//
// swagger:parameters GetDirectPVDriveList
type GetDirectPVDriveListParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
In: query
*/
Drives *string
/*
In: query
*/
Nodes *string
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls.
//
// To ensure default values, the struct must have been initialized with NewGetDirectPVDriveListParams() beforehand.
func (o *GetDirectPVDriveListParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
qs := runtime.Values(r.URL.Query())
qDrives, qhkDrives, _ := qs.GetOK("drives")
if err := o.bindDrives(qDrives, qhkDrives, route.Formats); err != nil {
res = append(res, err)
}
qNodes, qhkNodes, _ := qs.GetOK("nodes")
if err := o.bindNodes(qNodes, qhkNodes, route.Formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// bindDrives binds and validates parameter Drives from query.
func (o *GetDirectPVDriveListParams) bindDrives(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
o.Drives = &raw
return nil
}
// bindNodes binds and validates parameter Nodes from query.
func (o *GetDirectPVDriveListParams) bindNodes(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
o.Nodes = &raw
return nil
}

View File

@@ -0,0 +1,133 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/runtime"
"github.com/minio/console/models"
)
// GetDirectPVDriveListOKCode is the HTTP code returned for type GetDirectPVDriveListOK
const GetDirectPVDriveListOKCode int = 200
/*GetDirectPVDriveListOK A successful response.
swagger:response getDirectPVDriveListOK
*/
type GetDirectPVDriveListOK struct {
/*
In: Body
*/
Payload *models.GetDirectPVDriveListResponse `json:"body,omitempty"`
}
// NewGetDirectPVDriveListOK creates GetDirectPVDriveListOK with default headers values
func NewGetDirectPVDriveListOK() *GetDirectPVDriveListOK {
return &GetDirectPVDriveListOK{}
}
// WithPayload adds the payload to the get direct p v drive list o k response
func (o *GetDirectPVDriveListOK) WithPayload(payload *models.GetDirectPVDriveListResponse) *GetDirectPVDriveListOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the get direct p v drive list o k response
func (o *GetDirectPVDriveListOK) SetPayload(payload *models.GetDirectPVDriveListResponse) {
o.Payload = payload
}
// WriteResponse to the client
func (o *GetDirectPVDriveListOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(200)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}
/*GetDirectPVDriveListDefault Generic error response.
swagger:response getDirectPVDriveListDefault
*/
type GetDirectPVDriveListDefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
}
// NewGetDirectPVDriveListDefault creates GetDirectPVDriveListDefault with default headers values
func NewGetDirectPVDriveListDefault(code int) *GetDirectPVDriveListDefault {
if code <= 0 {
code = 500
}
return &GetDirectPVDriveListDefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the get direct p v drive list default response
func (o *GetDirectPVDriveListDefault) WithStatusCode(code int) *GetDirectPVDriveListDefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the get direct p v drive list default response
func (o *GetDirectPVDriveListDefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the get direct p v drive list default response
func (o *GetDirectPVDriveListDefault) WithPayload(payload *models.Error) *GetDirectPVDriveListDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the get direct p v drive list default response
func (o *GetDirectPVDriveListDefault) SetPayload(payload *models.Error) {
o.Payload = payload
}
// WriteResponse to the client
func (o *GetDirectPVDriveListDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(o._statusCode)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}

View File

@@ -0,0 +1,129 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
)
// GetDirectPVDriveListURL generates an URL for the get direct p v drive list operation
type GetDirectPVDriveListURL struct {
Drives *string
Nodes *string
_basePath string
// avoid unkeyed usage
_ struct{}
}
// WithBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *GetDirectPVDriveListURL) WithBasePath(bp string) *GetDirectPVDriveListURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *GetDirectPVDriveListURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *GetDirectPVDriveListURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/directpv/drives"
_basePath := o._basePath
if _basePath == "" {
_basePath = "/api/v1"
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
qs := make(url.Values)
var drivesQ string
if o.Drives != nil {
drivesQ = *o.Drives
}
if drivesQ != "" {
qs.Set("drives", drivesQ)
}
var nodesQ string
if o.Nodes != nil {
nodesQ = *o.Nodes
}
if nodesQ != "" {
qs.Set("nodes", nodesQ)
}
_result.RawQuery = qs.Encode()
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *GetDirectPVDriveListURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *GetDirectPVDriveListURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *GetDirectPVDriveListURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on GetDirectPVDriveListURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on GetDirectPVDriveListURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *GetDirectPVDriveListURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -0,0 +1,88 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/models"
)
// GetDirectPVVolumeListHandlerFunc turns a function with the right signature into a get direct p v volume list handler
type GetDirectPVVolumeListHandlerFunc func(GetDirectPVVolumeListParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn GetDirectPVVolumeListHandlerFunc) Handle(params GetDirectPVVolumeListParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// GetDirectPVVolumeListHandler interface for that can handle valid get direct p v volume list params
type GetDirectPVVolumeListHandler interface {
Handle(GetDirectPVVolumeListParams, *models.Principal) middleware.Responder
}
// NewGetDirectPVVolumeList creates a new http.Handler for the get direct p v volume list operation
func NewGetDirectPVVolumeList(ctx *middleware.Context, handler GetDirectPVVolumeListHandler) *GetDirectPVVolumeList {
return &GetDirectPVVolumeList{Context: ctx, Handler: handler}
}
/* GetDirectPVVolumeList swagger:route GET /directpv/volumes OperatorAPI getDirectPVVolumeList
Get directpv volumes list
*/
type GetDirectPVVolumeList struct {
Context *middleware.Context
Handler GetDirectPVVolumeListHandler
}
func (o *GetDirectPVVolumeList) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewGetDirectPVVolumeListParams()
uprinc, aCtx, err := o.Context.Authorize(r, route)
if err != nil {
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
if aCtx != nil {
*r = *aCtx
}
var principal *models.Principal
if uprinc != nil {
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
}
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params, principal) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@@ -0,0 +1,121 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
)
// NewGetDirectPVVolumeListParams creates a new GetDirectPVVolumeListParams object
//
// There are no default values defined in the spec.
func NewGetDirectPVVolumeListParams() GetDirectPVVolumeListParams {
return GetDirectPVVolumeListParams{}
}
// GetDirectPVVolumeListParams contains all the bound params for the get direct p v volume list operation
// typically these are obtained from a http.Request
//
// swagger:parameters GetDirectPVVolumeList
type GetDirectPVVolumeListParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
In: query
*/
Drives *string
/*
In: query
*/
Nodes *string
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls.
//
// To ensure default values, the struct must have been initialized with NewGetDirectPVVolumeListParams() beforehand.
func (o *GetDirectPVVolumeListParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
qs := runtime.Values(r.URL.Query())
qDrives, qhkDrives, _ := qs.GetOK("drives")
if err := o.bindDrives(qDrives, qhkDrives, route.Formats); err != nil {
res = append(res, err)
}
qNodes, qhkNodes, _ := qs.GetOK("nodes")
if err := o.bindNodes(qNodes, qhkNodes, route.Formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// bindDrives binds and validates parameter Drives from query.
func (o *GetDirectPVVolumeListParams) bindDrives(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
o.Drives = &raw
return nil
}
// bindNodes binds and validates parameter Nodes from query.
func (o *GetDirectPVVolumeListParams) bindNodes(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: false
// AllowEmptyValue: false
if raw == "" { // empty values pass all other validations
return nil
}
o.Nodes = &raw
return nil
}

View File

@@ -0,0 +1,133 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/runtime"
"github.com/minio/console/models"
)
// GetDirectPVVolumeListOKCode is the HTTP code returned for type GetDirectPVVolumeListOK
const GetDirectPVVolumeListOKCode int = 200
/*GetDirectPVVolumeListOK A successful response.
swagger:response getDirectPVVolumeListOK
*/
type GetDirectPVVolumeListOK struct {
/*
In: Body
*/
Payload *models.GetDirectPVVolumeListResponse `json:"body,omitempty"`
}
// NewGetDirectPVVolumeListOK creates GetDirectPVVolumeListOK with default headers values
func NewGetDirectPVVolumeListOK() *GetDirectPVVolumeListOK {
return &GetDirectPVVolumeListOK{}
}
// WithPayload adds the payload to the get direct p v volume list o k response
func (o *GetDirectPVVolumeListOK) WithPayload(payload *models.GetDirectPVVolumeListResponse) *GetDirectPVVolumeListOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the get direct p v volume list o k response
func (o *GetDirectPVVolumeListOK) SetPayload(payload *models.GetDirectPVVolumeListResponse) {
o.Payload = payload
}
// WriteResponse to the client
func (o *GetDirectPVVolumeListOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(200)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}
/*GetDirectPVVolumeListDefault Generic error response.
swagger:response getDirectPVVolumeListDefault
*/
type GetDirectPVVolumeListDefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
}
// NewGetDirectPVVolumeListDefault creates GetDirectPVVolumeListDefault with default headers values
func NewGetDirectPVVolumeListDefault(code int) *GetDirectPVVolumeListDefault {
if code <= 0 {
code = 500
}
return &GetDirectPVVolumeListDefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the get direct p v volume list default response
func (o *GetDirectPVVolumeListDefault) WithStatusCode(code int) *GetDirectPVVolumeListDefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the get direct p v volume list default response
func (o *GetDirectPVVolumeListDefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the get direct p v volume list default response
func (o *GetDirectPVVolumeListDefault) WithPayload(payload *models.Error) *GetDirectPVVolumeListDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the get direct p v volume list default response
func (o *GetDirectPVVolumeListDefault) SetPayload(payload *models.Error) {
o.Payload = payload
}
// WriteResponse to the client
func (o *GetDirectPVVolumeListDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(o._statusCode)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}

View File

@@ -0,0 +1,129 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
)
// GetDirectPVVolumeListURL generates an URL for the get direct p v volume list operation
type GetDirectPVVolumeListURL struct {
Drives *string
Nodes *string
_basePath string
// avoid unkeyed usage
_ struct{}
}
// WithBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *GetDirectPVVolumeListURL) WithBasePath(bp string) *GetDirectPVVolumeListURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *GetDirectPVVolumeListURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *GetDirectPVVolumeListURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/directpv/volumes"
_basePath := o._basePath
if _basePath == "" {
_basePath = "/api/v1"
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
qs := make(url.Values)
var drivesQ string
if o.Drives != nil {
drivesQ = *o.Drives
}
if drivesQ != "" {
qs.Set("drives", drivesQ)
}
var nodesQ string
if o.Nodes != nil {
nodesQ = *o.Nodes
}
if nodesQ != "" {
qs.Set("nodes", nodesQ)
}
_result.RawQuery = qs.Encode()
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *GetDirectPVVolumeListURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *GetDirectPVVolumeListURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *GetDirectPVVolumeListURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on GetDirectPVVolumeListURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on GetDirectPVVolumeListURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *GetDirectPVVolumeListURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -23,9 +23,12 @@ package operator_api
// Editing this file might prove futile when you re-run the generate command
import (
"context"
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/minio/console/models"
)
@@ -86,3 +89,40 @@ func (o *GetMPIntegration) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
o.Context.Respond(rw, r, route.Produces, route, res)
}
// GetMPIntegrationOKBody get m p integration o k body
//
// swagger:model GetMPIntegrationOKBody
type GetMPIntegrationOKBody struct {
// is email set
IsEmailSet bool `json:"isEmailSet,omitempty"`
}
// Validate validates this get m p integration o k body
func (o *GetMPIntegrationOKBody) Validate(formats strfmt.Registry) error {
return nil
}
// ContextValidate validates this get m p integration o k body based on context it is used
func (o *GetMPIntegrationOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (o *GetMPIntegrationOKBody) MarshalBinary() ([]byte, error) {
if o == nil {
return nil, nil
}
return swag.WriteJSON(o)
}
// UnmarshalBinary interface implementation
func (o *GetMPIntegrationOKBody) UnmarshalBinary(b []byte) error {
var res GetMPIntegrationOKBody
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*o = res
return nil
}

View File

@@ -42,7 +42,7 @@ type GetMPIntegrationOK struct {
/*
In: Body
*/
Payload *models.MpIntegration `json:"body,omitempty"`
Payload *GetMPIntegrationOKBody `json:"body,omitempty"`
}
// NewGetMPIntegrationOK creates GetMPIntegrationOK with default headers values
@@ -52,13 +52,13 @@ func NewGetMPIntegrationOK() *GetMPIntegrationOK {
}
// WithPayload adds the payload to the get m p integration o k response
func (o *GetMPIntegrationOK) WithPayload(payload *models.MpIntegration) *GetMPIntegrationOK {
func (o *GetMPIntegrationOK) WithPayload(payload *GetMPIntegrationOKBody) *GetMPIntegrationOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the get m p integration o k response
func (o *GetMPIntegrationOK) SetPayload(payload *models.MpIntegration) {
func (o *GetMPIntegrationOK) SetPayload(payload *GetMPIntegrationOKBody) {
o.Payload = payload
}

View File

@@ -0,0 +1,88 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/models"
)
// OperatorSubnetAPIKeyHandlerFunc turns a function with the right signature into a operator subnet Api key handler
type OperatorSubnetAPIKeyHandlerFunc func(OperatorSubnetAPIKeyParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn OperatorSubnetAPIKeyHandlerFunc) Handle(params OperatorSubnetAPIKeyParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// OperatorSubnetAPIKeyHandler interface for that can handle valid operator subnet Api key params
type OperatorSubnetAPIKeyHandler interface {
Handle(OperatorSubnetAPIKeyParams, *models.Principal) middleware.Responder
}
// NewOperatorSubnetAPIKey creates a new http.Handler for the operator subnet Api key operation
func NewOperatorSubnetAPIKey(ctx *middleware.Context, handler OperatorSubnetAPIKeyHandler) *OperatorSubnetAPIKey {
return &OperatorSubnetAPIKey{Context: ctx, Handler: handler}
}
/* OperatorSubnetAPIKey swagger:route GET /subnet/apikey OperatorAPI operatorSubnetApiKey
Subnet api key
*/
type OperatorSubnetAPIKey struct {
Context *middleware.Context
Handler OperatorSubnetAPIKeyHandler
}
func (o *OperatorSubnetAPIKey) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewOperatorSubnetAPIKeyParams()
uprinc, aCtx, err := o.Context.Authorize(r, route)
if err != nil {
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
if aCtx != nil {
*r = *aCtx
}
var principal *models.Principal
if uprinc != nil {
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
}
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params, principal) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@@ -0,0 +1,88 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/models"
)
// OperatorSubnetAPIKeyInfoHandlerFunc turns a function with the right signature into a operator subnet API key info handler
type OperatorSubnetAPIKeyInfoHandlerFunc func(OperatorSubnetAPIKeyInfoParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn OperatorSubnetAPIKeyInfoHandlerFunc) Handle(params OperatorSubnetAPIKeyInfoParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// OperatorSubnetAPIKeyInfoHandler interface for that can handle valid operator subnet API key info params
type OperatorSubnetAPIKeyInfoHandler interface {
Handle(OperatorSubnetAPIKeyInfoParams, *models.Principal) middleware.Responder
}
// NewOperatorSubnetAPIKeyInfo creates a new http.Handler for the operator subnet API key info operation
func NewOperatorSubnetAPIKeyInfo(ctx *middleware.Context, handler OperatorSubnetAPIKeyInfoHandler) *OperatorSubnetAPIKeyInfo {
return &OperatorSubnetAPIKeyInfo{Context: ctx, Handler: handler}
}
/* OperatorSubnetAPIKeyInfo swagger:route GET /subnet/apikey/info OperatorAPI operatorSubnetApiKeyInfo
Subnet API key info
*/
type OperatorSubnetAPIKeyInfo struct {
Context *middleware.Context
Handler OperatorSubnetAPIKeyInfoHandler
}
func (o *OperatorSubnetAPIKeyInfo) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewOperatorSubnetAPIKeyInfoParams()
uprinc, aCtx, err := o.Context.Authorize(r, route)
if err != nil {
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
if aCtx != nil {
*r = *aCtx
}
var principal *models.Principal
if uprinc != nil {
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
}
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params, principal) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@@ -0,0 +1,63 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime/middleware"
)
// NewOperatorSubnetAPIKeyInfoParams creates a new OperatorSubnetAPIKeyInfoParams object
//
// There are no default values defined in the spec.
func NewOperatorSubnetAPIKeyInfoParams() OperatorSubnetAPIKeyInfoParams {
return OperatorSubnetAPIKeyInfoParams{}
}
// OperatorSubnetAPIKeyInfoParams contains all the bound params for the operator subnet API key info operation
// typically these are obtained from a http.Request
//
// swagger:parameters OperatorSubnetAPIKeyInfo
type OperatorSubnetAPIKeyInfoParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls.
//
// To ensure default values, the struct must have been initialized with NewOperatorSubnetAPIKeyInfoParams() beforehand.
func (o *OperatorSubnetAPIKeyInfoParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@@ -0,0 +1,133 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/runtime"
"github.com/minio/console/models"
)
// OperatorSubnetAPIKeyInfoOKCode is the HTTP code returned for type OperatorSubnetAPIKeyInfoOK
const OperatorSubnetAPIKeyInfoOKCode int = 200
/*OperatorSubnetAPIKeyInfoOK A successful response.
swagger:response operatorSubnetApiKeyInfoOK
*/
type OperatorSubnetAPIKeyInfoOK struct {
/*
In: Body
*/
Payload *models.OperatorSubnetRegisterAPIKeyResponse `json:"body,omitempty"`
}
// NewOperatorSubnetAPIKeyInfoOK creates OperatorSubnetAPIKeyInfoOK with default headers values
func NewOperatorSubnetAPIKeyInfoOK() *OperatorSubnetAPIKeyInfoOK {
return &OperatorSubnetAPIKeyInfoOK{}
}
// WithPayload adds the payload to the operator subnet Api key info o k response
func (o *OperatorSubnetAPIKeyInfoOK) WithPayload(payload *models.OperatorSubnetRegisterAPIKeyResponse) *OperatorSubnetAPIKeyInfoOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the operator subnet Api key info o k response
func (o *OperatorSubnetAPIKeyInfoOK) SetPayload(payload *models.OperatorSubnetRegisterAPIKeyResponse) {
o.Payload = payload
}
// WriteResponse to the client
func (o *OperatorSubnetAPIKeyInfoOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(200)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}
/*OperatorSubnetAPIKeyInfoDefault Generic error response.
swagger:response operatorSubnetApiKeyInfoDefault
*/
type OperatorSubnetAPIKeyInfoDefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
}
// NewOperatorSubnetAPIKeyInfoDefault creates OperatorSubnetAPIKeyInfoDefault with default headers values
func NewOperatorSubnetAPIKeyInfoDefault(code int) *OperatorSubnetAPIKeyInfoDefault {
if code <= 0 {
code = 500
}
return &OperatorSubnetAPIKeyInfoDefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the operator subnet API key info default response
func (o *OperatorSubnetAPIKeyInfoDefault) WithStatusCode(code int) *OperatorSubnetAPIKeyInfoDefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the operator subnet API key info default response
func (o *OperatorSubnetAPIKeyInfoDefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the operator subnet API key info default response
func (o *OperatorSubnetAPIKeyInfoDefault) WithPayload(payload *models.Error) *OperatorSubnetAPIKeyInfoDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the operator subnet API key info default response
func (o *OperatorSubnetAPIKeyInfoDefault) SetPayload(payload *models.Error) {
o.Payload = payload
}
// WriteResponse to the client
func (o *OperatorSubnetAPIKeyInfoDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(o._statusCode)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}

View File

@@ -0,0 +1,104 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
)
// OperatorSubnetAPIKeyInfoURL generates an URL for the operator subnet API key info operation
type OperatorSubnetAPIKeyInfoURL struct {
_basePath string
}
// WithBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *OperatorSubnetAPIKeyInfoURL) WithBasePath(bp string) *OperatorSubnetAPIKeyInfoURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *OperatorSubnetAPIKeyInfoURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *OperatorSubnetAPIKeyInfoURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/subnet/apikey/info"
_basePath := o._basePath
if _basePath == "" {
_basePath = "/api/v1"
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *OperatorSubnetAPIKeyInfoURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *OperatorSubnetAPIKeyInfoURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *OperatorSubnetAPIKeyInfoURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on OperatorSubnetAPIKeyInfoURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on OperatorSubnetAPIKeyInfoURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *OperatorSubnetAPIKeyInfoURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -0,0 +1,99 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/validate"
)
// NewOperatorSubnetAPIKeyParams creates a new OperatorSubnetAPIKeyParams object
//
// There are no default values defined in the spec.
func NewOperatorSubnetAPIKeyParams() OperatorSubnetAPIKeyParams {
return OperatorSubnetAPIKeyParams{}
}
// OperatorSubnetAPIKeyParams contains all the bound params for the operator subnet Api key operation
// typically these are obtained from a http.Request
//
// swagger:parameters OperatorSubnetApiKey
type OperatorSubnetAPIKeyParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
Required: true
In: query
*/
Token string
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls.
//
// To ensure default values, the struct must have been initialized with NewOperatorSubnetAPIKeyParams() beforehand.
func (o *OperatorSubnetAPIKeyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
qs := runtime.Values(r.URL.Query())
qToken, qhkToken, _ := qs.GetOK("token")
if err := o.bindToken(qToken, qhkToken, route.Formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// bindToken binds and validates parameter Token from query.
func (o *OperatorSubnetAPIKeyParams) bindToken(rawData []string, hasKey bool, formats strfmt.Registry) error {
if !hasKey {
return errors.Required("token", "query", rawData)
}
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: true
// AllowEmptyValue: false
if err := validate.RequiredString("token", "query", raw); err != nil {
return err
}
o.Token = raw
return nil
}

View File

@@ -0,0 +1,133 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/runtime"
"github.com/minio/console/models"
)
// OperatorSubnetAPIKeyOKCode is the HTTP code returned for type OperatorSubnetAPIKeyOK
const OperatorSubnetAPIKeyOKCode int = 200
/*OperatorSubnetAPIKeyOK A successful response.
swagger:response operatorSubnetApiKeyOK
*/
type OperatorSubnetAPIKeyOK struct {
/*
In: Body
*/
Payload *models.OperatorSubnetAPIKey `json:"body,omitempty"`
}
// NewOperatorSubnetAPIKeyOK creates OperatorSubnetAPIKeyOK with default headers values
func NewOperatorSubnetAPIKeyOK() *OperatorSubnetAPIKeyOK {
return &OperatorSubnetAPIKeyOK{}
}
// WithPayload adds the payload to the operator subnet Api key o k response
func (o *OperatorSubnetAPIKeyOK) WithPayload(payload *models.OperatorSubnetAPIKey) *OperatorSubnetAPIKeyOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the operator subnet Api key o k response
func (o *OperatorSubnetAPIKeyOK) SetPayload(payload *models.OperatorSubnetAPIKey) {
o.Payload = payload
}
// WriteResponse to the client
func (o *OperatorSubnetAPIKeyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(200)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}
/*OperatorSubnetAPIKeyDefault Generic error response.
swagger:response operatorSubnetApiKeyDefault
*/
type OperatorSubnetAPIKeyDefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
}
// NewOperatorSubnetAPIKeyDefault creates OperatorSubnetAPIKeyDefault with default headers values
func NewOperatorSubnetAPIKeyDefault(code int) *OperatorSubnetAPIKeyDefault {
if code <= 0 {
code = 500
}
return &OperatorSubnetAPIKeyDefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the operator subnet Api key default response
func (o *OperatorSubnetAPIKeyDefault) WithStatusCode(code int) *OperatorSubnetAPIKeyDefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the operator subnet Api key default response
func (o *OperatorSubnetAPIKeyDefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the operator subnet Api key default response
func (o *OperatorSubnetAPIKeyDefault) WithPayload(payload *models.Error) *OperatorSubnetAPIKeyDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the operator subnet Api key default response
func (o *OperatorSubnetAPIKeyDefault) SetPayload(payload *models.Error) {
o.Payload = payload
}
// WriteResponse to the client
func (o *OperatorSubnetAPIKeyDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(o._statusCode)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}

View File

@@ -0,0 +1,117 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
)
// OperatorSubnetAPIKeyURL generates an URL for the operator subnet Api key operation
type OperatorSubnetAPIKeyURL struct {
Token string
_basePath string
// avoid unkeyed usage
_ struct{}
}
// WithBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *OperatorSubnetAPIKeyURL) WithBasePath(bp string) *OperatorSubnetAPIKeyURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *OperatorSubnetAPIKeyURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *OperatorSubnetAPIKeyURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/subnet/apikey"
_basePath := o._basePath
if _basePath == "" {
_basePath = "/api/v1"
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
qs := make(url.Values)
tokenQ := o.Token
if tokenQ != "" {
qs.Set("token", tokenQ)
}
_result.RawQuery = qs.Encode()
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *OperatorSubnetAPIKeyURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *OperatorSubnetAPIKeyURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *OperatorSubnetAPIKeyURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on OperatorSubnetAPIKeyURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on OperatorSubnetAPIKeyURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *OperatorSubnetAPIKeyURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -0,0 +1,88 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/models"
)
// OperatorSubnetLoginHandlerFunc turns a function with the right signature into a operator subnet login handler
type OperatorSubnetLoginHandlerFunc func(OperatorSubnetLoginParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn OperatorSubnetLoginHandlerFunc) Handle(params OperatorSubnetLoginParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// OperatorSubnetLoginHandler interface for that can handle valid operator subnet login params
type OperatorSubnetLoginHandler interface {
Handle(OperatorSubnetLoginParams, *models.Principal) middleware.Responder
}
// NewOperatorSubnetLogin creates a new http.Handler for the operator subnet login operation
func NewOperatorSubnetLogin(ctx *middleware.Context, handler OperatorSubnetLoginHandler) *OperatorSubnetLogin {
return &OperatorSubnetLogin{Context: ctx, Handler: handler}
}
/* OperatorSubnetLogin swagger:route POST /subnet/login OperatorAPI operatorSubnetLogin
Login to subnet
*/
type OperatorSubnetLogin struct {
Context *middleware.Context
Handler OperatorSubnetLoginHandler
}
func (o *OperatorSubnetLogin) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewOperatorSubnetLoginParams()
uprinc, aCtx, err := o.Context.Authorize(r, route)
if err != nil {
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
if aCtx != nil {
*r = *aCtx
}
var principal *models.Principal
if uprinc != nil {
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
}
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params, principal) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@@ -0,0 +1,88 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/models"
)
// OperatorSubnetLoginMFAHandlerFunc turns a function with the right signature into a operator subnet login m f a handler
type OperatorSubnetLoginMFAHandlerFunc func(OperatorSubnetLoginMFAParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn OperatorSubnetLoginMFAHandlerFunc) Handle(params OperatorSubnetLoginMFAParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// OperatorSubnetLoginMFAHandler interface for that can handle valid operator subnet login m f a params
type OperatorSubnetLoginMFAHandler interface {
Handle(OperatorSubnetLoginMFAParams, *models.Principal) middleware.Responder
}
// NewOperatorSubnetLoginMFA creates a new http.Handler for the operator subnet login m f a operation
func NewOperatorSubnetLoginMFA(ctx *middleware.Context, handler OperatorSubnetLoginMFAHandler) *OperatorSubnetLoginMFA {
return &OperatorSubnetLoginMFA{Context: ctx, Handler: handler}
}
/* OperatorSubnetLoginMFA swagger:route POST /subnet/login/mfa OperatorAPI operatorSubnetLoginMFA
Login to subnet using mfa
*/
type OperatorSubnetLoginMFA struct {
Context *middleware.Context
Handler OperatorSubnetLoginMFAHandler
}
func (o *OperatorSubnetLoginMFA) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewOperatorSubnetLoginMFAParams()
uprinc, aCtx, err := o.Context.Authorize(r, route)
if err != nil {
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
if aCtx != nil {
*r = *aCtx
}
var principal *models.Principal
if uprinc != nil {
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
}
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params, principal) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@@ -0,0 +1,102 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/validate"
"github.com/minio/console/models"
)
// NewOperatorSubnetLoginMFAParams creates a new OperatorSubnetLoginMFAParams object
//
// There are no default values defined in the spec.
func NewOperatorSubnetLoginMFAParams() OperatorSubnetLoginMFAParams {
return OperatorSubnetLoginMFAParams{}
}
// OperatorSubnetLoginMFAParams contains all the bound params for the operator subnet login m f a operation
// typically these are obtained from a http.Request
//
// swagger:parameters OperatorSubnetLoginMFA
type OperatorSubnetLoginMFAParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
Required: true
In: body
*/
Body *models.OperatorSubnetLoginMFARequest
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls.
//
// To ensure default values, the struct must have been initialized with NewOperatorSubnetLoginMFAParams() beforehand.
func (o *OperatorSubnetLoginMFAParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if runtime.HasBody(r) {
defer r.Body.Close()
var body models.OperatorSubnetLoginMFARequest
if err := route.Consumer.Consume(r.Body, &body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("body", "body", ""))
} else {
res = append(res, errors.NewParseError("body", "body", "", err))
}
} else {
// validate body object
if err := body.Validate(route.Formats); err != nil {
res = append(res, err)
}
ctx := validate.WithOperationRequest(context.Background())
if err := body.ContextValidate(ctx, route.Formats); err != nil {
res = append(res, err)
}
if len(res) == 0 {
o.Body = &body
}
}
} else {
res = append(res, errors.Required("body", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@@ -0,0 +1,133 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/runtime"
"github.com/minio/console/models"
)
// OperatorSubnetLoginMFAOKCode is the HTTP code returned for type OperatorSubnetLoginMFAOK
const OperatorSubnetLoginMFAOKCode int = 200
/*OperatorSubnetLoginMFAOK A successful response.
swagger:response operatorSubnetLoginMFAOK
*/
type OperatorSubnetLoginMFAOK struct {
/*
In: Body
*/
Payload *models.OperatorSubnetLoginResponse `json:"body,omitempty"`
}
// NewOperatorSubnetLoginMFAOK creates OperatorSubnetLoginMFAOK with default headers values
func NewOperatorSubnetLoginMFAOK() *OperatorSubnetLoginMFAOK {
return &OperatorSubnetLoginMFAOK{}
}
// WithPayload adds the payload to the operator subnet login m f a o k response
func (o *OperatorSubnetLoginMFAOK) WithPayload(payload *models.OperatorSubnetLoginResponse) *OperatorSubnetLoginMFAOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the operator subnet login m f a o k response
func (o *OperatorSubnetLoginMFAOK) SetPayload(payload *models.OperatorSubnetLoginResponse) {
o.Payload = payload
}
// WriteResponse to the client
func (o *OperatorSubnetLoginMFAOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(200)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}
/*OperatorSubnetLoginMFADefault Generic error response.
swagger:response operatorSubnetLoginMFADefault
*/
type OperatorSubnetLoginMFADefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
}
// NewOperatorSubnetLoginMFADefault creates OperatorSubnetLoginMFADefault with default headers values
func NewOperatorSubnetLoginMFADefault(code int) *OperatorSubnetLoginMFADefault {
if code <= 0 {
code = 500
}
return &OperatorSubnetLoginMFADefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the operator subnet login m f a default response
func (o *OperatorSubnetLoginMFADefault) WithStatusCode(code int) *OperatorSubnetLoginMFADefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the operator subnet login m f a default response
func (o *OperatorSubnetLoginMFADefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the operator subnet login m f a default response
func (o *OperatorSubnetLoginMFADefault) WithPayload(payload *models.Error) *OperatorSubnetLoginMFADefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the operator subnet login m f a default response
func (o *OperatorSubnetLoginMFADefault) SetPayload(payload *models.Error) {
o.Payload = payload
}
// WriteResponse to the client
func (o *OperatorSubnetLoginMFADefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(o._statusCode)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}

View File

@@ -0,0 +1,104 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
)
// OperatorSubnetLoginMFAURL generates an URL for the operator subnet login m f a operation
type OperatorSubnetLoginMFAURL struct {
_basePath string
}
// WithBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *OperatorSubnetLoginMFAURL) WithBasePath(bp string) *OperatorSubnetLoginMFAURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *OperatorSubnetLoginMFAURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *OperatorSubnetLoginMFAURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/subnet/login/mfa"
_basePath := o._basePath
if _basePath == "" {
_basePath = "/api/v1"
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *OperatorSubnetLoginMFAURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *OperatorSubnetLoginMFAURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *OperatorSubnetLoginMFAURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on OperatorSubnetLoginMFAURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on OperatorSubnetLoginMFAURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *OperatorSubnetLoginMFAURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -0,0 +1,102 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/validate"
"github.com/minio/console/models"
)
// NewOperatorSubnetLoginParams creates a new OperatorSubnetLoginParams object
//
// There are no default values defined in the spec.
func NewOperatorSubnetLoginParams() OperatorSubnetLoginParams {
return OperatorSubnetLoginParams{}
}
// OperatorSubnetLoginParams contains all the bound params for the operator subnet login operation
// typically these are obtained from a http.Request
//
// swagger:parameters OperatorSubnetLogin
type OperatorSubnetLoginParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
Required: true
In: body
*/
Body *models.OperatorSubnetLoginRequest
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls.
//
// To ensure default values, the struct must have been initialized with NewOperatorSubnetLoginParams() beforehand.
func (o *OperatorSubnetLoginParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if runtime.HasBody(r) {
defer r.Body.Close()
var body models.OperatorSubnetLoginRequest
if err := route.Consumer.Consume(r.Body, &body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("body", "body", ""))
} else {
res = append(res, errors.NewParseError("body", "body", "", err))
}
} else {
// validate body object
if err := body.Validate(route.Formats); err != nil {
res = append(res, err)
}
ctx := validate.WithOperationRequest(context.Background())
if err := body.ContextValidate(ctx, route.Formats); err != nil {
res = append(res, err)
}
if len(res) == 0 {
o.Body = &body
}
}
} else {
res = append(res, errors.Required("body", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@@ -0,0 +1,133 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/runtime"
"github.com/minio/console/models"
)
// OperatorSubnetLoginOKCode is the HTTP code returned for type OperatorSubnetLoginOK
const OperatorSubnetLoginOKCode int = 200
/*OperatorSubnetLoginOK A successful response.
swagger:response operatorSubnetLoginOK
*/
type OperatorSubnetLoginOK struct {
/*
In: Body
*/
Payload *models.OperatorSubnetLoginResponse `json:"body,omitempty"`
}
// NewOperatorSubnetLoginOK creates OperatorSubnetLoginOK with default headers values
func NewOperatorSubnetLoginOK() *OperatorSubnetLoginOK {
return &OperatorSubnetLoginOK{}
}
// WithPayload adds the payload to the operator subnet login o k response
func (o *OperatorSubnetLoginOK) WithPayload(payload *models.OperatorSubnetLoginResponse) *OperatorSubnetLoginOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the operator subnet login o k response
func (o *OperatorSubnetLoginOK) SetPayload(payload *models.OperatorSubnetLoginResponse) {
o.Payload = payload
}
// WriteResponse to the client
func (o *OperatorSubnetLoginOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(200)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}
/*OperatorSubnetLoginDefault Generic error response.
swagger:response operatorSubnetLoginDefault
*/
type OperatorSubnetLoginDefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
}
// NewOperatorSubnetLoginDefault creates OperatorSubnetLoginDefault with default headers values
func NewOperatorSubnetLoginDefault(code int) *OperatorSubnetLoginDefault {
if code <= 0 {
code = 500
}
return &OperatorSubnetLoginDefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the operator subnet login default response
func (o *OperatorSubnetLoginDefault) WithStatusCode(code int) *OperatorSubnetLoginDefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the operator subnet login default response
func (o *OperatorSubnetLoginDefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the operator subnet login default response
func (o *OperatorSubnetLoginDefault) WithPayload(payload *models.Error) *OperatorSubnetLoginDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the operator subnet login default response
func (o *OperatorSubnetLoginDefault) SetPayload(payload *models.Error) {
o.Payload = payload
}
// WriteResponse to the client
func (o *OperatorSubnetLoginDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(o._statusCode)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}

View File

@@ -0,0 +1,104 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
)
// OperatorSubnetLoginURL generates an URL for the operator subnet login operation
type OperatorSubnetLoginURL struct {
_basePath string
}
// WithBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *OperatorSubnetLoginURL) WithBasePath(bp string) *OperatorSubnetLoginURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *OperatorSubnetLoginURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *OperatorSubnetLoginURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/subnet/login"
_basePath := o._basePath
if _basePath == "" {
_basePath = "/api/v1"
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *OperatorSubnetLoginURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *OperatorSubnetLoginURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *OperatorSubnetLoginURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on OperatorSubnetLoginURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on OperatorSubnetLoginURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *OperatorSubnetLoginURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -0,0 +1,88 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/models"
)
// OperatorSubnetRegisterAPIKeyHandlerFunc turns a function with the right signature into a operator subnet register API key handler
type OperatorSubnetRegisterAPIKeyHandlerFunc func(OperatorSubnetRegisterAPIKeyParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn OperatorSubnetRegisterAPIKeyHandlerFunc) Handle(params OperatorSubnetRegisterAPIKeyParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// OperatorSubnetRegisterAPIKeyHandler interface for that can handle valid operator subnet register API key params
type OperatorSubnetRegisterAPIKeyHandler interface {
Handle(OperatorSubnetRegisterAPIKeyParams, *models.Principal) middleware.Responder
}
// NewOperatorSubnetRegisterAPIKey creates a new http.Handler for the operator subnet register API key operation
func NewOperatorSubnetRegisterAPIKey(ctx *middleware.Context, handler OperatorSubnetRegisterAPIKeyHandler) *OperatorSubnetRegisterAPIKey {
return &OperatorSubnetRegisterAPIKey{Context: ctx, Handler: handler}
}
/* OperatorSubnetRegisterAPIKey swagger:route POST /subnet/apikey/register OperatorAPI operatorSubnetRegisterApiKey
Register Operator with Subnet
*/
type OperatorSubnetRegisterAPIKey struct {
Context *middleware.Context
Handler OperatorSubnetRegisterAPIKeyHandler
}
func (o *OperatorSubnetRegisterAPIKey) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewOperatorSubnetRegisterAPIKeyParams()
uprinc, aCtx, err := o.Context.Authorize(r, route)
if err != nil {
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
if aCtx != nil {
*r = *aCtx
}
var principal *models.Principal
if uprinc != nil {
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
}
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params, principal) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@@ -0,0 +1,102 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/validate"
"github.com/minio/console/models"
)
// NewOperatorSubnetRegisterAPIKeyParams creates a new OperatorSubnetRegisterAPIKeyParams object
//
// There are no default values defined in the spec.
func NewOperatorSubnetRegisterAPIKeyParams() OperatorSubnetRegisterAPIKeyParams {
return OperatorSubnetRegisterAPIKeyParams{}
}
// OperatorSubnetRegisterAPIKeyParams contains all the bound params for the operator subnet register API key operation
// typically these are obtained from a http.Request
//
// swagger:parameters OperatorSubnetRegisterAPIKey
type OperatorSubnetRegisterAPIKeyParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
Required: true
In: body
*/
Body *models.OperatorSubnetAPIKey
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls.
//
// To ensure default values, the struct must have been initialized with NewOperatorSubnetRegisterAPIKeyParams() beforehand.
func (o *OperatorSubnetRegisterAPIKeyParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if runtime.HasBody(r) {
defer r.Body.Close()
var body models.OperatorSubnetAPIKey
if err := route.Consumer.Consume(r.Body, &body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("body", "body", ""))
} else {
res = append(res, errors.NewParseError("body", "body", "", err))
}
} else {
// validate body object
if err := body.Validate(route.Formats); err != nil {
res = append(res, err)
}
ctx := validate.WithOperationRequest(context.Background())
if err := body.ContextValidate(ctx, route.Formats); err != nil {
res = append(res, err)
}
if len(res) == 0 {
o.Body = &body
}
}
} else {
res = append(res, errors.Required("body", "body", ""))
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@@ -0,0 +1,133 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/runtime"
"github.com/minio/console/models"
)
// OperatorSubnetRegisterAPIKeyOKCode is the HTTP code returned for type OperatorSubnetRegisterAPIKeyOK
const OperatorSubnetRegisterAPIKeyOKCode int = 200
/*OperatorSubnetRegisterAPIKeyOK A successful response.
swagger:response operatorSubnetRegisterApiKeyOK
*/
type OperatorSubnetRegisterAPIKeyOK struct {
/*
In: Body
*/
Payload *models.OperatorSubnetRegisterAPIKeyResponse `json:"body,omitempty"`
}
// NewOperatorSubnetRegisterAPIKeyOK creates OperatorSubnetRegisterAPIKeyOK with default headers values
func NewOperatorSubnetRegisterAPIKeyOK() *OperatorSubnetRegisterAPIKeyOK {
return &OperatorSubnetRegisterAPIKeyOK{}
}
// WithPayload adds the payload to the operator subnet register Api key o k response
func (o *OperatorSubnetRegisterAPIKeyOK) WithPayload(payload *models.OperatorSubnetRegisterAPIKeyResponse) *OperatorSubnetRegisterAPIKeyOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the operator subnet register Api key o k response
func (o *OperatorSubnetRegisterAPIKeyOK) SetPayload(payload *models.OperatorSubnetRegisterAPIKeyResponse) {
o.Payload = payload
}
// WriteResponse to the client
func (o *OperatorSubnetRegisterAPIKeyOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(200)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}
/*OperatorSubnetRegisterAPIKeyDefault Generic error response.
swagger:response operatorSubnetRegisterApiKeyDefault
*/
type OperatorSubnetRegisterAPIKeyDefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
}
// NewOperatorSubnetRegisterAPIKeyDefault creates OperatorSubnetRegisterAPIKeyDefault with default headers values
func NewOperatorSubnetRegisterAPIKeyDefault(code int) *OperatorSubnetRegisterAPIKeyDefault {
if code <= 0 {
code = 500
}
return &OperatorSubnetRegisterAPIKeyDefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the operator subnet register API key default response
func (o *OperatorSubnetRegisterAPIKeyDefault) WithStatusCode(code int) *OperatorSubnetRegisterAPIKeyDefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the operator subnet register API key default response
func (o *OperatorSubnetRegisterAPIKeyDefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the operator subnet register API key default response
func (o *OperatorSubnetRegisterAPIKeyDefault) WithPayload(payload *models.Error) *OperatorSubnetRegisterAPIKeyDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the operator subnet register API key default response
func (o *OperatorSubnetRegisterAPIKeyDefault) SetPayload(payload *models.Error) {
o.Payload = payload
}
// WriteResponse to the client
func (o *OperatorSubnetRegisterAPIKeyDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(o._statusCode)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}

View File

@@ -0,0 +1,104 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
)
// OperatorSubnetRegisterAPIKeyURL generates an URL for the operator subnet register API key operation
type OperatorSubnetRegisterAPIKeyURL struct {
_basePath string
}
// WithBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *OperatorSubnetRegisterAPIKeyURL) WithBasePath(bp string) *OperatorSubnetRegisterAPIKeyURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *OperatorSubnetRegisterAPIKeyURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *OperatorSubnetRegisterAPIKeyURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/subnet/apikey/register"
_basePath := o._basePath
if _basePath == "" {
_basePath = "/api/v1"
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *OperatorSubnetRegisterAPIKeyURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *OperatorSubnetRegisterAPIKeyURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *OperatorSubnetRegisterAPIKeyURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on OperatorSubnetRegisterAPIKeyURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on OperatorSubnetRegisterAPIKeyURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *OperatorSubnetRegisterAPIKeyURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -0,0 +1,88 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/models"
)
// SetTenantAdministratorsHandlerFunc turns a function with the right signature into a set tenant administrators handler
type SetTenantAdministratorsHandlerFunc func(SetTenantAdministratorsParams, *models.Principal) middleware.Responder
// Handle executing the request and returning a response
func (fn SetTenantAdministratorsHandlerFunc) Handle(params SetTenantAdministratorsParams, principal *models.Principal) middleware.Responder {
return fn(params, principal)
}
// SetTenantAdministratorsHandler interface for that can handle valid set tenant administrators params
type SetTenantAdministratorsHandler interface {
Handle(SetTenantAdministratorsParams, *models.Principal) middleware.Responder
}
// NewSetTenantAdministrators creates a new http.Handler for the set tenant administrators operation
func NewSetTenantAdministrators(ctx *middleware.Context, handler SetTenantAdministratorsHandler) *SetTenantAdministrators {
return &SetTenantAdministrators{Context: ctx, Handler: handler}
}
/* SetTenantAdministrators swagger:route POST /namespaces/{namespace}/tenants/{tenant}/set-administrators OperatorAPI setTenantAdministrators
Set the consoleAdmin policy to the specified users and groups
*/
type SetTenantAdministrators struct {
Context *middleware.Context
Handler SetTenantAdministratorsHandler
}
func (o *SetTenantAdministrators) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewSetTenantAdministratorsParams()
uprinc, aCtx, err := o.Context.Authorize(r, route)
if err != nil {
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
if aCtx != nil {
*r = *aCtx
}
var principal *models.Principal
if uprinc != nil {
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
}
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params, principal) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@@ -0,0 +1,151 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/validate"
"github.com/minio/console/models"
)
// NewSetTenantAdministratorsParams creates a new SetTenantAdministratorsParams object
//
// There are no default values defined in the spec.
func NewSetTenantAdministratorsParams() SetTenantAdministratorsParams {
return SetTenantAdministratorsParams{}
}
// SetTenantAdministratorsParams contains all the bound params for the set tenant administrators operation
// typically these are obtained from a http.Request
//
// swagger:parameters SetTenantAdministrators
type SetTenantAdministratorsParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*
Required: true
In: body
*/
Body *models.SetAdministratorsRequest
/*
Required: true
In: path
*/
Namespace string
/*
Required: true
In: path
*/
Tenant string
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls.
//
// To ensure default values, the struct must have been initialized with NewSetTenantAdministratorsParams() beforehand.
func (o *SetTenantAdministratorsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if runtime.HasBody(r) {
defer r.Body.Close()
var body models.SetAdministratorsRequest
if err := route.Consumer.Consume(r.Body, &body); err != nil {
if err == io.EOF {
res = append(res, errors.Required("body", "body", ""))
} else {
res = append(res, errors.NewParseError("body", "body", "", err))
}
} else {
// validate body object
if err := body.Validate(route.Formats); err != nil {
res = append(res, err)
}
ctx := validate.WithOperationRequest(context.Background())
if err := body.ContextValidate(ctx, route.Formats); err != nil {
res = append(res, err)
}
if len(res) == 0 {
o.Body = &body
}
}
} else {
res = append(res, errors.Required("body", "body", ""))
}
rNamespace, rhkNamespace, _ := route.Params.GetOK("namespace")
if err := o.bindNamespace(rNamespace, rhkNamespace, route.Formats); err != nil {
res = append(res, err)
}
rTenant, rhkTenant, _ := route.Params.GetOK("tenant")
if err := o.bindTenant(rTenant, rhkTenant, route.Formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// bindNamespace binds and validates parameter Namespace from path.
func (o *SetTenantAdministratorsParams) bindNamespace(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: true
// Parameter is provided by construction from the route
o.Namespace = raw
return nil
}
// bindTenant binds and validates parameter Tenant from path.
func (o *SetTenantAdministratorsParams) bindTenant(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: true
// Parameter is provided by construction from the route
o.Tenant = raw
return nil
}

View File

@@ -0,0 +1,113 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/runtime"
"github.com/minio/console/models"
)
// SetTenantAdministratorsNoContentCode is the HTTP code returned for type SetTenantAdministratorsNoContent
const SetTenantAdministratorsNoContentCode int = 204
/*SetTenantAdministratorsNoContent A successful response.
swagger:response setTenantAdministratorsNoContent
*/
type SetTenantAdministratorsNoContent struct {
}
// NewSetTenantAdministratorsNoContent creates SetTenantAdministratorsNoContent with default headers values
func NewSetTenantAdministratorsNoContent() *SetTenantAdministratorsNoContent {
return &SetTenantAdministratorsNoContent{}
}
// WriteResponse to the client
func (o *SetTenantAdministratorsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(204)
}
/*SetTenantAdministratorsDefault Generic error response.
swagger:response setTenantAdministratorsDefault
*/
type SetTenantAdministratorsDefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
}
// NewSetTenantAdministratorsDefault creates SetTenantAdministratorsDefault with default headers values
func NewSetTenantAdministratorsDefault(code int) *SetTenantAdministratorsDefault {
if code <= 0 {
code = 500
}
return &SetTenantAdministratorsDefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the set tenant administrators default response
func (o *SetTenantAdministratorsDefault) WithStatusCode(code int) *SetTenantAdministratorsDefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the set tenant administrators default response
func (o *SetTenantAdministratorsDefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the set tenant administrators default response
func (o *SetTenantAdministratorsDefault) WithPayload(payload *models.Error) *SetTenantAdministratorsDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the set tenant administrators default response
func (o *SetTenantAdministratorsDefault) SetPayload(payload *models.Error) {
o.Payload = payload
}
// WriteResponse to the client
func (o *SetTenantAdministratorsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(o._statusCode)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}

View File

@@ -0,0 +1,124 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package operator_api
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
"strings"
)
// SetTenantAdministratorsURL generates an URL for the set tenant administrators operation
type SetTenantAdministratorsURL struct {
Namespace string
Tenant string
_basePath string
// avoid unkeyed usage
_ struct{}
}
// WithBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *SetTenantAdministratorsURL) WithBasePath(bp string) *SetTenantAdministratorsURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *SetTenantAdministratorsURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *SetTenantAdministratorsURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/namespaces/{namespace}/tenants/{tenant}/set-administrators"
namespace := o.Namespace
if namespace != "" {
_path = strings.Replace(_path, "{namespace}", namespace, -1)
} else {
return nil, errors.New("namespace is required on SetTenantAdministratorsURL")
}
tenant := o.Tenant
if tenant != "" {
_path = strings.Replace(_path, "{tenant}", tenant, -1)
} else {
return nil, errors.New("tenant is required on SetTenantAdministratorsURL")
}
_basePath := o._basePath
if _basePath == "" {
_basePath = "/api/v1"
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *SetTenantAdministratorsURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *SetTenantAdministratorsURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *SetTenantAdministratorsURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on SetTenantAdministratorsURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on SetTenantAdministratorsURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *SetTenantAdministratorsURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -0,0 +1,203 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package operatorapi
import (
"context"
"errors"
"os"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/cluster"
"github.com/minio/console/models"
"github.com/minio/console/operatorapi/operations"
"github.com/minio/console/operatorapi/operations/operator_api"
xhttp "github.com/minio/console/pkg/http"
"github.com/minio/console/pkg/subnet"
"github.com/minio/console/restapi"
v2 "github.com/minio/operator/pkg/apis/minio.min.io/v2"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
var (
apiKeySecretDefault = "operator-subnet"
apiKeySecretEnvVar = "API_KEY_SECRET_NAME"
)
func registerOperatorSubnetHandlers(api *operations.OperatorAPI) {
api.OperatorAPIOperatorSubnetLoginHandler = operator_api.OperatorSubnetLoginHandlerFunc(func(params operator_api.OperatorSubnetLoginParams, session *models.Principal) middleware.Responder {
res, err := getOperatorSubnetLoginResponse(session, params)
if err != nil {
return operator_api.NewOperatorSubnetLoginDefault(int(err.Code)).WithPayload(err)
}
return operator_api.NewOperatorSubnetLoginOK().WithPayload(res)
})
api.OperatorAPIOperatorSubnetLoginMFAHandler = operator_api.OperatorSubnetLoginMFAHandlerFunc(func(params operator_api.OperatorSubnetLoginMFAParams, session *models.Principal) middleware.Responder {
res, err := getOperatorSubnetLoginMFAResponse(session, params)
if err != nil {
return operator_api.NewOperatorSubnetLoginMFADefault(int(err.Code)).WithPayload(err)
}
return operator_api.NewOperatorSubnetLoginMFAOK().WithPayload(res)
})
api.OperatorAPIOperatorSubnetAPIKeyHandler = operator_api.OperatorSubnetAPIKeyHandlerFunc(func(params operator_api.OperatorSubnetAPIKeyParams, session *models.Principal) middleware.Responder {
res, err := getOperatorSubnetAPIKeyResponse(session, params)
if err != nil {
return operator_api.NewOperatorSubnetAPIKeyDefault(int(err.Code)).WithPayload(err)
}
return operator_api.NewOperatorSubnetAPIKeyOK().WithPayload(res)
})
api.OperatorAPIOperatorSubnetRegisterAPIKeyHandler = operator_api.OperatorSubnetRegisterAPIKeyHandlerFunc(func(params operator_api.OperatorSubnetRegisterAPIKeyParams, session *models.Principal) middleware.Responder {
res, err := getOperatorSubnetRegisterAPIKeyResponse(session, params)
if err != nil {
return operator_api.NewOperatorSubnetRegisterAPIKeyDefault(int(err.Code)).WithPayload(err)
}
return operator_api.NewOperatorSubnetRegisterAPIKeyOK().WithPayload(res)
})
api.OperatorAPIOperatorSubnetAPIKeyInfoHandler = operator_api.OperatorSubnetAPIKeyInfoHandlerFunc(func(params operator_api.OperatorSubnetAPIKeyInfoParams, session *models.Principal) middleware.Responder {
res, err := getOperatorSubnetAPIKeyInfoResponse(session, params)
if err != nil {
return operator_api.NewOperatorSubnetAPIKeyInfoDefault(int(err.Code)).WithPayload(err)
}
return operator_api.NewOperatorSubnetAPIKeyInfoOK().WithPayload(res)
})
}
func getOperatorSubnetLoginResponse(session *models.Principal, params operator_api.OperatorSubnetLoginParams) (*models.OperatorSubnetLoginResponse, *models.Error) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
username := params.Body.Username
password := params.Body.Password
if username == "" || password == "" {
return nil, restapi.ErrorWithContext(ctx, errors.New("empty credentials"))
}
subnetHTTPClient := &xhttp.Client{Client: restapi.GetConsoleHTTPClient()}
token, mfa, err := restapi.SubnetLogin(subnetHTTPClient, username, password)
if err != nil {
return nil, restapi.ErrorWithContext(ctx, err)
}
return &models.OperatorSubnetLoginResponse{
AccessToken: token,
MfaToken: mfa,
}, nil
}
func getOperatorSubnetLoginMFAResponse(session *models.Principal, params operator_api.OperatorSubnetLoginMFAParams) (*models.OperatorSubnetLoginResponse, *models.Error) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
subnetHTTPClient := &xhttp.Client{Client: restapi.GetConsoleHTTPClient()}
res, err := subnet.LoginWithMFA(subnetHTTPClient, *params.Body.Username, *params.Body.MfaToken, *params.Body.Otp)
if err != nil {
return nil, restapi.ErrorWithContext(ctx, err)
}
return &models.OperatorSubnetLoginResponse{
AccessToken: res.AccessToken,
}, nil
}
func getOperatorSubnetAPIKeyResponse(session *models.Principal, params operator_api.OperatorSubnetAPIKeyParams) (*models.OperatorSubnetAPIKey, *models.Error) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
subnetHTTPClient := &xhttp.Client{Client: restapi.GetConsoleHTTPClient()}
token := params.HTTPRequest.URL.Query().Get("token")
apiKey, err := subnet.GetAPIKey(subnetHTTPClient, token)
if err != nil {
return nil, restapi.ErrorWithContext(ctx, err)
}
return &models.OperatorSubnetAPIKey{APIKey: apiKey}, nil
}
func getOperatorSubnetRegisterAPIKeyResponse(session *models.Principal, params operator_api.OperatorSubnetRegisterAPIKeyParams) (*models.OperatorSubnetRegisterAPIKeyResponse, *models.Error) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
clientSet, err := cluster.K8sClient(session.STSSessionToken)
if err != nil {
return nil, restapi.ErrorWithContext(ctx, err)
}
tenants, err := getTenantsToRegister(ctx, session)
if err != nil {
return nil, restapi.ErrorWithContext(ctx, err)
}
k8sClient := &k8sClient{client: clientSet}
return registerTenants(ctx, tenants.Items, params.Body.APIKey, k8sClient)
}
func getTenantsToRegister(ctx context.Context, session *models.Principal) (*v2.TenantList, error) {
opClientClientSet, err := cluster.OperatorClient(session.STSSessionToken)
if err != nil {
return nil, err
}
opClient := &operatorClient{client: opClientClientSet}
return opClient.TenantList(ctx, "", metav1.ListOptions{})
}
func registerTenants(ctx context.Context, tenants []v2.Tenant, apiKey string, k8sClient K8sClientI) (*models.OperatorSubnetRegisterAPIKeyResponse, *models.Error) {
for _, tenant := range tenants {
if err := registerTenant(ctx, tenant, apiKey, k8sClient); err != nil {
return nil, restapi.ErrorWithContext(ctx, err)
}
}
if err := createSubnetAPIKeySecret(ctx, apiKey, k8sClient); err != nil {
return nil, restapi.ErrorWithContext(ctx, err)
}
return &models.OperatorSubnetRegisterAPIKeyResponse{Registered: true}, nil
}
func registerTenant(ctx context.Context, tenant v2.Tenant, apiKey string, k8sClient K8sClientI) error {
svcURL := tenant.GetTenantServiceURL()
mAdmin, err := getTenantAdminClient(ctx, k8sClient, &tenant, svcURL)
if err != nil {
return err
}
adminClient := restapi.AdminClient{Client: mAdmin}
_, err = restapi.SubnetRegisterWithAPIKey(ctx, adminClient, apiKey)
return err
}
func createSubnetAPIKeySecret(ctx context.Context, apiKey string, k8sClient K8sClientI) error {
apiKeySecret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{Name: getAPIKeySecretName()},
Type: corev1.SecretTypeOpaque,
Data: map[string][]byte{"api-key": []byte(apiKey)},
}
_, err := k8sClient.createSecret(ctx, "default", apiKeySecret, metav1.CreateOptions{})
return err
}
func getOperatorSubnetAPIKeyInfoResponse(session *models.Principal, params operator_api.OperatorSubnetAPIKeyInfoParams) (*models.OperatorSubnetRegisterAPIKeyResponse, *models.Error) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
clientSet, err := cluster.K8sClient(session.STSSessionToken)
if err != nil {
return nil, restapi.ErrorWithContext(ctx, err)
}
k8sClient := &k8sClient{client: clientSet}
if _, err := k8sClient.getSecret(ctx, "default", getAPIKeySecretName(), metav1.GetOptions{}); err != nil {
return nil, restapi.ErrorWithContext(ctx, err)
}
return &models.OperatorSubnetRegisterAPIKeyResponse{Registered: true}, nil
}
func getAPIKeySecretName() string {
if s := os.Getenv(apiKeySecretEnvVar); s != "" {
return s
}
return apiKeySecretDefault
}

View File

@@ -0,0 +1,304 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package operatorapi
import (
"context"
"fmt"
"net/http"
"net/http/httptest"
"net/url"
"os"
"testing"
"github.com/minio/console/models"
"github.com/minio/console/operatorapi/operations"
"github.com/minio/console/operatorapi/operations/operator_api"
"github.com/minio/console/pkg/subnet"
v2 "github.com/minio/operator/pkg/apis/minio.min.io/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type OperatorSubnetTestSuite struct {
suite.Suite
assert *assert.Assertions
loginServer *httptest.Server
loginWithError bool
loginMFAServer *httptest.Server
loginMFAWithError bool
getAPIKeyServer *httptest.Server
getAPIKeyWithError bool
registerAPIKeyServer *httptest.Server
registerAPIKeyWithError bool
k8sClient k8sClientMock
}
func (suite *OperatorSubnetTestSuite) SetupSuite() {
suite.assert = assert.New(suite.T())
suite.loginServer = httptest.NewServer(http.HandlerFunc(suite.loginHandler))
suite.loginMFAServer = httptest.NewServer(http.HandlerFunc(suite.loginMFAHandler))
suite.getAPIKeyServer = httptest.NewServer(http.HandlerFunc(suite.getAPIKeyHandler))
suite.registerAPIKeyServer = httptest.NewServer(http.HandlerFunc(suite.registerAPIKeyHandler))
suite.k8sClient = k8sClientMock{}
CreateSecretMock = func(ctx context.Context, namespace string, secret *v1.Secret, opts metav1.CreateOptions) (*v1.Secret, error) {
return &corev1.Secret{}, nil
}
k8sclientGetSecretMock = func(ctx context.Context, namespace, secretName string, opts metav1.GetOptions) (*corev1.Secret, error) {
data := make(map[string][]byte)
data["secretkey"] = []byte("secret")
data["accesskey"] = []byte("access")
sec := &corev1.Secret{
Data: data,
}
return sec, nil
}
}
func (suite *OperatorSubnetTestSuite) loginHandler(
w http.ResponseWriter, r *http.Request,
) {
if suite.loginWithError {
w.WriteHeader(400)
} else {
fmt.Fprintf(w, `{"mfa_required": true, "mfa_token": "mockToken"}`)
}
}
func (suite *OperatorSubnetTestSuite) loginMFAHandler(
w http.ResponseWriter, r *http.Request,
) {
if suite.loginMFAWithError {
w.WriteHeader(400)
} else {
fmt.Fprintf(w, `{"token_info": {"access_token": "mockToken"}}`)
}
}
func (suite *OperatorSubnetTestSuite) getAPIKeyHandler(
w http.ResponseWriter, r *http.Request,
) {
if suite.getAPIKeyWithError {
w.WriteHeader(400)
} else {
fmt.Fprintf(w, `{"api_key": "mockAPIKey"}`)
}
}
func (suite *OperatorSubnetTestSuite) registerAPIKeyHandler(
w http.ResponseWriter, r *http.Request,
) {
if suite.registerAPIKeyWithError {
w.WriteHeader(400)
} else {
fmt.Fprintf(w, `{"api_key": "mockAPIKey"}`)
}
}
func (suite *OperatorSubnetTestSuite) TearDownSuite() {
}
func (suite *OperatorSubnetTestSuite) TestRegisterOperatorSubnetHanlders() {
api := &operations.OperatorAPI{}
suite.assert.Nil(api.OperatorAPIOperatorSubnetLoginHandler)
suite.assert.Nil(api.OperatorAPIOperatorSubnetLoginMFAHandler)
suite.assert.Nil(api.OperatorAPIOperatorSubnetAPIKeyHandler)
suite.assert.Nil(api.OperatorAPIOperatorSubnetRegisterAPIKeyHandler)
registerOperatorSubnetHandlers(api)
suite.assert.NotNil(api.OperatorAPIOperatorSubnetLoginHandler)
suite.assert.NotNil(api.OperatorAPIOperatorSubnetLoginMFAHandler)
suite.assert.NotNil(api.OperatorAPIOperatorSubnetAPIKeyHandler)
suite.assert.NotNil(api.OperatorAPIOperatorSubnetRegisterAPIKeyHandler)
}
func (suite *OperatorSubnetTestSuite) TestOperatorSubnetLoginHandlerWithEmptyCredentials() {
params, api := suite.initSubnetLoginRequest("", "")
response := api.OperatorAPIOperatorSubnetLoginHandler.Handle(params, &models.Principal{})
_, ok := response.(*operator_api.OperatorSubnetLoginDefault)
suite.assert.True(ok)
}
func (suite *OperatorSubnetTestSuite) TestOperatorSubnetLoginHandlerWithServerError() {
params, api := suite.initSubnetLoginRequest("mockusername", "mockpassword")
suite.loginWithError = true
os.Setenv(subnet.ConsoleSubnetURL, suite.loginServer.URL)
response := api.OperatorAPIOperatorSubnetLoginHandler.Handle(params, &models.Principal{})
_, ok := response.(*operator_api.OperatorSubnetLoginDefault)
suite.assert.True(ok)
os.Unsetenv(subnet.ConsoleSubnetURL)
}
func (suite *OperatorSubnetTestSuite) TestOperatorSubnetLoginHandlerWithoutError() {
params, api := suite.initSubnetLoginRequest("mockusername", "mockpassword")
suite.loginWithError = false
os.Setenv(subnet.ConsoleSubnetURL, suite.loginServer.URL)
response := api.OperatorAPIOperatorSubnetLoginHandler.Handle(params, &models.Principal{})
_, ok := response.(*operator_api.OperatorSubnetLoginOK)
suite.assert.True(ok)
os.Unsetenv(subnet.ConsoleSubnetURL)
}
func (suite *OperatorSubnetTestSuite) initSubnetLoginRequest(username, password string) (params operator_api.OperatorSubnetLoginParams, api operations.OperatorAPI) {
registerOperatorSubnetHandlers(&api)
params.Body = &models.OperatorSubnetLoginRequest{Username: username, Password: password}
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *OperatorSubnetTestSuite) TestOperatorSubnetLoginMFAHandlerWithServerError() {
params, api := suite.initSubnetLoginMFARequest("mockusername", "mockMFA", "mockOTP")
suite.loginMFAWithError = true
os.Setenv(subnet.ConsoleSubnetURL, suite.loginMFAServer.URL)
response := api.OperatorAPIOperatorSubnetLoginMFAHandler.Handle(params, &models.Principal{})
_, ok := response.(*operator_api.OperatorSubnetLoginMFADefault)
suite.assert.True(ok)
os.Unsetenv(subnet.ConsoleSubnetURL)
}
func (suite *OperatorSubnetTestSuite) TestOperatorSubnetLoginMFAHandlerWithoutError() {
params, api := suite.initSubnetLoginMFARequest("mockusername", "mockMFA", "mockOTP")
suite.loginMFAWithError = false
os.Setenv(subnet.ConsoleSubnetURL, suite.loginMFAServer.URL)
response := api.OperatorAPIOperatorSubnetLoginMFAHandler.Handle(params, &models.Principal{})
_, ok := response.(*operator_api.OperatorSubnetLoginMFAOK)
suite.assert.True(ok)
os.Unsetenv(subnet.ConsoleSubnetURL)
}
func (suite *OperatorSubnetTestSuite) initSubnetLoginMFARequest(username, mfa, otp string) (params operator_api.OperatorSubnetLoginMFAParams, api operations.OperatorAPI) {
registerOperatorSubnetHandlers(&api)
params.Body = &models.OperatorSubnetLoginMFARequest{Username: &username, MfaToken: &mfa, Otp: &otp}
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *OperatorSubnetTestSuite) TestOperatorSubnetAPIKeyHandlerWithServerError() {
params, api := suite.initSubnetAPIKeyRequest()
suite.getAPIKeyWithError = true
os.Setenv(subnet.ConsoleSubnetURL, suite.getAPIKeyServer.URL)
response := api.OperatorAPIOperatorSubnetAPIKeyHandler.Handle(params, &models.Principal{})
_, ok := response.(*operator_api.OperatorSubnetAPIKeyDefault)
suite.assert.True(ok)
os.Unsetenv(subnet.ConsoleSubnetURL)
}
func (suite *OperatorSubnetTestSuite) TestOperatorSubnetAPIKeyHandlerWithoutError() {
params, api := suite.initSubnetAPIKeyRequest()
suite.getAPIKeyWithError = false
os.Setenv(subnet.ConsoleSubnetURL, suite.getAPIKeyServer.URL)
response := api.OperatorAPIOperatorSubnetAPIKeyHandler.Handle(params, &models.Principal{})
_, ok := response.(*operator_api.OperatorSubnetAPIKeyOK)
suite.assert.True(ok)
os.Unsetenv(subnet.ConsoleSubnetURL)
}
func (suite *OperatorSubnetTestSuite) initSubnetAPIKeyRequest() (params operator_api.OperatorSubnetAPIKeyParams, api operations.OperatorAPI) {
registerOperatorSubnetHandlers(&api)
params.HTTPRequest = &http.Request{URL: &url.URL{}}
return params, api
}
// TODO: Improve register tests (make code more testable)
// func (suite *OperatorSubnetTestSuite) TestOperatorSubnetRegisterAPIKeyHandlerWithServerError() {
// params, api := suite.initSubnetRegisterAPIKeyRequest()
// suite.registerAPIKeyWithError = true
// os.Setenv(subnet.ConsoleSubnetURL, suite.registerAPIKeyServer.URL)
// response := api.OperatorAPIOperatorSubnetRegisterAPIKeyHandler.Handle(params, &models.Principal{})
// _, ok := response.(*operator_api.OperatorSubnetRegisterAPIKeyDefault)
// suite.assert.True(ok)
// os.Unsetenv(subnet.ConsoleSubnetURL)
// }
// func (suite *OperatorSubnetTestSuite) TestOperatorSubnetRegisterAPIKeyHandlerWithError() {
// ctx := context.Background()
// suite.registerAPIKeyWithError = false
// os.Setenv(subnet.ConsoleSubnetURL, suite.registerAPIKeyServer.URL)
// res, err := registerTenants([]v2.Tenant{{
// Spec: v2.TenantSpec{CredsSecret: &corev1.LocalObjectReference{Name: "secret-name"}},
// }}, "mockAPIKey", ctx, suite.k8sClient)
// suite.assert.Nil(res)
// suite.assert.NotNil(err)
// os.Unsetenv(subnet.ConsoleSubnetURL)
// }
// func (suite *OperatorSubnetTestSuite) TestOperatorSubnetRegisterAPIKeyHandlerGetTenants() {
// ctx := context.Background()
// res, err := getTenantsToRegister(ctx, &models.Principal{})
// suite.assert.NotNil(res)
// suite.assert.Nil(err)
// }
func (suite *OperatorSubnetTestSuite) TestOperatorSubnetRegisterAPIKeyHandlerWithUnreachableTenant() {
ctx := context.Background()
res, err := registerTenants(ctx, []v2.Tenant{{
Spec: v2.TenantSpec{CredsSecret: &corev1.LocalObjectReference{Name: "secret-name"}},
}}, "mockAPIKey", suite.k8sClient)
suite.assert.Nil(res)
suite.assert.NotNil(err)
}
func (suite *OperatorSubnetTestSuite) TestOperatorSubnetRegisterAPIKeyHandlerZeroTenants() {
ctx := context.Background()
res, err := registerTenants(ctx, []v2.Tenant{}, "mockAPIKey", suite.k8sClient)
suite.assert.NotNil(res)
suite.assert.Nil(err)
}
// func (suite *OperatorSubnetTestSuite) initSubnetRegisterAPIKeyRequest() (params operator_api.OperatorSubnetRegisterAPIKeyParams, api operations.OperatorAPI) {
// registerOperatorSubnetHandlers(&api)
// params.Body = &models.OperatorSubnetAPIKey{APIKey: "mockAPIKey"}
// params.HTTPRequest = &http.Request{}
// return params, api
// }
func (suite *OperatorSubnetTestSuite) TestOperatorSubnetAPIKeyInfoHandlerWithNoSecret() {
params, api := suite.initSubnetAPIKeyInfoRequest()
os.Setenv(apiKeySecretEnvVar, "mock-operator-subnet")
response := api.OperatorAPIOperatorSubnetAPIKeyInfoHandler.Handle(params, &models.Principal{})
_, ok := response.(*operator_api.OperatorSubnetAPIKeyInfoDefault)
suite.assert.True(ok)
os.Unsetenv(apiKeySecretEnvVar)
}
// func (suite *OperatorSubnetTestSuite) TestOperatorSubnetAPIKeyInfoHandlerWithSecret() {
// params, api := suite.initSubnetAPIKeyInfoRequest()
// os.Setenv(apiKeySecretEnvVar, "mock-operator-subnet")
// session := &models.Principal{}
// clientSet, _ := cluster.K8sClient(session.STSSessionToken)
// k8sClient := &k8sClient{client: clientSet}
// ctx := context.Background()
// secret := &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: getAPIKeySecretName()}}
// k8sClient.createSecret(ctx, "default", secret, metav1.CreateOptions{})
// response := api.OperatorAPIOperatorSubnetAPIKeyInfoHandler.Handle(params, session)
// _, ok := response.(*operator_api.OperatorSubnetAPIKeyInfoOK)
// suite.assert.True(ok)
// k8sClient.deleteSecret(ctx, "default", getAPIKeySecretName(), metav1.DeleteOptions{})
// os.Unsetenv(apiKeySecretEnvVar)
// }
func (suite *OperatorSubnetTestSuite) initSubnetAPIKeyInfoRequest() (params operator_api.OperatorSubnetAPIKeyInfoParams, api operations.OperatorAPI) {
registerOperatorSubnetHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func TestOperatorSubnet(t *testing.T) {
suite.Run(t, new(OperatorSubnetTestSuite))
}

View File

@@ -52,6 +52,7 @@ func getSessionResponse(session *models.Principal, params authApi.SessionCheckPa
Operator: true,
Permissions: map[string][]string{},
Features: getListOfOperatorFeatures(),
DirectPV: getDirectPVEnabled(),
}
return sessionResp, nil
}

View File

@@ -128,6 +128,15 @@ func registerTenantHandlers(api *operations.OperatorAPI) {
return operator_api.NewUpdateTenantSecurityNoContent()
})
// Set Tenant Administrators
api.OperatorAPISetTenantAdministratorsHandler = operator_api.SetTenantAdministratorsHandlerFunc(func(params operator_api.SetTenantAdministratorsParams, session *models.Principal) middleware.Responder {
err := getSetTenantAdministratorsResponse(session, params)
if err != nil {
return operator_api.NewSetTenantAdministratorsDefault(int(err.Code)).WithPayload(err)
}
return operator_api.NewSetTenantAdministratorsNoContent()
})
// Tenant identity provider details
api.OperatorAPITenantIdentityProviderHandler = operator_api.TenantIdentityProviderHandlerFunc(func(params operator_api.TenantIdentityProviderParams, session *models.Principal) middleware.Responder {
resp, err := getTenantIdentityProviderResponse(session, params)
@@ -658,6 +667,7 @@ func parseTenantCertificates(ctx context.Context, clientSet K8sClientI, namespac
func getTenantSecurity(ctx context.Context, clientSet K8sClientI, tenant *miniov2.Tenant) (response *models.TenantSecurityResponse, err error) {
var minioExternalCertificates []*models.CertificateInfo
var minioExternalCaCertificates []*models.CertificateInfo
var tenantSecurityContext *models.SecurityContext
// Certificates used by MinIO server
if minioExternalCertificates, err = parseTenantCertificates(ctx, clientSet, tenant.Namespace, tenant.Spec.ExternalCertSecret); err != nil {
return nil, err
@@ -666,12 +676,17 @@ func getTenantSecurity(ctx context.Context, clientSet K8sClientI, tenant *miniov
if minioExternalCaCertificates, err = parseTenantCertificates(ctx, clientSet, tenant.Namespace, tenant.Spec.ExternalCaCertSecret); err != nil {
return nil, err
}
// Security Context used by MinIO server
if tenant.Spec.Pools[0].SecurityContext != nil {
tenantSecurityContext = convertK8sSCToModelSC(tenant.Spec.Pools[0].SecurityContext)
}
return &models.TenantSecurityResponse{
AutoCert: tenant.AutoCert(),
CustomCertificates: &models.TenantSecurityResponseCustomCertificates{
Minio: minioExternalCertificates,
MinioCAs: minioExternalCaCertificates,
},
SecurityContext: tenantSecurityContext,
}, nil
}
@@ -906,6 +921,58 @@ func getUpdateTenantIdentityProviderResponse(session *models.Principal, params o
return nil
}
func getSetTenantAdministratorsResponse(session *models.Principal, params operator_api.SetTenantAdministratorsParams) *models.Error {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
opClientClientSet, err := cluster.OperatorClient(session.STSSessionToken)
if err != nil {
return restapi.ErrorWithContext(ctx, err)
}
// get Kubernetes Client
clientSet, err := cluster.K8sClient(session.STSSessionToken)
if err != nil {
return restapi.ErrorWithContext(ctx, err)
}
k8sClient := &k8sClient{
client: clientSet,
}
opClient := &operatorClient{
client: opClientClientSet,
}
minTenant, err := getTenant(ctx, opClient, params.Namespace, params.Tenant)
if err != nil {
return restapi.ErrorWithContext(ctx, err)
}
minTenant.EnsureDefaults()
svcURL := GetTenantServiceURL(minTenant)
// getTenantAdminClient will use all certificates under ~/.console/certs/CAs to trust the TLS connections with MinIO tenants
mAdmin, err := getTenantAdminClient(
ctx,
k8sClient,
minTenant,
svcURL,
)
if err != nil {
return restapi.ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := restapi.AdminClient{Client: mAdmin}
for _, user := range params.Body.UserDNS {
if err := restapi.SetPolicy(ctx, adminClient, "consoleAdmin", user, "user"); err != nil {
return restapi.ErrorWithContext(ctx, err)
}
}
for _, group := range params.Body.GroupDNS {
if err := restapi.SetPolicy(ctx, adminClient, "consoleAdmin", group, "group"); err != nil {
return restapi.ErrorWithContext(ctx, err)
}
}
return nil
}
func getTenantSecurityResponse(session *models.Principal, params operator_api.TenantSecurityParams) (*models.TenantSecurityResponse, *models.Error) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
@@ -1026,6 +1093,12 @@ func updateTenantSecurity(ctx context.Context, operatorClient OperatorClientI, c
}
newMinIOExternalCaCertSecret = append(newMinIOExternalCaCertSecret, certificateSecrets...)
}
// set Security Context
var newTenantSecurityContext *corev1.PodSecurityContext
newTenantSecurityContext, _ = convertModelSCToK8sSC(params.Body.SecurityContext)
minInst.Spec.Pools[0].SecurityContext = newTenantSecurityContext
// Update External Certificates
minInst.Spec.ExternalCertSecret = newMinIOExternalCertSecret
minInst.Spec.ExternalCaCertSecret = newMinIOExternalCaCertSecret
@@ -1033,6 +1106,7 @@ func updateTenantSecurity(ctx context.Context, operatorClient OperatorClientI, c
if err != nil {
return err
}
// restart all MinIO pods at the same time
err = client.deletePodCollection(ctx, namespace, metav1.DeleteOptions{}, metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s=%s", miniov2.TenantLabel, minInst.Name),
@@ -1357,7 +1431,7 @@ func getTenantUsageResponse(session *models.Principal, params operator_api.GetTe
return info, nil
}
// getTenantLogsResponse returns the logs of a tenant
// getTenantLogsResponse returns the Audit Log and Log DB configuration of a tenant
func getTenantLogsResponse(session *models.Principal, params operator_api.GetTenantLogsParams) (*models.TenantLogs, *models.Error) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
@@ -1392,11 +1466,9 @@ func getTenantLogsResponse(session *models.Principal, params operator_api.GetTen
for k, v := range minTenant.Spec.Log.NodeSelector {
nodeSelector = append(nodeSelector, &models.NodeSelector{Key: k, Value: v})
}
if minTenant.Spec.Log.Db == nil {
minTenant.Spec.Log.Db = &miniov2.LogDbConfig{}
}
dbAnnotations := []*models.Annotation{}
for k, v := range minTenant.Spec.Log.Db.Annotations {
dbAnnotations = append(dbAnnotations, &models.Annotation{Key: k, Value: v})
@@ -1409,6 +1481,15 @@ func getTenantLogsResponse(session *models.Principal, params operator_api.GetTen
for k, v := range minTenant.Spec.Log.Db.NodeSelector {
dbNodeSelector = append(dbNodeSelector, &models.NodeSelector{Key: k, Value: v})
}
var logSecurityContext *models.SecurityContext
var logDBSecurityContext *models.SecurityContext
if minTenant.Spec.Log.SecurityContext != nil {
logSecurityContext = convertK8sSCToModelSC(minTenant.Spec.Log.SecurityContext)
}
if minTenant.Spec.Log.Db.SecurityContext != nil {
logDBSecurityContext = convertK8sSCToModelSC(minTenant.Spec.Log.Db.SecurityContext)
}
if minTenant.Spec.Log.Audit == nil || minTenant.Spec.Log.Audit.DiskCapacityGB == nil {
minTenant.Spec.Log.Audit = &miniov2.AuditConfig{DiskCapacityGB: swag.Int(0)}
@@ -1421,12 +1502,14 @@ func getTenantLogsResponse(session *models.Principal, params operator_api.GetTen
Labels: labels,
NodeSelector: nodeSelector,
ServiceAccountName: minTenant.Spec.Log.ServiceAccountName,
SecurityContext: logSecurityContext,
DbImage: minTenant.Spec.Log.Db.Image,
DbInitImage: minTenant.Spec.Log.Db.InitImage,
DbAnnotations: dbAnnotations,
DbLabels: dbLabels,
DbNodeSelector: dbNodeSelector,
DbServiceAccountName: minTenant.Spec.Log.Db.ServiceAccountName,
DbSecurityContext: logDBSecurityContext,
Disabled: false,
}
@@ -1454,11 +1537,10 @@ func getTenantLogsResponse(session *models.Principal, params operator_api.GetTen
return tenantLoggingConfiguration, nil
}
// setTenantLogsResponse returns the logs of a tenant
// setTenantLogsResponse updates the Audit Log and Log DB configuration for the tenant
func setTenantLogsResponse(session *models.Principal, params operator_api.SetTenantLogsParams) (bool, *models.Error) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
opClientClientSet, err := cluster.OperatorClient(session.STSSessionToken)
if err != nil {
return false, restapi.ErrorWithContext(ctx, err, restapi.ErrUnableToGetTenantUsage)
@@ -1474,44 +1556,54 @@ func setTenantLogsResponse(session *models.Principal, params operator_api.SetTen
}
labels := make(map[string]string)
for i := 0; i < len(params.Data.Labels); i++ {
if params.Data.Labels[i] != nil {
labels[params.Data.Labels[i].Key] = params.Data.Labels[i].Value
if params.Data.Labels != nil {
for i := 0; i < len(params.Data.Labels); i++ {
if params.Data.Labels[i] != nil {
labels[params.Data.Labels[i].Key] = params.Data.Labels[i].Value
}
}
minTenant.Spec.Log.Labels = labels
}
minTenant.Spec.Log.Labels = labels
annotations := make(map[string]string)
for i := 0; i < len(params.Data.Annotations); i++ {
if params.Data.Annotations[i] != nil {
annotations[params.Data.Annotations[i].Key] = params.Data.Annotations[i].Value
if params.Data.Annotations != nil {
annotations := make(map[string]string)
for i := 0; i < len(params.Data.Annotations); i++ {
if params.Data.Annotations[i] != nil {
annotations[params.Data.Annotations[i].Key] = params.Data.Annotations[i].Value
}
}
minTenant.Spec.Log.Annotations = annotations
}
minTenant.Spec.Log.Annotations = annotations
nodeSelector := make(map[string]string)
for i := 0; i < len(params.Data.NodeSelector); i++ {
if params.Data.NodeSelector[i] != nil {
nodeSelector[params.Data.NodeSelector[i].Key] = params.Data.NodeSelector[i].Value
if params.Data.NodeSelector != nil {
nodeSelector := make(map[string]string)
for i := 0; i < len(params.Data.NodeSelector); i++ {
if params.Data.NodeSelector[i] != nil {
nodeSelector[params.Data.NodeSelector[i].Key] = params.Data.NodeSelector[i].Value
}
}
minTenant.Spec.Log.NodeSelector = nodeSelector
}
minTenant.Spec.Log.NodeSelector = nodeSelector
logResourceRequest := make(corev1.ResourceList)
if reflect.TypeOf(params.Data.LogCPURequest).Kind() == reflect.String && params.Data.LogCPURequest != "0Gi" && params.Data.LogCPURequest != "" {
cpuQuantity, err := resource.ParseQuantity(params.Data.LogCPURequest)
if err != nil {
return false, restapi.ErrorWithContext(ctx, err)
if len(params.Data.LogCPURequest) > 0 {
if reflect.TypeOf(params.Data.LogCPURequest).Kind() == reflect.String && params.Data.LogCPURequest != "0Gi" && params.Data.LogCPURequest != "" {
cpuQuantity, err := resource.ParseQuantity(params.Data.LogCPURequest)
if err != nil {
return false, restapi.ErrorWithContext(ctx, err)
}
logResourceRequest["cpu"] = cpuQuantity
minTenant.Spec.Log.Resources.Requests = logResourceRequest
}
logResourceRequest["cpu"] = cpuQuantity
minTenant.Spec.Log.Resources.Requests = logResourceRequest
}
if reflect.TypeOf(params.Data.LogMemRequest).Kind() == reflect.String {
memQuantity, err := resource.ParseQuantity(params.Data.LogMemRequest)
if err != nil {
return false, restapi.ErrorWithContext(ctx, err)
}
if len(params.Data.LogMemRequest) > 0 {
if reflect.TypeOf(params.Data.LogMemRequest).Kind() == reflect.String && params.Data.LogMemRequest != "" {
memQuantity, err := resource.ParseQuantity(params.Data.LogMemRequest)
if err != nil {
return false, restapi.ErrorWithContext(ctx, err)
}
logResourceRequest["memory"] = memQuantity
minTenant.Spec.Log.Resources.Requests = logResourceRequest
logResourceRequest["memory"] = memQuantity
minTenant.Spec.Log.Resources.Requests = logResourceRequest
}
}
modified := false
@@ -1519,97 +1611,126 @@ func setTenantLogsResponse(session *models.Principal, params operator_api.SetTen
modified = true
}
dbLabels := make(map[string]string)
for i := 0; i < len(params.Data.DbLabels); i++ {
if params.Data.DbLabels[i] != nil {
dbLabels[params.Data.DbLabels[i].Key] = params.Data.DbLabels[i].Value
if params.Data.DbLabels != nil {
for i := 0; i < len(params.Data.DbLabels); i++ {
if params.Data.DbLabels[i] != nil {
dbLabels[params.Data.DbLabels[i].Key] = params.Data.DbLabels[i].Value
}
modified = true
}
modified = true
}
dbAnnotations := make(map[string]string)
for i := 0; i < len(params.Data.DbAnnotations); i++ {
if params.Data.DbAnnotations[i] != nil {
dbAnnotations[params.Data.DbAnnotations[i].Key] = params.Data.DbAnnotations[i].Value
if params.Data.DbAnnotations != nil {
for i := 0; i < len(params.Data.DbAnnotations); i++ {
if params.Data.DbAnnotations[i] != nil {
dbAnnotations[params.Data.DbAnnotations[i].Key] = params.Data.DbAnnotations[i].Value
}
modified = true
}
modified = true
}
dbNodeSelector := make(map[string]string)
for i := 0; i < len(params.Data.DbNodeSelector); i++ {
if params.Data.DbNodeSelector[i] != nil {
dbNodeSelector[params.Data.DbNodeSelector[i].Key] = params.Data.DbNodeSelector[i].Value
}
modified = true
}
logDBResourceRequest := make(corev1.ResourceList)
if reflect.TypeOf(params.Data.LogDBCPURequest).Kind() == reflect.String && params.Data.LogDBCPURequest != "0Gi" && params.Data.LogDBCPURequest != "" {
dbCPUQuantity, err := resource.ParseQuantity(params.Data.LogDBCPURequest)
if err != nil {
return false, restapi.ErrorWithContext(ctx, err)
}
logDBResourceRequest["cpu"] = dbCPUQuantity
minTenant.Spec.Log.Db.Resources.Requests = logDBResourceRequest
}
if reflect.TypeOf(params.Data.LogDBMemRequest).Kind() == reflect.String {
dbMemQuantity, err := resource.ParseQuantity(params.Data.LogDBMemRequest)
if err != nil {
return false, restapi.ErrorWithContext(ctx, err)
}
logDBResourceRequest["memory"] = dbMemQuantity
minTenant.Spec.Log.Db.Resources.Requests = logDBResourceRequest
}
minTenant.Spec.Log.Image = params.Data.Image
diskCapacityGB, err := strconv.Atoi(params.Data.DiskCapacityGB)
if err == nil {
if minTenant.Spec.Log.Audit != nil && minTenant.Spec.Log.Audit.DiskCapacityGB != nil {
*minTenant.Spec.Log.Audit.DiskCapacityGB = diskCapacityGB
} else {
minTenant.Spec.Log.Audit = &miniov2.AuditConfig{DiskCapacityGB: swag.Int(diskCapacityGB)}
}
}
minTenant.Spec.Log.ServiceAccountName = params.Data.ServiceAccountName
if params.Data.DbImage != "" || params.Data.DbServiceAccountName != "" {
modified = true
}
if modified {
if minTenant.Spec.Log.Db == nil {
// Default class name for Log search
diskSpaceFromAPI := int64(5) * humanize.GiByte // Default is 5Gi
logSearchStorageClass := "standard"
logSearchDiskSpace := resource.NewQuantity(diskSpaceFromAPI, resource.DecimalExponent)
minTenant.Spec.Log.Db = &miniov2.LogDbConfig{
VolumeClaimTemplate: &corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: params.Tenant + "-log",
},
Spec: corev1.PersistentVolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{
corev1.ReadWriteOnce,
},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceStorage: *logSearchDiskSpace,
},
},
StorageClassName: &logSearchStorageClass,
},
},
Labels: dbLabels,
Annotations: dbAnnotations,
NodeSelector: dbNodeSelector,
Image: params.Data.DbImage,
ServiceAccountName: params.Data.DbServiceAccountName,
Resources: corev1.ResourceRequirements{
Requests: minTenant.Spec.Log.Db.Resources.Requests,
},
if params.Data.DbNodeSelector != nil {
for i := 0; i < len(params.Data.DbNodeSelector); i++ {
if params.Data.DbNodeSelector[i] != nil {
dbNodeSelector[params.Data.DbNodeSelector[i].Key] = params.Data.DbNodeSelector[i].Value
}
modified = true
}
}
logDBResourceRequest := make(corev1.ResourceList)
if len(params.Data.LogDBCPURequest) > 0 {
if reflect.TypeOf(params.Data.LogDBCPURequest).Kind() == reflect.String && params.Data.LogDBCPURequest != "0Gi" && params.Data.LogDBCPURequest != "" {
dbCPUQuantity, err := resource.ParseQuantity(params.Data.LogDBCPURequest)
if err != nil {
return false, restapi.ErrorWithContext(ctx, err)
}
logDBResourceRequest["cpu"] = dbCPUQuantity
minTenant.Spec.Log.Db.Resources.Requests = logDBResourceRequest
}
}
if len(params.Data.LogDBMemRequest) > 0 {
if reflect.TypeOf(params.Data.LogDBMemRequest).Kind() == reflect.String && params.Data.LogDBMemRequest != "" {
dbMemQuantity, err := resource.ParseQuantity(params.Data.LogDBMemRequest)
if err != nil {
return false, restapi.ErrorWithContext(ctx, err)
}
logDBResourceRequest["memory"] = dbMemQuantity
minTenant.Spec.Log.Db.Resources.Requests = logDBResourceRequest
}
}
if len(params.Data.Image) > 0 {
minTenant.Spec.Log.Image = params.Data.Image
}
if params.Data.SecurityContext != nil {
minTenant.Spec.Log.SecurityContext, err = convertModelSCToK8sSC(params.Data.SecurityContext)
if err != nil {
return false, restapi.ErrorWithContext(ctx, err)
}
}
if len(params.Data.DiskCapacityGB) > 0 {
diskCapacityGB, err := strconv.Atoi(params.Data.DiskCapacityGB)
if err == nil {
if minTenant.Spec.Log.Audit != nil && minTenant.Spec.Log.Audit.DiskCapacityGB != nil {
*minTenant.Spec.Log.Audit.DiskCapacityGB = diskCapacityGB
} else {
minTenant.Spec.Log.Audit = &miniov2.AuditConfig{DiskCapacityGB: swag.Int(diskCapacityGB)}
}
}
}
if len(params.Data.ServiceAccountName) > 0 {
minTenant.Spec.Log.ServiceAccountName = params.Data.ServiceAccountName
}
if params.Data.DbLabels != nil {
if params.Data.DbImage != "" || params.Data.DbServiceAccountName != "" {
modified = true
}
if modified {
if minTenant.Spec.Log.Db == nil {
// Default class name for Log search
diskSpaceFromAPI := int64(5) * humanize.GiByte // Default is 5Gi
logSearchStorageClass := "standard"
logSearchDiskSpace := resource.NewQuantity(diskSpaceFromAPI, resource.DecimalExponent)
minTenant.Spec.Log.Db = &miniov2.LogDbConfig{
VolumeClaimTemplate: &corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: params.Tenant + "-log",
},
Spec: corev1.PersistentVolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{
corev1.ReadWriteOnce,
},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceStorage: *logSearchDiskSpace,
},
},
StorageClassName: &logSearchStorageClass,
},
},
Labels: dbLabels,
Annotations: dbAnnotations,
NodeSelector: dbNodeSelector,
Image: params.Data.DbImage,
ServiceAccountName: params.Data.DbServiceAccountName,
Resources: corev1.ResourceRequirements{
Requests: minTenant.Spec.Log.Db.Resources.Requests,
},
}
} else {
minTenant.Spec.Log.Db.Labels = dbLabels
minTenant.Spec.Log.Db.Annotations = dbAnnotations
minTenant.Spec.Log.Db.NodeSelector = dbNodeSelector
minTenant.Spec.Log.Db.Image = params.Data.DbImage
minTenant.Spec.Log.Db.InitImage = params.Data.DbInitImage
minTenant.Spec.Log.Db.ServiceAccountName = params.Data.DbServiceAccountName
minTenant.Spec.Log.Db.SecurityContext, err = convertModelSCToK8sSC(params.Data.DbSecurityContext)
if err != nil {
return false, restapi.ErrorWithContext(ctx, err)
}
}
} else {
minTenant.Spec.Log.Db.Labels = dbLabels
minTenant.Spec.Log.Db.Annotations = dbAnnotations
minTenant.Spec.Log.Db.NodeSelector = dbNodeSelector
minTenant.Spec.Log.Db.Image = params.Data.DbImage
minTenant.Spec.Log.Db.ServiceAccountName = params.Data.DbServiceAccountName
}
}
@@ -1639,7 +1760,6 @@ func enableTenantLoggingResponse(session *models.Principal, params operator_api.
return false, restapi.ErrorWithContext(ctx, err, restapi.ErrUnableToGetTenantUsage)
}
minTenant.EnsureDefaults()
// Default class name for Log search
diskSpaceFromAPI := int64(5) * humanize.GiByte // Default is 5Gi
logSearchStorageClass := "standard"
@@ -2094,11 +2214,10 @@ func getTenantMonitoringResponse(session *models.Principal, params operator_api.
client: opClientClientSet,
}
minInst, err := opClient.TenantGet(ctx, params.Namespace, params.Tenant, metav1.GetOptions{})
minInst, err := getTenant(ctx, opClient, params.Namespace, params.Tenant)
if err != nil {
return nil, restapi.ErrorWithContext(ctx, err)
}
monitoringInfo := &models.TenantMonitoringInfo{}
if minInst.Spec.Prometheus != nil {
@@ -2169,7 +2288,9 @@ func getTenantMonitoringResponse(session *models.Principal, params operator_api.
if len(minInst.Spec.Prometheus.SideCarImage) != 0 {
monitoringInfo.SidecarImage = minInst.Spec.Prometheus.SideCarImage
}
if minInst.Spec.Prometheus.SecurityContext != nil {
monitoringInfo.SecurityContext = convertK8sSCToModelSC(minInst.Spec.Prometheus.SecurityContext)
}
return monitoringInfo, nil
}
@@ -2263,12 +2384,16 @@ func setTenantMonitoringResponse(session *models.Principal, params operator_api.
if err == nil {
*minTenant.Spec.Prometheus.DiskCapacityDB = diskCapacityGB
}
minTenant.Spec.Prometheus.ServiceAccountName = params.Data.ServiceAccountName
minTenant.Spec.Prometheus.SecurityContext, err = convertModelSCToK8sSC(params.Data.SecurityContext)
if err != nil {
return false, restapi.ErrorWithContext(ctx, err)
}
_, err = opClient.TenantUpdate(ctx, minTenant, metav1.UpdateOptions{})
if err != nil {
return false, restapi.ErrorWithContext(ctx, err)
}
return true, nil
}
@@ -2637,15 +2762,28 @@ func parseTenantPool(pool *miniov2.Pool) *models.Pool {
var securityContext models.SecurityContext
if pool.SecurityContext != nil {
fsGroup := strconv.Itoa(int(*pool.SecurityContext.FSGroup))
runAsGroup := strconv.Itoa(int(*pool.SecurityContext.RunAsGroup))
runAsUser := strconv.Itoa(int(*pool.SecurityContext.RunAsUser))
var fsGroup string
var runAsGroup string
var runAsUser string
var fsGroupChangePolicy string
if pool.SecurityContext.FSGroup != nil {
fsGroup = strconv.Itoa(int(*pool.SecurityContext.FSGroup))
}
if pool.SecurityContext.RunAsGroup != nil {
runAsGroup = strconv.Itoa(int(*pool.SecurityContext.RunAsGroup))
}
if pool.SecurityContext.RunAsUser != nil {
runAsUser = strconv.Itoa(int(*pool.SecurityContext.RunAsUser))
}
if pool.SecurityContext.FSGroupChangePolicy != nil {
fsGroupChangePolicy = string(*pool.SecurityContext.FSGroupChangePolicy)
}
securityContext = models.SecurityContext{
FsGroup: &fsGroup,
RunAsGroup: &runAsGroup,
RunAsNonRoot: pool.SecurityContext.RunAsNonRoot,
RunAsUser: &runAsUser,
FsGroup: fsGroup,
RunAsGroup: &runAsGroup,
RunAsNonRoot: pool.SecurityContext.RunAsNonRoot,
RunAsUser: &runAsUser,
FsGroupChangePolicy: fsGroupChangePolicy,
}
}

View File

@@ -50,32 +50,42 @@ func convertModelSCToK8sSC(sc *models.SecurityContext) (*corev1.PodSecurityConte
if err != nil {
return nil, err
}
RunAsGroup, err := strconv.ParseInt(*sc.RunAsGroup, 10, 64)
runAsGroup, err := strconv.ParseInt(*sc.RunAsGroup, 10, 64)
if err != nil {
return nil, err
}
FsGroup, err := strconv.ParseInt(*sc.FsGroup, 10, 64)
fsGroup, err := strconv.ParseInt(sc.FsGroup, 10, 64)
if err != nil {
return nil, err
}
FSGroupChangePolicy := corev1.PodFSGroupChangePolicy(sc.FsGroupChangePolicy)
return &corev1.PodSecurityContext{
RunAsUser: &runAsUser,
RunAsGroup: &RunAsGroup,
RunAsNonRoot: sc.RunAsNonRoot,
FSGroup: &FsGroup,
RunAsUser: &runAsUser,
RunAsGroup: &runAsGroup,
RunAsNonRoot: sc.RunAsNonRoot,
FSGroup: &fsGroup,
FSGroupChangePolicy: &FSGroupChangePolicy,
}, nil
}
// convertK8sSCToModelSC validates and converts from corev1.PodSecurityContext to models.SecurityContext
func convertK8sSCToModelSC(sc *corev1.PodSecurityContext) *models.SecurityContext {
runAsUser := strconv.FormatInt(*sc.RunAsUser, 10)
RunAsGroup := strconv.FormatInt(*sc.RunAsGroup, 10)
FsGroup := strconv.FormatInt(*sc.FSGroup, 10)
runAsGroup := strconv.FormatInt(*sc.RunAsGroup, 10)
fsGroup := strconv.FormatInt(*sc.FSGroup, 10)
fsGroupPolicy := ""
if sc.FSGroupChangePolicy != nil {
fsGroupPolicy = string(*sc.FSGroupChangePolicy)
}
return &models.SecurityContext{
RunAsUser: &runAsUser,
RunAsGroup: &RunAsGroup,
RunAsNonRoot: sc.RunAsNonRoot,
FsGroup: &FsGroup,
RunAsUser: &runAsUser,
RunAsGroup: &runAsGroup,
RunAsNonRoot: sc.RunAsNonRoot,
FsGroup: fsGroup,
FsGroupChangePolicy: fsGroupPolicy,
}
}

View File

@@ -25,6 +25,22 @@ import (
"github.com/minio/pkg/env"
)
// ProviderConfig - OpenID IDP Configuration for console.
type ProviderConfig struct {
URL string
DisplayName string // user-provided - can be empty
ClientID, ClientSecret string
HMACSalt, HMACPassphrase string
Scopes string
Userinfo bool
RedirectCallbackDynamic bool
RedirectCallback string
}
type OpenIDPCfg map[string]ProviderConfig
var DefaultIDPConfig = "_"
func GetSTSEndpoint() string {
return strings.TrimSpace(env.Get(ConsoleMinIOServer, "http://localhost:9000"))
}

View File

@@ -206,6 +206,79 @@ func NewOauth2ProviderClient(scopes []string, r *http.Request, httpClient *http.
return client, nil
}
var defaultScopes = []string{"openid", "profile", "email"}
// NewOauth2ProviderClient instantiates a new oauth2 client using the
// `OpenIDPCfg` configuration struct. It returns a *Provider object that
// contains the necessary configuration to initiate an oauth2 authentication
// flow.
//
// We only support Authentication with the Authorization Code Flow - spec:
// https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth
func (o OpenIDPCfg) NewOauth2ProviderClient(name string, scopes []string, r *http.Request, httpClient *http.Client) (*Provider, error) {
ddoc, err := parseDiscoveryDoc(o[name].URL, httpClient)
if err != nil {
return nil, err
}
supportedResponseTypes := set.NewStringSet()
for _, responseType := range ddoc.ResponseTypesSupported {
// FIXME: ResponseTypesSupported is a JSON array of strings - it
// may not actually have strings with spaces inside them -
// making the following code unnecessary.
for _, s := range strings.Fields(responseType) {
supportedResponseTypes.Add(s)
}
}
isSupported := requiredResponseTypes.Difference(supportedResponseTypes).IsEmpty()
if !isSupported {
return nil, fmt.Errorf("expected 'code' response type - got %s, login not allowed", ddoc.ResponseTypesSupported)
}
// If provided scopes are empty we use the user configured list or a default
// list.
if len(scopes) == 0 {
scopesTmp := strings.Split(o[name].Scopes, ",")
for _, s := range scopesTmp {
w := strings.TrimSpace(s)
if w != "" {
scopes = append(scopes, w)
}
}
if len(scopes) == 0 {
scopes = defaultScopes
}
}
redirectURL := o[name].RedirectCallback
if o[name].RedirectCallbackDynamic {
// dynamic redirect if set, will generate redirect URLs
// dynamically based on incoming requests.
redirectURL = getLoginCallbackURL(r)
}
// add "openid" scope always.
scopes = append(scopes, "openid")
client := new(Provider)
client.oauth2Config = &xoauth2.Config{
ClientID: o[name].ClientID,
ClientSecret: o[name].ClientSecret,
RedirectURL: redirectURL,
Endpoint: oauth2.Endpoint{
AuthURL: ddoc.AuthEndpoint,
TokenURL: ddoc.TokenEndpoint,
},
Scopes: scopes,
}
client.ClientID = o[name].ClientID
client.UserInfo = o[name].Userinfo
client.provHTTPClient = httpClient
return client, nil
}
type User struct {
AppMetadata map[string]interface{} `json:"app_metadata"`
Blocked bool `json:"blocked"`

View File

@@ -67,11 +67,20 @@ type TokenClaims struct {
STSSessionToken string `json:"stsSessionToken,omitempty"`
AccountAccessKey string `json:"accountAccessKey,omitempty"`
HideMenu bool `json:"hm,omitempty"`
ObjectBrowser bool `json:"ob,omitempty"`
CustomStyleOB string `json:"customStyleOb,omitempty"`
}
// STSClaims claims struct for STS Token
type STSClaims struct {
AccessKey string `json:"accessKey,omitempty"`
}
// SessionFeatures represents features stored in the session
type SessionFeatures struct {
HideMenu bool
HideMenu bool
ObjectBrowser bool
CustomStyleOB string
}
// SessionTokenAuthenticate takes a session token, decode it, extract claims and validate the signature
@@ -115,7 +124,10 @@ func NewEncryptedTokenForClient(credentials *credentials.Value, accountAccessKey
}
if features != nil {
tokenClaims.HideMenu = features.HideMenu
tokenClaims.ObjectBrowser = features.ObjectBrowser
tokenClaims.CustomStyleOB = features.CustomStyleOB
}
encryptedClaims, err := encryptClaims(tokenClaims)
if err != nil {
return "", err
@@ -172,8 +184,9 @@ const (
// or data key provided as plaintext.
//
// The returned ciphertext data consists of:
// AEAD ID | iv | nonce | encrypted data
// 1 16 12 ~ len(data)
//
// AEAD ID | iv | nonce | encrypted data
// 1 16 12 ~ len(data)
func encrypt(plaintext, associatedData []byte) ([]byte, error) {
iv, err := sioutil.Random(16) // 16 bytes IV
if err != nil {

Some files were not shown because too many files have changed in this diff Show More