Skip to content

Commit df664e3

Browse files
authored
Cjlapao/implement devops new schema (#74)
* Hotfix 271124-1 - Fixed some issues with the ensure processes where we could get nil pointers - Added a new process to delete vms that were created but the creation process failed - Added the enforce of the flag force_changes on the create where it will delete vms if the pre-exist - Fixed some issues with the getVms method where the id was not being escaped - Added a fix for the intel macs where we now add the user to the sudoers list if not present - Added a fix where if PD failed to install we would get an error with dependencies * added initial new schema for deployment * wip * fixed lint issues * Some minor improvements in stability and small - Fixed an issue where if the api stopped responding the provider would crash - Added better context timeout to the state and remote_vm providers
1 parent 3c0ccb7 commit df664e3

File tree

14 files changed

+750
-252
lines changed

14 files changed

+750
-252
lines changed
Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
# For most projects, this workflow file will not need changing; you simply need
2-
# to commit it to your repository.
3-
#
4-
# You may wish to alter this file to override the set of languages analyzed,
5-
# or to provide custom queries or build logic.
61
name: 'CodeQL'
72

83
on:
94
push:
105
branches: [main]
116
pull_request:
12-
# The branches below must be a subset of the branches above
137
branches: [main]
148
schedule:
159
- cron: '0 7 * * 2'
@@ -22,22 +16,17 @@ jobs:
2216
strategy:
2317
fail-fast: false
2418
matrix:
25-
# Override automatic language detection by changing the below list
26-
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
2719
language: ['go']
28-
# Learn more...
29-
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
3020

3121
steps:
3222
- name: Checkout repository
3323
uses: actions/checkout@v4
3424
with:
35-
# We must fetch at least the immediate parents so that if this is
36-
# a pull request then we can checkout the head.
3725
fetch-depth: 2
38-
39-
# If this run was triggered by a pull request event, then checkout
40-
# the head of the pull request instead of the merge commit.
26+
- name: Setup Go
27+
uses: actions/setup-go@v4
28+
with:
29+
go-version-file: 'go.mod'
4130
- run: git checkout HEAD^2
4231
if: ${{ github.event_name == 'pull_request' }}
4332

@@ -46,26 +35,8 @@ jobs:
4635
uses: github/codeql-action/init@v3
4736
with:
4837
languages: ${{ matrix.language }}
49-
# If you wish to specify custom queries, you can do so here or in a config file.
50-
# By default, queries listed here will override any specified in a config file.
51-
# Prefix the list here with "+" to use these queries and those in the config file.
52-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
53-
54-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55-
# If this step fails, then you should remove it and run the build manually (see below)
5638
- name: Autobuild
5739
uses: github/codeql-action/autobuild@v3
5840

59-
# ℹ️ Command-line programs to run using the OS shell.
60-
# 📚 https://git.io/JvXDl
61-
62-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63-
# and modify them (or add more) to build your code if your project
64-
# uses a compiled language
65-
66-
#- run: |
67-
# make bootstrap
68-
# make release
69-
7041
- name: Perform CodeQL Analysis
7142
uses: github/codeql-action/analyze@v3

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ website/vendor
3535
*.winfile eol=crlf
3636

3737
terraform-provider-*
38+
*.local.*
39+
*.tmp*
3840
.local/
39-
__debug*
41+
__debug*

CHANGELOG.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Changelog
2-
3-
All notable changes to this project will be documented in this file.
4-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5-
6-
## [0.5.10] - 2025-01-21
7-
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5+
6+
## [0.5.10] - 2025-01-21
7+
88
- Added a publish pipeline
99
- Fixed an issue with the generate-changelog.sh
1010
- Added an announcement automation for discord
@@ -34,7 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
- Fixed an issue where if we enabled the HTTPS for a host and registered it with an orchestrator, it would fail due to the wrong port
3535
- Added the new resource called vm_state to set an existing VM to a state
3636
- Fixed an issue in the telemetry not being sent correctly
37-
- Fixed #53 an issue where the specs where not being applied correctly if the machine was stop at some points
37+
- Fixed #53 an issue where the specs where not being applied correctly if the machine was stop at some points
3838
- Fixed an issue where the specs cpu_count and memory_count where not being calculated correctly
3939
- Resolved #54 Added the ability to use the vm datasource with the orchestrator
4040
- Resolved #58 Added the new shared block to allow port forwarding in the the following providers, clone_vm, remote_image, vagrant_box and deploy
@@ -51,24 +51,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5151
- Added an option to update the devops service in a deploy resource
5252
- fixed a bug where the deploy resource would update but failed to report correctly
5353
- Fixed an issue with the client apiresponse being empty
54-
- Added better error messages when checking for resources
54+
- Added better error messages when checking for resources
5555
- Fixed an issue where by mistake the remoteimage was reporting it did not support orchestrator
5656
- Fixed an issue where remote_vm, vagrant_box and clone_vm would fail if this was pointing to an orchestrator
5757
- Added the ability of only running post scripts if something changed on them
5858
- Added the ability to disbale tls validation for self signed certificates
5959
- Fixed an issue with the https format for the orchestrator
60-
61-
62-
## [0.2.2] - 2023-01-01
63-
64-
- Fixed an issue that was preventing the deployment from linux machines
65-
- Removed some unnecessary files
66-
67-
## [0.2.0] - 2023-01-01
68-
69-
FEATURES:
70-
71-
- Fixed some bugs
72-
- Added the ability to register a deployment with a orchestrator
73-
- Added the ability to run prlctl commands
74-
- Added the ability to run a script on destroy it
60+
61+
62+
## [0.2.2] - 2023-01-01
63+
64+
- Fixed an issue that was preventing the deployment from linux machines
65+
- Removed some unnecessary files
66+
67+
## [0.2.0] - 2023-01-01
68+
69+
FEATURES:
70+
71+
- Fixed some bugs
72+
- Added the ability to register a deployment with a orchestrator
73+
- Added the ability to run prlctl commands
74+
- Added the ability to run a script on destroy it

internal/apiclient/register_with_orchestrator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
func RegisterWithOrchestrator(ctx context.Context, config HostConfig, request apimodels.OrchestratorHostRequest) (*apimodels.OrchestratorHostResponse, diag.Diagnostics) {
1616
diagnostics := diag.Diagnostics{}
1717
urlHost := helpers.GetHostUrl(config.Host)
18-
url := helpers.GetHostApiVersionedBaseUrl(urlHost) + "%s/orchestrator/hosts"
18+
url := helpers.GetHostApiVersionedBaseUrl(urlHost) + "/orchestrator/hosts"
1919

2020
auth, err := authenticator.GetAuthenticator(ctx, urlHost, config.License, config.Authorization, config.DisableTlsValidation)
2121
if err != nil {

internal/apiclient/set_machine_state.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ func SetMachineState(ctx context.Context, config HostConfig, machineId string, o
4545
diagnostics = append(diagnostics, diag...)
4646
return false, diagnostics
4747
}
48+
if vm == nil {
49+
diagnostics.AddError("There was an error getting the vm", "vm is nil")
50+
return false, diagnostics
51+
}
4852

4953
if vm.State == string(op) {
5054
tflog.Info(ctx, fmt.Sprintf("Machine %s is already in state %s", machineId, op))

internal/deploy/devops_service.go

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/base64"
66
"encoding/json"
77
"fmt"
8+
"math/big"
89
"path/filepath"
910
"strings"
1011

@@ -509,7 +510,7 @@ func (c *DevOpsServiceClient) CompareLicenses(ctx context.Context, license strin
509510
return false, nil
510511
}
511512

512-
func (c *DevOpsServiceClient) InstallDevOpsService(ctx context.Context, license string, config models.ParallelsDesktopDevopsConfigV2) (string, error) {
513+
func (c *DevOpsServiceClient) InstallDevOpsService(ctx context.Context, license string, config models.ParallelsDesktopDevopsConfigV3) (string, error) {
513514
// Installing DevOps Service
514515

515516
devopsPath := c.findPath(ctx, "prldevops")
@@ -552,6 +553,37 @@ func (c *DevOpsServiceClient) InstallDevOpsService(ctx context.Context, license
552553
if config.EnablePortForwarding.ValueBool() {
553554
configFile.EnvironmentVariables["ENABLE_REVERSE_PROXY"] = "true"
554555
}
556+
// Setting the caching options for the service
557+
if config.CatalogCacheKeepFreeDiskSpace.ValueBigFloat() != nil {
558+
configValue := config.CatalogCacheKeepFreeDiskSpace.ValueBigFloat()
559+
zeroValue := big.NewFloat(0)
560+
if configValue.Cmp(zeroValue) == 1 {
561+
configFile.EnvironmentVariables["CATALOG_CACHE_KEEP_FREE_DISK_SPACE"] = config.CatalogCacheKeepFreeDiskSpace.ValueBigFloat().String()
562+
}
563+
}
564+
if config.CatalogCacheMaxSize.ValueBigFloat() != nil {
565+
configValue := config.CatalogCacheMaxSize.ValueBigFloat()
566+
zeroValue := big.NewFloat(0)
567+
if configValue.Cmp(zeroValue) == 1 {
568+
configFile.EnvironmentVariables["CATALOG_CACHE_MAX_SIZE"] = config.CatalogCacheMaxSize.ValueBigFloat().String()
569+
}
570+
}
571+
if config.CatalogCacheAllowCacheAboveKeepFreeDiskSpace.ValueBool() {
572+
configFile.EnvironmentVariables["CATALOG_CACHE_ALLOW_CACHE_ABOVE_KEEP_FREE_DISK_SPACE"] = "true"
573+
}
574+
if config.DisableCatalogCachingStream.ValueBool() {
575+
configFile.EnvironmentVariables["DISABLE_CATALOG_PROVIDER_STREAMING"] = "true"
576+
}
577+
578+
// Setting the logging options for the service
579+
if config.EnableLogging.ValueBool() {
580+
configFile.EnvironmentVariables["PRL_DEVOPS_LOG_TO_FILE"] = "true"
581+
}
582+
if config.LogPath.ValueString() != "" {
583+
configFile.EnvironmentVariables["PRL_DEVOPS_LOG_FILE_PATH"] = config.LogPath.ValueString()
584+
} else {
585+
configFile.EnvironmentVariables["PRL_DEVOPS_LOG_FILE_PATH"] = "."
586+
}
555587

556588
yamlConfig, err := yaml.Marshal(configFile)
557589
if err != nil {
@@ -704,7 +736,7 @@ func (c *DevOpsServiceClient) GenerateDefaultRootPassword(ctx context.Context) (
704736
return encoded, nil
705737
}
706738

707-
func (c *DevOpsServiceClient) generateConfigFile(config models.ParallelsDesktopDevopsConfigV2) (string, error) {
739+
func (c *DevOpsServiceClient) generateConfigFile(config models.ParallelsDesktopDevopsConfigV3) (string, error) {
708740
configPath := "/tmp/service_config.json"
709741
configMap := make(map[string]interface{})
710742
if config.Port.ValueString() != "" {
@@ -758,9 +790,6 @@ func (c *DevOpsServiceClient) generateConfigFile(config models.ParallelsDesktopD
758790
if config.SystemReservedDisk.ValueString() != "" {
759791
configMap["system_reserved_disk"] = config.SystemReservedDisk.ValueString()
760792
}
761-
if config.EnableLogging.ValueBool() {
762-
configMap["log_output"] = true
763-
}
764793

765794
jsonConfig, err := json.Marshal(configMap)
766795
if err != nil {

internal/deploy/models/common.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (p *ParallelsDesktopDevOps) MapObject() basetypes.ObjectValue {
7373
return types.ObjectValueMust(attributeTypes, attrs)
7474
}
7575

76-
func ApiConfigHasChanges(context context.Context, planState, currentState *ParallelsDesktopDevopsConfigV2) bool {
76+
func ApiConfigHasChanges(context context.Context, planState, currentState *ParallelsDesktopDevopsConfigV3) bool {
7777
if planState == nil && currentState == nil {
7878
return false
7979
}
@@ -162,6 +162,34 @@ func ApiConfigHasChanges(context context.Context, planState, currentState *Paral
162162
return true
163163
}
164164

165+
if planState.LogPath != currentState.LogPath {
166+
return true
167+
}
168+
169+
if planState.EnablePortForwarding != currentState.EnablePortForwarding {
170+
return true
171+
}
172+
173+
if planState.UseLatestBeta != currentState.UseLatestBeta {
174+
return true
175+
}
176+
177+
if planState.CatalogCacheAllowCacheAboveKeepFreeDiskSpace != currentState.CatalogCacheAllowCacheAboveKeepFreeDiskSpace {
178+
return true
179+
}
180+
181+
if planState.CatalogCacheKeepFreeDiskSpace != currentState.CatalogCacheKeepFreeDiskSpace {
182+
return true
183+
}
184+
185+
if planState.CatalogCacheMaxSize != currentState.CatalogCacheMaxSize {
186+
return true
187+
}
188+
189+
if planState.DisableCatalogCachingStream != currentState.DisableCatalogCachingStream {
190+
return true
191+
}
192+
165193
if len(planState.EnvironmentVariables) != len(currentState.EnvironmentVariables) {
166194
return true
167195
}

0 commit comments

Comments
 (0)