Skip to content

Commit

Permalink
[DEVP-1980] post-merge fix-ups
Browse files Browse the repository at this point in the history
  • Loading branch information
bh-anton-k committed Jun 2, 2021
1 parent aae6259 commit 2723f83
Show file tree
Hide file tree
Showing 108 changed files with 23,769 additions and 252 deletions.
11 changes: 3 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2

prelude: &prelude
docker:
- image: golang:1.13-alpine
- image: golang:1.16-alpine
working_directory: ~/babylon

use_docker: &use_docker setup_remote_docker
Expand Down Expand Up @@ -44,7 +44,8 @@ workflows:
jobs:
- test:
<<: *not_master
- compile:
- build:
context: babylon
<<: *not_master

master-flow:
Expand All @@ -66,12 +67,6 @@ jobs:
- *install_base
- checkout
- run: babylon/build test
compile:
<<: *prelude
steps:
- *install_base
- checkout
- run: babylon/build compile
build:
<<: *prelude
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func ResourcePipelinePermissions() *schema.Resource {
func resourcePipelinePermissionsCreateOrUpdate(d *schema.ResourceData, m interface{}) error {
clients := m.(*client.AggregatedClient)

sn, err := securityhelper.NewSecurityNamespace(d, clients, securityhelper.SecurityNamespaceIDValues.Build, createBuildToken)
sn, err := securityhelper.NewSecurityNamespace(d, clients, securityhelper.SecurityNamespaceIDValues.Build, createBuildTokenBH)
if err != nil {
return err
}
Expand All @@ -55,7 +55,7 @@ func resourcePipelinePermissionsCreateOrUpdate(d *schema.ResourceData, m interfa
func resourcePipelinePermissionsRead(d *schema.ResourceData, m interface{}) error {
clients := m.(*client.AggregatedClient)

sn, err := securityhelper.NewSecurityNamespace(d, clients, securityhelper.SecurityNamespaceIDValues.Build, createBuildToken)
sn, err := securityhelper.NewSecurityNamespace(d, clients, securityhelper.SecurityNamespaceIDValues.Build, createBuildTokenBH)
if err != nil {
return err
}
Expand All @@ -77,7 +77,7 @@ func resourcePipelinePermissionsRead(d *schema.ResourceData, m interface{}) erro
func resourcePipelinePermissionsDelete(d *schema.ResourceData, m interface{}) error {
clients := m.(*client.AggregatedClient)

sn, err := securityhelper.NewSecurityNamespace(d, clients, securityhelper.SecurityNamespaceIDValues.Build, createBuildToken)
sn, err := securityhelper.NewSecurityNamespace(d, clients, securityhelper.SecurityNamespaceIDValues.Build, createBuildTokenBH)
if err != nil {
return err
}
Expand All @@ -89,7 +89,7 @@ func resourcePipelinePermissionsDelete(d *schema.ResourceData, m interface{}) er
return nil
}

func createBuildToken(d *schema.ResourceData, clients *client.AggregatedClient) (string, error) {
func createBuildTokenBH(d *schema.ResourceData, clients *client.AggregatedClient) (string, error) {
projectID, ok := d.GetOk("project_id")
if !ok {
return "", fmt.Errorf("failed to get 'project_id' from schema")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,47 @@ import (
* Begin unit tests
*/

func TestBuildPermissions_CreateBuildToken(t *testing.T) {
func TestBuildPermissions_CreateBuildTokenBH(t *testing.T) {
projectID := "9083e944-8e9e-405e-960a-c80180aa71e6"
buildID := "29"
expectedToken := fmt.Sprintf("%s/%s", projectID, buildID)

d := getBuildPermissionsResource(t, projectID, buildID, false)
gotToken, err := createBuildToken(d, nil)
gotToken, err := createBuildTokenBH(d, nil)
assert.NotEmpty(t, gotToken)
assert.Nil(t, err)
assert.Equal(t, expectedToken, gotToken)

expectedErr := fmt.Errorf("failed to get 'project_id' from schema")
d = getBuildPermissionsResource(t, "", "", false)
token, err := createBuildToken(d, nil)
token, err := createBuildTokenBH(d, nil)
assert.Empty(t, token)
assert.Equal(t, expectedErr, err)

expectedToken = fmt.Sprintf("%s", projectID)
d = getBuildPermissionsResource(t, projectID, "", true)
err = d.Set("build_id", nil)
token, err = createBuildToken(d, nil)
token, err = createBuildTokenBH(d, nil)
assert.NotEmpty(t, gotToken)
assert.Nil(t, err)
assert.Equal(t, expectedToken, token)

expectedErr = fmt.Errorf("build_id cannot be set when project_level is true")
d = getBuildPermissionsResource(t, projectID, "1234", true)
token, err = createBuildToken(d, nil)
token, err = createBuildTokenBH(d, nil)
assert.Empty(t, token)
assert.Equal(t, expectedErr, err)

expectedErr = fmt.Errorf("build_id required when project_level is not true")
d = getBuildPermissionsResource(t, projectID, "", false)
token, err = createBuildToken(d, nil)
token, err = createBuildTokenBH(d, nil)
assert.Empty(t, token)
assert.Equal(t, expectedErr, err)

expectedErr = fmt.Errorf("build_id required when project_level is not true")
d = getBuildPermissionsResource(t, projectID, "1234", false)
err = d.Set("build_id", nil)
token, err = createBuildToken(d, nil)
token, err = createBuildTokenBH(d, nil)
assert.Empty(t, token)
assert.Equal(t, expectedErr, err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/utils/tfhelper"
)

// ResourceServiceEndpointDockerRegistry schema and implementation for docker registry service endpoint resource
// ResourceServiceEndpointGenericWebhook schema and implementation for docker registry service endpoint resource
func ResourceServiceEndpointGenericWebhook() *schema.Resource {
r := genBaseServiceEndpointResource(flattenServiceEndpointGenericWebhook, expandServiceEndpointGenericWebhook)
r.Schema["url"] = &schema.Schema{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func Test_expandServiceEndpointGenericWebhook(t *testing.T) {
Owner: converter.String("library"),
Type: converter.String("generic"),
Url: converter.String("http://http.cat"),
Name: converter.String(""),
},
wantProject: converter.String("project"),
},
Expand Down
2 changes: 1 addition & 1 deletion azuredevops/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ func TestProvider_HasChildResources(t *testing.T) {
"azuredevops_serviceendpoint_bitbucket",
"azuredevops_serviceendpoint_kubernetes",
"azuredevops_serviceendpoint_aws",
"azuredevops_serviceendpoint_genericwebhook",
"azuredevops_serviceendpoint_artifactory",
"azuredevops_serviceendpoint_sonarqube",
"azuredevops_serviceendpoint_ssh",
"azuredevops_serviceendpoint_npm",
"azuredevops_serviceendpoint_genericwebhook",
"azuredevops_variable_group",
"azuredevops_git_repository",
"azuredevops_user_entitlement",
Expand Down
2 changes: 1 addition & 1 deletion babylon/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.13-alpine
FROM golang:1.16-alpine

RUN apk add bash git

Expand Down
3 changes: 3 additions & 0 deletions babylon/Dockerfile.sha
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ RUN \
&& pip3 install terraform-compliance==1.3.13 \
&& apk del zlib-dev xz-dev libxml2-dev libxslt-dev python3-dev build-base

# && apk cache clean
# fails with ERROR: Package cache is not enabled.

WORKDIR /opt/babylon
1 change: 1 addition & 0 deletions babylon/build
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ PLUGIN_DIR="babylon/terraform.d/plugins/babylonhealth.com/babylonhealth/${PROVID

run_compile() {
go mod download
go mod verify
go build
chmod +x "${BINARY_NAME}"
}
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ module github.com/microsoft/terraform-provider-azuredevops
go 1.16

require (
// patch versus microsoft-origin above
github.com/ahmetb/go-linq v3.0.0+incompatible
// patch versus microsoft-origin below
github.com/go-test/deep v1.0.3
github.com/golang/mock v1.4.4
github.com/golang/mock v1.4.1
github.com/google/go-cmp v0.5.2
github.com/google/uuid v1.1.1
github.com/hashicorp/go-multierror v1.0.0
Expand Down
Loading

0 comments on commit 2723f83

Please sign in to comment.