Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added local type #18

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion provider/cmd/pulumi-resource-aem/schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aem",
"version": "0.1.2-alpha.1718453175+e73fab23",
"version": "0.1.2-alpha.1718453293+5c68305a.dirty",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

"description": "Easily manage AEM instances in the cloud without a deep dev-ops knowledge",
"keywords": [
"pulumi",
Expand Down Expand Up @@ -195,6 +195,10 @@
"type": "boolean",
"description": "Enabled the AEM system service (systemd)."
},
"service_name": {
"type": "string",
"description": "Name of the AEM system service (systemd)."
},
"user": {
"type": "string",
"description": "System user under which AEM instance will be running. By default, the same as the user used to connect to the machine."
Expand Down
17 changes: 12 additions & 5 deletions provider/instance_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,15 @@ func (ic *InstanceClient) create() error {
return nil
}

func (ic *InstanceClient) serviceName() string {
if ic.data.System.ServiceName != "" {
return ic.data.System.ServiceName
}
return ServiceName
}

func (ic *InstanceClient) saveProfileScript() error {
envFile := fmt.Sprintf("/etc/profile.d/%s.sh", ServiceName)
envFile := fmt.Sprintf("/etc/profile.d/%s.sh", ic.serviceName())

systemEnvMap := ic.data.System.Env

Expand All @@ -104,7 +111,7 @@ func (ic *InstanceClient) saveProfileScript() error {
}

func (ic *InstanceClient) configureService() error {
if !ic.data.System.ServiceEnabled || ic.data.Client.Type == "local" {
if !ic.data.System.ServiceEnabled {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remeber such bool serviceEnabled in TF provider... why have you introduced it? these providers should not be so different

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

system service is must have; we want to maintain only the single and correct way of setting up AEM instances... maintaining variations will increase complexity

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm if serviceEnabled = false then runServiceCommand("start") need be replaced by "sh aemw instance launch" command and the similar thing for stopping

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for non-admin usages like on local/dev machine it would be fine

return nil
}

Expand All @@ -124,7 +131,7 @@ func (ic *InstanceClient) configureService() error {
if err != nil {
return fmt.Errorf("unable to template AEM system service definition: %w", err)
}
serviceFile := fmt.Sprintf("/etc/systemd/system/%s.service", ServiceName)
serviceFile := fmt.Sprintf("/etc/systemd/system/%s.service", ic.serviceName())
if err := ic.cl.FileWrite(serviceFile, serviceTemplated); err != nil {
return fmt.Errorf("unable to write AEM system service definition '%s': %w", serviceFile, err)
}
Expand All @@ -136,14 +143,14 @@ func (ic *InstanceClient) configureService() error {
}

func (ic *InstanceClient) runServiceAction(action string) error {
if !ic.data.System.ServiceEnabled || ic.data.Client.Type == "local" {
if !ic.data.System.ServiceEnabled {
return nil
}

ic.cl.Sudo = true
defer func() { ic.cl.Sudo = false }()

outBytes, err := ic.cl.RunShellCommand(fmt.Sprintf("systemctl %s %s.service", action, ServiceName), ".")
outBytes, err := ic.cl.RunShellCommand(fmt.Sprintf("systemctl %s %s.service", action, ic.serviceName()), ".")
if err != nil {
return fmt.Errorf("unable to perform AEM system service action '%s': %w", action, err)
}
Expand Down
2 changes: 2 additions & 0 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ type System struct {
WorkDir string `pulumi:"work_dir,optional"`
Env map[string]string `pulumi:"env,optional"`
ServiceEnabled bool `pulumi:"service_enabled,optional"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

ServiceName string `pulumi:"service_name,optional"`
ServiceConfig string `pulumi:"service_config,optional"`
User string `pulumi:"user,optional"`
Bootstrap *InstanceScript `pulumi:"bootstrap,optional"`
Expand All @@ -112,6 +113,7 @@ func (m *System) Annotate(a infer.Annotator) {
a.Describe(&m.WorkDir, "Remote root path where provider-related files will be stored.")
a.Describe(&m.Env, "Environment variables for AEM instances.")
a.Describe(&m.ServiceEnabled, "Enabled the AEM system service (systemd).")
a.Describe(&m.ServiceName, "Name of the AEM system service (systemd).")
a.Describe(&m.ServiceConfig, "Contents of the AEM system service definition file (systemd).")
a.Describe(&m.User, "System user under which AEM instance will be running. By default, the same as the user used to connect to the machine.")
a.Describe(&m.Bootstrap, "Script executed once upon instance connection, often for mounting on VM data volumes from attached disks (e.g., AWS EBS, Azure Disk Storage). This script runs only once, even during instance recreation, as changes are typically persistent and system-wide. If re-execution is needed, it is recommended to set up a new machine.")
Expand Down
6 changes: 6 additions & 0 deletions sdk/dotnet/Compose/Inputs/SystemArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public InputMap<string> Env
[Input("service_enabled")]
public Input<bool>? Service_enabled { get; set; }

/// <summary>
/// Name of the AEM system service (systemd).
/// </summary>
[Input("service_name")]
public Input<string>? Service_name { get; set; }

/// <summary>
/// System user under which AEM instance will be running. By default, the same as the user used to connect to the machine.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions sdk/dotnet/Compose/Outputs/System.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public sealed class System
/// </summary>
public readonly bool? Service_enabled;
/// <summary>
/// Name of the AEM system service (systemd).
/// </summary>
public readonly string? Service_name;
/// <summary>
/// System user under which AEM instance will be running. By default, the same as the user used to connect to the machine.
/// </summary>
public readonly string? User;
Expand All @@ -55,6 +59,8 @@ private System(

bool? service_enabled,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?


string? service_name,

string? user,

string? work_dir)
Expand All @@ -64,6 +70,7 @@ private System(
Env = env;
Service_config = service_config;
Service_enabled = service_enabled;
Service_name = service_name;
User = user;
Work_dir = work_dir;
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/dotnet/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.2-alpha.1718453175+e73fab23
0.1.2-alpha.1718453293+5c68305a.dirty
19 changes: 19 additions & 0 deletions sdk/go/aem/compose/pulumiTypes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions sdk/nodejs/types/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export namespace compose {
* Enabled the AEM system service (systemd).
*/
service_enabled?: pulumi.Input<boolean>;
/**
* Name of the AEM system service (systemd).
*/
service_name?: pulumi.Input<string>;
/**
* System user under which AEM instance will be running. By default, the same as the user used to connect to the machine.
*/
Expand Down
4 changes: 4 additions & 0 deletions sdk/nodejs/types/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export namespace compose {
* Enabled the AEM system service (systemd).
*/
service_enabled?: boolean;
/**
* Name of the AEM system service (systemd).
*/
service_name?: string;
/**
* System user under which AEM instance will be running. By default, the same as the user used to connect to the machine.
*/
Expand Down
16 changes: 16 additions & 0 deletions sdk/python/wttech_aem/compose/_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ def __init__(__self__, *,
env: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
service_config: Optional[pulumi.Input[str]] = None,
service_enabled: Optional[pulumi.Input[bool]] = None,
service_name: Optional[pulumi.Input[str]] = None,
user: Optional[pulumi.Input[str]] = None,
work_dir: Optional[pulumi.Input[str]] = None):
"""
Expand All @@ -259,6 +260,7 @@ def __init__(__self__, *,
:param pulumi.Input[Mapping[str, pulumi.Input[str]]] env: Environment variables for AEM instances.
:param pulumi.Input[str] service_config: Contents of the AEM system service definition file (systemd).
:param pulumi.Input[bool] service_enabled: Enabled the AEM system service (systemd).
:param pulumi.Input[str] service_name: Name of the AEM system service (systemd).
:param pulumi.Input[str] user: System user under which AEM instance will be running. By default, the same as the user used to connect to the machine.
:param pulumi.Input[str] work_dir: Remote root path where provider-related files will be stored.
"""
Expand All @@ -272,6 +274,8 @@ def __init__(__self__, *,
pulumi.set(__self__, "service_config", service_config)
if service_enabled is not None:
pulumi.set(__self__, "service_enabled", service_enabled)
if service_name is not None:
pulumi.set(__self__, "service_name", service_name)
if user is not None:
pulumi.set(__self__, "user", user)
if work_dir is not None:
Expand Down Expand Up @@ -337,6 +341,18 @@ def service_enabled(self) -> Optional[pulumi.Input[bool]]:
def service_enabled(self, value: Optional[pulumi.Input[bool]]):
pulumi.set(self, "service_enabled", value)

@property
@pulumi.getter
def service_name(self) -> Optional[pulumi.Input[str]]:
"""
Name of the AEM system service (systemd).
"""
return pulumi.get(self, "service_name")

@service_name.setter
def service_name(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "service_name", value)

@property
@pulumi.getter
def user(self) -> Optional[pulumi.Input[str]]:
Expand Down
12 changes: 12 additions & 0 deletions sdk/python/wttech_aem/compose/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ def __init__(__self__, *,
env: Optional[Mapping[str, str]] = None,
service_config: Optional[str] = None,
service_enabled: Optional[bool] = None,
service_name: Optional[str] = None,
user: Optional[str] = None,
work_dir: Optional[str] = None):
"""
Expand All @@ -282,6 +283,7 @@ def __init__(__self__, *,
:param Mapping[str, str] env: Environment variables for AEM instances.
:param str service_config: Contents of the AEM system service definition file (systemd).
:param bool service_enabled: Enabled the AEM system service (systemd).
:param str service_name: Name of the AEM system service (systemd).
:param str user: System user under which AEM instance will be running. By default, the same as the user used to connect to the machine.
:param str work_dir: Remote root path where provider-related files will be stored.
"""
Expand All @@ -295,6 +297,8 @@ def __init__(__self__, *,
pulumi.set(__self__, "service_config", service_config)
if service_enabled is not None:
pulumi.set(__self__, "service_enabled", service_enabled)
if service_name is not None:
pulumi.set(__self__, "service_name", service_name)
if user is not None:
pulumi.set(__self__, "user", user)
if work_dir is not None:
Expand Down Expand Up @@ -340,6 +344,14 @@ def service_enabled(self) -> Optional[bool]:
"""
return pulumi.get(self, "service_enabled")

@property
@pulumi.getter
def service_name(self) -> Optional[str]:
"""
Name of the AEM system service (systemd).
"""
return pulumi.get(self, "service_name")

@property
@pulumi.getter
def user(self) -> Optional[str]:
Expand Down