Skip to content

Commit

Permalink
Add a basic passthrough kubeadm resource (#113)
Browse files Browse the repository at this point in the history
* Stub out all the files

* Dead simple kubeadm component
  • Loading branch information
UnstoppableMango authored Aug 11, 2024
1 parent 7ca583a commit 4b77220
Show file tree
Hide file tree
Showing 23 changed files with 1,217 additions and 0 deletions.
40 changes: 40 additions & 0 deletions provider/pkg/provider/kubeadm/kubeadm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package kubeadm

import (
"context"
"fmt"

"github.com/pulumi/pulumi-go-provider/infer"
pb "github.com/unmango/pulumi-baremetal/gen/go/unmango/baremetal/v1alpha1"
"github.com/unmango/pulumi-baremetal/provider/pkg/provider/cmd"
)

type KubeadmArgs struct {
cmd.ArgsBase

Commands []string `pulumi:"commands"`
}

func (a KubeadmArgs) Cmd() *pb.Command {
return Builder(func(b *cmd.B) {
for _, c := range a.Commands {
b.Arg(c)
}
})
}

type Kubeadm struct{}

type KubeadmState = cmd.State[KubeadmArgs]

// Create implements infer.CustomCreate.
func (Kubeadm) Create(ctx context.Context, name string, inputs cmd.CommandArgs[KubeadmArgs], preview bool) (string, KubeadmState, error) {
state := KubeadmState{}
if err := state.Create(ctx, inputs, preview); err != nil {
return name, state, fmt.Errorf("kubeadm: %w", err)
}

return name, state, nil
}

var _ = (infer.CustomCreate[cmd.CommandArgs[KubeadmArgs], KubeadmState])((*Kubeadm)(nil))
2 changes: 2 additions & 0 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
"github.com/unmango/pulumi-baremetal/provider/pkg/provider"
"github.com/unmango/pulumi-baremetal/provider/pkg/provider/coreutils"
"github.com/unmango/pulumi-baremetal/provider/pkg/provider/kubeadm"
)

const Name string = "baremetal"
Expand Down Expand Up @@ -51,6 +52,7 @@ func Provider() p.Provider {
infer.Resource[coreutils.Mv](),
infer.Resource[coreutils.Rm](),
infer.Resource[coreutils.Tee](),
infer.Resource[kubeadm.Kubeadm](),
},
Components: []infer.InferredComponent{
// Consuming external resources is no bueno atm
Expand Down
29 changes: 29 additions & 0 deletions sdk/dotnet/Kubeadm/Inputs/KubeadmArgsArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
using Pulumi;

namespace UnMango.Baremetal.Kubeadm.Inputs
{

public sealed class KubeadmArgsArgs : global::Pulumi.ResourceArgs
{
[Input("commands", required: true)]
private InputList<string>? _commands;
public InputList<string> Commands
{
get => _commands ?? (_commands = new InputList<string>());
set => _commands = value;
}

public KubeadmArgsArgs()
{
}
public static new KubeadmArgsArgs Empty => new KubeadmArgsArgs();
}
}
121 changes: 121 additions & 0 deletions sdk/dotnet/Kubeadm/Kubeadm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
using Pulumi;

namespace UnMango.Baremetal.Kubeadm
{
[BaremetalResourceType("baremetal:kubeadm:Kubeadm")]
public partial class Kubeadm : global::Pulumi.CustomResource
{
[Output("args")]
public Output<Outputs.KubeadmArgs> Args { get; private set; } = null!;

[Output("createdFiles")]
public Output<ImmutableArray<string>> CreatedFiles { get; private set; } = null!;

[Output("customDelete")]
public Output<ImmutableArray<string>> CustomDelete { get; private set; } = null!;

[Output("customUpdate")]
public Output<ImmutableArray<string>> CustomUpdate { get; private set; } = null!;

[Output("exitCode")]
public Output<int> ExitCode { get; private set; } = null!;

[Output("movedFiles")]
public Output<ImmutableDictionary<string, string>> MovedFiles { get; private set; } = null!;

[Output("stderr")]
public Output<string> Stderr { get; private set; } = null!;

[Output("stdout")]
public Output<string> Stdout { get; private set; } = null!;

[Output("triggers")]
public Output<ImmutableArray<object>> Triggers { get; private set; } = null!;


/// <summary>
/// Create a Kubeadm resource with the given unique name, arguments, and options.
/// </summary>
///
/// <param name="name">The unique name of the resource</param>
/// <param name="args">The arguments used to populate this resource's properties</param>
/// <param name="options">A bag of options that control this resource's behavior</param>
public Kubeadm(string name, KubeadmArgs args, CustomResourceOptions? options = null)
: base("baremetal:kubeadm:Kubeadm", name, args ?? new KubeadmArgs(), MakeResourceOptions(options, ""))
{
}

private Kubeadm(string name, Input<string> id, CustomResourceOptions? options = null)
: base("baremetal:kubeadm:Kubeadm", name, null, MakeResourceOptions(options, id))
{
}

private static CustomResourceOptions MakeResourceOptions(CustomResourceOptions? options, Input<string>? id)
{
var defaultOptions = new CustomResourceOptions
{
Version = Utilities.Version,
PluginDownloadURL = "github://api.github.com/unmango",
};
var merged = CustomResourceOptions.Merge(defaultOptions, options);
// Override the ID if one was specified for consistency with other language SDKs.
merged.Id = id ?? merged.Id;
return merged;
}
/// <summary>
/// Get an existing Kubeadm resource's state with the given name, ID, and optional extra
/// properties used to qualify the lookup.
/// </summary>
///
/// <param name="name">The unique name of the resulting resource.</param>
/// <param name="id">The unique provider ID of the resource to lookup.</param>
/// <param name="options">A bag of options that control this resource's behavior</param>
public static Kubeadm Get(string name, Input<string> id, CustomResourceOptions? options = null)
{
return new Kubeadm(name, id, options);
}
}

public sealed class KubeadmArgs : global::Pulumi.ResourceArgs
{
[Input("args", required: true)]
public Input<Inputs.KubeadmArgsArgs> Args { get; set; } = null!;

[Input("customDelete")]
private InputList<string>? _customDelete;
public InputList<string> CustomDelete
{
get => _customDelete ?? (_customDelete = new InputList<string>());
set => _customDelete = value;
}

[Input("customUpdate")]
private InputList<string>? _customUpdate;
public InputList<string> CustomUpdate
{
get => _customUpdate ?? (_customUpdate = new InputList<string>());
set => _customUpdate = value;
}

[Input("triggers")]
private InputList<object>? _triggers;
public InputList<object> Triggers
{
get => _triggers ?? (_triggers = new InputList<object>());
set => _triggers = value;
}

public KubeadmArgs()
{
}
public static new KubeadmArgs Empty => new KubeadmArgs();
}
}
25 changes: 25 additions & 0 deletions sdk/dotnet/Kubeadm/Outputs/KubeadmArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// *** WARNING: this file was generated by pulumi. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
using Pulumi;

namespace UnMango.Baremetal.Kubeadm.Outputs
{

[OutputType]
public sealed class KubeadmArgs
{
public readonly ImmutableArray<string> Commands;

[OutputConstructor]
private KubeadmArgs(ImmutableArray<string> commands)
{
Commands = commands;
}
}
}
Empty file added sdk/dotnet/Kubeadm/README.md
Empty file.
44 changes: 44 additions & 0 deletions sdk/go/baremetal/kubeadm/init.go

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

Loading

0 comments on commit 4b77220

Please sign in to comment.