Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/rig-proto-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
"github.com/rigdev/rig/pkg/api/platform/v1": "platform/v1",
}
compiledTypes = []any{
v1.CapsuleStar{},
v1.Capsule{},
v1.CapsuleEnvironment{},
v1.Environment{},
v1.Project{},
Expand Down
109 changes: 55 additions & 54 deletions docs/docs/api/platform-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7834,9 +7834,9 @@ Empty response for updating users settings for the Rig project.



<a name="platform-v1-CapsuleEnvironment"></a>
<a name="platform-v1-Capsule"></a>

### CapsuleEnvironment
### Capsule



Expand All @@ -7846,104 +7846,87 @@ Empty response for updating users settings for the Rig project.
| apiVersion | [string](#string) | | |
| name | [string](#string) | | |
| project | [string](#string) | | |
| environment | [string](#string) | | |
| spec | [CapsuleSpecExtension](#platform-v1-CapsuleSpecExtension) | | |






<a name="platform-v1-CapsuleSpecExtension"></a>

### CapsuleSpecExtension



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| kind | [string](#string) | | |
| apiVersion | [string](#string) | | |
| image | [string](#string) | | |
| command | [string](#string) | | |
| args | [string](#string) | repeated | |
| interfaces | [v1alpha2.CapsuleInterface](#v1alpha2-CapsuleInterface) | repeated | |
| configFiles | [ConfigFile](#platform-v1-ConfigFile) | repeated | |
| environmentVariables | [EnvironmentVariables](#platform-v1-EnvironmentVariables) | | |
| scale | [v1alpha2.CapsuleScale](#v1alpha2-CapsuleScale) | | |
| nodeSelector | [CapsuleSpecExtension.NodeSelectorEntry](#platform-v1-CapsuleSpecExtension-NodeSelectorEntry) | repeated | |
| cronJobs | [v1alpha2.CronJob](#v1alpha2-CronJob) | repeated | |
| annotations | [CapsuleSpecExtension.AnnotationsEntry](#platform-v1-CapsuleSpecExtension-AnnotationsEntry) | repeated | |
| autoAddRigServiceAccounts | [bool](#bool) | | |
| spec | [CapsuleSpec](#platform-v1-CapsuleSpec) | | |
| environments | [Capsule.EnvironmentsEntry](#platform-v1-Capsule-EnvironmentsEntry) | repeated | |
| environmentRefs | [string](#string) | repeated | |






<a name="platform-v1-CapsuleSpecExtension-AnnotationsEntry"></a>
<a name="platform-v1-Capsule-EnvironmentsEntry"></a>

### CapsuleSpecExtension.AnnotationsEntry
### Capsule.EnvironmentsEntry



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| key | [string](#string) | | |
| value | [string](#string) | | |
| value | [CapsuleSpec](#platform-v1-CapsuleSpec) | | |






<a name="platform-v1-CapsuleSpecExtension-NodeSelectorEntry"></a>
<a name="platform-v1-CapsuleEnvironment"></a>

### CapsuleSpecExtension.NodeSelectorEntry
### CapsuleEnvironment



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| key | [string](#string) | | |
| value | [string](#string) | | |
| kind | [string](#string) | | |
| apiVersion | [string](#string) | | |
| name | [string](#string) | | |
| project | [string](#string) | | |
| environment | [string](#string) | | |
| spec | [CapsuleSpec](#platform-v1-CapsuleSpec) | | |






<a name="platform-v1-CapsuleStar"></a>
<a name="platform-v1-CapsuleSpec"></a>

### CapsuleStar
### CapsuleSpec



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| kind | [string](#string) | | |
| apiVersion | [string](#string) | | |
| name | [string](#string) | | |
| project | [string](#string) | | |
| capsuleBase | [CapsuleSpecExtension](#platform-v1-CapsuleSpecExtension) | | |
| environments | [string](#string) | repeated | |
| annotations | [CapsuleSpec.AnnotationsEntry](#platform-v1-CapsuleSpec-AnnotationsEntry) | repeated | |
| image | [string](#string) | | |
| command | [string](#string) | | |
| args | [string](#string) | repeated | |
| interfaces | [v1alpha2.CapsuleInterface](#v1alpha2-CapsuleInterface) | repeated | |
| files | [File](#platform-v1-File) | repeated | |
| env | [EnvironmentVariables](#platform-v1-EnvironmentVariables) | | |
| scale | [v1alpha2.CapsuleScale](#v1alpha2-CapsuleScale) | | |
| cronJobs | [v1alpha2.CronJob](#v1alpha2-CronJob) | repeated | |
| autoAddRigServiceAccounts | [bool](#bool) | | |






<a name="platform-v1-ConfigFile"></a>
<a name="platform-v1-CapsuleSpec-AnnotationsEntry"></a>

### ConfigFile
### CapsuleSpec.AnnotationsEntry



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| path | [string](#string) | | |
| content | [bytes](#bytes) | | |
| isSecret | [bool](#bool) | | |
| key | [string](#string) | | |
| value | [string](#string) | | |



Expand All @@ -7963,8 +7946,8 @@ Empty response for updating users settings for the Rig project.
| name | [string](#string) | | |
| namespaceTemplate | [string](#string) | | |
| operatorVersion | [string](#string) | | |
| clusterID | [string](#string) | | |
| capsuleBase | [ProjEnvCapsuleBase](#platform-v1-ProjEnvCapsuleBase) | | |
| cluster | [string](#string) | | |
| spec | [ProjEnvCapsuleBase](#platform-v1-ProjEnvCapsuleBase) | | |



Expand Down Expand Up @@ -8019,6 +8002,24 @@ Empty response for updating users settings for the Rig project.



<a name="platform-v1-File"></a>

### File



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| path | [string](#string) | | |
| asSecret | [bool](#bool) | | |
| bytes | [bytes](#bytes) | | |
| string | [string](#string) | | |






<a name="platform-v1-ProjEnvCapsuleBase"></a>

### ProjEnvCapsuleBase
Expand All @@ -8027,8 +8028,8 @@ Empty response for updating users settings for the Rig project.

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| configFiles | [ConfigFile](#platform-v1-ConfigFile) | repeated | |
| environmentVariables | [EnvironmentVariables](#platform-v1-EnvironmentVariables) | | |
| files | [File](#platform-v1-File) | repeated | |
| env | [EnvironmentVariables](#platform-v1-EnvironmentVariables) | | |



Expand All @@ -8047,7 +8048,7 @@ Empty response for updating users settings for the Rig project.
| apiVersion | [string](#string) | | |
| name | [string](#string) | | |
| environments | [string](#string) | repeated | |
| capsuleBase | [ProjEnvCapsuleBase](#platform-v1-ProjEnvCapsuleBase) | | |
| spec | [ProjEnvCapsuleBase](#platform-v1-ProjEnvCapsuleBase) | | |



Expand Down
32 changes: 16 additions & 16 deletions pkg/api/platform/v1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
k8sresource "k8s.io/apimachinery/pkg/api/resource"
)

func RolloutConfigToCapsuleSpecExtension(rc *capsule.RolloutConfig) (*platformv1.CapsuleSpecExtension, error) {
spec := &platformv1.CapsuleSpecExtension{
Kind: "CapsuleSpecExtension",
func RolloutConfigToCapsuleSpec(rc *capsule.RolloutConfig) (*platformv1.CapsuleSpec, error) {
spec := &platformv1.CapsuleSpec{
Kind: "CapsuleSpec",
ApiVersion: "v1", // TODO
Image: rc.GetImageId(),
Scale: &v1alpha2.CapsuleScale{
Expand All @@ -34,10 +34,10 @@ func RolloutConfigToCapsuleSpecExtension(rc *capsule.RolloutConfig) (*platformv1
}

for _, cf := range rc.GetConfigFiles() {
spec.ConfigFiles = append(spec.ConfigFiles, &platformv1.ConfigFile{
spec.Files = append(spec.Files, &platformv1.File{
Path: cf.GetPath(),
Content: cf.GetContent(),
IsSecret: cf.GetIsSecret(),
Bytes: cf.GetContent(),
AsSecret: cf.GetIsSecret(),
})
}

Expand Down Expand Up @@ -127,7 +127,7 @@ func HorizontalScaleConversion(horizontal *capsule.HorizontalScale, replicas uin
return res
}

func FeedContainerSettings(spec *platformv1.CapsuleSpecExtension, containerSettings *capsule.ContainerSettings) error {
func FeedContainerSettings(spec *platformv1.CapsuleSpec, containerSettings *capsule.ContainerSettings) error {
if spec.Scale == nil {
spec.Scale = &v1alpha2.CapsuleScale{}
}
Expand All @@ -136,7 +136,7 @@ func FeedContainerSettings(spec *platformv1.CapsuleSpecExtension, containerSetti
containerSettings.GetResources().GetLimits(),
containerSettings.GetResources().GetGpuLimits(),
)
spec.EnvironmentVariables = &platformv1.EnvironmentVariables{
spec.Env = &platformv1.EnvironmentVariables{
Direct: maps.Clone(containerSettings.GetEnvironmentVariables()),
}

Expand All @@ -145,7 +145,7 @@ func FeedContainerSettings(spec *platformv1.CapsuleSpecExtension, containerSetti
if err != nil {
return err
}
spec.EnvironmentVariables.Sources = append(spec.EnvironmentVariables.Sources, ref)
spec.Env.Sources = append(spec.Env.Sources, ref)
}
spec.Command = containerSettings.GetCommand()
spec.Args = containerSettings.GetArgs()
Expand Down Expand Up @@ -301,18 +301,18 @@ func makeVerticalScale(
return vs
}

func CapsuleSpecExtensionToRolloutConfig(spec *platformv1.CapsuleSpecExtension) (*capsule.RolloutConfig, error) {
func CapsuleSpecToRolloutConfig(spec *platformv1.CapsuleSpec) (*capsule.RolloutConfig, error) {
config := &capsule.RolloutConfig{
ImageId: spec.GetImage(),
Network: makeNetworks(spec.GetInterfaces()),
ContainerSettings: &capsule.ContainerSettings{
EnvironmentVariables: maps.Clone(spec.GetEnvironmentVariables().GetDirect()),
EnvironmentVariables: maps.Clone(spec.GetEnv().GetDirect()),
Command: spec.GetCommand(),
Args: spec.GetArgs(),
EnvironmentSources: makeEnvironmentSources(spec.GetEnvironmentVariables().GetSources()),
EnvironmentSources: makeEnvironmentSources(spec.GetEnv().GetSources()),
},
AutoAddRigServiceAccounts: spec.GetAutoAddRigServiceAccounts(),
ConfigFiles: makeConfigFiles(spec.GetConfigFiles()),
ConfigFiles: makeConfigFiles(spec.GetFiles()),
HorizontalScale: makeHorizontalScale(spec.GetScale().GetHorizontal()),
CronJobs: makeCronJobs(spec.GetCronJobs()),
Annotations: maps.Clone(spec.GetAnnotations()),
Expand Down Expand Up @@ -444,14 +444,14 @@ func makeHorizontalScale(spec *v1alpha2.HorizontalScale) *capsule.HorizontalScal
return res
}

func makeConfigFiles(configFiles []*platformv1.ConfigFile) []*capsule.ConfigFile {
func makeConfigFiles(configFiles []*platformv1.File) []*capsule.ConfigFile {
var res []*capsule.ConfigFile

for _, c := range configFiles {
res = append(res, &capsule.ConfigFile{
Path: c.GetPath(),
Content: c.GetContent(),
IsSecret: c.GetIsSecret(),
Content: c.GetBytes(),
IsSecret: c.GetAsSecret(),
})
}

Expand Down
28 changes: 14 additions & 14 deletions pkg/api/platform/v1/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ var (
}},
Annotations: map[string]string{"annotation": "value"},
}
spec = &platformv1.CapsuleSpecExtension{
Kind: "CapsuleSpecExtension",
spec = &platformv1.CapsuleSpec{
Kind: "CapsuleSpec",
ApiVersion: "v1",
Image: "image",
Command: "cmd",
Expand Down Expand Up @@ -229,18 +229,18 @@ var (
},
},
},
EnvironmentVariables: &platformv1.EnvironmentVariables{
Env: &platformv1.EnvironmentVariables{
Direct: map[string]string{"key1": "value1"},
Sources: []*platformv1.EnvironmentSource{{
Name: "some-map",
Kind: "ConfigMap",
}},
},
ConfigFiles: []*platformv1.ConfigFile{
Files: []*platformv1.File{
{
Path: "/etc/file1.yaml",
Content: []byte("hej"),
IsSecret: false,
Bytes: []byte("hej"),
AsSecret: false,
},
},
CronJobs: []*v1alpha2.CronJob{
Expand All @@ -260,28 +260,28 @@ var (
}
)

func Test_RolloutConfigToCapsuleSpecExtension(t *testing.T) {
spec2, err := RolloutConfigToCapsuleSpecExtension(rolloutConfig)
func Test_RolloutConfigToCapsuleSpec(t *testing.T) {
spec2, err := RolloutConfigToCapsuleSpec(rolloutConfig)
require.NoError(t, err)
require.Equal(t, spec, spec2)
}

func Test_CapsuleSpecExtensionToRolloutConfig(t *testing.T) {
config, err := CapsuleSpecExtensionToRolloutConfig(spec)
func Test_CapsuleSpecToRolloutConfig(t *testing.T) {
config, err := CapsuleSpecToRolloutConfig(spec)
require.NoError(t, err)
require.Equal(t, rolloutConfig, config)
}

func Test_conversion_both_ways(t *testing.T) {
config, err := CapsuleSpecExtensionToRolloutConfig(spec)
config, err := CapsuleSpecToRolloutConfig(spec)
require.NoError(t, err)
spec2, err := RolloutConfigToCapsuleSpecExtension(config)
spec2, err := RolloutConfigToCapsuleSpec(config)
require.NoError(t, err)
require.Equal(t, spec, spec2)

spec2, err = RolloutConfigToCapsuleSpecExtension(rolloutConfig)
spec2, err = RolloutConfigToCapsuleSpec(rolloutConfig)
require.NoError(t, err)
config, err = CapsuleSpecExtensionToRolloutConfig(spec2)
config, err = CapsuleSpecToRolloutConfig(spec2)
require.NoError(t, err)
require.Equal(t, rolloutConfig, config)

Expand Down
Loading