Skip to content

Commit

Permalink
Merge pull request #197 from loft-sh/DOC-196
Browse files Browse the repository at this point in the history
Adds autoSleep and autoDelete to platform vcluster.yaml docs
  • Loading branch information
zerbitx authored Jul 16, 2024
2 parents 538f64d + 215ffce commit 930e254
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 7 deletions.
58 changes: 56 additions & 2 deletions hack/platform/partials/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,60 @@ import (
// Config represents the external config for vcluster.yaml to generate associated partials
type Config struct {
External struct {
*config.PlatformConfig `json:"platform"`
Platform struct {
// APIKey defines where to find the platform access key and host. By default, vCluster will search in the following locations in this precedence:
// * platform.api.accessKey
// * environment variable called LICENSE
// * secret specified under external.platform.apiKey.secretName
// * secret called "vcluster-platform-api-key" in the vCluster namespace
APIKey config.PlatformAPIKey `json:"apiKey,omitempty"`

// AutoSleep holds configuration for automatic sleep and wakeup
// +optional
AutoSleep *AutoSleep `json:"autoSleep,omitempty"`

// AutoDelete holds configuration for automatic delete
// +optional
AutoDelete *AutoDelete `json:"autoDelete,omitempty"`
} `json:"platform"`
} `json:"external"`
}

type AutoSleep struct {
// AfterInactivity specifies after how many seconds of inactivity the virtual cluster should sleep
// +optional
AfterInactivity int64 `json:"afterInactivity,omitempty"`

// Schedule specifies scheduled virtual cluster sleep in Cron format, see https://en.wikipedia.org/wiki/Cron.
// Note: timezone defined in the schedule string will be ignored. Use ".Timezone" field instead.
// +optional
Schedule string `json:"schedule,omitempty"`

// Timezone specifies time zone used for scheduled virtual cluster operations. Defaults to UTC.
// Accepts the same format as time.LoadLocation() in Go (https://pkg.go.dev/time#LoadLocation).
// The value should be a location name corresponding to a file in the IANA Time Zone database, such as "America/New_York".
// +optional
Timezone string `json:"timezone,omitempty"`

// AutoSleep holds configuration for automatic wakeup
// +optional
AutoWakeup *AutoWakeup `json:"autoWakeup,omitempty"`
}

type AutoWakeup struct {
// Schedule specifies scheduled wakeup from sleep in Cron format, see https://en.wikipedia.org/wiki/Cron.
// Note: timezone defined in the schedule string will be ignored. The timezone for the autoSleep schedule will be
// used
// +optional
Schedule string `json:"schedule,omitempty"`
}

type AutoDelete struct {
// AfterInactivity specifies after how many seconds of inactivity the virtual cluster be deleted
// +optional
AfterInactivity int64 `json:"afterInactivity,omitempty"`
}

func main() {
_ = os.RemoveAll(util.BasePath)

Expand Down Expand Up @@ -904,7 +954,11 @@ spec:

util.DefaultRequire = false

paths := []string{"external/platform/apiKey"}
paths := []string{
"external/platform/apiKey",
"external/platform/autoSleep",
"external/platform/autoDelete",
}
for _, p := range paths {
util.GenerateFromPath(util.GenerateSchema(&Config{}), util.BasePath+"/config", p)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

## `apiKey` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">object</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> <span data-pro="false" className="config-field-pro">pro</span> {#apiKey}

APIKey defines where to find the platform access key and host. By default, vCluster will search in the following locations in this precedence:
* environment variable called LICENSE
* secret specified under external.platform.apiKey.secretName
* secret called "vcluster-platform-api-key" in the vCluster namespace


</summary>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

<details className="config-field" data-expandable="true">
<summary>

## `autoDelete` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">object</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> <span data-pro="false" className="config-field-pro">pro</span> {#autoDelete}



</summary>




<details className="config-field" data-expandable="false" open>
<summary>

### `afterInactivity` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">integer</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> <span data-pro="false" className="config-field-pro">pro</span> {#autoDelete-afterInactivity}



</summary>



</details>


</details>
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

<details className="config-field" data-expandable="true">
<summary>

## `autoSleep` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">object</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> <span data-pro="false" className="config-field-pro">pro</span> {#autoSleep}



</summary>




<details className="config-field" data-expandable="false" open>
<summary>

### `afterInactivity` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">integer</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> <span data-pro="false" className="config-field-pro">pro</span> {#autoSleep-afterInactivity}



</summary>



</details>



<details className="config-field" data-expandable="false" open>
<summary>

### `schedule` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">string</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> <span data-pro="false" className="config-field-pro">pro</span> {#autoSleep-schedule}



</summary>



</details>



<details className="config-field" data-expandable="false" open>
<summary>

### `timezone` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">string</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> <span data-pro="false" className="config-field-pro">pro</span> {#autoSleep-timezone}



</summary>



</details>



<details className="config-field" data-expandable="true">
<summary>

### `autoWakeup` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">object</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> <span data-pro="false" className="config-field-pro">pro</span> {#autoSleep-autoWakeup}



</summary>




<details className="config-field" data-expandable="false" open>
<summary>

#### `schedule` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">string</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> <span data-pro="false" className="config-field-pro">pro</span> {#autoSleep-autoWakeup-schedule}



</summary>



</details>


</details>


</details>
4 changes: 4 additions & 0 deletions platform/api/resources/vcluster-yaml/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ sidebar_label: vcluster.yaml
---

import ApiKey from '@site/platform/api/_partials/resources/config/external/platform/apiKey.mdx'
import AutoSleep from '@site/platform/api/_partials/resources/config/external/platform/autoSleep.mdx'
import AutoDelete from '@site/platform/api/_partials/resources/config/external/platform/autoDelete.mdx'

## Create a virtual cluster with a config file

Expand All @@ -14,4 +16,6 @@ please see [vcluster.yaml](/docs/vcluster/configure/vcluster-yaml).


<ApiKey />
<AutoSleep />
<AutoDelete />

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: apiKey
sidebar_label: apiKey
sidebar_position: 12
---

import ApiKey from '@site/platform/api/_partials/resources/config/external/platform/apiKey.mdx'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: autoDelete
sidebar_label: autoDelete
---

import AutoDelete from '@site/platform/api/_partials/resources/config/external/platform/autoDelete.mdx'

<AutoDelete />
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: autoSleep
sidebar_label: autoSleep
---

import AutoSleep from '@site/platform/api/_partials/resources/config/external/platform/autoSleep.mdx'

<AutoSleep />

0 comments on commit 930e254

Please sign in to comment.