oun / pulumi-flux

Pulumi provider for FluxCD
Apache License 2.0
9 stars 2 forks source link

Missing docs, and suspected bug #11

Open devantler opened 11 months ago

devantler commented 11 months ago

File: themes/default/content/registry/packages/flux/_index.md

I am trying to configure a flux provider in C# to bootstrap my existing Flux files, but I am encountering a weird behaviour that might be a bug.

string githubOwner = "xxx";
string repoName = "xxx";
string branch = config.Require("flux_branch");
string path = $"k8s/clusters/{Deployment.Instance.StackName}";

// Read the private key from the local filesystems home directory.
string sshPrivateKey = File.ReadAllText(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".ssh", "id_rsa"));

var fluxProvider = new Provider("flux", new ProviderArgs
{
    Kubernetes = new ProviderKubernetesArgs
    {
        ConfigPath = "~/.kube/config",
        ConfigContextCluster = "k3d-cluster-local"
    },
    Git = new ProviderGitArgs
    {
        Url = $"ssh://github.com/{githubOwner}/{repoName}",
        Branch = branch,
        // This throws an error for either the PrivateKey or the Password. It differs
        Ssh = new ProviderGitSshArgs()
        {
            Username = "git",
            PrivateKey = new StringAsset(sshPrivateKey).ToString(),
            Password = "xxxx"
        }
    }
});

_ = new FluxBootstrapGit("flux",
    new FluxBootstrapGitArgs
    {
        Path = path
    },
    new CustomResourceOptions
    {
        Provider = fluxProvider,
    }
);

The code throws the following error:

error: cannot encode provider configuration to call ConfigureProvider: objectEncoder failed on property "git": objectEncoder failed on property "ssh": objectEncoder failed on property "password": Expected a string, got: {map[4dabf18193072939515e22adb298388d:{1b47061264138c4ac30d75fd1eb44270} value:{xxxx}]}

Would it be possible to add an example of configuring Flux with SSH and check if some misconfiguration has happened? I am wondering why the setter parsed my string values into maps.

oun commented 11 months ago

Could you refer to nodejs example in https://github.com/oun/pulumi-flux/blob/main/examples/nodejs/flux-bootstrap-git/index.ts ? Are you passing the right password for the ssh private key?

devantler commented 8 months ago

Sorry I newer answerered - I moved on from this and has since been using OCI as a source. This looks correct to me, and I am sure that I was passing the right password back then. Given the error I guess it might be mapping related to the C# provider . I have experienced this on other plugins.