-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EE Fix/support management repo policies (#1588)
* support management policy repo in EE
- Loading branch information
Showing
10 changed files
with
83 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package policy | ||
|
||
import ( | ||
core_policy "github.com/diggerhq/digger/cli/pkg/core/policy" | ||
"log" | ||
"net/http" | ||
"os" | ||
) | ||
|
||
type PolicyCheckerProviderBasic struct{} | ||
|
||
func (p PolicyCheckerProviderBasic) Get(hostname string, organisationName string, authToken string) (core_policy.Checker, error) { | ||
var policyChecker core_policy.Checker | ||
if os.Getenv("NO_BACKEND") == "true" { | ||
log.Println("WARNING: running in 'backendless' mode. No policies will be supported.") | ||
policyChecker = NoOpPolicyChecker{} | ||
} else { | ||
policyChecker = DiggerPolicyChecker{ | ||
PolicyProvider: &DiggerHttpPolicyProvider{ | ||
DiggerHost: hostname, | ||
DiggerOrganisation: organisationName, | ||
AuthToken: authToken, | ||
HttpClient: http.DefaultClient, | ||
}} | ||
} | ||
return policyChecker, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package policy | ||
|
||
import ( | ||
"fmt" | ||
core_policy "github.com/diggerhq/digger/cli/pkg/core/policy" | ||
"github.com/diggerhq/digger/cli/pkg/policy" | ||
"os" | ||
) | ||
|
||
type PolicyCheckerProviderAdvanced struct{} | ||
|
||
func (p PolicyCheckerProviderAdvanced) Get(hostname string, organisationName string, authToken string) (core_policy.Checker, error) { | ||
managementRepo := os.Getenv("DIGGER_MANAGEMENT_REPO") | ||
if managementRepo != "" { | ||
token := os.Getenv("GITHUB_TOKEN") | ||
if token == "" { | ||
return nil, fmt.Errorf("failed to get managent repo policy provider: GITHUB_TOKEN not specified") | ||
} | ||
return policy.DiggerPolicyChecker{ | ||
PolicyProvider: DiggerRepoPolicyProvider{ | ||
ManagementRepoUrl: managementRepo, | ||
GitToken: token, | ||
}, | ||
}, nil | ||
} | ||
return policy.PolicyCheckerProviderBasic{}.Get(hostname, organisationName, authToken) | ||
} |