Commit Graph

33 Commits

Author SHA1 Message Date
Fraser Waters 705a2ae50b
Revert "allow URLs without template for downloading git repos ()" ()
Fixes https://github.com/pulumi/pulumi/issues/17862.

This reverts commit cfe2ccd36e.

---------

Co-authored-by: Julien <julien@caffeine.lu>
2024-11-26 13:39:16 +00:00
Thomas Gummerer cfe2ccd36e
allow URLs without template for downloading git repos ()
For remote plugins we want to allow URLs without a scheme to be used for
specifying the plugin location. We want to be consistent with this for
example for downloading templates in pulumi new.

Allow this parsing of Git URLs in the git utility.

---------

Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-11-21 15:29:38 +00:00
Thomas Gummerer 12c33dd47b
document GitCloneOrPull ()
While reading through this it took me a second to grok the signature, so
I figured it might be worth documenting it.
2024-11-19 09:59:32 +00:00
Thomas Gummerer 72123b8795
pass context to git clone utilities ()
Pass a context to the git clone utilities. In the future we want to be
able to use them to download plugins, which should be cancellable. Pass
the context through to allow this.

In theory this is not backwards compatible for this API, but we've
recently been allowing similar changes (e.g. in
https://github.com/pulumi/pulumi/pull/17621), so I think this is okay to
do.
2024-11-18 16:51:24 +00:00
Will Jones c496921d44
Enable some more linting rules ()
Issue  lists a number of extra linting checks that we could enable
in order to make our Go code more robust. This commit implements as many
as seem sensible:

* `durationcheck`, which checks for multiplication of `time.Duration`s,
which can lead to unexpected behaviour (e.g. `time.Second * time.Second`
is *not* one second)
* `goprintffuncname`, which checks that `Printf`-like functions are
appropriately suffixed with `f` to indicate as such
* `tenv`, which checks for `os.Setenv` in tests where `t.Setenv` is
generally a better solution
* `wastedassign`, which checks for assignments whose values are never
used (such as initial values before an `if` where both branches then
overwrite the value)
* `whitespace`, which checks for blank lines at the beginning and end of
blocks such as functions, `if`s, `for`s and so on.

This commit does *not* enable the following checks listed in :

* `wrapcheck`, which insists that third-party library errors are always
`%w`rapped -- we have a lot of cases where we don't do this and it's
probably a bit more involved than "just wrap them" in terms of making
sure we don't break anything (maybe)
* `predeclared`, which checks for shadowing of existing Go identifiers
-- we use `old` and `new` a lot, especially in step generation, so this
is probably a slightly bigger clean-up/one we might want to opt out of
* `mnd` (magic number detection) -- we have a lot of failures on this
* `nilnil` -- we only have a couple of failures on this; these could
probably be handled with `//nolint` but for now I've opted not to take
this route.
2024-10-03 17:37:13 +00:00
Julien ff5fe13fe2
Fix incorrect caching of git auth method in error cases ()
urlAuthParser.Parse caches auth methods. To avoid caching the auth
method when running into an error, we first checked that the auth method
is not nil. However we ran into a classic Go issue where a nil value of
a concrete type is assigned to a variable of an interface type, making 
it not equal to nil.

https://go.dev/doc/faq#nil_error

https://go.dev/play/p/AOSdCWd3XC1

Fixes https://github.com/pulumi/pulumi/issues/16637

---------

Co-authored-by: Thomas Gummerer <t.gummerer@gmail.com>
2024-07-16 14:53:32 +00:00
Germán Lena 956428f690
Update deployment settings git configuration to support directories that are not a git repo ()
Change how the deployment settings configures git repos to support
directories that are not git repositories

Fix https://github.com/pulumi/pulumi-service/issues/20675

---------

Co-authored-by: Levi Blackstone <levi@pulumi.com>
2024-07-11 14:14:18 +00:00
Germán Lena a7d5e238b8
New deployment settings wizards and environment variables management comands ()
- Turns `deployment settings init` command a wizard
- Adds new `deployment settings env` command to manage env variables
(including secrets encryption)
- Adds new `deployment settings set` command to configure individual
settings (including secrets encryption)

https://asciinema.org/a/QhuWHAvkmeAmVJkYqkCP0P6wb

Fix https://github.com/pulumi/pulumi-service/issues/20567
Fix https://github.com/pulumi/pulumi-service/issues/20576
2024-07-03 20:24:26 +00:00
Fraser Waters 0f4ddc2ccf
Use EqualError/ErrorContains instead of Error ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

This is a pass over all of /sdk to replace asserts that just checked we
had an error with asserts for what the error value is.

Just checking for an error is a weak test that can result in error paths
being broken and tests not detecting it.
2023-12-08 06:40:14 +00:00
Fraser Waters cf5b4a2790
Use `assert.NoError` rather than `assert.Nil` ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->
Likewise `require.NoError` instead of `require.Nil`, and `assert.Error`
rather than `assert.NotNil`.

The error variants of these functions print the errors nicer for test
failures using `Error()` rather than `GoString()`.

For bail errors this is _much_ better than the `result.Result` days
where we now get errors like:
```
Error:      	Received unexpected error:
            	BAIL: inner error
```
instead of:
```
Error:      	Expected nil, but got: &simpleResult{}
```

Also print the bail error in `TestPlan.Run` so we can see the
description of it.
2023-10-13 09:46:07 +00:00
Bryce Lampe 9a8a677a39 [cli/new] Support SSH-style Git URLs
This adds support for SSH-style Git URLs, enabling folks to use
private repos for their templates.

For instance,

    $ pulumi new git@github.com:acmecorp/templates/website

will now work as intended.

The `ssh_config` library handles finding the relevant SSH key for the
given host.

If the SSH key is protected by a password, the user will be prompted to
supply the password on-demand. (It is memoized to avoid asking multiple
times, as the template workflow requires using it more than once.) To
avoid prompting, the `PULUMI_GITSSH_PASSPHRASE` env var can be set.

Fixes  and .
2023-08-02 09:29:34 -07:00
Pat Gavlin 88290d8cb2 [cli] Add project root update metadata
These changes add the path to the current project relative to the root
of the VCS repository to update metadata. If VCS info is not available,
this metadata is not added.

Part of https://github.com/pulumi/home/issues/2946.
2023-07-17 17:06:41 -07:00
Fraser Waters ad8e095c74 sdk/go/common/util cleanup
Most of util, skips cmdutil and rpcutil
2023-03-10 08:49:00 +00:00
Justin Van Patten 487d1a03b8 cli: Fix issue with pulumi new and unstaged files 2022-10-27 22:39:31 +01:00
Fraser Waters 55d66c8bfb Report unstaged changes from GitCloneOrPull 2022-10-24 10:42:26 +01:00
杨成锴 7b09ad142a chore: Update doc comments, coding style, fix lint
* about error string: error string should not be capitalized or end with punctuation mark
* apply suggestions from code review
* lint: fix format error and simplify the code

Co-authored-by: Fraser Waters <frassle@gmail.com>
Co-authored-by: Aaron Friel <mayreply@aaronfriel.com>
2022-10-13 13:50:49 -07:00
Fraser Waters 3b97bf5788 Fix cloning from ADO repos
Small path bug, "git clone" by default clones to a new folder based on
the last part of the repo name. So running something like `pulumi new
https://fraser0275@dev.azure.com/fraser0275/fraser/_git/fraser` resulted
in us making a folder like /tmp/pulumi-templates-1234/fraser with all
the templates in it. That last part of the path was unexpected, because
when we use gogit it clones directly into the target directory we give
it.

Simple fix to just add `.` to the git clone command. I also added some
logging while I was about here, given it helped me work out this issue.
2022-10-07 08:27:46 +01:00
Kyle Dixler 7f38f05f0f
Merge remote-tracking branch 'origin/master' into dixler/6360/azure-devops 2022-09-23 10:06:29 -07:00
Kyle Dixler d14b4808be
removed url parsing 2022-09-23 07:19:05 -07:00
Kyle Dixler 3bda0057f4
initial version 2022-09-19 15:06:07 -07:00
avlllo 966508f6cd
Add token auth to git go module ()
* Add username/password support into git urls

* Add auth parser

* Add pending changelog

Co-authored-by: user <a.v.olshanskiy@tinkoff.ru>
Co-authored-by: Ian Wahbe <ian@wahbe.com>
2022-09-13 19:24:22 +02:00
Bryce Lampe 3d09e4e7c1
fix: handle .net and other domains in VCS detection () 2022-08-23 21:21:03 -07:00
Fraser Waters c9094f2ceb
Update go-git to v5 ()
* Update go-git to v5

* Add to CHANGELOG
2022-08-09 12:46:28 +01:00
Robbie McKinstry d706e9deb2
[sdk/go] Support nested git project paths ()
Support nested git project paths
2022-06-12 16:37:10 -04:00
Aaron Friel ed2923653c ci: radical idea - what if slow tests & no stdout makes GH consider runner dead? 2022-03-06 14:52:13 -08:00
Patrizio Bruno 9542709900
Set init.defaultBranch and user info in git tests ()
* tests: set init.defaultBranch and user info in git tests

* update CHANGELOG_PENDING.md
2022-02-10 15:59:31 +01:00
Ian Wahbe 7222e5570a
[cli] check main after master ()
* Allow specifying a branch with url#branch

* Probe for master and main

* Update CHANGELOG

* Fix linter errors

* Remove unnecessary feature

* Fix lint

* Update changelog to reflect new limited scope.

We only talk about the master -> main probing, because that is all the
PR does. It used to duplicate another feature.
2021-11-19 13:49:59 -08:00
svangordon-fruit 29fa23d6d9
Accept git remotes with periods in hostname ()
Fix `cloudSourceControlSSHRegex` so that it will match git remotes with periods or hyphens in the hostname. However, `azureSourceControlSSHRegex` _does_ match hostnames with a period. As a result, `TryGetVCSInfo` will treat these sorts of remotes as Azure source control remotes and drop the first group. This causes updates to have an incorrect `"vcs.kind"` field. For example, an update with a Git remote of `github.foo.acme.com` will have a `"vcs.kind"` field of `foo.acme.com`. This occurs if a user is using a self-hosted GH enterprise instance.
2021-08-01 10:47:44 -07:00
pulumi-bot 73a66f48ea [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
jetvova b4c2a3521c
Fixed issue (Missing Pulumi console tags on Windows) ()
Co-authored-by: Paul Stack <public@paulstack.co.uk>
2020-09-25 15:04:18 +01:00
CyrusNajmabadi 66bd3f4aa8
Breaking changes due to Feature 2.0 work
* Make `async:true` the default for `invoke` calls ()

* Switch away from native grpc impl. ()

* Remove usage of the 'deasync' library from @pulumi/pulumi. ()

* Only retry as long as we get unavailable back.  Anything else continues. ()

* Handle all errors for now. ()


* Do not assume --yes was present when using pulumi in non-interactive mode ()

* Upgrade all paths for sdk and pkg to v2

* Backport C# invoke classes and other recent gen changes ()

Adjust C# generation

* Replace IDeployment with a sealed class ()

Replace IDeployment with a sealed class

* .NET: default to args subtype rather than Args.Empty ()

* Adding system namespace for Dotnet code gen

This is required for using Obsolute attributes for deprecations

```
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'ObsoleteAttribute' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'Obsolete' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
```

* Fix the nullability of config type properties in C# codegen ()
2020-04-14 09:30:25 +01:00
evanboyle a4ec3ec81b move pkg/testing -> sdk/go/common/testing, leave behind pkg/testing/integration 2020-03-18 15:55:41 -07:00
evanboyle 0e9c5989bb move pkg/util/gitutil -> sdk/go/common/util/gitutil 2020-03-18 15:52:09 -07:00